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, 13.08.2010, 01:46

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:

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