wslpluginapi-sys 0.2.0+2.4.4

Rust bindings for the WSL Plugin API
Documentation
/* automatically generated by rust-bindgen 0.72.1 */

use windows_sys::core::*;
use windows_sys::Win32::Foundation::*;
use windows_sys::Win32::Networking::WinSock::SOCKET;
#[allow(unused_imports)]
use windows_sys::Win32::Security::*;
#[allow(clippy::upper_case_acronyms)]
type LPCWSTR = PCWSTR;
#[allow(clippy::upper_case_acronyms)]
type LPCSTR = PCSTR;
#[allow(clippy::upper_case_acronyms)]
type DWORD = u32;
#[cfg(feature = "hooks-field-names")]
use struct_field_names_as_array::FieldNamesAsSlice;

#[repr(C)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct WSLVersion {
    pub Major: u32,
    pub Minor: u32,
    pub Revision: u32,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
    ["Size of WSLVersion"][::std::mem::size_of::<WSLVersion>() - 12usize];
    ["Alignment of WSLVersion"][::std::mem::align_of::<WSLVersion>() - 4usize];
    ["Offset of field: WSLVersion::Major"][::std::mem::offset_of!(WSLVersion, Major) - 0usize];
    ["Offset of field: WSLVersion::Minor"][::std::mem::offset_of!(WSLVersion, Minor) - 4usize];
    ["Offset of field: WSLVersion::Revision"]
        [::std::mem::offset_of!(WSLVersion, Revision) - 8usize];
};
pub const WSLUserConfiguration_None: WSLUserConfiguration = 0;
pub const WSLUserConfiguration_WSLUserConfigurationCustomKernel: WSLUserConfiguration = 1;
pub const WSLUserConfiguration_WSLUserConfigurationCustomKernelCommandLine: WSLUserConfiguration =
    2;
pub type WSLUserConfiguration = ::std::os::raw::c_int;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct WSLVmCreationSettings {
    pub CustomConfigurationFlags: WSLUserConfiguration,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
    ["Size of WSLVmCreationSettings"][::std::mem::size_of::<WSLVmCreationSettings>() - 4usize];
    ["Alignment of WSLVmCreationSettings"]
        [::std::mem::align_of::<WSLVmCreationSettings>() - 4usize];
    ["Offset of field: WSLVmCreationSettings::CustomConfigurationFlags"]
        [::std::mem::offset_of!(WSLVmCreationSettings, CustomConfigurationFlags) - 0usize];
};
pub type WSLSessionId = DWORD;
#[repr(C)]
pub struct WSLSessionInformation {
    pub SessionId: WSLSessionId,
    pub UserToken: HANDLE,
    pub UserSid: PSID,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
    ["Size of WSLSessionInformation"][::std::mem::size_of::<WSLSessionInformation>() - 24usize];
    ["Alignment of WSLSessionInformation"]
        [::std::mem::align_of::<WSLSessionInformation>() - 8usize];
    ["Offset of field: WSLSessionInformation::SessionId"]
        [::std::mem::offset_of!(WSLSessionInformation, SessionId) - 0usize];
    ["Offset of field: WSLSessionInformation::UserToken"]
        [::std::mem::offset_of!(WSLSessionInformation, UserToken) - 8usize];
    ["Offset of field: WSLSessionInformation::UserSid"]
        [::std::mem::offset_of!(WSLSessionInformation, UserSid) - 16usize];
};
#[repr(C)]
pub struct WSLDistributionInformation {
    #[doc = " Distribution ID, guaranteed to be the same accross reboots"]
    pub Id: GUID,
    pub Name: LPCWSTR,
    pub PidNamespace: u64,
    #[doc = " Package family name, or NULL if none"]
    pub PackageFamilyName: LPCWSTR,
    #[doc = " Pid of the init process. Introduced in 2.0.5"]
    pub InitPid: u32,
    #[doc = " Type of distribution (ubuntu, debian, ...), introduced in TODO"]
    pub Flavor: LPCWSTR,
    #[doc = " Distribution version, introduced in TODO"]
    pub Version: LPCWSTR,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
    ["Size of WSLDistributionInformation"]
        [::std::mem::size_of::<WSLDistributionInformation>() - 64usize];
    ["Alignment of WSLDistributionInformation"]
        [::std::mem::align_of::<WSLDistributionInformation>() - 8usize];
    ["Offset of field: WSLDistributionInformation::Id"]
        [::std::mem::offset_of!(WSLDistributionInformation, Id) - 0usize];
    ["Offset of field: WSLDistributionInformation::Name"]
        [::std::mem::offset_of!(WSLDistributionInformation, Name) - 16usize];
    ["Offset of field: WSLDistributionInformation::PidNamespace"]
        [::std::mem::offset_of!(WSLDistributionInformation, PidNamespace) - 24usize];
    ["Offset of field: WSLDistributionInformation::PackageFamilyName"]
        [::std::mem::offset_of!(WSLDistributionInformation, PackageFamilyName) - 32usize];
    ["Offset of field: WSLDistributionInformation::InitPid"]
        [::std::mem::offset_of!(WSLDistributionInformation, InitPid) - 40usize];
    ["Offset of field: WSLDistributionInformation::Flavor"]
        [::std::mem::offset_of!(WSLDistributionInformation, Flavor) - 48usize];
    ["Offset of field: WSLDistributionInformation::Version"]
        [::std::mem::offset_of!(WSLDistributionInformation, Version) - 56usize];
};
#[repr(C)]
pub struct WslOfflineDistributionInformation {
    #[doc = " Distribution ID, guaranteed to be the same accross reboots"]
    pub Id: GUID,
    pub Name: LPCWSTR,
    #[doc = " Package family name, or NULL if none"]
    pub PackageFamilyName: LPCWSTR,
    #[doc = " Type of distribution (ubuntu, debian, ...), introduced in TODO"]
    pub Flavor: LPCWSTR,
    #[doc = " Distribution version, introduced in TODO"]
    pub Version: LPCWSTR,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
    ["Size of WslOfflineDistributionInformation"]
        [::std::mem::size_of::<WslOfflineDistributionInformation>() - 48usize];
    ["Alignment of WslOfflineDistributionInformation"]
        [::std::mem::align_of::<WslOfflineDistributionInformation>() - 8usize];
    ["Offset of field: WslOfflineDistributionInformation::Id"]
        [::std::mem::offset_of!(WslOfflineDistributionInformation, Id) - 0usize];
    ["Offset of field: WslOfflineDistributionInformation::Name"]
        [::std::mem::offset_of!(WslOfflineDistributionInformation, Name) - 16usize];
    ["Offset of field: WslOfflineDistributionInformation::PackageFamilyName"]
        [::std::mem::offset_of!(WslOfflineDistributionInformation, PackageFamilyName) - 24usize];
    ["Offset of field: WslOfflineDistributionInformation::Flavor"]
        [::std::mem::offset_of!(WslOfflineDistributionInformation, Flavor) - 32usize];
    ["Offset of field: WslOfflineDistributionInformation::Version"]
        [::std::mem::offset_of!(WslOfflineDistributionInformation, Version) - 40usize];
};
#[doc = " Create plan9 mount between Windows & Linux"]
pub type WSLPluginAPI_MountFolder = ::std::option::Option<
    unsafe extern "C" fn(
        Session: WSLSessionId,
        WindowsPath: LPCWSTR,
        LinuxPath: LPCWSTR,
        ReadOnly: BOOL,
        Name: LPCWSTR,
    ) -> HRESULT,
