#![allow(non_snake_case, non_camel_case_types)]
use core::ffi::c_void;
use crate::os::windows::types::PPS_POST_PROCESS_INIT_ROUTINE;
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "std", serde(rename_all = "PascalCase"))]
pub struct Guid {
pub data1: u32,
pub data2: u16,
pub data3: u16,
pub data4: [u8; 8],
}
impl Guid {
pub const fn new(data1: u32, data2: u16, data3: u16, data4: [u8; 8]) -> Self {
Guid { data1, data2, data3, data4 }
}
pub const fn from_u128(data: u128) -> Self {
let bytes = data.to_be_bytes();
Guid {
data1: u32::from_be_bytes([bytes[0], bytes[1], bytes[2], bytes[3]]),
data2: u16::from_be_bytes([bytes[4], bytes[5]]),
data3: u16::from_be_bytes([bytes[6], bytes[7]]),
data4: [bytes[8], bytes[9], bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15]],
}
}
}
#[repr(C)]
pub struct TEB {
Reserved1: [*mut c_void; 12],
pub ProcessEnvironmentBlock: *mut PEB,
Reserved2: [*mut c_void; 399],
Reserved3: [u8; 1952],
pub TlsSlots: [*mut c_void; 64],
Reserved4: [u8; 8],
Reserved5: [*mut c_void; 26],
ReservedForOle: *mut c_void,
Reserved6: [*mut c_void; 4],
pub TlsExpansionSlots: *mut c_void,
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct PEB {
Reserved1: [u8; 2],
pub BeingDebugged: u8,
Reserved2: [u8; 1],
Reserved3: [*mut c_void; 2],
pub Ldr: *mut PEB_LDR_DATA,
pub ProcessParameters: *mut RTL_USER_PROCESS_PARAMETERS,
Reserved4: [*mut c_void; 3],
pub AtlThunkSListPtr: *mut c_void,
Reserved5: *mut c_void,
Reserved6: u32,
Reserved7: *mut c_void,
Reserved8: u32,
pub AtlThunkSListPtr32: u32,
Reserved9: [*mut c_void; 45],
Reserved10: [u8; 96],
pub PostProcessInitRoutine: PPS_POST_PROCESS_INIT_ROUTINE,
Reserved11: [u8; 128],
Reserved12: [*mut c_void; 1],
pub SessionId: u32,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct RTL_USER_PROCESS_PARAMETERS {
Reserved1: [u8; 16],
Reserved2: [*mut c_void; 10],
pub ImagePathName: UNICODE_STRING,
pub CommandLine: UNICODE_STRING,
pub Environment: *mut u16,
}
impl Default for RTL_USER_PROCESS_PARAMETERS {
fn default() -> Self {
unsafe { core::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct UNICODE_STRING {
pub Length: u16,
pub MaximumLength: u16,
pub Buffer: *mut u16,
}
impl UNICODE_STRING {
pub fn from_wide(wide: &[u16]) -> Self {
Self {
Length: (wide.len() * 2) as u16,
MaximumLength: (wide.len() * 2) as u16,
Buffer: wide.as_ptr() as *mut u16,
}
}
}
#[repr(C)]
#[derive(Debug)]
pub struct LIST_ENTRY {
pub flink: *mut LIST_ENTRY,
pub blink: *mut LIST_ENTRY,
}
#[repr(C)]
#[derive(Debug)]
pub struct LDR_DATA_TABLE_ENTRY {
pub InLoadOrderLinks: LIST_ENTRY,
pub InMemoryOrderLinks: LIST_ENTRY,
pub InInitializationOrderLinks: LIST_ENTRY,
pub DllBase: *mut c_void,
pub EntryPoint: *mut c_void,
pub SizeOfImage: u32,
pub FullDllName: UNICODE_STRING,
pub BaseDllName: UNICODE_STRING,
}
#[repr(C)]
#[derive(Debug)]
pub struct PEB_LDR_DATA {
pub Length: u32,
pub Initialized: u8,
pub SsHandle: *mut c_void,
pub InLoadOrderModuleList: LIST_ENTRY,
pub InMemoryOrderModuleList: LIST_ENTRY,
pub InInitializationOrderModuleList: LIST_ENTRY,
}