Skip to content

Commit

Permalink
fixes & improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
MJx0 committed Nov 10, 2023
1 parent ed9e3d1 commit 5c53c8f
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 42 deletions.
10 changes: 5 additions & 5 deletions AndUE4Dumper/source/src/Core/Dumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ namespace Dumper

LOGI("Dumping, please wait...");

std::string objfile_path = dir + "/objects_dump.txt";
std::string objfile_path = dir + "/ObjectsDump.txt";
File objfile(objfile_path, "w");
if (!objfile.ok())
{
Expand All @@ -173,7 +173,7 @@ namespace Dumper
std::function<void(UE_UObject)> objdump_callback = nullptr;
objdump_callback = [&objfile](UE_UObject object)
{
fmt::print(objfile, "{}\n", object.GetName());
fmt::print(objfile, "[{:010}]: {}\n", object.GetIndex(), object.GetFullName());
};

std::unordered_map<uint8 *, std::vector<UE_UObject>> packages;
Expand Down Expand Up @@ -224,13 +224,13 @@ namespace Dumper
for (const auto &func : cls.Functions)
{
// UObject::ProcessInternal for blueprint functions
if (!processInternal_once && (func.EFlags & FUNC_BlueprintEvent))
if (!processInternal_once && (func.EFlags & FUNC_BlueprintEvent) && func.Func)
{
JsonGen::idaFunctions.push_back({"UObject", "ProcessInternal", func.Func - Profile::BaseAddress});
processInternal_once = true;
}

if (func.EFlags & FUNC_Native)
if ((func.EFlags & FUNC_Native) && func.Func)
{
std::string execFuncName = "exec";
execFuncName += func.Name;
Expand All @@ -246,7 +246,7 @@ namespace Dumper

for (const auto &func : st.Functions)
{
if (func.EFlags & FUNC_Native)
if ((func.EFlags & FUNC_Native) && func.Func)
{
std::string execFuncName = "exec";
execFuncName += func.Name;
Expand Down
4 changes: 0 additions & 4 deletions AndUE4Dumper/source/src/Core/GameProfiles/Games/DBD.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ class DBDProfile : public IGameProfile
return 0;

add_imm12 = KittyArm64::decode_addsub_imm(add_insn);
if (add_imm12 == 0)
return 0;

return (page_off + adrp_pc_rel + add_imm12);
}
Expand Down Expand Up @@ -96,8 +94,6 @@ class DBDProfile : public IGameProfile
return 0;

add_imm12 = KittyArm64::decode_addsub_imm(add_insn);
if (add_imm12 == 0)
return 0;

return (page_off + adrp_pc_rel + add_imm12);
}
Expand Down
8 changes: 3 additions & 5 deletions AndUE4Dumper/source/src/Core/GameProfiles/Games/Farlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ class FarlightProfile : public IGameProfile
return 0;

add_imm12 = KittyArm64::decode_addsub_imm(add_insn);
if (add_imm12 == 0)
return 0;

return (page_off + adrp_pc_rel + add_imm12);
}
Expand Down Expand Up @@ -129,7 +127,7 @@ class FarlightProfile : public IGameProfile
else if (e_machine == EM_AARCH64)
{
PATTERN_MAP_TYPE map_type = isEmulator() ? PATTERN_MAP_TYPE::ANY_R : PATTERN_MAP_TYPE::ANY_X;
std::string ida_pattern = "C8 00 00 37 ? ? ? ? ? ? 28 91 ? ? FF 97";
std::string ida_pattern = "C8 00 00 37 ? ? ? ? ? ? ? 91 ? ? FF 97";
int step = 4;

uintptr_t insn_address = findIdaPattern(map_type, ida_pattern, step);
Expand All @@ -155,8 +153,8 @@ class FarlightProfile : public IGameProfile
return 0;

add_imm12 = KittyArm64::decode_addsub_imm(add_insn);
if (add_imm12 != 0)
return (page_off + adrp_pc_rel + add_imm12);

return (page_off + adrp_pc_rel + add_imm12);
}

return 0;
Expand Down
4 changes: 0 additions & 4 deletions AndUE4Dumper/source/src/Core/GameProfiles/Games/PES.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ class PESProfile : public IGameProfile
return 0;

add_imm12 = KittyArm64::decode_addsub_imm(add_insn);
if (add_imm12 == 0)
return 0;

return (page_off + adrp_pc_rel + add_imm12);
}
Expand Down Expand Up @@ -96,8 +94,6 @@ class PESProfile : public IGameProfile
return 0;

add_imm12 = KittyArm64::decode_addsub_imm(add_insn);
if (add_imm12 == 0)
return 0;

return (page_off + adrp_pc_rel + add_imm12);
}
Expand Down
8 changes: 2 additions & 6 deletions AndUE4Dumper/source/src/Core/GameProfiles/Games/PUBGM.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PUBGMProfile : public IGameProfile
"com.rekoo.pubgm",
"com.pubg.imobile",
"com.pubg.krmobile",
"com.vng.pubgmobile",
"com.vng.pubgmobile",
};

