mirror-ac/user/um/imports.cpp

33 lines
1,022 B
C++
Raw Normal View History

2023-08-16 11:28:46 +02:00
#include "imports.h"
#include "../common.h"
usermode::Imports::Imports()
{
NtQueryInformationThread = nullptr;
RtlDosPathNameToNtPathName_U = nullptr;
2023-08-16 11:28:46 +02:00
this->ImportMap["NtQueryInformationThread"] = NtQueryInformationThread;
this->ImportMap["RtlDosPathNameToNtPathName_U"] = RtlDosPathNameToNtPathName_U;
2023-08-16 11:28:46 +02:00
std::map<std::string, void*>::iterator it;
2023-08-17 10:45:50 +02:00
for (it = this->ImportMap.begin(); it != this->ImportMap.end(); it++)
{
HMODULE module_handle = GetModuleHandle(L"ntdll.dll");
2023-08-17 10:45:50 +02:00
if (!module_handle)
{
LOG_ERROR("GetModuleHandle failed with status code 0x%x", GetLastError());
return;
}
2023-08-17 10:45:50 +02:00
it->second = GetProcAddress(module_handle, it->first.c_str());
2023-08-17 10:45:50 +02:00
if (!it->second)
{
LOG_ERROR("GetProcAddress failed with status code 0x%x", GetLastError());
}
}
2023-08-16 11:28:46 +02:00
}