CreateProcess with DEBUG_PROCESS flag causes error 50 on some executables
c++, createprocess, debugging, windows
Solution
You won't have much use for an unmanaged debugger to debug a managed executable. Check out the MDbg sample to see what that takes.
The ERROR_NOT_SUPPORTED error is however not exclusive to managed executables, although more likely, you'll also get it when you try to debug a 64-bit executable with a 32-bit debugger. Add the x64 platform target to your project to build a 64-bit version of it.
Problem
I am trying to write a small debugger. My simplified code is ``` STARTUPINFOA sui; ZeroMemory( &sui, sizeof(sui) ); sui.cb = sizeof(sui); PROCESS_INFORMATION pi; ZeroMemory( &pi, sizeof(pi) ); DWORD dwFlags = DEBUG_PROCESS; string program = "program.exe"; if (! CreateProcessA(NULL, (char*) program.c_str(), NULL, NULL, TRUE, dwFlags, NULL, NULL, &sui, &pi)) printf("%s failed. LastError = %d", program.c_str(), GetLastError()); ``` On a large amount of executables it works fine. But on C#-compiled executables this piece of code outputs "program.exe failed. LastError = 50". Error 50 is ERROR_NOT_SUPPORTED (http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx). What can be a reason of this? How I can debug all kind of binaries?