mirror of
https://github.com/bol-van/zapret.git
synced 2024-11-26 12:10:53 +03:00
Compare commits
3 Commits
da1226ceee
...
8a09df7097
Author | SHA1 | Date | |
---|---|---|---|
|
8a09df7097 | ||
|
1e8e46c14f | ||
|
a145fe73fe |
Binary file not shown.
Binary file not shown.
@ -959,6 +959,7 @@ void tcp_rewrite_winsize(struct tcphdr *tcp, uint16_t winsize, uint8_t scale_fac
|
||||
|
||||
static HANDLE w_filter = NULL;
|
||||
static OVERLAPPED ovl = { .hEvent = NULL };
|
||||
uint32_t w_win32_error=0;
|
||||
|
||||
static HANDLE windivert_init_filter(const char *filter, UINT64 flags)
|
||||
{
|
||||
@ -971,24 +972,25 @@ static HANDLE windivert_init_filter(const char *filter, UINT64 flags)
|
||||
hMutex = CreateMutexA(NULL,TRUE,mutex_name);
|
||||
if (hMutex && GetLastError()==ERROR_ALREADY_EXISTS)
|
||||
WaitForSingleObject(hMutex,INFINITE);
|
||||
|
||||
h = WinDivertOpen(filter, WINDIVERT_LAYER_NETWORK, 0, flags);
|
||||
w_win32_error = GetLastError();
|
||||
|
||||
if (hMutex)
|
||||
{
|
||||
ReleaseMutex(hMutex);
|
||||
CloseHandle(hMutex);
|
||||
SetLastError(w_win32_error);
|
||||
}
|
||||
|
||||
if (h != INVALID_HANDLE_VALUE) return h;
|
||||
|
||||
errorcode = GetLastError();
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, errorcode, MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), (LPTSTR)&errormessage, 0, NULL);
|
||||
NULL, w_win32_error, MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), (LPTSTR)&errormessage, 0, NULL);
|
||||
fprintf(stderr, "windivert: error opening filter: %s", errormessage);
|
||||
LocalFree(errormessage);
|
||||
if (errorcode == 577)
|
||||
if (w_win32_error == ERROR_INVALID_IMAGE_HASH)
|
||||
fprintf(stderr,"windivert: try to disable secure boot and install OS patches\n");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
void rawsend_cleanup(void)
|
||||
@ -1014,6 +1016,7 @@ bool windivert_init(const char *filter)
|
||||
ovl.hEvent = CreateEventW(NULL,FALSE,FALSE,NULL);
|
||||
if (!ovl.hEvent)
|
||||
{
|
||||
w_win32_error = GetLastError();
|
||||
rawsend_cleanup();
|
||||
return false;
|
||||
}
|
||||
@ -1041,8 +1044,8 @@ static bool windivert_recv_filter(HANDLE hFilter, uint8_t *packet, size_t *len,
|
||||
}
|
||||
for(;;)
|
||||
{
|
||||
err = GetLastError();
|
||||
switch(err)
|
||||
w_win32_error = GetLastError();
|
||||
switch(w_win32_error)
|
||||
{
|
||||
case ERROR_IO_PENDING:
|
||||
// make signals working
|
||||
@ -1079,7 +1082,9 @@ bool windivert_recv(uint8_t *packet, size_t *len, WINDIVERT_ADDRESS *wa)
|
||||
|
||||
static bool windivert_send_filter(HANDLE hFilter, const uint8_t *packet, size_t len, const WINDIVERT_ADDRESS *wa)
|
||||
{
|
||||
return WinDivertSend(hFilter,packet,(UINT)len,NULL,wa);
|
||||
bool b = WinDivertSend(hFilter,packet,(UINT)len,NULL,wa);
|
||||
w_win32_error = GetLastError();
|
||||
return b;
|
||||
}
|
||||
bool windivert_send(const uint8_t *packet, size_t len, const WINDIVERT_ADDRESS *wa)
|
||||
{
|
||||
|
@ -149,6 +149,8 @@ uint8_t tcp_find_scale_factor(const struct tcphdr *tcp);
|
||||
bool tcp_has_fastopen(const struct tcphdr *tcp);
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
extern uint32_t w_win32_error;
|
||||
|
||||
bool windivert_init(const char *filter);
|
||||
bool windivert_recv(uint8_t *packet, size_t *len, WINDIVERT_ADDRESS *wa);
|
||||
bool windivert_send(const uint8_t *packet, size_t len, const WINDIVERT_ADDRESS *wa);
|
||||
|
@ -411,7 +411,7 @@ static int win_main(const char *windivert_filter)
|
||||
char ifout[22];
|
||||
|
||||
if (!windivert_init(windivert_filter))
|
||||
return 1;
|
||||
return w_win32_error;
|
||||
|
||||
printf("windivert initialized. capture is started.\n");
|
||||
|
||||
@ -433,7 +433,7 @@ static int win_main(const char *windivert_filter)
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, "windivert: recv failed. errno %d\n", errno);
|
||||
break;
|
||||
return w_win32_error;
|
||||
}
|
||||
*ifout=0;
|
||||
if (wa.Outbound) snprintf(ifout,sizeof(ifout),"%u.%u", wa.Network.IfIdx, wa.Network.SubIfIdx);
|
||||
|
Loading…
Reference in New Issue
Block a user