>;
#[doc = " Execute a program in the root namespace.\n On success, 'Socket' is connected to stdin & stdout (stderr goes to dmesg) // 'Arguments' is expected to be NULL terminated"]
pub type WSLPluginAPI_ExecuteBinary = ::std::option::Option<
    unsafe extern "C" fn(
        Session: WSLSessionId,
        Path: LPCSTR,
        Arguments: *mut LPCSTR,
        Socket: *mut SOCKET,
    ) -> HRESULT,
>;
#[doc = " Execute a program in a user distribution\n On success, 'Socket' is connected to stdin & stdout (stderr goes to dmesg) // 'Arguments' is expected to be NULL terminated"]
pub type WSLPluginAPI_ExecuteBinaryInDistribution = ::std::option::Option<
    unsafe extern "C" fn(
        Session: WSLSessionId,
        Distribution: *const GUID,
        Path: LPCSTR,
        Arguments: *mut LPCSTR,
        Socket: *mut SOCKET,
    ) -> HRESULT,
>;
#[doc = " Set the error message to display to the user if the VM or distribution creation fails.\n Must be called synchronously in either OnVMStarted() or OnDistributionStarted()."]
pub type WSLPluginAPI_PluginError =
    ::std::option::Option<unsafe extern "C" fn(UserMessage: LPCWSTR) -> HRESULT>;
#[doc = " Called when the VM has started.\n 'Session' and 'UserSettings' are only valid during while the call is in progress."]
pub type WSLPluginAPI_OnVMStarted = ::std::option::Option<
    unsafe extern "C" fn(
        Session: *const WSLSessionInformation,
        UserSettings: *const WSLVmCreationSettings,
    ) -> HRESULT,
>;
#[doc = " Called when the VM is about to stop.\n 'Session' is only valid during while the call is in progress."]
pub type WSLPluginAPI_OnVMStopping =
    ::std::option::Option<unsafe extern "C" fn(Session: *const WSLSessionInformation) -> HRESULT>;
#[doc = " Called when a distribution has started.\n 'Session' and 'Distribution' is only valid during while the call is in progress."]
pub type WSLPluginAPI_OnDistributionStarted = ::std::option::Option<
    unsafe extern "C" fn(
        Session: *const WSLSessionInformation,
        Distribution: *const WSLDistributionInformation,
    ) -> HRESULT,
