Skip to content

Commit

Permalink
[IMP] Use SearchPath() to find file to execute.
Browse files Browse the repository at this point in the history
  • Loading branch information
redneck-f25 committed Sep 4, 2016
1 parent cad55d7 commit 37e04d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/x64
**~
/*.sdf
/*.VC.db
/*.VC.opendb
**/Debug/
**/Release/
9 changes: 3 additions & 6 deletions cSuRun/cSuRun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ int main()
wchar_t pipename[PIPENAME_LEN];
DWORD exitCode;
int nh = 0;
DWORD res;

GetModuleFileName(NULL, helper_bin, 2047);
pch = wcsrchr(helper_bin, L'.');
Expand All @@ -88,14 +89,10 @@ int main()
{
return 1;
}
if (!CreateProcess(NULL, application, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi))
{
res = SearchPath(NULL, application, L".exe", 2048, application_full, NULL);
if (res == 0 || res >= 2048) {
return 1;
}
GetModuleFileNameEx(pi.hProcess, NULL, application_full, 2047);
TerminateProcess(pi.hProcess, 0);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);

StringCchPrintf(surun_cmdline, 2048, CMDLINE_INVOKE_FMT,
helper_bin, GetCurrentProcessId(), application_full, commandLine);
Expand Down

0 comments on commit 37e04d2

Please sign in to comment.