首页
社区
课程
招聘
[旧帖] [求助]一定要帮帮我啊,我都弄了两天了,实在不知道该怎么办,帮我调试一下啊 0.00雪花
发表于: 2008-12-20 18:28 3614

[旧帖] [求助]一定要帮帮我啊,我都弄了两天了,实在不知道该怎么办,帮我调试一下啊 0.00雪花

2008-12-20 18:28
3614
驱动代码很短,如下:
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直播授课

收藏
免费 0
支持
分享
最新回复 (5)
雪    币: 7
活跃值: (54)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
LZ你这句 pmodulelist=(int *)pDriverObj->DriverSection 如果目的是要取得DriverSection的指针话需要pmodulelist=(int *)(DriverObj->DriverSection)
2008-12-20 19:22
0
雪    币: 101
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
LZ基本功要练练了。
设有指向type类型的指针变量p,则有:
p+i <==> (char*)p + sizeof(type)*i

故:
m=*(pmodulelist+0x30)修改为m=*(int*)((char*)pmodulelist+0x30);
即可解决上叙问题。(且仅仅解决上叙问题)
2008-12-20 19:53
0
雪    币: 581
活跃值: (149)
能力值: ( LV12,RANK:600 )
在线值:
发帖
回帖
粉丝
4
下面的你自己改改
        PLDR_DATA_TABLE_ENTRY pDriverSection;
        PLDR_DATA_TABLE_ENTRY  pListHead;
       
        pDriverSection = pDriverObject->DriverSection;

        pListHead = (PLDR_DATA_TABLE_ENTRY)pDriverObject->DriverSection;

         pDriverSection = (PLDR_DATA_TABLE_ENTRY)pListHead->InLoadOrderLinks.Flink;

  

        while(pDriverSection != pListHead)
        {
                DbgPrint("0x%x %ws",pDriverSection->DllBase,pDriverSection->FullDllName.Buffer);
               
                pDriverSection = (PLDR_DATA_TABLE_ENTRY)pDriverSection->InLoadOrderLinks.Flink;
        }

如果是检测隐藏驱动的话...这种办法不行了
2008-12-20 20:27
0
雪    币: 101
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
楼上正解123456
2008-12-20 21:11
0
雪    币: 200
活跃值: (15)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
谢谢雁南飞和Sysnap ,也谢谢大家
2008-12-21 19:57
0
游客
登录 | 注册 方可回帖
返回
//