Giter Site home page Giter Site logo

Endianness about pe-parse HOT 2 CLOSED

trailofbits avatar trailofbits commented on May 28, 2024
Endianness

from pe-parse.

Comments (2)

dguido avatar dguido commented on May 28, 2024

from pe-parse.

jkolek avatar jkolek commented on May 28, 2024

Being worked on in #45.

I wasn't able to find much information about PE file endianness, but here
is some information that I have found.

According to this source
https://en.wikibooks.org/wiki/X86_Disassembly/Windows_Executable_Files
the PE header signature (which is always 0x00004550 = "\0\0EP")
should indicate:
a) the file is a legitimate PE file,
b) the byte order of the file
But I wasn't able to find any other information related to the signature
and the byte ordering.

Also, in the NT file header in the Characteristics field there are some
deprecated flags:
IMAGE_FILE_BYTES_REVERSED_LO - Little endian: the least significant
bit (LSB) precedes the most significant bit (MSB) in memory. This
flag is deprecated and should be zero.
IMAGE_FILE_BYTES_REVERSED_HI - Big endian: the MSB precedes the LSB
in memory. This flag is deprecated and should be zero.
Source: Microsoft Portable Executable and Common Object File Format
Specification

But there is nothing else related to their usage, and also how these
flags are related to each other.

On this source http://www.doswin32.com/doswin32-en.txt there is a text:
1.7. If you do NOT need to load the extension DLL with your program
(to save memory and for quicker load time) you can mark your program
not to load this DLL. This is accomplished by setting
the IMAGE_FILE_BYTES_REVERSED_LO attribute (this attribute is ignored
by Win32 on x86).
NOTE: Some old linkers (Borland tlink32 version < 5.0, Watcom wlink)
always set this bit. New linkers (ilink32 from BCB >= 4, link
from VC >= 4) do not.
UniLink sets this bit if you use -ay or -aY command line switches
instead of -ax or -aX).

Which means that IMAGE_FILE_BYTES_REVERSED_LO was also used for something
else unrelated to the byte ordering.

So far I have implemented byte swapping if there is a little-endian machine
set and Characteristics flag IMAGE_FILE_BYTES_REVERSED_HI is on.

from pe-parse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.