2007-11-18 22:27
我先简单介绍一下Nt系列函数与Zw系列函数的区别 以ReadFile为例 ntdll.dll导出了ZwReadFile和NtReadFile 以下是反汇编代码
.text:7C92E27C ; __stdcall NtReadFile(x, x, x, x, x, x, x, x, x)
.text:7C92E27C public _NtReadFile@36
.text:7C92E27C _NtReadFile@36 proc near ; CODE XREF: RtlGetSetBootStatusData(x,x,x,x,x,x)+5F p
.text:7C92E27C ; RtlGetSetBootStatusData(x,x,x,x,x,x):loc_7C95170D p ...
.text:7C92E27C mov eax, 0B7h ; NtReadFile
.text:7C92E281 mov edx, 7FFE0300h
.text:7C92E286 call dword ptr [edx]
.text:7C92E288 retn 24h
.text:7C92E288 _NtReadFile@36 endp
.text:7C92E288
.text:7C92E288 ; ---------------------------------------------------------------------------
.text:7C92E28B db 6 dup(90h)
.text:7C92E291 ; Exported entry 274. NtReadFileScatter
.text:7C92E291 ; Exported entry 1083. ZwReadFileScatter
.text:7C92E291
我们可以看到 ZwReadFile和NtReadFile函数指向同一段代码....
也就是说在用户态 不管你调用ZwReadFile还是NtReadFile都是一样的 因为他们是同一个函数的两个不同名称而已.... 而且他们最终都会调用到ntoskrnl中的NtReadFile中去
而ntoskrnl.exe导出的ZwReadFile和NtReadFile却是不同的
.text:00406508 ; NTSTATUS __stdcall ZwReadFile(HANDLE FileHandle,HANDLE Event,PIO_APC_ROUTINE ApcRoutine,PVOID ApcContext,PIO_STATUS_BLOCK IoStatusBlock,PVOID Buffer,ULONG Length,PLARGE_INTEGER ByteOffset,PULONG Key)
.text:00406508 mov eax, 0B7h
.text:0040650D lea edx, [esp+FileHandle]
.text:00406511 pushf
.text:00406512 push 8
.text:00406514 call _KiSystemService
.text:00406519
.text:7C92E27C ; __stdcall NtReadFile(x, x, x, x, x, x, x, x, x)
.text:7C92E27C public _NtReadFile@36
.text:7C92E27C _NtReadFile@36 proc near ; CODE XREF: RtlGetSetBootStatusData(x,x,x,x,x,x)+5F p
.text:7C92E27C ; RtlGetSetBootStatusData(x,x,x,x,x,x):loc_7C95170D p ...
.text:7C92E27C mov eax, 0B7h ; NtReadFile
.text:7C92E281 mov edx, 7FFE0300h
.text:7C92E286 call dword ptr [edx]
.text:7C92E288 retn 24h
.text:7C92E288 _NtReadFile@36 endp
.text:7C92E288
.text:7C92E288 ; ---------------------------------------------------------------------------
.text:7C92E28B db 6 dup(90h)
.text:7C92E291 ; Exported entry 274. NtReadFileScatter
.text:7C92E291 ; Exported entry 1083. ZwReadFileScatter
.text:7C92E291
我们可以看到 ZwReadFile和NtReadFile函数指向同一段代码....
也就是说在用户态 不管你调用ZwReadFile还是NtReadFile都是一样的 因为他们是同一个函数的两个不同名称而已.... 而且他们最终都会调用到ntoskrnl中的NtReadFile中去
而ntoskrnl.exe导出的ZwReadFile和NtReadFile却是不同的
.text:00406508 ; NTSTATUS __stdcall ZwReadFile(HANDLE FileHandle,HANDLE Event,PIO_APC_ROUTINE ApcRoutine,PVOID ApcContext,PIO_STATUS_BLOCK IoStatusBlock,PVOID Buffer,ULONG Length,PLARGE_INTEGER ByteOffset,PULONG Key)
.text:00406508 mov eax, 0B7h
.text:0040650D lea edx, [esp+FileHandle]
.text:00406511 pushf
.text:00406512 push 8
.text:00406514 call _KiSystemService
.text:00406519