Can I add breakpoint on windows CreateProcess API in Visual studio like I can do in Windbg?
+6
A:
Yes - Go "Debug / New breakpoint / Break at function..." and paste this:
{,,kernel32.dll}_CreateProcessW@40
into the Function box.
That assumes a Unicode build - replace W
with A
for ANSI builds.
A bit of explanation: the @40
piece is part of the stdcall calling convention, and gives the number of bytes of parameters that the function takes. In win32, this is almost always 4 times the number of parameters.
A related note: sometimes the name of the function as seen by the debugger is different from its real name - see this blog post for an example, and how to find the right name to use: Setting a Visual Studio breakpoint on a Win32 API function in user32.dll
RichieHindle
2009-07-15 11:45:54
Better to break on both. Because of the funky non-const behavior of CreateProcessW, even Unicode applications might call CreateProcessA. The CreateProcess macro doesn't hide the underlying two function declarations so they remain callable. This also applies to similar macros for other function pairs.
MSalters
2009-07-15 14:38:57