Ok here is my story… I am modifying the i8042prt.sys driver (mouse
port driver) that comes with the DDK so as to get data directly from the
driver to my application. On NT this had proven to be not as difficult of
a task as it has on 2000. Following is what I have tried and what I have
run against.
First I simply named my device in the AddDevice routine, tested it
successfully and then tried creating a symbolic link the old fashion way
in the “AddDevice” routine itself. This caused both the mouse and keyboard
to not work (drv probably never loaded). So I decided to use
IoRegisterDeviceInterface() instead, again in the AddDevice routine.
I called the IoSetDeviceInterfaceState(pdo, true) in response to the
IRP_MN_START_DEVICE irp. The interface registered yet I was not able to
use CreateFile. It always failed except when I deleted the GENERIC_READ
flag leaving GENERIC_WRITE only in the call. Even so the handle so
obtained when used with the ReadFile() and WriteFile() failed to read or
write, of course. I then tried both REGISTERING and enabling the
interfaces in I8xMouseStartDevice routine of the sample (called in
response to IRP_MN_START_DEVICE irp). Again I was able to register but
had the same problem with CreateFile().
I then tried both naming and registering the device, which previously I
was not able to do when I was registering the device in the AddDevice
routine. This time it worked though, yet I had the same problem with
CreateFile. So I tried creating a symbolic link to my named device from
the user application using DefineDosDevice(DDD_RAW_TARGET_PATH,
“somename”, \Device\Optic01), this succeeded. Yet the CreateFile had
the same problem.
I have gone through the registry to see if there were some keys causing
this problem, have found none. I used a utility called Devview.exe, that
came with a book i bought, to look at the security on the device objects
and Under “Allow To everyone” it said, FILE_READ_DATA, FILE_WRITE_DATA
along with other attributes. So for all practical purposes it should
work. Dose anyone have any idea as to what I may be doing wrong here?
I’ve been working at this problem for a while now and am now getting
desperate, any help would be greatly appreciated.
drv_hndl = CreateFile(&dev_path_array[0][0],
/*GENERIC_READ|*/GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0,
NULL);
Kernel level
dev_index = InterlockedIncrement(&last_index);
_snwprintf(name, NAME_SIZE, L"\Device\Optic%2.2d",
dev_index);
RtlInitUnicodeString(&dev_name, name);
status = IoCreateDevice(Driver, // driver
maxSize, // size of extension
&dev_name, // device name
FILE_DEVICE_8042_PORT, // device type ??
unknown at this time!!!
,
// device characteristics
FALSE, // exclusive
&device // new device
);
Registration process in I8xMouseStart
status = IoRegisterDeviceInterface(MouseExtension->PDO,
&GUID_DEVCLASS_MOUSE, NULL, &MouseExtension->sys_mou_interface);
if (NT_SUCCESS(status))
status = IoSetDeviceInterfaceState(&MouseExtension->sys_mou_interface,
TRUE);
if (!NT_SUCCESS(status))
goto I8xMouseStartDeviceExit;