代码如下
ULONG OldTrap01=0x804e04db; //这个是我本地机器原来的中断0E的地址,我是直接把用这个地址,替换掉,程序被HOOK的地址,还原的,还原后,电脑就死机了,我自己HOOK然后自己恢复,就没问题,别的程序HOOK的,我恢复了,就死机,第一次HOOK,谁能帮我看看啊,弄了,几天了,没想明白为什么呢,求大神解答
NTSTATUS NTAPI UnHookIDT(UINT nIdtNum,PVOID SaveFunction)
{
KAFFINITY processors;
PKTHREAD thread;
LONG i;
IDTINFO idt_info;
IDTENTRY* idt_entries;
ULONG_PTR NewTrap = 0;
UNICODE_STRING ustrKeSetAffinityThread;
_KeSetAffinityThread KeSetAffinityThread;
processors = KeQueryActiveProcessors();
DbgPrint("processors=%x\n",processors);
thread = KeGetCurrentThread();
DbgPrint("thread=%x\n",thread);
NewTrap = (ULONG_PTR)SaveFunction;
RtlInitUnicodeString(&ustrKeSetAffinityThread, L"KeSetAffinityThread");
KeSetAffinityThread = (_KeSetAffinityThread)MmGetSystemRoutineAddress(&ustrKeSetAffinityThread);
for(i = 0; i < 32; i++)
{
KAFFINITY curProc = processors & (1 << i);
if(curProc != 0)
{
KeSetAffinityThread(thread, curProc);
__asm sidt idt_info
idt_entries = (IDTENTRY*) MAKELONG(idt_info.LowIDTbase,idt_info.HiIDTbase);
//////////////////////////////////////////////////////////////////////////
//__asm nop;
//__asm nop;
//__asm nop;
__asm cli;
if (nIdtNum==0x01)
{
idt_entries[nIdtNum].LowOffset = (USHORT)OldTrap01;
idt_entries[nIdtNum].HiOffset = (USHORT)((ULONG)OldTrap01 >> 16);
}
else
{
idt_entries[nIdtNum].LowOffset = (USHORT)OldTrap0e;
idt_entries[nIdtNum].HiOffset = (USHORT)((ULONG)OldTrap0e >> 16);
}
;
__asm sti;
//////////////////////////////////////////////////////////////////////////
}
}
KeSetAffinityThread(thread, processors);
return STATUS_SUCCESS;
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课