From: unclepauly on 27 May 2010 16:43 hello, i am modifying the diskperf sample in the wdk so that i can communicate with it from user land. the diskperf sample is WDM. at the end of DriverEntry, i do: RtlInitUnicodeString( &ntUnicodeString, NT_DEVICE_NAME ); status = IoCreateDevice(DriverObject, 0, &ntUnicodeString, FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, FALSE, &deviceObject ); where NT_DEVICE_NAME is defined as : #define NT_DEVICE_NAME L"\\Device\\DiskPerfTest" then i set up the symbolic link. then, in the IRP_MJ_DEVICE_CONTROL handler, i do a check for some IOCTRL code i made up: if (currentIrpStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_DISKFILTR_MY_CODE) { //user-land has spoken to us ! DbgPrint("!!!! HERE !!!!"); Irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(Irp, IO_NO_INCREMENT); return STATUS_SUCCESS; } so....in my test app, i simply do: HANDLE hDevice = CreateFile( "\\\\.\\DiskPerfTest", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); then i can send it the IOCTRL by doing: DeviceIoControl ( hDevice, (DWORD) IOCTL_DISKFILTR_MY_CODE, NULL, 0, NULL, 0, NULL, NULL); when i run the test app, in DebugView, i can see the above line of code being hit, ie the driver is receiving the IOCTL_DISKFILTR_MY_CODE from the test app. the problem is, when the test app's main() exits, i get a blue screen (the error is in the diskperf driver). i put a _getch() at the end of the main() function and all is definitely good until main exits. the problem can be reproduced even when i remove my IOCTRL from the driver, and remove the DeviceIoControl call from the test app. in other words the following code reproduces the blue screen: VOID __cdecl main(__in ULONG argc, __in_ecount(argc) PCHAR argv[]) { HANDLE hDevice; UNREFERENCED_PARAMETER(argc); UNREFERENCED_PARAMETER(argv); hDevice = CreateFileA("\\\\.\\DiskPerfTest", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if(hDevice == INVALID_HANDLE_VALUE) { //report the problem } } to clarify, i can actually create a handle to the filter driver, and i can send it IOCTRLs..but the driver crashes when the main() function ends. has anyone any idea what the problem is from the info i have given, if not i can provide more info/code if required. thank you.
From: Doron Holan [MSFT] on 27 May 2010 18:58 you are probably not handling IRP_MJ_CLEANUP and _CLOSE properly. in those two IRP dispatch routines you need to check if the irp is sent to the control devobj and if so, complete it immediatley, otherwise send it down the stack. also, this check if (currentIrpStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_DISKFILTR_MY_CODE) is not enough. you need a top level check if the io is sent to the control devobj and if so and if the IOCTL value is unrecognized, complete it immediately (vs what your default case right now does which sends it down the stack) d "unclepauly" wrote in message news:F7730F3B-70F6-4BDD-A8B0-280ABC9B0322(a)microsoft.com... hello, i am modifying the diskperf sample in the wdk so that i can communicate with it from user land. the diskperf sample is WDM. at the end of DriverEntry, i do: RtlInitUnicodeString( &ntUnicodeString, NT_DEVICE_NAME ); status = IoCreateDevice(DriverObject, 0, &ntUnicodeString, FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, FALSE, &deviceObject ); where NT_DEVICE_NAME is defined as : #define NT_DEVICE_NAME L"\\Device\\DiskPerfTest" then i set up the symbolic link. then, in the IRP_MJ_DEVICE_CONTROL handler, i do a check for some IOCTRL code i made up: if (currentIrpStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_DISKFILTR_MY_CODE) { //user-land has spoken to us ! DbgPrint("!!!! HERE !!!!"); Irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(Irp, IO_NO_INCREMENT); return STATUS_SUCCESS; } so....in my test app, i simply do: HANDLE hDevice = CreateFile( "\\\\.\\DiskPerfTest", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); then i can send it the IOCTRL by doing: DeviceIoControl ( hDevice, (DWORD) IOCTL_DISKFILTR_MY_CODE, NULL, 0, NULL, 0, NULL, NULL); when i run the test app, in DebugView, i can see the above line of code being hit, ie the driver is receiving the IOCTL_DISKFILTR_MY_CODE from the test app. the problem is, when the test app's main() exits, i get a blue screen (the error is in the diskperf driver). i put a _getch() at the end of the main() function and all is definitely good until main exits. the problem can be reproduced even when i remove my IOCTRL from the driver, and remove the DeviceIoControl call from the test app. in other words the following code reproduces the blue screen: VOID __cdecl main(__in ULONG argc, __in_ecount(argc) PCHAR argv[]) { HANDLE hDevice; UNREFERENCED_PARAMETER(argc); UNREFERENCED_PARAMETER(argv); hDevice = CreateFileA("\\\\.\\DiskPerfTest", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if(hDevice == INVALID_HANDLE_VALUE) { //report the problem } } to clarify, i can actually create a handle to the filter driver, and i can send it IOCTRLs..but the driver crashes when the main() function ends. has anyone any idea what the problem is from the info i have given, if not i can provide more info/code if required. thank you.
From: unclepauly on 28 May 2010 08:59 thank you thats fixed it ;) "Doron Holan [MSFT]" wrote: > you are probably not handling IRP_MJ_CLEANUP and _CLOSE properly. in those > two IRP dispatch routines you need to check if the irp is sent to the > control devobj and if so, complete it immediatley, otherwise send it down > the stack. > > also, this check > > if (currentIrpStack->Parameters.DeviceIoControl.IoControlCode == > IOCTL_DISKFILTR_MY_CODE) > > is not enough. you need a top level check if the io is sent to the control > devobj and if so and if the IOCTL value is unrecognized, complete it > immediately (vs what your default case right now does which sends it down > the stack) > > d > "unclepauly" wrote in message > news:F7730F3B-70F6-4BDD-A8B0-280ABC9B0322(a)microsoft.com... > > hello, > > i am modifying the diskperf sample in the wdk so that i can communicate with > it from user land. the diskperf sample is WDM. at the end of DriverEntry, i > do: > > RtlInitUnicodeString( &ntUnicodeString, NT_DEVICE_NAME ); > status = IoCreateDevice(DriverObject, 0, &ntUnicodeString, > FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, FALSE, &deviceObject ); > > where NT_DEVICE_NAME is defined as : > > #define NT_DEVICE_NAME L"\\Device\\DiskPerfTest" > > then i set up the symbolic link. then, in the IRP_MJ_DEVICE_CONTROL handler, > i do a check for some IOCTRL code i made up: > > if (currentIrpStack->Parameters.DeviceIoControl.IoControlCode == > IOCTL_DISKFILTR_MY_CODE) > { > //user-land has spoken to us ! > DbgPrint("!!!! HERE !!!!"); > > Irp->IoStatus.Status = STATUS_SUCCESS; > IoCompleteRequest(Irp, IO_NO_INCREMENT); > return STATUS_SUCCESS; > } > > > so....in my test app, i simply do: > > HANDLE hDevice = CreateFile( "\\\\.\\DiskPerfTest", GENERIC_READ | > GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); > > then i can send it the IOCTRL by doing: > > DeviceIoControl ( hDevice, (DWORD) IOCTL_DISKFILTR_MY_CODE, NULL, 0, NULL, > 0, NULL, NULL); > > when i run the test app, in DebugView, i can see the above line of code > being hit, ie the driver is receiving the IOCTL_DISKFILTR_MY_CODE from the > test app. > the problem is, when the test app's main() exits, i get a blue screen (the > error is in the diskperf driver). i put a _getch() at the end of the main() > function and all is definitely good until main exits. > > the problem can be reproduced even when i remove my IOCTRL from the driver, > and remove the DeviceIoControl call from the test app. in other words the > following code reproduces the blue screen: > > VOID __cdecl main(__in ULONG argc, __in_ecount(argc) PCHAR argv[]) > { > HANDLE hDevice; > > UNREFERENCED_PARAMETER(argc); > UNREFERENCED_PARAMETER(argv); > > hDevice = CreateFileA("\\\\.\\DiskPerfTest", GENERIC_READ | > GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); > > > if(hDevice == INVALID_HANDLE_VALUE) > { > //report the problem > } > } > > to clarify, i can actually create a handle to the filter driver, and i can > send it IOCTRLs..but the driver crashes when the main() function ends. > > has anyone any idea what the problem is from the info i have given, if not i > can provide more info/code if required. > > thank you. > > . >
|
Pages: 1 Prev: : PCI and PCIe in WMDF Next: DPC's and its schedulers in multiprocessor environment |