close

線性執行模組敘述老資料,已經忘了在哪找的了 LX - Linear eXecutable Module Format Description June 3, 1992 Figure 1. 32-bit Linear EXE File Layout 00h +------------------+ <--+ | DOS 2 Compatible | | | EXE Header | | 1Ch +------------------+ | | unused | | +------------------+ | 24h | OEM Identifier | | 26h | OEM Info | | | | |-- DOS 2.0 Section 3Ch | Offset to | | (Discarded) | Linear EXE | | | Header | | 40h +------------------+ | | DOS 2.0 Stub | | | Program & | | | Reloc. Table | | +------------------+ <--+ | | xxh +------------------+ <--+ | Executable | | | Info | | +------------------+ | | Module | | | Info | | +------------------+ |-- Linear Executable | Loader Section | | Module Header | Info | | (Resident) +------------------+ | | Table Offset | | | Info | | +------------------+ <--+ | Object Table | | +------------------+ | | Object Page Table| | +------------------+ | | Resource Table | | +------------------+ | | Resident Name | | | Table | | +------------------+ |-- Loader Section | Entry Table | | (Resident) +------------------+ | | Module Format | | | Directives Table | | | (Optional) | | +------------------+ | | Resident | | | Directives Data | | | (Optional) | | | | | | (Verify Record) | | +------------------+ | | Per-Page | | | Checksum | | +------------------+ <--+ | Fixup Page Table | | +------------------+ | | Fixup Record | | | Table | | +------------------+ |-- Fixup Section | Import Module | | (Optionally Resident) | Name Table | | +------------------+ | | Import Procedure | | | Name Table | | +------------------+ <--+ | Preload Pages | | +------------------+ | | Demand Load | | | Pages | | +------------------+ | | Iterated Pages | | +------------------+ | | Non-Resident | |-- (Non-Resident) | Name Table | | +------------------+ | | Non-Resident | | | Directives Data | | | (Optional) | | | | | | (To be Defined) | | +------------------+ <--+ | Debug Info | |-- (Not used by Loader) +------------------+ <--+ Figure 2. 32-bit Linear EXE Header +-----+-----+-----+-----+-----+-----+-----+-----+ 00h | "L" "X" |B-ORD|W-ORD| FORMAT LEVEL | +-----+-----+-----+-----+-----+-----+-----+-----+ 08h | CPU TYPE | OS TYPE | MODULE VERSION | +-----+-----+-----+-----+-----+-----+-----+-----+ 10h | MODULE FLAGS | MODULE # OF PAGES | +-----+-----+-----+-----+-----+-----+-----+-----+ 18h | EIP OBJECT # | EIP | +-----+-----+-----+-----+-----+-----+-----+-----+ 20h | ESP OBJECT # | ESP | +-----+-----+-----+-----+-----+-----+-----+-----+ 28h | PAGE SIZE | PAGE OFFSET SHIFT | +-----+-----+-----+-----+-----+-----+-----+-----+ 30h | FIXUP SECTION SIZE | FIXUP SECTION CHECKSUM| +-----+-----+-----+-----+-----+-----+-----+-----+ 38h | LOADER SECTION SIZE |LOADER SECTION CHECKSUM| +-----+-----+-----+-----+-----+-----+-----+-----+ 40h | OBJECT TABLE OFF | # OBJECTS IN MODULE | +-----+-----+-----+-----+-----+-----+-----+-----+ 48h | OBJECT PAGE TABLE OFF | OBJECT ITER PAGES OFF | +-----+-----+-----+-----+-----+-----+-----+-----+ 50h | RESOURCE TABLE OFFSET |#RESOURCE TABLE ENTRIES| +-----+-----+-----+-----+-----+-----+-----+-----+ 58h | RESIDENT NAME TBL OFF | ENTRY TABLE OFFSET | +-----+-----+-----+-----+-----+-----+-----+-----+ 60h | MODULE DIRECTIVES OFF | # MODULE DIRECTIVES | +-----+-----+-----+-----+-----+-----+-----+-----+ 68h | FIXUP PAGE TABLE OFF |FIXUP RECORD TABLE OFF | +-----+-----+-----+-----+-----+-----+-----+-----+ 70h | IMPORT MODULE TBL OFF | # IMPORT MOD ENTRIES | +-----+-----+-----+-----+-----+-----+-----+-----+ 78h | IMPORT PROC TBL OFF | PER-PAGE CHECKSUM OFF | +-----+-----+-----+-----+-----+-----+-----+-----+ 80h | DATA PAGES OFFSET | #PRELOAD PAGES | +-----+-----+-----+-----+-----+-----+-----+-----+ 88h | NON-RES NAME TBL OFF | NON-RES NAME TBL LEN | +-----+-----+-----+-----+-----+-----+-----+-----+ 90h | NON-RES NAME TBL CKSM | AUTO DS OBJECT # | +-----+-----+-----+-----+-----+-----+-----+-----+ 98h | DEBUG INFO OFF | DEBUG INFO LEN | +-----+-----+-----+-----+-----+-----+-----+-----+ A0h | #INSTANCE PRELOAD | #INSTANCE DEMAND | +-----+-----+-----+-----+-----+-----+-----+-----+ A8h | HEAPSIZE | +-----+-----+-----+-----+ Note: The OBJECT ITER PAGES OFF must either be 0 or set to the same value as DATA PAGES OFFSET in OS/2 2.0. Ie., iterated pages are required to be in the same section of the file as regular pages. Note: Table offsets in the Linear EXE Header may be set to zero to indicate that the table does not exist in the EXE file and it's size is zero. "L" "X" = DW Signature word. The signature word is used by the loader to identify the EXE file as a valid 32-bit Linear Executable Module Format. "L" is low order byte. "X" is high order byte. B-ORD = DB Byte Ordering. This byte specifies the byte ordering for the linear EXE format. The values are: 00H - Little Endian Byte Ordering. 01H - Big Endian Byte Ordering. W-ORD = DB Word Ordering. This byte specifies the Word ordering for the linear EXE format. The values are: 00H - Little Endian Word Ordering. 01H - Big Endian Word Ordering. Format Level = DD Linear EXE Format Level. The Linear EXE Format Level is set to 0 for the initial version of the 32-bit linear EXE format. Each incompatible change to the linear EXE format must increment this value. This allows the system to recognized future EXE file versions so that an appropriate error message may be displayed if an attempt is made to load them. CPU Type = DW Module CPU Type. This field specifies the type of CPU required by this module to run. The values are: 01H - 80286 or upwardly compatible CPU is required to execute this module. 02H - 80386 or upwardly compatible CPU is required to execute this module. 03H - 80486 or upwardly compatible CPU is required to execute this module. OS Type = DW Module OS Type. This field specifies the type of Operating system required to run this module. The currently defined values are: 00H - Unknown (any "new-format" OS) 01H - OS/2 (default) 02H - Windows 03H - DOS 4.x 04H - Windows 386 MODULE VERSION = DD Version of the linear EXE module. This is useful for differentiating between revisions of dynamic linked modules. This value is specified at link time by the user. MODULE FLAGS = DD Flag bits for the module. The module flag bits have the following definitions. 00000001h = Reserved for system use. 00000002h = Reserved for system use. 00000004h = Per-Process Library Initialization. The setting of this bit requires the EIP Object # and EIP fields to have valid values. If the EIP Object # and EIP fields are valid and this bit is NOT set, then Global Library Initialization is assumed. Setting this bit for an EXE file is invalid. 00000008h = Reserved for system use. 00000010h = Internal fixups for the module have been applied. The setting of this bit in a Linear Executable Module indicates that each object of the module has a preferred load address specified in the Object Table Reloc Base Addr. If the module's objects can not be loaded at these preferred addresses, then the relocation records that have been retained in the file data will be applied. 00000020h = External fixups for the module have been applied. 00000040h = Reserved for system use. 00000080h = Reserved for system use. 00000100h = Incompatible with PM windowing. 00000200h = Compatible with PM windowing. 00000300h = Uses PM windowing API. 00000400h = Reserved for system use. 00000800h = Reserved for system use. 00001000h = Reserved for system use. 00002000h = Module is not loadable. When the 'Module is not loadable' flag is set, it indicates that either errors were detected at link time or that the module is being incrementally linked and therefore can't be loaded. 00004000h = Reserved for system use. 00038000h = Module type mask. 00000000h = Program module. A module can not contain dynamic links to other modules that have the 'program module' type. 00008000h = Library module. 00018000h = Protected Memory Library module. 00020000h = Physical Device Driver module. 00028000h = Virtual Device Driver module. 40000000h = Per-process Library Termination. The setting of this bit requires the EIP Object # and EIP fields to have valid values. If the EIP Object # and EIP fields are valid and this bit is NOT set, then Global Library Termination is assumed. Setting this bit for an EXE file is invalid. MODULE # PAGES = DD Number of pages in module. This field specifies the number of pages physically contained in this module. In other words, pages containing either enumerated or iterated data, or zero-fill pages that have relocations, not invalid or zero-fill pages implied by the Virtual Size in the Object Table being larger than the number of pages actually in the linear EXE file. These pages are contained in the 'preload pages', 'demand load pages' and 'iterated data pages' sections of the linear EXE module. This is used to determine the size of the page information tables in the linear EXE module. EIP OBJECT # = DD The Object number to which the Entry Address is relative. This specifies the object to which the Entry Address is relative. This must be a nonzero value for a program module to be correctly loaded. A zero value for a library module indicates that no library entry routine exists. If this value is zero, then both the Per-process Library Initialization bit and the Per-process Library Termination bit must be clear in the module flags, or else the loader will fail to load the module. Further, if the Per-process Library Termination bit is set, then the object to which this field refers must be a 32-bit object (i.e., the Big/Default bit must be set in the object flags; see below). EIP = DD Entry Address of module. The Entry Address is the starting address for program modules and the library initialization and Library termination address for library modules. ESP OBJECT # = DD The Object number to which the ESP is relative. This specifies the object to which the starting ESP is relative. This must be a nonzero value for a program module to be correctly loaded. This field is ignored for a library module. ESP = DD Starting stack address of module. The ESP defines the starting stack pointer address for program modules. A zero value in this field indicates that the stack pointer is to be initialized to the highest address/offset in the object. This field is ignored for a library module. PAGE SIZE = DD The size of one page for this system. This field specifies the page size used by the linear EXE format and the system. For the initial version of this linear EXE format the page size is 4Kbytes. (The 4K page size is specified by a value of 4096 in this field.) PAGE OFFSET SHIFT = DD The shift left bits for page offsets. This field gives the number of bit positions to shift left when interpreting the Object Page Table entries' page offset field. This determines the alignment of the page information in the file. For example, a value of 4 in this field would align all pages in the Data Pages and Iterated Pages sections on 16 byte (paragraph) boundaries. A Page Offset Shift of 9 would align all pages on a 512 byte (disk sector) basis. The default value for this field is 12 (decimal), which give a 4096 byte alignment. All other offsets are byte aligned. FIXUP SECTION SIZE = DD Total size of the fixup information in bytes. This includes the following 4 tables: - Fixup Page Table - Fixup Record Table - Import Module name Table - Import Procedure Name Table FIXUP SECTION CHECKSUM = DD Checksum for fixup information. This is a cryptographic checksum covering all of the fixup information. The checksum for the fixup information is kept separate because the fixup data is not always loaded into main memory with the 'loader section'. If the checksum feature is not implemented, then the linker will set these fields to zero. LOADER SECTION SIZE = DD Size of memory resident tables. This is the total size in bytes of the tables required to be memory resident for the module, while the module is in use. This total size includes all tables from the Object Table down to and including the Per-Page Checksum Table. LOADER SECTION CHECKSUM = DD Checksum for loader section. This is a cryptographic checksum covering all of the loader section information. If the checksum feature is not implemented, then the linker will set these fields to zero. OBJECT TABLE OFF = DD Object Table offset. This offset is relative to the beginning of the linear EXE header. # OBJECTS IN MODULE = DD Object Table Count. This defines the number of entries in Object Table. OBJECT PAGE TABLE OFFSET = DD Object Page Table offset This offset is relative to the beginning of the linear EXE header. OBJECT ITER PAGES OFF = DD Object Iterated Pages offset. This offset is relative to the beginning of the EXE file. RESOURCE TABLE OFF = DD Resource Table offset. This offset is relative to the beginning of the linear EXE header. # RESOURCE TABLE ENTRIES = DD Number of entries in Resource Table. RESIDENT NAME TBL OFF = DD Resident Name Table offset. This offset is relative to the beginning of the linear EXE header. ENTRY TBL OFF = DD Entry Table offset. This offset is relative to the beginning of the linear EXE header. MODULE DIRECTIVES OFF = DD Module Format Directives Table offset. This offset is relative to the beginning of the linear EXE header. # MODULE DIRECTIVES = DD Number of Module Format Directives in the Table. This field specifies the number of entries in the Module Format Directives Table. FIXUP PAGE TABLE OFF = DD Fixup Page Table offset. This offset is relative to the beginning of the linear EXE header. FIXUP RECORD TABLE OFF = DD Fixup Record Table Offset This offset is relative to the beginning of the linear EXE header. IMPORT MODULE TBL OFF = DD Import Module Name Table offset. This offset is relative to the beginning of the linear EXE header. # IMPORT MOD ENTRIES = DD The number of entries in the Import Module Name Table. IMPORT PROC TBL OFF = DD Import Procedure Name Table offset. This offset is relative to the beginning of the linear EXE header. PER-PAGE CHECKSUM OFF = DD Per-Page Checksum Table offset. This offset is relative to the beginning of the linear EXE header. DATA PAGES OFFSET = DD Data Pages Offset. This offset is relative to the beginning of the EXE file. # PRELOAD PAGES = DD Number of Preload pages for this module. Note that OS/2 2.0 does not respect the preload of pages as specified in the executable file for performance reasons. NON-RES NAME TBL OFF = DD Non-Resident Name Table offset. This offset is relative to the beginning of the EXE file. NON-RES NAME TBL LEN = DD Number of bytes in the Non-resident name table. NON-RES NAME TBL CKSM = DD Non-Resident Name Table Checksum. This is a cryptographic checksum of the Non-Resident Name Table. AUTO DS OBJECT # = DD The Auto Data Segment Object number. This is the object number for the Auto Data Segment used by 16-bit modules. This field is supported for 16-bit compatibility only and is not used by 32-bit modules. DEBUG INFO OFF = DD Debug Information offset. This offset is relative to the beginning of the linear EXE header. DEBUG INFO LEN = DD Debug Information length. The length of the debug information in bytes. # INSTANCE PRELOAD = DD Instance pages in preload section. The number of instance data pages found in the preload section. # INSTANCE DEMAND = DD Instance pages in demand section. The number of instance data pages found in the demand section. HEAPSIZE = DD Heap size added to the Auto DS Object. The heap size is the number of bytes added to the Auto Data Segment by the loader. This field is supported for 16-bit compatibility only and is not used by 32-bit modules. Program (EXE) startup registers and Library entry registers Program startup registers are defined as follows. EIP = Starting program entry address. ESP = Top of stack address. CS = Code selector for base of linear address space. DS = ES = SS = Data selector for base of linear address space. FS = Data selector of base of Thread Information Block (TIB). GS = 0. EAX = EBX = 0. ECX = EDX = 0. ESI = EDI = 0. EBP = 0. [ESP+0] = Return address to routine which calls DosExit(1,EAX). [ESP+4] = Module handle for program module. [ESP+8] = Reserved. [ESP+12] = Environment data object address. [ESP+16] = Command line linear address in environment data object. Library initialization registers are defined as follows. EIP = Library entry address. ESP = User program stack. CS = Code selector for base of linear address space. DS = ES = SS = Data selector for base of linear address space. Note that a 32-bit Protected Memory Library module will be given a GDT selector in the DS and ES registers (PROTDS) that addresses the full linear address space available to a application. This selector should be saved by the initialization routine. Non-Protected Memory Library modules will receive a selector (FLATDS) that addresses the same amount of linear address space as an application's .EXE can. FS = Data selector of base of Thread Information Block (TIB). GS = 0. EAX = EBX = 0. ECX = EDX = 0. ESI = EDI = 0. EBP = 0. [ESP+0] = Return address to system, (EAX) = return code. [ESP+4] = Module handle for library module. [ESP+8] = 0 (Initialization) Note that a 32-bit library may specify that its entry address is in a 16-bit code object. In this case, the entry registers are the same as for entry to a library using the Segmented EXE format. These are documented elsewhere. This means that a 16-bit library may be relinked to take advantage of the benefits of the Linear EXE format (notably, efficient paging). Library termination registers are defined as follows. EIP = Library entry address. ESP = User program stack. CS = Code selector for base of linear address space. DS = ES = SS = Data selector for base of linear address space. FS = Data selector of base of Thread Information Block (TIB). GS = 0. EAX = EBX = 0. ECX = EDX = 0. ESI = EDI = 0. EBP = 0. [ESP+0] = Return address to system. [ESP+4] = Module handle for library module. [ESP+8] = 1 (Termination) Note that Library termination is not allowed for libraries with 16-bit entries. Object Table The number of entries in the Object Table is given by the # Objects in Module field in the linear EXE header. Entries in the Object Table are numbered starting from one. Each Object Table entry has the following format: +-----+-----+-----+-----+-----+-----+-----+-----+ 00h | VIRTUAL SIZE | RELOC BASE ADDR | +-----+-----+-----+-----+-----+-----+-----+-----+ 08h | OBJECT FLAGS | PAGE TABLE INDEX | +-----+-----+-----+-----+-----+-----+-----+-----+ 10h | # PAGE TABLE ENTRIES | RESERVED | +-----+-----+-----+-----+-----+-----+-----+-----+ VIRTUAL SIZE = DD Virtual memory size. This is the size of the object that will be allocated when the object is loaded. The object's virtual size (rounded up to the page size value) must be greater than or equal to the total size of the pages in the EXE file for the object. This memory size must also be large enough to contain all of the iterated data and uninitialized data in the EXE file. RELOC BASE ADDR = DD Relocation Base Address. The relocation base address the object is currently relocated to. If the internal relocation fixups for the module have been removed, this is the address the object will be allocated at by the loader. OBJECT FLAGS = DW Flag bits for the object. The object flag bits have the following definitions. 0001h = Readable Object. 0002h = Writable Object. 0004h = Executable Object. The readable, writable and executable flags provide support for all possible protections. In systems where all of these protections are not supported, the loader will be responsible for making the appropriate protection match for the system. 0008h = Resource Object. 0010h = Discardable Object. 0020h = Object is Shared. 0040h = Object has Preload Pages. 0080h = Object has Invalid Pages. 0100h = Object has Zero Filled Pages. 0200h = Object is Resident (valid for VDDs, PDDs only). 0300h = Object is Resident & Contiguous (VDDs, PDDs only). 0400h = Object is Resident & 'long-lockable' (VDDs, PDDs only). 0800h = Reserved for system use. 1000h = 16:16 Alias Required (80x86 Specific). 2000h = Big/Default Bit Setting (80x86 Specific). The 'big/default' bit , for data segments, controls the setting of the Big bit in the segment descriptor. (The Big bit, or B-bit, determines whether ESP or SP is used as the stack pointer.) For code segments, this bit controls the setting of the Default bit in the segment descriptor. (The Default bit, or D-bit, determines whether the default word size is 32-bits or 16-bits. It also affects the interpretation of the instruction stream.) 4000h = Object is conforming for code (80x86 Specific). 8000h = Object I/O privilege level (80x86 Specific). Only used for 16:16 Alias Objects. PAGE TABLE INDEX = DD Object Page Table Index. This specifies the number of the first object page table entry for this object. The object page table specifies where in the EXE file a page can be found for a given object and specifies per-page attributes. The object table entries are ordered by logical page in the object table. In other words the object table entries are sorted based on the object page table index value. # PAGE TABLE ENTRIES = DD # of object page table entries for this object. Any logical pages at the end of an object that do not have an entry in the object page table associated with them are handled as zero filled or         invalid pages by the loader.         When the last  logical pages  of an  object  are not         specified with an object page table entry,  they are         treated as either zero filled pages or invalid pages         based on the last entry in the object page table for .msgcontent .wsharing ul li { text-indent: 0; } 分享 Facebook Plurk YAHOO! .


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 zd0000686 的頭像
    zd0000686

    綠的家具

    zd0000686 發表在 痞客邦 留言(0) 人氣()