Hi,
First of all, thanks for the replies.
Tony, I used WinObj utility, and APfilter does occur in the list of objects in the GLOBAL?? folder. This should mean that APfilter is installed in correct location, as other devices like /DosDevices/C: also appear as C: in that folder. This was also apparent from the fact that error was not ERROR_FILE_NOT_FOUND.
Maxim, I have dispatch routines registered for all IRPs, and most of them just pass through the IRP (exceptions are in the listing below). Is this what you meant? Also, how would that make a difference, as I am not sending an IRP yet, just creating a handle?
The listing below shows how I register for all IRPs.
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) {
DriverObject->MajorFunction[i] = SfPassThrough;
}
//
// We will use SfCreate for all the create operations
//
DriverObject->MajorFunction[IRP_MJ_CREATE] = SfCreate;
DriverObject->MajorFunction[IRP_MJ_CREATE_NAMED_PIPE] = SfCreate;
DriverObject->MajorFunction[IRP_MJ_CREATE_MAILSLOT] = SfCreate;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = UserModeHandle;
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = SfFsControl;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = SfCleanupClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = SfCleanupClose;
Also, here is an example of a very similar thing which DOES WORK:
CreateFile call:
hDevice = CreateFile(
“\\.\Event_Sample”, // lpFileName
GENERIC_READ | GENERIC_WRITE, // dwDesiredAccess
FILE_SHARE_READ | FILE_SHARE_WRITE, // dwShareMode
NULL, // lpSecurityAttributes
OPEN_EXISTING, // dwCreationDistribution
0, // dwFlagsAndAttributes
NULL // hTemplateFile
);
DriverEntry section:
//
// Create the device object
//
RtlInitUnicodeString( &ntDeviceName, NTDEVICE_NAME_STRING );
status = IoCreateDevice(
DriverObject, // DriverObject
sizeof( DEVICE_EXTENSION ), // DeviceExtensionSize
&ntDeviceName, // DeviceName
FILE_DEVICE_UNKNOWN, // DeviceType
FILE_DEVICE_SECURE_OPEN, // DeviceCharacteristics
FALSE, // Not Exclusive
&deviceObject // DeviceObject
);
if ( !NT_SUCCESS(status) ) {
DebugPrint((“\tIoCreateDevice returned 0x%x\n”, status));
return( status );
}
//
// Set up dispatch entry points for the driver.
//
DriverObject->MajorFunction[IRP_MJ_CREATE] =
DriverObject->MajorFunction[IRP_MJ_CLOSE] = EventCreateClose;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = EventCleanup;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = EventDispatchIoControl;
DriverObject->DriverUnload = EventUnload;
//
// Create a symbolic link for userapp to interact with the driver.
//
RtlInitUnicodeString( &symbolicLinkName, SYMBOLIC_NAME_STRING );
status = IoCreateSymbolicLink( &symbolicLinkName, &ntDeviceName );
if ( !NT_SUCCESS(status) ) {
IoDeleteDevice( deviceObject );
DebugPrint((“\tIoCreateSymbolicLink returned 0x%x\n”, status));
return( status );
}
I am perplexed. Please help!
P.S. I’ve just been doing windows programming 3 days. It would be kind if replies were more descriptive.
Thanks,
Aman