librz/util/subprocess: fix inability to automatically run .com executables (#5312)
This commit is contained in:
parent
f15589d3cf
commit
faf3c53168
1 changed files with 7 additions and 6 deletions
|
|
@ -262,7 +262,6 @@ RZ_API RZ_OWN RzSubprocess *rz_subprocess_start_opt(RZ_NONNULL const RzSubproces
|
|||
HANDLE stdin_read = curr_stdin_handle;
|
||||
HANDLE stdout_write = curr_stdout_handle;
|
||||
HANDLE stderr_write = curr_stderr_handle;
|
||||
LPWSTR lpFilePart;
|
||||
PWCHAR cmd_exe = RZ_NEWS0(WCHAR, MAX_PATH);
|
||||
#if NTDDI_VERSION >= NTDDI_VISTA
|
||||
LPPROC_THREAD_ATTRIBUTE_LIST attr_list = NULL;
|
||||
|
|
@ -276,10 +275,12 @@ RZ_API RZ_OWN RzSubprocess *rz_subprocess_start_opt(RZ_NONNULL const RzSubproces
|
|||
|
||||
if (!rz_file_exists(opt->file)) {
|
||||
DWORD len;
|
||||
if ((len = SearchPathW(NULL, file, L".exe", MAX_PATH, cmd_exe, &lpFilePart)) < 1) {
|
||||
RZ_LOG_DEBUG("SearchPath failed for %s\n", opt->file);
|
||||
free(file);
|
||||
return NULL;
|
||||
if ((len = SearchPathW(NULL, file, L".exe", MAX_PATH, cmd_exe, NULL)) < 1) {
|
||||
if ((len = SearchPathW(NULL, file, L".com", MAX_PATH, cmd_exe, NULL)) < 1) {
|
||||
RZ_LOG_DEBUG("SearchPath failed for %s\n", opt->file);
|
||||
free(file);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (len > MAX_PATH) {
|
||||
PWCHAR tmp = realloc(cmd_exe, sizeof(WCHAR) * len);
|
||||
|
|
@ -289,7 +290,7 @@ RZ_API RZ_OWN RzSubprocess *rz_subprocess_start_opt(RZ_NONNULL const RzSubproces
|
|||
return NULL;
|
||||
}
|
||||
cmd_exe = tmp;
|
||||
SearchPathW(NULL, file, L".exe", len, cmd_exe, &lpFilePart);
|
||||
SearchPathW(NULL, file, L".exe", len, cmd_exe, NULL);
|
||||
}
|
||||
free(file);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue