darkpanda
Dark Prince
- Joined
- Oct 28, 2007
- Messages
- 844
2. I explain to you how to modify thr pad by yourselfbut you must know hexadecimal, if that's ok
Ok let's explain a little bit for this one:
First thing to know is that the compression goes backwards: it starts at the end of the byte sequence, and rolls up to the beginning
Second thing is that compression is directed by 2 instructions: "copy as-is" (B2) and "fill-in" (B0):
- "copy as-is" (B2)
- this sequence "starts" (so, at then end) with byte B2, followed by a 2-byte integer value (short), in little endian format. I show an example below highlighted in red:
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_ a_ n_ ._ ._ ._ ._ ._ ._ ._
24 00 24 00 4A 43 65 73 61 72 37 0B 00 B2 00 19 00 B0 52 6F 6D 61 6E 05 00 B2 00 0D 00 B0
24 00 24 00 4A 43 65 73 61 72 37 0B 00 B2 00 19 00 B0 52 6F 6D 61 6E 05 00 B2 00 0D 00 B0
You see that first occurence is "0B 00 B2" and second is "05 00 B2". For the first occurence, the 2-byte little-endian value is "00 0B" (in fact it is "0B 00" but swapped because it is little-endian, which mean "little end first"). "00 0B" is hexadecimal value for "11" (eleven), so this instruction means "copy as-is the next (i.e. previous) eleven bytes".
You see that the "next (i.e. previous) eleven bytes" are clearly the following (highlighted in purple):
You see that the "next (i.e. previous) eleven bytes" are clearly the following (highlighted in purple):
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_ a_ n_ ._ ._ ._ ._ ._ ._ ._
24 00 24 00 4A 43 65 73 61 72 37 0B 00 B2 00 19 00 B0 52 6F 6D 61 6E 05 00 B2 00 0D 00 B0
11 10 09 08 07 06 05 04 03 02 01
24 00 24 00 4A 43 65 73 61 72 37 0B 00 B2 00 19 00 B0 52 6F 6D 61 6E 05 00 B2 00 0D 00 B0
11 10 09 08 07 06 05 04 03 02 01
Same for the second occurence, which has length "00 05", the "5" bytes to copy as-is are the following ones:
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_ a_ n_ ._ ._ ._ ._ ._ ._ ._
24 00 24 00 4A 43 65 73 61 72 37 0B 00 B2 00 19 00 B0 52 6F 6D 61 6E 05 00 B2 00 0D 00 B0
11 10 09 08 07 06 05 04 03 02 01 .. .. .. .. .. .. .. 05 04 03 02 01
So when uncompressing, those bytes will simply be copied "as-is" to the uncompressed data, while the compression instruction (0? 00 B2) will be removed
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_ a_ n_ ._ ._ ._ ._ ._ ._ ._
24 00 24 00 4A 43 65 73 61 72 37 0B 00 B2 00 19 00 B0 52 6F 6D 61 6E 05 00 B2 00 0D 00 B0
11 10 09 08 07 06 05 04 03 02 01 .. .. .. .. .. .. .. 05 04 03 02 01
So when uncompressing, those bytes will simply be copied "as-is" to the uncompressed data, while the compression instruction (0? 00 B2) will be removed
- "fill-in" (B0)
This sequence "starts" (so, at then end) with byte B0, followed by a 2-byte integer value (short), in little endian format, followed by a single byte. I show an example below highlighted in blue:
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_ a_ n_ ._ ._ ._ ._ ._ ._ ._
24 00 24 00 4A 43 65 73 61 72 37 0B 00 B2 00 19 00 B0 52 6F 6D 61 6E 05 00 B2 00 0D 00 B0
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_ a_ n_ ._ ._ ._ ._ ._ ._ ._
24 00 24 00 4A 43 65 73 61 72 37 0B 00 B2 00 19 00 B0 52 6F 6D 61 6E 05 00 B2 00 0D 00 B0
You see that first occurence is "00 19 00 B0" and second is "00 0D 00 B0". For the first occurence, the 2-byte little-endian value is "00 19" (in fact "19 00") which is hexadecimal value for "25, and the single byte value is "00", so this instruction means "fill in the next (previous) 25 bytes with '00'".
Same for the second occurence, which has length "00 0D", hexadecimal for "13", and byte "00", which means "fill in the next 13 bytes with "00"
- uncompress
So when we combine both instructions, we see they cover all the compressed content:
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_ a_ n_ ._ ._ ._ ._ ._ ._ ._
24 00 24 00 4A 43 65 73 61 72 37 0B 00 B2 00 19 00 B0 52 6F 6D 61 6E 05 00 B2 00 0D 00 B0
When uncompressing, this gives the following result, keeping purple color for uncrompessed B2 sequences, and green color for B0 uncompressed sequences (remember, always goes backwards):
24 00 24 00 4A 43 65 73 61 72 37 0B 00 B2 00 19 00 B0 52 6F 6D 61 6E 05 00 B2 00 0D 00 B0
When uncompressing, this gives the following result, keeping purple color for uncrompessed B2 sequences, and green color for B0 uncompressed sequences (remember, always goes backwards):
Compressed
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_ a_ n_ ._ ._ ._ ._ ._ ._ ._
24 00 24 00 4A 43 65 73 61 72 37 0B 00 B2 00 19 00 B0 52 6F 6D 61 6E 05 00 B2 00 0D 00 B0
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_ a_ n_ ._ ._ ._ ._ ._ ._ ._
24 00 24 00 4A 43 65 73 61 72 37 0B 00 B2 00 19 00 B0 52 6F 6D 61 6E 05 00 B2 00 0D 00 B0
Uncompressed
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_ a_ n_ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._
24 00 24 00 4A 43 65 73 61 72 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 6F 6D 61 6E 00 00 00 00 00 00 00 00 00 00 00 00 00
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_ a_ n_ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._
24 00 24 00 4A 43 65 73 61 72 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 6F 6D 61 6E 00 00 00 00 00 00 00 00 00 00 00 00 00
- manual char padding
If you want to free more chars, because the optimal compressed sequance left more chars for modding, here we can for example use 1 more char for Ceasar's leader name, we will add a "2" at the end (hex value for char "2" is "32").
We must take precautions for 2 things:
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_ a_ n_ ._ ._ ._ ._ ._ ._ ._
24 00 24 00 4A 43 65 73 61 72 37 0B 00 B2 00 19 00 B0 52 6F 6D 61 6E 05 00 B2 00 0D 00 B0
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ 2_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_ a_ n_ ._ ._ ._ ._ ._ ._
24 00 24 00 4A 43 65 73 61 72 37 32 0C 00 B2 00 18 00 B0 52 6F 6D 61 6E 05 00 B2 00 0D 00 B0
You see the modified compressed byte sequence is indeed 1 char longer, but uncompressed sequence will be the same length in the end:
Before
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_
24 00 24 00 4A 43 65 73 61 72 37 0B 00 B2 00 19 00 B0 52 6F 6D
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_
24 00 24 00 4A 43 65 73 61 72 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 6F 6D
11 10 09 08 07 06 05 04 03 02 01 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01
After
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ 2_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_
24 00 24 00 4A 43 65 73 61 72 37 32 0C 00 B2 00 18 00 B0 52 6F 6D
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ 2_ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_
24 00 24 00 4A 43 65 73 61 72 37 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 6F 6D
12 11 10 09 08 07 06 05 04 03 02 01 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01
We must take precautions for 2 things:
Make the B2 sequence 1 char longer, so the hex value will be "00 0C" instead of "00 0B"
Make the "preceding" (i.e. "following") B0 fill-in sequence 1 char shorter, so the hex value will be "00 18" instead of "00 19"
Here is the result, comparing before and after (changes in yellow):Make the "preceding" (i.e. "following") B0 fill-in sequence 1 char shorter, so the hex value will be "00 18" instead of "00 19"
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_ a_ n_ ._ ._ ._ ._ ._ ._ ._
24 00 24 00 4A 43 65 73 61 72 37 0B 00 B2 00 19 00 B0 52 6F 6D 61 6E 05 00 B2 00 0D 00 B0
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ 2_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_ a_ n_ ._ ._ ._ ._ ._ ._
24 00 24 00 4A 43 65 73 61 72 37 32 0C 00 B2 00 18 00 B0 52 6F 6D 61 6E 05 00 B2 00 0D 00 B0
You see the modified compressed byte sequence is indeed 1 char longer, but uncompressed sequence will be the same length in the end:
Before
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_
24 00 24 00 4A 43 65 73 61 72 37 0B 00 B2 00 19 00 B0 52 6F 6D
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_
24 00 24 00 4A 43 65 73 61 72 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 6F 6D
11 10 09 08 07 06 05 04 03 02 01 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01
After
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ 2_ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_
24 00 24 00 4A 43 65 73 61 72 37 32 0C 00 B2 00 18 00 B0 52 6F 6D
$_ ._ $_ ._ J_ C_ e_ s_ a_ r_ 7_ 2_ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ ._ R_ o_ m_
24 00 24 00 4A 43 65 73 61 72 37 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 6F 6D
12 11 10 09 08 07 06 05 04 03 02 01 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01
Hope this helps !!
Last edited: