Software is freely redistributable as long as this licence is kept with the Software. Charging a fee for the Software is prohibited.
Software, or parts thereof, may be incorporated into other free software (that may be obtained free of charge) without requiring permission from the author, as long as those parts of the Software that are used remain under this licence, as long as due credit is given to the author of the Software in the resulting work, and as long as the author is informed of this action.
Modified forms of the Software may be created and distributed, as long as the resulting work remains under this licence, as long as the modified form of the Software is distributed with documentation which still gives credit to the original author of the Software, as long as the modified form of the Software is distributed with a clear statement that it is not the original form of the Software as distributed by the author, and as long as the author is informed of this action.
Software, or parts thereof, may be incorporated into other software which is not free (for which a fee is charged) as long as permission is granted from the author of the Software. The author reserves the right to grant permission only for a fee, which may at his option take the form of royalty payments. The author also reserves the right to refuse to grant permission if he deems it necessary.
The author of the Software explicitly lay no claim to, and assert no rights over, any programs written by other people and extended by the Software. Such programs do not fall under this licence at all, and may be placed under any licence.
No other licence applies to the Software, and nothing else grants you any permission to copy, modify, sublicence or distribute the Software in any way.
| NASM v0.98 | www.web-sites.co.uk/nasm/ |
| ALINK v1.6 | www.geocities.com/SiliconValley/Network/4311/ |
| gcc v2.8.1 | www.delorie.com |
| make v3.77 | www.delorie.com |
| UPX v1.07d (optional) | upx.tsx.org |
D3X | examples.zip 2879 +---BIN | stubx.exe 47436 (90624) +---DOC | d3x.htm 32075 | d3x.txt 29305 \---SRC | makefile 720 | fix.c 4295 | stubx.c 19540 | stubs.h 6285 \---KERNEL d3x.asm 100880 extapi.inc 22890 lang.mac 1745
> StubX -s my_MZapp.exeor
> StubX -s my_D3X1.exeand voila! the dream comes true...
The D3X1 specifications:
d3x1_hdr struc sign dd ? ;signature 'D3X1' hdrsize dd ? ;header size (bytes) binsize dd ? ;binary size (bytes) admsize dd ? ;additional memory (bytes) entry dd ? ;entry point tos dd ? ;top of stack d3x1_hdr ends
eflags ?202h cs,ds,ss program block sel (cs = code32, ds=ss = data32) es selector for transferbuffer (es:0 -> stubinfo) fs flat data selector gs flat code selector eip,esp according to header .admsize zeroed <others> undefined
[00h] (byte[]) = 'd3x1stub vM.mm' [10h] (dword) = size of stubinfo [14h] (dword) = <unused> [18h] (dword) = memory block handle [1ch] (dword) = initial size (.binsize+.admsize) [20h] (word) = transferbuffer size [22h] (word) = transferbuffer data32 selector [24h] (word) = transferbuffer data segment [26h] (word) = PSP selector [28h] (word) = transferbuffer code16 selector [2ah] (word) = environment size [2ch] (dword) = platform (0=RAW, 1=XMS, 2=VCPI, 3=DPMI)
> StubX -s my_DJapp.exe
> StubX -s my_LEapp.exe
push dword 3302h popfd mov ax,01cdh <- int01h, not debug exceptionIf an exception handler is installed, it will be called in a DPMI compliant manner: with the exception structure on the stack. You can alter *ONLY* those fields DPMI says you can, and nothing else. Anyway, there are two deviations from the rule:
| Func. | Mode(s) | Ver | Description |
|---|---|---|---|
| 0000h | P | 0.9 | Allocate LDT descriptors |
| 0001h | r | 1.0 | Free LDT descriptor |
| 0003h | P | 0.9 | Get huge pointer increment |
| 0006h | P | 0.9 | Get segment base address |
| 0007h | P | 1.0 | Set segment base address |
| 0008h | P | 1.0 | Set segment limit |
| 0009h | P | 1.0 | Set descriptor access rights |
| 000Ah | P | 0.9 | Create alias descriptor |
| 000Bh | P | 0.9 | Get descriptor |
| 000Ch | P | 1.0 | Set descriptor |
| 0100h | r | 0.9 | Allocate DOS memory |
| 0101h | r | 1.0 | Free DOS memory |
| 0102h | r | 0.9 | Resize DOS memory |
| 0200h | P | 0.9 | Get real-mode interrupt vector |
| 0201h | P | 0.9 | Set real-mode interrupt vector |
| 0202h | P | 0.9 | Get exception vector |
| 0203h | P | 0.9 | Set exception vector |
| 0204h | P | 0.9 | Get protected-mode int vector |
| 0205h | P | 0.9 | Set protected-mode int vector |
| 0300h | r | 0.9 | Simulate real-mode interrupt |
| 0301h | r | 0.9 | Call real-mode procedure (RETF) |
| 0302h | r | 0.9 | Call real-mode procedure (IRET) |
| 0303h | P | 0.9 | Allocate real mode call-back |
| 0304h | P | 0.9 | Free real mode call-back |
| 0400h | P | 0.9 | Get version |
| 0500h | P/r | 0.9 | Get free memory information |
| 0501h | P/r | 0.9 | Allocate memory block |
| 0502h | P/r | 0.9 | Free memory block |
| 0503h | P/r | 0.9 | Resize memory block |
| 0600h | P | bogus | Lock memory |
| 0601h | P | bogus | Unlock memory |
| 0604h | P | bogus | Get page size |
| 0800h | P | 0.9 | Map physical address |
| 0900h | P | 0.9 | Disable interrupts |
| 0901h | P | 0.9 | Enable interrupts |
| 0902h | P | 0.9 | Get interrupt state |
| RAW | - kb granular | (best fit) |
| XMS | - kb granular | (???) |
| VCPI | - 4k granular | (first fit) |
| DPMI | - ??? | (???) |
1.DOS/09h - Write String to Standard Output:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 09h
DS:EDX -> '$' terminated string to write
Out: always successful
---------------------------------------------------------------------------
2.DOS/1Ah - Set Disk Transfer Area:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 1Ah
DS:EDX -> buffer for DTA
Out: always successful
---------------------------------------------------------------------------
3.DOS/1Bh - Get Allocation Information for Default Drive:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 1Bh
Out: always successful:
AL = sectors per cluster
ECX = bytes per sector
EDX = total number of clusters
DS:EBX -> media ID byte
---------------------------------------------------------------------------
4.DOS/1Ch - Get Allocation Information for Specific Drive:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 1Ch
DL = drive number
Out: if successful:
same as DOS/1Bh
if failed:
AL = FFh (invalid drive)
---------------------------------------------------------------------------
5.DOS/1Fh - Get Drive Parameter Block for Default Drive:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 1Fh
Out: if successful:
DS:EBX -> drive parameter block
if failed:
AL = FFh (invalid drive)
---------------------------------------------------------------------------
6.DOS/25h - Set Interrupt Vector:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 25h
AL = interrupt number
DS:EDX -> interrupt routine
Out: if successful:
carry flag clear
if failed:
carry flag set
---------------------------------------------------------------------------
7.DOS/2Fh - Get Disk Transfer Area:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 2Fh
Out: always successful:
ES:EBX -> DTA
---------------------------------------------------------------------------
8.DOS/32h - Get Drive Parameter Block for Specific Drive:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 32h
DL = drive number
Out: if successful:
AL = 0
DS:EBX -> drive parameter block
if failed:
AL = FFh (invalid drive)
---------------------------------------------------------------------------
9.DOS/34h - Get Address of InDOS Flag:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 34h
Out: always successful:
ES:EBX -> InDOS flag
---------------------------------------------------------------------------
10.DOS/35h - Get Interrupt Vector:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 35h
AL = interrupt number
Out: always successful:
ES:EBX -> interrupt routine
---------------------------------------------------------------------------
11.DOS/39h - Create Subdirectory:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 39h
DS:EDX -> ASCIIZ path name
Out: if successful:
carry flag clear
if failed:
carry flag set
EAX = error code
---------------------------------------------------------------------------
12.DOS/3Ah - Remove Subdirectory:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 3Ah
DS:EDX -> ASCIIZ path name
Out: if successful:
carry flag clear
if failed:
carry flag set
EAX = error code
---------------------------------------------------------------------------
13.DOS/3Bh - Set Directory:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 3Bh
DS:EDX -> ASCIIZ path name
Out: if successful:
carry flag clear
if failed:
carry flag set
EAX = error code
---------------------------------------------------------------------------
14.DOS/3Ch - Create File:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 3Ch
CX = attribute
DS:EDX -> ASCIIZ path name
Out: if successful:
carry flag clear
EAX = handle
if failed:
carry flag set
EAX = error code
---------------------------------------------------------------------------
15.DOS/3Dh - Open File:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 3Dh
AL = open code
DS:EDX -> ASCIIZ path name
Out: if successful:
carry flag clear
EAX = handle
if failed:
carry flag set
EAX = error code
---------------------------------------------------------------------------
16.DOS/3Fh - Read From File:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 3Fh
BX = file handle
ECX = number of bytes to read
DS:EDX -> buffer to read to
Out: if successful:
carry flag clear
EAX = number of bytes read
if failed:
carry flag set
EAX = error code
---------------------------------------------------------------------------
17.DOS/40h - Write To File:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 40h
BX = file handle
ECX = number of bytes to write
DS:EDX -> buffer to write from
Out: if successful:
carry flag clear
EAX = number of bytes written
if failed:
carry flag set
EAX = error code
---------------------------------------------------------------------------
18.DOS/41h - Delete File:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 41h
DS:EDX -> ASCIIZ path name
Out: if successful:
carry flag clear
if failed:
carry flag set
EAX = error code
---------------------------------------------------------------------------
19.DOS/43h - Get/Set File Attributes:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 43h
AL = function code
CX = desired attributes
DS:EDX -> ASCIIZ path name
Out: if successful:
carry flag clear
CX = current attributes
if failed:
carry flag set
EAX = error code
---------------------------------------------------------------------------
20.DOS/47h - Get Directory Path:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 47h
DL = drive number
DS:ESI -> buffer for path
Out: if successful:
carry flag clear
buffer pointed to by DS:ESI is filled with the path
if failed:
carry flag set
EAX = error code
---------------------------------------------------------------------------
21.DOS/48h - Allocate Memory Block:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 48h
BX = paragraphs to allocate
Out: if successful:
carry flag clear
EAX = selector for memory block
if failed:
carry flag set
EAX = error code
EBX = maximum paragraphs available
---------------------------------------------------------------------------
22.DOS/49h - Free Memory Block:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 49h
ES = selector for memory block
Out: if successful:
carry flag clear
ES = NULL selector (to prevent loading invalid selector)
if failed:
carry flag set
EAX = error code
---------------------------------------------------------------------------
23.DOS/4Ah - Resize Memory Block:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 4Ah
BX = total paragraphs to allocate
ES = selector
Out: if successful:
carry flag clear
if failed:
carry flag set
EAX = error code
EBX = maximum paragraphs available for specified block
---------------------------------------------------------------------------
24.DOS/4Bh - Sub-Function 00h - Load and Execute Program:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 4Bh
AL = 00h
DS:EDX -> path name
ES:EBX -> parameter block
Out: if successful:
carry flag clear
if failed:
carry flag set
EAX = error code
---------------------------------------------------------------------------
25.DOS/4Eh - Search for First Filename Match:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 4Eh
CX = file attribute
DS:EDX -> ASCIIZ path name
Out: if successful:
carry flag clear
EAX = 0
if failed:
carry flag set
EAX = error code
---------------------------------------------------------------------------
26.DOS/4Fh - Search for Next Filename Match:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 4Fh
Out: if successful:
carry flag clear
EAX = 0
if failed:
carry flag set
EAX = error code
---------------------------------------------------------------------------
27.DOS/56h - Rename File:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 56h
DS:EDX -> old filename
ES:EDI -> new filename
Out: if successful:
carry flag clear
if failed:
carry flag set
EAX = error code
---------------------------------------------------------------------------
28.DOS/5Bh - New File:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 5Bh
CX = attribute
DS:EDX -> ASCIIZ path name
Out: if successful:
carry flag clear
EAX = handle
if failed:
carry flag set
EAX = error code
---------------------------------------------------------------------------
29.DOS/62h - Get PSP:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AH = 62h
Out: always successful:
EBX PSP selector
---------------------------------------------------------------------------
1.MOUSE/0009h - Set graphics pointer shape
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AX = 0009h
BX = hot spot (horizontal)
CX = hot spot (vertical)
DS:EDX -> pointer shape
Out: none
---------------------------------------------------------------------------
2.MOUSE/000Ch - Set event handler
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AX = 000Ch
CX = event mask
DS:EDX -> event handler code
Out: none
---------------------------------------------------------------------------
3.MOUSE/0016h - Save driver state
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AX = 0016h
DS:EDX -> buffer for driver state
Out: none
---------------------------------------------------------------------------
4.MOUSE/0017h - Load driver state
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In: AX = 0017h
DS:EDX -> buffer containing state
Out: none
---------------------------------------------------------------------------
The DOC files for D3X may be not complete, as I'm working on this alone and there are things I can't figure out for now... If you have something decent to comment/ask/suggest, do not hesitate to do so.
Creditz:
Adam Seychell (DOS32 v0.1) - idea and basics CW Sandmann (CWSDPMI v0.90+ r4) - task and int handling Matthias Grimrath (PMODE/DJ v1.2) - VCPI setup Michael Tippach (WDOSX v0.96 beta 1) - LE loaderGreetz:
Zeratul ~ AG (Gfx/Code/Muzak) - happy new games, if any...