Skip to content

set_pm_interrupt

Set protected mode interrupt handler

Declaration

Source position: go32.pp line 134

  function set_pm_interrupt(vector: Byte; const intaddr: tseginfo)
                            : Boolean;

Description

Sets the address of the protected mode handler for an interrupt.

Parameters:

vector
number of protected mode interrupt to set.
intaddr
selector:offset address to the interrupt vector.

Return values: True if successful, False otherwise.

Remark

The address supplied must be a valid selector:offset protected mode address. !!!

Errors

Check the int31error variable.

See also

Name Description
get_pm_interrupt Return protected mode interrupt handler
get_rm_interrupt Get real mode interrupt vector
set_rm_interrupt Set real mode interrupt handler

Example

{ This example shows how to redirect a software interrupt by
changing the protected mode handler of the DPMI host.
In more detail it hooks interrupt 1Ch which is called every
time the timer interrupt (int 08) is executed. This is the
preferred way to hook the timer, because int 1Ch is a software
interrupt which doesn't need so much initialization stuff
compared to hooking a hardware interrupt.
}
uses
        crt,
        go32;
const
        { interrupt number we want to hook }
        int1c = $1c;
var
        { 48 bit pointer to old interrupt handler }
        oldint1c : tseginfo;
        { 48 bit pointer to new interrupt handler }
        newint1c : tseginfo;
        { increased every time the interrupt is called  }
        int1c_counter : Longint;
        { the current data selector }
        int1c_ds : Word; external name '___v2prt0_ds_alias';
{ the actual handler code }
procedure int1c_handler; assembler;
asm
   cli
{ save all registers }
   pushw %ds
   pushw %ax
{ prepare segment registers for FPC procedure }
   movw %cs:int1c_ds, %ax
   movw %ax, %ds
{ simply increase the counter by one }
   incl int1c_counter
{ restore registers }
   popw %ax
   popw %ds
   sti
   iret
end;
var i : Longint;
begin
     { insert right handler data into new handler variable }
     newint1c.offset := @int1c_handler;
     newint1c.segment := get_cs;
     { get the old handler }
     get_pm_interrupt(int1c, oldint1c);
     Writeln('-- Press any key to exit --');
     { set new handler }
     set_pm_interrupt(int1c, newint1c);
     { write the number of interrupts occurred }
     while (not keypressed) do begin
           gotoxy(1, wherey);
           write('Number of interrupts occurred : ', int1c_counter);
     end;
     { restore old handler }
     set_pm_interrupt(int1c, oldint1c);
end.