某些Zw*和Nt*函数既在ntdll.dll中导出又在ntoskrnl.exe中导出,他们有什么区别呢?
我们分三部分比较:
step 1: ntdll.dll中的Zw*和Nt*有什么区别?
step 2: ntoskrnl.exe中的Zw*和Nt*有什么区别?
step 3: ntdll.dll中的Zw*与ntoskrnl.exe中的Zw*有什么区别? 
        ntdll.dll中的Nt*与ntoskrnl.exe中的Nt*有什么区别?
在下面的讨论中我们以ZwCreateFile和NtCreateFile为例

讨论前:我先贴点Kd给我们的答案
Part1:
kd> u Ntdll! ZwCreateFile L4
ntdll!ZwCreateFile:
77f87cac b820000000       mov     eax,0x20
77f87cb1 8d542404         lea     edx,[esp+0x4]
77f87cb5 cd2e             int     2e
77f87cb7 c22c00           ret     0x2c
kd> u Ntdll! NtCreateFile L4
ntdll!ZwCreateFile:
77f87cac b820000000       mov     eax,0x20
77f87cb1 8d542404         lea     edx,[esp+0x4]
77f87cb5 cd2e             int     2e
77f87cb7 c22c00           ret     0x2c

Part2:
kd> u Nt!ZwCreateFile L4
nt!ZwCreateFile:
8042fa70 b820000000       mov     eax,0x20
8042fa75 8d542404         lea     edx,[esp+0x4]
8042fa79 cd2e             int     2e
8042fa7b c22c00           ret     0x2c
kd> u Nt!NtCreateFile L14
nt!NtCreateFile:
804a7172 55               push    ebp
804a7173 8bec             mov     ebp,esp
804a7175 33c0             xor     eax,eax
804a7177 50               push    eax
804a7178 50               push    eax
804a7179 50               push    eax
804a717a ff7530           push    dword ptr [ebp+0x30]
804a717d ff752c           push    dword ptr [ebp+0x2c]
804a7180 ff7528           push    dword ptr [ebp+0x28]
804a7183 ff7524           push    dword ptr [ebp+0x24]
804a7186 ff7520           push    dword ptr [ebp+0x20]
804a7189 ff751c           push    dword ptr [ebp+0x1c]
804a718c ff7518           push    dword ptr [ebp+0x18]
804a718f ff7514           push    dword ptr [ebp+0x14]
804a7192 ff7510           push    dword ptr [ebp+0x10]
804a7195 ff750c           push    dword ptr [ebp+0xc]
804a7198 ff7508           push    dword ptr [ebp+0x8]
804a719b e8b284ffff       call    nt!IoCreateFile (8049f652)
804a71a0 5d               pop     ebp
804a71a1 c22c00           ret     0x2c

1) Part1 输出的是Ntdll.dll中ZwCreateFile和NtCreateFile的汇编代码,我们发现实现是一样的;
eax是中断号,edx是函数的参数起始地址([Esp]是返回地址);从而我可以大胆的说:Ntdll.dll中ZwCreateFile和NtCreateFile功能是一样的作用:都是调用int 2E中断;

IDA给我们的答案:
.text:77F87CAC ; Exported entry  92. NtCreateFile
.text:77F87CAC ; Exported entry 740. ZwCreateFile
.text:77F87CAC
.text:77F87CAC
.text:77F87CAC                 public ZwCreateFile
.text:77F87CAC ZwCreateFile    proc near               ;
.text:77F87CAC
.text:77F87CAC arg_0           = dword ptr  4
.text:77F87CAC
.text:77F87CAC                 mov     eax, 20h        ; NtCreateFile
.text:77F87CB1                 lea     edx, [esp+arg_0]
.text:77F87CB5                 int     2Eh             ; DOS 2+ internal - EXECUTE COMMAND
.text:77F87CB5                                         ; DS:SI -> counted CR-terminated command string
.text:77F87CB7                 retn    2Ch
.text:77F87CB7 ZwCreateFile    endp

原来在ntdll中NtCreateFile只是ZwCreateFile的别名。

2) Part2 输出的是Ntoskrnl.exe中ZwCreateFile和NtCreateFile的汇编代码,也许令你很失望,汇编代码不一样;ZwCreateFile中eax是中断号,edx是函数的参数起始地址,然后调用int 2E中断; NtCreateFile只是把参数入栈去调用IoCreateFile;
他们的区别是:NtCreateFile是实现代码,而ZwCreateFile仍通过中断来实现功能,2E软中断的20h子中断号的处理程序是NtCreateFile;这样一说他们是没区别了?错!NtCreateFile是在ring0下了,而ZwCreateFile是通过int 2E进入ring0的,而不论ZwCreateFile处于什么模式下。