>;
#[doc = " Called when a distribution is about to stop.\n 'Session' and 'Distribution' is only valid during while the call is in progress.\n Note: It's possible that stopping a distribution fails (for instance if a file is in use).\n In this case, it's possible for this notification to be called multiple times for the same distribution."]
pub type WSLPluginAPI_OnDistributionStopping = ::std::option::Option<
    unsafe extern "C" fn(
        Session: *const WSLSessionInformation,
        Distribution: *const WSLDistributionInformation,
    ) -> HRESULT,
>;
#[doc = " Called when a distribution is registered or unregisteed.\n Returning failure will NOT cause the operation to fail."]
pub type WSLPluginAPI_OnDistributionRegistered = ::std::option::Option<
    unsafe extern "C" fn(
        Session: *const WSLSessionInformation,
        Distribution: *const WslOfflineDistributionInformation,
    ) -> HRESULT,
>;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "hooks-field-names", derive(FieldNamesAsSlice))]
pub struct WSLPluginHooksV1 {
    pub OnVMStarted: WSLPluginAPI_OnVMStarted,
    pub OnVMStopping: WSLPluginAPI_OnVMStopping,
    pub OnDistributionStarted: WSLPluginAPI_OnDistributionStarted,
    pub OnDistributionStopping: WSLPluginAPI_OnDistributionStopping,
    #[doc = " Introduced in 2.1.2"]
    pub OnDistributionRegistered: WSLPluginAPI_OnDistributionRegistered,
    #[doc = " Introduced in 2.1.2"]
    pub OnDistributionUnregistered: WSLPluginAPI_OnDistributionRegistered,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
    ["Size of WSLPluginHooksV1"][::std::mem::size_of::<WSLPluginHooksV1>() - 48usize];
    ["Alignment of WSLPluginHooksV1"][::std::mem::align_of::<WSLPluginHooksV1>() - 8usize];
    ["Offset of field: WSLPluginHooksV1::OnVMStarted"]
        [::std::mem::offset_of!(WSLPluginHooksV1, OnVMStarted) - 0usize];
    ["Offset of field: WSLPluginHooksV1::OnVMStopping"]
        [::std::mem::offset_of!(WSLPluginHooksV1, OnVMStopping) - 8usize];
    ["Offset of field: WSLPluginHooksV1::OnDistributionStarted"]
        [::std::mem::offset_of!(WSLPluginHooksV1, OnDistributionStarted) - 16usize];
    ["Offset of field: WSLPluginHooksV1::OnDistributionStopping"]
        [::std::mem::offset_of!(WSLPluginHooksV1, OnDistributionStopping) - 24usize];
    ["Offset of field: WSLPluginHooksV1::OnDistributionRegistered"]
        [::std::mem::offset_of!(WSLPluginHooksV1, OnDistributionRegistered) - 32usize];
    ["Offset of field: WSLPluginHooksV1::OnDistributionUnregistered"]
        [::std::mem::offset_of!(WSLPluginHooksV1, OnDistributionUnregistered) - 40usize];
};
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct WSLPluginAPIV1 {
    pub Version: WSLVersion,
    pub MountFolder: WSLPluginAPI_MountFolder,
    pub ExecuteBinary: WSLPluginAPI_ExecuteBinary,
    pub PluginError: WSLPluginAPI_PluginError,
    #[doc = " Introduced in 2.1.2"]
    pub ExecuteBinaryInDistribution: WSLPluginAPI_ExecuteBinaryInDistribution,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
    ["Size of WSLPluginAPIV1"][::std::mem::size_of::<WSLPluginAPIV1>() - 48usize];
    ["Alignment of WSLPluginAPIV1"][::std::mem::align_of::<WSLPluginAPIV1>() - 8usize];
    ["Offset of field: WSLPluginAPIV1::Version"]
        [::std::mem::offset_of!(WSLPluginAPIV1, Version) - 0usize];
    ["Offset of field: WSLPluginAPIV1::MountFolder"]
        [::std::mem::offset_of!(WSLPluginAPIV1, MountFolder) - 16usize];
    ["Offset of field: WSLPluginAPIV1::ExecuteBinary"]
        [::std::mem::offset_of!(WSLPluginAPIV1, ExecuteBinary) - 24usize];
    ["Offset of field: WSLPluginAPIV1::PluginError"]
        [::std::mem::offset_of!(WSLPluginAPIV1, PluginError) - 32usize];
    ["Offset of field: WSLPluginAPIV1::ExecuteBinaryInDistribution"]
        [::std::mem::offset_of!(WSLPluginAPIV1, ExecuteBinaryInDistribution) - 40usize];
};
pub type WSLPluginAPI_EntryPointV1 = ::std::option::Option<
    unsafe extern "C" fn(Api: *const WSLPluginAPIV1, Hooks: *mut WSLPluginHooksV1) -> HRESULT,
>;