Microsoft KB Archive/59916

INF: Definition of Resource Table Section of OS/2 .EXE Header PSS ID Number: Q59916 Article last modified on 09-09-1991 PSS database name: P_PresMan

1.10 1.21

OS/2

Summary:

The definition of the resource table section of the executable header for OS/2 is not correct in either the documentation or the NEWEXE.H file that is supplied with some of the programming toolkits.

The correct definition of the resource table section of the executable header is listed below.

More Information:

The definition of the new .EXE header itself is correct in NEWEXE.H as follows:

struct new_exe /* New .EXE header / { unsigned short ne_magic; / Magic number NE_MAGIC / unsigned char ne_ver; / Version number / unsigned char ne_rev; / Revision number / unsigned short ne_enttab; / Offset of entry table / unsigned short ne_cbenttab; / Number of bytes in entry table / long ne_crc; / Checksum of whole file / unsigned short ne_flags; / Flag word / unsigned short ne_autodata; / Automatic data segment number / unsigned short ne_heap; / Initial heap allocation / unsigned short ne_stack; / Initial stack allocation / long ne_csip; / Initial CS:IP setting / long ne_sssp; / Initial SS:SP setting / unsigned short ne_cseg; / Count of file segments / unsigned short ne_cmod; / Entries in module reference table / unsigned short ne_cbnrestab; / Size of nonresident name table / unsigned short ne_segtab; / Offset of segment table / unsigned short ne_rsrctab; / Offset of resource table / unsigned short ne_restab; / Offset of resident name table / unsigned short ne_modtab; / Offset of module reference table / unsigned short ne_imptab; / Offset of imported names table / long ne_nrestab; / Offset of nonresident names table / unsigned short ne_cmovent; / Count of movable ent / unsigned short ne_align; / Segment alignment shift count / unsigned short ne_cres; / Count of resource entries / unsigned char ne_exetyp; / Target operating system / unsigned char ne_flagsothers; / Other .EXE flags / char ne_res[NERESBYTES]; / Pad structure to 64 bytes */ };

The ne_rsrctab field is the offset to the resource table from the beginning of the new .EXE header. The ne_cres field is the count of the number resources in the resource table and the number of resource segments that are located at the end of the segment table.

The resource table itself is an array of 4-byte structures defined as follows:

struct { ushort rt_id; /* Type of resource (MENU, DIALOG, POINTER, and so on.) / ushort rt_name; / ID of resource from .RC file */ };

The resource entries in the segment table are defined using the new_seg structure as follows:

struct new_seg /* New .EXE segment table entry / { unsigned short ns_sector; / File sector of start of segment / unsigned short ns_cbseg; / Number of bytes in file / unsigned short ns_flags; / Attribute flags / unsigned short ns_minalloc; / Minimum allocation in bytes */ };

See NEWEXE.H, which is available in the OS/2 version 1.0 Programmer’s Toolkit and also available in the Software/Data Library, for details on the segment table fields.

NEWEXE can be found in the Software/Data Library by searching on the keyword NEWEXE, the Q number of this article, or S12338. NEWEXE was archived using the PKware file-compression utility.

Copyright Microsoft Corporation 1991.