VOID HookInterrupt(UCHAR iVec, void (*InterruptHandler)( void )) { IDT Idt; INT_VECTOR Vec; ULONG i; LoadIDT( &Idt ); LoadINTVector( &Idt, iVec, &Vec); KdPrint( ( "HookInterrupt: Vector -- %X, 0x%p, 0x%p\n", iVec, VEC_OFFSET_TO_ADDR( Vec ), InterruptHandler)); ADDR_TO_VEC_OFFSET( Vec, (ULONG64) InterruptHandler); //Vec.wSelector = selector; SaveINTVector( &Idt, iVec, &Vec ); }
VOID BackupInterrupt(UCHAR iVec, OUT PINT_VECTOR Vec) { IDT Idt; ULONG i; LoadIDT( &Idt ); LoadINTVector( &Idt, iVec, Vec); }
VOID RestoreInterrupt(UCHAR iVec, IN PINT_VECTOR Vec) { IDT Idt; ULONG i; LoadIDT( &Idt ); SaveINTVector( &Idt, iVec, Vec); }
/** Kernel (real) entry point **/ void kmain(struct mb_partial_info *mbi) { printk("RAM detected : %uk (lower), %uk (upper)\n", mbi->low_mem, mbi->high_mem); printk("Command line got: %s \n", mbi->cmdline); printk ("Initialize GDT ... "); InitGDT(); asm(" movw $0x18, %ax \n \ movw %ax, %ss \n \ movl $0x1FFF0, %esp"); OkMsg(); LoadIDT(); printk ("IDT loaded éè\n"); InitPIC(); sti; while(1) { } }
VOID CopyInterrupt(UCHAR fromVec, UCHAR toVec) { IDT Idt; INT_VECTOR Vec; ULONG i; LoadIDT( &Idt ); LoadINTVector( &Idt, fromVec, &Vec); KdPrint( ( "CopyInterrupt: Vector, 0x%p\n", VEC_OFFSET_TO_ADDR( Vec ))); SaveINTVector( &Idt, toVec, &Vec ); }