AuroraRuntime/Source/Process/ProcessMap.Win32.cpp

45 lines
1.1 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: ProcessMap.Win32.cpp
Date: 2021-6-12
Author: Reece
***/
2021-09-30 14:57:41 +00:00
#include <Source/RuntimeInternal.hpp>
2021-06-27 21:25:29 +00:00
#include "ProcessMap.Win32.hpp"
#include "ProcessMap.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
{
MODULEENTRY32 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
}
me32.dwSize = sizeof(MODULEENTRY32);
2021-06-27 21:25:29 +00:00
if (!Module32First(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
}
while (Module32Next(hModuleSnap, &me32));
2021-06-27 21:25:29 +00:00
CloseHandle(hModuleSnap);
2021-06-27 21:25:29 +00:00
}
}