Skip to main content

Force change file size in byte and CRC checksum by any value

I play LOL game. Sometime we have game patch done 99% then stopped. The log file display Error message like [bla bla here] So I have to re-patch or restart my PC.
This time has no luck, so I decided to fix myself, hoping can play couple of funny game.
LOL game first verify size of old game data file in byte. In my case is some character image in game_dir/.../assets/images/champions/.
This folder store all champions images from action to tile...
In my case the file Tryndamme_Tile_2.jpg size is not match, expected is 150503 (byte).

In my mind, Garena or Riot game have to verify everything in game data to avoid cheating from local. etc. And they will use filesize and checksum and some other methods to done this.

So first I have to add missing image (Tryndamme_Tile_2.jpg), then force size of this image to match LOL Game expected in update.
Copy file is easy, that use command prompt. Shift + Right click to folder contain image u want to copy to LOL game data. I have to use command prompt because of permission in folder game data. I do not know other way to copy, so just use "familiar" cmd.
[imge here]

After some googling, I find way to edit file to exactly size in byte. I use and hex Editor (HxD) in Windows. Because LOL only play on Windows or MAC OS.  If in linux IDE, I has every tool to use.
Fortunately, I only have to edit file with few hundred KB jpg image.
[HxD] hex editor.
In this editor, when you type something to this, it auto in replace mode, so filesize do not change. So I copy something then paste. From 170KB I delete content int hex Editor to 147KB ~ 150503 byte. After some modify, finally I got exactly byte size need.

Copy to LOL and re update patch.
[quit LOL update use taskmanager or similar (PC Hunter) ...)

[image]

It say CRC not match, crc: is abcdefgh expected crc:e9e99e32 vvv
So I have to force my file to CRC I want.

After few googling, there is no tool for me in Windows. Some tool like CRC faker can't be downloaded or found somewhere.
So I endup with this post
https://www.nayuki.io/page/forcing-a-files-crc-to-any-value

Unfortunately, it do not have any runable program (exe or install). Only source code available: java, python and c.

I decide using python script because it faster to build env in Windows to work with. Java has large download jdk and jre and I do not familiar with javac.
C is good option but I do not have experience with gcc on Windows. Install IDE like code block, DevCpp or Visual Studio is time costly.

So go Python !
Install only in couple of minute. Forgot tick add to ENV variable, no problem re-run installer and re-check. And voila.

Git-bash I have from previous install.
I have to install editor Sublime Text 3 to view python source.

[image ...]
After python env and source downloaded.
I set name to crc_faker.py
then run:
python crc_faker.py file_name offset new_CRC
First I use offset = 1
then I fake crc with offset = 0;

OK
OK, Done ...

Voila ! Now I copy faked CRC jpg image to LOL and hope LOL game will work.

...



Noooooooooooo!

CRC auto changed or the way LOL compute CRC is different.

CRC can be verify using HxD feature in menu.

It has some params: polynomial, init, ...
I don't know.

I only curious on polynomial, after 20' googling, I end up with function index nth. So it's worth nothing.

Only offset is the params I think that affect different CRC compute.

In some first attempt to Force LOL accept Tryndamme_Tile_2.jpg, I saw that LOL see extractly CRC checksum like in HxD.
After some trial-error LOL turn to calculate different CRC.
So I think there are something LOL added or the way it calc CRC different from my HxD.

I try some way to reserve CRC offset but no luck.
After about 3 hours of trial n error, I gave up. My hope of play some LOL game is gone.

So I decide to download new LOL game from start (>5GB on a dial-up net :( ). It may take more than 2 hours to download.

But I still have something to harvest.
First, I've digging in some guide to fix LOL patch from Garena both US and Asia. But end-up with nothing work or the guide is too old.
Second, the fastest way is to copy a game from Net Cafe using USB or similar. Or copy only damage game data from nearest computer.
My nearest LOL game just 2 meter below (:) ) but I don't use that "hard" way.

