This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: A very brief explanation of hex editing  (Read 4139 times)

Will

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 140
    • View Profile
A very brief explanation of hex editing
« on: May 24, 2012, 01:45:40 am »
Many people will have to hex edit at some point in their wow dev experience. Though, i imagine few people actually know what they are doing. This is just a very brief informative piece to encourage people to start understanding essentially what it is and perhaps look into it more to help this great wowmodding community!

First off here is some keywords that you will need to know:


  • BINARY: simple enough..
  • BIT: A single binary digit. 0 or 1
  • BYTE: 8 bits, possibly the most commonly used unit?
  • NIBBLE: 4 bites
  • WORDS: Binary data is stored in memory as groups of bits, each group occupies a single 'address'. The length of a word is fixed for a given computer and values typically range from 16 (WORD) to 64bits (Q(uad)WORDs). (64bit ftw..)

Right, so after a few key words we can start getting into things..


A computer is actually a lot more stupid then you can imagine. It can only handle two numbers. I won't go into why, but for this reason a computer works out math by using base 2. For this reason, each binary digit represents a base of 2, which you will see in the short snippet of math below..

So... 4 bit binary numbers can represent decimal numbers in the range: (As explained before in the keywords, you can tell it is 4 bit, because there are 4 binary numbers..)
0000 = 0, to
1111 = 15. [2^3 + 2^2 + 2^1 + 2^0 = 15]

To represent larger decimal numbers requires more bits, e.g. a byte (8 bits) gives us a range:
00000000 = 0 to
11111111 = 255. [Do the maths like shown above for yourself but 8 times instead of 4]


Different number base systems


To save writing long strings of 1’s and 0’s, binary numbers can be expressed in a more compact form by simply choosing a base greater than 2. I.e.

Octal is base 8. This requires 8 digits or symbols 0,1,2,3,4,5,6,7
To convert a binary number to octal just split it into groups of 3 bits (starting from the right hand {least significant} end) and express each group by one of the above digits.              

E.g  the byte 10001110    groups as:  10   001   110
                                           2       1       6    in octal form (often written 216 (to the base 8))

The math behind this:
for the first group from the right: 110 = [2^2 + 2^1 + 0^0 = 6]
for the second group: 001 = [0^2 + 0^1 + 2^0 = 1]
for the last in group: 10 = [2^1 + 0^0 = 2]


So, now lets go on to hex, because that is what we are here for. :)


Hexadecimal  or 'Hex’ is base 16. This requires 16 digits or symbols 0,1,2,3,4,5,6,7,8,9, ? Now what ? We need 10,11,12,13,14,15 (but can't obviously because a computer handles 0-9..)

But that's noo problem: let A =10, B=11, C=12, D=13, E=14 and F=15
To convert a binary number to the very widely used hex notation just split it into groups of 4 bits (recall 4 bits can represent decimal numbers from 0 to 15) and express each group by one of the above digits.

E.g  1000 1110  an 8 bit binary number
        8       E    in hex form (sometimes written 8E16) or in software 8Eh or 0x8E[/color]


So there is hex notation.. I hope this will help some people understand their hex editor a little more. Like i said, this is only a very brief introduction to the topic, but i know i always used to hate working on something if i didn't even know what i was actually doing. So i guess, In conclusion, Hex is basically a way to express binary numbers in an easy way.

For more information on Hex editing, please refer to Schlumpf's take on it here:
viewtopic.php?f=48&t=611&p=4157&hilit=Hex+editing#p4157

Please let me know if you see any mistakes or think something ought to be mentioned. Also, if anyone has any questions, ask here too ^^

Regards,
Will
« Last Edit: May 24, 2012, 11:53:24 pm by Admin »
- JutsuONLINE - http://www.jutsuonline.co/
Always recruiting. Contact me

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: A very brief explanation of hex editing
« Reply #1 on: May 24, 2012, 03:44:11 pm »
Those colors are horrible. Please use only normal text with section and subsection bbcodes.

Also, you chose the wrong forum. On a side note, I already wrote a guide on that multiple years ago, which should be around here as well.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Will

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 140
    • View Profile
Re: A very brief explanation of hex editing
« Reply #2 on: May 24, 2012, 04:00:40 pm »
I could not find another guide on this.
Link it please, I am interested to see how clearly articulated it is / noob friendly. If it is, this thread can be disregarded, no prob..



And thanks, I'll take take your presentational opinion into consideration..
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
- JutsuONLINE - http://www.jutsuonline.co/
Always recruiting. Contact me

Mjollna

  • Contributors
  • Model Change Addict
  • *****
  • Posts: 254
    • View Profile
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Will

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 140
    • View Profile
Re: A very brief explanation of hex editing
« Reply #4 on: May 24, 2012, 04:46:30 pm »
I think i'll leave this up, as It is more noob friendly and is in a thread of it's own.

I Shall also link Schlumpf's version in the first post incase people wish to read further on hex editing. (Y)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
- JutsuONLINE - http://www.jutsuonline.co/
Always recruiting. Contact me

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: A very brief explanation of hex editing
« Reply #5 on: May 24, 2012, 06:44:36 pm »
As said: please format your post properly.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Will

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 140
    • View Profile
Re: A very brief explanation of hex editing
« Reply #6 on: May 24, 2012, 07:28:54 pm »
...


I am happy with the format of my post. If you are adamant on it changing, you may private message me about it. Lol. I'd prefer not to have flames littered in this thread though, if that's okay. Like i explained, you can pm me if you feel strongly about it.. :S

Thanks,
Will
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
- JutsuONLINE - http://www.jutsuonline.co/
Always recruiting. Contact me

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: A very brief explanation of hex editing
« Reply #7 on: May 24, 2012, 11:40:41 pm »
A WORD is fixed at 16 bit. 32 bit variables are D(double)WORDs, 64bit is Q(quad)WORDs.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Will

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 140
    • View Profile
Re: A very brief explanation of hex editing
« Reply #8 on: May 25, 2012, 12:59:45 am »
..in der Tat.

If anyone feels something is not explained well, let me know and ill try clear it up for you.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
- JutsuONLINE - http://www.jutsuonline.co/
Always recruiting. Contact me