win32
win32 copied to clipboard
CreateProcess does not exist?
Hello,
I'm working on a small debugger for windows which means I need to pass creation flags that I cannot pass with the process
library. I found it strange that there is no binding for that function in Win32. Even more, as there is DebugApi which seems to me that it can only be used on an already started process.
Yotam
Hi Yotam,
CreateProcess
isn't here mostly because it's a very extensive API to make bindings for. It's inputs can get quite deeply nested and it's available arguments spread out over different includes.
Win32
also does not impose a minimum Windows version, as such it's difficult to determine which inputs (enum values etc) are valid for it.
Is there a particular reason you can't call the function from C and expose a simplified interface to your Haskell code via foreign imports? That's how most programs requiring non-standard process creation options do it.
Thanks for the reply. I haven't thought about creating a simplified C code or seen anywhere that this is the best option in such cases. I'll do that. If you have any advice on how to handle the C library inside a stack project that would be appreciated.
I also would strongly recommend avoiding exposing CreateProcess at all. Instead, explicitly bind to CreateProcessW (Unicode version), and maybe CreateProcessA (ANSI version). (the win32 package does seem to only expose the Unicode versions anyway, something that technically inverts the default behavior of the native APIs, since, if, for example, you call only CreateProcess, Windows will treat that as a call to CreateProcessA, and never as a call to CreateProcessW.)
...you might also want to know that Windows also has ZwCreateProcess & NtCreateProcess. :) (I don't think there exist [Zw/Nt]CreateProcess[A/W], however. Not sure tho.)