mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-02-07 23:59:36 +08:00
support npcap non-compatiable mode
This commit is contained in:
parent
f7166bfde3
commit
f1e18d4583
@ -40,10 +40,42 @@ struct init_pcap_t
|
||||
|
||||
}do_it;
|
||||
|
||||
static void init_npcap_dll_path()
|
||||
{
|
||||
BOOL(WINAPI *SetDllDirectory)(LPCTSTR);
|
||||
char sysdir_name[512];
|
||||
int len;
|
||||
|
||||
SetDllDirectory = (BOOL(WINAPI *)(LPCTSTR)) GetProcAddress(GetModuleHandle("kernel32.dll"), "SetDllDirectoryA");
|
||||
if (SetDllDirectory == NULL) {
|
||||
printf("Error in SetDllDirectory");
|
||||
}
|
||||
else {
|
||||
len = GetSystemDirectory(sysdir_name, 480); // be safe
|
||||
if (!len)
|
||||
printf("Error in GetSystemDirectory (%d)", (int)GetLastError());
|
||||
strcat(sysdir_name, "\\Npcap");
|
||||
if (SetDllDirectory(sysdir_name) == 0)
|
||||
printf("Error in SetDllDirectory(\"System32\\Npcap\")");
|
||||
}
|
||||
}
|
||||
|
||||
#define EXPORT_FUN(XXX) do{ XXX= (__typeof__(XXX)) GetProcAddress(wpcap, #XXX); }while(0)
|
||||
int init_pcap()
|
||||
{
|
||||
HMODULE wpcap=LoadLibrary("wpcap.dll");
|
||||
if(wpcap!=0)
|
||||
{
|
||||
printf("using system32/wpcap.dll\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
init_npcap_dll_path();
|
||||
//SetDllDirectory("C:\\Windows\\System32\\Npcap\\");
|
||||
wpcap=LoadLibrary("wpcap.dll");
|
||||
if(wpcap!=0)
|
||||
printf("using system32/npcap/wpcap.dll\n");
|
||||
}
|
||||
if(wpcap==0)
|
||||
{
|
||||
printf("cant not open wpcap.dll, make sure winpcap/npcap is installed\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user