MCPcopy Create free account
hub / github.com/Phobos-developers/Phobos / GetGameModulesBaseAddresses

Method GetGameModulesBaseAddresses

src/Utilities/AresHelper.cpp:52–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52void AresHelper::GetGameModulesBaseAddresses()
53{
54 HANDLE hCurrentProcess = GetCurrentProcess();
55 std::vector<std::pair<std::string, BYTE*>> syringables;
56 std::vector<std::pair<std::string, BYTE*>> others;
57 HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, GetProcessId(hCurrentProcess));
58 if (hSnap != INVALID_HANDLE_VALUE)
59 {
60 MODULEENTRY32 modEntry { };
61 modEntry.dwSize = sizeof(modEntry);
62 if (Module32First(hSnap, &modEntry))
63 {
64 do
65 {
66 DWORD _useless;
67 DWORD infoBufferSize = GetFileVersionInfoSize(modEntry.szModule, &_useless);
68 if (infoBufferSize == 0)
69 continue;
70 std::vector<char> infoBuffer(infoBufferSize);
71 if (!GetFileVersionInfo(modEntry.szModule, NULL, infoBufferSize, infoBuffer.data()))
72 continue;
73 LPVOID nameBuffer;
74 unsigned int nameBufferSize;
75 // 0409 04b0 is language: English (American), codepage: UTF-16
76 if (!VerQueryValue(infoBuffer.data(), "\\StringFileInfo\\040904b0\\OriginalFilename", &nameBuffer, &nameBufferSize))
77 continue;
78 const char* originalModuleName = (const char*)nameBuffer;
79 if (!_strcmpi(originalModuleName, "Sun.exe"))
80 continue;
81 if (module_has_syhks00(modEntry.hModule))
82 {
83 if (!_strcmpi(originalModuleName, "Ares.dll"))
84 AresBaseAddress = (uintptr_t)modEntry.modBaseAddr;
85 else if (!_strcmpi(originalModuleName, PHOBOS_DLL))
86 PhobosBaseAddress = (uintptr_t)modEntry.modBaseAddr;
87 syringables.emplace_back(originalModuleName, modEntry.modBaseAddr);
88 }
89 else
90 {
91 others.emplace_back(originalModuleName, modEntry.modBaseAddr);
92 }
93 }
94 while (Module32Next(hSnap, &modEntry));
95 }
96 }
97 CloseHandle(hSnap);
98#ifndef USING_MULTIFINITE_SYRINGE
99 Debug::LogDeferred("Modules presumably injected by Syringe:\n");
100 for (auto const& [modName, modBaseAddr] : syringables)
101 Debug::LogDeferred("Module %s base address : 0x%p.\n", modName.c_str(), modBaseAddr);
102 Debug::LogDeferred("Other modules:\n");
103 for (auto const& [modName, modBaseAddr] : others)
104 Debug::LogDeferred("Module %s base address : 0x%p.\n", modName.c_str(), modBaseAddr);
105#endif
106}
107
108void AresHelper::Init()
109{

Callers

nothing calls this directly

Calls 3

module_has_syhks00Function · 0.85
dataMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected