This is a really simple utility I made to generate Vanilla and Forge mappings for my projects.
The tool creates .cpp files which contain std::unordered_maps.
The maps turn deobfuscated inputs (for example net/minecraft/client/Minecraft)
into their obfuscated counterparts (in this case ave).
Run the tool using build_and_run.sh.
If you cannot run Bash scripts, you can compile it yourself: g++ -o hardcode_mapper.exe -std=c++20 -O2 main.cpp.
This project has a res folder, which contains two files: vanilla-mappings.txt and forge-mappings.txt.
These files are then read and used by the program to generate the C++ code.
The default provided files contain all the mappings for Minecraft 1.8.9 and, as such, the output generated code will contain everything (and be quite large).
The files are formatted as follows:
CLASSES
deobf_name1 obf_name1
deobf_name2 obf_name2
(...)
deobf_nameN obf_nameN
FIELDS
deobf_name1 obf_name1
deobf_name2 obf_name2
(...)
deobf_nameN obf_nameN
METHODS
deobf_name1 deobf_signature1 obf_name1 obf_signature1
deobf_name2 deobf_signature2 obf_name2 obf_signature2
(...)
deobf_nameN deobf_signatureN obf_nameN obf_signatureN
All of the file sections (Classes, Fields, Methods) are optional. For example, the Forge file has no classes in it, because Forge does not obfuscate class names, but instead uses 'intermediary names' for fields and methods.
Please keep in mind that (at least for now) you cannot change the order of the sections and you cannot have empty rows, due to the way in which the code reads the file. I will fix these issues if they ever become a problem, but it doesn't really matter for now.
For now, the tool is hardcoded (how ironic) to only use the two files that are already provided in res.
The tool will create a maps folder, containing vanilla_hardcode.cpp and forge_hardcode.cpp
This is how the files will look:
// vanilla_hardcode.cpp
#include <unordered_map>
#include <string_view>
namespace VanillaHardcode {
std::unordered_map<std::string_view, std::string_view> classMap = {
{ "deobf_name1", "obf_name1" },
{ "deobf_name2", "obf_name2" },
// ...
{ "deobf_nameN", "obf_nameN" },
};
std::unordered_map<std::string_view, std::string_view> fieldMap = {
{ "deobf_name1", "obf_name1" },
{ "deobf_name2", "obf_name2" },
// ...
{ "deobf_nameN", "obf_nameN" },
};
std::unordered_map<std::string_view, std::string_view> methodMap = {
{ "deobf_name1|deobf_signature1", "obf_name1|obf_signature1" },
{ "deobf_name2|deobf_signature2", "obf_name2|obf_signature2" },
// ...
{ "deobf_nameN|deobf_signatureN", "obf_nameN|obf_signatureN" },
};
}The tool is barebones at the moment and the code is not the greatest, but it serves its purpose well enough.
If you wish to make it better, you are always welcome to make a pull request!