diff --git a/ncat/ncat.vcxproj b/ncat/ncat.vcxproj index 185c9338c..fc44dfa59 100644 --- a/ncat/ncat.vcxproj +++ b/ncat/ncat.vcxproj @@ -213,7 +213,6 @@ - diff --git a/ncat/util.c b/ncat/util.c index f2eb63e31..fd845b2ba 100644 --- a/ncat/util.c +++ b/ncat/util.c @@ -235,7 +235,18 @@ void logtest(const char *fmt, ...) /* Exit status 2 indicates a program error other than a network error. */ void die(char *err) { +#ifdef WIN32 + int error_number; + char *strerror_s; + error_number = GetLastError(); + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error_number, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR) &strerror_s, 0, NULL); + fprintf(stderr, "%s: %s\n", err, strerror_s); + HeapFree(GetProcessHeap(), 0, strerror_s); +#else perror(err); +#endif fflush(stderr); exit(2); }