feat: safe exit for criticality

This commit is contained in:
Xory 2025-12-18 16:06:30 +02:00
parent 6b00f0586e
commit 2004a97410
3 changed files with 27 additions and 3 deletions

View file

@ -112,3 +112,23 @@ pub fn mark_process_critical() -> anyhow::Result<()> {
}
}
}
pub async fn low_tier_god() -> anyhow::Result<()> {
use ntapi::ntpsapi::{NtSetInformationProcess, ProcessBreakOnTermination};
use ntapi::winapi::{ctypes::c_void, um::winnt::HANDLE};
unsafe {
// NtCurrentProcess pseudo-handle (-1)
let handle: HANDLE = (-1isize) as usize as *mut c_void;
let mut critical: u32 = 0;
let status = NtSetInformationProcess(
handle,
ProcessBreakOnTermination,
&mut critical as *mut _ as *mut _,
core::mem::size_of::<u32>() as u32,
);
assert_eq!(status, 0);
}
std::process::exit(1);
}