question

YuweiBa-3096 avatar image
0 Votes"
YuweiBa-3096 asked RLWA32-6355 edited

windows-rs CreateProcessW with EXTENDED_STARTUPINFO_PRESENT

I'm using the Rust binding windows-rs to call Win32 APIs to create processes with ConPty.

However the CreateProcessW can only run "some" programs, for example, "notepad.exe",

If I ran "cmd.exe", "powershell.exe", "ping.exe", the program won't start and exit with code: exitcode: 3221225794.

I have a repro at: https://github.com/ibigbug/windows-rs-CreateProcessW

To run different programs, change https://github.com/ibigbug/windows-rs-CreateProcessW/blob/9ba54f27fdbefd07aa8fd03fed96373aeca046f6/src/main.rs#L131

and "cargo r"

related Github issue: https://github.com/microsoft/windows-rs/issues/1121

windows-api-general
· 7
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

There is a Microsoft sample that uses pseudoconsoles with ping.exe at https://github.com/microsoft/terminal/tree/main/samples/ConPTY/EchoCon.

You might want to try converting that to use the Rust binding as a test of your work.


0 Votes 0 ·

Thanks for the reply

If you read the related Github Issue before writing you'll see this is what I'm doing.

I have no problem using the APIs as I mentioned it does work with "notepad.exe".

My question is why is "ping.exe" not working ?

0 Votes 0 ·

Notepad is a windows desktop application (gui application) and does not use any console input/output.

0 Votes 0 ·
Show more comments

Sample doesn't compile:

thread::spawn(move || loop {
             ------- value moved into closure here
   let mut buffer = [0u8; 1024];
   match file_out.read(&mut buffer) {
         -------- variable moved due to use in closure

thread::spawn(move || loop {
             ^^^^^^^ value used here after move
   let mut buffer = [0u8; 1024];
   match file_out.read(&mut buffer) {
         -------- use occurs due to use in closure



0 Votes 0 ·

Sorry fixed. I added a dup code section in from copy&paste

0 Votes 0 ·

0 Answers