feat eprocess flag protect
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
#include "process_func.h"
|
||||
namespace process_function
|
||||
{
|
||||
ULONG orin_protect_val;
|
||||
|
||||
auto eprocess_get_protect_offset() -> UINT32
|
||||
{
|
||||
UNICODE_STRING func_name{ 0 };
|
||||
RtlInitUnicodeString(&func_name, L"PsIsProtectedProcess");
|
||||
auto pfunc_address = reinterpret_cast<unsigned char*>(MmGetSystemRoutineAddress(&func_name));
|
||||
auto offset = *(UINT32*)(pfunc_address + 0x2);
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
auto eprocess_protect_process_on(UINT32 Pid) -> NTSTATUS
|
||||
{
|
||||
PEPROCESS process{ 0 };
|
||||
|
||||
auto status = PsLookupProcessByProcessId(ULongToHandle(Pid), &process);
|
||||
if (!NT_SUCCESS(status))
|
||||
return status;
|
||||
|
||||
auto offset = eprocess_get_protect_offset();
|
||||
|
||||
auto Protection = reinterpret_cast<unsigned long*>((UINT64)process + offset);
|
||||
if (*Protection != 0xc0000061)
|
||||
{
|
||||
orin_protect_val = *Protection;
|
||||
*Protection = 0xc0000061;
|
||||
}
|
||||
|
||||
ObDereferenceObject(process);
|
||||
return status;
|
||||
}
|
||||
|
||||
auto eprocess_protect_process_off(UINT32 Pid) -> NTSTATUS
|
||||
{
|
||||
PEPROCESS process{ 0 };
|
||||
|
||||
auto status = PsLookupProcessByProcessId(ULongToHandle(Pid), &process);
|
||||
if (!NT_SUCCESS(status))
|
||||
return status;
|
||||
|
||||
auto offset = eprocess_get_protect_offset();
|
||||
auto Protection = reinterpret_cast<unsigned long*>((UINT64)process + offset);
|
||||
if (*Protection == 0xc0000061)
|
||||
*Protection = orin_protect_val;
|
||||
|
||||
ObDereferenceObject(process);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#ifndef PROCESS_FUNC
|
||||
#define PROCESS_FUNC
|
||||
#include "Base.h"
|
||||
|
||||
|
||||
namespace process_function
|
||||
{
|
||||
auto eprocess_protect_process_on(UINT32 Pid)->NTSTATUS;
|
||||
|
||||
auto eprocess_protect_process_off(UINT32 Pid)->NTSTATUS;
|
||||
|
||||
auto kernel_kill_process(UINT32 Pid)->NTSTATUS;
|
||||
}
|
||||
|
||||
#endif // !PROCESS_FUNC
|
||||
Reference in New Issue
Block a user