Print error message if filter initialization fails

This commit is contained in:
ValdikSS 2017-08-15 14:09:06 +03:00
parent 96fb5f9516
commit b74c974235

View File

@ -62,9 +62,15 @@ static char* dumb_memmem(const char* haystack, int hlen, const char* needle, int
} }
static HANDLE init(char *filter, UINT64 flags) { static HANDLE init(char *filter, UINT64 flags) {
LPTSTR errormessage = NULL;
filter = WinDivertOpen(filter, WINDIVERT_LAYER_NETWORK, 0, flags); filter = WinDivertOpen(filter, WINDIVERT_LAYER_NETWORK, 0, flags);
if (filter != INVALID_HANDLE_VALUE) if (filter != INVALID_HANDLE_VALUE)
return filter; return filter;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(), MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
(LPTSTR)&errormessage, 0, NULL);
printf("%s", errormessage);
return NULL; return NULL;
} }