【发布时间】:2018-05-21 03:11:35
【问题描述】:
通过查看 Windows 中系统调用的痕迹,我对这些不同类型的系统调用感到非常困惑。以下是我遇到的一些不同类型:
NtQueryPerformanceCounter( Counter=0xbcf6c8 [1.45779e+009], Freq=null ) => 0
NtProtectVirtualMemory( ProcessHandle=-1, BaseAddress=0xbcf6f4 …
NtProtectVirtualMemory( ProcessHandle=-1, BaseAddress=0xbcf6f4 [0x7702e000]…
NtQuerySystemInformation( SystemInformationClass=0 [SystemBasicInformation]
NtQueryVirtualMemory( ProcessHandle=-1, BaseAddress=0x76f20000, MemoryInformationClass=6, MemoryInformation=0xbcf440, Length=0xc, ReturnLength=null ) => 0
我知道这些被称为 API 系统调用。我未经训练的眼睛将这些分类为以“Nt”开头的系统调用。
但我也遇到过这些:
"CreateSemaphoreW","CreateSemaphoreA","GlobalAddAtomW","lstrcpynW","LoadLibraryExW","SearchPathW",
"CreateFileW","CreateFileMappingW","MapViewOfFileEx","GetSystemMetrics","RegisterClipboardFormatW","SystemParametersInfoW",
"GetDC","GetDeviceCaps","ReleaseDC","LocalAlloc"
虽然我可能错了,但我假设这些是系统调用,级别低于以 Nt 开头的系统调用。
这是我遇到的另一个痕迹:
HeapAlloc HeapAlloc HeapFree HeapFree HeapAlloc HeapAlloc HeapFree
HeapFree NtOpenKey GetProcessHeap HeapAlloc NtOpenKey HeapAlloc NtOpenKey
NtQueryValueKey NtQueryValueKey HeapFree HeapAlloc HeapAlloc NtOpenKey
NtQueryValueKey HeapAlloc HeapAlloc RegOpenKeyExW
此跟踪包含 Nt 和那些不包含...
这些跟踪使我假设在 Windows 中存在不同的系统调用集,人们似乎以相同的名称(“系统调用”)引用它们。如果我错了,有人可以告诉我吗?如果我是对的,这些不同的系统调用集是否有名称?
谢谢
【问题讨论】:
-
Windows (NT) 系统调用通常以
Nt(ntdll.dll) 或NtUser或NtGdi(Windows 10 中的win32u.dll) 为前缀。这些是存根函数,将 system call table 中的函数号传递给内核模式调度程序(例如,通过 x64sysenter或syscall指令)。您可能还会看到Zw前缀名称。在用户模式下,这些与Nt函数名称相同。它们在内核中有所不同,但这与您的问题没有直接关系。 -
其他如
CreateFileW和HeapAlloc是Windows API 调用。通常这些在用户模式下执行尽可能多的工作和准备——通常通过运行时库函数,例如RtlDosPathNameToNtPathName_U和RtlAllocateHeap(在 ntdll.dll 中)。最终他们调用(或可能调用)内核系统函数,例如NtCreateFile或NtAllocateVirtualMemory。 -
还有诸如
CreateProcessWithLogonW之类的调用是通过对系统服务(例如本例中的辅助登录服务)进行RPC调用来实现的。如果它通过 LPC 端口,那么系统调用可能是NtAlpcSendWaitReceivePort。该服务通常有权进行其他调用,例如CreateProcessAsUser,最终调用NtCreateUserProcess。
标签: windows kernel system-calls trace