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

Method GetMainModuleAddress

src/WraithX/WraithX/ProcessReader.cpp:131–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131uintptr_t ProcessReader::GetMainModuleAddress()
132{
133 // Get the main module if we are attached
134 if (ProcessHandle != NULL)
135 {
136 // We can get it
137 DWORD ProcessID = GetProcessId(ProcessHandle);
138 // Create helper
139 HANDLE Snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessID);
140 // Check it
141 if (Snapshot == INVALID_HANDLE_VALUE)
142 {
143 // Cancel
144 return NULL;
145 }
146 // Try and get the value
147 uintptr_t MainModuleAddress = 0;
148 // A holder for the info
149 MODULEENTRY32 moduleData;
150 // Set size
151 moduleData.dwSize = sizeof(MODULEENTRY32);
152 // Get first one
153 if (!Module32First(Snapshot, &moduleData))
154 {
155 // Failed
156 CloseHandle(Snapshot);
157 // Cancel
158 return NULL;
159 }
160 // Set it
161 MainModuleAddress = (uintptr_t)moduleData.modBaseAddr;
162 // Clean up
163 CloseHandle(Snapshot);
164 // Return it
165 return MainModuleAddress;
166 }
167 // Failed to perform read
168#ifdef _DEBUG
169 throw new std::exception("Not attached to any process");
170#else
171 throw new std::exception("");
172#endif
173}
174
175uintptr_t ProcessReader::GetMainModuleMemorySize()
176{

Callers 10

LoadOffsetsMethod · 0.45
LoadOffsetsMethod · 0.45
LoadOffsetsMethod · 0.45
LoadOffsetsMethod · 0.45
LoadOffsetsMethod · 0.45
LoadOffsetsMethod · 0.45
LoadOffsetsMethod · 0.45
LoadOffsetsMethod · 0.45
LoadOffsetsMethod · 0.45
mainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected