Annotation of os232sdk/toolkt20/c/os2h/newexe.h, revision 1.1

1.1     ! root        1: /*
        !             2:  *     SCCSID = @(#)newexe.h   13.4 89/06/26
        !             3:  *
        !             4:  *  Title
        !             5:  *
        !             6:  *     newexe.h
        !             7:  *     (C) Copyright Microsoft Corp 1984-1987
        !             8:  *
        !             9:  *  Description
        !            10:  *
        !            11:  *     Data structure definitions for the DOS 4.0/Windows 2.0
        !            12:  *     executable file format.
        !            13:  *
        !            14:  */
        !            15: 
        !            16: 
        !            17: 
        !            18:     /*_________________________________________________________________*
        !            19:      |                                                                 |
        !            20:      |                                                                 |
        !            21:      | DOS3 .EXE FILE HEADER DEFINITION                               |
        !            22:      |                                                                 |
        !            23:      |_________________________________________________________________|
        !            24:      *                                                                 */
        !            25: 
        !            26: 
        !            27: #define EMAGIC         0x5A4D          /* Old magic number */
        !            28: #define ENEWEXE        sizeof(struct exe_hdr)
        !            29:                                        /* Value of E_LFARLC for new .EXEs */
        !            30: #define ENEWHDR        0x003C          /* Offset in old hdr. of ptr. to new */
        !            31: #define ERESWDS        0x0010          /* No. of reserved words (OLD) */
        !            32: #define ERES1WDS       0x0004          /* No. of reserved words in e_res */
        !            33: #define ERES2WDS       0x000A          /* No. of reserved words in e_res2 */
        !            34: #define ECP            0x0004          /* Offset in struct of E_CP */
        !            35: #define ECBLP          0x0002          /* Offset in struct of E_CBLP */
        !            36: #define EMINALLOC      0x000A          /* Offset in struct of E_MINALLOC */
        !            37: 
        !            38: struct exe_hdr                         /* DOS 1, 2, 3 .EXE header */
        !            39:   {
        !            40:     unsigned short     e_magic;        /* Magic number */
        !            41:     unsigned short     e_cblp;         /* Bytes on last page of file */
        !            42:     unsigned short     e_cp;           /* Pages in file */
        !            43:     unsigned short     e_crlc;         /* Relocations */
        !            44:     unsigned short     e_cparhdr;      /* Size of header in paragraphs */
        !            45:     unsigned short     e_minalloc;     /* Minimum extra paragraphs needed */
        !            46:     unsigned short     e_maxalloc;     /* Maximum extra paragraphs needed */
        !            47:     unsigned short     e_ss;           /* Initial (relative) SS value */
        !            48:     unsigned short     e_sp;           /* Initial SP value */
        !            49:     unsigned short     e_csum;         /* Checksum */
        !            50:     unsigned short     e_ip;           /* Initial IP value */
        !            51:     unsigned short     e_cs;           /* Initial (relative) CS value */
        !            52:     unsigned short     e_lfarlc;       /* File address of relocation table */
        !            53:     unsigned short     e_ovno;         /* Overlay number */
        !            54:     unsigned short     e_res[ERES1WDS];/* Reserved words */
        !            55:     unsigned short     e_oemid;        /* OEM identifier (for e_oeminfo) */
        !            56:     unsigned short     e_oeminfo;      /* OEM information; e_oemid specific */
        !            57:     unsigned short     e_res2[ERES2WDS];/* Reserved words */
        !            58:     long               e_lfanew;       /* File address of new exe header */
        !            59:   };
        !            60: 
        !            61: #define E_MAGIC(x)     (x).e_magic
        !            62: #define E_CBLP(x)      (x).e_cblp
        !            63: #define E_CP(x)        (x).e_cp
        !            64: #define E_CRLC(x)      (x).e_crlc
        !            65: #define E_CPARHDR(x)   (x).e_cparhdr
        !            66: #define E_MINALLOC(x)  (x).e_minalloc
        !            67: #define E_MAXALLOC(x)  (x).e_maxalloc
        !            68: #define E_SS(x)        (x).e_ss
        !            69: #define E_SP(x)        (x).e_sp
        !            70: #define E_CSUM(x)      (x).e_csum
        !            71: #define E_IP(x)        (x).e_ip
        !            72: #define E_CS(x)        (x).e_cs
        !            73: #define E_LFARLC(x)    (x).e_lfarlc
        !            74: #define E_OVNO(x)      (x).e_ovno
        !            75: #define E_RES(x)       (x).e_res
        !            76: #define E_OEMID(x)     (x).e_oemid
        !            77: #define E_OEMINFO(x)   (x).e_oeminfo
        !            78: #define E_RES2(x)      (x).e_res2
        !            79: #define E_LFANEW(x)    (x).e_lfanew
        !            80: 
        !            81: 
        !            82:     /*_________________________________________________________________*
        !            83:      |                                                                 |
        !            84:      |                                                                 |
        !            85:      | OS/2 & WINDOWS .EXE FILE HEADER DEFINITION - 286 version       |
        !            86:      |                                                                 |
        !            87:      |_________________________________________________________________|
        !            88:      *                                                                 */
        !            89: 
        !            90: #define NEMAGIC        0x454E          /* New magic number */
        !            91: #define NERESBYTES     8               /* Eight bytes reserved (now) */
        !            92: #define NECRC          8               /* Offset into new header of NE_CRC */
        !            93: 
        !            94: struct new_exe                         /* New .EXE header */
        !            95:   {
        !            96:     unsigned short     ne_magic;       /* Magic number NE_MAGIC */
        !            97:     unsigned char      ne_ver;         /* Version number */
        !            98:     unsigned char      ne_rev;         /* Revision number */
        !            99:     unsigned short     ne_enttab;      /* Offset of Entry Table */
        !           100:     unsigned short     ne_cbenttab;    /* Number of bytes in Entry Table */
        !           101:     long               ne_crc;         /* Checksum of whole file */
        !           102:     unsigned short     ne_flags;       /* Flag word */
        !           103:     unsigned short     ne_autodata;    /* Automatic data segment number */
        !           104:     unsigned short     ne_heap;        /* Initial heap allocation */
        !           105:     unsigned short     ne_stack;       /* Initial stack allocation */
        !           106:     long               ne_csip;        /* Initial CS:IP setting */
        !           107:     long               ne_sssp;        /* Initial SS:SP setting */
        !           108:     unsigned short     ne_cseg;        /* Count of file segments */
        !           109:     unsigned short     ne_cmod;        /* Entries in Module Reference Table */
        !           110:     unsigned short     ne_cbnrestab;   /* Size of non-resident name table */
        !           111:     unsigned short     ne_segtab;      /* Offset of Segment Table */
        !           112:     unsigned short     ne_rsrctab;     /* Offset of Resource Table */
        !           113:     unsigned short     ne_restab;      /* Offset of resident name table */
        !           114:     unsigned short     ne_modtab;      /* Offset of Module Reference Table */
        !           115:     unsigned short     ne_imptab;      /* Offset of Imported Names Table */
        !           116:     long               ne_nrestab;     /* Offset of Non-resident Names Table */
        !           117:     unsigned short     ne_cmovent;     /* Count of movable entries */
        !           118:     unsigned short     ne_align;       /* Segment alignment shift count */
        !           119:     unsigned short     ne_cres;        /* Count of resource entries */
        !           120:     unsigned char      ne_exetyp;      /* Target operating system */
        !           121:     unsigned char      ne_flagsothers; /* Other .EXE flags */
        !           122:     char               ne_res[NERESBYTES];
        !           123:                                        /* Pad structure to 64 bytes */
        !           124:   };
        !           125: 
        !           126: #define NE_MAGIC(x)        (x).ne_magic
        !           127: #define NE_VER(x)          (x).ne_ver
        !           128: #define NE_REV(x)          (x).ne_rev
        !           129: #define NE_ENTTAB(x)       (x).ne_enttab
        !           130: #define NE_CBENTTAB(x)     (x).ne_cbenttab
        !           131: #define NE_CRC(x)          (x).ne_crc
        !           132: #define NE_FLAGS(x)        (x).ne_flags
        !           133: #define NE_AUTODATA(x)     (x).ne_autodata
        !           134: #define NE_HEAP(x)         (x).ne_heap
        !           135: #define NE_STACK(x)        (x).ne_stack
        !           136: #define NE_CSIP(x)         (x).ne_csip
        !           137: #define NE_SSSP(x)         (x).ne_sssp
        !           138: #define NE_CSEG(x)         (x).ne_cseg
        !           139: #define NE_CMOD(x)         (x).ne_cmod
        !           140: #define NE_CBNRESTAB(x)     (x).ne_cbnrestab
        !           141: #define NE_SEGTAB(x)       (x).ne_segtab
        !           142: #define NE_RSRCTAB(x)      (x).ne_rsrctab
        !           143: #define NE_RESTAB(x)       (x).ne_restab
        !           144: #define NE_MODTAB(x)       (x).ne_modtab
        !           145: #define NE_IMPTAB(x)       (x).ne_imptab
        !           146: #define NE_NRESTAB(x)      (x).ne_nrestab
        !           147: #define NE_CMOVENT(x)      (x).ne_cmovent
        !           148: #define NE_ALIGN(x)        (x).ne_align
        !           149: #define NE_CRES(x)         (x).ne_cres
        !           150: #define NE_RES(x)          (x).ne_res
        !           151: #define NE_EXETYP(x)       (x).ne_exetyp
        !           152: #define NE_FLAGSOTHERS(x)   (x).ne_flagsothers
        !           153: 
        !           154: #define NE_USAGE(x)    (WORD)*((WORD *)(x)+1)
        !           155: #define NE_PNEXTEXE(x) (WORD)(x).ne_cbenttab
        !           156: #define NE_ONEWEXE(x)  (WORD)(x).ne_crc
        !           157: #define NE_PFILEINFO(x) (WORD)((DWORD)(x).ne_crc >> 16)
        !           158: 
        !           159: 
        !           160: /*
        !           161:  *  Target operating systems
        !           162:  */
        !           163: 
        !           164: #define NE_UNKNOWN     0x0             /* Unknown (any "new-format" OS) */
        !           165: #define NE_OS2         0x1             /* Microsoft/IBM OS/2 (default)  */
        !           166: #define NE_WINDOWS     0x2             /* Microsoft Windows */
        !           167: #define NE_DOS4        0x3             /* Microsoft MS-DOS 4.x */
        !           168: #define NE_DEV386       0x4             /* Microsoft Windows 386 */
        !           169: 
        !           170: 
        !           171: /*
        !           172:  *  Format of NE_FLAGS(x):
        !           173:  *
        !           174:  *  p                                  Not-a-process
        !           175:  *   x                                 Unused
        !           176:  *    e                                Errors in image
        !           177:  *     x                               Unused
        !           178:  *     b                               Bound Family/API
        !           179:  *       ttt                           Application type
        !           180:  *         f                           Floating-point instructions
        !           181:  *          3                          386 instructions
        !           182:  *           2                         286 instructions
        !           183:  *            0                        8086 instructions
        !           184:  *             P                       Protected mode only
        !           185:  *              p                      Per-process library initialization
        !           186:  *               i                     Instance data
        !           187:  *                s                    Solo data
        !           188:  */
        !           189: #define NENOTP         0x8000          /* Not a process */
        !           190: #define NEIERR         0x2000          /* Errors in image */
        !           191: #define NEBOUND        0x0800          /* Bound Family/API */
        !           192: #define NEAPPTYP       0x0700          /* Application type mask */
        !           193: #define NENOTWINCOMPAT 0x0100          /* Not compatible with P.M. Windowing */
        !           194: #define NEWINCOMPAT    0x0200          /* Compatible with P.M. Windowing */
        !           195: #define NEWINAPI       0x0300          /* Uses P.M. Windowing API */
        !           196: #define NEFLTP         0x0080          /* Floating-point instructions */
        !           197: #define NEI386         0x0040          /* 386 instructions */
        !           198: #define NEI286         0x0020          /* 286 instructions */
        !           199: #define NEI086         0x0010          /* 8086 instructions */
        !           200: #define NEPROT         0x0008          /* Runs in protected mode only */
        !           201: #define NEPPLI         0x0004          /* Per-Process Library Initialization */
        !           202: #define NEINST         0x0002          /* Instance data */
        !           203: #define NESOLO         0x0001          /* Solo data */
        !           204: 
        !           205: /*
        !           206:  *  Format of NE_FLAGSOTHERS(x):
        !           207:  *
        !           208:  *      7 6 5 4 3 2 1 0  - bit no
        !           209:  *                    |
        !           210:  *                    +---------------- Support for long file names
        !           211:  *
        !           212:  */
        !           213: 
        !           214: #define NELONGNAMES     0x01
        !           215: 
        !           216: 
        !           217: 
        !           218: struct new_seg                         /* New .EXE segment table entry */
        !           219:   {
        !           220:     unsigned short     ns_sector;      /* File sector of start of segment */
        !           221:     unsigned short     ns_cbseg;       /* Number of bytes in file */
        !           222:     unsigned short     ns_flags;       /* Attribute flags */
        !           223:     unsigned short     ns_minalloc;    /* Minimum allocation in bytes */
        !           224:   };
        !           225: 
        !           226: #define NS_SECTOR(x)   (x).ns_sector
        !           227: #define NS_CBSEG(x)    (x).ns_cbseg
        !           228: #define NS_FLAGS(x)    (x).ns_flags
        !           229: #define NS_MINALLOC(x) (x).ns_minalloc
        !           230: 
        !           231: 
        !           232: /*
        !           233:  *  Format of NS_FLAGS(x)
        !           234:  *
        !           235:  *  Flag word has the following format:
        !           236:  *
        !           237:  *     15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0  - bit no
        !           238:  *         |  |  |  |  | | | | | | | | | | |
        !           239:  *         |  |  |  |  | | | | | | | | +-+-+--- Segment type DATA/CODE
        !           240:  *         |  |  |  |  | | | | | | | +--------- Iterated segment
        !           241:  *         |  |  |  |  | | | | | | +----------- Movable segment
        !           242:  *         |  |  |  |  | | | | | +------------- Segment can be shared
        !           243:  *         |  |  |  |  | | | | +--------------- Preload segment
        !           244:  *         |  |  |  |  | | | +----------------- Execute/read-only for code/data segment
        !           245:  *         |  |  |  |  | | +------------------- Segment has relocations
        !           246:  *         |  |  |  |  | +--------------------- Code conforming/Data is expand down
        !           247:  *         |  |  |  +--+----------------------- I/O privilege level
        !           248:  *         |  |  +----------------------------- Discardable segment
        !           249:  *         |  +-------------------------------- 32-bit code segment
        !           250:  *         +----------------------------------- Huge segment/GDT allocation requested
        !           251:  *
        !           252:  */
        !           253: 
        !           254: #define NSTYPE         0x0007          /* Segment type mask */
        !           255: 
        !           256: #if (EXE386 == 0)
        !           257: #define NSCODE         0x0000          /* Code segment */
        !           258: #define NSDATA         0x0001          /* Data segment */
        !           259: #define NSITER         0x0008          /* Iterated segment flag */
        !           260: #define NSMOVE         0x0010          /* Movable segment flag */
        !           261: #define NSSHARED       0x0020          /* Shared segment flag */
        !           262: #define NSPRELOAD      0x0040          /* Preload segment flag */
        !           263: #define NSEXRD         0x0080          /* Execute-only (code segment), or
        !           264:                                        *  read-only (data segment)
        !           265:                                        */
        !           266: #define NSRELOC        0x0100          /* Segment has relocations */
        !           267: #define NSCONFORM      0x0200          /* Conforming segment */
        !           268: #define NSEXPDOWN      0x0200          /* Data segment is expand down */
        !           269: #define NSDPL          0x0C00          /* I/O privilege level (286 DPL bits) */
        !           270: #define SHIFTDPL       10              /* Left shift count for SEGDPL field */
        !           271: #define NSDISCARD      0x1000          /* Segment is discardable */
        !           272: #define NS32BIT        0x2000          /* 32-bit code segment */
        !           273: #define NSHUGE         0x4000          /* Huge memory segment, length of
        !           274:                                         * segment and minimum allocation
        !           275:                                         * size are in segment sector units
        !           276:                                         */
        !           277: #define NSGDT          0x8000          /* GDT allocation requested */
        !           278: 
        !           279: #define NSPURE         NSSHARED        /* For compatibility */
        !           280: 
        !           281: #define NSALIGN 9      /* Segment data aligned on 512 byte boundaries */
        !           282: 
        !           283: #define NSLOADED    0x0004     /* ns_sector field contains memory addr */
        !           284: #endif
        !           285: 
        !           286: 
        !           287: struct new_segdata                     /* Segment data */
        !           288:   {
        !           289:     union
        !           290:       {
        !           291:        struct
        !           292:          {
        !           293:            unsigned short      ns_niter;       /* number of iterations */
        !           294:            unsigned short      ns_nbytes;      /* number of bytes */
        !           295:            char                ns_iterdata;    /* iterated data bytes */
        !           296:          } ns_iter;
        !           297:        struct
        !           298:          {
        !           299:            char                ns_data;        /* data bytes */
        !           300:          } ns_noniter;
        !           301:       } ns_union;
        !           302:   };
        !           303: 
        !           304: struct new_rlcinfo                     /* Relocation info */
        !           305:   {
        !           306:     unsigned short     nr_nreloc;      /* number of relocation items that */
        !           307:   };                                   /* follow */
        !           308: 
        !           309: #pragma pack(1)
        !           310: 
        !           311: 
        !           312: struct new_rlc                         /* Relocation item */
        !           313:   {
        !           314:     char               nr_stype;       /* Source type */
        !           315:     char               nr_flags;       /* Flag byte */
        !           316:     unsigned short     nr_soff;        /* Source offset */
        !           317:     union
        !           318:       {
        !           319:        struct
        !           320:          {
        !           321:            char        nr_segno;       /* Target segment number */
        !           322:            char        nr_res;         /* Reserved */
        !           323:            unsigned short nr_entry;    /* Target Entry Table offset */
        !           324:          }             nr_intref;      /* Internal reference */
        !           325:        struct
        !           326:          {
        !           327:            unsigned short nr_mod;      /* Index into Module Reference Table */
        !           328:            unsigned short nr_proc;     /* Procedure ordinal or name offset */
        !           329:          }             nr_import;      /* Import */
        !           330:        struct
        !           331:          {
        !           332:            unsigned short nr_ostype;   /* OSFIXUP type */
        !           333:            unsigned short nr_osres;    /* reserved */
        !           334:          }             nr_osfix;       /* Operating system fixup */
        !           335:       }                nr_union;       /* Union */
        !           336:   };
        !           337: 
        !           338: #pragma pack()
        !           339: 
        !           340: 
        !           341: #define NR_STYPE(x)    (x).nr_stype
        !           342: #define NR_FLAGS(x)    (x).nr_flags
        !           343: #define NR_SOFF(x)     (x).nr_soff
        !           344: #define NR_SEGNO(x)    (x).nr_union.nr_intref.nr_segno
        !           345: #define NR_RES(x)      (x).nr_union.nr_intref.nr_res
        !           346: #define NR_ENTRY(x)    (x).nr_union.nr_intref.nr_entry
        !           347: #define NR_MOD(x)      (x).nr_union.nr_import.nr_mod
        !           348: #define NR_PROC(x)     (x).nr_union.nr_import.nr_proc
        !           349: #define NR_OSTYPE(x)   (x).nr_union.nr_osfix.nr_ostype
        !           350: #define NR_OSRES(x)    (x).nr_union.nr_osfix.nr_osres
        !           351: 
        !           352: 
        !           353: 
        !           354: /*
        !           355:  *  Format of NR_STYPE(x) and R32_STYPE(x):
        !           356:  *
        !           357:  *      7 6 5 4 3 2 1 0  - bit no
        !           358:  *              | | | |
        !           359:  *              +-+-+-+--- source type
        !           360:  *
        !           361:  */
        !           362: 
        !           363: #define NRSTYP         0x0f            /* Source type mask */
        !           364: #define NRSBYT         0x00            /* lo byte (8-bits)*/
        !           365: #define NRSSEG         0x02            /* 16-bit segment (16-bits) */
        !           366: #define NRSPTR         0x03            /* 16:16 pointer (32-bits) */
        !           367: #define NRSOFF         0x05            /* 16-bit offset (16-bits) */
        !           368: #define NRPTR48        0x06            /* 16:32 pointer (48-bits) */
        !           369: #define NROFF32        0x07            /* 32-bit offset (32-bits) */
        !           370: #define NRSOFF32       0x08            /* 32-bit self-relative offset (32-bits) */
        !           371: 
        !           372: 
        !           373: /*
        !           374:  *  Format of NR_FLAGS(x) and R32_FLAGS(x):
        !           375:  *
        !           376:  *      7 6 5 4 3 2 1 0  - bit no
        !           377:  *                | | |
        !           378:  *                | +-+--- Reference type
        !           379:  *                +------- Additive fixup
        !           380:  */
        !           381: 
        !           382: #define NRADD          0x04            /* Additive fixup */
        !           383: #define NRRTYP         0x03            /* Reference type mask */
        !           384: #define NRRINT         0x00            /* Internal reference */
        !           385: #define NRRORD         0x01            /* Import by ordinal */
        !           386: #define NRRNAM         0x02            /* Import by name */
        !           387: #define NRROSF         0x03            /* Operating system fixup */
        !           388: 
        !           389: 
        !           390: #if (EXE386 == 0)
        !           391: 
        !           392: /* Resource type or name string */
        !           393: struct rsrc_string
        !           394:     {
        !           395:     char rs_len;           /* number of bytes in string */
        !           396:     char rs_string[ 1 ];    /* text of string */
        !           397:     };
        !           398: 
        !           399: #define RS_LEN( x )    (x).rs_len
        !           400: #define RS_STRING( x ) (x).rs_string
        !           401: 
        !           402: /* Resource type information block */
        !           403: struct rsrc_typeinfo
        !           404:     {
        !           405:     unsigned short rt_id;
        !           406:     unsigned short rt_nres;
        !           407:     long rt_proc;
        !           408:     };
        !           409: 
        !           410: #define RT_ID( x )   (x).rt_id
        !           411: #define RT_NRES( x ) (x).rt_nres
        !           412: #define RT_PROC( x ) (x).rt_proc
        !           413: 
        !           414: /* Resource name information block */
        !           415: struct rsrc_nameinfo
        !           416:     {
        !           417:     /* The following two fields must be shifted left by the value of  */
        !           418:     /* the rs_align field to compute their actual value.  This allows */
        !           419:     /* resources to be larger than 64k, but they do not need to be    */
        !           420:     /* aligned on 512 byte boundaries, the way segments are          */
        !           421:     unsigned short rn_offset;  /* file offset to resource data */
        !           422:     unsigned short rn_length;  /* length of resource data */
        !           423:     unsigned short rn_flags;   /* resource flags */
        !           424:     unsigned short rn_id;      /* resource name id */
        !           425:     unsigned short rn_handle;  /* If loaded, then global handle */
        !           426:     unsigned short rn_usage;   /* Initially zero.  Number of times */
        !           427:                                /* the handle for this resource has */
        !           428:                                /* been given out */
        !           429:     };
        !           430: 
        !           431: #define RN_OFFSET( x ) (x).rn_offset
        !           432: #define RN_LENGTH( x ) (x).rn_length
        !           433: #define RN_FLAGS( x )  (x).rn_flags
        !           434: #define RN_ID( x )     (x).rn_id
        !           435: #define RN_HANDLE( x ) (x).rn_handle
        !           436: #define RN_USAGE( x )  (x).rn_usage
        !           437: 
        !           438: #define RSORDID     0x8000     /* if high bit of ID set then integer id */
        !           439:                                /* otherwise ID is offset of string from
        !           440:                                   the beginning of the resource table */
        !           441: 
        !           442:                                /* Ideally these are the same as the */
        !           443:                                /* corresponding segment flags */
        !           444: #define RNMOVE     0x0010      /* Moveable resource */
        !           445: #define RNPURE     0x0020      /* Pure (read-only) resource */
        !           446: #define RNPRELOAD   0x0040     /* Preloaded resource */
        !           447: #define RNDISCARD   0xF000     /* Discard priority level for resource */
        !           448: 
        !           449: /* Resource table */
        !           450: struct new_rsrc
        !           451:     {
        !           452:     unsigned short rs_align;   /* alignment shift count for resources */
        !           453:     struct rsrc_typeinfo rs_typeinfo;
        !           454:     };
        !           455: 
        !           456: #define RS_ALIGN( x ) (x).rs_align
        !           457: 
        !           458: 
        !           459: #endif /* NOT EXE386 */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.