xxxxx@yahoo.com wrote:
Hi,
I am calling ZWEnumerateKey from my kernel module on windows 2000,
Which gets failed since NtEnumerateKey is hooked, through SSDT.
Please help me to resolve following questions:
1- Can we directly call ntoskrnl.exe functions from a kernel module, i.e skipping SSDT.
A method to bypass SSDT hooks in kernel.
In kernel mode, entry points named NtXxxXxx are the original unhooked
addresses directly in ntoskrnl.exe. When you call those, SSDT hooking
does not affect you, but the “PreviousMode” global state still reflect
the state in your code, so if your code was called from user mode, the
entry point will validate parameters as if IT was called from user mode.
Also in kernel mode, entry points named ZwXxxXxx reenter the system call
dispatcher, sets PreviousMode to “KernelMode” and then obeys any SSDT hooks.
In user mode on the other hand NtXxxXxx and ZwXxxXxx are exactly the
same code address in ntdll.dll, which goes through INT
2E/SYSCALL/SYSENTER, sets PreviousMode to “UserMode” and obeys any SSDT
hooks.
To Unpatch the SSDT to its original values (unwise if hooking was done
by friendly code doing something useful), simply assign the NtXxxXxx
addresses directly back into the SSDT.
Another detail: Although all of the NtXxxXxx and ZwXxxXxx addresses
exist in both user and kernel mode, only a “random” subset of these
names is listed in the export tables of ntoskrnl and ntdll. Finding the
remaining addresses is left as a hard exercise for the developer.
–
Jakob Bøhm, M.Sc.Eng. * xxxxx@danware.dk * direct tel:+45-45-90-25-33
Danware Data A/S * Bregnerodvej 127 * DK-3460 Birkerod * DENMARK
http://www.netop.com * tel:+45-45-90-25-25 * fax tel:+45-45-90-25-26
Information in this mail is hasty, not binding and may not be right