Protectmode handler called from realmode (Developers)
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:
- Protectmode handler called from realmode - Laaca, 12.08.2010, 21:12 ![Open in board view [Board]](img/board_d.gif) ![Open in mix view [Mix]](img/mix_d.gif) - Protectmode handler called from realmode - ecm, 12.08.2010, 21:24- Protectmode handler called from realmode - Laaca, 13.08.2010, 01:46- Protectmode handler called from realmode - Japheth, 13.08.2010, 07:31- Protectmode handler called from realmode - bretjohn, 13.08.2010, 18:43- EDIT: Protectmode handler called from realmode - bretjohn, 13.08.2010, 19:25- Volumes vs physical storage media | WAS "Protectmod handl" - DOS386, 26.08.2010, 09:33- Volumes vs physical storage media | WAS "Protectmod handl" - bretjohn, 26.08.2010, 19:03- Volumes vs physical storage media | WAS "Protectmod handl" - DOS386, 27.08.2010, 03:25- Volumes vs physical storage media | WAS "Protectmod handl" - bretjohn, 27.08.2010, 16:47- Volumes vs physical storage media | WAS "Protectmod handl" - DOS386, 28.08.2010, 01:26- Volumes vs physical storage media | WAS "Protectmod handl" - bretjohn, 28.08.2010, 16:35- Volumes vs physical storage media | WAS "Protectmod handl" - DOS386, 06.09.2010, 20:10
 
 
- Volumes vs physical storage media | WAS "Protectmod handl" - bretjohn, 28.08.2010, 16:35
 
- Volumes vs physical storage media | WAS "Protectmod handl" - DOS386, 28.08.2010, 01:26
 
- Volumes vs physical storage media | WAS "Protectmod handl" - bretjohn, 27.08.2010, 16:47
 
- Volumes vs physical storage media | WAS "Protectmod handl" - DOS386, 27.08.2010, 03:25
 
- Volumes vs physical storage media | WAS "Protectmod handl" - bretjohn, 26.08.2010, 19:03
 
- Volumes vs physical storage media | WAS "Protectmod handl" - DOS386, 26.08.2010, 09:33
 
- EDIT: Protectmode handler called from realmode - bretjohn, 13.08.2010, 19:25
 
- Protectmode handler called from realmode - bretjohn, 13.08.2010, 18:43
 
- Protectmode handler called from realmode - Japheth, 13.08.2010, 07:31
 
- Protectmode handler called from realmode - Laaca, 13.08.2010, 01:46
 
- Protectmode handler called from realmode - ecm, 12.08.2010, 21:24
 Board view
Board view Mix view
Mix view
