Not quite a full answer, but here's code I use to work with a FILE_DEVICE_UNKNOWN device that just needs simple start/open/read/close ops. I use the following code to setup names for my device - "\\Device\\TestDriver4" is used to identify the device for the CreateService calls 'name of service' - (TestDriver4), while "\\DosDevices\\TDRV4" enables opening of the device with CreateFile as "\\.\TDRV4".
// internal device name - season to taste
#define TDRV4_INTERNAL_NAME L"\\Device\\TestDriver4"
// symbolic link name - seems to be necessary to use 'DosDevices'
// once in place (see call to IoCreateSymbolicLink in TDrv1_CreateDevice0)
// the CreateFile() API will be able to open our device as
// "\\\\.\\TDRV4" [ i.e. "\\.\TDRV4"]
#define TDRV4_SYMBOLICLINK_NAME L"\\DosDevices\\TDRV4"
In my drivers TDrv4_CreateDevice0 fn, the internal name is used in IoCreateDevice, and the symbolic name (aka file name) is used in the call to IoCreateSymbolicLink.
RtlInitUnicodeString( &ustrInternalName, TDRV4\_INTERNAL\_NAME);
// create the device
result = IoCreateDevice( pDriverObj, // From DriverEntry.
sizeof(TDRV4\_DEVICE\_EXTENSION), // Make us a block of non-paged pool
// large enough to store our extension data.
&ustrInternalName, // Any device object that can be
// the target of an I/O request or
// that a higher-level driver can
// connect to must have a DeviceName.
// An unnamed device object is visible
// only to the driver that created it
// or to an FSD through a volume parameter block (VPB).
// (ref \[NTDDK\])
FILE\_DEVICE\_UNKNOWN, // (We'd use FILE\_DEVICE\_SERIAL for a serial filter, e.g.)
0, // DeviceCharacteristics ignored.
FALSE, // Exclusive - if TRUE, thread IO calls serialized.
&pDevObj); // On return, will hold pointer to the new device object.
if(NT\_SUCCESS(result)) {
// stop chain
pDevObj->NextDevice = NULL;
pDevObj->AttachedDevice = NULL;
////