MCPcopy Create free account
hub / github.com/Scobalula/Greyhound / GetModuleAddress

Method GetModuleAddress

src/WraithX/WraithX/ProcessReader.cpp:219–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219uintptr_t ProcessReader::GetModuleAddress(const std::string & ModuleName)
220{
221 // Get the main module if we are attached
222 if (ProcessHandle != NULL)
223 {
224 // Check if we're 32bit
225 BOOL IsWin32 = false;
226 if (!IsWow64Process(ProcessHandle, &IsWin32))
227 return 0;
228 // We can get it
229 DWORD ProcessID = GetProcessId(ProcessHandle);
230 // Handle Modules
231 HMODULE hMods[1024];
232 DWORD cbNeeded;
233 // Try and get the value
234 uintptr_t ModuleAddress = 0;
235 // Attempt to enum all modules
236 if (EnumProcessModulesEx(ProcessHandle, hMods, sizeof(hMods), &cbNeeded, IsWin32 ? LIST_MODULES_32BIT : LIST_MODULES_DEFAULT))
237 {
238 for (uint32_t i = 0; i < (cbNeeded / sizeof(HMODULE)); i++)
239 {
240 // Module Name
241 TCHAR szModName[MAX_PATH];
242 // Get the name of the file
243 if (GetModuleFileNameEx(ProcessHandle, hMods[i], szModName, sizeof(szModName) / sizeof(TCHAR)))
244 {
245 // Get as ASCII, and then get the file name
246 auto FileName = Strings::ToLower(FileSystems::GetFileName(Strings::ToNormalString(szModName)));
247
248 if (FileName == ModuleName)
249 {
250 ModuleAddress = (uintptr_t)hMods[i];
251 }
252 }
253 }
254 }
255 // Return it
256 return ModuleAddress;
257 }
258 // Failed to perform read
259#ifdef _DEBUG
260 throw new std::exception("Not attached to any process");
261#else
262 throw new std::exception("");
263#endif
264}
265
266uintptr_t ProcessReader::GetModuleMemorySize(const std::string & ModuleName)
267{

Callers 1

LoadOffsetsMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected