BOOLEAN InitHackAddress()
{
_SEH_TRY
{
g_KernelBase = GetKernelBaseAndSize( &g_KernelSize );
g_HackPspCreateProcess = SearchHackPspCreateProcess( &g_NopPspCreateProcess.Address );
g_HackKiDispatchException = SearchKiDispatchException( g_KernelBase,g_KernelSize );
g_HackDbgkpQueueMessage = SearchDbgkpQueueMessage( g_KernelBase,g_KernelSize );
g_HackDbgkCreateThread = SearchDbgkCreateThread( g_KernelBase,g_KernelSize );
SearchDbgkNotifyRoutine( g_KernelBase,g_KernelSize );
g_HackPspExitThread = SearchPspExitThread();
g_HackMmCreatePeb = SearchMmCreatePeb( g_HackPspCreateProcess );
SearchDbgkpSetProcessDebugObject( g_KernelBase,g_KernelSize );
if
( g_HackDbgkpSetProcessDebugObject[3] )
g_HackDbgkpMarkProcessPeb = SearchDbgkpMarkProcessPeb( g_HackDbgkpSetProcessDebugObject[3] ) ;
if
( g_NopPspCreateProcess.Address != 0 ){
RtlFillMemory( g_NopPspCreateProcess.NopCode,sizeof(g_NopPspCreateProcess.NopCode),0x90 );
g_NopPspCreateProcess.Size = 9;
RtlCopyMemory( g_NopPspCreateProcess.OrigCode,(PVOID)g_NopPspCreateProcess.Address,g_NopPspCreateProcess.Size );
}
if
( g_NopDbgkForwardException.Address != 0 ){
RtlFillMemory( g_NopDbgkForwardException.NopCode,sizeof(g_NopDbgkForwardException.NopCode),0x90 );
RtlCopyMemory( g_NopDbgkForwardException.OrigCode,(PVOID)g_NopDbgkForwardException.Address,g_NopDbgkForwardException.Size );
}
if
( g_NopDbgkExitThread.Address != 0 ){
RtlFillMemory( g_NopDbgkExitThread.NopCode,sizeof(g_NopDbgkExitThread.NopCode),0x90 );
RtlCopyMemory( g_NopDbgkExitThread.OrigCode,(PVOID)g_NopDbgkExitThread.Address,g_NopDbgkExitThread.Size );
}
if
( g_NopDbgkExitProcess.Address != 0 ){
RtlFillMemory( g_NopDbgkExitProcess.NopCode,sizeof(g_NopDbgkExitProcess.NopCode),0x90 );
RtlCopyMemory( g_NopDbgkExitProcess.OrigCode,(PVOID)g_NopDbgkExitProcess.Address,g_NopDbgkExitProcess.Size );
}
if
( g_NopDbgkMapViewOfSection.Address != 0){
RtlFillMemory( g_NopDbgkMapViewOfSection.NopCode,sizeof(g_NopDbgkMapViewOfSection.NopCode),0x90 );
RtlCopyMemory( g_NopDbgkMapViewOfSection.OrigCode,(PVOID)g_NopDbgkMapViewOfSection.Address,g_NopDbgkMapViewOfSection.Size );
}
if
( g_NopDbgkUnMapViewOfSection.Address != 0 ){
RtlFillMemory( g_NopDbgkUnMapViewOfSection.NopCode,sizeof(g_NopDbgkUnMapViewOfSection.NopCode),0x90 );
RtlCopyMemory( g_NopDbgkUnMapViewOfSection.OrigCode,(PVOID)g_NopDbgkUnMapViewOfSection.Address,g_NopDbgkUnMapViewOfSection.Size );
}
}
_SEH_HANDLER
{
DbgPrint(
"InitHackAddress Exception!\n"
);
}
return
( g_HackPspCreateProcess != 0 &&
g_HackKiDispatchException != 0 &&
g_HackDbgkForwardException != 0 &&
g_HackDbgkpQueueMessage != 0 &&
g_NopPspCreateProcess.Address != 0 &&
g_NopDbgkForwardException.Address != 0 &&
g_HackDbgkCreateThread != 0 &&
g_HackDbgkExitThread != 0 &&
g_NopDbgkExitThread.Address != 0 &&
g_HackDbgkExitProcess != 0 &&
g_NopDbgkExitProcess.Address != 0 &&
g_HackDbgkMapViewOfSection != 0 &&
g_NopDbgkMapViewOfSection.Address != 0 &&
g_HackDbgkUnMapViewOfSection != 0 &&
g_NopDbgkUnMapViewOfSection.Address != 0 &&
g_HackPspExitThread != 0 &&
g_HackMmCreatePeb != 0 &&
g_HackDbgkpSetProcessDebugObject[0] != 0 &&
g_HackDbgkpSetProcessDebugObject[1] != 0 &&
g_HackDbgkpSetProcessDebugObject[2] != 0 &&
g_HackDbgkpSetProcessDebugObject[3] != 0 &&
g_HackDbgkpMarkProcessPeb != 0 );
}