Driver loading / unloading error if WinDbg is connected with a breakpoint

I just started with driver development. For some experiments with loading, unloading and debugging, I wrote the following simple driver:

#include <ntddk.h> 

void DriverUnload(PDRIVER_OBJECT pDriverObject) 
{ 
    UNREFERENCED_PARAMETER(pDriverObject);
    DbgPrint("Driver unloading\n"); 
} 

NTSTATUS DriverEntry( 
    PDRIVER_OBJECT DriverObject, 
    PUNICODE_STRING RegistryPath) 
{ 
    UNREFERENCED_PARAMETER(DriverObject);
    UNREFERENCED_PARAMETER(RegistryPath);

    DriverObject->DriverUnload = DriverUnload; 
    DbgPrint("Hello, World\n"); 

    return STATUS_SUCCESS; 
}

I compiled a driver for my target system, Windows 7 64bit, with debugging symbols, copied it to the target system and loaded and launched it using Loader Loader OSR.

Everything works fine, and I can unload and load the driver: enter image description here

I can connect to WinDbg using a serial connection, and I can successfully break and start the target system. However, the problem occurs when I try to set a breakpoint.

First I tried to set a breakpoint as follows:

kd> bp MyDriver1! Driverentry

, :

kd > bl
0 e fffff880`03572010 0001 (0001) < Unloaded_MyDriver1.sys > + 0x1010

, , (?), .

, , :

kd > bu MyDriver1

0 e fffff880`03578000 0001 (0001) MyDriver1! DriverEntry <PERF> (MyDriver1 + 0x0)

(net start MyDriver1), :

- 80000003 ( )


  • *
  • , *
  • CTRL + C ( ) *
  • CTRL + BREAK ( GUI), *
  • . *
  • *
  • *
  • *
  • , "g", *
  • "Enter". . *
  • "g" "Enter". *
  • *

nt! RtlpBreakWithStatusInstruction: fffff800 028ca490 cc int 3 kd > bu MyDriver1 kd> bl 0 e fffff880 03572010 0001

(0001) MyDriver1! DriverEntry <PERF> (MyDriver1 + 0x0)

kd > bc 0 kd > bl 1 e fffff880`03578000 0001 (0001)

MyDriver1! DriverEntry (MyDriver1 + 0x0)

kd > g - c0000005 (!!! !!!)

nt! IopUnloadDriver + 0x327: fffff800`02cb8b29 0fb74844 movzx

ecx, ptr [rax + 44h]

, , BSOD...

? ?

+3
1

, ,   sxe ld: MyDriver1

, , MyDriver1! DriverEntry DriverEntry.

bu MyDriver1 PE .

, , , - .

+5

Source: https://habr.com/ru/post/1524529/


All Articles