I have an .exe
that on it's own it "runs" normally, no errors. I call it with CreateProcess()
and I call WaitForSingleObject()
to know when it has finished, and when WaitForSingleObject()
gets called the "child" process crushes.
The code:
#include <iostream>
#include <windows.h>
using namespace std;
int main() {
STARTUPINFOA info;
PROCESS_INFORMATION processInfo;
ZeroMemory(&info, sizeof(info));
info.cb = sizeof(info);
ZeroMemory(&processInfo, sizeof(processInfo));
char path[] = "C:/.../ExeName.exe";
if (CreateProcessA(path, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &info, &processInfo)) {
WaitForSingleObject(processInfo.hProcess, INFINITE);
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}
else {
cout << "Fail";
}
return 0;
}
The called .exe
reads from a file, does some(light I would say) calculations and heap allocation, without printing anything and then it writes the results in another file. If it can't find the files it creates them, I tried copying the file it will read from, to where the calling .exe
is, but nothing changed.
char path[]
is initialized or does it reveal some secrets? Change the parts that you want to hide if they contain anything sensitive. – Ted Lyngmo Mar 8 at 14:35