diff options
Diffstat (limited to 'src/msil/ch/epfl/lamp/compiler/msil/PEFile.java')
-rw-r--r-- | src/msil/ch/epfl/lamp/compiler/msil/PEFile.java | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/msil/ch/epfl/lamp/compiler/msil/PEFile.java b/src/msil/ch/epfl/lamp/compiler/msil/PEFile.java index 481d5f2116..3eb22b9985 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/PEFile.java +++ b/src/msil/ch/epfl/lamp/compiler/msil/PEFile.java @@ -95,7 +95,7 @@ public class PEFile { /** Ecma 335, 25.2.1 MS-DOS header: * * "The PE format starts with an MS-DOS stub of exactly the following 128 bytes to - * be placed at the front of the module." + * be placed at the front of the module." * * We are only checking for MZ (Mark Zbikowski) */ @@ -107,13 +107,13 @@ public class PEFile { /** Ecma 335, 25.2.1 MS-DOS header: * * "At offset 0x3c in the DOS header is a 4-byte unsigned integer offset, lfanew, - * to the PE signature (shall be "PE\0\0"), immediately followed by the PE file header. + * to the PE signature (shall be "PE\0\0"), immediately followed by the PE file header." */ seek(0x3c); PE_SIGNATURE_OFFSET = readInt(); seek(PE_SIGNATURE_OFFSET); - + // start of PE signature (a signature that is just 4 bytes long) fileFormatCheck(readByte() != 0x50, "Invalid PE file format: " + filename); // 'P' fileFormatCheck(readByte() != 0x45, "Invalid PE file format: " + filename); // 'E' fileFormatCheck(readByte() != 0x00, "Invalid PE file format: " + filename); // 0 @@ -125,26 +125,19 @@ public class PEFile { PE_HEADER_OFFSET = COFF_HEADER_OFFSET + 20; seek(COFF_HEADER_OFFSET); - skip(2); - /** Ecma 335, 25.2.2: "Number of sections; indicates size of the Section Table" */ - numOfSections = readShort(); - //trace("Number of sections = " + numOfSections); - /** Ecma 335, 25.2.2: "Time and date the file was created in seconds since - * January 1st 1970 00:00:00 or 0." - */ + /* start of PE file header, Sec. 25.2.2 in Partition II */ + skip(2); // Machine (always 0x14c) + numOfSections = readShort(); // Number of sections; indicates size of the Section Table Date timeStamp = new Date(readInt() * 1000L); - //trace("Time stamp = " + timeStamp); - - skip(2 * INT_SIZE); + skip(2 * INT_SIZE); // skip Pointer to Symbol Table (always 0) and Number of Symbols (always 0) optHeaderSize = readShort(); int characteristics = readShort(); isDLL = (characteristics & 0x2000) != 0; - //trace("Characteristics = " + Integer.toHexString(characteristics)); seek(PE_HEADER_OFFSET + 208); // p.157, Partition II - CLI_RVA = readInt(); + CLI_RVA = readInt(); // called "Data Directory Table" in Ch. 4 of Expert IL book CLI_Length = readInt(); //trace("CLI_RVA = 0x" + Table.int2hex(CLI_RVA)); //trace("CLI_Length = 0x" + Table.int2hex(CLI_Length)); |