Skip to content

Commit

Permalink
Replace last char of wrapped exe name with _
Browse files Browse the repository at this point in the history
  • Loading branch information
ojwb committed Dec 23, 2024
1 parent 375ea58 commit 80a4d29
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions src/wrapmsw.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
buf = realloc(buf, len * sizeof(wchar_t));
if (!buf) exit(1);
got = GetModuleFileNameW(NULL, buf, len);
if (got + 1 < len) {
if (got < len) {
/* Strange Microsoft nastiness - skip prefix "\\?\" if present. */
if (wcsncmp(buf, L"\\\\?\\", 4) == 0) {
buf += 4;
Expand All @@ -59,17 +59,23 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
e[strlen("OPENSSL_MODULES=") + e_len] = L'\0';
printf("setenv %ls\n", e);
_wputenv(e);
wcscpy(buf + got - 4, L"_.exe");
buf[got - 5] = L'_';
printf("command %ls\n", buf);
break;
}
len += len;
}
cmd_line = GetCommandLineW();
wchar_t *c = malloc(wcslen(cmd_line) + 1);
if (!c) exit(1);
wcscpy(c, cmd_line);
wchar_t *p = wcsstr(c, L".exe");
if (!p) exit(1);
p[-1] = '_';
/* ShellExecute returns an HINSTANCE for some strange reason - the docs say
* the only valid operation is to convert it to "INT_PTR" (which seems to
* actually be an integer type. Marvellous. */
if ((INT_PTR)ShellExecuteW(NULL, NULL, buf, cmd_line, NULL, nCmdShow) <= 32) {
if ((INT_PTR)ShellExecuteW(NULL, NULL, buf, c, NULL, nCmdShow) <= 32) {
return 1;
}
return 0;
Expand Down
6 changes: 3 additions & 3 deletions survex.iss.in
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ Type: files; Name: "{app}\cad3d.exe"

[Files]
Source: "*.exe"; Excludes: "wrapmsw.exe,aven.exe,survexport.exe"; DestDir: "{app}"
; Install aven.exe as aven_.exe and survexport.exe as survexport_.exe.
Source: "aven.exe"; DestDir: "{app}"; DestName: "aven_.exe"
Source: "survexport.exe"; DestDir: "{app}"; DestName: "survexport_.exe"
; Install aven.exe as ave_.exe and survexport.exe as survexpor_.exe.
Source: "aven.exe"; DestDir: "{app}"; DestName: "ave_.exe"
Source: "survexport.exe"; DestDir: "{app}"; DestName: "survexpor_.exe"
; Install wrapmsw.exe as aven.exe and survexport.exe.
Source: "wrapmsw.exe"; DestDir: "{app}"; DestName: "aven.exe"
Source: "wrapmsw.exe"; DestDir: "{app}"; DestName: "survexport.exe"
Expand Down

0 comments on commit 80a4d29

Please sign in to comment.