3) 从而我们得出:
   ntdll.dll中ZwCreateFile与ntoskrnl.exe中ZwCreateFile的区别是:前者是user Mode application called,后者是Kernel Mode driver Called;
   ntdll.dll中NtCreateFile与ntoskrnl.exe中NtCreateFile区别是:前者在ring3下工作,后者在ring0下工作;前者通过中断实现,后者是前者的中断处理程序。

注: 以前弄的东西,今天才写的,不知道有没有问题,望见谅!如果还有不清楚的参见: http://www.osronline.com/article.cfm?article=257  (Osronline/The Nt Insider/The Nt Insider 2003 Archive)

Zw*与Nt*的区别相关推荐

  1. 了解Zw*与Nt*的区别

    某些Zw*和Nt*函数既在ntdll.dll中导出又在ntoskrnl.exe中导出,他们有什么区别呢? 我们分三部分比较: step 1: ntdll.dll中的Zw*和Nt*有什么区别? step ...

  2. ntoskrnl.exe中Zw*与Nt*的区别

    某些Zw*和Nt*函数既在ntdll.dll中导出又在ntoskrnl.exe中导出,他们有什么区别呢? 我们分三部分比较: step 1: ntdll.dll中的Zw*和Nt*有什么区别? step ...

  3. Nt*和Zw*系列函数的区别

    ntdll.dll和ntoskrnl.exe的Nt和Zw系列函数区别 in ring3: lkd> ? ntdll!ZwOpenProcess Evaluate expression: 2089 ...

  4. zw和nt开头的系统调用的区别

    在RING3下,应用程序调用NT或者ZW效果是一样的.在RING0下,调用NT函数跟ZW函数就不一样了 ZW开头的函数是通过eax中系统服务号去SSDT中查找相应的系统服务,然后调用之 若在驱动中直接 ...

  5. 内核解惑:zw函数和nt函数的区别

    转载自:http://hi.baidu.com/resoft007/item/eb510a0d0ae2ac03addc7019 http://bbs.pediy.com/showthread.php? ...

  6. Windows API 理解----Nt* Zw*

    在你要理解Zw和Nt 系列API时,你首先要知道一点,那就是系统调用.什么是系统调用呢? 系统调用:操作系统为应用程序提供的可被调用的一组函数,也叫"System Call". 从 ...

  7. Nt*和Zw*开头的函数

    原文链接:http://blog.csdn.net/tianzhhy/article/details/6184265 http://blog.csdn.net/evi10r/article/detai ...

  8. 【驱动之四】Nt和Zw

    Ring3中的NATIVE API,和Ring0的系统调用,都有同名的Zw和Nt系列函数,初次接触会感到很迷茫. 现在就以ZwOpenProcess和NtOpenProcess函数为例,详细阐述下他们 ...

  9. windows驱动快速入门

    本公众号分享的所有技术仅用于学习交流,请勿用于其他非法活动,如有错漏,欢迎留言交流指正 NT驱动框架 <Windows 内核情景分析>.(毛德操) 前置知识 R3和R0 的由来 Intel ...

最新文章

  1. 麦肯锡顾问的核心意识:成果决定价值
  2. Python零基础入门(4)——分支与循环练习题
  3. 转!!配置Tomcat时server.xml和content.xml自动还原问题
  4. 京瓷打印机几个常见密码
  5. Mysql 拿指定经纬度与数据库多条经纬度进行距离计算
  6. 合并分支时有的文件删除了_GitGithub入门教程笔记(4)之分支管理一
  7. 对android.mk debug
  8. base64原理核心规则
  9. java 字段构造函数_依赖注入–字段vs构造函数vs方法
  10. Android异常总结---Test run failed:Unable to find instrumentation target package
  11. amos调节变量怎么画_结构方程模型建模思路及Amos操作--调节变量效果确定(二)...
  12. idea创建yml配置文件不是绿色
  13. 【论文阅读笔记】FCOS代码结合论文阅读
  14. 原型工具Axure6.5的使用
  15. 拉卡拉服务器响应超时,拉卡拉传统POS机11个常见问题及解决方法
  16. [重要]宝塔面板Linux7.4.3/Windows6.8紧急更新
  17. ubuntu 安装caj阅读器
  18. 探寻Linux 中国之路
  19. Python爬虫之抓取豆瓣影评数据
  20. Linux下的系统服务

热门文章

  1. 什么是Session共享?请举出使用场景
  2. WP缩略图出不了,打开缩略图提示“A TimThumb error has occured”
  3. 【bzoj2038】[国家集训队2010]小Z的袜子 莫队
  4. Java 第7章 数组
  5. ASP.Net MVC的学习
  6. 一个初学者困惑的Oracle的认证问题
  7. 【Demo 0062】目录及文件基本操作
  8. C#3.0语法新特性集合
  9. Python学习笔记:IO编程StringIO和BytesIO
  10. 为什么很多人说 Java 不适合编写桌面应用?