2nd: int32 and crc32 has some different.
int 32 has a signed bit so max positive value of it is 2^32 (about 2 bil). But crc 32 when convert to INT is max 2 x 2^32 so some of my offset bit I calculate from 2 CRC different by HxD and LOL update not work because it bigger than Int 32.
ie: d2da0236 or f20902ff
and HxD do not accept this too big offset.

I use try to use different offset to verify (calc) CRC in HxD and see different output.

Tool to calc different offset between 2 integer (2 hex string is more precious). No tool found.
I end up with source code again. This time only Csharp :(.
No Visual Studio, only online CSharp available:

private void getOffSet(byte one, byte two)
{
  byte baseByte = 0x80;

  int defaultOffset = 0x0418;

  int mul = (one - baseByte) % 8;

  int result = mul * 0x2000 + defaultOffset;
  result += two * 0x0020;

  Console.WriteLine(result.ToString("X"));
}

The source here http://stackoverflow.com/questions/21989547/calculating-offset-from-two-hex-strings
and http://stackoverflow.com/questions/141262/can-someone-explain-hex-offsets-to-me

csharp online like here:http://www.tutorialspoint.com/compile_csharp_online.php

After some attempt to calc offset but no luck because of tired and I do not familiar with byte programming operator.

So I will try this later. But may be new LOL game will replace old one so how can I re-generate this situation ?

Another doc I will try to know, I have to master (know)  my tool.
https://www.cosc.canterbury.ac.nz/greg.ewing/essays/CRC-Reverse-Engineering.html
http://www.csm.ornl.gov/~dunigan/crc.html

Ha ha it's just few Km of short documents.

[Day 2]
After reading/studying 2 reference above, I found that why LOL game generate different CRC with HxD, It must be it's parameters: Poly, ReflectIn, ReflectOut, XOR in XOR out. Not just poly or offset I thought.


Mình thi thoảng chơi Leage of Legend, 1 game như kiểu Dota đang thịnh hành hiện nay. Game online là cách rẻ tiền để "live the moment", bạn hãy nhớ lại những pha combat ức chế kay cmn kú hay lúc hành team kia.
Garena vn như shit, các bản vá hay gặp lỗi và windows thì tỉ thứ rác như virus, maleware ... làm cho nó ì ạch. Nhưng vì game vẫn phải vô win (m chạy dual boot ubuntu).
Hum nay update patch tiếp tục lăn ra chết khi chạy được 199%. Restart các kiểu con đà điểu ko ăn thua quyết định fix bằng tay. Thử chơi một trò time eater mới.
....



Comments

Post a Comment

Popular posts from this blog

Rand mm 10

https://stackoverflow.com/questions/2447791/define-vs-const Oh const vs define, many time I got unexpected interview question. As this one, I do not know much or try to study this. My work flow, and I believe of many programmer is that search topic only when we have task or job to tackle. We ignore many 'basic', 'fundamental' documents, RTFM is boring. So I think it is a trade off between the two way of study language. And I think there are a bridge or balanced way to extract both advantage of two method. There are some huge issue with programmer like me that prevent we master some technique that take only little time if doing properly. For example, some Red Hat certificate program, lesson, course that I have learned during Collage gave our exceptional useful when it cover almost all topic while working with Linux. I remember it called something like RHEL (RedHat Enterprise Linux) Certificate... I think there are many tons of documents, guide n books about Linux bu

Martin Fowler - Software Architecture - Making Architecture matter

  https://martinfowler.com/architecture/ One can appreciate the point of this presentation when one's sense of code smell is trained, functional and utilized. Those controlling the budget as well as developer leads should understand the design stamina hypothesis, so that the appropriate focus and priority is given to internal quality - otherwise pay a high price soon. Andrew Farrell 8 months ago I love that he was able to give an important lesson on the “How?” of software architecture at the very end: delegate decisions to those with the time to focus on them. Very nice and straight-forward talk about the value of software architecture For me, architecture is the distribution of complexity in a system. And also, how subsystems communicate with each other. A battle between craftmanship and the economics and economics always win... https://hackernoon.com/applying-clean-architecture-on-web-application-with-modular-pattern-7b11f1b89011 1. Independent of Frameworks 2. Testable 3. Indepe