Protectmode handler called from realmode (Developers)
Fixed!
There were three problems in my code.
1) the original SP is necessary to shift by 6 (as cm suggested) not by 4 (as microsoft suggested)
2) it is necessary to save FLAGS
3) the biggest problem, I had an absolutely stupid typo in my code:
should be: Get_rm_interrupt($13,old13h);
but I had: Get_pm_interrupt($13,old13h
So the correct code is:
uses Go32;
procedure Int13hHandler; assembler;
{I know, it does nothing but in first step would be enough not to crash}
asm
cld
lodsd;mov es:[edi+2Ah],eax {restores CS:IP}
lodsd;mov es:[edi+20h],ax {flags}
add word ptr es:[edi+2Eh],6 {sets SP}
iret
end;
procedure Int13hHandler_Dummy;begin end;
var p:pointer;
r:registers;
b:byte;
old13h:TsegInfo;
new13h:TsegInfo;
regs13h:trealregs;
begin
Get_rm_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,old13h);
free_rm_callback(new13h);
{restores normal state}
writeln('Still fine, leaving');
end.
---
DOS-u-akbar!
Complete thread:
- Protectmode handler called from realmode - Laaca, 12.08.2010, 21:12 (Developers)
- 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