How to Reverse Engineer with ImHex and hide your assets
Hide the assets of your Games and Projects in general by transforming them into Hex!
ImHex is a hexadecimal editor, written in C++, for reverse engineers, programmers and people who they value their retinas when they work at 3 am. 😃
There are a multitude of things that can be done with ImHex. In this video we will see how it can be useful, for example, to “hide” the assets (images, fonts, audios, …) of your games by transforming them into Hex!
As an example, we will show how to implement it in Game Development more precisely in SFML.
💾 How to install ImHex
You can use compressed binary packages available in Releases in the ImHex GitHub repository.
There are packages for: Windows with MSYS2, macOS, Debian(suitable for Ubuntu, Mint and among others), Arch and Fedora.
Once downloaded, you can use the package. Example on Ubuntu:
Or you can also compile ImHex from scratch, which is how I did it…
🚀 How to Compile and Install
First of all, make sure you have the dependencies:
On Ubuntu, Debian, Mint:
In Arch:
In Fedora:
In Gentoo:
In MSYS2
Now recursively clone the repository, compile and install with the commands below:
After installation, you can now remove the cloned repository:
Usage
In this example we will see how to hide your assets with ImHex and as a guinea pig we will use SFML. So to do this, follow the steps:
01. Choose an image, a font, or any other asset you want to reverse engineer with ImHex.
02. Click: File > Open File and select the file you want
03. Press: Ctrl + a to select all binary addresses
04. Then click: Edit > Copy as… > C++ Array
05. Create a file to store your array, example: img.hpp
06. Paste the copied array and rename the data
array to img_data
07. Save and do the same steps for source, for example, or any other binary as said.
After that, include the files in your code and don’t forget to include the headers: #include <cstdint>
(for type uint8_t
) and also #include <array>
.
Compile and see that even without static files, your project will render the assets without any problems.
Tip: the ideal is to store the array on the heap and preferably using smart pointers.
See and test with the example codes below:
💫 Click here to see img.hpp
💫 Click here to see font.hpp
💻 C++ SFML code with data
Compile:
g++ main.cpp -lsfml-graphics -lsfml-window -lsfml-system
🎥 Watch the video
The video is in Portuguese, however, all the steps described here can be followed regardless of your language. But, if you want to understand what was said, use YouTube’s automatic translation.
Comments