Re: dos_interrupt
- Posted by Duffy <eagleranch at plumasnet.com> Feb 28, 2003
- 444 views
This is a multi-part message in MIME format. ------=_NextPart_000_0009_01C2DE7F.879818A0 charset="iso-8859-1" -- The following calls an interrupt thru the DPMI 0300h function -- it uses 32 bit registers. -- This works with ex.exe, it may work with exw.exe and win95/98. -- It will not work with exw.exe and win ME=20 -- -- See Ralf Brown's Interrupt List for more information on DPMI = functions. -- Another good source for info on protected mode programming is Dieter = Pawelczak's -- Pass32/Pro32 assembler/extender and documentation, it's free. constant=20 REG_EDI =3D #00, REG_ESI =3D #04, REG_EBP =3D #08, -- reserved =3D #0C should be (00h) REG_EBX =3D #10, REG_EDX =3D #14, REG_ECX =3D #18, REG_EAX =3D #1C, REG_flags =3D #20, REG_ES =3D #22, REG_DS =3D #24, REG_FS =3D #26, REG_GS =3D #28, REG_IP =3D #2A, -- used by 0301h & 0302h only REG_CS =3D #2C, -- " REG_SP =3D #2E, -- (00h) use default stack REG_SS =3D #30 -- (00h) " -- dummy =3D #32 word for alignment (00h) atom xfrblk xfrblk =3D allocate(#34) integer intn intn =3D 0 sequence int31_code -- DosProtectedModeInterface int31_code =3D {#50, -- push eax #53, -- push ebx #51, -- push ecx #57, -- push edi #06, -- push es #66,#B8,#00,#03} & -- mov ax,#0300 ; Call Real = Mode Interrupt {#8B,#1D} & int_to_bytes(intn) & -- mov ebx,[intn] ; interrupt = to execute {#33,#C9} & -- xor ecx,ecx {#BF} & int_to_bytes(xfrblk) & -- mov edi,offset xfrblk {#1E, -- push ds #07, -- pop es ; es:edi = pointer to xfrblk #CD,#31, -- int 31 #07, -- pop es #5F, -- pop edi #59, -- pop ecx #5B, -- pop ebx #58, -- pop eax #C3} -- ret atom int31 int31 =3D allocate(length(int31_code)) poke(int31,int31_code) procedure call_DPMI300(integer interrupt_number) poke(intn,interrupt_number) call(int31) -- on return xfrblk will hold results end procedure -- Example: poke4(xfrblk+REG_EAX,#00003000) -- Get MS-DOS Version Number call_DPMI300(#21) printf( 1, "DOS Version: %d.%d\n", {remainder(peek4u(xfrblk+REG_EAX),#100), floor(peek4u(xfrblk+REG_EAX)/#100)} ) ------=_NextPart_000_0009_01C2DE7F.879818A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4134.100" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff><FONT size=3D2> <DIV><BR><FONT face=3D"Courier New">-- The following calls an interrupt = thru the=20 DPMI 0300h function<BR>-- it uses 32 bit registers.<BR>-- This works = with=20 ex.exe, it may work with exw.exe and win95/98.<BR>-- It will not work = with=20 exw.exe and win ME <BR>--<BR>-- See Ralf Brown's Interrupt List for more = information on DPMI functions.<BR>-- Another good source for info on = protected=20 mode programming is Dieter Pawelczak's<BR>-- Pass32/Pro32 = assembler/extender and=20 documentation, it's free.</FONT></DIV> <DIV><FONT face=3D"Courier New"></FONT> </DIV> <DIV><BR><FONT face=3D"Courier New">constant <BR>REG_EDI =3D = #00,<BR>REG_ESI =3D #04,<BR>REG_EBP =3D =20 #08,<BR>  = ; =20 -- reserved =3D #0C should be (00h)<BR>REG_EBX =3D = #10,<BR>REG_EDX=20 =3D #14,<BR>REG_ECX =3D #18,<BR>REG_EAX = =3D =20 #1C,<BR>REG_flags =3D #20,<BR>REG_ES =3D = #22,<BR>REG_DS=20 =3D #24,<BR>REG_FS =3D = #26,<BR>REG_GS=20 =3D #28,<BR>REG_IP =3D =20 #2A, -- used by 0301h & 0302h = only<BR>REG_CS=20 =3D #2C, =20 -- = "<BR>REG_SP=20 =3D #2E, -- (00h) use = default=20 stack<BR>REG_SS =3D = #30 --=20 (00h) =20 "<BR> &n= bsp; =20 -- dummy =3D #32 word for alignment (00h)</FONT></DIV> <DIV><FONT face=3D"Courier New"></FONT> </DIV> <DIV><FONT face=3D"Courier New">atom xfrblk xfrblk =3D=20 allocate(#34)</FONT></DIV> <DIV><FONT face=3D"Courier New"></FONT> </DIV> <DIV><FONT face=3D"Courier New">integer intn intn =3D = 0</FONT></DIV> <DIV><FONT face=3D"Courier New"></FONT> </DIV> <DIV><FONT face=3D"Courier New">sequence=20 int31_code &nb= sp; =20 -- DosProtectedModeInterface<BR>int31_code =3D<BR> =20 {#50, &n= bsp; &nb= sp; =20 -- push eax<BR> =20 #53, &nb= sp; &nbs= p; =20 -- push ebx<BR> =20 #51, &nb= sp; &nbs= p; =20 -- push ecx<BR> =20 #57, &nb= sp; &nbs= p; =20 -- push edi<BR> =20 #06, &nb= sp; &nbs= p; =20 -- push es<BR> #66,#B8,#00,#03}=20 & &n= bsp; =20 -- mov ax,#0300 ; Call Real = Mode=20 Interrupt<BR> {#8B,#1D} & int_to_bytes(intn) & = --=20 mov ebx,[intn] ; interrupt to=20 execute<BR> {#33,#C9}=20 & &n= bsp; =20 -- xor ecx,ecx<BR> {#BF} &=20 int_to_bytes(xfrblk) & -- = mov =20 edi,offset xfrblk<BR> =20 {#1E, &n= bsp; &nb= sp; =20 -- push ds<BR> =20 #07, &nb= sp; &nbs= p; =20 -- pop =20 es ; es:edi = pointer to=20 xfrblk<BR> =20 #CD,#31,  = ; = =20 -- int 31<BR> =20 #07, &nb= sp; &nbs= p; =20 -- pop es<BR> =20 #5F, &nb= sp; &nbs= p; =20 -- pop edi<BR> =20 #59, &nb= sp; &nbs= p; =20 -- pop ecx<BR> =20 #5B, &nb= sp; &nbs= p; =20 -- pop ebx<BR> =20 #58, &nb= sp; &nbs= p; =20 -- pop eax<BR> =20 #C3} &nb= sp; &nbs= p; =20 -- ret</FONT></DIV> <DIV><FONT face=3D"Courier New"></FONT> </DIV> <DIV><FONT face=3D"Courier New">atom int31<BR>int31 =3D=20 allocate(length(int31_code))<BR>poke(int31,int31_code)</FONT></DIV> <DIV><FONT face=3D"Courier New"></FONT> </DIV> <DIV><BR><FONT face=3D"Courier New">procedure call_DPMI300(integer=20 interrupt_number)<BR> =20 poke(intn,interrupt_number)<BR> =20 call(int31) &n= bsp; =20 -- on return xfrblk will hold results<BR>end procedure</FONT></DIV> <DIV><FONT face=3D"Courier New"></FONT> </DIV> <DIV><BR><FONT face=3D"Courier New">-- Example:</FONT></DIV> <DIV><FONT face=3D"Courier New"></FONT> </DIV> <DIV><FONT face=3D"Courier = New">poke4(xfrblk+REG_EAX,#00003000) =20 -- Get MS-DOS Version Number</FONT></DIV> <DIV><FONT face=3D"Courier New"></FONT> </DIV> <DIV><FONT face=3D"Courier New">call_DPMI300(#21)</FONT></DIV> <DIV><FONT face=3D"Courier New"></FONT> </DIV> <DIV><FONT face=3D"Courier New">printf( 1, "DOS Version:=20 %d.%d\n",<BR> =20 {remainder(peek4u(xfrblk+REG_EAX),#100),<BR>  = ; =20 floor(peek4u(xfrblk+REG_EAX)/#100)} )</FONT></DIV> <DIV><FONT face=3D"Courier New"></FONT> </DIV> ------=_NextPart_000_0009_01C2DE7F.879818A0--