|
|
@ -83,15 +83,11 @@ namespace vdm
|
|
|
|
{
|
|
|
|
{
|
|
|
|
static const auto ps_lookup_peproc =
|
|
|
|
static const auto ps_lookup_peproc =
|
|
|
|
util::get_kmodule_export(
|
|
|
|
util::get_kmodule_export(
|
|
|
|
"ntoskrnl.exe",
|
|
|
|
"ntoskrnl.exe", "PsLookupProcessByProcessId");
|
|
|
|
"PsLookupProcessByProcessId");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PEPROCESS peproc = nullptr;
|
|
|
|
PEPROCESS peproc = nullptr;
|
|
|
|
this->syscall<PsLookupProcessByProcessId>(
|
|
|
|
syscall<PsLookupProcessByProcessId>(
|
|
|
|
ps_lookup_peproc,
|
|
|
|
ps_lookup_peproc, (HANDLE)pid, &peproc);
|
|
|
|
(HANDLE)pid,
|
|
|
|
|
|
|
|
&peproc
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
return peproc;
|
|
|
|
return peproc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -99,37 +95,42 @@ namespace vdm
|
|
|
|
{
|
|
|
|
{
|
|
|
|
static const auto ntoskrnl_get_virtual =
|
|
|
|
static const auto ntoskrnl_get_virtual =
|
|
|
|
util::get_kmodule_export(
|
|
|
|
util::get_kmodule_export(
|
|
|
|
"ntoskrnl.exe",
|
|
|
|
"ntoskrnl.exe", "MmGetVirtualForPhysical");
|
|
|
|
"MmGetVirtualForPhysical");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this->syscall<MmGetVirtualForPhysical>(
|
|
|
|
return syscall<MmGetVirtualForPhysical>(
|
|
|
|
ntoskrnl_get_virtual, addr);
|
|
|
|
ntoskrnl_get_virtual, addr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
__forceinline auto kalloc(std::size_t size) -> std::uintptr_t
|
|
|
|
__forceinline auto kalloc(std::size_t size) -> std::uintptr_t
|
|
|
|
{
|
|
|
|
{
|
|
|
|
static const auto mm_allocate =
|
|
|
|
static const auto mm_allocate =
|
|
|
|
util::get_kmodule_export("ntoskrnl.exe", "ExAllocatePool");
|
|
|
|
util::get_kmodule_export(
|
|
|
|
|
|
|
|
"ntoskrnl.exe", "ExAllocatePool");
|
|
|
|
|
|
|
|
|
|
|
|
return this->syscall<std::uintptr_t(*)
|
|
|
|
return syscall<std::uintptr_t(*)
|
|
|
|
(std::uint8_t, std::size_t)>(mm_allocate, NULL, size);
|
|
|
|
(std::uint8_t, std::size_t)>(mm_allocate, NULL, size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
__forceinline auto get_physical(std::uintptr_t phys_addr) -> std::uintptr_t
|
|
|
|
__forceinline auto get_physical(std::uintptr_t phys_addr) -> std::uintptr_t
|
|
|
|
{
|
|
|
|
{
|
|
|
|
static const auto mm_get_physical =
|
|
|
|
static const auto mm_get_physical =
|
|
|
|
util::get_kmodule_export("ntoskrnl.exe", "MmGetPhysicalAddress");
|
|
|
|
util::get_kmodule_export(
|
|
|
|
|
|
|
|
"ntoskrnl.exe", "MmGetPhysicalAddress");
|
|
|
|
|
|
|
|
|
|
|
|
return this->syscall<std::uintptr_t(*)
|
|
|
|
return syscall<std::uintptr_t(*)
|
|
|
|
(std::uintptr_t)>(mm_get_physical, phys_addr);
|
|
|
|
(std::uintptr_t)>(mm_get_physical, phys_addr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
__forceinline auto get_current_thread(void) -> PETHREAD
|
|
|
|
__forceinline auto get_pethread(std::uint32_t tid) -> PETHREAD
|
|
|
|
{
|
|
|
|
{
|
|
|
|
static const auto ke_get_thread =
|
|
|
|
static const auto ps_lookup_thread =
|
|
|
|
util::get_kmodule_export("ntoskrnl.exe", "KeGetCurrentThread");
|
|
|
|
util::get_kmodule_export(
|
|
|
|
|
|
|
|
"ntoskrnl.exe", "PsLookupThreadByThreadId");
|
|
|
|
|
|
|
|
|
|
|
|
return this->syscall<PETHREAD(*)()>(ke_get_thread);
|
|
|
|
PETHREAD result = nullptr;
|
|
|
|
|
|
|
|
syscall<PsLookupThreadByThreadId>(
|
|
|
|
|
|
|
|
ps_lookup_thread, (HANDLE)tid, &result);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
__forceinline auto readcr3(void) -> std::uintptr_t
|
|
|
|
__forceinline auto readcr3(void) -> std::uintptr_t
|
|
|
|