MCPcopy Create free account
hub / github.com/OpenSteam001/OpenSteamTool / EnumerateModules

Function EnumerateModules

src/OSTPlatform/Windows/Process.cpp:313–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311}
312
313std::vector<ModuleInfo> EnumerateModules(uint32_t pid) {
314 std::vector<ModuleInfo> modules;
315 Windows::UniqueFileHandle snapshot(
316 CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, pid));
317 if (!snapshot) {
318 OSTP_LOG_DEBUG("CreateToolhelp32Snapshot(pid={}) failed (error={})", pid, GetLastError());
319 return modules;
320 }
321
322 MODULEENTRY32W entry{};
323 entry.dwSize = sizeof(entry);
324 if (Module32FirstW(snapshot.get(), &entry)) {
325 do {
326 std::filesystem::path nativePath(entry.szExePath);
327 std::string path = Encoding::WideToUtf8(entry.szExePath);
328 if (path.empty()) continue;
329
330 modules.push_back(ModuleInfo{
331 std::move(path),
332 std::move(nativePath),
333 entry.modBaseSize,
334 false,
335 });
336 } while (Module32NextW(snapshot.get(), &entry));
337 }
338 return modules;
339}
340
341bool IsSystemModulePath(const std::string& path) {
342 static const std::string systemDir = [] {

Callers

nothing calls this directly

Calls 3

WideToUtf8Function · 0.85
emptyMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected