Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdffe2ea

Browse files
committed
Made WinDump use Npcap when Npcap and WinPcap coexist.
There are two steps:1) Add "wpcap.dll" to the "DelayLoadDLLs" of the project file.2) Call init_npcap_dll_path() before you use any wpcap.dll functions, the beginning of the main() function is a good place.
1 parentbb60861 commitdffe2ea

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

‎Tcpdump.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,26 @@ static int tcpdump_printf(netdissect_options *ndo _U_,
443443
returnret;
444444
}
445445

446+
staticvoidinit_npcap_dll_path()
447+
{
448+
BOOL(WINAPI*SetDllDirectory)(LPCTSTR);
449+
charsysdir_name[512];
450+
intlen;
451+
452+
SetDllDirectory= (BOOL(WINAPI*)(LPCTSTR))GetProcAddress(GetModuleHandle("kernel32.dll"),"SetDllDirectoryA");
453+
if (SetDllDirectory==NULL) {
454+
error("Error in SetDllDirectory");
455+
}
456+
else {
457+
len=GetSystemDirectory(sysdir_name,480);//be safe
458+
if (!len)
459+
error("Error in GetSystemDirectory (%d)",GetLastError());
460+
strcat(sysdir_name,"\\Npcap");
461+
if (SetDllDirectory(sysdir_name)==0)
462+
error("Error in SetDllDirectory(\"System32\\Npcap\")");
463+
}
464+
}
465+
446466
int
447467
main(intargc,char**argv)
448468
{
@@ -466,6 +486,9 @@ main(int argc, char **argv)
466486
intdevnum;
467487
#endif
468488
intstatus;
489+
490+
init_npcap_dll_path();
491+
469492
#ifdefWIN32
470493
u_intUserBufferSize=1000000;
471494
if(wsockinit()!=0)return1;

‎win32/prj/WinDump.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
<DataExecutionPrevention>
136136
</DataExecutionPrevention>
137137
<TargetMachine>MachineX86</TargetMachine>
138+
<DelayLoadDLLs>wpcap.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
138139
</Link>
139140
<Bscmake>
140141
<SuppressStartupBanner>true</SuppressStartupBanner>
@@ -176,6 +177,7 @@
176177
<DataExecutionPrevention>
177178
</DataExecutionPrevention>
178179
<TargetMachine>MachineX86</TargetMachine>
180+
<DelayLoadDLLs>wpcap.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
179181
</Link>
180182
<Bscmake>
181183
<SuppressStartupBanner>true</SuppressStartupBanner>
@@ -221,6 +223,7 @@
221223
<DataExecutionPrevention>
222224
</DataExecutionPrevention>
223225
<TargetMachine>MachineX64</TargetMachine>
226+
<DelayLoadDLLs>wpcap.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
224227
</Link>
225228
<Bscmake>
226229
<SuppressStartupBanner>true</SuppressStartupBanner>
@@ -263,6 +266,7 @@
263266
<DataExecutionPrevention>
264267
</DataExecutionPrevention>
265268
<TargetMachine>MachineX64</TargetMachine>
269+
<DelayLoadDLLs>wpcap.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
266270
</Link>
267271
<Bscmake>
268272
<SuppressStartupBanner>true</SuppressStartupBanner>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp