CreateProcess return code 1 however Process does not start
-
Hi, I am getting back a 1 from CreateProcess indicting success however the process never takes off I can cann't find it in TaskManager Either Here is the code this code used to work I just cleaned up my computer tried re-building the app
strncpy(&herc_command[0],"HERC_CMD.EXE ",13);
memset(&si,0,sizeof(si)); si.cb= sizeof(si); sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; // Hercmd will inherit this event hutil\_module = GetModuleHandle("HENGINE"); hercgui\_addr = GetProcAddress(hutil\_module,"hercgui\_proc"); if (hercgui\_addr == NULL) errcd = GetLastError(); strncpy(&herc\_parm\[0\],&hercgui\_addr,8); return\_code = CreateProcess((LPCSTR) &herc\_command\[0\], // command (LPCSTR) &herc\_parm\[0\], // paramter (LPCSTR) &sa, NULL, TRUE, (DWORD) NULL, NULL, NULL, &si, &pi); if (return\_code == 0 ) errcd = GetLastError();
Please ensure the target is not started, by adding some log in that process. If process terminates as soon as the startup, then TaskManager cant show it. Please check the values of returned PROCESS_INFORMATION structure. Process ID is avaialable in pi.dwProcessId.
return_code = CreateProcess((LPCSTR) &herc_command[0], // command
(LPCSTR) &herc_parm[0], // paramter
(LPCSTR) &sa,
NULL,
TRUE,
(DWORD) NULL,
NULL,
NULL,
&si,
&pi);Is third parameter is correct? Conversion to a string is not correct.
-
Please ensure the target is not started, by adding some log in that process. If process terminates as soon as the startup, then TaskManager cant show it. Please check the values of returned PROCESS_INFORMATION structure. Process ID is avaialable in pi.dwProcessId.
return_code = CreateProcess((LPCSTR) &herc_command[0], // command
(LPCSTR) &herc_parm[0], // paramter
(LPCSTR) &sa,
NULL,
TRUE,
(DWORD) NULL,
NULL,
NULL,
&si,
&pi);Is third parameter is correct? Conversion to a string is not correct.
-
Hi, I am getting back a 1 from CreateProcess indicting success however the process never takes off I can cann't find it in TaskManager Either Here is the code this code used to work I just cleaned up my computer tried re-building the app
strncpy(&herc_command[0],"HERC_CMD.EXE ",13);
memset(&si,0,sizeof(si)); si.cb= sizeof(si); sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; // Hercmd will inherit this event hutil\_module = GetModuleHandle("HENGINE"); hercgui\_addr = GetProcAddress(hutil\_module,"hercgui\_proc"); if (hercgui\_addr == NULL) errcd = GetLastError(); strncpy(&herc\_parm\[0\],&hercgui\_addr,8); return\_code = CreateProcess((LPCSTR) &herc\_command\[0\], // command (LPCSTR) &herc\_parm\[0\], // paramter (LPCSTR) &sa, NULL, TRUE, (DWORD) NULL, NULL, NULL, &si, &pi); if (return\_code == 0 ) errcd = GetLastError();
Since CreateProcess() returns before the process has been fully initialized (e.g., waiting on some other DLL to load), it would have no way of knowing that. It goes ahead and returns a non-zero value because it did start the process.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
Since CreateProcess() returns before the process has been fully initialized (e.g., waiting on some other DLL to load), it would have no way of knowing that. It goes ahead and returns a non-zero value because it did start the process.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
Since CWinApp::CWinApp is the first piece of executable code as far as I am concerned I would set a breakpoint e.g. (__debugbreak) at that location if it doesn't get there where else would I look ? Thanks
I dont't think the target process will be started under the debugger by the host process. There are three possible things I can think of testing. First, in the project settings of the target app enter the same parameters you would recieve from the host process. Then start debugging and see if the app starts or if it aborts as well. Second, try starting another process, e.g. cmd.exe, from the host process to check if this works at all. Third, use as little parameters as possible and possibly log (or check in debugger) the values before passing them to the CreateProcess() call to see if they really are what you expect them to be.
-
I dont't think the target process will be started under the debugger by the host process. There are three possible things I can think of testing. First, in the project settings of the target app enter the same parameters you would recieve from the host process. Then start debugging and see if the app starts or if it aborts as well. Second, try starting another process, e.g. cmd.exe, from the host process to check if this works at all. Third, use as little parameters as possible and possibly log (or check in debugger) the values before passing them to the CreateProcess() call to see if they really are what you expect them to be.
I tried entering the .exe on cmd.exe and it just returned, next I tried starting it from Task Manager and it and I saw it pop up for a second , tried to debug it and got invalid handle as it disappeared My guess I have a CWinApp to start things off and some how I didn't build it as a MFC project On my property pages -> Project Default USE of MFC -> USe MFC as Shared DLL maybe its something else in my project settings Any Ideas are welcome
-
I tried entering the .exe on cmd.exe and it just returned, next I tried starting it from Task Manager and it and I saw it pop up for a second , tried to debug it and got invalid handle as it disappeared My guess I have a CWinApp to start things off and some how I didn't build it as a MFC project On my property pages -> Project Default USE of MFC -> USe MFC as Shared DLL maybe its something else in my project settings Any Ideas are welcome
ForNow wrote:
I tried entering the .exe on cmd.exe and it just returned...
Is it a dialog-based app, or some other app that has a doc/view?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
ForNow wrote:
I tried entering the .exe on cmd.exe and it just returned...
Is it a dialog-based app, or some other app that has a doc/view?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
ForNow wrote:
It has a MainWindow CFrameWnd
SDI or MDI?
ForNow wrote:
Something about the way I build it I think
That's kind of what I was leaning towards. If it was a dialog-based app, I was going to suggest to you to use the
DS_NOFAILCREATE
style."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
ForNow wrote:
It has a MainWindow CFrameWnd
SDI or MDI?
ForNow wrote:
Something about the way I build it I think
That's kind of what I was leaning towards. If it was a dialog-based app, I was going to suggest to you to use the
DS_NOFAILCREATE
style."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous