Home > Windows > windows内核函数命名规则(system routine naming convention)

windows内核函数命名规则(system routine naming convention)

windows内核函数命名的一般格式为:

<Prefix><Operation><Object>

Prefix指示导出该例程的组件,Operation指出对对象或资源做什么样的动作,Object标示操作的对象或资源。比如ExAllocatePoolWithTag是一个执行体(Executive)例程,用来从分页池(paged pool)或非分页池(nonpaged pool)中分配内存。KeInitializeThread是一个分配并且设置内核线程对象(kernel thread object)的内核例程。

下面的表列出了常用的前缀和组件的对应关系。

PrefixComponent
AlpcAdvanced Local Inter-Process Communication
CcCommon Cache
CmConfiguration Manager
DbgkDebugging Framework for User-Mode
EmErrata Manager
EtwEvent Tracing for Windows
ExExecutive support routines
FsRtlFile System Driver Run-Time Library
HalHardware abstraction layer
HvlHypervisor Library
IoI/O manager
KeKernel
KdKernel Debugger
KsKernel Streaming
LsaLocal Security Authority
MmMemory manager
NtNT system services(most of which are exported as Win32 functions) ,NT Native API
ObObject manager
PfPrefetcher
PoPower manager
PpPnP manager
PsProcess support
RtlRun-time library
SeSecurity
TmTransaction manager
VfVerifier
WheaWindows Hardware Error Architecture
Wmiwindows management instrumentation
Wdiwindows diagnostic infrastructure
ZwThe origin of the prefix "Zw" is unknown;it is rumored that this prefix was chosen due to its having no significance at all.Mirror entry point for system services (beginning with Nt) that sets previous access mode to kernel,which eliminates parameter validation, since Nt system services validate parameters only if previous access mode is user mode
LpcLocal Procedure Call
LdrLoader
NlsNational language support
DbgDebug
TdiTransport driver interface
CsrClient Server Runtime,represents the interface to the win32 subsystem located in csrss.exe
InbvInitialize boot video

每一个系统组件还有一个变体前缀来指示内部使用(unexported)的函数,或者是组件前缀的第一个字母后面跟上i(指internal),或者是全部的前缀跟上字母p(指private)。比如Ki指示一个Kernel内部函数,Psp指示一个Process support内部函数。

有些内核函数还在前缀或简化的前缀后面加上小写字母f,来指示这个函数使用fastcall调用约定,比如ObfDereferenceObject。KfRaiseIrql、KfLowerIrql、KfAcquireSpinLock、KfReleaseSpinLock等亦属此类。

经常会有人问Zw到底是什么单词的缩写(abbreviation),而且有种种的猜测在流传。实际上到现在也没有一个权威的说法,姑且认为选择这样一个古怪的前缀很难与其他组件发生冲突吧。

如果你知道这里没有列出的前缀或者有错误的地方,欢迎留言指出。

Categories: Windows Tags:
  1. No comments yet.
  1. No trackbacks yet.

Copyleft © 2009-2010 mopyman 本站为原创网站,除非另有声明,本网站采用知识共享“署名2.5 中国大陆”许可协议授权.