Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 991
user20256 Avatar asked Sep 26 '08 18:09

user20256


People also ask

What does hex offset mean?

The offset is the number of bytes from the beginning of the string. Offset Hex. Shows the current offset (position) of the cursor in hexadecimal (digits 0-9, letters A-F). The offset is the number of bytes from the beginning of the string.

What is the hex offset from start for first?

The address of a hex dump counts tracks the number of bytes in the data and offsets each line by that number. So the first line starts at offset 0, and the second line represents the number 16, which is how many bytes precede the current line.

What does 0x04 mean?

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).


3 Answers

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.

like image 91
Cade Roux Avatar answered Sep 19 '22 17:09

Cade Roux


Think of a binary file as a linear array of bytes.

0x04 would be the 5th (in a 0 based array) element in the array, and 0x05 would be the 6th.

The two values in 0x04 and 0x05 can be OR'ed together to create the number 28,315.

Since the value you are reading is 16 bit, you need to bitshift one value over and then OR them together, ie if you were manipulating the file in c#, you would use something like this:

int value = (ByteArray[4] >> 8) | ByteArray[5]);

Hopefully this helps explain how hex addresses work.

like image 45
FlySwat Avatar answered Sep 18 '22 17:09

FlySwat


It's the 4th and the 5th XX code your viewing...

1   2  3  4  5  6
01  AB 11 7B FF 5A

So, the 0x04 and 0x05 is "7B" and "FF".

Assuming what you're saying, in your case 7BFF should be equal to your desired value.

HTH

like image 24
vIceBerg Avatar answered Sep 18 '22 17:09

vIceBerg