From: ams AT ludd DOT luth DOT se (Martin Str|mberg) Newsgroups: comp.os.msdos.djgpp Subject: Re: Some assembly questions Date: 20 Mar 1999 12:01:25 GMT Organization: University of Lulea, Sweden Lines: 98 Message-ID: <7d02ml$abi$1@news.luth.se> References: <7cm980$f69$1 AT news DOT luth DOT se> <+n+tMKAodQ82Ewk+@xemu.demon.co.uk> <7crdu0$h9i$1 AT news DOT luth DOT se> NNTP-Posting-Host: queeg.ludd.luth.se X-Newsreader: TIN [UNIX 1.3 950824BETA PL0] To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Martin Str|mberg (ams AT ludd DOT luth DOT se) wrote: Thanks to George Foot, I have realised one thing wrong in my code. Alas the result hasn't improved. Still the same thing happens. : Perhaps somebody can tell me what I'm doing wrong in the following : code. It just chains the previous handler. When I get this to work : I'll not always jump to the previous one. : : What happens for me is it says "About to insert me...", I press : or , then no matter how long I wait (at least 2 : minutes) nothing more happens. I try hitting or some other : keys: nothing happens. When I get bored, I hit C-C, and is rewarded : with "This program has performed an illegal instruction..." : "Fault location 0028:C0001FE7 : Faulting component: VMM(01) + 00000FE7 : Interrupts in service: 1" : : : Shostakovich, String Quartet No. 15, : : MartinS : : ----- Code starts. ----- : #include : #include : #include : #include : #include : #include : #include : : #define MAX_BUF (16) : : extern void handler(void); : extern void handler_end(void); : : _go32_dpmi_seginfo old_isr, new_isr; Added line unsigned long address_of_old_isr : : asm(" : .text : .p2align 2 : : .globl _handler : _handler: : : /* The two following lines (pushw %cs; popw %ds) doesn't help; same result. : pushw %cs : popw %ds*/ : jmp *_old_isr This line is now jmp *_address_of_old_isr : : _handler_end: : nop : : "); : : : int main(int argc, char *argv[]) : { : : printf("About to insert me...\n"); : getkey(); : : _go32_dpmi_lock_code(&handler, &handler_end - &handler); : : _go32_dpmi_lock_data(&old_isr, sizeof(old_isr)); Added a line _go32_dpmi_lock_data(&address_of_old_isr, sizeof(address_of_old_isr)); : : _go32_dpmi_get_protected_mode_interrupt_vector(0x31, &old_isr); : : new_isr.pm_offset = (int)&handler; : new_isr.pm_selector = _go32_my_cs(); Added line address_of_old_isr = old_isr.pm_offset; : : _go32_dpmi_set_protected_mode_interrupt_vector(0x31, &new_isr); : : /* system("bash"); */ : sleep(5); : : printf("About to remove...\n"); : : _go32_dpmi_set_protected_mode_interrupt_vector(0x31, &old_isr); : : : return 0; : : } : ----- Code ends. -----