
subttl  EXEC and EXE file structures
page

;
; EXEC arg block - load/go program
;

;
; The following get used as arguments to the EXEC system call.  They indicate
; whether or not the program is executed or whether or not a program header
; gets created.
;
exec_func_no_execute    EQU 1           ; no execute bit
exec_func_overlay       EQU 2           ; overlay bit

Exec0           STRUC
Exec0_environ   DW      ?               ; seg addr of environment
Exec0_com_line  DD      ?               ; pointer to asciz command line
Exec0_5C_FCB    DD      ?               ; default fcb at 5C
Exec0_6C_FCB    DD      ?               ; default fcb at 6C
Exec0           ENDS

Exec1           STRUC
Exec1_environ   DW      ?               ; seg addr of environment
Exec1_com_line  DD      ?               ; pointer to asciz command line
Exec1_5C_FCB    DD      ?               ; default fcb at 5C
Exec1_6C_FCB    DD      ?               ; default fcb at 6C
Exec1_SP        DW      ?               ; stack pointer of program
Exec1_SS        DW      ?               ; stack seg register of program
Exec1_IP        DW      ?               ; entry point IP
Exec1_CS        DW      ?               ; entry point CS
Exec1           ENDS

Exec3           STRUC
Exec3_load_addr DW      ?               ; seg address of load point
Exec3_reloc_fac DW      ?               ; relocation factor
Exec3           ENDS

;
; int 21,4b05 implementation
;
;**     Data structure passed for ExecReady call

ERStruc         STRUC
ER_Reserved     dw      ?               ; reserved, should be zero
ER_Flags        dw      ?
ER_ProgName     dd      ?               ; ptr to ASCIIZ str of prog name
ER_PSP          dw      ?               ; PSP of the program
ER_StartAddr    dd      ?               ; Start CS:IP of the program
ER_ProgSize     dd      ?               ; Program size including PSP
ERStruc         ENDS

;** bit fields in ER_Flags

ER_EXE          equ     0001h
ER_OVERLAY      equ     0002h





;
; Exit codes in upper byte
;
Exit_terminate          EQU     0
Exit_abort              EQU     0
Exit_Ctrl_C             EQU     1
Exit_Hard_Error         EQU     2
Exit_Keep_process       EQU     3



;
; EXE file header
;

EXE_file        STRUC
exe_signature   dw      ?       ;+00h   ; must contain 4D5A  (yay zibo!)
exe_len_mod_512 dw      ?       ;+02h   ; low 9 bits of length
exe_pages       dw      ?       ;+04h   ; number of 512b pages in file
exe_rle_count   dw      ?       ;+06h   ; count of reloc entries
exe_par_dir     dw      ?       ;+08h   ; number of paragraphs before image
exe_min_BSS     dw      ?       ;+0Ah   ; minimum number of para of BSS
exe_max_BSS     dw      ?       ;+0Ch   ; max number of para of BSS
exe_SS          dw      ?       ;+0Eh   ; stack of image
exe_SP          dw      ?       ;+10h   ; SP of image
exe_chksum      dw      ?       ;+12h   ; checksum  of file (ignored)
exe_IP          dw      ?       ;+14h   ; IP of entry
exe_CS          dw      ?       ;+16h   ; CS of entry
exe_rle_table   dw      ?       ;+18h   ; byte offset of reloc table
exe_iov         dw      ?       ;+1Ah   ; overlay number (0 for root)
;------ The following fields may not be present.
; if EXE_RLE_TABLE==1Ch then not present
; if EXE_RLE_TABLE==1Eh then EXE_LINKER_VER present and valid
; if EXE_RLE_TABLE==20h then EXE_LINKER_VER field contains garbage
; if EXE_RLE_TABLE> 20h then EXE_LINKER_VER present and valid
;                                           =0 if "don't know"
exe_sym_tab     DD      ?       ;+1Ch   ; offset of symbol table in file
;------ The following fields may not be present.  If the EXE_RLE_TABLE
;       value encompasses the fields then they are present and valid.
exe_flags       dw      ?       ;+20h   ; flags: EKNOWEAS
                dw      ?       ;+22h   ; currently unused
exe_oem_ID      dw      ?       ;+24h   ; Reserved for OEM identifier
exe_oem_info    dw      ?       ;+26h   ; Reserved for OEM information
exe_pif_info    DD      ?       ;+28h   ; offset to PIF info
exe_pif_len     dw      ?       ;+2Ch   ; Length of PIF info, 0 if not present
                dw      7 dup(?);+2Eh   ; Reserved for future use
exe_nhdr_offset DD      ?       ;+3Ch   ; offset to new EXE header
EXE_file        ENDS
exe_Linker_ver  equ     word ptr EXE_SYM_TAB;+1Ch version # of producing linker
exe_Behavior    equ     word ptr EXE_FLAGS  ;+20h behavior bits

exe_valid_old_signature EQU 4D5Ah       ;"MZ"
exe_valid_signature     EQU 5A4Dh       ;"ZM" DOS magic number
exe_E32MAGIC            EQU 584Ch       ;"XL" New 32-bit magic number
exe_NEMAGIC             EQU 454Eh       ;"EN" New 16-bit magic number

symbol_entry    STRUC
sym_value       DD  ?
sym_type        DW  ?
sym_len         DB  ?
sym_name        DB  255 dup (?)
symbol_entry    ENDS


;32-bit OS/2 LX header is defined in \drf6\h\exe386.h
;16-bit OS/2 NE header is defined in \drf6\h\newexe.h

