fazwh
驱动牛犊
驱动牛犊
  • 注册日期2005-09-11
  • 最后登录2020-11-18
  • 粉丝0
  • 关注0
  • 积分32分
  • 威望303点
  • 贡献值0点
  • 好评度48点
  • 原创分0分
  • 专家分0分
  • 社区居民
阅读:2890回复:2

windows 7 函数导出地址 与 Kernel32.dll不一样

楼主#
更多 发布于:2010-01-31 12:15
最近研究win7插apc启动进程,发现从kernel32.dll中导出的WinExec地址与实际地址不一样,有一个偏移值。不知是否有人知道。

我用的是win7 nt6.1.7600.16385 用exescope查看地址为0x77e6e695,而通过GetProcAddress查看到的地址每次都不一样,有一个偏移。是不是win7有什么新的改变?

vista上好象(记不太清楚)也有这个现象,但能通过kernel32中的地址启动程序。2k/xp/2k3上是一致的。

未发现这方面的文档,希望大牛们指点一二。
附件名称/大小 下载次数 最后更新
kernel32_win7.rar (337KB)  12 2010-01-31 12:15
fazwh
驱动牛犊
驱动牛犊
  • 注册日期2005-09-11
  • 最后登录2020-11-18
  • 粉丝0
  • 关注0
  • 积分32分
  • 威望303点
  • 贡献值0点
  • 好评度48点
  • 原创分0分
  • 专家分0分
  • 社区居民
沙发#
发布于:2010-01-31 12:48
自己给自己找答案了。分享一下。
http://www.harmonysecurity.com/blog/2009/06/retrieving-kernel32s-base-address.html

xor ebx, ebx // clear ebx
mov ebx, fs:[ 0x30 ] // get a pointer to the PEB
mov ebx, [ ebx + 0x0C ] // get PEB->Ldr
mov ebx, [ ebx + 0x1C ] // get PEB->Ldr.InInitializationOrderModuleList.Flink (1st entry)
mov ebx, [ ebx ] // get the next entry (2nd entry)
mov ebx, [ ebx + 0x08 ] // get the 2nd entries base address (kernel32.dll)

This method has worked for all versions of Windows from Windows 2000 up to and including Windows Vista. The introduction of Windows 7 (rc1) has broken this method of retrieving the kernel32 base address due to the new MinWin kernel structure employed by Windows 7. A new module kernelbase.dll is loaded before kernel32.dll and as such appears in the second entry of the InInitializationOrder module list.

To retrieve the kernel32.dll base address in a generic manner on all versions of Windows from Windows 2000 up to and including Windows 7 (rc1) a slightly modified approach can be used. Instead of parsing the PEB's InInitializationOrder module list, the InMemoryOrder module list can be parsed instead. The third entry in this list will always be that of kernel32.dll (The first being that of the main module and the second being that of ntdll.dll). The code used to retrieve the kernel32 base address based on this method is shown below:

xor ebx, ebx // clear ebx
mov ebx, fs:[ 0x30 ] // get a pointer to the PEB
mov ebx, [ ebx + 0x0C ] // get PEB->Ldr
mov ebx, [ ebx + 0x14 ] // get PEB->Ldr.InMemoryOrderModuleList.Flink (1st entry)
mov ebx, [ ebx ] // get the next entry (2nd entry)
mov ebx, [ ebx ] // get the next entry (3rd entry)
mov ebx, [ ebx + 0x10 ] // get the 3rd entries base address (kernel32.dll)
fazwh
驱动牛犊
驱动牛犊
  • 注册日期2005-09-11
  • 最后登录2020-11-18
  • 粉丝0
  • 关注0
  • 积分32分
  • 威望303点
  • 贡献值0点
  • 好评度48点
  • 原创分0分
  • 专家分0分
  • 社区居民
板凳#
发布于:2010-01-31 12:56
真是牛人,感谢一下。
游客

返回顶部