阅读:1172回复:0
Source for IoCancelIrp
@ebp+8 Irp
@ebp+4 call return address @ebp old_esp @ebp-4 OldIrql @ebp-8 pCancelRoutine nt!IoCancelIrp: 804e60cc 55 push ebp 804e60cd 8bec mov ebp,esp 804e60cf 51 push ecx 804e60d0 51 push ecx 804e60d1 803d1c55548000 cmp byte ptr [nt!IopVerifierOn (8054551c)],0x0//May be the verifier needs 804e60d8 56 push esi 804e60d9 8b7508 mov esi,[ebp+0x8] //Irp 804e60dc 0f85800d0300 jne nt!IoCancelIrp+0x12 (80516e62) //if nt!IopVerifierOn!=0 804e60e2 8d45fc lea eax,[ebp-0x4] 804e60e5 50 push eax //&OldIrql 804e60e6 e8fb540000 call nt!IoAcquireCancelSpinLock (804eb5e6) 804e60eb 8d4638 lea eax,[esi+0x38] //&Irp->CancelRoutine 804e60ee c6462401 mov byte ptr [esi+0x24],0x1 //Irp->Cancel=TRUE 804e60f2 8945f8 mov [ebp-0x8],eax //pCancelRoutine=&Irp->CancelRoutine 804e60f5 b800000000 mov eax,0x0 804e60fa 8b4df8 mov ecx,[ebp-0x8] 804e60fd 8701 xchg [ecx],eax //interlocakedexchange Irp->CancelRoutine=NULL 804e60ff 85c0 test eax,eax //Irp->CancelRoutine?=NULL 804e6101 0f84fe5c0200 je nt!IoCancelIrp+0x71 (8050be05)//No NULL 804e6107 8a4e22 mov cl,[esi+0x22] //Irp->StackCount 804e610a fec1 inc cl 804e610c 384e23 cmp [esi+0x23],cl//CurrentLocation 804e610f 0f8f670d0300 jnle nt!IoCancelIrp+0x50 (80516e7c)//KeBugCheckEx if not equal 804e6115 8a4dfc mov cl,[ebp-0x4]//OldIrql 804e6118 884e25 mov [esi+0x25],cl//Irp->CancelIrql 804e611b 8b4e60 mov ecx,[esi+0x60]//Irp->CurrentStackLocation 804e611e 56 push esi //Irp 804e611f ff7114 push dword ptr [ecx+0x14]//CurrentStackLocation->DeviceObject 804e6122 ffd0 call eax //CancelRoutine 804e6124 b001 mov al,0x1 //return TRUE 804e6126 5e pop esi 804e6127 c9 leave 804e6128 c20400 ret 0x4 8050be05 ff75fc push dword ptr [ebp-0x4] 8050be08 e8ccf7fdff call nt!IoReleaseCancelSpinLock (804eb5d9) 8050be0d 32c0 xor al,al //return FALSE 8050be0f e912a3fdff jmp nt!IoCancelIrp+0x7b (804e6126) 80516e7c 6a00 push 0x0 80516e7e 6a00 push 0x0 80516e80 6a00 push 0x0 80516e82 56 push esi 80516e83 6a48 push 0x48 80516e85 e838080100 call nt!KeBugCheckEx (805276c2) 80516e8a cc int 3 So if ignore the jump and bugcheck //This is the C code for IoCancelIrp BOOLEAN IoCancelIrp(PIRP pIrp) { KIRQL OldIrql; PDRIVER_CANCEL pCancelRoutine; IoAcquireCancelSpinLock(&OldIrql); pIrp->Cancel=TRUE; pCancelRoutine=IoSetCancelRoutine(pIrp,NULL) if(pCancelRoutine==NULL) { IoReleaseCancelSpinLock(&OldIrql); return FALSE; } else { // Do BugCheck() if the CurrentStackLocation is not right Irp->CancelIrql=OldIrql;//CurrentIrql who called this function pCancelRoutine(Irp->CurrentStackLocation->DeviceObject,pIrp); //Pay attention that this function doesn\'t call IoReleaseCancelSpinLock return TRUE; } } |
|