Can someone explain hex offsets to me?
Asked Answered
P

6

25

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?

Psychiatrist answered 26/9, 2008 at 18:56 Comment(2)
Why is this question marked down? It is a perfectly valid question.Ciliary
See how much better quality answers you get with a proper question?Fireman
D
15

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.

Delisadelisle answered 26/9, 2008 at 18:57 Comment(1)
@OregonGhost: Hope you don't mind, I felt your addition deserved to be part of that answer.Fireman
P
3

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.

Publias answered 26/9, 2008 at 19:0 Comment(0)
A
2

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

Affiliate answered 26/9, 2008 at 18:58 Comment(0)
T
1

Start here. Once you learn how to read hexadecimal values, you'll be in much better shape to actually solve your problem.

Tesstessa answered 26/9, 2008 at 18:58 Comment(0)
L
1

0x04 in hex is 4 in decimal. 0x10 in hex is 16 in decimal. calc.exe can convert between hex and decimal for you.

Offset 4 means 4 bytes from the start of the file. Offset 0 is the first byte in the file.

Libriform answered 26/9, 2008 at 18:58 Comment(0)
C
1

Look at bytes 4 and five they should have the values 0x6E 0x9B (or 0x9B 0x6E) depending on your endianess.

Cannibalism answered 26/9, 2008 at 18:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.