use windows::Win32::Foundation::HANDLE;
use windows::Win32::System::Threading::TerminateProcess;
use crate::identity::Key;
pub(crate) trait Kernel: Sync {
fn creation_token(&self, handle: HANDLE) -> windows::core::Result<Key>;
fn terminate(&self, handle: HANDLE, exit_code: u32) -> windows::core::Result<()>;
}
pub(crate) struct HostKernel;
impl Kernel for HostKernel {
fn creation_token(&self, handle: HANDLE) -> windows::core::Result<Key> {
super::creation_token_result(handle)
}
fn terminate(&self, handle: HANDLE, exit_code: u32) -> windows::core::Result<()> {
unsafe { TerminateProcess(handle, exit_code) }
}
}
forward_kernel! {
fn creation_token(&self, handle: HANDLE) -> windows::core::Result<Key>;
fn terminate(&self, handle: HANDLE, exit_code: u32) -> windows::core::Result<()>;
}
#[cfg(test)]
#[path = "kernel/fake.rs"]
pub(crate) mod fake;