网上找的方法要么不全,要么不靠谱,还是要自己动手,现贴上源码
有不对的地方,还请指正
typedef NTSTATUS (__stdcall *pRtlDispatchException) (PEXCEPTION_RECORD pExcptRec, CONTEXT *pContext);
pRtlDispatchException RtlDispatchException = (pRtlDispatchException)0x7700B51A; //win764下的地址
typedef NTSTATUS (NTAPI *pKiUserExceptionDispatcher) (PEXCEPTION_RECORD pExcptRec, CONTEXT *pContext);
pKiUserExceptionDispatcher old_KiUserExceptionDispatcher = NULL;
typedef NTSTATUS (NTAPI *pZwContinue) (PCONTEXT pContext, int num);
pZwContinue ZwContinue = NULL;
typedef NTSTATUS (NTAPI *pZwRaiseException) (PEXCEPTION_RECORD pExcptRec, CONTEXT *pContext, int num);
pZwRaiseException ZwRaiseException = NULL;
VOID NTAPI KiUserExceptionDispatcher_My(PEXCEPTION_RECORD pExcptRec,PCONTEXT pContext)
{
DWORD retValue;
if (RtlDispatchException(pExcptRec,pContext))
{
::AfxMessageBox("ZwContinue");
retValue=::ZwContinue( pContext,0);
}else{
::AfxMessageBox("ZwRaiseException");
retValue=::ZwRaiseException(pExcptRec,pContext,0);
}
}
VOID NTAPI KiUserExceptionDispatcher(PEXCEPTION_RECORD pExcptRec, PCONTEXT pContext)
{
_asm
{
cld
push [esp+4]
push [esp]
call KiUserExceptionDispatcher_My;
ret 8
}
}
void InLineHook_KiUserExceptionDispatcher()
{
HMODULE h = LoadLibraryA("ntdll.dll");
//PLONG newaddr = (PLONG)&KiUserExceptionDispatcher;
//KiUserExceptionDispatcher = (pKiUserExceptionDispatcher)(GetProcAddress(h, "KiUserExceptionDispatcher"));
old_KiUserExceptionDispatcher = (pKiUserExceptionDispatcher)(GetProcAddress(h, "KiUserExceptionDispatcher"));
ZwContinue = (pZwContinue)(GetProcAddress(h, "ZwContinue"));
ZwRaiseException = (pZwRaiseException)(GetProcAddress(h, "ZwRaiseException"));
//KiUserExceptionDispatcher = (pKiUserExceptionDispatcher)My_KiUserExceptionDispatcher;
TRACE("old_Ki: %x \n", old_KiUserExceptionDispatcher);
WriteProcessMemory(GetCurrentProcess(), old_KiUserExceptionDispatcher, &KiUserExceptionDispatcher, 4, NULL);
if (h)
{
CloseHandle(h);
}
}
void CKiUEDDlg::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
InLineHook_KiUserExceptionDispatcher();
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课