1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-29 10:59:02 +00:00

Print error message when -e fails on Windows. Closes #527. Fixes #111

This commit is contained in:
dmiller
2016-08-30 12:12:58 +00:00
parent da8d868a9e
commit c82915cb71

View File

@@ -311,8 +311,20 @@ static int run_command_redirected(char *cmdexec, struct subprocess_info *info)
memset(&pi, 0, sizeof(pi));
if (CreateProcess(NULL, cmdexec, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi) == 0) {
if (o.verbose)
logdebug("Error in CreateProcess: %d\n", GetLastError());
if (o.verbose) {
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&lpMsgBuf,
0, NULL);
logdebug("Error in CreateProcess: %s\nCommand was: %s\n", (lpMsgBuf), cmdexec);
}
CloseHandle(info->child_in_r);
CloseHandle(info->child_in_w);
CloseHandle(info->child_out_r);