#include <errno.h>#include <realmode.h>#include <biosint.h>Go to the source code of this file.
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| void | hook_bios_interrupt (unsigned int interrupt, unsigned int handler, struct segoff *chain_vector) |
| Hook INT vector. | |
| int | unhook_bios_interrupt (unsigned int interrupt, unsigned int handler, struct segoff *chain_vector) |
| Unhook INT vector. | |
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| void hook_bios_interrupt | ( | unsigned int | interrupt, | |
| unsigned int | handler, | |||
| struct segoff * | chain_vector | |||
| ) |
Hook INT vector.
| interrupt | INT number | |
| handler | Offset within .text16 to interrupt handler | |
| chain_vector | Vector for chaining to previous handler |
chain_vector will be filled in with the address of the previously-installed handler for this interrupt; the handler should probably exit by ljmping via this vector.
Definition at line 24 of file biosint.c.
References copy_from_real, copy_to_real, DBG, DBG_HDA, DBG_LOG, hooked_bios_interrupts, segoff::offset, rm_cs, and segoff::segment.
Referenced by call_bootsector(), fake_e820(), hide_etherboot(), hook_comboot_interrupts(), hook_int13(), pxe_activate(), and undinet_hook_isr().
00025 { 00026 struct segoff vector = { 00027 .segment = rm_cs, 00028 .offset = handler, 00029 }; 00030 00031 DBG ( "Hooking INT %#02x to %04x:%04x\n", 00032 interrupt, rm_cs, handler ); 00033 00034 if ( ( chain_vector->segment != 0 ) || 00035 ( chain_vector->offset != 0 ) ) { 00036 /* Already hooked; do nothing */ 00037 DBG ( "...already hooked\n" ); 00038 return; 00039 } 00040 00041 copy_from_real ( chain_vector, 0, ( interrupt * 4 ), 00042 sizeof ( *chain_vector ) ); 00043 DBG ( "...chaining to %04x:%04x\n", 00044 chain_vector->segment, chain_vector->offset ); 00045 if ( DBG_LOG ) { 00046 char code[64]; 00047 copy_from_real ( code, chain_vector->segment, 00048 chain_vector->offset, sizeof ( code ) ); 00049 DBG_HDA ( *chain_vector, code, sizeof ( code ) ); 00050 } 00051 00052 copy_to_real ( 0, ( interrupt * 4 ), &vector, sizeof ( vector ) ); 00053 hooked_bios_interrupts++; 00054 }
| int unhook_bios_interrupt | ( | unsigned int | interrupt, | |
| unsigned int | handler, | |||
| struct segoff * | chain_vector | |||
| ) |
Unhook INT vector.
| interrupt | INT number | |
| handler | Offset within .text16 to interrupt handler | |
| chain_vector | Vector containing address of previous handler |
Definition at line 69 of file biosint.c.
References copy_from_real, copy_to_real, DBG, EBUSY, hooked_bios_interrupts, segoff::offset, rm_cs, and segoff::segment.
Referenced by call_bootsector(), pxe_deactivate(), undinet_unhook_isr(), unfake_e820(), unhide_etherboot(), unhook_comboot_interrupts(), and unhook_int13().
00070 { 00071 struct segoff vector; 00072 00073 DBG ( "Unhooking INT %#02x from %04x:%04x\n", 00074 interrupt, rm_cs, handler ); 00075 00076 copy_from_real ( &vector, 0, ( interrupt * 4 ), sizeof ( vector ) ); 00077 if ( ( vector.segment != rm_cs ) || ( vector.offset != handler ) ) { 00078 DBG ( "...cannot unhook; vector points to %04x:%04x\n", 00079 vector.segment, vector.offset ); 00080 return -EBUSY; 00081 } 00082 00083 DBG ( "...restoring to %04x:%04x\n", 00084 chain_vector->segment, chain_vector->offset ); 00085 copy_to_real ( 0, ( interrupt * 4 ), chain_vector, 00086 sizeof ( *chain_vector ) ); 00087 00088 chain_vector->segment = 0; 00089 chain_vector->offset = 0; 00090 hooked_bios_interrupts--; 00091 return 0; 00092 }
1.5.7.1