其实这是以前内容的复习,另外再通过dt 数据来获取结构和偏移量,手工在windbg中查看信息
程序:bz6
以前的驱动程序简直毫无驱动的样子,现在用个稍微健全的例子:
NTSTATUS DriverEntry(PDRIVER_OBJECT driver, PUNICODE_STRING reg_path)
{
NTSTATUS status;
#if DBG
_asm int 3
#endif
driver->DriverUnload = DriverUnload;
status = CreateDevice(driver);
Dump(driver);
return status;
}
CreateDevice(driver)是自定义函数,用来真正建立一个驱动设备。返回一个status,猜猜看,我们能不能在eax中读取返回值。
反汇编先:
kd> uf bz6!driverentry
bz6!DriverEntry [d:\mydriver\bz6\bz6.c @ 110]:
110 f8428680 8bff mov edi,edi
110 f8428682 55 push ebp
110 f8428683 8bec mov ebp,esp
110 f8428685 51 push ecx
114 f8428686 cc int 3
121 f8428687 8b4508 mov eax,dword ptr [ebp+8]
121 f842868a c74034d08442f8 mov dword ptr [eax+34h],offset bz6!DriverUnload (f84284d0)
123 f8428691 8b4d08 mov ecx,dword ptr [ebp+8]
123 f8428694 51 push ecx
123 f8428695 e876fdffff call bz6!CreateDevice (f8428410)
123 f842869a 8945fc mov dword ptr [ebp-4],eax
125 f842869d 8b5508 mov edx,dword ptr [ebp+8]
125 f84286a0 52 push edx
125 f84286a1 e8aafeffff call bz6!Dump (f8428550)
127 f84286a6 8b45fc mov eax,dword ptr [ebp-4]
128 f84286a9 8be5 mov esp,ebp
128 f84286ab 5d pop ebp
128 f84286ac c20800