8 Import Library Format


Traditional import libraries, that is, libraries that describe the exports from one image for use by another, typically follow the layout described in Section 7, "Archive (Library) File Format." The primary difference is that import library members contain pseudo-object files instead of real ones, where each member includes the section contributions needed to build the Import Tables described in Section 6.4, "The .idata Section." The linker generates this archive while building the exporting application.

The section contributions for an import can be inferred from a small set of information. The linker can either generate the complete, verbose information into the import library for each member at the time of the library's creation, or it can write only the canonical information to the library and let the application that later uses it generate the necessary data on-the-fly.

In an import library with the long format, a single member contains the following information:

Archive member header

File header

Section headers

Data corresponding to each of the section headers

COFF symbol table

Strings

In contrast a short import library is written as follows:

Archive member header

Import header

Null-terminated import name string

Null-terminated dll name string

This is sufficient information to accurately reconstruct the entire contents of the member at the time of its use.

8.1 Import Header

The import header contains the following fields and offsets:

Offset

Size

Field

Description

0

2

Sig1

Must be IMAGE_FILE_MACHINE_UNKNOWN. See Section 3.3.1, "Machine Types," for more information.

2

2

Sig2

Must be 0xFFFF.

4

2

Version

 

6

2

Machine

Number identifying type of target machine. See Section 3.3.1, "Machine Types," for more information.

8

4

Time-Date Stamp

Time and date the file was created.

12

4

Size Of Data

Size of the strings following the header.

16

2

Ordinal/Hint

Either the ordinal or the hint for the import, determined by the value in the Name Type field.

18

2 bits

Type

The import type. See Section 8.2, "Import Type," for specific values and descriptions.

 

3 bits

Name Type

The Import Name Type. See Section 8.3, "Import Name Type," for specific values and descriptions.

 

11 bits

Reserved

Reserved. Must be zero.

This structure is followed by two null-terminated strings describing the imported symbol's name, and the dll from which it came.

8.2 Import Type

The following values are defined for the Type field in the Import Header:

Constant

Value

Description

IMPORT_CODE

0

The import is executable code.

IMPORT_DATA

1

The import is data.

IMPORT_CONST

2

The import was specified as CONST in the .def file.

These values are used to determine which section contributions must be generated by the tool using the library if it must access that data.

8.3 Import Name Type

The null-terminated import symbol name immediately follows its associated Import Header. The following values are defined for the Name Type field in the Import Header, indicating how the name is to be used to generate the correct symbols representing the import:

Constant

Value

Description

IMPORT_ORDINAL

0

The import is by ordinal. This indicates that the value in the Ordinal/Hint field of the Import Header is the import's ordinal. If this constant is not specified, then the Ordinal/Hint field should always be interpreted as the import's hint.

IMPORT_NAME

1

The import name is identical to the public symbol name.

IMPORT_NAME_NOPREFIX

2

The import name is the public symbol name, but skipping the leading ?, @, or optionally _.

IMPORT_NAME_UNDECORATE

3

The import name is the public symbol name, but skipping the leading ?, @, or optionally _, and truncating at the first @.



The Common Language Infrastructure Annotated Standard (Microsoft. NET Development Series)
The Common Language Infrastructure Annotated Standard (Microsoft. NET Development Series)
ISBN: N/A
EAN: N/A
Year: 2002
Pages: 121

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net