mirror of
https://github.com/0O0o0oOoO00/Alas.git
synced 2026-05-14 13:49:26 +08:00
opt: make injector more automated
This commit is contained in:
@@ -2737,21 +2737,21 @@ using ElfFile32 = ElfFile<Elf32_Ehdr, Elf32_Phdr, Elf32_Shdr, Elf32_Addr, Elf32_
|
||||
void do_local_patch(const std::string& game_lib_dir) {
|
||||
fs::path lib_dir(game_lib_dir);
|
||||
auto libtolua_file = lib_dir / "libtolua.so";
|
||||
auto libtolua_backup_file = lib_dir / "libtolua.so.bak";
|
||||
|
||||
ElfFile32 libtolua(readFile(libtolua_file));
|
||||
|
||||
auto curr_needed = libtolua.getNeededLibs();
|
||||
for (const auto& lib : curr_needed) {
|
||||
if (lib == "libcracker.so") {
|
||||
return;
|
||||
goto ret;
|
||||
}
|
||||
}
|
||||
auto libtolua_backup_file = lib_dir / "libtolua.so.bak";
|
||||
if (!exists(libtolua_backup_file)) {
|
||||
fs::copy(libtolua_file, libtolua_backup_file, fs::copy_options::overwrite_existing);
|
||||
}
|
||||
libtolua.addNeeded({"libcracker.so"});
|
||||
writeFile(libtolua_file, libtolua.fileContents);
|
||||
|
||||
ret:
|
||||
fs::copy("libcracker.so", lib_dir / "libcracker.so", fs::copy_options::overwrite_existing);
|
||||
}
|
||||
|
||||
@@ -2760,21 +2760,21 @@ void do_local_depatch(const std::string& game_lib_dir) {
|
||||
auto libtolua_file = lib_dir / "libtolua.so";
|
||||
auto libtolua_backup_file = lib_dir / "libtolua.so.bak";
|
||||
|
||||
if (exists(libtolua_backup_file)) {
|
||||
fs::copy(libtolua_backup_file, libtolua_file, fs::copy_options::overwrite_existing);
|
||||
return;
|
||||
}
|
||||
|
||||
ElfFile32 libtolua(readFile(libtolua_file));
|
||||
|
||||
auto curr_needed = libtolua.getNeededLibs();
|
||||
for (const auto& lib : curr_needed) {
|
||||
if (lib == "libcracker.so") {
|
||||
if (exists(libtolua_backup_file)) {
|
||||
fs::copy(libtolua_backup_file, libtolua_file, fs::copy_options::overwrite_existing);
|
||||
return;
|
||||
} else {
|
||||
libtolua.removeNeeded({"libcracker.so"});
|
||||
writeFile(libtolua_file, libtolua.fileContents);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
Reference in New Issue
Block a user