Add rust kext to the mono repo

This commit is contained in:
Vladimir Stoilov
2024-04-29 17:04:08 +03:00
parent 740ef1ad32
commit b0f664047b
98 changed files with 13811 additions and 84 deletions

View File

@@ -0,0 +1,22 @@
use alloc::string::{String, ToString};
use ntstatus::ntstatus::NtStatus;
use windows_sys::Win32::Foundation::STATUS_SUCCESS;
use crate::ffi;
pub fn check_ntstatus(status: i32) -> Result<(), String> {
if status == STATUS_SUCCESS {
return Ok(());
}
let Some(status) = NtStatus::from_u32(status as u32) else {
return Err("UNKNOWN_ERROR_CODE".to_string());
};
return Err(status.to_string());
}
pub fn get_system_timestamp_ms() -> u64 {
// 100 nano seconds units -> device by 10 -> micro seconds -> divide by 1000 -> milliseconds
unsafe { ffi::pm_QuerySystemTime() / 10_000 }
}