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
1 changed files with 6 additions and 0 deletions

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) {
LPTSTR errormessage = NULL;
filter = WinDivertOpen(filter, WINDIVERT_LAYER_NETWORK, 0, flags);
if (filter != INVALID_HANDLE_VALUE)
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;
}