// chinese version doesn't have GNames encrypted but FNameEntry* is encrypted
Expand Down Expand Up @@ -104,8 +104,6 @@ class PUBGMProfile : public IGameProfile
return 0;

add_imm12 = KittyArm64::decode_addsub_imm(add_insn);
if (add_imm12 == 0)
return 0;

return (page_off + adrp_pc_rel + add_imm12);
}
Expand Down Expand Up @@ -171,10 +169,8 @@ class PUBGMProfile : public IGameProfile
return 0;

add_imm12 = KittyArm64::decode_addsub_imm(add_insn);
if (add_imm12 == 0)
return 0;

if (!KittyArm64::decode_ldrstr_uimm(ldrb_insn, &ldrb_imm12) || ldrb_imm12 == 0)
if (!KittyArm64::decode_ldrstr_uimm(ldrb_insn, &ldrb_imm12))
return 0;

enc_names = (page_off + adrp_pc_rel + add_imm12 + ldrb_imm12 - 4);
Expand Down
6 changes: 1 addition & 5 deletions AndUE4Dumper/source/src/Core/GameProfiles/Games/Torchlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,14 @@ class TorchlightProfile : public IGameProfile
return 0;

add_imm12 = KittyArm64::decode_addsub_imm(add_insn);
if (add_imm12 == 0)
return 0;

return (page_off + adrp_pc_rel + add_imm12);
}

