2 * Set OPENSSL_MODULES to .exe's directory and run real .exe
4 * Copyright (C) 2002,2010,2014,2024 Olly Betts
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 wWinMain(HINSTANCE hInst
, HINSTANCE hPrevInst
, LPWSTR lpCmdLine
, int nCmdShow
)
30 (void)hInst
; /* suppress compiler warning */
31 (void)hPrevInst
; /* suppress compiler warning */
34 buf
= realloc(buf
, len
* sizeof(wchar_t));
36 got
= GetModuleFileNameW(NULL
, buf
, len
);
38 /* Strange Microsoft nastiness - skip prefix "\\?\" if present. */
39 if (wcsncmp(buf
, L
"\\\\?\\", 4) == 0) {
43 wchar_t *p
= wcsrchr(buf
, L
'\\');
52 wchar_t *e
= malloc((e_len
+ strlen("OPENSSL_MODULES=") + 1) * sizeof(wchar_t));
54 wcscpy(e
, L
"OPENSSL_MODULES=");
55 memcpy(e
+ strlen("OPENSSL_MODULES="), e_val
, e_len
* sizeof(wchar_t));
56 e
[strlen("OPENSSL_MODULES=") + e_len
] = L
'\0';
63 /* ShellExecute returns an HINSTANCE for some strange reason - the docs say
64 * the only valid operation is to convert it to "INT_PTR" (which seems to
65 * actually be an integer type. Marvellous. */
66 if ((INT_PTR
)ShellExecuteW(NULL
, NULL
, buf
, lpCmdLine
, NULL
, nCmdShow
) <= 32) {