Search code examples
assemblynasmdosx86-16

Hooking Int 09h interrupt


I have a problem hooking int 09h I've changed the pointer to my new Isr, if I debug on windows, the interrupt is triggered every time I push a key. But in VMWare it seems that only is triggered one time and no more. I've tested in DOS 6.22 and happens exactly the same.

My code look like this:

MyIsr:
    pusha
    pushf
    ;tell PIC that interrupt has finished
    mov al,0x20
    out 0x20,al
    popf
    popa
    iret

If I use a USB keyboard can I send the same commands like Ps/2?


Solution

  • There could be a number of issues here, as you haven't posted a complete view of the code you are writing. Could you please explain exactly what you are tying to accomplish?

    If an ISR is called and not handled, you won't be able to do anything, so keep this in mind. Your problem may be related to how you are installing the ISR in the interrupt vector table.

    • In real mode, you do it with INT 21h, AH=25h
    • In protected mode, under DJGPP, you need to use a DPMI function (either using INT 21H functions, or using C functions. See DPMI documentation
    • Locking down the memory for the ISR is also needed when running in PM, as the memory can get "paged out" (You need this for the ISR because we don't really "know" when it will run).

    Regardless, your ISR should look more like the following:

    newInt9:
    
    enter 0,0
    push eax
    
    in al, 60h
    mov [raw_key], al
    
    mov al, 20h
    out 20h, al
    
    pop eax
    leave
    iret     
    

    ;endproc