uintptr_t GetNamesPtr() const override
{
PATTERN_MAP_TYPE map_type = isEmulator() ? PATTERN_MAP_TYPE::ANY_R : PATTERN_MAP_TYPE::ANY_X;
std::string ida_pattern = "C8 00 00 37 ? ? ? ? ? ? 28 91 ? ? FF 97";
std::string ida_pattern = "C8 00 00 37 ? ? ? ? ? ? ? 91 ? ? FF 97";
int step = 4;

uintptr_t insn_address = findIdaPattern(map_type, ida_pattern, step);
Expand All @@ -96,8 +94,6 @@ class TorchlightProfile : public IGameProfile
return 0;

add_imm12 = KittyArm64::decode_addsub_imm(add_insn);
if (add_imm12 == 0)
return 0;

return (page_off + adrp_pc_rel + add_imm12);
}
Expand Down
18 changes: 7 additions & 11 deletions AndUE4Dumper/source/src/Core/wrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1736,22 +1736,23 @@ void UE_UPackage::SaveStruct(std::vector<Struct> &arr, FILE *file)
{
for (auto &s : arr)
{
fmt::print(file, "// Object Name: {}\n// Size: {:#04x} // Inherited bytes: {:#04x}\n{} {{", s.FullName, s.Size, s.Inherited, s.CppName);
fmt::print(file, "// Object: {}\n// Inherited Bytes: {:#0x} | Struct Size: {:#0x}\n{} {{", s.FullName, s.Inherited, s.Size, s.CppName);

if (s.Members.size())
{
fmt::print(file, "\n\t// Fields");
for (auto &m : s.Members)
{
fmt::print(file, "\n\t{} {}; // Offset: {:#04x} // Size: {:#04x}", m.Type, m.Name, m.Offset, m.Size);
fmt::print(file, "\n\t{} {}; // Offset: {:#0x} | Size: {:#0x}", m.Type, m.Name, m.Offset, m.Size);
}
}
if (s.Functions.size())
{
fmt::print(file, "{}\n\t// Functions", s.Members.size() ? "\n" : "");
for (auto &f : s.Functions)
{
fmt::print(file, "\n\n\t// Object Name: {}\n\t// Flags: [{}]\n\t// Offset: {:#08x} // Return & Params: [ Num({}) Size({:#0x}) ]\n\t{}({});", f.FullName, f.Flags, f.Func - Profile::BaseAddress, f.NumParams, f.ParamSize, f.CppName, f.Params);
void *funcOffset = f.Func ? (void*)(f.Func - Profile::BaseAddress) : nullptr;
fmt::print(file, "\n\n\t// Object: {}\n\t// Flags: [{}]\n\t// Offset: {}\n\t// Return & Params: [ Num({}) Size({:#0x}) ]\n\t{}({});", f.FullName, f.Flags, funcOffset, f.NumParams, f.ParamSize, f.CppName, f.Params);
}
}
fmt::print(file, "\n}};\n\n");
Expand All @@ -1762,7 +1763,7 @@ void UE_UPackage::SaveEnum(std::vector<Enum> &arr, FILE *file)
{
for (auto &e : arr)
{
fmt::print(file, "// Object Name: {}\n{} {{", e.FullName, e.CppName);
fmt::print(file, "// Object: {}\n{} {{", e.FullName, e.CppName);

size_t lastIdx = e.Members.size() - 1;
for (size_t i = 0; i < lastIdx; i++)
Expand Down Expand Up @@ -1809,10 +1810,10 @@ bool UE_UPackage::Save(const std::string &dir, const std::string &headers_dir)
// make safe to use as a file name
std::string packageName = ioutils::replace_specials(GetObject().GetName(), '_');

File fulldump_file(dir + "/FullDump.hpp", "a");
File fulldump_file(dir + "/AIOHeader.hpp", "a");
if (fulldump_file.ok())
{
fmt::print(fulldump_file, "// {} Dumping: [ Enums: {} | Structs: {} | Classes: {} ]\n\n", packageName, Enums.size(), Structures.size(), Classes.size());
fmt::print(fulldump_file, "// Package {}: [ Enums: {} | Structs: {} | Classes: {} ]\n\n", packageName, Enums.size(), Structures.size(), Classes.size());
}

if (Enums.size())
Expand Down Expand Up @@ -1884,11 +1885,6 @@ bool UE_UPackage::Save(const std::string &dir, const std::string &headers_dir)
}
}

if (fulldump_file.ok())
{
fmt::print(fulldump_file, "\n\n");
}

return true;
}

Expand Down
3 changes: 2 additions & 1 deletion AndUE4Dumper/source/src/executable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,11 @@ int main(int argc, char **args)
if (sGamePackage == pkg)
{
dumpStatus = Dumper::Dump(sDumpGameDir, sDumpHeadersDir, bDumpLib, it);
break;
goto done;
}
}
}
done:

if (dumpStatus == Dumper::UE_DS_NONE)
{
Expand Down
3 changes: 2 additions & 1 deletion AndUE4Dumper/source/src/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ void dump_thread(bool bDumpLib)
if (sGamePackage == pkg)
{
dumpStatus = Dumper::Dump(sDumpDir, sDumpHeadersDir, bDumpLib, it);
break;
goto done;
}
}
}
done:

if (dumpStatus == Dumper::UE_DS_NONE)
{
Expand Down

0 comments on commit 5c53c8f

Please sign in to comment.