Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Calling "C" FFI with variable sized structure
windows-rs has the following struct
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct TOKEN_PRIVILEGES {
pub PrivilegeCount: u32,
pub Privileges: [LUID_AND_ATTRIBUTES; 1]
}
I want to call the following function with newstate having three privileges
pub unsafe fn AdjustTokenPrivileges(tokenhandle: HANDLE, disableallprivileges: bool, newstate: Option<*const TOKEN_PRIVILEGES>, bufferlength: u32, previousstate: Option<*mut TOKEN_PRIVILEGES>, returnlength: Option<*mut u32>) -> windows_core::Result<()>
How do I create a TOKEN_PRIVILEGES with more than one Privileges (LUID_AND_ATTRIBUTES).
let token_privileges = TOKEN_PRIVILEGES {
PrivilegeCount: 3,
Privileges: /* Need to create a "C" style array of 3 elements of type LUID_AND_ATTRIBUTES */
}
Do I need to create a Vec<LUID_AND_ATTRIBUTES>
and somehow get a pointer to the contents? Maybe into_boxed_slice? How about for an arbitrary number of elements?
7 posts - 2 participants
🏷️ rust_feed