;       SCCSID = @(#)loadvars.inc	6.1 90/11/17
;      SCCSID = @(#)loadvars.inc	6.2 90/01/24
; ****************************************************************************
; *                                                                          *
; *                       IBM/Microsoft Confidential                         *
; *                                                                          *
; *                 Copyright (c) IBM Corporation  1987, 1990                *
; *                 Copyright (c) Microsoft Corp.  1987, 1990                *
; *                           All Rights Reserved                            *
; *                                                                          *
; ****************************************************************************

;       Loader local stack equated variables
;       Old EXE Header format

oh_s    STRUC
oh_signature    dw      ?               ; Must contain 4D5A
oh_len_mod_512  dw      ?               ; Low 9 bits of length
oh_pages        dw      ?               ; Number of 512 byte pages
oh_rle_count    dw      ?               ; Count of reloc entries
oh_par_dir      dw      ?               ; # of paras before image
oh_min_BSS      dw      ?               ; Min # of paras of BSS
oh_max_BSS      dw      ?               ; Max # of paras of BSS
oh_SS           dw      ?               ; SS of image
oh_SP           dw      ?               ; SP of image
oh_chksum       dw      ?               ; Ignored checksum of file
oh_IP           dw      ?               ; IP of image
oh_CS           dw      ?               ; CS of image
oh_rle_table    dw      ?               ; Byte offset to reloc table
oh_iov          dw      ?               ; Overlay number( 0 for root )
oh_sym_tab      dd      ?               ; offset of symbol table in file
oh_40_BB        dw      ?               ; DOS 4.0 behavior bits
oh_win_BB       dw      ?               ; Windows behavior bits
oh_oem_ID       dw      ?               ; Reserved for OEM's
oh_oem_info     dw      ?               ; Reserved for OEM's
oh_res          dw      10 DUP (?)      ; Reserved for future use
oh_nhdr_offset  dd      ?               ; offset to new EXE header
oh_s    ENDS

EXE_VALID_SIGNATURE     EQU     "ZM"
EXE_VALID_OLDSIGNATURE  EQU     "MZ"

;       Relocation Data Item format

ri_s    STRUC
ri_stype        db      ?               ; relocation source type
ri_flags        db      ?               ; relocation target type
ri_source       dw      ?               ; relocation source offset
ri_target_seg   dw      ?               ; internal target segment index
ri_target_off   dw      ?               ; internal target entry offset index
ri_s    ENDS

ri_target_modnam EQU    ri_target_seg   ; import module name offset
ri_target_impnam EQU    ri_target_off   ; imoprt procedure name offset

SOURCE_MASK     EQU     07h
SEG_ADR         EQU     02h
FAR_ADR         EQU     03h
OFF_ADR         EQU     05h
TARGET_MASK     EQU     03h
INTERNALREF     EQU     00h
IMPORTORDINAL   EQU     01h
IMPORTNAME      EQU     02h
ADDITIVE        EQU     04h

;       ex_func, a stack variable set by the exec.asm to EXEC_TRACE
;       if the program is to be debugged

EXEC_TRACE      EQU     14

?frame          =       0

localvar        ex_lib_name,DWORD
localvar        ex_func,BYTE
localvar        ex_mode,BYTE
localvar        ex_fh,WORD
localvar        ex_mte,WORD
localvar        ex_seghndl,WORD
localvar        ex_seg_alias,WORD
localvar        ex_environ,WORD
localvar        ex_cmdoff,WORD
localvar        ex_filetype,WORD

BASE_VAR_LEN    =       ?frame
?temp           =       ?frame

localvar        ex_ibb,WORD
localvar        ex_ohdr,<SIZE oh_s>
localvar        ex_dma,WORD
localvar        ex_size,WORD
localvar        ex_load_block,WORD
localvar        ex_rel_fac,WORD
localvar        ex_res_len_para,WORD
localvar        ex_envstr,DWORD
localvar        ex_argstr,DWORD
localvar        ex_relbuf,32

OEXE_VAR_LEN    =       ((?frame + 1) AND 0FFFEh)
                                        ; overlay oldheader structure with
?frame          =       ?temp           ; newheader structure

localvar        ex_ste,WORD
localvar        ex_segno,WORD
localvar        ex_mte_sel,WORD
localvar        ex_tgtmte_sel,WORD
localvar        ex_dslen,WORD           ; length of DS, 0 = 64K
localvar        ex_envlen,WORD          ; length of environment segment
localvar        ex_reloc_item,<SIZE ri_s>

NEXE_VAR_LEN    =       ((?frame + 1) AND 0FFFEh)

ex_ss_sp        EQU (dword ptr ex_ste)
ex_cs_ip        EQU (dword ptr ex_reloc_item)
ex_ds           EQU (word ptr ex_tgtmte_sel)


;       buffer to save module name or procedure name

        buf_length      equ     64


;       loader temporary descriptor index values

LD_MTESEL       equ     0
LD_ENVSEL       equ     LD_MTESEL
LD_TMPSEL       equ     2
LD_RMPSEL       equ     4
GC_MTESEL       equ     LD_MTESEL
GC_TMPSEL       equ     LD_TMPSEL

LD_SELCOUNT     equ     3       ; number of decsriptors to allocate


rparm struc
rp_handle       dw      ?               ; handle to segment
rp_selector     dw      ?               ; GDT selector to use
rparm ends
