AuroraRuntime/Source/Process/AuProcessMap.Win32.cpp

52 lines
1.3 KiB
C++
Raw Normal View History

2021-06-27 21:25:29 +00:00
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuProcessMap.Win32.cpp
2021-06-27 21:25:29 +00:00
Date: 2021-6-12
Author: Reece
***/
2021-09-30 14:57:41 +00:00
#include <Source/RuntimeInternal.hpp>
#include "AuProcessMap.Win32.hpp"
#include "AuProcessMap.NT.hpp"
#include <tlhelp32.h>
2021-06-27 21:25:29 +00:00
namespace Aurora::Process
{
void MakeToolHelp32Snapshot()
2021-06-27 21:25:29 +00:00
{
2024-04-21 10:37:00 +00:00
MODULEENTRY32W me32;
HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());
if (hModuleSnap == INVALID_HANDLE_VALUE)
2021-06-27 21:25:29 +00:00
{
SysPushErrorGen("CreateToolhelp32Snapshot");
return;
2021-06-27 21:25:29 +00:00
}
2024-04-21 10:37:00 +00:00
me32.dwSize = sizeof(MODULEENTRY32W);
2021-06-27 21:25:29 +00:00
2024-04-21 10:37:00 +00:00
if (!pModule32FirstW)
{
SysPushErrorFeatureMissing();
return;
}
if (!pModule32FirstW(hModuleSnap, &me32))
2021-06-27 21:25:29 +00:00
{
SysPushErrorGen("Module32First failed");
CloseHandle(hModuleSnap);
return;
2021-06-27 21:25:29 +00:00
}
do
2021-06-27 21:25:29 +00:00
{
auto h = reinterpret_cast<HMODULE>(me32.modBaseAddr);
InvaildateModule(h);
MakeAware(h);
2021-06-27 21:25:29 +00:00
}
2024-04-21 10:37:00 +00:00
while (pModule32NextW &&
pModule32NextW(hModuleSnap, &me32));
2021-06-27 21:25:29 +00:00
CloseHandle(hModuleSnap);
2021-06-27 21:25:29 +00:00
}
}