Jump to content

Executable File Header Utility

From EDM2

The Executable File Header Utility (EXEHDR.EXE) displays and modifies the contents of an executable-file header. EXEHDR generates an Output listing showing the contents of the file header and information about each object or segment in the file. Options are provided that let you change values in the file header.

Uses of EXEHDR include:

  • Determining whether a file is an application or a dynamic link library
  • Viewing and changing the attributes set by the module definition file
  • Viewing the number and size of code and data segments.

You can use EXEHDR with DOS or OS/2 applications and dynamic-link libraries.

Operating System/2 Executable File Header Utility was included with:

Usage

EXEHDR [options] filename...

Regardless of options, EXEHDR always creates an Output listing of the file header.

Options

<options>
Options used to modify Output or change the file header.

Valid options are:

/? or /HELP
To display EXEHDR help, type EXEHDR /? at the command prompt. The appropriate copyright statement appears along with a brief list of EXEHDR options.

/HEAP:(0H - ffffH) or /HEA[P]:nnnn

Set Heap Allocation (/HEAP)
This option sets the size of the local heap and is applicable to OS/2 applications only. The field <nnnn> contains the local heap size in bytes.
You can specify <nnnn> in decimal, octal, or hexadecimal radix using standard C language notation.

/MAX:(0H - ffffH) or /MA[X]:nnnn

Set Maximum Allocation (/MAX)
This option sets the maximum allocation of memory for the program. The field <nnnn> contains the maximum number of 16-byte paragraphs required to load and run the program. This value must be equal to or greater than the minimum allocation.
The Maximum Allocation option is equivalent to the LINK386 /CParmaxalloc option.
Refer to Set Max Allocation Space (/CP) (in LINK386 Help)
You can specify <nnnn> in decimal, octal, or hexadecimal radix using standard C language notation.

/MIN:(0H - ffffH) or /MI[N]:nnnn

Set Minimum Allocation (/MIN)
This option sets the minimum allocation of memory for the program. The field <nnnn> contains the minimum number of 16-byte paragraphs required to load and run the program. This value must be equal to or less than the maximum allocation.
You can specify <nnnn> in decimal, octal, or hexadecimal radix using standard C language notation.
/NEWFILES or /NE[WFILES]
This option enables long file name support for OS/2 16-bit LINK files. OS/2 32-bit LINK386 files have long file name support.
/NOLOGO or /NO[LOGO]
Suppress Sign-On Banner
This option suppresses the sign-on banner displayed by EXEHDR when it starts.

/PMTYPE:(PM | VIO | NOVIO | WINDOWAPI | WINDOWCOMPAT | NOTWINDOWCOMPAT) or /P[MTYPE]:type

Set Application Type
This option specifies the type of application. It pertains only to OS/2 applications. The /PMTYPE option in EXEHDR is equivalent to either the NAME Statement in the module-definition file or the Name Application Type (/PM) in LINK386.
A keyword in <type> is equivalent to a keyword in a NAME statement, as shown in the following list:
Field Keyword Equiv. Keyword 
PM WINDOWAPI 
VIO WINDOWCOMPAT 
NOVIO NOTWINDOWCOMPAT 
The NAME statement keyword is also accepted.
/RESETERROR or /R[ESETERROR]
Reset LINK386 Error (/RESETERROR)
This option clears an error flag stored in OS/2 applications. The error flag is set by LINK386 when the link has unresolved external references or duplicate symbol definitions (any LINK386 error messages starting with L2xxx).
OS/2 does not load the application if the error flag is set. This option allows you to attempt to run a program with LINK386 errors and is useful during application development.

/STACKDOS:(0H - ffffH) or /STACKDOS:nnnn

Set DOS Stack Allocation (/STACKDOS)
This option sets the size of the stack in the DOS header. The field nnnn contains the stack size in bytes. This option is equivalent to the Control Stack Size (/ST) (in LINK). DOS modules have a maximum stack size of 65,535.
Almost all OS/2 applications have a DOS header and DOS stub. The DOS stub normally is found in 3 forms. First, the LINK386 default stub. This simply prints an error message and exits the DOS program. It will say something like "Can only be run from Presentation Manager". The second common stub type is a FAPI (Family API) program. This allow the applications to be run equally from a real DOS machine, an OS/2 or Windows DOS box, or from an OS/2 protected mode session. Most of the OS/2 system utilities are written with FAPI. :Third stub type is independant DOS and OS/2 binary images in one single application. The DOS .exe is included in the OS/2 STUB statement of the LINK386 .def file.
You can specify nnnn in decimal, hexadecimal, or octal radix using standard C language notation. For instance, a DOS stack size of 4,096 bytes can be expressed as any of the following:
  • /STACKDOS:4096
  • /STACKDOS:0x1000
  • /STACKDOS:010000

/STACKOS2:(0H - ffffffffH) or /STACKOS2:nnnn

Set OS/2 Stack Allocation (/STACKOS2)
This option sets the size of the stack in the OS/2 header. The field nnnn contains the stack size in bytes. This option is equivalent to the Control Stack Size (/ST) (in LINK386 Help). OS/2 16-bit NE modules have a maximum stack size of 65,535. OS/2 32-bit LX modules have a maximum stack size of 4,294,967,295. The /STACKOS2 only changes the OS/2 header and has no effect on the DOS stub in the same module.
You can specify nnnn in decimal, hexadecimal, or octal radix using standard C language notation. For instance, an OS/2 stack size of 32,768 bytes can be expressed as any of the following:
  • /STACKOS2:32768
  • /STACKOS2:0x8000
  • /STACKOS2:0100000
DO NOT USE /STACK
There is an old EXEHDR option /STACK that performed a function similar to /STACKDOS and /STACKOS2 combined. The old /STACK option has serious limitations and potentially dangerous side effects. It it very strongly recommended that you do not use /STACK, and start using /STACKDOS and /STACKOS2 instead. For an old DOS only application, the /STACK option should work just fine. For a 32-bit OS/2 application, the old /STACK will change only the DOS stub stack header, not the OS/2 header. For a 16-bit OS/2 application, the old /STACK option will attempt to change both the DOS stub and OS/2 header stack values to the same nnnn value. This is potentially disasterous. The DOS stub and OS/2 headers are sometimes independant of each other. Attempts to change one might have disasterous results in the other. Since there are 2 stacks in 2 different headers in the same application there needs to be 2 different options: /STACKDOS and /STACKOS2.
/VERBOSE or /V[ERBOSE]
Display in Verbose Mode (/VERBOSE)
This option displays the executable-file header in verbose mode.
<filename>
One or more names of applications or dynamic-link library files.
Notes
Note that for OS/2 16-bit NE modules the maximum value for /STACKOS2 is FFFFh.
Option characters are not case sensitive: /R and /r are equivalent.
Options can be shortened to the fewest characters that uniquely identify them. The characters in brackets can be omitted: /N and /NOLOGO are equivalent.
Although use of the minimum one-letter abbreviations is allowed, if a future release has an additional option starting with the same letter, the one-letter option will no longer be usable.
The option /STACK is deprecated, and has been replaced by /STACKDOS and /STACKOS2. Because /STACK has serious limitations and can potentially damage an executable file, it is strongly recommended that you do not use it. Use one or both of the replacement options instead.
Executable headers are used by the operating system to determine characteristics of the executable file, such as stack size, entry point, number of objects (or segments), and so on. EXEHDR recognizes three different kinds of executable headers: DOS (generated by DOS linker), OS/2 16-bit (generated by LINK), and OS/2 32-bit (generated by LINK386).

Output

EXEHDR lists the current contents of the file header and information about each object (or segment) in the file. To redirect this output to a printer or disk file, use the operating system redirection operator.

The output is in two parts: a Header Listing giving the contents of the file header; and an Object or Segment Listing giving attributes of all objects (or segments) in the file. If the /VERBOSE option is specified, additional output is generated.

Header Listing

The header listing is comprised of the following fields:

<Module> Name of Application
This field lists the name of the application as specified in the NAME statement of the module-definition file.
If no module definition was used to create the executable file, this field displays the name assumed by default.
If a module definition was used to create the file, but the LIBRARY statement appeared instead of the NAME statement (thus specifying a dynamic-link library), the name of the library is given and EXEHDR uses the word "Library" instead of "Module" to identify the field.
<Description> Description of Application
This field gives the contents, if any, of the DESCRIPTION statement of the module-definition file used to create the file being examined.
Type of Automatic Data Object
This field indicates the type of automatic data segment in a program: SHARED, NONSHARED, or NONE. This type can be specified in a module-definition file. The defaults are NONSHARED for applications and SHARED for dynamic-link libraries.

<Initial CS:IP> Program Starting Address

This field gives the program starting address (if an application is being examined) or address of the initialization routine (if a dynamic-link library is being examined).
<Initial SS
SP> Initial Stack Pointer
This field gives the value of the initial stack pointer.
<Extra Stack Allocation> Additional stack allocation
This field gives the value of the extra stack location.
<DGROUP> Automatic-Data-Object Number

Object or Segment Listing

The object listing is comprised of the following fields:

no.
Object index number, starting with 1, in decimal
type
Identification of the object as a code or data object
A code object is comprised of segments with class name ending in CODE. All other objects are data objects.
address Location
within the file, of the contents of the object (in hexadecimal)
file
Size of the object (in bytes), as contained in the file (in hexadecimal)
mem
Size of the object (in bytes), as it is stored in memory (in hexadecimal)
If the value of this field is greater than the value of <file>, the operating system pads the additional space with zero values at load time.
flags
Object attributes
If the /VERBOSE option is not used, only non-default attributes are listed. Attributes are given in the form specified in the module-definition file.

Object Example

The following output is generated by EXEHDR for the executable file LINK386.EXE:

Module: LINK386 Description: Operating System/2 32-bit LX Linker Data: NONSHARED Initial CS:IP: seg 2 offset 6c78 Initial SS:SP: seg 4 offset 0000 Extra stack allocation: 4000 bytes DGROUP: seg 4

no. type address file mem flags

 1 CODE 00006000 0f7d6 0f7d7
 2 CODE 00015a00 08e40 08e40
 3 DATA 0001ea00 02865 02865
 4 DATA 00021400 02337 08bd0

Verbose Output

When you specify the /VERBOSE option, EXEHDR generates additional output:

  • DOS-specific header information. All OS/2 executable files have a DOS header, whether bound or not. If the program is not bound, the DOS portion typically consists of a stub that simply terminates the program.
  • OS/2-specific header information. The object-table display in verbose mode is described below.
  • File addresses and lengths of the various tables in the executable file. For each table, the following is generated:
  • Name of the table
  • Address of the table within the file
  • Length of the table in hexadecimal radix
  • Length of the table in decimal radix
  • Object table with complete attributes, not just the non-default attributes. The /VERBOSE option displays two additional attributes:
  • The RELOCS attribute is displayed for each object that has address relocations. Relocations occur in each object that references objects in other objects or makes dynamic-link references.
  • The ITERATED attribute is displayed for each object that has iterated data. Iterated data consist of a special code that packs repeated bytes.
  • Run-time relocations and fixups.
  • All exported entry points.

Error Messages

EXEHDR error messages:

EXH1100: invalid magic number xxxxH {#define ER_badmagic} EXEHDR discovered an unknown signature xxxx in the header for the file. The signature in the header of a file identifies the type of .EXE to the operating system. EXEHDR only recognizes signatures for DOS (5A4DH) and OS/2 (454EH and 584CH) files. Make sure the file is not a DOS .com image. Also make sure that it is a DOS or OS/2 .EXE file. Many Windows and Linux files have a different signature.

EXH1101: automatic data segment greater than 64K; correcting heap size {#define ER_autodata1} There was not enough space in the automatic data segment to accommodate the requested new heap size. The heap size has been adjusted to the maximum available space. This error only occurs for 16-bit OS/2 applications. If /HEAP or /STACKOS2 is used then the total size of DGROUP plus the heap plus the stack must be less than 64K. The heap will be assigned 64K-1-DGROUP-STACK. EXEHDR issues this warning that it performed the .EXE file modification with a reduced HEAP value. Make sure the reduced value is acceptable.

EXH1102: automatic data segment greater than 64K; correcting stack size {#define ER_autodata2} There was not enough space in the automatic data segment to accommodate the requested new stack size. The stack size has been adjusted to the maximum available space. This error only occurs for 16-bit OS/2 applications. If /HEAP or /STACKOS2 is used then the total size of DGROUP plus the heap plus the stack must be less than 64K. This error occurs when the heap is zero. The stack will be assigned 64K-1-DGROUP. ACTION: EXEHDR issues this warning that it performed the .EXE file modification with a reduced STACK value. Make sure the reduced value is acceptable.

EXH1103: invalid .EXE file : actual length less than reported {#define ER_badsize} The second and third fields in the input DOS file header indicate a file size greater than the actual size of the file. This error occurs in DOS files only. EXEHDR assumes the file has been corrupted and will not perform any modifications.

EXH1104: cannot change load-high program {#define ER_high} When the minimum allocation value and the maximum allocation value are both 0, the file cannot be modified. Both minimum and maximum allocation of 0 is not a legal value for a DOS header. This is a DOS header only error condition. Change either /MIN or /MAX to a non-zero value.

EXH1105: minimum allocation less than stack; correcting minimum {#define ER_minalloc1} If the minimum allocation is not enough to accommodate the stack (either the original stack request or the modified request), the minimum allocation value is adjusted. This error applies only to DOS programs. This is a warning that EXEHDR has modified the /MIN value to create a legal DOS .EXE header. Make sure the new /MIN value is acceptable.

EXH1106: minimum allocation greater than maximum; correcting maximum {#define ER_minalloc2} If the minimum allocation is greater than the maximum allocation, the maximum allocation value is adjusted. If a display of DOS header values is requested, the values shown will be the values after the packed file is expanded. This error applies only to DOS programs. This is a warning that EXEHDR has modified the /MAX value to create a legal DOS .EXE header. Make sure the new /MAX value is acceptable.

EXH1107: unexpected end of resident/nonresident name table {#define ER_minalloc2} While decoding run-time relocation records, EXEHDR found the end of the resident/nonresident name table. The .EXE file is probably corrupted. This error applies only to OS/2 and Windows programs. The current version of EXEHDR will not issue this error any longer. Therefore, report to IBM if you receive this error with the current version of EXEHDR.

EXH1108: unknown format of relocation records {#define ER_badreloc} EXEHDR cannot decode the information in the file header because the header is not in a standard format. The fixup relocation count is 0, which is not permitted. This error applies only to OS/2 and Windows programs.

EXH1109: illegal value 'xxxx' {#define ER_illval} A command-line argument to EXEHDR contained an illegal value. Retry the EXEHDR command with a correct option.

EXH1110: malformed number xxxx {#define ER_badnum} A command-line option for EXEHDR required a value, but the specified number was mistyped. Retry the EXEHDR command with a correct option.

EXH1111: option requires value {#define ER_noval} A command-line option for EXEHDR required a value, but no value was specified, or the specified value was in an illegal format for the given option. Retry the EXEHDR command with a correct option.

EXH1112: value out of legal range xxxx - xxxx {#define ER_range1} A command-line option for EXEHDR required a value, but the specified number did not fall in the required decimal range. The current version of EXEHDR will not issue this error any longer. Therefore, report to IBM if you receive this error with the current version of EXEHDR.

EXH1113: value out of legal range xxxxH - xxxxH {#define ER_range2} A command-line option for EXEHDR required a value, but the specified number did not fall in the required hexadecimal range. Retry the EXEHDR command with a correct option.

EXH1114: missing option value; option xxxx ignored {#define ER_noval1} A command-line option for EXEHDR required a value, but nothing was specified. EXEHDR ignored the option. Retry the EXEHDR command with a correct option.

EXH1115: option xxxx ignored {#define ER_igno} A command-line option for EXEHDR was ignored. This error usually occurs with error U1116, unrecognized option. Retry the EXEHDR command with a correct option.

EXH1116: unrecognized option: xxxx {#define ER_unrec} A command-line option for EXEHDR was not recognized. This error usually occurs with either U1115, option ignored, or U1111, option requires value. Retry the EXEHDR command with a correct option.

EXH1117: The same option has been used more than once {#define ER_twice} You are not permitted to enter the same option more than once. Correct the command line by only entering each option only once.

EXH1118: Invalid option combination xxxx {#define ER_combine} Certain options can not be used together. For instance, /STACK is deprecated and replace by /STACKDOS and /STACKOS2. You are not permitted to use /STACK in combination with the replacement options. Remove the offending option.

EXH1119: /STACK deprecated, use /STACKDOS and/or /STACKOS2 {#define ER_stackdep} The /STACK option should not be used any longer. Use the /STACKDOS and/or /STACKOS2 options instead. /STACK does not work on the LX 32-bit OS/2 binary files. Furthermore, on NE 16-bit OS/2 and Windows binary files it will attempt to change both the MZ DOS stub and the 16-bit NE stack values. This is potentially dangerous because the 2 stacks may have no relationship to each other. By changing one, you could accidently damage the other. To distinguish which stack you want to change use /STACKDOS or /STACKOS2. If you happen to want to change both stacks, then use both the /STACKDOS and /STACKOS2 options. Remove the /STACK option from your command line. Use the /STACKDOS and/or /STACKOS2 options instead.

EXH1120: input file missing {#define ER_noinp} No input file was specified on the EXEHDR command line. Retry the EXEHDR command with a correct filename.

EXH1121: command line too long: xxxx {#define ER_cmdmax} The current version of EXEHDR will not issue this error any longer. Therefore, report to IBM if you receive this error with the current version of EXEHDR.

EXH1122: input filename too long: xxxx {#define ER_filmax} The specified filename is longer than the allowable filename size. The current maximum size is 256 characters. Retry the EXEHDR command with a correct filename.

EXH1124: Invalid information level requested {#define ER_badinfo} DLL call to FileVerParseModuleVersion returns rc=124.

EXH1130: cannot read 'xxxx' {#define ER_read} EXEHDR could not read the input file. Either the file is missing or the file attribute is set to prevent reading. Make sure the file was correctly specified. If EXEHDR file modifying options are specified, make sure the file is read/write accessable. File modifying options require the ability to write to the file.

EXH1131: not valid .EXE file {#define ER_illexe} The input file specified on the EXEHDR command line was not a valid .EXE file.

EXH1132: unexpected end-of-file {#define ER_eof} EXEHDR found an unexpected end-of-file condition while reading the .EXE file. The .EXE file is probably corrupt.

EXH1133: no Import Procedure Names Table {#define ER_noimptab}

EXH1134: loop in internal fixup chain {#define ER_chaincycle}

EXH1140: out of memory {#define ER_memovf} There was not enough memory for EXEHDR to decode the header of the executable file.

EXH1150: Not a valid module version value {#define ER_badmodver} A call to FileVerParseModuleVersion returns rc=150.


Versions
  • Version 4.01.003 (2003-12-11)
  • Version 4.01.001 (2001-10-04)