Skip to content

How to use LPPROC_THREAD_ATTRIBUTE_LIST? #771

Closed
@ibigbug

Description

@ibigbug

Basically I want to translate this from C# into Rust: https://github.com/microsoft/terminal/blob/2559ed6efa05cb8f999fbf0b8d890ec81161220a/samples/ConPTY/GUIConsole/GUIConsole.ConPTY/Processes/ProcessFactory.cs#L44

I was able to do this to get the lpSize:

InitializeProcThreadAttributeList(LPPROC_THREAD_ATTRIBUTE_LIST: NULL, 1, 0, &mut lpSize);

However I need to manually alloc the memory for LPPROC_THREAD_ATTRIBUTE_LIST with a fixed size and pass the memory to InitializeProcThreadAttributeList again. this is what I'm doing:

  let mut start_info: STARTUPINFOEXW = { mem::zeroed() };
  start_info.StartupInfo.cb = mem::size_of::<STARTUPINFOEXW>() as u32;
  let mut lpAttributeList: Box<[u8]> = vec![0; lpSize].into_boxed_slice();
  start_info.lpAttributeList = &mut *lpAttributeList;   // this line doesn't work

However it doesn't allow me to do the above:

error[E0308]: mismatched types
  --> terminal\src\windows\process.rs:57:34
   |
57 |     start_info.lpAttributeList = &mut *lpAttributeList;
   |                                  ^^^^^^^^^^^^^^^^^^^^^ expected struct `terminal::process::bindings::Windows::Win32::SystemServices::LPPROC_THREAD_ATTRIBUTE_LIST`, found `&mut [u8]`

I feel this is kind of more like a Rust question, thought would be great to get some help here :)

thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions