Skip to content

Commit

Permalink
Visual Studio 2022
Browse files Browse the repository at this point in the history
  • Loading branch information
guttir14 committed Nov 13, 2021
1 parent 18f5f1d commit b5858d8
Show file tree
Hide file tree
Showing 14 changed files with 1,405 additions and 913 deletions.
9 changes: 6 additions & 3 deletions Dumper/Dumper.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down Expand Up @@ -58,6 +58,9 @@
<GenerateManifest>false</GenerateManifest>
<LibraryPath>$(SolutionDir)libs;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Label="Vcpkg">
<VcpkgEnabled>true</VcpkgEnabled>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
Expand Down Expand Up @@ -102,7 +105,7 @@
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateDebugInformation>false</GenerateDebugInformation>
<AdditionalDependencies>ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
Expand Down
46 changes: 23 additions & 23 deletions Dumper/Dumper.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Headers">
<Filter Include="include">
<UniqueIdentifier>{7feed74c-41d0-4a17-93ca-9e368259955d}</UniqueIdentifier>
</Filter>
<Filter Include="include\fmt">
<UniqueIdentifier>{fa04ece9-af5e-44b6-9f99-319055d65faa}</UniqueIdentifier>
</Filter>
<Filter Include="headers">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Sources">
<Filter Include="sources">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Sources\include">
<UniqueIdentifier>{7feed74c-41d0-4a17-93ca-9e368259955d}</UniqueIdentifier>
</Filter>
<Filter Include="Sources\include\fmt">
<UniqueIdentifier>{fa04ece9-af5e-44b6-9f99-319055d65faa}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Sources</Filter>
<Filter>sources</Filter>
</ClCompile>
<ClCompile Include="utils.cpp">
<Filter>Sources</Filter>
<Filter>sources</Filter>
</ClCompile>
<ClCompile Include="wrappers.cpp">
<Filter>Sources</Filter>
<Filter>sources</Filter>
</ClCompile>
<ClCompile Include="generic.cpp">
<Filter>Sources</Filter>
<Filter>sources</Filter>
</ClCompile>
<ClCompile Include="..\include\fmt\format.cc">
<Filter>Sources\include\fmt</Filter>
<Filter>include\fmt</Filter>
</ClCompile>
<ClCompile Include="memory.cpp">
<Filter>Sources</Filter>
<Filter>sources</Filter>
</ClCompile>
<ClCompile Include="engine.cpp">
<Filter>Sources</Filter>
<Filter>sources</Filter>
</ClCompile>
<ClCompile Include="dumper.cpp">
<Filter>Sources</Filter>
<Filter>sources</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="engine.h">
<Filter>Headers</Filter>
<Filter>headers</Filter>
</ClInclude>
<ClInclude Include="utils.h">
<Filter>Headers</Filter>
<Filter>headers</Filter>
</ClInclude>
<ClInclude Include="memory.h">
<Filter>Headers</Filter>
<Filter>headers</Filter>
</ClInclude>
<ClInclude Include="wrappers.h">
<Filter>Headers</Filter>
<Filter>headers</Filter>
</ClInclude>
<ClInclude Include="generic.h">
<Filter>Headers</Filter>
<Filter>headers</Filter>
</ClInclude>
<ClInclude Include="defs.h">
<Filter>Headers</Filter>
<Filter>headers</Filter>
</ClInclude>
<ClInclude Include="dumper.h">
<Filter>Headers</Filter>
<Filter>headers</Filter>
</ClInclude>
</ItemGroup>
</Project>
22 changes: 15 additions & 7 deletions Dumper/dumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ STATUS Dumper::Init(int argc, char *argv[]) {
Full = false;
} else if (arg16 == 'w-') {
Wait = true;
} else if ((arg16 == 'f-')) {
} else if (arg16 == 'f-') {
i++;
if (i < argc) { PackageName = argv[i]; }
else { return STATUS::FAILED; }
Expand Down Expand Up @@ -68,13 +68,14 @@ STATUS Dumper::Init(int argc, char *argv[]) {
Directory = root / "Games" / game;
fs::create_directories(Directory);

auto [base, size] = GetModuleInfo(pid, processName);
if (!(base && size)) { return STATUS::MODULE_NOT_FOUND; }
Base = (uint64)base;
uint64 size = GetImageSize();
if (!size) { return STATUS::MODULE_NOT_FOUND; }

Image = VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (!Read(base, Image, size)) {
if (!Read((void*)Base, Image, size)) {
return STATUS::CANNOT_READ;
}

return EngineInit(game.string(), Image);
}
}
Expand Down Expand Up @@ -108,9 +109,16 @@ STATUS Dumper::Dump() {
std::function<void(UE_UObject)> callback;
if (Full) {
callback = [&file, &size, &packages](UE_UObject object) {
fmt::print(file, "[{:0>6}] <{}> <{}> {}\n", object.GetIndex(), object.GetAddress(), Read<void*>(object.GetAddress()), object.GetFullName());

auto isFunction = object.IsA<UE_UFunction>();
if (isFunction) {
fmt::print(file, "[{:0>6}] <{}> <{}> {} {:x}\n", object.GetIndex(), object.GetAddress(), Read<void*>(object.GetAddress()), object.GetFullName(), object.Cast<UE_UFunction>().GetFunc() - Base);
}
else {
fmt::print(file, "[{:0>6}] <{}> <{}> {}\n", object.GetIndex(), object.GetAddress(), Read<void*>(object.GetAddress()), object.GetFullName());
}
size++;
if (object.IsA<UE_UStruct>() || object.IsA<UE_UEnum>()) {
if (isFunction || object.IsA<UE_UStruct>() || object.IsA<UE_UEnum>()) {
auto packageObj = object.GetPackageObject();
packages[packageObj].push_back(object);
}
Expand Down
33 changes: 18 additions & 15 deletions Dumper/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,12 @@ struct {
} Brickadia;
static_assert(sizeof(Brickadia) == sizeof(Offsets));


struct {
void* offsets; // address to filled offsets structure
std::pair<const char*, uint32> names; // NamePoolData signature
std::pair<const char*, uint32> objects; // ObjObjects signature
std::function<bool(std::pair<uint8*, uint8*>*)> callback;
std::function<bool(void*, void*)> callback;
} engines[] = {
{ // RogueCompany | PropWitchHuntModule-Win64-Shipping | Scum
&Default,
Expand Down Expand Up @@ -282,9 +283,9 @@ struct {
&Default,
{"\x4C\x8D\x35\x00\x00\x00\x00\x0F\x10\x07\x83\xFB\x01", 13},
{"\x48\x8B\x05\x00\x00\x00\x00\x48\x8B\x0C\xC8\x48\x8D\x04\xD1\xEB", 16},
[](std::pair<uint8*, uint8*>* s) {
[](void* start, void* end) {
if (!Decrypt_ANSI) {
auto decryptAnsi = FindPointer(s->first, s->second, "\xE8\x00\x00\x00\x00\x0F\xB7\x1B\xC1\xEB\x06\x4C\x89\x36\x4C\x89\x76\x08\x85\xDB\x74\x48", 22);
auto decryptAnsi = FindPointer(start, end, "\xE8\x00\x00\x00\x00\x0F\xB7\x1B\xC1\xEB\x06\x4C\x89\x36\x4C\x89\x76\x08\x85\xDB\x74\x48", 22);
if (decryptAnsi) {
/*
mov [rsp +8], rbx
Expand All @@ -299,7 +300,7 @@ struct {
*(uint64*)(trampoline + 17) = (uint64)((uint8*)decryptAnsi + 0x4A); // https://i.imgur.com/zWtMDar.png
Decrypt_ANSI = (ansi_fn)VirtualAlloc(0, sizeof(trampoline), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (Decrypt_ANSI) {
memcpy(Decrypt_ANSI, trampoline, sizeof(trampoline));
memcpy((void*)Decrypt_ANSI, trampoline, sizeof(trampoline));
return true;
}
}
Expand Down Expand Up @@ -332,11 +333,12 @@ std::unordered_map<std::string, decltype(&engines[0])> games = {
{"POLYGON-Win64-Shipping", &engines[4]},
{"FortniteClient-Win64-Shipping", &engines[5]},
{"TheIsleClient-Win64-Shipping", &engines[6]},
{"PortalWars-Win64-Shipping", &engines[7]}
{"PortalWars-Win64-Shipping", &engines[7]},
{"Tiger-Win64-Shipping", &engines[0]}
};

STATUS EngineInit(std::string game, void* image) {
auto sections = GetExSections(image);

auto it = games.find(game);
if (it == games.end()) { return STATUS::ENGINE_NOT_FOUND; }

Expand All @@ -345,21 +347,22 @@ STATUS EngineInit(std::string game, void* image) {

void* names = nullptr;
void* objects = nullptr;
bool callback = false;

uint8 found = 0;
if (!engine->callback) {
callback = true;
found |= 4;
}

for (auto i = 0; i < sections.size(); i++) {
auto &s = sections.at(i);
if (!names) if (names = FindPointer(s.first, s.second, engine->names.first, engine->names.second)) found |= 1;
if (!objects) if (objects = FindPointer(s.first, s.second, engine->objects.first, engine->objects.second)) found |= 2;
if (!callback) if (callback = engine->callback(&s)) found |= 4;
if (found == 7) break;
}
IterateExSections(
image,
[&](void* start, void* end)->bool {
if (!(found & 1)) if (names = FindPointer(start, end, engine->names.first, engine->names.second)) found |= 1;
if (!(found & 2)) if (objects = FindPointer(start, end, engine->objects.first, engine->objects.second)) found |= 2;
if (!(found & 4)) if (engine->callback(start, end)) found |= 4;
if (found == 7) return 1;
return 0;
}
);

if (found != 7) return STATUS::ENGINE_FAILED;

Expand Down
2 changes: 1 addition & 1 deletion Dumper/generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void FNamePool::DumpBlock(uint32 blockId, uint32 blockSize, std::function<void(s
auto entry = UE_FNameEntry(it);
auto [wide, len] = entry.Info();
if (len) {
char buf[1024]{};
char buf[1024];
entry.String(buf, wide, len);
callback(std::string_view(buf, len), entryHandle);
uint16 size = UE_FNameEntry::Size(wide, len);
Expand Down
27 changes: 22 additions & 5 deletions Dumper/memory.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
#include <Windows.h>
#include <winternl.h>
#include "memory.h"

HANDLE hProcess;
uint64 Base;

bool Read(void *address, void *buffer, uint64 size) {
return ReadProcessMemory(hProcess, address, buffer, size, nullptr);
bool Read(void* address, void* buffer, uint64 size) {
uint64 read;
return ReadProcessMemory(hProcess, address, buffer, size, &read) && read == size;
}

bool ReaderInit(uint32 pid) {
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
return hProcess != nullptr;
}
PROCESS_BASIC_INFORMATION pbi;
hProcess = OpenProcess(GENERIC_READ, 0, pid);
if (!hProcess) return false;
if (0 > NtQueryInformationProcess(hProcess, ProcessBasicInformation, &pbi, sizeof(pbi), 0)) goto failed;
Base = Read<uint64>((uint8*)pbi.PebBaseAddress + 0x10);
if (!Base) goto failed;
return true;
failed:
CloseHandle(hProcess);
return false;
}

uint64 GetImageSize() {
char buffer[0x400];
if (!Read((void*)Base, buffer, 0x400)) return 0;
auto nt = (PIMAGE_NT_HEADERS)(buffer + ((PIMAGE_DOS_HEADER)buffer)->e_lfanew);
return nt->OptionalHeader.SizeOfImage;
}
2 changes: 2 additions & 0 deletions Dumper/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ template <typename T> T Read(void *address) {
}

bool ReaderInit(uint32 pid);

uint64 GetImageSize();
Loading

0 comments on commit b5858d8

Please sign in to comment.