Hello,
I'm trying to hook ZwQuerySystemInformation on Windows 7 32 bits. Here's the code I have:
In DriverEntry:
.....
The enable/disable WP are pretty straight forward - I'm using MDL's to disable KeServiceTable protection. Here is my custom ZwQuerySystemInformation:
I'm trying to hook ZwQuerySystemInformation on Windows 7 32 bits. Here's the code I have:
In DriverEntry:
.....
Code: Select all
/* Start the hooking proess */
WPGLOBAL state = disableWP(KeServiceDescriptorTable.KiServiceTable, KeServiceDescriptorTable.nSystemCalls);
if((state.mdl == NULL) || (state.address == NULL)) {
return STATUS_UNSUCCESSFUL;
}
RtlInitUnicodeString(&FuncName, L"ZwQuerySystemInformation");
ZwQuerySystemInformation = (QUERY_SYS_INFO)MmGetSystemRoutineAddress(&FuncName);
if(ZwQuerySystemInformation != NULL)
hookSSDTEntry((BYTE *)ZwQuerySystemInformation, (BYTE *)myZwQuerySystemInformation, (DWORD *)state.address);
enableWP(&state);
/* end hooking process */
The enable/disable WP are pretty straight forward - I'm using MDL's to disable KeServiceTable protection. Here is my custom ZwQuerySystemInformation:
Code: Select all
Just a single wrapper to see that it is actually working. The SSDT hooking routines: NTSTATUS myZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, PVOID SystemInformation, ULONG SystemInformationLength, PULONG ReturnLength)
{
DbgPrint("Hooked ZwQuerySystemInformation Invoked \n");
return ZwQuerySystemInformation(SystemInformationClass, SystemInformation, SystemInformationLength, ReturnLength);
}
Code: Select all
Pretty straightforward, the problem is that I can see the string "Hooked ZwQuerySystemInformation Invoked " about 10-15 times after which the system freezes. I can't even break the debugger so that I can check if a BSOD has actually occurred. Any ideas as to where I might be wrong are welcomed.DWORD getSSDTIndex(BYTE *address) {
BYTE *addressOfIndex;
DWORD index;
addressOfIndex = address + 1;
return *((PULONG)addressOfIndex);
}
BYTE* hookSSDTEntry(BYTE *apicall, BYTE *newadd, DWORD *calltable) {
PLONG target;
DWORD indexValue;
indexValue = getSSDTIndex(apicall);
return (BYTE *)InterlockedExchange((PLONG)&calltable[indexValue], (LONG)newadd);
}
Last edited by GamingMasteR on Sun Aug 21, 2011 3:56 am, edited 1 time in total.
Reason: Added [code] tags