ISR Hooking.

git-svn-id: https://spexeah.com:8443/svn/Asuro@76 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
kieron 2017-05-17 17:31:38 +00:00
parent 886e6a8cdf
commit bc96202990
25 changed files with 685 additions and 1 deletions

BIN
Asuro.iso

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -33,7 +33,7 @@ var
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](nil); if uint32(Hooks[i]) <> 0 then Hooks[i](void(0));
end; end;
console.writestringln('Divide by Zero Exception.'); console.writestringln('Divide by Zero Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(1));
end;
console.writestringln('Debug Exception.'); console.writestringln('Debug Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(1, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(1, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(10));
end;
console.writestringln('Bad TSS Exception.'); console.writestringln('Bad TSS Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(10, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(10, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(11));
end;
console.writestringln('Segment Not Present Exception.'); console.writestringln('Segment Not Present Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(11, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(11, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(12));
end;
console.writestringln('Stack Fault Exception.'); console.writestringln('Stack Fault Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(12, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(12, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(13));
end;
console.writestringln('General Protection Fault.'); console.writestringln('General Protection Fault.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(13, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(13, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(14));
end;
console.writestringln('Page Fault.'); console.writestringln('Page Fault.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(14, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(14, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(15));
end;
console.writestringln('Unknown Interrupt Exception.'); console.writestringln('Unknown Interrupt Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(15, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(15, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(16));
end;
console.writestringln('Coprocessor Fault Exception.'); console.writestringln('Coprocessor Fault Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(16, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(16, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(17));
end;
console.writestringln('Alignment Check Exception.'); console.writestringln('Alignment Check Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(17, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(17, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(18));
end;
console.writestringln('Machine Check Exception.'); console.writestringln('Machine Check Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(18, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(18, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(2));
end;
console.writestringln('NMI Exception.'); console.writestringln('NMI Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(2, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(2, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(3));
end;
console.writestringln('Breakpoint Exception'); console.writestringln('Breakpoint Exception');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(3, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(3, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(4));
end;
console.writestringln('IDO Exception.'); console.writestringln('IDO Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(4, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(4, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(5));
end;
console.writestringln('OOB Exception.'); console.writestringln('OOB Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(5, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(5, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(6));
end;
console.writestringln('Invalid OPCode Exception.'); console.writestringln('Invalid OPCode Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(6, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(6, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(7));
end;
console.writestringln('No Coprocessor Exception.'); console.writestringln('No Coprocessor Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(7, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(7, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(8));
end;
console.writestringln('Double Fault.'); console.writestringln('Double Fault.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(8, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(8, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.

View File

@ -18,19 +18,57 @@ uses
IDT; IDT;
procedure register(); procedure register();
procedure hook(hook_method : uint32);
procedure unhook(hook_method : uint32);
implementation implementation
var
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
procedure Main(); interrupt; procedure Main(); interrupt;
var
i : integer;
begin begin
CLI; CLI;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) <> 0 then Hooks[i](void(9));
end;
console.writestringln('Coprocessor Seg Overrun Exception.'); console.writestringln('Coprocessor Seg Overrun Exception.');
util.halt_and_catch_fire; util.halt_and_catch_fire;
end; end;
procedure register(); procedure register();
begin begin
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
IDT.set_gate(9, uint32(@Main), $08, ISR_RING_0); IDT.set_gate(9, uint32(@Main), $08, ISR_RING_0);
end; end;
procedure hook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = hook_method then exit;
end;
for i:=0 to MAX_HOOKS-1 do begin
if uint32(Hooks[i]) = 0 then begin
Hooks[i]:= pp_hook_method(hook_method);
exit;
end;
end;
end;
procedure unhook(hook_method : uint32);
var
i : uint32;
begin
for i:=0 to MAX_HOOKS-1 do begin
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
exit;
end;
end;
end. end.