2 * Acess2 x86_64 Project
9 void Error_Handler(tRegs *Regs);
12 const char * const csaERROR_NAMES[] = {
13 "Divide By Zero", "Debug", "NMI Exception", "INT3",
14 "INTO", "Out of Bounds", "Invalid Opcode", "Coprocessor not avaliable",
15 "Double Fault", "Coprocessor Segment Overrun", "Bad TSS", "Segment Not Present",
16 "Stack Fault Exception", "GPF", "#PF", "Reserved",
17 "Floating Point Exception", "Alignment Check Exception", "Machine Check Exception", "Reserved",
18 "Reserved", "Reserved", "Reserved", "Reserved",
19 "Reserved", "Reserved", "Reserved", "Reserved",
20 "Reserved", "Reserved", "Reserved", "Reserved"
24 void Error_Handler(tRegs *Regs)
30 Log("CPU Error %x, Code: 0x%x", Regs->IntNum, Regs->ErrorCode);
31 Log(" - %s", csaERROR_NAMES[Regs->IntNum]);
32 Log(" CS:RIP = 0x%04x:%016x", Regs->CS, Regs->RIP);
33 Log(" SS:RSP = 0x%04x:%016x", Regs->SS, Regs->RSP);
34 Log(" RFLAGS = 0x%016x", Regs->RFlags);
36 Log(" RAX %016x RCX %016x RDX %016x RBX %016x",
37 Regs->RAX, Regs->RCX, Regs->RDX, Regs->RBX);
38 Log(" RSP %016x RBP %016x RSI %016x RDI %016x",
39 Regs->RSP, Regs->RBP, Regs->RSP, Regs->RDI);
40 Log(" R8 %016x R9 %016x R10 %016x R11 %016x",
41 Regs->R8, Regs->R9, Regs->R10, Regs->R11);
42 Log(" R12 %016x R13 %016x R14 %016x R15 %016x",
43 Regs->R12, Regs->R13, Regs->R14, Regs->R15);
44 Log(" FS %04x GS %04x", Regs->FS, Regs->GS);
48 __asm__ __volatile__ ("mov %%cr0, %0":"=r"(cr));
49 Warning(" CR0 0x%08x", cr);
50 __asm__ __volatile__ ("mov %%cr2, %0":"=r"(cr));
51 Warning(" CR2 0x%08x", cr);
52 __asm__ __volatile__ ("mov %%cr3, %0":"=r"(cr));
53 Warning(" CR3 0x%08x", cr);
54 __asm__ __volatile__ ("mov %%cr4, %0":"=r"(cr));
55 Warning(" CR4 0x%08x", cr);
57 switch( Regs->IntNum )
60 Warning(" Offending bytes: %02x %02x %02x %02x",
61 *(Uint8*)Regs->RIP+0, *(Uint8*)Regs->RIP+1,
62 *(Uint8*)Regs->RIP+2, *(Uint8*)Regs->RIP+3);
67 __asm__ __volatile__ ("hlt");