Hello! All,
I decided to try the way that pend the post read operation, queue it using cancel safe queue, and let a worker thread to read the data and then complete the intercepted operation.
So sad .... I got a BSOD. The result of "analyze -v" is at the end of the file. The cause seems be that I use Mutex to protect the queue and it reqires IRQL<=APC_LEVEL in order to call FltCbdqInsertIo.
Should I use spin lock instead to fix this problem? However, many posts here seem not recommend spin lock.
If I still use the mutex, that means I have to give up this read operation if IRQL level is not <=APC_LEVEL, which can cause my driver functionlity wrong.
If I will not pend the post read operation, I still can't carry on my driver's functionality because FltReadFile requires PASSIVE_LEVEL.
Can any one here tell me what I should do? Looking forward to hearing from you soon! I am quite stuck now.
Thank you.
Heidi
=============================================================================================
kd> !analyze -v
*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************
ATTEMPTED_SWITCH_FROM_DPC (b8)
A wait operation, attach process, or yield was attempted from a DPC routine.
This is an illegal operation and the stack track will lead to the offending
code and original DPC routine.
Arguments:
Arg1: 00000000, Original thread which is the cause of the failure
Arg2: 00000000, New thread
Arg3: 00000000, Stack address of the original thread
Arg4: 00000000
Debugging Details:
DEFAULT_BUCKET_ID: DRIVER_FAULT
BUGCHECK_STR: 0xB8
PROCESS_NAME: System
LAST_CONTROL_TRANSFER: from 804f7bad to 80527bec
STACK_TEXT:
f78b2750 804f7bad 00000003 f78b2aac 00000000 nt!RtlpBreakWithStatusInstruction
f78b279c 804f879a 00000003 862019f8 863b2020 nt!KiBugCheckDebugBreak+0x19
f78b2b7c 804f8ca0 000000b8 00000000 00000000 nt!KeBugCheck2+0x574
f78b2b9c 80541a47 000000b8 f78b2cd0 00000202 nt!KeBugCheck+0x14
f78b2bac 805417bf f78b2bd0 86200858 00000000 nt!SwapContext+0x157
f78b2bc0 804fb4a7 8055b17c 00000000 f78b2be4 nt!KiUnlockDispatcherDatabase+0x77
f78b2bd0 80534a7b 8055b17c 86013528 86200858 nt!KeInsertQueue+0x25
f78b2be4 bae324c9 86013528 00000001 86158b8c nt!ExQueueWorkItem+0x1b
f78b2bf8 f7887faa 86013528 86200858 f7887e56 fltMgr!FltQueueGenericWorkItem+0x49
f78b2c20 bae3222d 86013528 861bbe64 00000000 myMini!MyMiniCsqInsertIo+0x5a
f78b2c38 bae32c61 86158b4c 867e8e48 00000000 fltMgr!FltpInsertIrp+0x1d
f78b2c5c bae3231a 86158b4c 867e8e48 861ee2c0 fltMgr!FltpIoCsqInsertIrpEx+0x49
f78b2c7c f78876ea 86158b4c 861bbe64 861ee2c0 fltMgr!FltCbdqInsertIo+0x2c
f78b2ca0 f7887c5b f78b2d04 861ccc40 00000000 myMini!PendingReadIOForEncryption+0x7a
f78b2ce0 bae2bef3 861bbe64 f78b2d04 861ccc40 myMini!MyMiniPostReadBuffers+0x37
f78b2d48 bae2e338 001bbe08 867e8e48 861bbe08 fltMgr!FltpPerformPostCallbacks+0x1c5
f78b2d5c bae2e867 861bbe08 f78b2df4 f78b2d90 fltMgr!FltpProcessIoCompletion+0x10
f78b2d6c 8064d8b0 8607f020 867e8e48 861bbe08 fltMgr!FltpPassThroughCompletion+0x89
f78b2d90 804f06ae 8607f020 867e8e48 f78b2df4 nt!IovpLocalCompletionRoutine+0xb4
f78b2dc0 8064dd38 861df260 8637cb70 00000000 nt!IopfCompleteRequest+0xa2
f78b2e2c f74c7bf4 f78b2e5c f74c7ed4 8637cab8 nt!IovCompleteRequest+0x9a
f78b2e34 f74c7ed4 8637cab8 867e8e48 00000001 CLASSPNP!ClassCompleteRequest+0x11
f78b2e5c 8064d8b0 00000000 86d50f48 861df260 CLASSPNP!TransferPktComplete+0x180
f78b2e80 804f06ae 00000000 86d50f48 f78b2ee4 nt!IovpLocalCompletionRoutine+0xb4
f78b2eb0 8064dd38 86160008 86160008 861df30c nt!IopfCompleteRequest+0xa2
f78b2f1c bae4f8f8 863bcae8 86d50f48 f78b2f60 nt!IovCompleteRequest+0x9a
f78b2f2c bae4f436 86160008 00000001 00000000 SCSIPORT!SpCompleteRequest+0x5e
f78b2f60 bae4f6f7 863bcae8 86160008 f78b2fcf SCSIPORT!SpProcessCompletedRequest+0x632
f78b2fd0 80541b9d 863bcaa4 863bca30 00000000 SCSIPORT!ScsiPortCompletionDpc+0x2b5
f78b2ff4 8054186a f59a4934 00000000 00000000 nt!KiRetireDpcList+0x46
f78b2ff8 f59a4934 00000000 00000000 00000000 nt!KiDispatchInterrupt+0x2a
WARNING: Frame IP not in any known module. Following frames may be wrong.
8054186a 00000000 00000009 bb835675 00000128 0xf59a4934
STACK_COMMAND: kb
FOLLOWUP_IP:
myMini!myMiniCsqInsertIo+5a
f7887faa 8bd8 mov ebx,eax
FAULTING_SOURCE_CODE:
1060: Status = FltQueueGenericWorkItem( WorkItem,
1061: InstCtx->Instance,
1062: MyMiniPendingIOWorkItemRoutine,
1063: DelayedWorkQueue,
1064: InstCtx->Instance );
1065:
1066: if (!NT_SUCCESS(Status)) {
1067: LOG_PRINT(LOGFL_ERRORS,
1068: ("[MYMINI]: Failed to queue the work item (Status = 0x%x)\n",
1069: Status) );
SYMBOL_STACK_INDEX: 9
SYMBOL_NAME: myMini!MyMiniCsqInsertIo+5a
FOLLOWUP_NAME: MachineOwner
MODULE_NAME: myMini
IMAGE_NAME: myMini.sys
DEBUG_FLR_IMAGE_TIMESTAMP: 4af36a9b
FAILURE_BUCKET_ID: 0xB8_VRF_myMini!MyMiniCsqInsertIo+5a
BUCKET_ID: 0xB8_VRF_myMini!MyMiniCsqInsertIo+5a
Followup: MachineOwner