nt!NtCreateFile和nt!ZwCreateFile
1: kd> u Nt!ZwCreateFile L10
nt!ZwCreateFile:
fffff807`7700cdd0 488bc4 mov rax,rsp
fffff807`7700cdd3 fa cli
fffff807`7700cdd4 4883ec10 sub rsp,10h
fffff807`7700cdd8 50 push rax
fffff807`7700cdd9 9c pushfq
fffff807`7700cdda 6a10 push 10h
fffff807`7700cddc 488d05bd6e0000 lea rax,[nt!KiServiceLinkage (fffff807`77013ca0)]
fffff807`7700cde3 50 push rax
fffff807`7700cde4 b855000000 mov eax,55h
fffff807`7700cde9 e952440100 jmp nt!KiServiceInternal (fffff807`77021240)
fffff807`7700cdee c3 ret
fffff807`7700cdef 90 nop
1: kd> u Nt!NtCreateFile L20
nt!NtCreateFile:
fffff807`772871a0 4881ec88000000 sub rsp,88h
fffff807`772871a7 33c0 xor eax,eax
fffff807`772871a9 4889442478 mov qword ptr [rsp+78h],rax
fffff807`772871ae c744247020000000 mov dword ptr [rsp+70h],20h
fffff807`772871b6 89442468 mov dword ptr [rsp+68h],eax
fffff807`772871ba 4889442460 mov qword ptr [rsp+60h],rax
fffff807`772871bf 89442458 mov dword ptr [rsp+58h],eax
fffff807`772871c3 8b8424e0000000 mov eax,dword ptr [rsp+0E0h]
fffff807`772871ca 89442450 mov dword ptr [rsp+50h],eax
fffff807`772871ce 488b8424d8000000 mov rax,qword ptr [rsp+0D8h]
fffff807`772871d6 4889442448 mov qword ptr [rsp+48h],rax
fffff807`772871db 8b8424d0000000 mov eax,dword ptr [rsp+0D0h]
fffff807`772871e2 89442440 mov dword ptr [rsp+40h],eax
fffff807`772871e6 8b8424c8000000 mov eax,dword ptr [rsp+0C8h]
fffff807`772871ed 89442438 mov dword ptr [rsp+38h],eax
fffff807`772871f1 8b8424c0000000 mov eax,dword ptr [rsp+0C0h]
fffff807`772871f8 89442430 mov dword ptr [rsp+30h],eax
fffff807`772871fc 8b8424b8000000 mov eax,dword ptr [rsp+0B8h]
fffff807`77287203 89442428 mov dword ptr [rsp+28h],eax
fffff807`77287207 488b8424b0000000 mov rax,qword ptr [rsp+0B0h]
fffff807`7728720f 4889442420 mov qword ptr [rsp+20h],rax
fffff807`77287214 e817000000 call nt!IopCreateFile (fffff807`77287230)
fffff807`77287219 4881c488000000 add rsp,88h
fffff807`77287220 c3 ret
NtCreateFile是实作创建文件,ZwCreateFile调用NT系统服务API完成。
NtCreateFile和ZwCreateFile参数检查的不同
从上图,NtCreateFile调用IopCreateFile, 根据之前是否是内核模式决定参数检查。对于ZwCreateFile, 本身就处于内核模式,参数检查步骤就省掉了。
微风不燥,阳光正好,你就像风一样经过这里,愿你停留的片刻温暖舒心。
我是程序员小迷(致力于C、C++、Java、Kotlin、Android、Shell、JavaScript、TypeScript、Python等编程技术的技巧经验分享),若作品对您有帮助,请关注、分享、点赞、收藏、在看、喜欢,您的支持是我们为您提供帮助的最大动力。
欢迎关注。助您在编程路上越走越好!