use alloc::boxed::Box;
use alloc::vec;
use core::mem::zeroed;
use azathoth_core::os::Current::structs::URL_COMPONENTSA;
use azathoth_core::os::Current::types::DWORD;
#[repr(C)]
pub struct UrlCrackContext {
pub scheme: Box<[u8]>,
pub host: Box<[u8]>,
pub path: Box<[u8]>,
pub extra: Box<[u8]>,
pub components: URL_COMPONENTSA,
}
impl UrlCrackContext {
pub fn new() -> Self {
let mut scheme = vec![0u8; 32].into_boxed_slice();
let mut host = vec![0u8; 256].into_boxed_slice();
let mut path = vec![0u8; 1024].into_boxed_slice();
let mut extra = vec![0u8; 1024].into_boxed_slice();
let mut components = unsafe { zeroed::<URL_COMPONENTSA>() };
components.dwStructSize = size_of::<URL_COMPONENTSA>() as DWORD;
components.lpszScheme = scheme.as_mut_ptr();
components.dwSchemeLength = scheme.len() as DWORD;
components.lpszHostName = host.as_mut_ptr();
components.dwHostNameLength = host.len() as DWORD;
components.lpszUrlPath = path.as_mut_ptr();
components.dwUrlPathLength = path.len() as DWORD;
components.lpszExtraInfo = extra.as_mut_ptr();
components.dwExtraInfoLength = extra.len() as DWORD;
Self {
scheme,
host,
path,
extra,
components,
}
}
}
impl Default for UrlCrackContext {
fn default() -> Self {
Self::new()
}
}