Mail Archives: djgpp/1999/03/20/08:36:11
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
: <space> or <Enter>, then no matter how long I wait (at least 2
: minutes) nothing more happens. I try hitting <space> 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 <stdio.h>
: #include <stdlib.h>
: #include <unistd.h>
: #include <dpmi.h>
: #include <go32.h>
: #include <pc.h>
: #include <keys.h>
:
: #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. -----
- Raw text -