Search code examples
hexhex-editors

Can someone explain hex offsets to me?


I downloaded Hex Workshop, and I was told to read a .dbc file.

It should contain 28,315 if you read offset 0x04 and 0x05

I am unsure how to do this? What does 0x04 mean?


Solution

  • 0x04 is hex for 4 (the 0x is just a common prefix convention for base 16 representation of numbers - since many people think in decimal), and that would be the fourth byte (since they are saying offset, they probably count the first byte as byte 0, so offset 0x04 would be the 5th byte).

    I guess they are saying that the 4th and 5th byte together would be 28315, but did they say if this is little-endian or big-endian?

    28315 (decimal) is 0x6E9B in hexadecimal notation, probably in the file in order 0x9B 0x6E if it's little-endian.

    Note: Little-endian and big-endian refer to the order bytes are written. Humans typical write decimal notation and hexadecimal in a big-endian way, so:

    256 would be written as 0x0100 (digits on the left are the biggest scale)

    But that takes two bytes and little-endian systems will write the low byte first: 0x00 0x01. Big-endian systems will write the high-byte first: 0x01 0x00.

    Typically Intel systems are little-endian and other systems vary.