-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcKernal.cpp
46 lines (34 loc) · 1.14 KB
/
cKernal.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "cKernal.h"
cKernal_t cKernal::_instance = nullptr;
cKernal_t cKernal::Get()
{
if (_instance == nullptr)
_instance = std::make_shared<cKernal>();
return _instance;
}
cKernal::cKernal()
{
if (_logger == nullptr)
_logger = cLogger::Get();
_ntDLL = GetModuleHandleA("ntdll");
if (!_ntDLL)
return;
_fnNtQueryInformationProces = reinterpret_cast<pNtQueryInformationProcess>(GetProcAddress(_ntDLL, "NtQueryInformationProcess"));
if (!_fnNtQueryInformationProces)
return;
}
cKernal::~cKernal()
{
}
void* cKernal::GetPEBFromHandle(const HANDLE& handle)
{
PROCESS_BASIC_INFORMATION pbi = {};
NtQueryInformationProcess(handle, 0, &pbi, sizeof(PROCESS_BASIC_INFORMATION), 0);
return pbi.PebBaseAddress;
}
DWORD cKernal::NtQueryInformationProcess(HANDLE ProcessHandle, DWORD ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength, PULONG ReturnLength)
{
if (!_fnNtQueryInformationProces)
return NULL;
return _fnNtQueryInformationProces(ProcessHandle, ProcessInformationClass, ProcessInformation, ProcessInformationLength, ReturnLength);
}