use super::*;

unsafe extern "system" {
    pub(super) fn CreateFileA(
        lp_file_name: *const c_char,
        desired_access: u32,
        share_mode: u32,
        security_attributes: *mut c_void,
        creation_disposition: u32,
        flags_and_attributes: u32,
        template_file: *mut c_void,
    ) -> isize;
    pub(super) fn SetFilePointer(
        file: isize,
        distance: i32,
        distance_high: *mut i32,
        move_method: u32,
    ) -> u32;
    pub(super) fn WriteFile(
        file: isize,
        buffer: *const c_void,
        bytes_to_write: u32,
        bytes_written: *mut u32,
        overlapped: *mut c_void,
    ) -> i32;
    pub(super) fn CloseHandle(handle: isize) -> i32;
    pub(super) fn DisableThreadLibraryCalls(module: *mut c_void) -> i32;
    pub(super) fn FlushInstructionCache(
        process: *mut c_void,
        base_address: *const c_void,
        size: usize,
    ) -> i32;
    pub(super) fn GetCurrentProcess() -> *mut c_void;
    pub(super) fn GetSystemDirectoryA(buffer: *mut u8, size: u32) -> u32;
    pub(super) fn GetProcAddress(module: isize, name: *const c_char) -> *mut c_void;
    pub(super) fn LoadLibraryA(name: *const c_char) -> isize;
    pub(super) fn OutputDebugStringA(output: *const c_char);
    pub(super) fn VirtualAlloc(
        address: *mut c_void,
        size: usize,
        allocation_type: u32,
        protect: u32,
    ) -> *mut c_void;
    pub(super) fn VirtualProtect(
        address: *mut c_void,
        size: usize,
        new_protect: u32,
        old_protect: *mut u32,
    ) -> i32;
}

#[repr(C)]
pub(crate) struct Guid {
    data1: u32,
    data2: u16,
    data3: u16,
    data4: [u8; 8],
}

pub(super) type DirectInput8CreateFn = unsafe extern "system" fn(
    instance: *mut c_void,
    version: u32,
    riid: *const Guid,
    out: *mut *mut c_void,
    outer: *mut c_void,
) -> i32;
pub(super) type ShellStateServiceFn = unsafe extern "thiscall" fn(*mut u8) -> i32;
pub(super) type ShellTransitionModeFn = unsafe extern "thiscall" fn(*mut u8, u32, u32) -> i32;
pub(super) type ProfileStartupDispatchFn = unsafe extern "thiscall" fn(*mut u8, u32, u32) -> i32;
pub(super) type RuntimeResetFn = unsafe extern "thiscall" fn(*mut u8) -> *mut u8;
pub(super) type StartupRuntimeAllocThunkFn = unsafe extern "cdecl" fn(u32) -> *mut u8;
pub(super) type LoadScreenSetScalarFn = unsafe extern "thiscall" fn(*mut u8, u32) -> u32;
pub(super) type LoadScreenConstructFn = unsafe extern "thiscall" fn(*mut u8) -> *mut u8;
pub(super) type LoadScreenHandleMessageFn = unsafe extern "thiscall" fn(*mut u8, *mut u8) -> i32;
pub(super) type ShellRuntimePrimeFn = unsafe extern "thiscall" fn(*mut u8) -> i32;
pub(super) type ShellFrameCycleFn = unsafe extern "thiscall" fn(*mut u8) -> i32;
pub(super) type ShellObjectServiceFn = unsafe extern "thiscall" fn(*mut u8) -> i32;
pub(super) type ShellChildServiceFn = unsafe extern "thiscall" fn(*mut u8) -> i32;
pub(super) type ShellPublishWindowFn = unsafe extern "thiscall" fn(*mut u8, *mut u8, u32) -> i32;
pub(super) type ShellUnpublishWindowFn = unsafe extern "thiscall" fn(*mut u8, *mut u8) -> i32;
pub(super) type ShellObjectTeardownFn = unsafe extern "thiscall" fn(*mut u8) -> i32;
pub(super) type ShellObjectRangeRemoveFn =
    unsafe extern "thiscall" fn(*mut u8, u32, u32, u32) -> i32;
pub(super) type ShellRemoveNodeFn = unsafe extern "thiscall" fn(*mut u8, *mut u8) -> i32;
pub(super) type ShellNodeVcallFn = unsafe extern "thiscall" fn(*mut u8, *mut u8) -> i32;
pub(super) type Mode2TeardownFn = unsafe extern "thiscall" fn(*mut u8) -> i32;
