ObRegisterCallbacks使用
本文在windows7 内核太中实现无hook进程保护。现在网上找的例子基本上都是针对windows 32位系统的,也基本上都是教你用ssdt hook,inline hook去挂钩NtOpenProcess,NtTerminateProcess等系统调用,百度一大堆。当然在windows 64位系统中是不可能的,在64位系统中加载驱动必须要有签名。而且不可能去hook SSDT GDT等,否则将触发异常 紧接着系统蓝屏。因为PG(PatchGuard)保护着系统内核,除非能跳过验证。
在系统中还是用标准的回调注册函数ObRegisterCallbacks()比较好,这个函数只在XP以后才添加进去(还有对应的ObUnRegisterCallbacks删除回调),查看WDK对该函数的描述
ObRegisterCallbacks
The ObRegisterCallbacks routine registers a list of callback routines for thread and process handle operations.
NTSTATUS
ObRegisterCallbacks(
IN POB_CALLBACK_REGISTRATION CallBackRegistration,
OUT PVOID *RegistrationHandle
);
Parameters
CallBackRegistration
A pointer to an OB_CALLBACK_REGISTRATION structure that specifies the list of callback routines and other registration information.
RegistrationHandle
A pointer to a variable that receives a value that identifies the set of registered callback routines. The caller passes this value to the ObUnRegisterCallbacks routine to unregister the set of callbacks.
发现创建回调的时候失败了 返回了错误码0xC0000022查看msdn
The callback routines do not reside in a signed kernel binary image.
这个回调函数得签名过才能正确添加回调函数,其实这个限制也只针对32系统,因为在正常情况下x64的必须要签名过才能加载驱动程序^_^。
bp ObRegisterCallbacks