驱动代码很短,如下:
NTSTATUS DriverEntry(IN PDRIVER_OBJECT pDriverObj,IN PUNICODE_STRING pRegString)
{
int *pmodulelist,m;
pmodulelist=(int *)pDriverObj->DriverSection;
m=*(pmodulelist+0x30); \*这边有错啊*\
while(wcscmp((PWCHAR)m,L"ntoskrnl.exe")!=0)
{
m=*pmodulelist;
pmodulelist=(int *)m;
m=*(pmodulelist+0x30); \*这边有错啊*\
}
DbgPrint("module name is:%ws---address is:%x",(PWCHAR)m,*(pmodulelist+0x18));
return STATUS_SUCCESS;
}
这段代码是得到ntoskrnl.exe的基址和名称,并打印出来.程序通过DriverObject结构体中DriverSection成员指向LDR_DATA_TABLE_ENTRY结构,通过遍历这张表得到ntoskrnl的基址,不过我没有定义LDR_DATA_TABLE_ENTRY结构.
----------我是用DDK编译的--------------------------------
~~~~错误我已经找出来了,但不知道为什么会这样~~~~~~~~~
下面用IDA得到的反汇编代码:
text:000103B8 public DriverEntry
.text:000103B8 DriverEntry proc near
.text:000103B8
.text:000103B8 var_8 = dword ptr -8
.text:000103B8 var_4 = dword ptr -4
.text:000103B8 arg_0 = dword ptr 8
.text:000103B8
.text:000103B8 push ebp
.text:000103B9 mov ebp, esp
.text:000103BB sub esp, 8
.text:000103BE mov eax, [ebp+arg_0]
.text:000103C1 mov dword ptr [eax+34h], offset NT_unload
.text:000103C8 mov ecx, [ebp+arg_0]
.text:000103CB mov edx, [ecx+14h]
.text:000103CE mov [ebp+var_4], edx
.text:000103D1 mov eax, [ebp+var_4]
.text:000103D4 mov ecx, [eax+0C0h] \*就是这个地方和源程序中的第一个错误对应,不知道这个0C0h是怎么出来的,我的程序中是m=*(pmodulelist+0x30);,应该加30h才对啊,不知道怎么会这样的~~~*\
.text:000103DA mov [ebp+var_8], ecx
一定要帮帮我啊~~~~~~~~~~~~不胜感激~~~~~我实在没办法了~~~~~
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课