Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Protectmode handler called from realmode (Developers)

posted by Laaca Homepage, Czech republic, 12.08.2010, 21:12

Hello all. I need help with interrupt stuff where I totally got stuck.
I have a protectmode program which hooks the INT13h interrupt. Then calls some INT21h functions which internaly calls the INT13h (which is now hooked) and from this hooked 1NT13h I analyse the given arguments.
Purpose: to find out to which physical device and LBA address points the DOS drives.

I had no problem to code it in real mode in Turbo pascal.
But in Freepascal it still crashes :-(

As information resources I used these two documents:
http://www.delorie.com/djgpp/doc/dpmi/ch4.6.html
and
http://support.microsoft.com/?scid=kb%3Ben-us%3B67845&x=11&y=11

And here is my code:

uses Go32;

procedure Int13hHandler; assembler;
{I know, it does nothing but in first step would be enough not to crash}
asm
cld
lodsw;mov es:[edi+2Ah],ax {restores IP}
lodsw;mov es:[edi+2Ch],ax {restores CS}
add word ptr es:[edi+2Eh],4 {or "6"?} {sets SP}
iret
end;
procedure Int13hHandler_Dummy;begin end;


var
old13h:TsegInfo;
new13h:TsegInfo;
regs13h:trealregs; external name '___v2prt0_rmcb_regs';

begin
Get_pm_interrupt($13,old13h);
{Backup of old interrupt handler}

get_rm_callback(@Int13hHandler, regs13h, new13h);
{prepares the protectmode procedure for calling from realmode}

Set_rm_interrupt($13,new13h);
{install my interrupt handler}

asm
mov ah,32h {load info from}
mov dl,3 {disk C:}
int 21h {this call will lead to INT13h/AH=42h}
end; {I will trap it and analyze the given arguments}

writeln('Everything seems to be fine');
readln;

Set_rm_interrupt($13,new13h);
{restores normal state}

writeln('Stil fine, leaving');
end.

---
DOS-u-akbar!

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 251 users online (0 registered, 251 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum