├── .github └── ISSUE_TEMPLATE │ └── bug_report.md ├── .gitignore ├── .gitmodules ├── CHANGELOG.md ├── Common ├── Packet32.h ├── WpcapNames.h ├── npcap-bpf.h └── npcap-defs.h ├── Examples-pcap ├── GNUmakefile ├── MakeAll.sln ├── UDPdump │ ├── GNUmakefile │ ├── UDPdump.vcxproj │ └── udpdump.c ├── basic_dump │ ├── GNUmakefile │ ├── basic_dump.c │ └── basic_dump.vcxproj ├── basic_dump_ex │ ├── GNUmakefile │ ├── basic_dump_ex.c │ └── basic_dump_ex.vcxproj ├── iflist │ ├── GNUmakefile │ ├── iflist.c │ └── iflist.vcxproj ├── pcap_filter │ ├── GNUmakefile │ ├── Makefile.unix │ ├── pcap_filter.c │ └── pcap_filter.vcxproj ├── pktdump_ex │ ├── GNUmakefile │ ├── pktdump_ex.c │ └── pktdump_ex.vcxproj ├── readfile │ ├── GNUmakefile │ ├── readfile.c │ └── readfile.vcxproj ├── readfile_ex │ ├── GNUmakefile │ ├── readfile_ex.c │ └── readfile_ex.vcxproj ├── savedump │ ├── GNUmakefile │ ├── savedump.c │ └── savedump.vcxproj ├── sendpack │ ├── GNUmakefile │ ├── sendpack.c │ └── sendpack.vcxproj ├── stats │ ├── stats.c │ └── stats.vcxproj └── winpcap_stress │ ├── winpcap_stress.c │ └── winpcap_stress.vcxproj ├── Examples ├── MakeAll.sln ├── NETMETER │ ├── CapDll.h │ ├── CaptureThread.cpp │ ├── Console.h │ ├── LineColl.cpp │ ├── LineColl.h │ ├── MainFrm.cpp │ ├── MainFrm.h │ ├── NETMETER.CPP │ ├── NETMETER.H │ ├── NetMeter.vcxproj │ ├── NetMeter.vcxproj.filters │ ├── ProgCaptDlg.h │ ├── SelectAdapter.cpp │ ├── SelectAdapter.h │ ├── StdAfx.cpp │ ├── StdAfx.h │ ├── netmeter.rc │ ├── netmeterDoc.cpp │ ├── netmeterDoc.h │ ├── netmeterView.cpp │ ├── netmeterView.h │ ├── res │ │ ├── BMP00001.BMP │ │ ├── bitmap1.bmp │ │ ├── bitmap2.bmp │ │ ├── cap_wizi.bmp │ │ ├── listbmp.bmp │ │ ├── netmeter.ico │ │ ├── netmeter.rc2 │ │ └── netmeterDoc.ico │ └── resource.h ├── PacketDriver │ ├── GetMacAddress │ │ ├── GetMacAddress.c │ │ └── GetMacAddress.vcxproj │ ├── TestPacketCapture │ │ ├── TestPacketCapture.c │ │ └── TestPacketCapture.vcxproj │ ├── TestPacketSend │ │ ├── TestPacketSend.c │ │ └── TestPacketSend.vcxproj │ └── readme.txt ├── UDPdump │ ├── UDPdump.vcxproj │ └── udpdump.c ├── UserLevelBridge │ ├── UserBridge.c │ └── UserBridge.vcxproj ├── iflist │ ├── iflist.c │ ├── iflist.vcxproj │ └── iflist.vcxproj.filters ├── misc │ ├── basic_dump.c │ ├── basic_dump.vcxproj │ ├── basic_dump_ex.c │ ├── basic_dump_ex.vcxproj │ ├── misc.h │ ├── readfile.c │ ├── readfile.vcxproj │ ├── readfile_ex.c │ ├── readfile_ex.vcxproj │ ├── savedump.c │ ├── savedump.vcxproj │ ├── sendpack.c │ └── sendpack.vcxproj ├── pcap_filter │ ├── pcap_filter.c │ └── pcap_filter.vcxproj ├── pcap_fopen │ ├── pcap_fopen.cpp │ └── pcap_fopen.vcxproj ├── pktdump_ex │ ├── pktdump_ex.c │ └── pktdump_ex.vcxproj ├── sendcap │ ├── sendcap.c │ ├── sendcap.vcxproj │ └── sendcap.vcxproj.filters ├── smp_1 │ ├── smp_1.c │ └── smp_1.vcxproj └── tcptop │ ├── tcptop.c │ └── tcptop.vcxproj ├── LICENSE ├── Npcap_Guide.html ├── README.md ├── SDK_CHANGELOG.md ├── appveyor.yml ├── build_sdk.bat ├── build_sdk.txt ├── build_test.bat ├── create_docs.bat ├── create_docs.make ├── create_examples.bat ├── create_include.bat ├── create_lib.bat ├── docs ├── Npcap-Third-Party-Open-Source.fodt ├── Npcap-Third-Party-Open-Source.pdf ├── README ├── index.html ├── npcap-api.xml ├── npcap-devguide.xml ├── npcap-guide-wrapper.html ├── npcap-guide-wrapper.xml ├── npcap-guide.xml ├── npcap-internals.xml ├── npcap-intro.xml ├── npcap-tutorial.xml └── winpcap_noc.dox ├── installer ├── Build.bat ├── CheckStatus.bat ├── DiagReport.bat ├── DiagReport.ps1 └── FixInstall.bat ├── packetWin7 ├── Dll │ ├── AdInfo.cpp │ ├── Packet.def │ ├── Packet32-Int.h │ ├── Packet32.cpp │ ├── Project │ │ ├── Packet.sln │ │ ├── Packet.vcxproj │ │ └── Packet.vcxproj.filters │ ├── debug.h │ ├── version.rc │ └── version.rc2 ├── Helper │ ├── NpcapHelper.sln │ ├── NpcapHelper │ │ ├── NpcapHelper.cpp │ │ ├── NpcapHelper.exe.manifest.in │ │ ├── NpcapHelper.vcxproj │ │ ├── NpcapHelper.vcxproj.filters │ │ ├── resource.h │ │ ├── version.rc │ │ └── version.rc2 │ ├── NpcapHelperTest │ │ ├── NpcapHelperTest.c │ │ ├── NpcapHelperTest.vcxproj │ │ └── NpcapHelperTest.vcxproj.filters │ └── debug.h ├── NPFInstall │ ├── NPFInstall.sln │ └── NPFInstall │ │ ├── CalloutInstall.cpp │ │ ├── CalloutInstall.h │ │ ├── DriverStoreClear.cpp │ │ ├── DriverStoreClear.h │ │ ├── LoopbackInstall.cpp │ │ ├── LoopbackInstall.h │ │ ├── LoopbackRecord.cpp │ │ ├── LoopbackRecord.h │ │ ├── LoopbackRename.cpp │ │ ├── LoopbackRename.h │ │ ├── LoopbackRename2.cpp │ │ ├── LoopbackRename2.h │ │ ├── NPFInstall.cpp │ │ ├── NPFInstall.exe.manifest.in │ │ ├── NPFInstall.vcxproj │ │ ├── NPFInstall.vcxproj.filters │ │ ├── ProcessUtil.cpp │ │ ├── ProcessUtil.h │ │ ├── ProtInstall.cpp │ │ ├── ProtInstall.h │ │ ├── RegUtil.cpp │ │ ├── RegUtil.h │ │ ├── msg.h │ │ ├── netcfgapi.cpp │ │ ├── netcfgapi.h │ │ ├── rc_ids.h │ │ ├── version.rc │ │ └── version.rc2 ├── WlanHelper │ ├── WlanHelper.sln │ └── WlanHelper │ │ ├── Tool.cpp │ │ ├── Tool.h │ │ ├── WlanHelper.cpp │ │ ├── WlanHelper.exe.manifest.in │ │ ├── WlanHelper.vcxproj │ │ ├── WlanHelper.vcxproj.filters │ │ ├── version.rc │ │ └── version.rc2 ├── npf │ ├── npf Package │ │ └── npf Package.vcxproj │ ├── npf.sln │ └── npf │ │ ├── Loopback.c │ │ ├── Loopback.h │ │ ├── Openclos.c │ │ ├── Packet.c │ │ ├── Packet.h │ │ ├── Read.c │ │ ├── Write.c │ │ ├── ieee80211_radiotap.h │ │ ├── ioctls.h │ │ ├── macros.h │ │ ├── memory_tags.h │ │ ├── npcap.inf │ │ ├── npcap.rc │ │ ├── npcap_wfp.inf │ │ ├── npf.vcxproj │ │ ├── npf.vcxproj.filters │ │ ├── stdafx.h │ │ ├── time_calls.h │ │ ├── valid_insns.h │ │ ├── win_bpf.h │ │ └── win_bpf_filter.c └── vs14 │ └── npcap.sln ├── test ├── README.md ├── make_test.bat └── static.props ├── version.h └── wpcap └── wpcap-cmake.bat /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help Npcap improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Diagnostic information** 27 | * Windows version from `winver` (e.g. Windows 11 Version 21H2, OS Build 22000.795) 28 | * Output of [DiagReport](https://npcap.com/guide/npcap-users-guide.html#npcap-issues-diagreport) 29 | * [Installation logs](https://npcap.com/guide/npcap-users-guide.html#npcap-issues-installation-log) 30 | * If installation failed, include [SetupApi.dev.log](https://docs.microsoft.com/en-us/windows-hardware/drivers/install/setupapi-device-installation-log-entries) 31 | * If blue screen crash (BSoD), provide [Windows memory dump file](https://docs.microsoft.com/en-us/troubleshoot/windows-client/performance/read-small-memory-dump-file#small-memory-dump-files). This may include sensitive information that should not be posted to Github. You may email it to dmiller@nmap.com instead. Reference the issue number in the subject of the email. 32 | * Any special hardware or software that may be relevant: VPN, firewall, antivirus, virtualization (SR-IOV passthrough, etc). 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.ncb 3 | *.suo 4 | *.sdf 5 | *.opensdf 6 | *.aps 7 | *.pdb 8 | *.exe 9 | *.msi 10 | *.zip 11 | *.ilk 12 | *.obj 13 | *.user 14 | *.cat 15 | *.sys 16 | *.dll 17 | *.ipch 18 | *.VC.db 19 | Debug/ 20 | Release/ 21 | OEM Debug/ 22 | OEM Release/ 23 | Win7 Release SDV/ 24 | sdv/ 25 | build.err 26 | build.log 27 | msbuild.log 28 | runsdvui.cmd 29 | SDV-default.xml 30 | sdv-user.sdv 31 | sdv-map.h 32 | staticdv.job 33 | StaticDVTrace.log 34 | npcap.res 35 | /npcap-sdk/ 36 | /dox/prj/ 37 | *.VC.opendb 38 | .vs/ 39 | Win* OEM RO Release/ 40 | Win* OEM Release/ 41 | Win* Release/ 42 | Win* Debug/ 43 | x64/ 44 | ARM64/ 45 | ARM64EC/ 46 | /wpcap/build-win32/ 47 | /wpcap/build-x64/ 48 | /wpcap/build-ARM64/ 49 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "wpcap/libpcap"] 2 | path = wpcap/libpcap 3 | url = ../libpcap 4 | -------------------------------------------------------------------------------- /Examples-pcap/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | SUBDIRS = basic_dump basic_dump_ex iflist pcap_filter pktdump_ex readfile readfile_ex savedump sendpack UDPdump 5 | 6 | all clean install uninstall: ${SUBDIRS} 7 | for subdir in ${SUBDIRS}; do \ 8 | echo "Entering $$subdir"; \ 9 | (cd $$subdir && ${MAKE} $@) \ 10 | done; 11 | -------------------------------------------------------------------------------- /Examples-pcap/UDPdump/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Loris Degioanni 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = udpdump.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap -lwsock32 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o udpdump.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} udpdump.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/basic_dump/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = basic_dump.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o basic_dump.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} basic_dump.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/basic_dump/basic_dump.c: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | /* 3 | * we do not want the warnings about the old deprecated and unsecure CRT functions 4 | * since these examples can be compiled under *nix as well 5 | */ 6 | #define _CRT_SECURE_NO_WARNINGS 7 | #endif 8 | 9 | #include 10 | #include 11 | #include 12 | #ifdef _WIN32 13 | #include 14 | BOOL LoadNpcapDlls() 15 | { 16 | _TCHAR npcap_dir[512]; 17 | UINT len; 18 | len = GetSystemDirectory(npcap_dir, 480); 19 | if (!len) { 20 | fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError()); 21 | return FALSE; 22 | } 23 | _tcscat_s(npcap_dir, 512, _T("\\Npcap")); 24 | if (SetDllDirectory(npcap_dir) == 0) { 25 | fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError()); 26 | return FALSE; 27 | } 28 | return TRUE; 29 | } 30 | #endif 31 | 32 | /* prototype of the packet handler */ 33 | void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data); 34 | 35 | int main() 36 | { 37 | pcap_if_t *alldevs; 38 | pcap_if_t *d; 39 | int inum; 40 | int i=0; 41 | pcap_t *adhandle; 42 | char errbuf[PCAP_ERRBUF_SIZE]; 43 | 44 | #ifdef _WIN32 45 | /* Load Npcap and its functions. */ 46 | if (!LoadNpcapDlls()) 47 | { 48 | fprintf(stderr, "Couldn't load Npcap\n"); 49 | exit(1); 50 | } 51 | #endif 52 | 53 | /* Retrieve the device list */ 54 | if(pcap_findalldevs(&alldevs, errbuf) == -1) 55 | { 56 | fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf); 57 | exit(1); 58 | } 59 | 60 | /* Print the list */ 61 | for(d=alldevs; d; d=d->next) 62 | { 63 | printf("%d. %s", ++i, d->name); 64 | if (d->description) 65 | printf(" (%s)\n", d->description); 66 | else 67 | printf(" (No description available)\n"); 68 | } 69 | 70 | if(i==0) 71 | { 72 | printf("\nNo interfaces found! Make sure Npcap is installed.\n"); 73 | return -1; 74 | } 75 | 76 | printf("Enter the interface number (1-%d):",i); 77 | scanf("%d", &inum); 78 | 79 | if(inum < 1 || inum > i) 80 | { 81 | printf("\nInterface number out of range.\n"); 82 | /* Free the device list */ 83 | pcap_freealldevs(alldevs); 84 | return -1; 85 | } 86 | 87 | /* Jump to the selected adapter */ 88 | for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++); 89 | 90 | /* Open the device */ 91 | /* Open the adapter */ 92 | if ((adhandle= pcap_open_live(d->name, // name of the device 93 | 65536, // portion of the packet to capture. 94 | // 65536 grants that the whole packet will be captured on all the MACs. 95 | 1, // promiscuous mode (nonzero means promiscuous) 96 | 1000, // read timeout 97 | errbuf // error buffer 98 | )) == NULL) 99 | { 100 | fprintf(stderr,"\nUnable to open the adapter. %s is not supported by Npcap\n", d->name); 101 | /* Free the device list */ 102 | pcap_freealldevs(alldevs); 103 | return -1; 104 | } 105 | 106 | printf("\nlistening on %s...\n", d->description); 107 | 108 | /* At this point, we don't need any more the device list. Free it */ 109 | pcap_freealldevs(alldevs); 110 | 111 | /* start the capture */ 112 | pcap_loop(adhandle, 0, packet_handler, NULL); 113 | 114 | pcap_close(adhandle); 115 | return 0; 116 | } 117 | 118 | 119 | /* Callback function invoked by libpcap for every incoming packet */ 120 | void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data) 121 | { 122 | struct tm *ltime; 123 | char timestr[16]; 124 | time_t local_tv_sec; 125 | 126 | /* 127 | * unused parameters 128 | */ 129 | (VOID)(param); 130 | (VOID)(pkt_data); 131 | 132 | /* convert the timestamp to readable format */ 133 | local_tv_sec = header->ts.tv_sec; 134 | ltime=localtime(&local_tv_sec); 135 | strftime( timestr, sizeof timestr, "%H:%M:%S", ltime); 136 | 137 | printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len); 138 | 139 | } 140 | -------------------------------------------------------------------------------- /Examples-pcap/basic_dump_ex/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = basic_dump_ex.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o basic_dump_ex.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} basic_dump_ex.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/basic_dump_ex/basic_dump_ex.c: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | /* 3 | * we do not want the warnings about the old deprecated and unsecure CRT functions 4 | * since these examples can be compiled under *nix as well 5 | */ 6 | #define _CRT_SECURE_NO_WARNINGS 7 | #endif 8 | 9 | #include 10 | #include 11 | #include 12 | #ifdef _WIN32 13 | #include 14 | BOOL LoadNpcapDlls() 15 | { 16 | _TCHAR npcap_dir[512]; 17 | UINT len; 18 | len = GetSystemDirectory(npcap_dir, 480); 19 | if (!len) { 20 | fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError()); 21 | return FALSE; 22 | } 23 | _tcscat_s(npcap_dir, 512, _T("\\Npcap")); 24 | if (SetDllDirectory(npcap_dir) == 0) { 25 | fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError()); 26 | return FALSE; 27 | } 28 | return TRUE; 29 | } 30 | #endif 31 | 32 | int main() 33 | { 34 | pcap_if_t *alldevs; 35 | pcap_if_t *d; 36 | int inum; 37 | int i=0; 38 | pcap_t *adhandle; 39 | int res; 40 | char errbuf[PCAP_ERRBUF_SIZE]; 41 | struct tm *ltime; 42 | char timestr[16]; 43 | struct pcap_pkthdr *header; 44 | const u_char *pkt_data; 45 | time_t local_tv_sec; 46 | 47 | #ifdef _WIN32 48 | /* Load Npcap and its functions. */ 49 | if (!LoadNpcapDlls()) 50 | { 51 | fprintf(stderr, "Couldn't load Npcap\n"); 52 | exit(1); 53 | } 54 | #endif 55 | 56 | /* Retrieve the device list */ 57 | if(pcap_findalldevs(&alldevs, errbuf) == -1) 58 | { 59 | fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf); 60 | return -1; 61 | } 62 | 63 | /* Print the list */ 64 | for(d=alldevs; d; d=d->next) 65 | { 66 | printf("%d. %s", ++i, d->name); 67 | if (d->description) 68 | printf(" (%s)\n", d->description); 69 | else 70 | printf(" (No description available)\n"); 71 | } 72 | 73 | if(i==0) 74 | { 75 | printf("\nNo interfaces found! Make sure Npcap is installed.\n"); 76 | return -1; 77 | } 78 | 79 | printf("Enter the interface number (1-%d):",i); 80 | scanf("%d", &inum); 81 | 82 | if(inum < 1 || inum > i) 83 | { 84 | printf("\nInterface number out of range.\n"); 85 | /* Free the device list */ 86 | pcap_freealldevs(alldevs); 87 | return -1; 88 | } 89 | 90 | /* Jump to the selected adapter */ 91 | for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++); 92 | 93 | /* Open the adapter */ 94 | if ((adhandle= pcap_open_live(d->name, // name of the device 95 | 65536, // portion of the packet to capture. 96 | // 65536 grants that the whole packet will be captured on all the MACs. 97 | 1, // promiscuous mode (nonzero means promiscuous) 98 | 1000, // read timeout 99 | errbuf // error buffer 100 | )) == NULL) 101 | { 102 | fprintf(stderr,"\nUnable to open the adapter. %s is not supported by Npcap\n", d->name); 103 | /* Free the device list */ 104 | pcap_freealldevs(alldevs); 105 | return -1; 106 | } 107 | 108 | printf("\nlistening on %s...\n", d->description); 109 | 110 | /* At this point, we don't need any more the device list. Free it */ 111 | pcap_freealldevs(alldevs); 112 | 113 | /* Retrieve the packets */ 114 | while((res = pcap_next_ex( adhandle, &header, &pkt_data)) >= 0){ 115 | 116 | if(res == 0) 117 | /* Timeout elapsed */ 118 | continue; 119 | 120 | /* convert the timestamp to readable format */ 121 | local_tv_sec = header->ts.tv_sec; 122 | ltime=localtime(&local_tv_sec); 123 | strftime( timestr, sizeof timestr, "%H:%M:%S", ltime); 124 | 125 | printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len); 126 | } 127 | 128 | if(res == -1){ 129 | printf("Error reading the packets: %s\n", pcap_geterr(adhandle)); 130 | return -1; 131 | } 132 | 133 | pcap_close(adhandle); 134 | return 0; 135 | } 136 | -------------------------------------------------------------------------------- /Examples-pcap/iflist/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = iflist.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o iflist.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} iflist.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/pcap_filter/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = pcap_filter.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o pf.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} pf.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/pcap_filter/Makefile.unix: -------------------------------------------------------------------------------- 1 | 2 | CC = gcc 3 | INCLDIR = -I /usr/src/sys 4 | LIBS = -lpcap 5 | 6 | pktdump: pcap_filter.o 7 | $(CC) $(INCLDIR) pcap_filter.o $(LIBS) -o pf 8 | rm *.o 9 | 10 | -------------------------------------------------------------------------------- /Examples-pcap/pktdump_ex/GNUmakefile: -------------------------------------------------------------------------------- 1 | PCAP_PATH = ../../lib 2 | CFLAGS = -g -O -mno-cygwin -I ../../include 3 | 4 | OBJS = pktdump_ex.o 5 | LIBS = -L ${PCAP_PATH} -lwpcap 6 | 7 | all: ${OBJS} 8 | ${CC} ${CFLAGS} -o pktdump_ex.exe ${OBJS} ${LIBS} 9 | 10 | clean: 11 | rm -f ${OBJS} pktdump_ex.exe 12 | 13 | .c.o: 14 | ${CC} ${CFLAGS} -c -o $*.o $< 15 | -------------------------------------------------------------------------------- /Examples-pcap/readfile/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = readfile.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o readfile.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} readfile.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/readfile/readfile.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define LINE_LEN 16 6 | #define TIMEVAL_AFTER(a, b) (((a).tv_sec > (b).tv_sec) || ((a).tv_sec == (b).tv_sec && (a).tv_usec > (b).tv_usec)) 7 | #define TIMEVAL_BEFORE(a, b) (((a).tv_sec < (b).tv_sec) || ((a).tv_sec == (b).tv_sec && (a).tv_usec < (b).tv_usec)) 8 | 9 | #ifdef _WIN32 10 | #include 11 | BOOL LoadNpcapDlls() 12 | { 13 | _TCHAR npcap_dir[512]; 14 | UINT len; 15 | len = GetSystemDirectory(npcap_dir, 480); 16 | if (!len) { 17 | fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError()); 18 | return FALSE; 19 | } 20 | _tcscat_s(npcap_dir, 512, _T("\\Npcap")); 21 | if (SetDllDirectory(npcap_dir) == 0) { 22 | fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError()); 23 | return FALSE; 24 | } 25 | return TRUE; 26 | } 27 | #endif 28 | 29 | void dispatcher_handler(u_char *, const struct pcap_pkthdr *, const u_char *); 30 | 31 | struct state { 32 | int verify; 33 | const struct timeval first; 34 | const struct timeval prev; 35 | pcap_t *p; 36 | }; 37 | 38 | int main(int argc, char **argv) 39 | { 40 | pcap_t *fp; 41 | char *filename = NULL; 42 | char errbuf[PCAP_ERRBUF_SIZE]; 43 | struct state st; 44 | memset(&st, 0, sizeof(st)); 45 | 46 | #ifdef _WIN32 47 | /* Load Npcap and its functions. */ 48 | if (!LoadNpcapDlls()) 49 | { 50 | fprintf(stderr, "Couldn't load Npcap\n"); 51 | exit(1); 52 | } 53 | #endif 54 | 55 | if (argc == 3 && strcmp(argv[1], "-v") == 0) { 56 | filename = argv[2]; 57 | st.verify = 1; 58 | } 59 | else if(argc != 2) 60 | { 61 | printf("usage: %s [-v] filename", argv[0]); 62 | return -1; 63 | 64 | } 65 | else 66 | filename = argv[1]; 67 | 68 | /* Open the capture file */ 69 | if ((fp = pcap_open_offline(filename, // name of the device 70 | errbuf // error buffer 71 | )) == NULL) 72 | { 73 | fprintf(stderr,"\nUnable to open the file %s: %s\n", filename, errbuf); 74 | return -1; 75 | } 76 | 77 | /* read and dispatch packets until EOF is reached */ 78 | st.p = fp; 79 | if (0 != pcap_loop(fp, 0, dispatcher_handler, (u_char *) &st)) { 80 | fprintf(stderr, "pcap_loop error: %s\n", pcap_geterr(fp)); 81 | pcap_close(fp); 82 | return -1; 83 | } 84 | 85 | if (st.prev.tv_sec == 0 && st.prev.tv_usec == 0) { 86 | fprintf(stderr, "No packets processed!\n"); 87 | pcap_close(fp); 88 | return -1; 89 | } 90 | 91 | if (!TIMEVAL_AFTER(st.prev, st.first)) { 92 | fprintf(stderr, "Timestamps do not increase: %lu.%06lu\n", st.prev.tv_sec, st.prev.tv_usec); 93 | pcap_close(fp); 94 | return -1; 95 | } 96 | pcap_close(fp); 97 | return 0; 98 | } 99 | 100 | 101 | 102 | void dispatcher_handler(u_char *temp1, 103 | const struct pcap_pkthdr *header, 104 | const u_char *pkt_data) 105 | { 106 | u_int i=0; 107 | 108 | struct state *st = (struct state *) temp1; 109 | if (st->first.tv_sec == 0 && st->first.tv_usec == 0) { 110 | memcpy(&st->first, &header->ts, sizeof(struct timeval)); 111 | } 112 | 113 | if (st->verify && (st->prev.tv_sec != 0 || st->prev.tv_usec != 0)) { 114 | /* Default timestamp mode is monotonically increasing */ 115 | if (TIMEVAL_BEFORE(header->ts, st->prev)) { 116 | fprintf(stderr, "Backwards timestamp!\n"); 117 | pcap_breakloop(st->p); 118 | } 119 | } 120 | 121 | /* print pkt timestamp and pkt len */ 122 | printf("%ld:%ld (%ld)\n", header->ts.tv_sec, header->ts.tv_usec, header->len); 123 | 124 | /* Print the packet */ 125 | for (i=1; (i < header->caplen + 1 ) ; i++) 126 | { 127 | printf("%.2x ", pkt_data[i-1]); 128 | if ( (i % LINE_LEN) == 0) printf("\n"); 129 | } 130 | 131 | printf("\n\n"); 132 | memcpy(&st->prev, &header->ts, sizeof(struct timeval)); 133 | } 134 | -------------------------------------------------------------------------------- /Examples-pcap/readfile_ex/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = readfile_ex.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o readfile_ex.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} readfile_ex.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/readfile_ex/readfile_ex.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define LINE_LEN 16 5 | 6 | #ifdef _WIN32 7 | #include 8 | BOOL LoadNpcapDlls() 9 | { 10 | _TCHAR npcap_dir[512]; 11 | UINT len; 12 | len = GetSystemDirectory(npcap_dir, 480); 13 | if (!len) { 14 | fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError()); 15 | return FALSE; 16 | } 17 | _tcscat_s(npcap_dir, 512, _T("\\Npcap")); 18 | if (SetDllDirectory(npcap_dir) == 0) { 19 | fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError()); 20 | return FALSE; 21 | } 22 | return TRUE; 23 | } 24 | #endif 25 | 26 | int main(int argc, char **argv) 27 | { 28 | pcap_t *fp; 29 | char errbuf[PCAP_ERRBUF_SIZE]; 30 | struct pcap_pkthdr *header; 31 | const u_char *pkt_data; 32 | u_int i=0; 33 | int res; 34 | 35 | #ifdef _WIN32 36 | /* Load Npcap and its functions. */ 37 | if (!LoadNpcapDlls()) 38 | { 39 | fprintf(stderr, "Couldn't load Npcap\n"); 40 | exit(1); 41 | } 42 | #endif 43 | 44 | if(argc != 2) 45 | { 46 | printf("usage: %s filename", argv[0]); 47 | return -1; 48 | 49 | } 50 | 51 | /* Open the capture file */ 52 | if ((fp = pcap_open_offline(argv[1], // name of the device 53 | errbuf // error buffer 54 | )) == NULL) 55 | { 56 | fprintf(stderr,"\nUnable to open the file %s.\n", argv[1]); 57 | return -1; 58 | } 59 | 60 | /* Retrieve the packets from the file */ 61 | while((res = pcap_next_ex(fp, &header, &pkt_data)) >= 0) 62 | { 63 | /* print pkt timestamp and pkt len */ 64 | printf("%ld:%ld (%ld)\n", header->ts.tv_sec, header->ts.tv_usec, header->len); 65 | 66 | /* Print the packet */ 67 | for (i=1; (i < header->caplen + 1 ) ; i++) 68 | { 69 | printf("%.2x ", pkt_data[i-1]); 70 | if ( (i % LINE_LEN) == 0) printf("\n"); 71 | } 72 | 73 | printf("\n\n"); 74 | } 75 | 76 | 77 | if (res == -1) 78 | { 79 | printf("Error reading the packets: %s\n", pcap_geterr(fp)); 80 | } 81 | 82 | pcap_close(fp); 83 | return 0; 84 | } 85 | 86 | -------------------------------------------------------------------------------- /Examples-pcap/savedump/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = savedump.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o savedump.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} savedump.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples-pcap/savedump/savedump.c: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | /* 3 | * we do not want the warnings about the old deprecated and unsecure CRT functions 4 | * since these examples can be compiled under *nix as well 5 | */ 6 | #define _CRT_SECURE_NO_WARNINGS 7 | #endif 8 | 9 | #include 10 | 11 | #ifdef _WIN32 12 | #include 13 | BOOL LoadNpcapDlls() 14 | { 15 | _TCHAR npcap_dir[512]; 16 | UINT len; 17 | len = GetSystemDirectory(npcap_dir, 480); 18 | if (!len) { 19 | fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError()); 20 | return FALSE; 21 | } 22 | _tcscat_s(npcap_dir, 512, _T("\\Npcap")); 23 | if (SetDllDirectory(npcap_dir) == 0) { 24 | fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError()); 25 | return FALSE; 26 | } 27 | return TRUE; 28 | } 29 | #endif 30 | 31 | /* prototype of the packet handler */ 32 | void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data); 33 | 34 | int main(int argc, char **argv) 35 | { 36 | pcap_if_t *alldevs; 37 | pcap_if_t *d; 38 | int inum; 39 | int i=0; 40 | pcap_t *adhandle; 41 | char errbuf[PCAP_ERRBUF_SIZE]; 42 | pcap_dumper_t *dumpfile; 43 | 44 | #ifdef _WIN32 45 | /* Load Npcap and its functions. */ 46 | if (!LoadNpcapDlls()) 47 | { 48 | fprintf(stderr, "Couldn't load Npcap\n"); 49 | exit(1); 50 | } 51 | #endif 52 | 53 | 54 | /* Check command line */ 55 | if(argc != 2) 56 | { 57 | printf("usage: %s filename", argv[0]); 58 | return -1; 59 | } 60 | 61 | /* Retrieve the device list on the local machine */ 62 | if (pcap_findalldevs(&alldevs, errbuf) == -1) 63 | { 64 | fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf); 65 | exit(1); 66 | } 67 | 68 | /* Print the list */ 69 | for(d=alldevs; d; d=d->next) 70 | { 71 | printf("%d. %s", ++i, d->name); 72 | if (d->description) 73 | printf(" (%s)\n", d->description); 74 | else 75 | printf(" (No description available)\n"); 76 | } 77 | 78 | if(i==0) 79 | { 80 | printf("\nNo interfaces found! Make sure Npcap is installed.\n"); 81 | return -1; 82 | } 83 | 84 | printf("Enter the interface number (1-%d):",i); 85 | scanf("%d", &inum); 86 | 87 | if(inum < 1 || inum > i) 88 | { 89 | printf("\nInterface number out of range.\n"); 90 | /* Free the device list */ 91 | pcap_freealldevs(alldevs); 92 | return -1; 93 | } 94 | 95 | /* Jump to the selected adapter */ 96 | for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++); 97 | 98 | 99 | /* Open the adapter */ 100 | if ((adhandle= pcap_open_live(d->name, // name of the device 101 | 65536, // portion of the packet to capture. 102 | // 65536 grants that the whole packet will be captured on all the MACs. 103 | 1, // promiscuous mode (nonzero means promiscuous) 104 | 1000, // read timeout 105 | errbuf // error buffer 106 | )) == NULL) 107 | { 108 | fprintf(stderr,"\nUnable to open the adapter. %s is not supported by Npcap\n", d->name); 109 | /* Free the device list */ 110 | pcap_freealldevs(alldevs); 111 | return -1; 112 | } 113 | 114 | /* Open the dump file */ 115 | dumpfile = pcap_dump_open(adhandle, argv[1]); 116 | 117 | if(dumpfile==NULL) 118 | { 119 | fprintf(stderr,"\nError opening output file\n"); 120 | return -1; 121 | } 122 | 123 | printf("\nlistening on %s... Press Ctrl+C to stop...\n", d->description); 124 | 125 | /* At this point, we no longer need the device list. Free it */ 126 | pcap_freealldevs(alldevs); 127 | 128 | /* start the capture */ 129 | pcap_loop(adhandle, 0, packet_handler, (unsigned char *)dumpfile); 130 | 131 | pcap_close(adhandle); 132 | return 0; 133 | } 134 | 135 | /* Callback function invoked by libpcap for every incoming packet */ 136 | void packet_handler(u_char *dumpfile, const struct pcap_pkthdr *header, const u_char *pkt_data) 137 | { 138 | /* save the packet on the dump file */ 139 | pcap_dump(dumpfile, header, pkt_data); 140 | } 141 | -------------------------------------------------------------------------------- /Examples-pcap/sendpack/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Makefile for cygwin gcc 2 | # Nate Lawson 3 | 4 | PCAP_PATH = ../../lib 5 | CFLAGS = -g -O -mno-cygwin -I ../../include 6 | 7 | OBJS = sendpack.o 8 | LIBS = -L ${PCAP_PATH} -lwpcap 9 | 10 | all: ${OBJS} 11 | ${CC} ${CFLAGS} -o sendpack.exe ${OBJS} ${LIBS} 12 | 13 | clean: 14 | rm -f ${OBJS} sendpack.exe 15 | 16 | .c.o: 17 | ${CC} ${CFLAGS} -c -o $*.o $< 18 | -------------------------------------------------------------------------------- /Examples/NETMETER/CapDll.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | 35 | #if !defined(AFX_CapDll_H__03FA9206_C8EA_11D2_B729_0048540133F7__INCLUDED_) 36 | #define AFX_CapDll_H__03FA9206_C8EA_11D2_B729_0048540133F7__INCLUDED_ 37 | 38 | #if _MSC_VER >= 1000 39 | #pragma once 40 | #endif // _MSC_VER >= 1000 41 | 42 | #ifndef __AFXWIN_H__ 43 | #error include 'stdafx.h' before including this file for PCH 44 | #endif 45 | 46 | #include "resource.h" // main symbols 47 | #define MaxCapPars 10 48 | 49 | ///////////////////////////////////////////////////////////////////////////// 50 | // CCapDll: 51 | // See CapDll.cpp for the implementation of this class 52 | // 53 | #ifdef _EXPORTING 54 | #define CLASS_DECLSPEC __declspec(dllexport) 55 | #else 56 | #define CLASS_DECLSPEC __declspec(dllimport) 57 | #endif 58 | 59 | void CLASS_DECLSPEC InitCapDll(const char* INI); 60 | 61 | class CLASS_DECLSPEC CCapDll 62 | { 63 | public: 64 | CCapDll(); 65 | const char* GetFileName(); 66 | char* SetFileName(const char* fn); 67 | const char* GetAdapter(); 68 | const char* GetPath(); 69 | const char* GetFilter(); 70 | char* SetPath(const char * p); 71 | char* SetAdapter(const char* ad); 72 | char* SetFilter(const char* ad); 73 | int CaptureDialog(const char* Adapter,const char* P, CWnd* mw); 74 | int ChooseAdapter(const char* Adapter, CWnd* mw); 75 | const char* Capture(const char* file, CWnd* mw); 76 | ~CCapDll(); 77 | private: 78 | char* Path; 79 | char* Adapter; 80 | char* FileName; 81 | char* Filter; 82 | int bufdim; 83 | int ncapture; 84 | int snaplen; 85 | int promisquous; 86 | void LoadCmds(); 87 | CString RetrieveValue(CString keyval); 88 | }; 89 | 90 | 91 | ///////////////////////////////////////////////////////////////////////////// 92 | 93 | //{{AFX_INSERT_LOCATION}} 94 | // Microsoft Developer Studio will insert additional declarations immediately before the previous line. 95 | 96 | #endif // !defined(AFX_CapDll_H__03FA9206_C8EA_11D2_B729_0048540133F7__INCLUDED_) 97 | -------------------------------------------------------------------------------- /Examples/NETMETER/CaptureThread.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #include "stdafx.h" 35 | #include "resource.h" 36 | #include "capdll.h" 37 | #include "console.h" 38 | 39 | HANDLE in,out,err; 40 | 41 | DWORD d; 42 | CCapPars* pObject; 43 | CRITICAL_SECTION Crit; 44 | 45 | // callback routine called by libpcap for every incoming packet 46 | void dispatcher_handler(u_char *pParam,const struct pcap_pkthdr *header, const u_char *pkt_data) 47 | { 48 | UINT delay; 49 | LARGE_INTEGER Bps,Pps; 50 | CCapPars* pObject; 51 | 52 | pObject=(CCapPars*)pParam; 53 | //Calculate the delay in microseconds from the last sample. 54 | //This value is obtained from the timestamp that the capture driver 55 | //associates to the sample. 56 | delay=(header->ts.tv_sec-pObject->lasttime.tv_sec)*1000000-pObject->lasttime.tv_usec+header->ts.tv_usec; 57 | //get the number of Bits per second 58 | Bps.QuadPart=(((LONGLONG)(*(LONGLONG*)(pkt_data+8))*80)/(delay)); 59 | //get the number of Packets per second 60 | Pps.QuadPart=(((LONGLONG)(*(LONGLONG*)(pkt_data))*100000000)/((LONGLONG)delay*14880)); 61 | 62 | //store current timestamp 63 | pObject->lasttime.tv_sec=header->ts.tv_sec; 64 | pObject->lasttime.tv_usec=header->ts.tv_usec; 65 | 66 | pObject->prg->DrawBoard(&(pObject->prg->DrawBuffer),pObject->prg->wrett,Bps.LowPart,Pps.LowPart); 67 | } 68 | 69 | //main thread procedure: launches the capture and wait 70 | UINT MyThreadProc( LPVOID pParam ) 71 | { 72 | int i; 73 | 74 | if (pParam == NULL) 75 | return -1; // illegal parameter 76 | pObject=(CCapPars*)pParam; 77 | 78 | //reset the timer 79 | pObject->lasttime.tv_sec=0; 80 | pObject->lasttime.tv_usec=0; 81 | 82 | //start the capture loop 83 | i = pcap_loop(pObject->fp, 0, dispatcher_handler, (PUCHAR)pParam); 84 | 85 | Sleep(INFINITE); 86 | 87 | return 0; 88 | } 89 | 90 | -------------------------------------------------------------------------------- /Examples/NETMETER/Console.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #include 35 | #include "netmeterDoc.h" 36 | #include "netmeterView.h" 37 | 38 | UINT MyThreadProc( LPVOID pParam ); 39 | 40 | typedef struct CCapPars 41 | { 42 | CNetmeterView* prg; //CNetmeterView class that launched the capture thread 43 | pcap_t *fp; //libpcap adapter 44 | struct timeval lasttime; //last capture time (internal) 45 | }CCapPars; 46 | -------------------------------------------------------------------------------- /Examples/NETMETER/LineColl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #include "LineColl.h" 35 | 36 | #ifdef _DEBUG 37 | #undef THIS_FILE 38 | static char THIS_FILE[]=__FILE__; 39 | #define new DEBUG_NEW 40 | #endif 41 | 42 | ////////////////////////////////////////////////////////////////////// 43 | // Construction/Destruction 44 | ////////////////////////////////////////////////////////////////////// 45 | 46 | LineCollection::LineCollection(CString *s,int skip) 47 | { 48 | m_Skip=skip; 49 | if(s==NULL) return; 50 | *this=*s; 51 | } 52 | 53 | LineCollection::LineCollection(CArchive &ar,int skip) 54 | { 55 | if (ar.IsStoring()) 56 | { 57 | return; 58 | } 59 | else 60 | { 61 | m_Skip=skip; 62 | CString s; 63 | int i,j; 64 | vect.SetSize(0); 65 | for(i=0,j=0;ar.ReadString(s);i++) 66 | { 67 | if(m_Skip && s=="") continue; 68 | vect.SetSize(j+1); 69 | vect[j]=s; 70 | j++; 71 | } 72 | } 73 | } 74 | 75 | LineCollection::~LineCollection() 76 | { 77 | } 78 | 79 | int LineCollection::GetSize() 80 | { 81 | return vect.GetSize(); 82 | } 83 | 84 | CString & LineCollection::operator =(CString &s) 85 | { 86 | int i,l,n,t=0; 87 | l=s.GetLength(); 88 | vect.SetSize(0); 89 | for(i=0,n=0;i0 && (s)[i-1]=='\n') continue; 94 | vect.SetSize(t+1); 95 | vect[t]=(s).Mid(n,i-n-1); 96 | t++; 97 | n=i+1; 98 | } 99 | } 100 | return s; 101 | } 102 | 103 | void LineCollection::clear() 104 | { 105 | vect.SetSize(0); 106 | } 107 | 108 | -------------------------------------------------------------------------------- /Examples/NETMETER/LineColl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #if !defined(AFX_LINECOLL_H__EE11D4A3_ED58_11D1_939A_000000000000__INCLUDED_) 35 | #define AFX_LINECOLL_H__EE11D4A3_ED58_11D1_939A_000000000000__INCLUDED_ 36 | 37 | #if _MSC_VER >= 1000 38 | #pragma once 39 | #endif // _MSC_VER >= 1000 40 | 41 | #include 42 | #include 43 | 44 | class LineCollection 45 | { 46 | public: 47 | void clear(); 48 | CString & operator =(CString &); 49 | int GetSize(); 50 | int getLineCount(){return GetSize();}; 51 | const char* line(int i){if (i vect; 59 | }; 60 | 61 | #endif // !defined(AFX_LINECOLL_H__EE11D4A3_ED58_11D1_939A_000000000000__INCLUDED_) 62 | -------------------------------------------------------------------------------- /Examples/NETMETER/MainFrm.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #include "stdafx.h" 35 | #include "netmeter.h" 36 | 37 | #include "MainFrm.h" 38 | 39 | #ifdef _DEBUG 40 | #define new DEBUG_NEW 41 | #undef THIS_FILE 42 | static char THIS_FILE[] = __FILE__; 43 | #endif 44 | 45 | ///////////////////////////////////////////////////////////////////////////// 46 | // CMainFrame 47 | 48 | IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) 49 | 50 | BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) 51 | //{{AFX_MSG_MAP(CMainFrame) 52 | //}}AFX_MSG_MAP 53 | END_MESSAGE_MAP() 54 | 55 | ///////////////////////////////////////////////////////////////////////////// 56 | // CMainFrame construction/destruction 57 | 58 | CMainFrame::CMainFrame() 59 | { 60 | } 61 | 62 | CMainFrame::~CMainFrame() 63 | { 64 | } 65 | 66 | BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) 67 | { 68 | if( !CFrameWnd::PreCreateWindow(cs) ) 69 | return FALSE; 70 | 71 | cs.style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; 72 | cs.cx=260; 73 | cs.cy=180; 74 | 75 | return TRUE; 76 | } 77 | 78 | ///////////////////////////////////////////////////////////////////////////// 79 | // CMainFrame diagnostics 80 | 81 | #ifdef _DEBUG 82 | void CMainFrame::AssertValid() const 83 | { 84 | CFrameWnd::AssertValid(); 85 | } 86 | 87 | void CMainFrame::Dump(CDumpContext& dc) const 88 | { 89 | CFrameWnd::Dump(dc); 90 | } 91 | 92 | #endif //_DEBUG 93 | -------------------------------------------------------------------------------- /Examples/NETMETER/MainFrm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | // MainFrm.h : interface of the CMainFrame class 35 | // 36 | ///////////////////////////////////////////////////////////////////////////// 37 | 38 | #if !defined(AFX_MAINFRM_H__3BF6CD27_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 39 | #define AFX_MAINFRM_H__3BF6CD27_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_ 40 | 41 | #if _MSC_VER > 1000 42 | #pragma once 43 | #endif // _MSC_VER > 1000 44 | 45 | class CMainFrame : public CFrameWnd 46 | { 47 | 48 | protected: // create from serialization only 49 | CMainFrame(); 50 | DECLARE_DYNCREATE(CMainFrame) 51 | 52 | // Attributes 53 | public: 54 | 55 | // Operations 56 | public: 57 | 58 | // Overrides 59 | // ClassWizard generated virtual function overrides 60 | //{{AFX_VIRTUAL(CMainFrame) 61 | public: 62 | virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 63 | //}}AFX_VIRTUAL 64 | 65 | // Implementation 66 | public: 67 | virtual ~CMainFrame(); 68 | #ifdef _DEBUG 69 | virtual void AssertValid() const; 70 | virtual void Dump(CDumpContext& dc) const; 71 | #endif 72 | 73 | // Generated message map functions 74 | protected: 75 | //{{AFX_MSG(CMainFrame) 76 | //}}AFX_MSG 77 | DECLARE_MESSAGE_MAP() 78 | }; 79 | 80 | ///////////////////////////////////////////////////////////////////////////// 81 | 82 | //{{AFX_INSERT_LOCATION}} 83 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 84 | 85 | #endif // !defined(AFX_MAINFRM_H__3BF6CD27_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 86 | -------------------------------------------------------------------------------- /Examples/NETMETER/NETMETER.H: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | // netmeter.h : main header file for the NETMETER application 35 | // 36 | 37 | #if !defined(AFX_NETMETER_H__3BF6CD23_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 38 | #define AFX_NETMETER_H__3BF6CD23_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_ 39 | 40 | #if _MSC_VER > 1000 41 | #pragma once 42 | #endif // _MSC_VER > 1000 43 | 44 | #ifndef __AFXWIN_H__ 45 | #error include 'stdafx.h' before including this file for PCH 46 | #endif 47 | 48 | #include "resource.h" // main symbols 49 | 50 | ///////////////////////////////////////////////////////////////////////////// 51 | // CNetmeterApp: 52 | // See netmeter.cpp for the implementation of this class 53 | // 54 | 55 | class CNetmeterApp : public CWinApp 56 | { 57 | public: 58 | CNetmeterApp(); 59 | 60 | // Overrides 61 | // ClassWizard generated virtual function overrides 62 | //{{AFX_VIRTUAL(CNetmeterApp) 63 | public: 64 | virtual BOOL InitInstance(); 65 | //}}AFX_VIRTUAL 66 | 67 | // Implementation 68 | //{{AFX_MSG(CNetmeterApp) 69 | afx_msg void OnAppAbout(); 70 | //}}AFX_MSG 71 | DECLARE_MESSAGE_MAP() 72 | }; 73 | 74 | 75 | ///////////////////////////////////////////////////////////////////////////// 76 | 77 | //{{AFX_INSERT_LOCATION}} 78 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 79 | 80 | #endif // !defined(AFX_NETMETER_H__3BF6CD23_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 81 | -------------------------------------------------------------------------------- /Examples/NETMETER/NetMeter.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | 73 | 74 | Resource Files 75 | 76 | 77 | 78 | 79 | Resource Files 80 | 81 | 82 | -------------------------------------------------------------------------------- /Examples/NETMETER/ProgCaptDlg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | 35 | #if !defined(AFX_PROGCAPTDLG_H__D79DA3C4_3B52_11D2_9482_0020AF2A4474__INCLUDED_) 36 | #define AFX_PROGCAPTDLG_H__D79DA3C4_3B52_11D2_9482_0020AF2A4474__INCLUDED_ 37 | 38 | #if _MSC_VER >= 1000 39 | #pragma once 40 | #endif // _MSC_VER >= 1000 41 | // ProgCaptDlg.h : header file 42 | // 43 | #include "..\..\include\pcap-c.h" 44 | 45 | class CCapPars; 46 | 47 | ///////////////////////////////////////////////////////////////////////////// 48 | // CProgCaptDlg dialog 49 | 50 | class CProgCaptDlg : public CDialog 51 | { 52 | // Construction 53 | public: 54 | CProgCaptDlg(CWnd* pParent = NULL); // standard constructor 55 | CCapPars* m_Main; 56 | int npc; 57 | int init; 58 | pcap_t *fp; 59 | pcap_dumper_t *dumpfile; 60 | 61 | 62 | // Dialog Data 63 | //{{AFX_DATA(CProgCaptDlg) 64 | enum { IDD = IDD_CAP_BUSY }; 65 | CStatic m_Static; 66 | CProgressCtrl m_Progress; 67 | //}}AFX_DATA 68 | 69 | 70 | // Overrides 71 | // ClassWizard generated virtual function overrides 72 | //{{AFX_VIRTUAL(CProgCaptDlg) 73 | public: 74 | virtual BOOL PreTranslateMessage(MSG* pMsg); 75 | protected: 76 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 77 | //}}AFX_VIRTUAL 78 | 79 | // Implementation 80 | protected: 81 | int p; 82 | int v; 83 | 84 | // Generated message map functions 85 | //{{AFX_MSG(CProgCaptDlg) 86 | virtual BOOL OnInitDialog(); 87 | virtual void OnCancel(); 88 | //}}AFX_MSG 89 | DECLARE_MESSAGE_MAP() 90 | }; 91 | 92 | //{{AFX_INSERT_LOCATION}} 93 | // Microsoft Developer Studio will insert additional declarations immediately before the previous line. 94 | 95 | #endif // !defined(AFX_PROGCAPTDLG_H__D79DA3C4_3B52_11D2_9482_0020AF2A4474__INCLUDED_) 96 | -------------------------------------------------------------------------------- /Examples/NETMETER/SelectAdapter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #if !defined(AFX_SELECTADAPTER_H__D41A3004_2B3D_11D0_9528_0020AF2A4474__INCLUDED_) 35 | #define AFX_SELECTADAPTER_H__D41A3004_2B3D_11D0_9528_0020AF2A4474__INCLUDED_ 36 | 37 | #if _MSC_VER >= 1000 38 | #pragma once 39 | #endif // _MSC_VER >= 1000 40 | // SelectAdapter.h : header file 41 | // 42 | 43 | #include "linecoll.h" 44 | #include "resource.h" 45 | 46 | ///////////////////////////////////////////////////////////////////////////// 47 | // CSelectAdapter dialog 48 | 49 | int ExecuteApp(CString & s); 50 | 51 | class CSelectAdapter : public CDialog 52 | { 53 | // Construction 54 | public: 55 | CSelectAdapter(CWnd* pParent = NULL); // standard constructor 56 | 57 | // Dialog Data 58 | //{{AFX_DATA(CSelectAdapter) 59 | enum { IDD = IDD_ADAPTER }; 60 | CStatic m_CAdapter; 61 | CListCtrl m_ListCtrl; 62 | //}}AFX_DATA 63 | CString m_Adapter; 64 | CString m_Cmd; 65 | CImageList m_ctlImage; 66 | 67 | // Overrides 68 | // ClassWizard generated virtual function overrides 69 | //{{AFX_VIRTUAL(CSelectAdapter) 70 | protected: 71 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 72 | //}}AFX_VIRTUAL 73 | 74 | // Implementation 75 | protected: 76 | void Update(LineCollection &lc); 77 | void AddItem(int nItem,int nSubItem,LPCTSTR strItem,int nImageIndex=-1); 78 | void SelectItem(int i); 79 | 80 | // Generated message map functions 81 | //{{AFX_MSG(CSelectAdapter) 82 | virtual BOOL OnInitDialog(); 83 | virtual void OnOK(); 84 | afx_msg void OnSelectItem(NMHDR* pNMHDR, LRESULT* pResult); 85 | afx_msg void Ondblclickitem(NMHDR* pNMHDR, LRESULT* pResult); 86 | //}}AFX_MSG 87 | DECLARE_MESSAGE_MAP() 88 | }; 89 | 90 | //{{AFX_INSERT_LOCATION}} 91 | // Microsoft Developer Studio will insert additional declarations immediately before the previous line. 92 | 93 | #endif // !defined(AFX_SELECTADAPTER_H__D41A3004_2B3D_11D0_9528_0020AF2A4474__INCLUDED_) 94 | -------------------------------------------------------------------------------- /Examples/NETMETER/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | // stdafx.cpp : source file that includes just the standard includes 35 | // netmeter.pch will be the pre-compiled header 36 | // stdafx.obj will contain the pre-compiled type information 37 | 38 | #include "stdafx.h" 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Examples/NETMETER/StdAfx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #if !defined(AFX_STDAFX_H__3BF6CD25_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 7 | #define AFX_STDAFX_H__3BF6CD25_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_ 8 | 9 | #if _MSC_VER > 1000 10 | #pragma once 11 | #endif // _MSC_VER > 1000 12 | 13 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 14 | 15 | #include // MFC core and standard components 16 | #include // MFC extensions 17 | #include // MFC support for Internet Explorer 4 Common Controls 18 | #ifndef _AFX_NO_AFXCMN_SUPPORT 19 | #include // MFC support for Windows Common Controls 20 | #endif // _AFX_NO_AFXCMN_SUPPORT 21 | 22 | 23 | //{{AFX_INSERT_LOCATION}} 24 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 25 | 26 | #endif // !defined(AFX_STDAFX_H__3BF6CD25_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 27 | -------------------------------------------------------------------------------- /Examples/NETMETER/netmeterDoc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #include "stdafx.h" 35 | #include "netmeter.h" 36 | 37 | #include "netmeterDoc.h" 38 | 39 | #ifdef _DEBUG 40 | #define new DEBUG_NEW 41 | #undef THIS_FILE 42 | static char THIS_FILE[] = __FILE__; 43 | #endif 44 | 45 | ///////////////////////////////////////////////////////////////////////////// 46 | // CNetmeterDoc 47 | 48 | IMPLEMENT_DYNCREATE(CNetmeterDoc, CDocument) 49 | 50 | BEGIN_MESSAGE_MAP(CNetmeterDoc, CDocument) 51 | //{{AFX_MSG_MAP(CNetmeterDoc) 52 | //}}AFX_MSG_MAP 53 | END_MESSAGE_MAP() 54 | 55 | ///////////////////////////////////////////////////////////////////////////// 56 | // CNetmeterDoc construction/destruction 57 | 58 | CNetmeterDoc::CNetmeterDoc() 59 | { 60 | } 61 | 62 | CNetmeterDoc::~CNetmeterDoc() 63 | { 64 | } 65 | 66 | BOOL CNetmeterDoc::OnNewDocument() 67 | { 68 | if (!CDocument::OnNewDocument()) 69 | return FALSE; 70 | 71 | return TRUE; 72 | } 73 | 74 | 75 | 76 | ///////////////////////////////////////////////////////////////////////////// 77 | // CNetmeterDoc serialization 78 | 79 | void CNetmeterDoc::Serialize(CArchive& ar) 80 | { 81 | if (ar.IsStoring()) 82 | { 83 | } 84 | else 85 | { 86 | } 87 | } 88 | 89 | ///////////////////////////////////////////////////////////////////////////// 90 | // CNetmeterDoc diagnostics 91 | 92 | #ifdef _DEBUG 93 | void CNetmeterDoc::AssertValid() const 94 | { 95 | CDocument::AssertValid(); 96 | } 97 | 98 | void CNetmeterDoc::Dump(CDumpContext& dc) const 99 | { 100 | CDocument::Dump(dc); 101 | } 102 | #endif //_DEBUG 103 | 104 | ///////////////////////////////////////////////////////////////////////////// 105 | // CNetmeterDoc commands 106 | -------------------------------------------------------------------------------- /Examples/NETMETER/netmeterDoc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | // netmeterDoc.h : interface of the CNetmeterDoc class 35 | // 36 | ///////////////////////////////////////////////////////////////////////////// 37 | 38 | #if !defined(AFX_NETMETERDOC_H__3BF6CD29_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 39 | #define AFX_NETMETERDOC_H__3BF6CD29_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_ 40 | 41 | #if _MSC_VER > 1000 42 | #pragma once 43 | #endif // _MSC_VER > 1000 44 | 45 | 46 | class CNetmeterDoc : public CDocument 47 | { 48 | protected: // create from serialization only 49 | CNetmeterDoc(); 50 | DECLARE_DYNCREATE(CNetmeterDoc) 51 | 52 | // Attributes 53 | public: 54 | 55 | // Operations 56 | public: 57 | 58 | // Overrides 59 | // ClassWizard generated virtual function overrides 60 | //{{AFX_VIRTUAL(CNetmeterDoc) 61 | public: 62 | virtual BOOL OnNewDocument(); 63 | virtual void Serialize(CArchive& ar); 64 | //}}AFX_VIRTUAL 65 | 66 | // Implementation 67 | public: 68 | virtual ~CNetmeterDoc(); 69 | #ifdef _DEBUG 70 | virtual void AssertValid() const; 71 | virtual void Dump(CDumpContext& dc) const; 72 | #endif 73 | 74 | protected: 75 | 76 | // Generated message map functions 77 | protected: 78 | //{{AFX_MSG(CNetmeterDoc) 79 | //}}AFX_MSG 80 | DECLARE_MESSAGE_MAP() 81 | }; 82 | 83 | ///////////////////////////////////////////////////////////////////////////// 84 | 85 | //{{AFX_INSERT_LOCATION}} 86 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 87 | 88 | #endif // !defined(AFX_NETMETERDOC_H__3BF6CD29_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 89 | -------------------------------------------------------------------------------- /Examples/NETMETER/netmeterView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies 16 | * nor the names of its contributors may be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #if !defined(AFX_NETMETERVIEW_H__3BF6CD2B_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 35 | #define AFX_NETMETERVIEW_H__3BF6CD2B_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_ 36 | 37 | #if _MSC_VER > 1000 38 | #pragma once 39 | #endif // _MSC_VER > 1000 40 | 41 | class CNetmeterView : public CView 42 | { 43 | protected: // create from serialization only 44 | CRITICAL_SECTION Crit; 45 | CWinThread* thr; 46 | CString StartCapture(); 47 | void StopCapture(); 48 | CNetmeterView(); 49 | DECLARE_DYNCREATE(CNetmeterView) 50 | // Attributes 51 | public: 52 | CPen gridpen; 53 | CPen diagrampen1; 54 | CPen diagrampen2; 55 | UINT BytesCaptured; 56 | int lastval1,lastval2; 57 | CDC DrawBuffer; 58 | int time; 59 | int delta; 60 | int TimeSlice; 61 | CString Adapter; 62 | RECT wrett; 63 | HBITMAP hBitmap; 64 | CNetmeterDoc* GetDocument(); 65 | void DrawBoard(CDC* pDC,RECT rett,int height1,int height2); 66 | void CreateBoard(CDC* pDC,CDC *DrawBuff,RECT rett); 67 | // Operations 68 | public: 69 | // Overrides 70 | // ClassWizard generated virtual function overrides 71 | //{{AFX_VIRTUAL(CNetmeterView) 72 | public: 73 | virtual void OnDraw(CDC* pDC); // overridden to draw this view 74 | virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 75 | protected: 76 | //}}AFX_VIRTUAL 77 | 78 | // Implementation 79 | public: 80 | virtual ~CNetmeterView(); 81 | #ifdef _DEBUG 82 | virtual void AssertValid() const; 83 | virtual void Dump(CDumpContext& dc) const; 84 | #endif 85 | 86 | protected: 87 | 88 | // Generated message map functions 89 | protected: 90 | //{{AFX_MSG(CNetmeterView) 91 | afx_msg void OnTimer(UINT nIDEvent); 92 | afx_msg void OnSelAdapter(); 93 | //}}AFX_MSG 94 | DECLARE_MESSAGE_MAP() 95 | }; 96 | 97 | #ifndef _DEBUG // debug version in netmeterView.cpp 98 | inline CNetmeterDoc* CNetmeterView::GetDocument() 99 | { return (CNetmeterDoc*)m_pDocument; } 100 | #endif 101 | 102 | ///////////////////////////////////////////////////////////////////////////// 103 | 104 | //{{AFX_INSERT_LOCATION}} 105 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 106 | 107 | #endif // !defined(AFX_NETMETERVIEW_H__3BF6CD2B_6C2B_11D3_B76F_0080C8DF82B3__INCLUDED_) 108 | -------------------------------------------------------------------------------- /Examples/NETMETER/res/BMP00001.BMP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nmap/npcap/33105960dc380d2f22ab853a931fb5b915b4ba62/Examples/NETMETER/res/BMP00001.BMP -------------------------------------------------------------------------------- /Examples/NETMETER/res/bitmap1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nmap/npcap/33105960dc380d2f22ab853a931fb5b915b4ba62/Examples/NETMETER/res/bitmap1.bmp -------------------------------------------------------------------------------- /Examples/NETMETER/res/bitmap2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nmap/npcap/33105960dc380d2f22ab853a931fb5b915b4ba62/Examples/NETMETER/res/bitmap2.bmp -------------------------------------------------------------------------------- /Examples/NETMETER/res/cap_wizi.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nmap/npcap/33105960dc380d2f22ab853a931fb5b915b4ba62/Examples/NETMETER/res/cap_wizi.bmp -------------------------------------------------------------------------------- /Examples/NETMETER/res/listbmp.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nmap/npcap/33105960dc380d2f22ab853a931fb5b915b4ba62/Examples/NETMETER/res/listbmp.bmp -------------------------------------------------------------------------------- /Examples/NETMETER/res/netmeter.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nmap/npcap/33105960dc380d2f22ab853a931fb5b915b4ba62/Examples/NETMETER/res/netmeter.ico -------------------------------------------------------------------------------- /Examples/NETMETER/res/netmeter.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // NETMETER.RC2 - resources Microsoft Visual C++ does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by Microsoft Visual C++ 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | ///////////////////////////////////////////////////////////////////////////// 11 | // Add manually edited resources here... 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | -------------------------------------------------------------------------------- /Examples/NETMETER/res/netmeterDoc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nmap/npcap/33105960dc380d2f22ab853a931fb5b915b4ba62/Examples/NETMETER/res/netmeterDoc.ico -------------------------------------------------------------------------------- /Examples/NETMETER/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by netmeter.rc 4 | // 5 | #define IDD_ABOUTBOX 100 6 | #define IDR_MAINFRAME 128 7 | #define IDR_NETMETTYPE 129 8 | #define IDB_YELLOW 133 9 | #define IDB_BLUE 134 10 | #define IDB_YELL 135 11 | #define IDB_CAP_WIZ 175 12 | #define IDD_ADAPTER 180 13 | #define IDC_ADAPTER 1000 14 | #define IDC_LIST1 3109 15 | #define seladapter 32771 16 | 17 | // Next default values for new objects 18 | // 19 | #ifdef APSTUDIO_INVOKED 20 | #ifndef APSTUDIO_READONLY_SYMBOLS 21 | #define _APS_NEXT_RESOURCE_VALUE 137 22 | #define _APS_NEXT_COMMAND_VALUE 32772 23 | #define _APS_NEXT_CONTROL_VALUE 1000 24 | #define _APS_NEXT_SYMED_VALUE 101 25 | #endif 26 | #endif 27 | -------------------------------------------------------------------------------- /Examples/PacketDriver/readme.txt: -------------------------------------------------------------------------------- 1 | These files use the packet.dll API instead of wpcap.dll. 2 | The use of packet.dll API is strongly discouraged. 3 | -------------------------------------------------------------------------------- /Examples/iflist/iflist.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Examples/misc/basic_dump.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "misc.h" 3 | #include 4 | 5 | /* prototype of the packet handler */ 6 | void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data); 7 | 8 | int main() 9 | { 10 | pcap_if_t *alldevs; 11 | pcap_if_t *d; 12 | int inum; 13 | int i=0; 14 | pcap_t *adhandle; 15 | char errbuf[PCAP_ERRBUF_SIZE]; 16 | 17 | /* Load Npcap and its functions. */ 18 | if (!LoadNpcapDlls()) 19 | { 20 | fprintf(stderr, "Couldn't load Npcap\n"); 21 | exit(1); 22 | } 23 | 24 | /* Retrieve the device list on the local machine */ 25 | if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) 26 | { 27 | fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf); 28 | exit(1); 29 | } 30 | 31 | /* Print the list */ 32 | for(d=alldevs; d; d=d->next) 33 | { 34 | printf("%d. %s", ++i, d->name); 35 | if (d->description) 36 | printf(" (%s)\n", d->description); 37 | else 38 | printf(" (No description available)\n"); 39 | } 40 | 41 | if(i==0) 42 | { 43 | printf("\nNo interfaces found! Make sure Npcap is installed.\n"); 44 | return -1; 45 | } 46 | 47 | printf("Enter the interface number (1-%d):",i); 48 | scanf_s("%d", &inum); 49 | 50 | if(inum < 1 || inum > i) 51 | { 52 | printf("\nInterface number out of range.\n"); 53 | /* Free the device list */ 54 | pcap_freealldevs(alldevs); 55 | return -1; 56 | } 57 | 58 | /* Jump to the selected adapter */ 59 | for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++); 60 | 61 | /* Open the device */ 62 | if ( (adhandle= pcap_open(d->name, // name of the device 63 | 65536, // portion of the packet to capture 64 | // 65536 guarantees that the whole packet will be captured on all the link layers 65 | PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode 66 | 1000, // read timeout 67 | NULL, // authentication on the remote machine 68 | errbuf // error buffer 69 | ) ) == NULL) 70 | { 71 | fprintf(stderr,"\nUnable to open the adapter. %s is not supported by Npcap\n", d->name); 72 | /* Free the device list */ 73 | pcap_freealldevs(alldevs); 74 | return -1; 75 | } 76 | 77 | printf("\nlistening on %s...\n", d->description); 78 | 79 | /* At this point, we don't need any more the device list. Free it */ 80 | pcap_freealldevs(alldevs); 81 | 82 | /* start the capture */ 83 | pcap_loop(adhandle, 0, packet_handler, NULL); 84 | 85 | return 0; 86 | } 87 | 88 | 89 | /* Callback function invoked by libpcap for every incoming packet */ 90 | void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data) 91 | { 92 | struct tm ltime; 93 | char timestr[16]; 94 | time_t local_tv_sec; 95 | 96 | /* 97 | * unused variables 98 | */ 99 | (VOID)(param); 100 | (VOID)(pkt_data); 101 | 102 | /* convert the timestamp to readable format */ 103 | local_tv_sec = header->ts.tv_sec; 104 | localtime_s(<ime, &local_tv_sec); 105 | strftime( timestr, sizeof timestr, "%H:%M:%S", <ime); 106 | 107 | printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len); 108 | 109 | } 110 | -------------------------------------------------------------------------------- /Examples/misc/basic_dump_ex.c: -------------------------------------------------------------------------------- 1 | #include "pcap.h" 2 | #include 3 | 4 | 5 | int main() 6 | { 7 | pcap_if_t *alldevs; 8 | pcap_if_t *d; 9 | int inum; 10 | int i=0; 11 | pcap_t *adhandle; 12 | int res; 13 | char errbuf[PCAP_ERRBUF_SIZE]; 14 | struct tm ltime; 15 | char timestr[16]; 16 | struct pcap_pkthdr *header; 17 | const u_char *pkt_data; 18 | time_t local_tv_sec; 19 | 20 | 21 | /* Retrieve the device list on the local machine */ 22 | if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) 23 | { 24 | fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf); 25 | exit(1); 26 | } 27 | 28 | /* Print the list */ 29 | for(d=alldevs; d; d=d->next) 30 | { 31 | printf("%d. %s", ++i, d->name); 32 | if (d->description) 33 | printf(" (%s)\n", d->description); 34 | else 35 | printf(" (No description available)\n"); 36 | } 37 | 38 | if(i==0) 39 | { 40 | printf("\nNo interfaces found! Make sure Npcap is installed.\n"); 41 | return -1; 42 | } 43 | 44 | printf("Enter the interface number (1-%d):",i); 45 | scanf_s("%d", &inum); 46 | 47 | if(inum < 1 || inum > i) 48 | { 49 | printf("\nInterface number out of range.\n"); 50 | /* Free the device list */ 51 | pcap_freealldevs(alldevs); 52 | return -1; 53 | } 54 | 55 | /* Jump to the selected adapter */ 56 | for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++); 57 | 58 | /* Open the device */ 59 | if ( (adhandle= pcap_open(d->name, // name of the device 60 | 65536, // portion of the packet to capture. 61 | // 65536 guarantees that the whole packet will be captured on all the link layers 62 | PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode 63 | 1000, // read timeout 64 | NULL, // authentication on the remote machine 65 | errbuf // error buffer 66 | ) ) == NULL) 67 | { 68 | fprintf(stderr,"\nUnable to open the adapter. %s is not supported by Npcap\n", d->name); 69 | /* Free the device list */ 70 | pcap_freealldevs(alldevs); 71 | return -1; 72 | } 73 | 74 | printf("\nlistening on %s...\n", d->description); 75 | 76 | /* At this point, we don't need any more the device list. Free it */ 77 | pcap_freealldevs(alldevs); 78 | 79 | /* Retrieve the packets */ 80 | while((res = pcap_next_ex( adhandle, &header, &pkt_data)) >= 0){ 81 | 82 | if(res == 0) 83 | /* Timeout elapsed */ 84 | continue; 85 | 86 | /* convert the timestamp to readable format */ 87 | local_tv_sec = header->ts.tv_sec; 88 | localtime_s(<ime, &local_tv_sec); 89 | strftime( timestr, sizeof timestr, "%H:%M:%S", <ime); 90 | 91 | printf("%s,%.6d len:%d\n", timestr, header->ts.tv_usec, header->len); 92 | } 93 | 94 | if(res == -1){ 95 | printf("Error reading the packets: %s\n", pcap_geterr(adhandle)); 96 | return -1; 97 | } 98 | 99 | return 0; 100 | } 101 | -------------------------------------------------------------------------------- /Examples/misc/misc.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | BOOL LoadNpcapDlls() 4 | { 5 | _TCHAR npcap_dir[512]; 6 | UINT len; 7 | len = GetSystemDirectory(npcap_dir, 480); 8 | if (!len) { 9 | fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError()); 10 | return FALSE; 11 | } 12 | _tcscat_s(npcap_dir, 512, _T("\\Npcap")); 13 | if (SetDllDirectory(npcap_dir) == 0) { 14 | fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError()); 15 | return FALSE; 16 | } 17 | return TRUE; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /Examples/misc/readfile.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "misc.h" 4 | 5 | #define LINE_LEN 16 6 | 7 | void dispatcher_handler(u_char *, const struct pcap_pkthdr *, const u_char *); 8 | 9 | int main(int argc, char **argv) 10 | { 11 | pcap_t *fp; 12 | char errbuf[PCAP_ERRBUF_SIZE]; 13 | char source[PCAP_BUF_SIZE]; 14 | 15 | /* Load Npcap and its functions. */ 16 | if (!LoadNpcapDlls()) 17 | { 18 | fprintf(stderr, "Couldn't load Npcap\n"); 19 | exit(1); 20 | } 21 | 22 | if(argc != 2){ 23 | 24 | printf("usage: %s filename", argv[0]); 25 | return -1; 26 | 27 | } 28 | 29 | /* Create the source string according to the new WinPcap syntax */ 30 | if ( pcap_createsrcstr( source, // variable that will keep the source string 31 | PCAP_SRC_FILE, // we want to open a file 32 | NULL, // remote host 33 | NULL, // port on the remote host 34 | argv[1], // name of the file we want to open 35 | errbuf // error buffer 36 | ) != 0) 37 | { 38 | fprintf(stderr,"\nError creating a source string\n"); 39 | return -1; 40 | } 41 | 42 | /* Open the capture file */ 43 | if ( (fp= pcap_open(source, // name of the device 44 | 65536, // portion of the packet to capture 45 | // 65536 guarantees that the whole packet will be captured on all the link layers 46 | PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode 47 | 1000, // read timeout 48 | NULL, // authentication on the remote machine 49 | errbuf // error buffer 50 | ) ) == NULL) 51 | { 52 | fprintf(stderr,"\nUnable to open the file %s.\n", source); 53 | return -1; 54 | } 55 | 56 | // read and dispatch packets until EOF is reached 57 | pcap_loop(fp, 0, dispatcher_handler, NULL); 58 | 59 | return 0; 60 | } 61 | 62 | 63 | 64 | void dispatcher_handler(u_char *temp1, 65 | const struct pcap_pkthdr *header, const u_char *pkt_data) 66 | { 67 | u_int i=0; 68 | 69 | /* 70 | * Unused variable 71 | */ 72 | (VOID)temp1; 73 | 74 | /* print pkt timestamp and pkt len */ 75 | printf("%ld:%ld (%ld)\n", header->ts.tv_sec, header->ts.tv_usec, header->len); 76 | 77 | /* Print the packet */ 78 | for (i=1; (i < header->caplen + 1 ) ; i++) 79 | { 80 | printf("%.2x ", pkt_data[i-1]); 81 | if ( (i % LINE_LEN) == 0) printf("\n"); 82 | } 83 | 84 | printf("\n\n"); 85 | 86 | } 87 | -------------------------------------------------------------------------------- /Examples/misc/readfile_ex.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "misc.h" 4 | 5 | #define LINE_LEN 16 6 | 7 | int main(int argc, char **argv) 8 | { 9 | pcap_t *fp; 10 | char errbuf[PCAP_ERRBUF_SIZE]; 11 | char source[PCAP_BUF_SIZE]; 12 | struct pcap_pkthdr *header; 13 | const u_char *pkt_data; 14 | u_int i=0; 15 | int res; 16 | 17 | /* Load Npcap and its functions. */ 18 | if (!LoadNpcapDlls()) 19 | { 20 | fprintf(stderr, "Couldn't load Npcap\n"); 21 | exit(1); 22 | } 23 | 24 | if(argc != 2) 25 | { 26 | printf("usage: %s filename", argv[0]); 27 | return -1; 28 | } 29 | 30 | /* Create the source string according to the new WinPcap syntax */ 31 | if ( pcap_createsrcstr( source, // variable that will keep the source string 32 | PCAP_SRC_FILE, // we want to open a file 33 | NULL, // remote host 34 | NULL, // port on the remote host 35 | argv[1], // name of the file we want to open 36 | errbuf // error buffer 37 | ) != 0) 38 | { 39 | fprintf(stderr,"\nError creating a source string\n"); 40 | return -1; 41 | } 42 | 43 | /* Open the capture file */ 44 | if ( (fp= pcap_open(source, // name of the device 45 | 65536, // portion of the packet to capture 46 | // 65536 guarantees that the whole packet will be captured on all the link layers 47 | PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode 48 | 1000, // read timeout 49 | NULL, // authentication on the remote machine 50 | errbuf // error buffer 51 | ) ) == NULL) 52 | { 53 | fprintf(stderr,"\nUnable to open the file %s.\n", source); 54 | return -1; 55 | } 56 | 57 | /* Retrieve the packets from the file */ 58 | while((res = pcap_next_ex( fp, &header, &pkt_data)) >= 0) 59 | { 60 | /* print pkt timestamp and pkt len */ 61 | printf("%ld:%ld (%ld)\n", header->ts.tv_sec, header->ts.tv_usec, header->len); 62 | 63 | /* Print the packet */ 64 | for (i=1; (i < header->caplen + 1 ) ; i++) 65 | { 66 | printf("%.2x ", pkt_data[i-1]); 67 | if ( (i % LINE_LEN) == 0) printf("\n"); 68 | } 69 | 70 | printf("\n\n"); 71 | } 72 | 73 | 74 | if (res == -1) 75 | { 76 | printf("Error reading the packets: %s\n", pcap_geterr(fp)); 77 | } 78 | 79 | return 0; 80 | } 81 | 82 | -------------------------------------------------------------------------------- /Examples/misc/savedump.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "misc.h" 3 | 4 | /* prototype of the packet handler */ 5 | void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data); 6 | 7 | int main(int argc, char **argv) 8 | { 9 | pcap_if_t *alldevs; 10 | pcap_if_t *d; 11 | int inum; 12 | int i=0; 13 | pcap_t *adhandle; 14 | char errbuf[PCAP_ERRBUF_SIZE]; 15 | pcap_dumper_t *dumpfile; 16 | 17 | /* Load Npcap and its functions. */ 18 | if (!LoadNpcapDlls()) 19 | { 20 | fprintf(stderr, "Couldn't load Npcap\n"); 21 | exit(1); 22 | } 23 | 24 | /* Check command line */ 25 | if(argc != 2) 26 | { 27 | printf("usage: %s filename", argv[0]); 28 | return -1; 29 | } 30 | 31 | /* Retrieve the device list on the local machine */ 32 | if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) 33 | { 34 | fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf); 35 | exit(1); 36 | } 37 | 38 | /* Print the list */ 39 | for(d=alldevs; d; d=d->next) 40 | { 41 | printf("%d. %s", ++i, d->name); 42 | if (d->description) 43 | printf(" (%s)\n", d->description); 44 | else 45 | printf(" (No description available)\n"); 46 | } 47 | 48 | if(i==0) 49 | { 50 | printf("\nNo interfaces found! Make sure Npcap is installed.\n"); 51 | return -1; 52 | } 53 | 54 | printf("Enter the interface number (1-%d):",i); 55 | scanf_s("%d", &inum); 56 | 57 | if(inum < 1 || inum > i) 58 | { 59 | printf("\nInterface number out of range.\n"); 60 | /* Free the device list */ 61 | pcap_freealldevs(alldevs); 62 | return -1; 63 | } 64 | 65 | /* Jump to the selected adapter */ 66 | for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++); 67 | 68 | 69 | /* Open the device */ 70 | if ( (adhandle= pcap_open(d->name, // name of the device 71 | 65536, // portion of the packet to capture 72 | // 65536 guarantees that the whole packet will be captured on all the link layers 73 | PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode 74 | 1000, // read timeout 75 | NULL, // authentication on the remote machine 76 | errbuf // error buffer 77 | ) ) == NULL) 78 | { 79 | fprintf(stderr,"\nUnable to open the adapter. %s is not supported by Npcap\n", d->name); 80 | /* Free the device list */ 81 | pcap_freealldevs(alldevs); 82 | return -1; 83 | } 84 | 85 | /* Open the dump file */ 86 | dumpfile = pcap_dump_open(adhandle, argv[1]); 87 | 88 | if(dumpfile==NULL) 89 | { 90 | fprintf(stderr,"\nError opening output file\n"); 91 | return -1; 92 | } 93 | 94 | printf("\nlistening on %s... Press Ctrl+C to stop...\n", d->description); 95 | 96 | /* At this point, we no longer need the device list. Free it */ 97 | pcap_freealldevs(alldevs); 98 | 99 | /* start the capture */ 100 | pcap_loop(adhandle, 0, packet_handler, (unsigned char *)dumpfile); 101 | 102 | return 0; 103 | } 104 | 105 | /* Callback function invoked by libpcap for every incoming packet */ 106 | void packet_handler(u_char *dumpfile, const struct pcap_pkthdr *header, const u_char *pkt_data) 107 | { 108 | /* save the packet on the dump file */ 109 | pcap_dump(dumpfile, header, pkt_data); 110 | } 111 | -------------------------------------------------------------------------------- /Examples/misc/sendpack.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include "misc.h" 6 | 7 | 8 | void main(int argc, char **argv) 9 | { 10 | pcap_t *fp; 11 | char errbuf[PCAP_ERRBUF_SIZE]; 12 | u_char packet[100]; 13 | int i; 14 | 15 | /* Load Npcap and its functions. */ 16 | if (!LoadNpcapDlls()) 17 | { 18 | fprintf(stderr, "Couldn't load Npcap\n"); 19 | exit(1); 20 | } 21 | 22 | /* Check the validity of the command line */ 23 | if (argc != 2) 24 | { 25 | printf("usage: %s interface (e.g. 'rpcap://eth0')", argv[0]); 26 | return; 27 | } 28 | 29 | /* Open the output device */ 30 | if ( (fp= pcap_open(argv[1], // name of the device 31 | 100, // portion of the packet to capture (only the first 100 bytes) 32 | PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode 33 | 1000, // read timeout 34 | NULL, // authentication on the remote machine 35 | errbuf // error buffer 36 | ) ) == NULL) 37 | { 38 | fprintf(stderr,"\nUnable to open the adapter. %s is not supported by Npcap\n", argv[1]); 39 | return; 40 | } 41 | 42 | i = 0; 43 | switch(pcap_datalink(fp)) 44 | { 45 | case DLT_NULL: 46 | // Pretend IPv4 47 | packet[i++] = 2; 48 | packet[i++] = 0; 49 | packet[i++] = 0; 50 | packet[i++] = 0; 51 | break; 52 | case DLT_EN10MB: 53 | /* Supposing to be on ethernet, set mac destination to 1:1:1:1:1:1 */ 54 | while (i < 6) 55 | packet[i++]=1; 56 | 57 | /* set mac source to 2:2:2:2:2:2 */ 58 | while (i < 12) 59 | packet[i++]=2; 60 | break; 61 | default: 62 | fprintf(stderr, "\nError, unknown data-link type %u\n", pcap_datalink(fp)); 63 | return 4; 64 | } 65 | 66 | /* Fill the rest of the packet */ 67 | for(;i<100;i++) 68 | { 69 | packet[i]=(u_char)i; 70 | } 71 | 72 | /* Send down the packet */ 73 | if (pcap_sendpacket(fp, packet, 100 /* size */) != 0) 74 | { 75 | fprintf(stderr,"\nError sending the packet: %s\n", pcap_geterr(fp)); 76 | return; 77 | } 78 | 79 | return; 80 | } 81 | -------------------------------------------------------------------------------- /Examples/pcap_fopen/pcap_fopen.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 CACE Technologies, Davis (California) 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of CACE Technologies nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * This sample was contributed by 31 | * Marcin Okraszewski (Marcin.OkraszewskiATpl.compuware.com) 32 | * 33 | */ 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | BOOL LoadNpcapDlls() 40 | { 41 | _TCHAR npcap_dir[512]; 42 | UINT len; 43 | len = GetSystemDirectory(npcap_dir, 480); 44 | if (!len) { 45 | fprintf(stderr, "Error in GetSystemDirectory: %x", GetLastError()); 46 | return FALSE; 47 | } 48 | _tcscat_s(npcap_dir, 512, _T("\\Npcap")); 49 | if (SetDllDirectory(npcap_dir) == 0) { 50 | fprintf(stderr, "Error in SetDllDirectory: %x", GetLastError()); 51 | return FALSE; 52 | } 53 | return TRUE; 54 | } 55 | 56 | /** Prints packet timestaps regardless of format*/ 57 | int _tmain(int argc, _TCHAR* argv[]) 58 | { 59 | char errbuf[PCAP_ERRBUF_SIZE]; 60 | _TCHAR cmd[1024]; 61 | _TCHAR tshark_path[MAX_PATH]; 62 | _TCHAR file_path[MAX_PATH]; 63 | 64 | /* Load Npcap and its functions. */ 65 | if (!LoadNpcapDlls()) 66 | { 67 | fprintf(stderr, "Couldn't load Npcap\n"); 68 | exit(1); 69 | } 70 | 71 | if ( argc != 3 ) { 72 | _tprintf(_T("Prints packet timestaps regardless of format.\n")); 73 | _tprintf(_T("Usage:\n\t%s \n"), argv[0]); 74 | return 1; 75 | } 76 | 77 | // conversion to short path name in case there are spaces 78 | if ( ! GetShortPathName(argv[1], tshark_path, MAX_PATH) || 79 | ! GetShortPathName(argv[2], file_path, MAX_PATH) ) 80 | { 81 | _tprintf(_T("Failed to convert paths to short form.")); 82 | return 1; 83 | } 84 | 85 | // create tshark command, which will make the trace conversion and print in libpcap format to stdout 86 | if ( _stprintf_s(cmd, 1024, _T("%s -r %s -w - -F libpcap"), tshark_path, file_path) < 0 ) { 87 | _tprintf(_T("Failed to create command\n")); 88 | return 1; 89 | } 90 | 91 | // start tshark 92 | FILE *tshark_out = _tpopen(cmd, _T("rb")); 93 | if ( tshark_out == NULL ) { 94 | strerror_s(errbuf, PCAP_ERRBUF_SIZE, errno); 95 | printf("Failed run tshark: %s\n", errbuf); 96 | _tprintf(_T("Command: %s"), cmd); 97 | return 1; 98 | } 99 | 100 | // open stdout from tshark 101 | pcap_t *pcap = pcap_fopen_offline(tshark_out, errbuf); 102 | if ( pcap == NULL ) { 103 | printf("Error opening stream from tshark: %s\n", errbuf); 104 | return 1; 105 | } 106 | 107 | // print information about every packet int trace 108 | struct pcap_pkthdr hdr; 109 | while ( pcap_next(pcap, &hdr) ) { 110 | printf("packet: ts: %u.%06u, len: %4u, caplen: %4u\n", hdr.ts.tv_sec, hdr.ts.tv_usec, hdr.len, hdr.caplen); 111 | } 112 | 113 | // clean up 114 | pcap_close(pcap); 115 | _pclose(tshark_out); 116 | return 0; 117 | } 118 | 119 | -------------------------------------------------------------------------------- /Examples/sendcap/sendcap.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Npcap_Guide.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Npcap Guide 7 | 10 | 11 | 12 |

The Npcap Guide is located in the "docs" directory. 13 | You can also find the latest version of the Guide on Npcap.com. 14 |

15 | 16 | 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Npcap 2 | ========== 3 | 4 | [![Build status](https://ci.appveyor.com/api/projects/status/woero8l6qhgy4syx?svg=true)](https://ci.appveyor.com/project/dmiller-nmap/npcap) 5 | ![Environment](https://img.shields.io/badge/Windows-7,%208,%208.1,%2010,%2011-brightgreen.svg) 6 | [![Release](https://img.shields.io/github/release/nmap/npcap.svg)](https://npcap.com/#download) 7 | [![Issues](https://img.shields.io/github/issues/nmap/npcap.svg)](https://github.com/nmap/npcap/issues) 8 | 9 | [**Npcap**](https://npcap.com) is a packet capture and injection library for 10 | Windows by the [**Nmap Project**](https://nmap.org). It is a complete update to 11 | the unmaintained [**WinPcap**](http://www.winpcap.org/) project with improved 12 | speed, reliability, and security. 13 | 14 | ## Documentation 15 | 16 | The complete documentation for Npcap is available in the [Npcap 17 | Guide](https://npcap.com/guide/) on [npcap.com](https://npcap.com/). There you 18 | will find information about 19 | [installation](https://npcap.com/guide/npcap-users-guide.html#npcap-installation), 20 | [reporting 21 | bugs](https://npcap.com/guide/npcap-users-guide.html#npcap-issues), 22 | [developing software with 23 | Npcap](https://npcap.com/guide/npcap-devguide.html), and [Npcap 24 | internals](https://npcap.com/guide/npcap-internals.html). 25 | 26 | ## Downloads 27 | 28 | The latest installer, Software Development Kit (SDK), source, and debug symbols 29 | can be downloaded from https://npcap.com/#download 30 | 31 | ## Bug report 32 | 33 | Please report any bugs or issues about Npcap at: [Npcap issues on 34 | GitHub](https://github.com/nmap/npcap/issues). In your report, please provide 35 | your 36 | [**DiagReport**](https://npcap.com/guide/npcap-users-guide.html#npcap-issues-diagreport) 37 | output, user software version (e.g. Nmap, Wireshark), reproduce steps and other 38 | information you think necessary. Refer to [the Npcap Guide section on reporting 39 | bugs](https://npcap.com/guide/npcap-users-guide.html#npcap-issues) for more 40 | complete directions. 41 | 42 | ## License 43 | 44 | The [Npcap License](https://github.com/nmap/npcap/blob/master/LICENSE) allows 45 | end users to download, install, and use Npcap from our site for free on up to 5 46 | systems (including commercial usage). Software providers (open source or 47 | otherwise) which want to use Npcap functionality are welcome to point their 48 | users to [npcap.com](https://npcap.com/) for those users to download and install. 49 | 50 | We fund the Npcap project by selling [Npcap OEM](https://npcap.com/oem/). This 51 | special version of Npcap includes enterprise features such as the silent 52 | installer and commercial support as well as special license rights. 53 | 54 | 55 | ## Contact 56 | 57 | * ``dev@nmap.org`` (Nmap development list, for technical issues and discussion) 58 | * ``sales@nmap.com`` (Sales address for commercial/licensing issues) 59 | * [Npcap Issues Tracker](https://github.com/nmap/npcap/issues/) 60 | -------------------------------------------------------------------------------- /SDK_CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## Unreleased changes 2 | 3 | * Renamed the `SKF_AD_*` constants to `NPCAP_AD_*` to avoid confusion with code 4 | that may expect the same values or ordering as the constants defined by 5 | Linux. The old names are still conditionally defined for convenience. 6 | 7 | ## Npcap SDK 1.15 [2025] 8 | 9 | * Added a new function, `PacketGetInfo()`. This uses the `PACKET_OID_DATA` 10 | structure to issue information requests to the Npcap driver. Currently 11 | defined requests are `NPF_GETINFO_VERSION`, `NPF_GETINFO_CONFIG`, and 12 | `NPF_GETINFO_BPFEXT`. 13 | 14 | * Using `PacketGetInfo()` with `NPF_GETINFO_BPFEXT` allows user code to 15 | determine which BPF extensions are supported by the driver. The first 16 | extensions supported by the driver will be `SKF_AD_VLAN_TAG` and 17 | `SKF_AD_VLAN_TAG_PRESENT`, which have the same meanings as the Linux kernel's 18 | BPF extensions of the same names. 19 | 20 | * Moved Npcap's BPF definitions to `npcap-bpf.h` and other definitions to 21 | `npcap-defs.h` to allow them to be used independently of `Packet32.h`. They 22 | are included by `Packet32.h`, so there should be no need to change existing 23 | code. 24 | 25 | ## Npcap SDK 1.14 [2022-08-18] 26 | 27 | * Restored `PacketLibraryVersion` export. It is still preferred to use 28 | `PacketGetVersion()` 29 | 30 | ## Npcap SDK 1.13 [2022-06-21] 31 | 32 | * Added SAL annotations to most function prototypes and several struct fields 33 | in `Packet32.h` 34 | 35 | * The undocumented `char PacketLibraryVersion[]` export has been removed from 36 | Npcap 1.70 and later. The `PacketGetVersion()` function is the documented way 37 | to get the runtime version of the Packet.dll library. 38 | 39 | * PacketGetNetType() now always sets the LinkSpeed field to 0. Many adapters 40 | did not support the OID that was being used to get the link speed, and 41 | libpcap (Npcap's published API) does not pass this information through, so 42 | there should be no impact on the majority of software. Software that needs 43 | link speed may use `pcap_oid_get_request()` or `GetAdaptersAddresses()` to 44 | get the information. 45 | 46 | ## Npcap SDK 1.12 [2021-12-06] 47 | 48 | * Added this changelog. 49 | 50 | * Included wpcap.lib for ARM64. 51 | 52 | * Updated `Examples-pcap/pcap_filter` to show modern API usage with 53 | `pcap_create()` and `pcap_activate()`. 54 | 55 | * Removed documentation and examples for the "kernel dump" feature of WinPcap, 56 | which has never been supported by Npcap and was disabled in WinPcap 3.1. The 57 | `Packet32.h` functions which supported this mode have been marked as 58 | deprecated. 59 | 60 | ## Npcap SDK 1.11 [2021-09-03] 61 | 62 | * Fix an issue with libpcap header files which required VS 2015 or later. This 63 | change was made to accommodate a few existing licensees. We strongly 64 | recommend using a currently-supported compiler version to build software with Npcap. 65 | 66 | * Added `const` qualifiers to input parameters for several `Packet32.h` functions. 67 | 68 | ## Npcap SDK 1.10 [2021-06-22] 69 | 70 | * ARM64 libs for Packet.dll added. 71 | 72 | * Updated documentation. 73 | 74 | ## Npcap SDK 1.07 [2021-03-10] 75 | 76 | * Updated libpcap headers to 1.10.1 from 1.9.1. See [the libpcap CHANGES 77 | file](https://github.com/the-tcpdump-group/libpcap/blob/libpcap-1.10/CHANGES) 78 | and issue [#276](http://issues.npcap.org/276) for notable changes. 79 | 80 | * Added `Packet32.h` functions to set per-handle time source and precision. 81 | This supports libpcap function `pcap_set_tstamp_type()` on Npcap 1.20 and 82 | later. 83 | 84 | 85 | ---- 86 | Earlier changes not tracked. 87 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # Notes: 2 | # - Minimal appveyor.yml file is an empty file. All sections are optional. 3 | # - Indent each level of configuration with 2 spaces. Do not use tabs! 4 | # - All section names are case-sensitive. 5 | # - Section names should be unique on each level. 6 | 7 | #---------------------------------# 8 | # general configuration # 9 | #---------------------------------# 10 | 11 | # version format 12 | version: 0.10.{build} 13 | 14 | # branches to build 15 | branches: 16 | # blacklist 17 | except: 18 | - gh-pages 19 | 20 | # Do not build on tags (GitHub only) 21 | skip_tags: true 22 | 23 | #---------------------------------# 24 | # environment configuration # 25 | #---------------------------------# 26 | 27 | image: Visual Studio 2022 28 | 29 | # clone directory 30 | clone_folder: C:\Npcap 31 | clone_depth: 10 32 | 33 | # environment variables 34 | environment: 35 | SignTool: C:\Program Files (x86)\Windows Kits\10\bin\x64 36 | 37 | # scripts that run after cloning repository 38 | install: 39 | # clone the submodules 40 | - cmd: git submodule update --init --recursive 41 | # install Win-Flex-Bison 42 | - cmd: cinst winflexbison -y 43 | 44 | #---------------------------------# 45 | # build configuration # 46 | #---------------------------------# 47 | 48 | # scripts to run before build 49 | # before_build: 50 | 51 | # scripts to run *after* solution is built and *before* automatic packaging occurs (web apps, NuGet packages, Azure Cloud Services) 52 | # before_package: 53 | 54 | # scripts to run after build 55 | # after_build: 56 | 57 | # to run your custom scripts instead of automatic MSBuild 58 | build_script: 59 | - cmd: cd installer 60 | - cmd: echo .| Build.bat 61 | 62 | # to disable automatic builds 63 | # build: off 64 | -------------------------------------------------------------------------------- /build_sdk.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | for /F tokens^=3^,4^ delims^=^"^ ^ %%A in (version.h) do if "%%A" == "NPCAP_SDK_VERSION" set SDK_VER=%%B 3 | if "%SDK_VER%" == "" goto :fail 4 | set SDKFILENAME=npcap-sdk-%SDK_VER%.zip 5 | 6 | if "%2"== "" ( rd /s/q ./npcap-sdk 2>nul >nul) else ( rd /s /q "%2" 2>nul >nul) 7 | 8 | SET TOPSRCDIR=%cd% 9 | 10 | rem Must build Npcap in order to have the lib files available (and to ensure it builds correctly!) 11 | cd installer 12 | call Build.bat 13 | cd %TOPSRCDIR% 14 | 15 | call create_include.bat %1 %2 16 | 17 | call create_lib.bat %1 %2 || goto :fail 18 | 19 | call create_examples.bat %1 %2 20 | 21 | rem Requires msys2 or cygwin, roffit, xsltproc and Docbook XSL stylesheets 22 | call create_docs.bat %1 %2 || goto :fail 23 | 24 | del %SDKFILENAME% 25 | copy SDK_CHANGELOG.md .\npcap-sdk\SDK_CHANGELOG.md 26 | 27 | cd .\npcap-sdk 28 | "C:\Program Files\7-Zip\7z.exe" a ..\%SDKFILENAME% . 29 | PAUSE 30 | 31 | exit /b 32 | :fail 33 | echo Failed! 34 | pause 35 | exit /b 1 36 | -------------------------------------------------------------------------------- /build_sdk.txt: -------------------------------------------------------------------------------- 1 | In order to build the developers' pack, you need to compile the various DLLs and then call build_sdk.bat 2 | This batch file, in turn, calls the four batches 3 | - create_includes.bat creates the include folder 4 | - create_lib.bat creates the lib folder 5 | - create_examples.bat copies the examples folder to the developers' pack. The examples can be compiled only under the developers' pack folder. 6 | - create_docs.bat creates the documentation (via Docbook XSL and Roffit), and then copies the generated files under the developers' pack folder. 7 | 8 | The syntax for the various scripts is 9 | 10 | winpcap_folder developer_folder 11 | 12 | winpcap_folder The winpcap sources folder. It is defaulted to .\ 13 | developer_folder The developers' pack folder. It is defaulted to .\npcap-sdk. 14 | 15 | HINT: just call build_sdk.bat without any parameter! 16 | 17 | -------------------------------------------------------------------------------- /build_test.bat: -------------------------------------------------------------------------------- 1 | SET MODE="Release" 2 | SET TOPSRCDIR=%cd% 3 | SET VERB=Build 4 | if NOT "%1" == "" SET VERB="%1" 5 | 6 | rem call build_sdk.bat || goto :error 7 | cd %TOPSRCDIR% 8 | 9 | Call :BUILD_TEST x86 || goto :error 10 | Call :BUILD_TEST x64 || goto :error 11 | Call :BUILD_TEST ARM64 || goto :error 12 | exit /b 13 | 14 | :BUILD_TEST 15 | set TOOLSET=%1 16 | if "%1" == "ARM64" set TOOLSET=amd64_arm64 17 | for /f "usebackq delims=#" %%a in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -version 17 -property installationPath`) do call "%%a\VC\Auxiliary\Build\vcvarsall.bat" %TOOLSET% 18 | if %ERRORLEVEL% NEQ 0 goto :error 19 | 20 | msbuild /p:ForceImportBeforeCppTargets="%CD%\test\static.props" ".\Examples-pcap\MakeAll.sln" /m /t:%VERB% /p:Configuration=%MODE% /p:Platform="%1" || goto :error 21 | msbuild /p:ForceImportBeforeCppTargets="%CD%\test\static.props" ".\Examples\sendcap\sendcap.vcxproj" /m /t:%VERB% /p:Configuration=%MODE% /p:Platform="%1" || goto :error 22 | if NOT "%VERB%" == "Build" goto :EOF 23 | 24 | set BINDIR=%1\ 25 | if "%1" == "x86" set BINDIR="" 26 | 27 | mkdir test\%1\ 28 | copy /b ".\Examples-pcap\%BINDIR%%MODE%\iflist.exe" test\%1\ 29 | copy /b ".\Examples-pcap\%BINDIR%%MODE%\pcap_filter.exe" test\%1\ 30 | copy /b ".\Examples-pcap\%BINDIR%%MODE%\sendpack.exe" test\%1\ 31 | copy /b ".\Examples-pcap\%BINDIR%%MODE%\readfile.exe" test\%1\ 32 | 33 | copy /b ".\Examples\sendcap\%BINDIR%%MODE%\sendcap.exe" test\%1\ 34 | 35 | goto :EOF 36 | 37 | :error 38 | echo Something failed: %ERRORLEVEL% 39 | exit /b 1 40 | -------------------------------------------------------------------------------- /create_docs.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem Ensure trailing slash 4 | IF "%2"=="" (set WPDPACKDESTDIR=.\npcap-sdk\) ELSE (set WPDPACKDESTDIR=%~dp2) 5 | rem Remove last character (trailing slash) 6 | set WPDPACKDESTDIR=%WPDPACKDESTDIR:~0,-1% 7 | 8 | rem Ensure trailing slash 9 | IF ""=="%1" (set WINPCAPSOURCEDIR=.\) ELSE (set WINPCAPSOURCEDIR=%~dp1) 10 | rem Remove last character (trailing slash) 11 | set WINPCAPSOURCEDIR=%WINPCAPSOURCEDIR:~0,-1% 12 | 13 | set DOCBOOKXSL_VER=1.79.2 14 | 15 | if exist "C:\msys64\usr\bin\env.exe" ( 16 | set RUNBASH=C:\msys64\usr\bin\env.exe MSYSTEM=MINGW64 CHERE_INVOKING=1 /usr/bin/bash --login 17 | ) else ( 18 | set RUNBASH=C:\cygwin\bin\bash.exe --login 19 | ) 20 | 21 | set DOCBOOKXSL=C:\xslt\docbook-xsl-%DOCBOOKXSL_VER% 22 | set XSLTPROC=C:\xslt\bin\xsltproc.exe 23 | if not exist %XSLTPROC% ( 24 | set XSLTPROC=%RUNBASH% -c "xsltproc ""$@"";" -- 25 | set DOCBOOKXSL=/mingw64/share/xml/docbook/xsl-stylesheets-%DOCBOOKXSL_VER% 26 | ) else ( 27 | if not exist %DOCBOOKXSL% ( 28 | set MISSING=%DOCBOOKXSL% 29 | goto :missing 30 | ) 31 | ) 32 | set ROFFIT=%WINPCAPSOURCEDIR%\..\roffit\roffit 33 | if not exist %ROFFIT% ( 34 | set MISSING=%ROFFIT% 35 | goto :missing 36 | ) 37 | 38 | echo Creating \docs folder 39 | mkdir %WPDPACKDESTDIR% >nul 2>nul 40 | mkdir %WPDPACKDESTDIR%\docs >nul 2>nul 41 | 42 | echo - Deleting existing WinPcap documentation 43 | del /q /S %WPDPACKDESTDIR%\docs\*.* 2> nul > nul 44 | echo - Creating new documentation 45 | xcopy /v /Y "%WINPCAPSOURCEDIR%\Npcap_Guide.html" %WPDPACKDESTDIR%\ 46 | mkdir %WPDPACKDESTDIR%\docs\wpcap >nul 2>nul 47 | %XSLTPROC% --path %DOCBOOKXSL% --nonet --stringparam media.type html --stringparam base.dir %WPDPACKDESTDIR%/docs/ --stringparam use.id.as.filename 1 %DOCBOOKXSL%/html/chunk.xsl %WINPCAPSOURCEDIR%/docs/npcap-guide-wrapper.xml 48 | 49 | for %%i in (%WINPCAPSOURCEDIR%) do set FULLPATHSOURCE=%%~fi 50 | for %%i in (%WPDPACKDESTDIR%) do set FULLPATHDEST=%%~fi 51 | %RUNBASH% -c "cd $(cygpath '%FULLPATHSOURCE%'); make -f create_docs.make LIBPCAPDIR=$(cygpath '%FULLPATHSOURCE%/wpcap/libpcap') DOCDIR=$(cygpath '%FULLPATHDEST%/docs') ROFFIT=perl\ $(cygpath '%ROFFIT%');" 52 | 53 | echo Folder \docs created successfully 54 | set WPDPACKDESTDIR= 55 | set WINPCAPSOURCEDIR= 56 | exit /b 57 | 58 | :missing 59 | echo "Failed to generate docs: %MISSING% is missing" 60 | exit /b 1 61 | -------------------------------------------------------------------------------- /create_docs.make: -------------------------------------------------------------------------------- 1 | ROFFIT = roffit 2 | LIBPCAPDIR = ./wpcap/libpcap 3 | DOCDIR = ./npcap-sdk/docs 4 | 5 | PCT = % 6 | 7 | %.3pcap: %.3pcap.in 8 | sed -e 's/@MAN_MISC_INFO@/7/g' -e 's/@MAN_FILE_FORMATS@/5/g' -e 's/@MAN_ADMIN_COMMANDS@/8/g' $< > $@ 9 | %.7: %.manmisc.in 10 | sed -e 's/@MAN_MISC_INFO@/7/g' -e 's/@MAN_FILE_FORMATS@/5/g' -e 's/@MAN_ADMIN_COMMANDS@/8/g' $< > $@ 11 | %.5: %.manfile.in 12 | sed -e 's/@MAN_MISC_INFO@/7/g' -e 's/@MAN_FILE_FORMATS@/5/g' -e 's/@MAN_ADMIN_COMMANDS@/8/g' $< > $@ 13 | 14 | ${DOCDIR}/wpcap/pcap.html: $(LIBPCAPDIR)/pcap.3pcap $(LIBPCAPDIR)/pcap.3pcap $(LIBPCAPDIR)/pcap_compile.3pcap $(LIBPCAPDIR)/pcap_datalink.3pcap $(LIBPCAPDIR)/pcap_dump_open.3pcap $(LIBPCAPDIR)/pcap_get_tstamp_precision.3pcap $(LIBPCAPDIR)/pcap_list_datalinks.3pcap $(LIBPCAPDIR)/pcap_list_tstamp_types.3pcap $(LIBPCAPDIR)/pcap_open_dead.3pcap $(LIBPCAPDIR)/pcap_open_offline.3pcap $(LIBPCAPDIR)/pcap_set_tstamp_precision.3pcap $(LIBPCAPDIR)/pcap_set_tstamp_type.3pcap $(LIBPCAPDIR)/pcap-savefile.5 $(LIBPCAPDIR)/pcap-filter.7 $(LIBPCAPDIR)/pcap-linktype.7 $(LIBPCAPDIR)/pcap-tstamp.7 15 | mkdir -p ${DOCDIR}/wpcap/ build/wpcap/ 16 | rm -f ${DOCDIR}/wpcap/*.html build/wpcap/*.html 17 | # Generate the contents 18 | find "$(LIBPCAPDIR)" -maxdepth 1 \( -name '*.3pcap' -o -name '*.7' -o -name '*.5' \) | while read m; do \ 19 | p=$${m$(PCT).3pcap} ; \ 20 | p=$${p$(PCT).7} ; \ 21 | p=$${p$(PCT).5} ; \ 22 | p=$${p##*/} ; \ 23 | $(ROFFIT) --mandir="$(LIBPCAPDIR)" --hrefdir=. "$$m" > ${DOCDIR}/wpcap/$$p.html ; \ 24 | done 25 | -------------------------------------------------------------------------------- /create_examples.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | IF "%2"=="" (set WPDPACKDESTDIR=npcap-sdk) ELSE (set WPDPACKDESTDIR=%2) 4 | 5 | IF ""=="%1" (set WINPCAPSOURCEDIR=.\) ELSE (set WINPCAPSOURCEDIR=%1) 6 | 7 | echo Creating \Examples folder 8 | mkdir %WPDPACKDESTDIR% >nul 2>nul 9 | rd /S /Q %WPDPACKDESTDIR%\Examples-pcap >nul 2>nul 10 | mkdir %WPDPACKDESTDIR%\Examples-pcap >nul 2>nul 11 | rd /S /Q %WPDPACKDESTDIR%\Examples-remote >nul 2>nul 12 | mkdir %WPDPACKDESTDIR%\Examples-remote >nul 2>nul 13 | 14 | rem Can't pipe stdout to stdin of tar; claims "Damaged archive" 15 | git archive --prefix="%WPDPACKDESTDIR%/Examples-remote/" HEAD:Examples -o Examples-remote.tar 16 | tar xf Examples-remote.tar 17 | del Examples-remote.tar 18 | 19 | git archive --prefix="%WPDPACKDESTDIR%/Examples-pcap/" HEAD:Examples-pcap -o Examples-pcap.tar 20 | tar xf Examples-pcap.tar 21 | del Examples-pcap.tar 22 | 23 | rem *** Delete Netmeter since it's no more part of the Developer's pack *** 24 | rd /S /Q %WPDPACKDESTDIR%\Examples-remote\NetMeter\ 25 | 26 | rem *** Delete WinPcapStress, since it's not a real example *** 27 | rd /S /Q %WPDPACKDESTDIR%\Examples-pcap\winpcap_stress 28 | 29 | rem *** Delete stats, since it's not a real example *** 30 | rd /S /Q %WPDPACKDESTDIR%\Examples-pcap\stats 31 | 32 | 33 | echo Folder \Examples created successfully 34 | set WPDPACKDESTDIR= 35 | set WINPCAPSOURCEDIR= 36 | 37 | echo ******************************************************************** 38 | echo * * 39 | echo * Now you can build the examples from the developers' pack folder! * 40 | echo * * 41 | echo ******************************************************************** 42 | -------------------------------------------------------------------------------- /create_include.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | IF "%2"=="" (set WPDPACKDESTDIR=.\npcap-sdk\) ELSE (set WPDPACKDESTDIR=%2) 4 | 5 | IF ""=="%1" (set WINPCAPSOURCEDIR=.\) ELSE (set WINPCAPSOURCEDIR=%1) 6 | 7 | echo Creating \Include folder 8 | mkdir %WPDPACKDESTDIR% 2>nul >nul 9 | mkdir %WPDPACKDESTDIR%\Include 2>nul >nul 10 | mkdir %WPDPACKDESTDIR%\Include\pcap 2>nul >nul 11 | 12 | 13 | SETLOCAL ENABLEEXTENSIONS 14 | 15 | xcopy /v /Y %WINPCAPSOURCEDIR%\wpcap\libpcap\pcap\ %WPDPACKDESTDIR%\Include\pcap\ >nul 16 | for /F "usebackq skip=1 tokens=3 delims=/ " %%i in (`findstr "CMAKE_INSTALL_INCLUDEDIR" "%WINPCAPSOURCEDIR%\wpcap\libpcap\CMakeLists.txt"`) do ( 17 | copy /v /Y "%WINPCAPSOURCEDIR%\wpcap\libpcap\%%i" "%WPDPACKDESTDIR%\Include\%%i" 18 | ) 19 | 20 | xcopy /v /Y %WINPCAPSOURCEDIR%\Common\Packet32.h %WPDPACKDESTDIR%\Include\ >nul 21 | xcopy /v /Y %WINPCAPSOURCEDIR%\Common\npcap-bpf.h %WPDPACKDESTDIR%\Include\ >nul 22 | xcopy /v /Y %WINPCAPSOURCEDIR%\Common\npcap-defs.h %WPDPACKDESTDIR%\Include\ >nul 23 | 24 | echo Folder \Include created successfully 25 | set WPDPACKDESTDIR= 26 | set WINPCAPSOURCEDIR= 27 | -------------------------------------------------------------------------------- /create_lib.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | IF "%2"=="" (set WPDPACKDESTDIR=.\npcap-sdk\) ELSE (set WPDPACKDESTDIR=%2) 4 | 5 | IF ""=="%1" (set WINPCAPSOURCEDIR=.\) ELSE (set WINPCAPSOURCEDIR=%1) 6 | 7 | echo Checking for wpcap build dirs 8 | set WPCAPBUILDDIR32=%WINPCAPSOURCEDIR%\wpcap\build-win32 9 | if not exist "%WPCAPBUILDDIR32%" goto :fail 10 | set WPCAPBUILDDIR64=%WINPCAPSOURCEDIR%\wpcap\build-x64 11 | if not exist "%WPCAPBUILDDIR64%" goto :fail 12 | set WPCAPBUILDDIRARM=%WINPCAPSOURCEDIR%\wpcap\build-ARM64 13 | if not exist "%WPCAPBUILDDIRARM%" goto :fail 14 | 15 | echo Checking for Packet build dir 16 | set PACKETBUILDDIR=%WINPCAPSOURCEDIR%\packetWin7\vs14 17 | if not exist "%PACKETBUILDDIR%" goto :fail 18 | 19 | echo Creating \Lib folder 20 | mkdir %WPDPACKDESTDIR% >nul 2>nul 21 | mkdir %WPDPACKDESTDIR%\Lib >nul 2>nul 22 | mkdir %WPDPACKDESTDIR%\Lib\x64 >nul 2>nul 23 | mkdir %WPDPACKDESTDIR%\Lib\ARM64 >nul 2>nul 24 | 25 | xcopy /v /Y "%WPCAPBUILDDIR32%\Release\wpcap.lib" %WPDPACKDESTDIR%\Lib\ || goto :fail 26 | xcopy /v /Y "%WPCAPBUILDDIR64%\Release\wpcap.lib" %WPDPACKDESTDIR%\Lib\x64 || goto :fail 27 | xcopy /v /Y "%WPCAPBUILDDIRARM%\Release\wpcap.lib" %WPDPACKDESTDIR%\Lib\ARM64 || goto :fail 28 | xcopy /v /Y "%PACKETBUILDDIR%\Release\packet.lib" %WPDPACKDESTDIR%\Lib\ || goto :fail 29 | xcopy /v /Y "%PACKETBUILDDIR%\x64\Release\packet.lib" %WPDPACKDESTDIR%\Lib\x64 || goto :fail 30 | xcopy /v /Y "%PACKETBUILDDIR%\ARM64\Release No AirPcap\packet.lib" %WPDPACKDESTDIR%\Lib\ARM64 || goto :fail 31 | 32 | echo Folder \Lib created successfully 33 | 34 | set WPDPACKDESTDIR= 35 | set WINPCAPSOURCEDIR= 36 | 37 | exit /b 38 | 39 | :fail 40 | echo Failed. 41 | pause 42 | exit /b 1 43 | 44 | -------------------------------------------------------------------------------- /docs/Npcap-Third-Party-Open-Source.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nmap/npcap/33105960dc380d2f22ab853a931fb5b915b4ba62/docs/Npcap-Third-Party-Open-Source.pdf -------------------------------------------------------------------------------- /docs/README: -------------------------------------------------------------------------------- 1 | The documentation in this directory can be found in HTML format at 2 | https://npcap.com/guide/ 3 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Npcap Guide 7 | 10 | 11 | 12 |

The Npcap Guide has moved to 13 | https://npcap.com/guide/. 14 | If you are not redirected automatically within 3 seconds, 15 | follow this link.

16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/npcap-guide-wrapper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Npcap Guide 7 | 10 | 11 | 12 |

The Npcap Guide has moved to 13 | https://npcap.com/guide/". 14 | If you are not redirected automatically within 3 seconds, 15 | follow this link.

16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/npcap-guide-wrapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | ]> 11 | 12 |
13 | 14 | Npcap Reference Guide 15 | 16 | A manual and guide to Npcap, a packet capture and network analysis framework for Windows, for users and 17 | software developers. Npcap is a modern, safe, and compatible update to WinPcap. 18 | 19 | 20 | 21 | &npcap-intro; 22 | &npcap-guide; 23 | &npcap-devguide; 24 | &npcap-api; 25 | &npcap-tutorial; 26 | &npcap-internals; 27 | 28 |
29 | -------------------------------------------------------------------------------- /installer/Build.bat: -------------------------------------------------------------------------------- 1 | SET NPCAPDIR=".." 2 | SET MODE="Release" 3 | rem SET MODE="Debug" 4 | SET VSVER=17 5 | 6 | :::::::::: 7 | for /f "usebackq delims=#" %%a in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -version %VSVER% -property installationPath`) do call "%%a\VC\Auxiliary\Build\vcvarsall.bat" x86 & goto :break1 8 | :break1 9 | if %ERRORLEVEL% NEQ 0 goto :badenv 10 | 11 | msbuild "%NPCAPDIR%\packetWin7\vs14\npcap.sln" /m /t:Build /p:Configuration="%MODE%" /p:Platform="x86" 12 | msbuild "%NPCAPDIR%\packetWin7\vs14\npcap.sln" /m /t:Build /p:Configuration="%MODE% Win10 driver" /p:Platform="x86" 13 | msbuild "%NPCAPDIR%\wpcap\build-win32\wpcap.vcxproj" /m /t:Build /p:Configuration="%MODE%" /p:Platform="Win32" 14 | 15 | for /f "usebackq delims=#" %%a in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -version %VSVER% -property installationPath`) do call "%%a\VC\Auxiliary\Build\vcvarsall.bat" x64 & goto :break2 16 | :break2 17 | if %ERRORLEVEL% NEQ 0 goto :badenv 18 | 19 | msbuild "%NPCAPDIR%\packetWin7\vs14\npcap.sln" /m /t:Build /p:Configuration="%MODE%" /p:Platform="x64" 20 | msbuild "%NPCAPDIR%\packetWin7\vs14\npcap.sln" /m /t:Build /p:Configuration="%MODE% Win10 driver" /p:Platform="x64" 21 | msbuild "%NPCAPDIR%\wpcap\build-x64\wpcap.vcxproj" /m /t:Build /p:Configuration="%MODE%" /p:Platform="x64" 22 | 23 | for /f "usebackq delims=#" %%a in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -version %VSVER% -property installationPath`) do call "%%a\VC\Auxiliary\Build\vcvarsall.bat" amd64_arm64 & goto :break3 24 | :break3 25 | if %ERRORLEVEL% NEQ 0 goto :badenv 26 | 27 | msbuild "%NPCAPDIR%\packetWin7\vs14\npcap.sln" /m /t:Build /p:Configuration="%MODE%" /p:Platform="ARM64" 28 | msbuild "%NPCAPDIR%\packetWin7\vs14\npcap.sln" /m /t:Build /p:Configuration="%MODE% Win10 driver" /p:Platform="ARM64" 29 | msbuild "%NPCAPDIR%\wpcap\build-ARM64\wpcap.vcxproj" /m /t:Build /p:Configuration="%MODE%" /p:Platform="ARM64" 30 | 31 | exit /b 32 | 33 | :bad_env 34 | echo Failed to set environment 35 | exit /b 1 36 | -------------------------------------------------------------------------------- /installer/CheckStatus.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem Make sure we can find where Npcap is installed 4 | set KEY_NAME=HKLM\Software\WOW6432Node\Npcap 5 | for /F "usebackq tokens=1,2*" %%A IN (`reg query "%KEY_NAME%" /ve 2^>nul ^| find "REG_SZ"`) do ( 6 | set NPCAP_DIR=%%C 7 | ) 8 | if defined NPCAP_DIR (goto DO_CHECK) 9 | set KEY_NAME=HKLM\Software\Npcap 10 | for /F "usebackq tokens=1,2*" %%A IN (`reg query "%KEY_NAME%" /ve 2^>nul ^| find "REG_SZ"`) do ( 11 | set NPCAP_DIR=%%C 12 | ) 13 | if defined NPCAP_DIR (goto DO_CHECK) else (goto ABORT) 14 | 15 | :DO_CHECK 16 | 17 | rem If start type is not SYSTEM_START, we need to fix that. 18 | for /F "usebackq tokens=1,4" %%A in (`sc.exe qc npcap`) do ( 19 | if %%A == START_TYPE ( 20 | if NOT %%B == SYSTEM_START ( 21 | goto FIXINSTALL 22 | ) 23 | ) 24 | ) 25 | 26 | goto ABORT 27 | 28 | :FIXINSTALL 29 | "%NPCAP_DIR%\FixInstall.bat" 30 | exit /b %ERRORLEVEL% 31 | 32 | :ABORT 33 | exit /b 0 34 | -------------------------------------------------------------------------------- /installer/DiagReport.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | whoami /Groups | find "S-1-16-12288" >NUL 4 | if ERRORLEVEL 1 ( 5 | rem This tools must run with administrator permissions 6 | rem It will popup the UAC dialog, please click [Yes] to continue. 7 | echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" 8 | echo UAC.ShellExecute "%~s0", "%*", "", "runas", 1 >> "%temp%\getadmin.vbs" 9 | "%temp%\getadmin.vbs" 10 | exit /b 2 11 | ) 12 | 13 | set dir=%~dp0 14 | set scriptPath=%dir%DiagReport.ps1 15 | for /f "tokens=*" %%a in ('powershell Get-ExecutionPolicy') do ( 16 | set originPolicy=%%a 17 | ) 18 | powershell Set-ExecutionPolicy 0 19 | 20 | rem this call only works for Administrator 21 | rem powershell %scriptPath% 22 | 23 | rem This call works also for normal users 24 | rem "No Exit" version: 25 | rem powershell -NoExit -noprofile -command "&{start-process powershell -ArgumentList '-NoExit -noprofile -file \"%scriptPath%\"' -verb RunAs}" 26 | rem "Exit" version: 27 | powershell -noprofile -command "&{start-process powershell -ArgumentList '-noprofile -file \"%scriptPath%\"' -verb RunAs}" 28 | 29 | powershell Set-ExecutionPolicy %originPolicy% 30 | 31 | rem pause 32 | -------------------------------------------------------------------------------- /installer/FixInstall.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem Start type auto will start the Npcap service at boot. Set this to "demand" for demand start instead. 3 | set START_TYPE=system 4 | 5 | setlocal ENABLEEXTENSIONS 6 | 7 | rem Get the installed configuration 8 | set KEY_NAME=HKLM\SYSTEM\CurrentControlSet\Services\npcap\Parameters 9 | for /F "usebackq tokens=1,2*" %%A IN (`reg query "%KEY_NAME%" /v "Dot11Support" 2^>nul ^| find "Dot11Support"`) do ( 10 | set Dot11Support=%%C 11 | ) 12 | echo Dot11Support = %Dot11Support% 13 | for /F "usebackq tokens=1,2*" %%A IN (`reg query "%KEY_NAME%" /v "LoopbackAdapter" 2^>nul ^| find "LoopbackAdapter"`) do ( 14 | set LoopbackAdapter=%%C 15 | ) 16 | echo LoopbackAdapter = %LoopbackAdapter% 17 | 18 | rem Make sure we can find where Npcap is installed 19 | set KEY_NAME=HKLM\Software\WOW6432Node\Npcap 20 | for /F "usebackq tokens=1,2*" %%A IN (`reg query "%KEY_NAME%" /ve 2^>nul ^| find "REG_SZ"`) do ( 21 | set NPCAP_DIR=%%C 22 | ) 23 | if defined NPCAP_DIR (goto DO_FIX) 24 | set KEY_NAME=HKLM\Software\Npcap 25 | for /F "usebackq tokens=1,2*" %%A IN (`reg query "%KEY_NAME%" /ve 2^>nul ^| find "REG_SZ"`) do ( 26 | set NPCAP_DIR=%%C 27 | ) 28 | if defined NPCAP_DIR (goto DO_FIX) else (goto ABORT) 29 | 30 | :DO_FIX 31 | echo NPCAP_DIR = "%NPCAP_DIR%" 32 | rem Stop the services and set their start types properly 33 | net stop npcap 34 | sc.exe config npcap start= %START_TYPE% 35 | if %Dot11Support% == 0x1 ( 36 | net stop npcap_wifi 37 | rem *_wifi service is disabled at install 38 | sc.exe config npcap_wifi start= disabled 39 | ) 40 | 41 | rem Remove and reinstall loopback adapters 42 | if not %LoopbackAdapter% == "" ( 43 | "%NPCAP_DIR%\NPFInstall.exe" -ul 44 | rem ) 45 | rem TODO Remove any leftover adapters in any case 46 | rem netsh interface show interface | find "Npcap Loopback Adapter" 47 | rem if NOT ERRORLEVEL 1 ( 48 | rem echo Some Npcap Loopback Adapter was not removed. Remove it manually: 49 | rem echo 1. In the Device Manager, open 'Network adapters' 50 | rem echo 2. Right-click any 'Npcap Loopback Adapter' and choose 'Uninstall device' 51 | rem echo 3. Repeat until all Npcap Loopback Adapters are removed 52 | rem start devmgmt.msc 53 | rem pause 54 | rem ) 55 | rem 56 | rem if not %LoopbackAdapter% == "" ( 57 | "%NPCAP_DIR%\NPFInstall.exe" -il 58 | ) 59 | 60 | rem Start the Base Filtering Engine in case it was disabled 61 | sc.exe config bfe start= auto 62 | net start bfe 63 | 64 | rem Restart the services 65 | net start npcap 66 | 67 | rem Rebind the filters to all adapters 68 | if %Dot11Support% == 0x1 ( 69 | "%NPCAP_DIR%\NPFInstall.exe" -r2 70 | ) else ( 71 | "%NPCAP_DIR%\NPFInstall.exe" -r 72 | ) 73 | 74 | rem Done! 75 | goto EOF 76 | 77 | :ABORT 78 | echo "Unable to find or fix your installation" 79 | exit /b 1 80 | 81 | :EOF 82 | exit /b 0 83 | -------------------------------------------------------------------------------- /packetWin7/Dll/Packet.def: -------------------------------------------------------------------------------- 1 | LIBRARY packet 2 | 3 | EXPORTS 4 | PacketLibraryVersion 5 | PacketGetVersion 6 | PacketGetDriverVersion 7 | PacketGetDriverName 8 | PacketOpenAdapter 9 | PacketSendPacket 10 | PacketSendPackets 11 | PacketAllocatePacket 12 | PacketInitPacket 13 | PacketFreePacket 14 | PacketReceivePacket 15 | PacketCloseAdapter 16 | PacketSetHwFilter 17 | PacketGetAdapterNames 18 | PacketRequest 19 | PacketSetBuff 20 | PacketSetBpf 21 | PacketSetSnapLen 22 | PacketGetStats 23 | PacketGetStatsEx 24 | PacketGetNetType 25 | PacketIsLoopbackAdapter 26 | PacketIsMonitorModeSupported 27 | PacketSetMonitorMode 28 | PacketGetMonitorMode 29 | PacketSetReadTimeout 30 | PacketSetMode 31 | PacketSetNumWrites 32 | PacketGetNetInfoEx 33 | PacketSetMinToCopy 34 | PacketGetReadEvent 35 | PacketStopDriver 36 | PacketSetDumpName 37 | PacketSetDumpLimits 38 | PacketIsDumpEnded 39 | PacketSetLoopbackBehavior 40 | PacketSetTimestampMode 41 | PacketGetTimestampModes 42 | PacketGetInfo 43 | PacketGetAirPcapHandle 44 | -------------------------------------------------------------------------------- /packetWin7/Dll/Packet32.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nmap/npcap/33105960dc380d2f22ab853a931fb5b915b4ba62/packetWin7/Dll/Packet32.cpp -------------------------------------------------------------------------------- /packetWin7/Dll/Project/Packet.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Packet", "Packet.vcxproj", "{17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug No AirPcap|Win32 = Debug No AirPcap|Win32 11 | Debug No AirPcap|x64 = Debug No AirPcap|x64 12 | Debug|Win32 = Debug|Win32 13 | Debug|x64 = Debug|x64 14 | OEM Release No AirPcap|Win32 = OEM Release No AirPcap|Win32 15 | OEM Release No AirPcap|x64 = OEM Release No AirPcap|x64 16 | Release LOG_TO_FILE|Win32 = Release LOG_TO_FILE|Win32 17 | Release LOG_TO_FILE|x64 = Release LOG_TO_FILE|x64 18 | Release No AirPcap|Win32 = Release No AirPcap|Win32 19 | Release No AirPcap|x64 = Release No AirPcap|x64 20 | Release|Win32 = Release|Win32 21 | Release|x64 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Debug No AirPcap|Win32.ActiveCfg = Debug No AirPcap|Win32 25 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Debug No AirPcap|Win32.Build.0 = Debug No AirPcap|Win32 26 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Debug No AirPcap|x64.ActiveCfg = Debug No AirPcap|x64 27 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Debug No AirPcap|x64.Build.0 = Debug No AirPcap|x64 28 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Debug|Win32.ActiveCfg = Debug|Win32 29 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Debug|Win32.Build.0 = Debug|Win32 30 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Debug|x64.ActiveCfg = Debug|x64 31 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Debug|x64.Build.0 = Debug|x64 32 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.OEM Release No AirPcap|Win32.ActiveCfg = OEM Release No AirPcap|Win32 33 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.OEM Release No AirPcap|Win32.Build.0 = OEM Release No AirPcap|Win32 34 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.OEM Release No AirPcap|x64.ActiveCfg = OEM Release No AirPcap|x64 35 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.OEM Release No AirPcap|x64.Build.0 = OEM Release No AirPcap|x64 36 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Release LOG_TO_FILE|Win32.ActiveCfg = Release LOG_TO_FILE|Win32 37 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Release LOG_TO_FILE|Win32.Build.0 = Release LOG_TO_FILE|Win32 38 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Release LOG_TO_FILE|x64.ActiveCfg = Release LOG_TO_FILE|x64 39 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Release LOG_TO_FILE|x64.Build.0 = Release LOG_TO_FILE|x64 40 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Release No AirPcap|Win32.ActiveCfg = Release No AirPcap|Win32 41 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Release No AirPcap|Win32.Build.0 = Release No AirPcap|Win32 42 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Release No AirPcap|x64.ActiveCfg = Release No AirPcap|x64 43 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Release No AirPcap|x64.Build.0 = Release No AirPcap|x64 44 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Release|Win32.ActiveCfg = Release|Win32 45 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Release|Win32.Build.0 = Release|Win32 46 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Release|x64.ActiveCfg = Release|x64 47 | {17D62EEB-EABF-4D94-B1FF-BCDAAFA7DA52}.Release|x64.Build.0 = Release|x64 48 | EndGlobalSection 49 | GlobalSection(SolutionProperties) = preSolution 50 | HideSolutionNode = FALSE 51 | EndGlobalSection 52 | EndGlobal 53 | -------------------------------------------------------------------------------- /packetWin7/Dll/Project/Packet.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | Resource Files 36 | 37 | 38 | -------------------------------------------------------------------------------- /packetWin7/Dll/version.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | 4 | #define APSTUDIO_READONLY_SYMBOLS 5 | ///////////////////////////////////////////////////////////////////////////// 6 | // 7 | // Generated from the TEXTINCLUDE 2 resource. 8 | // 9 | #include "winresrc.h" 10 | #ifndef IDC_STATIC 11 | #define IDC_STATIC (-1) 12 | #endif 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | #undef APSTUDIO_READONLY_SYMBOLS 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // Neutral resources 19 | 20 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) 21 | #ifdef _WIN32 22 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 23 | #pragma code_page(1252) 24 | #endif //_WIN32 25 | 26 | #ifdef APSTUDIO_INVOKED 27 | ///////////////////////////////////////////////////////////////////////////// 28 | // 29 | // TEXTINCLUDE 30 | // 31 | 32 | 1 TEXTINCLUDE 33 | BEGIN 34 | "\r\n" 35 | "\0" 36 | END 37 | 38 | 2 TEXTINCLUDE 39 | BEGIN 40 | "#include ""afxres.h""\r\n" 41 | "\0" 42 | END 43 | 44 | 3 TEXTINCLUDE 45 | BEGIN 46 | "#include ""version.rc2""\r\n" 47 | "\r\n" 48 | "\0" 49 | END 50 | 51 | #endif // APSTUDIO_INVOKED 52 | 53 | #endif // Neutral resources 54 | ///////////////////////////////////////////////////////////////////////////// 55 | 56 | 57 | 58 | #ifndef APSTUDIO_INVOKED 59 | ///////////////////////////////////////////////////////////////////////////// 60 | // 61 | // Generated from the TEXTINCLUDE 3 resource. 62 | // 63 | #include "version.rc2" 64 | 65 | ///////////////////////////////////////////////////////////////////////////// 66 | #endif // not APSTUDIO_INVOKED 67 | 68 | -------------------------------------------------------------------------------- /packetWin7/Dll/version.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // version.rc2 - resources Microsoft Visual C++ does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by Microsoft Visual C++ 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | #include "..\..\version.h" 11 | 12 | VS_VERSION_INFO VERSIONINFO 13 | FILEVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 14 | PRODUCTVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 15 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 16 | #if defined(_DEBUG) && defined(_DEBUG_TO_FILE) 17 | FILEFLAGS VS_FF_SPECIALBUILD | VS_FF_DEBUG 18 | #elseif defined(_DEBUG) 19 | FILEFLAGS VS_FF_DEBUG 20 | #elseif defined(_DEBUG_TO_FILE) 21 | FILEFLAGS VS_FF_SPECIALBUILD 22 | #else 23 | FILEFLAGS 0x0L 24 | #endif 25 | FILEOS VOS_NT_WINDOWS32 26 | FILETYPE VFT_DLL 27 | FILESUBTYPE 0x0L 28 | BEGIN 29 | BLOCK "StringFileInfo" 30 | BEGIN 31 | BLOCK "000004b0" 32 | BEGIN 33 | VALUE "CompanyName", WINPCAP_COMPANY_NAME 34 | VALUE "FileDescription", "The Packet API for Windows" 35 | VALUE "FileVersion", WINPCAP_VER_STRING 36 | VALUE "InternalName", "Packet.dll" 37 | VALUE "LegalCopyright", WINPCAP_COPYRIGHT_STRING 38 | VALUE "LegalTrademarks", "" 39 | VALUE "OriginalFilename", "Packet.dll" 40 | VALUE "ProductName", WINPCAP_PRODUCT_NAME 41 | VALUE "ProductVersion", WINPCAP_VER_STRING 42 | #ifdef _DEBUG_TO_FILE 43 | VALUE "SpecialBuild", "LOG_TO_FILE build" 44 | #endif 45 | END 46 | END 47 | BLOCK "VarFileInfo" 48 | BEGIN 49 | VALUE "Translation", 0x0, 1200 50 | END 51 | END 52 | -------------------------------------------------------------------------------- /packetWin7/Helper/NpcapHelper.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NpcapHelper", "NpcapHelper\NpcapHelper.vcxproj", "{917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NpcapHelperTest", "NpcapHelperTest\NpcapHelperTest.vcxproj", "{3F697FA8-4C35-416C-A381-2631AAB79D39}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Win32 = Debug|Win32 13 | Debug|x64 = Debug|x64 14 | OEM Release|Win32 = OEM Release|Win32 15 | OEM Release|x64 = OEM Release|x64 16 | Release|Win32 = Release|Win32 17 | Release|x64 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.Debug|Win32.ActiveCfg = Debug|Win32 21 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.Debug|Win32.Build.0 = Debug|Win32 22 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.Debug|x64.ActiveCfg = Debug|x64 23 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.Debug|x64.Build.0 = Debug|x64 24 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.OEM Release|Win32.ActiveCfg = OEM Release|Win32 25 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.OEM Release|Win32.Build.0 = OEM Release|Win32 26 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.OEM Release|x64.ActiveCfg = OEM Release|x64 27 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.OEM Release|x64.Build.0 = OEM Release|x64 28 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.Release|Win32.ActiveCfg = Release|Win32 29 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.Release|Win32.Build.0 = Release|Win32 30 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.Release|x64.ActiveCfg = Release|x64 31 | {917BE5CC-CE5E-4476-A9E7-3B1F96E9FC43}.Release|x64.Build.0 = Release|x64 32 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.Debug|Win32.ActiveCfg = Debug|Win32 33 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.Debug|Win32.Build.0 = Debug|Win32 34 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.Debug|x64.ActiveCfg = Debug|x64 35 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.Debug|x64.Build.0 = Debug|x64 36 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.OEM Release|Win32.ActiveCfg = Release|Win32 37 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.OEM Release|Win32.Build.0 = Release|Win32 38 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.OEM Release|x64.ActiveCfg = Release|x64 39 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.OEM Release|x64.Build.0 = Release|x64 40 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.Release|Win32.ActiveCfg = Release|Win32 41 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.Release|Win32.Build.0 = Release|Win32 42 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.Release|x64.ActiveCfg = Release|x64 43 | {3F697FA8-4C35-416C-A381-2631AAB79D39}.Release|x64.Build.0 = Release|x64 44 | EndGlobalSection 45 | GlobalSection(SolutionProperties) = preSolution 46 | HideSolutionNode = FALSE 47 | EndGlobalSection 48 | EndGlobal 49 | -------------------------------------------------------------------------------- /packetWin7/Helper/NpcapHelper/NpcapHelper.exe.manifest.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /packetWin7/Helper/NpcapHelper/NpcapHelper.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | Header Files 28 | 29 | 30 | 31 | 32 | Resource Files 33 | 34 | 35 | -------------------------------------------------------------------------------- /packetWin7/Helper/NpcapHelper/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by version.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /packetWin7/Helper/NpcapHelper/version.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | 4 | #define APSTUDIO_READONLY_SYMBOLS 5 | ///////////////////////////////////////////////////////////////////////////// 6 | // 7 | // Generated from the TEXTINCLUDE 2 resource. 8 | // 9 | #include "winresrc.h" 10 | #ifndef IDC_STATIC 11 | #define IDC_STATIC (-1) 12 | #endif 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | #undef APSTUDIO_READONLY_SYMBOLS 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // Neutral resources 19 | 20 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) 21 | #ifdef _WIN32 22 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 23 | #pragma code_page(1252) 24 | #endif //_WIN32 25 | 26 | #ifdef APSTUDIO_INVOKED 27 | ///////////////////////////////////////////////////////////////////////////// 28 | // 29 | // TEXTINCLUDE 30 | // 31 | 32 | 1 TEXTINCLUDE 33 | BEGIN 34 | "\r\n" 35 | "\0" 36 | END 37 | 38 | 2 TEXTINCLUDE 39 | BEGIN 40 | "#include ""afxres.h""\r\n" 41 | "\0" 42 | END 43 | 44 | 3 TEXTINCLUDE 45 | BEGIN 46 | "#include ""version.rc2""\r\n" 47 | "\r\n" 48 | "\0" 49 | END 50 | 51 | #endif // APSTUDIO_INVOKED 52 | 53 | #endif // Neutral resources 54 | ///////////////////////////////////////////////////////////////////////////// 55 | 56 | 57 | 58 | #ifndef APSTUDIO_INVOKED 59 | ///////////////////////////////////////////////////////////////////////////// 60 | // 61 | // Generated from the TEXTINCLUDE 3 resource. 62 | // 63 | #include "version.rc2" 64 | 65 | ///////////////////////////////////////////////////////////////////////////// 66 | #endif // not APSTUDIO_INVOKED 67 | 68 | -------------------------------------------------------------------------------- /packetWin7/Helper/NpcapHelper/version.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // version.rc2 - resources Microsoft Visual C++ does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by Microsoft Visual C++ 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | #include "..\..\..\version.h" 11 | 12 | VS_VERSION_INFO VERSIONINFO 13 | FILEVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 14 | PRODUCTVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 15 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 16 | #ifdef _DEBUG 17 | FILEFLAGS VS_FF_DEBUG 18 | #else 19 | FILEFLAGS 0x0L 20 | #endif 21 | FILEOS VOS_NT_WINDOWS32 22 | FILETYPE VFT_APP 23 | FILESUBTYPE 0x0L 24 | BEGIN 25 | BLOCK "StringFileInfo" 26 | BEGIN 27 | BLOCK "000004b0" 28 | BEGIN 29 | VALUE "CompanyName", WINPCAP_COMPANY_NAME 30 | VALUE "FileDescription", "The helper program for \x22Admin-only Mode\x22" 31 | VALUE "FileVersion", WINPCAP_VER_STRING 32 | VALUE "InternalName", "NpcapHelper.exe" 33 | VALUE "LegalCopyright", WINPCAP_COPYRIGHT_STRING 34 | VALUE "LegalTrademarks", "" 35 | VALUE "OriginalFilename", "NpcapHelper.exe" 36 | VALUE "ProductName", WINPCAP_PRODUCT_NAME 37 | VALUE "ProductVersion", WINPCAP_VER_STRING 38 | VALUE "Build Description", WINPCAP_BUILD_DESCRIPTION 39 | END 40 | END 41 | BLOCK "VarFileInfo" 42 | BEGIN 43 | VALUE "Translation", 0x0, 1200 44 | END 45 | END 46 | -------------------------------------------------------------------------------- /packetWin7/Helper/NpcapHelperTest/NpcapHelperTest.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NPFInstall", "NPFInstall\NPFInstall.vcxproj", "{5D8A2717-4F35-4402-B868-45612D27291B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | OEM Release|Win32 = OEM Release|Win32 13 | OEM Release|x64 = OEM Release|x64 14 | Release|Win32 = Release|Win32 15 | Release|x64 = Release|x64 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {5D8A2717-4F35-4402-B868-45612D27291B}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {5D8A2717-4F35-4402-B868-45612D27291B}.Debug|Win32.Build.0 = Debug|Win32 20 | {5D8A2717-4F35-4402-B868-45612D27291B}.Debug|x64.ActiveCfg = Debug|x64 21 | {5D8A2717-4F35-4402-B868-45612D27291B}.Debug|x64.Build.0 = Debug|x64 22 | {5D8A2717-4F35-4402-B868-45612D27291B}.OEM Release|Win32.ActiveCfg = OEM Release|Win32 23 | {5D8A2717-4F35-4402-B868-45612D27291B}.OEM Release|Win32.Build.0 = OEM Release|Win32 24 | {5D8A2717-4F35-4402-B868-45612D27291B}.OEM Release|x64.ActiveCfg = OEM Release|x64 25 | {5D8A2717-4F35-4402-B868-45612D27291B}.OEM Release|x64.Build.0 = OEM Release|x64 26 | {5D8A2717-4F35-4402-B868-45612D27291B}.Release|Win32.ActiveCfg = Release|Win32 27 | {5D8A2717-4F35-4402-B868-45612D27291B}.Release|Win32.Build.0 = Release|Win32 28 | {5D8A2717-4F35-4402-B868-45612D27291B}.Release|x64.ActiveCfg = Release|x64 29 | {5D8A2717-4F35-4402-B868-45612D27291B}.Release|x64.Build.0 = Release|x64 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall/CalloutInstall.h: -------------------------------------------------------------------------------- 1 | /***********************IMPORTANT NPCAP LICENSE TERMS*********************** 2 | * 3 | * Npcap (https://npcap.com) is a Windows packet sniffing driver and library and 4 | * is copyright (c) 2013-2025 by Nmap Software LLC ("The Nmap Project"). All 5 | * rights reserved. 6 | * 7 | * Even though Npcap source code is publicly available for review, it is not 8 | * open source software and may not be redistributed or used in other software 9 | * without special permission from the Nmap Project. The standard (free) version 10 | * is usually limited to installation on five systems. For more details, see the 11 | * LICENSE file included with Npcap and also available at 12 | * https://github.com/nmap/npcap/blob/master/LICENSE. This header file 13 | * summarizes a few important aspects of the Npcap license, but is not a 14 | * substitute for that full Npcap license agreement. 15 | * 16 | * We fund the Npcap project by selling two types of commercial licenses to a 17 | * special Npcap OEM edition: 18 | * 19 | * 1) The Npcap OEM Redistribution License allows companies distribute Npcap OEM 20 | * within their products. Licensees generally use the Npcap OEM silent 21 | * installer, ensuring a seamless experience for end users. Licensees may choose 22 | * between a perpetual unlimited license or a quarterly term license, along with 23 | * options for commercial support and updates. Prices and details: 24 | * https://npcap.com/oem/redist.html 25 | * 26 | * 2) The Npcap OEM Internal-Use License is for organizations that wish to use 27 | * Npcap OEM internally, without redistribution outside their organization. This 28 | * allows them to bypass the 5-system usage cap of the Npcap free edition. It 29 | * includes commercial support and update options, and provides the extra Npcap 30 | * OEM features such as the silent installer for automated deployment. Prices 31 | * and details: https://npcap.com/oem/internal.html 32 | * 33 | * Both of these licenses include updates and support as well as a warranty. 34 | * Npcap OEM also includes a silent installer for unattended installation. 35 | * Further details about Npcap OEM are available from https://npcap.com/oem/, 36 | * and you are also welcome to contact us at sales@nmap.com to ask any questions 37 | * or set up a license for your organization. 38 | * 39 | * Free and open source software producers are also welcome to contact us for 40 | * redistribution requests. However, we normally recommend that such authors 41 | * instead ask your users to download and install Npcap themselves. It will be 42 | * free for them if they need 5 or fewer copies. 43 | * 44 | * If the Nmap Project (directly or through one of our commercial licensing 45 | * customers) has granted you additional rights to Npcap or Npcap OEM, those 46 | * additional rights take precedence where they conflict with the terms of the 47 | * license agreement. 48 | * 49 | * Since the Npcap source code is available for download and review, users 50 | * sometimes contribute code patches to fix bugs or add new features. By sending 51 | * these changes to the Nmap Project (including through direct email or our 52 | * mailing lists or submitting pull requests through our source code 53 | * repository), it is understood unless you specify otherwise that you are 54 | * offering the Nmap Project the unlimited, non-exclusive right to reuse, 55 | * modify, and relicense your code contribution so that we may (but are not 56 | * obligated to) incorporate it into Npcap. If you wish to specify special 57 | * license conditions or restrictions on your contributions, just say so when 58 | * you send them. 59 | * 60 | * This software is distributed in the hope that it will be useful, but WITHOUT 61 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 62 | * FOR A PARTICULAR PURPOSE. Warranty rights and commercial support are 63 | * available for the OEM Edition described above. 64 | * 65 | * Other copyright notices and attribution may appear below this license header. 66 | * We have kept those for attribution purposes, but any license terms granted by 67 | * those notices apply only to their original work, and not to any changes made 68 | * by the Nmap Project or to this entire file. 69 | * 70 | ***************************************************************************/ 71 | /*++ 72 | 73 | Module Name: 74 | 75 | CalloutInstall.h 76 | 77 | Abstract: 78 | 79 | This is used for installing the Windows Filtering Platform (WFP) callout driver, for capturing the loopback traffic, the used INF file is: npf(npcap)_wfp.inf 80 | 81 | --*/ 82 | #include 83 | 84 | BOOL isFileExist(TCHAR szFileFullPath[]); 85 | 86 | BOOL InstallWFPCallout(); 87 | 88 | BOOL UninstallWFPCallout(); 89 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall/DriverStoreClear.h: -------------------------------------------------------------------------------- 1 | /***********************IMPORTANT NPCAP LICENSE TERMS*********************** 2 | * 3 | * Npcap (https://npcap.com) is a Windows packet sniffing driver and library and 4 | * is copyright (c) 2013-2025 by Nmap Software LLC ("The Nmap Project"). All 5 | * rights reserved. 6 | * 7 | * Even though Npcap source code is publicly available for review, it is not 8 | * open source software and may not be redistributed or used in other software 9 | * without special permission from the Nmap Project. The standard (free) version 10 | * is usually limited to installation on five systems. For more details, see the 11 | * LICENSE file included with Npcap and also available at 12 | * https://github.com/nmap/npcap/blob/master/LICENSE. This header file 13 | * summarizes a few important aspects of the Npcap license, but is not a 14 | * substitute for that full Npcap license agreement. 15 | * 16 | * We fund the Npcap project by selling two types of commercial licenses to a 17 | * special Npcap OEM edition: 18 | * 19 | * 1) The Npcap OEM Redistribution License allows companies distribute Npcap OEM 20 | * within their products. Licensees generally use the Npcap OEM silent 21 | * installer, ensuring a seamless experience for end users. Licensees may choose 22 | * between a perpetual unlimited license or a quarterly term license, along with 23 | * options for commercial support and updates. Prices and details: 24 | * https://npcap.com/oem/redist.html 25 | * 26 | * 2) The Npcap OEM Internal-Use License is for organizations that wish to use 27 | * Npcap OEM internally, without redistribution outside their organization. This 28 | * allows them to bypass the 5-system usage cap of the Npcap free edition. It 29 | * includes commercial support and update options, and provides the extra Npcap 30 | * OEM features such as the silent installer for automated deployment. Prices 31 | * and details: https://npcap.com/oem/internal.html 32 | * 33 | * Both of these licenses include updates and support as well as a warranty. 34 | * Npcap OEM also includes a silent installer for unattended installation. 35 | * Further details about Npcap OEM are available from https://npcap.com/oem/, 36 | * and you are also welcome to contact us at sales@nmap.com to ask any questions 37 | * or set up a license for your organization. 38 | * 39 | * Free and open source software producers are also welcome to contact us for 40 | * redistribution requests. However, we normally recommend that such authors 41 | * instead ask your users to download and install Npcap themselves. It will be 42 | * free for them if they need 5 or fewer copies. 43 | * 44 | * If the Nmap Project (directly or through one of our commercial licensing 45 | * customers) has granted you additional rights to Npcap or Npcap OEM, those 46 | * additional rights take precedence where they conflict with the terms of the 47 | * license agreement. 48 | * 49 | * Since the Npcap source code is available for download and review, users 50 | * sometimes contribute code patches to fix bugs or add new features. By sending 51 | * these changes to the Nmap Project (including through direct email or our 52 | * mailing lists or submitting pull requests through our source code 53 | * repository), it is understood unless you specify otherwise that you are 54 | * offering the Nmap Project the unlimited, non-exclusive right to reuse, 55 | * modify, and relicense your code contribution so that we may (but are not 56 | * obligated to) incorporate it into Npcap. If you wish to specify special 57 | * license conditions or restrictions on your contributions, just say so when 58 | * you send them. 59 | * 60 | * This software is distributed in the hope that it will be useful, but WITHOUT 61 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 62 | * FOR A PARTICULAR PURPOSE. Warranty rights and commercial support are 63 | * available for the OEM Edition described above. 64 | * 65 | * Other copyright notices and attribution may appear below this license header. 66 | * We have kept those for attribution purposes, but any license terms granted by 67 | * those notices apply only to their original work, and not to any changes made 68 | * by the Nmap Project or to this entire file. 69 | * 70 | ***************************************************************************/ 71 | /*++ 72 | 73 | Module Name: 74 | 75 | DriverStoreClear.h 76 | 77 | Abstract: 78 | 79 | This is used to clear the cache of Npcap driver in the Driver Store. 80 | 81 | --*/ 82 | 83 | BOOLEAN ClearDriverStore(); 84 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall/LoopbackRecord.h: -------------------------------------------------------------------------------- 1 | /***********************IMPORTANT NPCAP LICENSE TERMS*********************** 2 | * 3 | * Npcap (https://npcap.com) is a Windows packet sniffing driver and library and 4 | * is copyright (c) 2013-2025 by Nmap Software LLC ("The Nmap Project"). All 5 | * rights reserved. 6 | * 7 | * Even though Npcap source code is publicly available for review, it is not 8 | * open source software and may not be redistributed or used in other software 9 | * without special permission from the Nmap Project. The standard (free) version 10 | * is usually limited to installation on five systems. For more details, see the 11 | * LICENSE file included with Npcap and also available at 12 | * https://github.com/nmap/npcap/blob/master/LICENSE. This header file 13 | * summarizes a few important aspects of the Npcap license, but is not a 14 | * substitute for that full Npcap license agreement. 15 | * 16 | * We fund the Npcap project by selling two types of commercial licenses to a 17 | * special Npcap OEM edition: 18 | * 19 | * 1) The Npcap OEM Redistribution License allows companies distribute Npcap OEM 20 | * within their products. Licensees generally use the Npcap OEM silent 21 | * installer, ensuring a seamless experience for end users. Licensees may choose 22 | * between a perpetual unlimited license or a quarterly term license, along with 23 | * options for commercial support and updates. Prices and details: 24 | * https://npcap.com/oem/redist.html 25 | * 26 | * 2) The Npcap OEM Internal-Use License is for organizations that wish to use 27 | * Npcap OEM internally, without redistribution outside their organization. This 28 | * allows them to bypass the 5-system usage cap of the Npcap free edition. It 29 | * includes commercial support and update options, and provides the extra Npcap 30 | * OEM features such as the silent installer for automated deployment. Prices 31 | * and details: https://npcap.com/oem/internal.html 32 | * 33 | * Both of these licenses include updates and support as well as a warranty. 34 | * Npcap OEM also includes a silent installer for unattended installation. 35 | * Further details about Npcap OEM are available from https://npcap.com/oem/, 36 | * and you are also welcome to contact us at sales@nmap.com to ask any questions 37 | * or set up a license for your organization. 38 | * 39 | * Free and open source software producers are also welcome to contact us for 40 | * redistribution requests. However, we normally recommend that such authors 41 | * instead ask your users to download and install Npcap themselves. It will be 42 | * free for them if they need 5 or fewer copies. 43 | * 44 | * If the Nmap Project (directly or through one of our commercial licensing 45 | * customers) has granted you additional rights to Npcap or Npcap OEM, those 46 | * additional rights take precedence where they conflict with the terms of the 47 | * license agreement. 48 | * 49 | * Since the Npcap source code is available for download and review, users 50 | * sometimes contribute code patches to fix bugs or add new features. By sending 51 | * these changes to the Nmap Project (including through direct email or our 52 | * mailing lists or submitting pull requests through our source code 53 | * repository), it is understood unless you specify otherwise that you are 54 | * offering the Nmap Project the unlimited, non-exclusive right to reuse, 55 | * modify, and relicense your code contribution so that we may (but are not 56 | * obligated to) incorporate it into Npcap. If you wish to specify special 57 | * license conditions or restrictions on your contributions, just say so when 58 | * you send them. 59 | * 60 | * This software is distributed in the hope that it will be useful, but WITHOUT 61 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 62 | * FOR A PARTICULAR PURPOSE. Warranty rights and commercial support are 63 | * available for the OEM Edition described above. 64 | * 65 | * Other copyright notices and attribution may appear below this license header. 66 | * We have kept those for attribution purposes, but any license terms granted by 67 | * those notices apply only to their original work, and not to any changes made 68 | * by the Nmap Project or to this entire file. 69 | * 70 | ***************************************************************************/ 71 | /*++ 72 | 73 | Module Name: 74 | 75 | LoopbackRecord.h 76 | 77 | Abstract: 78 | 79 | This is used for enumerating our "Npcap Loopback Adapter" using NetCfg API, if found, we changed its name from "Ethernet X" or "Local Network Area" to "Npcap Loopback Adapter". 80 | Also, we need to make a flag in registry to let the Npcap driver know that "this adapter is ours", so send the loopback traffic to it. 81 | 82 | --*/ 83 | 84 | #include 85 | #include 86 | using namespace std; 87 | 88 | typedef std::basic_string tstring; 89 | 90 | int getIntDevID(TCHAR strDevID[]); 91 | BOOL AddFlagToRegistry(tstring strDeviceName); 92 | BOOL AddFlagToRegistry_Service(tstring strDeviceName); 93 | BOOL RecordLoopbackDevice(int iNpcapAdapterID); 94 | BOOL EraseLoopbackRecord(); 95 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall/LoopbackRename.h: -------------------------------------------------------------------------------- 1 | /***********************IMPORTANT NPCAP LICENSE TERMS*********************** 2 | * 3 | * Npcap (https://npcap.com) is a Windows packet sniffing driver and library and 4 | * is copyright (c) 2013-2025 by Nmap Software LLC ("The Nmap Project"). All 5 | * rights reserved. 6 | * 7 | * Even though Npcap source code is publicly available for review, it is not 8 | * open source software and may not be redistributed or used in other software 9 | * without special permission from the Nmap Project. The standard (free) version 10 | * is usually limited to installation on five systems. For more details, see the 11 | * LICENSE file included with Npcap and also available at 12 | * https://github.com/nmap/npcap/blob/master/LICENSE. This header file 13 | * summarizes a few important aspects of the Npcap license, but is not a 14 | * substitute for that full Npcap license agreement. 15 | * 16 | * We fund the Npcap project by selling two types of commercial licenses to a 17 | * special Npcap OEM edition: 18 | * 19 | * 1) The Npcap OEM Redistribution License allows companies distribute Npcap OEM 20 | * within their products. Licensees generally use the Npcap OEM silent 21 | * installer, ensuring a seamless experience for end users. Licensees may choose 22 | * between a perpetual unlimited license or a quarterly term license, along with 23 | * options for commercial support and updates. Prices and details: 24 | * https://npcap.com/oem/redist.html 25 | * 26 | * 2) The Npcap OEM Internal-Use License is for organizations that wish to use 27 | * Npcap OEM internally, without redistribution outside their organization. This 28 | * allows them to bypass the 5-system usage cap of the Npcap free edition. It 29 | * includes commercial support and update options, and provides the extra Npcap 30 | * OEM features such as the silent installer for automated deployment. Prices 31 | * and details: https://npcap.com/oem/internal.html 32 | * 33 | * Both of these licenses include updates and support as well as a warranty. 34 | * Npcap OEM also includes a silent installer for unattended installation. 35 | * Further details about Npcap OEM are available from https://npcap.com/oem/, 36 | * and you are also welcome to contact us at sales@nmap.com to ask any questions 37 | * or set up a license for your organization. 38 | * 39 | * Free and open source software producers are also welcome to contact us for 40 | * redistribution requests. However, we normally recommend that such authors 41 | * instead ask your users to download and install Npcap themselves. It will be 42 | * free for them if they need 5 or fewer copies. 43 | * 44 | * If the Nmap Project (directly or through one of our commercial licensing 45 | * customers) has granted you additional rights to Npcap or Npcap OEM, those 46 | * additional rights take precedence where they conflict with the terms of the 47 | * license agreement. 48 | * 49 | * Since the Npcap source code is available for download and review, users 50 | * sometimes contribute code patches to fix bugs or add new features. By sending 51 | * these changes to the Nmap Project (including through direct email or our 52 | * mailing lists or submitting pull requests through our source code 53 | * repository), it is understood unless you specify otherwise that you are 54 | * offering the Nmap Project the unlimited, non-exclusive right to reuse, 55 | * modify, and relicense your code contribution so that we may (but are not 56 | * obligated to) incorporate it into Npcap. If you wish to specify special 57 | * license conditions or restrictions on your contributions, just say so when 58 | * you send them. 59 | * 60 | * This software is distributed in the hope that it will be useful, but WITHOUT 61 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 62 | * FOR A PARTICULAR PURPOSE. Warranty rights and commercial support are 63 | * available for the OEM Edition described above. 64 | * 65 | * Other copyright notices and attribution may appear below this license header. 66 | * We have kept those for attribution purposes, but any license terms granted by 67 | * those notices apply only to their original work, and not to any changes made 68 | * by the Nmap Project or to this entire file. 69 | * 70 | ***************************************************************************/ 71 | /*++ 72 | 73 | Module Name: 74 | 75 | LoopbackRename.h 76 | 77 | Abstract: 78 | 79 | This is used for enumerating our "Npcap Loopback Adapter" using NetCfg API, if found, we changed its name from "Ethernet X" to "Npcap Loopback Adapter". 80 | Also, we need to make a flag in registry to let the Npcap driver know that "this adapter is ours", so send the loopback traffic to it. 81 | 82 | This code is modified based on example: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364686.aspx 83 | --*/ 84 | 85 | #include "..\..\Common\WpcapNames.h" 86 | 87 | #include 88 | 89 | BOOL RenameLoopbackNetwork(TCHAR strDeviceName[]); 90 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall/LoopbackRename2.h: -------------------------------------------------------------------------------- 1 | /***********************IMPORTANT NPCAP LICENSE TERMS*********************** 2 | * 3 | * Npcap (https://npcap.com) is a Windows packet sniffing driver and library and 4 | * is copyright (c) 2013-2025 by Nmap Software LLC ("The Nmap Project"). All 5 | * rights reserved. 6 | * 7 | * Even though Npcap source code is publicly available for review, it is not 8 | * open source software and may not be redistributed or used in other software 9 | * without special permission from the Nmap Project. The standard (free) version 10 | * is usually limited to installation on five systems. For more details, see the 11 | * LICENSE file included with Npcap and also available at 12 | * https://github.com/nmap/npcap/blob/master/LICENSE. This header file 13 | * summarizes a few important aspects of the Npcap license, but is not a 14 | * substitute for that full Npcap license agreement. 15 | * 16 | * We fund the Npcap project by selling two types of commercial licenses to a 17 | * special Npcap OEM edition: 18 | * 19 | * 1) The Npcap OEM Redistribution License allows companies distribute Npcap OEM 20 | * within their products. Licensees generally use the Npcap OEM silent 21 | * installer, ensuring a seamless experience for end users. Licensees may choose 22 | * between a perpetual unlimited license or a quarterly term license, along with 23 | * options for commercial support and updates. Prices and details: 24 | * https://npcap.com/oem/redist.html 25 | * 26 | * 2) The Npcap OEM Internal-Use License is for organizations that wish to use 27 | * Npcap OEM internally, without redistribution outside their organization. This 28 | * allows them to bypass the 5-system usage cap of the Npcap free edition. It 29 | * includes commercial support and update options, and provides the extra Npcap 30 | * OEM features such as the silent installer for automated deployment. Prices 31 | * and details: https://npcap.com/oem/internal.html 32 | * 33 | * Both of these licenses include updates and support as well as a warranty. 34 | * Npcap OEM also includes a silent installer for unattended installation. 35 | * Further details about Npcap OEM are available from https://npcap.com/oem/, 36 | * and you are also welcome to contact us at sales@nmap.com to ask any questions 37 | * or set up a license for your organization. 38 | * 39 | * Free and open source software producers are also welcome to contact us for 40 | * redistribution requests. However, we normally recommend that such authors 41 | * instead ask your users to download and install Npcap themselves. It will be 42 | * free for them if they need 5 or fewer copies. 43 | * 44 | * If the Nmap Project (directly or through one of our commercial licensing 45 | * customers) has granted you additional rights to Npcap or Npcap OEM, those 46 | * additional rights take precedence where they conflict with the terms of the 47 | * license agreement. 48 | * 49 | * Since the Npcap source code is available for download and review, users 50 | * sometimes contribute code patches to fix bugs or add new features. By sending 51 | * these changes to the Nmap Project (including through direct email or our 52 | * mailing lists or submitting pull requests through our source code 53 | * repository), it is understood unless you specify otherwise that you are 54 | * offering the Nmap Project the unlimited, non-exclusive right to reuse, 55 | * modify, and relicense your code contribution so that we may (but are not 56 | * obligated to) incorporate it into Npcap. If you wish to specify special 57 | * license conditions or restrictions on your contributions, just say so when 58 | * you send them. 59 | * 60 | * This software is distributed in the hope that it will be useful, but WITHOUT 61 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 62 | * FOR A PARTICULAR PURPOSE. Warranty rights and commercial support are 63 | * available for the OEM Edition described above. 64 | * 65 | * Other copyright notices and attribution may appear below this license header. 66 | * We have kept those for attribution purposes, but any license terms granted by 67 | * those notices apply only to their original work, and not to any changes made 68 | * by the Nmap Project or to this entire file. 69 | * 70 | ***************************************************************************/ 71 | /*++ 72 | 73 | Module Name: 74 | 75 | LoopbackRename2.h 76 | 77 | Abstract: 78 | 79 | This is used for enumerating our "Npcap Loopback Adapter" using netsh.exe tool, if found, we changed its name from "Ethernet X" to "Npcap Loopback Adapter". 80 | 81 | This code is based on the Windows built-in netsh.exe tool. 82 | --*/ 83 | 84 | #include "..\..\Common\WpcapNames.h" 85 | 86 | #include 87 | #include 88 | #include 89 | using namespace std; 90 | 91 | typedef std::basic_string tstring; 92 | #include 93 | 94 | tstring executeCommand(TCHAR* strCmd); 95 | 96 | void PrepareRenameLoopbackNetwork2(); 97 | 98 | BOOL DoRenameLoopbackNetwork2(); 99 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall/NPFInstall.exe.manifest.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall/NPFInstall.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | 91 | 92 | Resource Files 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall/ProcessUtil.h: -------------------------------------------------------------------------------- 1 | /***********************IMPORTANT NPCAP LICENSE TERMS*********************** 2 | * 3 | * Npcap (https://npcap.com) is a Windows packet sniffing driver and library and 4 | * is copyright (c) 2013-2025 by Nmap Software LLC ("The Nmap Project"). All 5 | * rights reserved. 6 | * 7 | * Even though Npcap source code is publicly available for review, it is not 8 | * open source software and may not be redistributed or used in other software 9 | * without special permission from the Nmap Project. The standard (free) version 10 | * is usually limited to installation on five systems. For more details, see the 11 | * LICENSE file included with Npcap and also available at 12 | * https://github.com/nmap/npcap/blob/master/LICENSE. This header file 13 | * summarizes a few important aspects of the Npcap license, but is not a 14 | * substitute for that full Npcap license agreement. 15 | * 16 | * We fund the Npcap project by selling two types of commercial licenses to a 17 | * special Npcap OEM edition: 18 | * 19 | * 1) The Npcap OEM Redistribution License allows companies distribute Npcap OEM 20 | * within their products. Licensees generally use the Npcap OEM silent 21 | * installer, ensuring a seamless experience for end users. Licensees may choose 22 | * between a perpetual unlimited license or a quarterly term license, along with 23 | * options for commercial support and updates. Prices and details: 24 | * https://npcap.com/oem/redist.html 25 | * 26 | * 2) The Npcap OEM Internal-Use License is for organizations that wish to use 27 | * Npcap OEM internally, without redistribution outside their organization. This 28 | * allows them to bypass the 5-system usage cap of the Npcap free edition. It 29 | * includes commercial support and update options, and provides the extra Npcap 30 | * OEM features such as the silent installer for automated deployment. Prices 31 | * and details: https://npcap.com/oem/internal.html 32 | * 33 | * Both of these licenses include updates and support as well as a warranty. 34 | * Npcap OEM also includes a silent installer for unattended installation. 35 | * Further details about Npcap OEM are available from https://npcap.com/oem/, 36 | * and you are also welcome to contact us at sales@nmap.com to ask any questions 37 | * or set up a license for your organization. 38 | * 39 | * Free and open source software producers are also welcome to contact us for 40 | * redistribution requests. However, we normally recommend that such authors 41 | * instead ask your users to download and install Npcap themselves. It will be 42 | * free for them if they need 5 or fewer copies. 43 | * 44 | * If the Nmap Project (directly or through one of our commercial licensing 45 | * customers) has granted you additional rights to Npcap or Npcap OEM, those 46 | * additional rights take precedence where they conflict with the terms of the 47 | * license agreement. 48 | * 49 | * Since the Npcap source code is available for download and review, users 50 | * sometimes contribute code patches to fix bugs or add new features. By sending 51 | * these changes to the Nmap Project (including through direct email or our 52 | * mailing lists or submitting pull requests through our source code 53 | * repository), it is understood unless you specify otherwise that you are 54 | * offering the Nmap Project the unlimited, non-exclusive right to reuse, 55 | * modify, and relicense your code contribution so that we may (but are not 56 | * obligated to) incorporate it into Npcap. If you wish to specify special 57 | * license conditions or restrictions on your contributions, just say so when 58 | * you send them. 59 | * 60 | * This software is distributed in the hope that it will be useful, but WITHOUT 61 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 62 | * FOR A PARTICULAR PURPOSE. Warranty rights and commercial support are 63 | * available for the OEM Edition described above. 64 | * 65 | * Other copyright notices and attribution may appear below this license header. 66 | * We have kept those for attribution purposes, but any license terms granted by 67 | * those notices apply only to their original work, and not to any changes made 68 | * by the Nmap Project or to this entire file. 69 | * 70 | ***************************************************************************/ 71 | /*++ 72 | 73 | Module Name: 74 | 75 | ProcessUtil.h 76 | 77 | Abstract: 78 | 79 | Get processes which are using Npcap DLLs. 80 | 81 | --*/ 82 | 83 | #include 84 | #include 85 | using namespace std; 86 | 87 | typedef std::basic_string tstring; 88 | 89 | tstring getInUseProcesses(); 90 | 91 | BOOL killInUseProcesses(); 92 | 93 | BOOL killInUseProcesses_Soft(); 94 | 95 | BOOL killInUseProcesses_Polite(); 96 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall/RegUtil.h: -------------------------------------------------------------------------------- 1 | /***********************IMPORTANT NPCAP LICENSE TERMS*********************** 2 | * 3 | * Npcap (https://npcap.com) is a Windows packet sniffing driver and library and 4 | * is copyright (c) 2013-2025 by Nmap Software LLC ("The Nmap Project"). All 5 | * rights reserved. 6 | * 7 | * Even though Npcap source code is publicly available for review, it is not 8 | * open source software and may not be redistributed or used in other software 9 | * without special permission from the Nmap Project. The standard (free) version 10 | * is usually limited to installation on five systems. For more details, see the 11 | * LICENSE file included with Npcap and also available at 12 | * https://github.com/nmap/npcap/blob/master/LICENSE. This header file 13 | * summarizes a few important aspects of the Npcap license, but is not a 14 | * substitute for that full Npcap license agreement. 15 | * 16 | * We fund the Npcap project by selling two types of commercial licenses to a 17 | * special Npcap OEM edition: 18 | * 19 | * 1) The Npcap OEM Redistribution License allows companies distribute Npcap OEM 20 | * within their products. Licensees generally use the Npcap OEM silent 21 | * installer, ensuring a seamless experience for end users. Licensees may choose 22 | * between a perpetual unlimited license or a quarterly term license, along with 23 | * options for commercial support and updates. Prices and details: 24 | * https://npcap.com/oem/redist.html 25 | * 26 | * 2) The Npcap OEM Internal-Use License is for organizations that wish to use 27 | * Npcap OEM internally, without redistribution outside their organization. This 28 | * allows them to bypass the 5-system usage cap of the Npcap free edition. It 29 | * includes commercial support and update options, and provides the extra Npcap 30 | * OEM features such as the silent installer for automated deployment. Prices 31 | * and details: https://npcap.com/oem/internal.html 32 | * 33 | * Both of these licenses include updates and support as well as a warranty. 34 | * Npcap OEM also includes a silent installer for unattended installation. 35 | * Further details about Npcap OEM are available from https://npcap.com/oem/, 36 | * and you are also welcome to contact us at sales@nmap.com to ask any questions 37 | * or set up a license for your organization. 38 | * 39 | * Free and open source software producers are also welcome to contact us for 40 | * redistribution requests. However, we normally recommend that such authors 41 | * instead ask your users to download and install Npcap themselves. It will be 42 | * free for them if they need 5 or fewer copies. 43 | * 44 | * If the Nmap Project (directly or through one of our commercial licensing 45 | * customers) has granted you additional rights to Npcap or Npcap OEM, those 46 | * additional rights take precedence where they conflict with the terms of the 47 | * license agreement. 48 | * 49 | * Since the Npcap source code is available for download and review, users 50 | * sometimes contribute code patches to fix bugs or add new features. By sending 51 | * these changes to the Nmap Project (including through direct email or our 52 | * mailing lists or submitting pull requests through our source code 53 | * repository), it is understood unless you specify otherwise that you are 54 | * offering the Nmap Project the unlimited, non-exclusive right to reuse, 55 | * modify, and relicense your code contribution so that we may (but are not 56 | * obligated to) incorporate it into Npcap. If you wish to specify special 57 | * license conditions or restrictions on your contributions, just say so when 58 | * you send them. 59 | * 60 | * This software is distributed in the hope that it will be useful, but WITHOUT 61 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 62 | * FOR A PARTICULAR PURPOSE. Warranty rights and commercial support are 63 | * available for the OEM Edition described above. 64 | * 65 | * Other copyright notices and attribution may appear below this license header. 66 | * We have kept those for attribution purposes, but any license terms granted by 67 | * those notices apply only to their original work, and not to any changes made 68 | * by the Nmap Project or to this entire file. 69 | * 70 | ***************************************************************************/ 71 | /*++ 72 | 73 | Module Name: 74 | 75 | RegUtil.h 76 | 77 | Abstract: 78 | 79 | This is used for operating on registry. 80 | 81 | --*/ 82 | 83 | #include "..\..\Common\WpcapNames.h" 84 | 85 | #define NPF_SOFT_REGISTRY_NAME_T _T(NPF_SOFT_REGISTRY_NAME) 86 | #define NPF_DRIVER_NAME_SMALL_T _T(NPF_DRIVER_NAME_SMALL) 87 | #define NPCAP_REG_KEY_NAME _T("SOFTWARE\\") NPF_SOFT_REGISTRY_NAME_T 88 | #define NPCAP_SERVICE_REG_KEY_NAME _T("SYSTEM\\CurrentControlSet\\Services\\") NPF_DRIVER_NAME_SMALL_T 89 | #define NPCAP_REG_LOOPBACK_VALUE_NAME _T("LoopbackAdapter") 90 | 91 | BOOL WriteStrToRegistry(LPCTSTR strSubKey, LPCTSTR strValueName, LPCTSTR strDeviceName, DWORD dwSamDesired); 92 | BOOL DeleteValueFromRegistry(LPCTSTR strSubKey, LPCTSTR strValueName); 93 | BOOL IncrementRegistryDword(LPCTSTR strSubKey, LPCTSTR strValueName, DWORD maxValue); 94 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall/rc_ids.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Module Name: 6 | 7 | rc_ids.h 8 | 9 | Abstract: 10 | 11 | Header for devcon resources 12 | 13 | --*/ 14 | 15 | #define IDS_ENABLED 3000 16 | #define IDS_ENABLED_REBOOT 3001 17 | #define IDS_ENABLE_FAILED 3002 18 | #define IDS_DISABLED 3003 19 | #define IDS_DISABLED_REBOOT 3004 20 | #define IDS_DISABLE_FAILED 3005 21 | #define IDS_RESTARTED 3006 22 | #define IDS_REQUIRES_REBOOT 3007 23 | #define IDS_RESTART_FAILED 3008 24 | #define IDS_REMOVED 3009 25 | #define IDS_REMOVED_REBOOT 3010 26 | #define IDS_REMOVE_FAILED 3011 27 | 28 | 29 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall/version.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | 4 | #define APSTUDIO_READONLY_SYMBOLS 5 | ///////////////////////////////////////////////////////////////////////////// 6 | // 7 | // Generated from the TEXTINCLUDE 2 resource. 8 | // 9 | #include "winresrc.h" 10 | #ifndef IDC_STATIC 11 | #define IDC_STATIC (-1) 12 | #endif 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | #undef APSTUDIO_READONLY_SYMBOLS 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // Neutral resources 19 | 20 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) 21 | #ifdef _WIN32 22 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 23 | #pragma code_page(1252) 24 | #endif //_WIN32 25 | 26 | #ifdef APSTUDIO_INVOKED 27 | ///////////////////////////////////////////////////////////////////////////// 28 | // 29 | // TEXTINCLUDE 30 | // 31 | 32 | 1 TEXTINCLUDE 33 | BEGIN 34 | "\r\n" 35 | "\0" 36 | END 37 | 38 | 2 TEXTINCLUDE 39 | BEGIN 40 | "#include ""afxres.h""\r\n" 41 | "\0" 42 | END 43 | 44 | 3 TEXTINCLUDE 45 | BEGIN 46 | "#include ""version.rc2""\r\n" 47 | "\r\n" 48 | "\0" 49 | END 50 | 51 | #endif // APSTUDIO_INVOKED 52 | 53 | #endif // Neutral resources 54 | ///////////////////////////////////////////////////////////////////////////// 55 | 56 | 57 | 58 | #ifndef APSTUDIO_INVOKED 59 | ///////////////////////////////////////////////////////////////////////////// 60 | // 61 | // Generated from the TEXTINCLUDE 3 resource. 62 | // 63 | #include "version.rc2" 64 | 65 | ///////////////////////////////////////////////////////////////////////////// 66 | #endif // not APSTUDIO_INVOKED 67 | 68 | -------------------------------------------------------------------------------- /packetWin7/NPFInstall/NPFInstall/version.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // version.rc2 - resources Microsoft Visual C++ does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by Microsoft Visual C++ 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | #include "..\..\..\version.h" 11 | 12 | VS_VERSION_INFO VERSIONINFO 13 | FILEVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 14 | PRODUCTVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 15 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 16 | #ifdef _DEBUG 17 | FILEFLAGS VS_FF_DEBUG 18 | #else 19 | FILEFLAGS 0x0L 20 | #endif 21 | FILEOS VOS_NT_WINDOWS32 22 | FILETYPE VFT_APP 23 | FILESUBTYPE 0x0L 24 | BEGIN 25 | BLOCK "StringFileInfo" 26 | BEGIN 27 | BLOCK "000004b0" 28 | BEGIN 29 | VALUE "CompanyName", WINPCAP_COMPANY_NAME 30 | VALUE "FileDescription", "A LWF & WFP driver installation tool" 31 | VALUE "FileVersion", WINPCAP_VER_STRING 32 | VALUE "InternalName", "NPFInstall.exe" 33 | VALUE "LegalCopyright", WINPCAP_COPYRIGHT_STRING 34 | VALUE "LegalTrademarks", "" 35 | VALUE "OriginalFilename", "NPFInstall.exe" 36 | VALUE "ProductName", WINPCAP_PRODUCT_NAME 37 | VALUE "ProductVersion", WINPCAP_VER_STRING 38 | END 39 | END 40 | BLOCK "VarFileInfo" 41 | BEGIN 42 | VALUE "Translation", 0x0, 1200 43 | END 44 | END 45 | -------------------------------------------------------------------------------- /packetWin7/WlanHelper/WlanHelper.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WlanHelper", "WlanHelper\WlanHelper.vcxproj", "{044CB4DC-827D-4134-B14B-DE114E884BB9}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | OEM Release|Win32 = OEM Release|Win32 13 | OEM Release|x64 = OEM Release|x64 14 | Release|Win32 = Release|Win32 15 | Release|x64 = Release|x64 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.Debug|Win32.Build.0 = Debug|Win32 20 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.Debug|x64.ActiveCfg = Debug|x64 21 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.Debug|x64.Build.0 = Debug|x64 22 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.OEM Release|Win32.ActiveCfg = OEM Release|Win32 23 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.OEM Release|Win32.Build.0 = OEM Release|Win32 24 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.OEM Release|x64.ActiveCfg = OEM Release|x64 25 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.OEM Release|x64.Build.0 = OEM Release|x64 26 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.Release|Win32.ActiveCfg = Release|Win32 27 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.Release|Win32.Build.0 = Release|Win32 28 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.Release|x64.ActiveCfg = Release|x64 29 | {044CB4DC-827D-4134-B14B-DE114E884BB9}.Release|x64.Build.0 = Release|x64 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /packetWin7/WlanHelper/WlanHelper/WlanHelper.exe.manifest.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /packetWin7/WlanHelper/WlanHelper/WlanHelper.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | 31 | 32 | Resource Files 33 | 34 | 35 | -------------------------------------------------------------------------------- /packetWin7/WlanHelper/WlanHelper/version.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nmap/npcap/33105960dc380d2f22ab853a931fb5b915b4ba62/packetWin7/WlanHelper/WlanHelper/version.rc -------------------------------------------------------------------------------- /packetWin7/WlanHelper/WlanHelper/version.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // version.rc2 - resources Microsoft Visual C++ does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by Microsoft Visual C++ 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | #include "..\..\..\version.h" 11 | 12 | VS_VERSION_INFO VERSIONINFO 13 | FILEVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 14 | PRODUCTVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 15 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 16 | #ifdef _DEBUG 17 | FILEFLAGS VS_FF_DEBUG 18 | #else 19 | FILEFLAGS 0x0L 20 | #endif 21 | FILEOS VOS_NT_WINDOWS32 22 | FILETYPE VFT_APP 23 | FILESUBTYPE 0x0L 24 | BEGIN 25 | BLOCK "StringFileInfo" 26 | BEGIN 27 | BLOCK "000004b0" 28 | BEGIN 29 | VALUE "CompanyName", WINPCAP_COMPANY_NAME 30 | VALUE "FileDescription", "A tool for wireless adapter settings" 31 | VALUE "FileVersion", WINPCAP_VER_STRING 32 | VALUE "InternalName", "WlanHelper.exe" 33 | VALUE "LegalCopyright", WINPCAP_COPYRIGHT_STRING 34 | VALUE "LegalTrademarks", "" 35 | VALUE "OriginalFilename", "WlanHelper.exe" 36 | VALUE "ProductName", WINPCAP_PRODUCT_NAME 37 | VALUE "ProductVersion", WINPCAP_VER_STRING 38 | VALUE "Build Description", WINPCAP_BUILD_DESCRIPTION 39 | END 40 | END 41 | BLOCK "VarFileInfo" 42 | BEGIN 43 | VALUE "Translation", 0x0, 1200 44 | END 45 | END 46 | -------------------------------------------------------------------------------- /packetWin7/npf/npf/npcap.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "..\..\..\version.h" 3 | 4 | ///////////////////////////////////////////////////////////////////////////// 5 | // 6 | // Version 7 | // 8 | VS_VERSION_INFO VERSIONINFO 9 | FILEVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 10 | PRODUCTVERSION WINPCAP_MAJOR,WINPCAP_MINOR,WINPCAP_REV,WINPCAP_BUILD 11 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 12 | #ifdef DBG 13 | FILEFLAGS VS_FF_DEBUG 14 | #else 15 | FILEFLAGS 0x0L 16 | #endif 17 | FILEOS VOS_NT_WINDOWS32 18 | FILETYPE VFT_DRV 19 | FILESUBTYPE VFT2_DRV_SYSTEM 20 | BEGIN 21 | BLOCK "StringFileInfo" 22 | BEGIN 23 | BLOCK "000004b0" 24 | BEGIN 25 | VALUE "CompanyName", WINPCAP_COMPANY_NAME 26 | #ifdef _AMD64_ 27 | VALUE "FileDescription", "npcap.sys (NT6 AMD64) Kernel Filter Driver" 28 | #else 29 | VALUE "FileDescription", "npcap.sys (NT6 x86) Kernel Filter Driver" 30 | #endif 31 | VALUE "FileVersion", WINPCAP_VER_STRING 32 | VALUE "InternalName", "NPCAP" 33 | VALUE "LegalCopyright", WINPCAP_COPYRIGHT_STRING 34 | VALUE "LegalTrademarks", "" 35 | VALUE "OriginalFilename", "npcap.sys" 36 | VALUE "ProductName", WINPCAP_PRODUCT_NAME 37 | VALUE "ProductVersion", WINPCAP_VER_STRING 38 | END 39 | END 40 | BLOCK "VarFileInfo" 41 | BEGIN 42 | VALUE "Translation", 0x0, 1200 43 | END 44 | END 45 | -------------------------------------------------------------------------------- /packetWin7/npf/npf/npcap_wfp.inf: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------- 2 | ; NPCAP_WFP.INF -- Npcap NDIS 6.x LightWeight Filter Driver 3 | ; 4 | ; Copyright (c) 2025, Nmap Software LLC. All rights reserved. 5 | ;------------------------------------------------------------------------ 6 | [version] 7 | Signature = "$Windows NT$" 8 | Class = WFPCALLOUTS 9 | ClassGUID = {57465043-616C-6C6F-7574-5F636C617373} 10 | CatalogFile = %NPF_DriverName%.cat 11 | Provider = %Insecure% 12 | DriverVer=05/15/2015,14.48.38.905 13 | PnpLockDown=1 14 | 15 | 16 | [Manufacturer] 17 | %Insecure%=Insecure,NTx86,NTARM64,NTamd64 18 | 19 | [Insecure.NTx86] 20 | %NPF_Desc%=Install, INSECURE_NPCAP 21 | 22 | [Insecure.NTARM64] 23 | %NPF_Desc%=Install, INSECURE_NPCAP 24 | 25 | [Insecure.NTamd64] 26 | %NPF_Desc%=Install, INSECURE_NPCAP 27 | 28 | ;------------------------------------------------------------------------- 29 | ; Installation Section 30 | ;------------------------------------------------------------------------- 31 | [Install] 32 | AddReg=Inst_Ndi 33 | Characteristics=0x40000 34 | NetCfgInstanceId="{7daf2ac8-e9f6-4765-a842-f1f5d2501341}" 35 | Copyfiles = npf.copyfiles.sys 36 | 37 | [SourceDisksNames] 38 | 1=%NPF_Desc%,"",, 39 | 40 | [SourceDisksFiles] 41 | npcap.sys=1 42 | 43 | [DestinationDirs] 44 | DefaultDestDir=12 45 | npf.copyfiles.sys=12 46 | 47 | [npf.copyfiles.sys] 48 | %NPF_DriverName%.sys,,,2 49 | 50 | 51 | ;------------------------------------------------------------------------- 52 | ; Ndi installation support 53 | ;------------------------------------------------------------------------- 54 | [Inst_Ndi] 55 | HKR, Ndi,Service,,%NPF_DriverName% 56 | HKR, Ndi,CoServices,0x00010000,%NPF_DriverName% 57 | HKR, Ndi,HelpText,,%NPF_HelpText% 58 | 59 | ;------------------------------------------------------------------------- 60 | ; Service installation support 61 | ;------------------------------------------------------------------------- 62 | [Install.Services] 63 | AddService=%NPF_DriverName%,,NPF_Service_Inst 64 | AddService=,2 65 | 66 | [NPF_Service_Inst] 67 | DisplayName = %NPF_Desc% 68 | ServiceType = 1 ;SERVICE_KERNEL_DRIVER 69 | StartType = 1 ;SERVICE_SYSTEM_START 70 | ErrorControl = 1 ;SERVICE_ERROR_NORMAL 71 | ServiceBinary = %12%\%NPF_DriverName%.sys 72 | LoadOrderGroup = NDIS 73 | Description = %NPF_Desc% 74 | AddReg = Common.Params.reg 75 | 76 | [Common.Params.reg] 77 | 78 | [Strings] 79 | NPF_DriverName = "npcap" 80 | Insecure = "Nmap Project" 81 | NPF_Desc = "Npcap Packet Driver (NPCAP)" 82 | NPF_HelpText = "A NDIS 6 filter driver & WFP callout driver to support packet capturing and sending under Windows 7, 8 & 10" 83 | -------------------------------------------------------------------------------- /packetWin7/npf/npf/npf.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Source Files 6 | 7 | 8 | Source Files 9 | 10 | 11 | Source Files 12 | 13 | 14 | Source Files 15 | 16 | 17 | Source Files 18 | 19 | 20 | Source Files 21 | 22 | 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | Header Files 44 | 45 | 46 | Header Files 47 | 48 | 49 | Header Files 50 | 51 | 52 | 53 | 54 | Driver Files 55 | 56 | 57 | Driver Files 58 | 59 | 60 | 61 | 62 | {5481204c-ccff-42d5-ac09-0a194cc3cf17} 63 | 64 | 65 | {a7428563-a40c-41d0-924b-d9d4c19fbc02} 66 | 67 | 68 | {bb3bdb45-b66d-4ceb-9cae-41d99d8bda6e} 69 | 70 | 71 | {41d550b0-0cfb-4e43-b66c-30757a553772} 72 | 73 | 74 | 75 | 76 | Resource Files 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /packetWin7/npf/npf/stdafx.h: -------------------------------------------------------------------------------- 1 | /***********************IMPORTANT NPCAP LICENSE TERMS*********************** 2 | * 3 | * Npcap (https://npcap.com) is a Windows packet sniffing driver and library and 4 | * is copyright (c) 2013-2025 by Nmap Software LLC ("The Nmap Project"). All 5 | * rights reserved. 6 | * 7 | * Even though Npcap source code is publicly available for review, it is not 8 | * open source software and may not be redistributed or used in other software 9 | * without special permission from the Nmap Project. The standard (free) version 10 | * is usually limited to installation on five systems. For more details, see the 11 | * LICENSE file included with Npcap and also available at 12 | * https://github.com/nmap/npcap/blob/master/LICENSE. This header file 13 | * summarizes a few important aspects of the Npcap license, but is not a 14 | * substitute for that full Npcap license agreement. 15 | * 16 | * We fund the Npcap project by selling two types of commercial licenses to a 17 | * special Npcap OEM edition: 18 | * 19 | * 1) The Npcap OEM Redistribution License allows companies distribute Npcap OEM 20 | * within their products. Licensees generally use the Npcap OEM silent 21 | * installer, ensuring a seamless experience for end users. Licensees may choose 22 | * between a perpetual unlimited license or a quarterly term license, along with 23 | * options for commercial support and updates. Prices and details: 24 | * https://npcap.com/oem/redist.html 25 | * 26 | * 2) The Npcap OEM Internal-Use License is for organizations that wish to use 27 | * Npcap OEM internally, without redistribution outside their organization. This 28 | * allows them to bypass the 5-system usage cap of the Npcap free edition. It 29 | * includes commercial support and update options, and provides the extra Npcap 30 | * OEM features such as the silent installer for automated deployment. Prices 31 | * and details: https://npcap.com/oem/internal.html 32 | * 33 | * Both of these licenses include updates and support as well as a warranty. 34 | * Npcap OEM also includes a silent installer for unattended installation. 35 | * Further details about Npcap OEM are available from https://npcap.com/oem/, 36 | * and you are also welcome to contact us at sales@nmap.com to ask any questions 37 | * or set up a license for your organization. 38 | * 39 | * Free and open source software producers are also welcome to contact us for 40 | * redistribution requests. However, we normally recommend that such authors 41 | * instead ask your users to download and install Npcap themselves. It will be 42 | * free for them if they need 5 or fewer copies. 43 | * 44 | * If the Nmap Project (directly or through one of our commercial licensing 45 | * customers) has granted you additional rights to Npcap or Npcap OEM, those 46 | * additional rights take precedence where they conflict with the terms of the 47 | * license agreement. 48 | * 49 | * Since the Npcap source code is available for download and review, users 50 | * sometimes contribute code patches to fix bugs or add new features. By sending 51 | * these changes to the Nmap Project (including through direct email or our 52 | * mailing lists or submitting pull requests through our source code 53 | * repository), it is understood unless you specify otherwise that you are 54 | * offering the Nmap Project the unlimited, non-exclusive right to reuse, 55 | * modify, and relicense your code contribution so that we may (but are not 56 | * obligated to) incorporate it into Npcap. If you wish to specify special 57 | * license conditions or restrictions on your contributions, just say so when 58 | * you send them. 59 | * 60 | * This software is distributed in the hope that it will be useful, but WITHOUT 61 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 62 | * FOR A PARTICULAR PURPOSE. Warranty rights and commercial support are 63 | * available for the OEM Edition described above. 64 | * 65 | * Other copyright notices and attribution may appear below this license header. 66 | * We have kept those for attribution purposes, but any license terms granted by 67 | * those notices apply only to their original work, and not to any changes made 68 | * by the Nmap Project or to this entire file. 69 | * 70 | ***************************************************************************/ 71 | 72 | #define NPF_REQUEST_ID '5678' 73 | 74 | #define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1) 75 | 76 | #include 77 | #include 78 | #include 79 | #include 80 | #include 81 | #include "macros.h" 82 | #include "memory_tags.h" 83 | -------------------------------------------------------------------------------- /test/README.md: -------------------------------------------------------------------------------- 1 | #Tests for Npcap. 2 | 3 | Requirements: 4 | 5 | * Npcap installed 6 | * Nmap installed 7 | * Some examples from the SDK 8 | 9 | ##SDK examples required 10 | 11 | From `Examples-pcap`: 12 | 13 | * iflist.exe 14 | * pcap_filter.exe 15 | * sendpack.exe 16 | * readfile.exe 17 | 18 | From `Examples-remote`: 19 | 20 | * sendcap.exe 21 | -------------------------------------------------------------------------------- /test/make_test.bat: -------------------------------------------------------------------------------- 1 | SET SAVEPID=0 2 | 3 | set ARCH=x86 4 | rem All platforms support x86 emulation 5 | Call :DO_TEST x86 || goto :error 6 | 7 | rem If we're running in native arch, 8 | if "%PROCESSOR_ARCHITEW6432%" == "" ( 9 | rem and it's x86, we're done. 10 | if "%PROCESSOR_ARCHITECTURE%" == "x86" goto :quit 11 | 12 | rem Otherwise, test the native arch 13 | set ARCH=%PROCESSOR_ARCHITECTURE% 14 | ) else ( 15 | rem Otherwise, we're running in WOW64, so test the native arch 16 | set ARCH=%PROCESSOR_ARCHITEW6432% 17 | ) 18 | 19 | if "%ARCH%" == "AMD64" ( 20 | set ARCH=x64 21 | ) else ( 22 | if NOT "%ARCH%" == "ARM64" goto :error 23 | ) 24 | 25 | Call :DO_TEST %ARCH% || goto :error 26 | 27 | :quit 28 | pause 29 | exit /b %ERR% 30 | 31 | :error 32 | set ERR=%ERRORLEVEL% 33 | if "%ERR%" == "" set ERR=1 34 | echo %ARCH% Failed: %ERR% 35 | if %SAVEPID% NEQ 0 taskkill /PID %SAVEPID% 36 | goto :quit 37 | 38 | :DO_TEST 39 | 40 | echo Testing iflist... 41 | set devname="" 42 | for /f "TOKENS=1,2" %%a in ('nmap --iflist') do @if %%a==lo0 set devname=%%b 43 | if not "%devname%"=="\Device\NPF_Loopback" goto :error 44 | .\%1\iflist.exe || goto :error 45 | 46 | echo Testing Loopback operations... 47 | echo Testing pcap_filter... 48 | del loopback-%1.pcap 49 | start .\%1\pcap_filter.exe -o loopback-%1.pcap -s %devname% -f tcp -l 1450 50 | for /F "TOKENS=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq pcap_filter.exe"') do set SAVEPID=%%b 51 | if "%SAVEPID%" == "" goto :error 52 | 53 | echo Running nmap... 54 | nmap -F -O -d -n localhost || goto :error 55 | nmap -F -O -d -n -6 localhost || goto :error 56 | 57 | echo Testing sendpack... 58 | .\%1\sendpack.exe %devname% || goto :error 59 | 60 | echo Killing pcap_filter... 61 | taskkill /PID %SAVEPID% || goto :error 62 | SET SAVEPID=0 63 | 64 | echo Reading dump file... 65 | .\%1\readfile.exe -v loopback-%1.pcap || goto :error 66 | 67 | echo Replaying dump file... 68 | .\%1\sendcap.exe loopback-%1.pcap %devname% s || goto :error 69 | 70 | 71 | echo Checking for Internet... 72 | set devname="" 73 | for /f "TOKENS=1,3" %%a in ('nmap --route-dst scanme.nmap.org') do @if %%b==srcaddr set ifname=%%a 74 | if %ifname%=="" goto :error 75 | if %ifname%=="No" goto :error 76 | for /f "TOKENS=1,2" %%a in ('nmap --iflist') do @if %%a==%ifname% set devname=%%b 77 | if not %devname:~0,12%==\Device\NPF_ goto :error 78 | 79 | echo Testing pcap_filter... 80 | del scanme-%1.pcap 81 | start .\%1\pcap_filter.exe -o scanme-%1.pcap -s %devname% -f tcp -l 1450 82 | for /F "TOKENS=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq pcap_filter.exe"') do set SAVEPID=%%b 83 | 84 | echo Running nmap... 85 | nmap -F -O -d -n scanme.nmap.org || goto :error 86 | rem Need IPv6 connectivity to test this: 87 | rem nmap -F -O -d -n -6 scanme.nmap.org || goto :error 88 | 89 | echo Testing sendpack... 90 | .\%1\sendpack.exe %devname% || goto :error 91 | 92 | echo Killing pcap_filter... 93 | taskkill /PID %SAVEPID% || goto :error 94 | SET SAVEPID=0 95 | 96 | echo Reading dump file... 97 | .\%1\readfile.exe -v scanme-%1.pcap || goto :error 98 | 99 | echo Replaying dump file... 100 | .\%1\sendcap.exe scanme-%1.pcap %devname% || goto :error 101 | 102 | goto :EOF 103 | -------------------------------------------------------------------------------- /test/static.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MultiThreaded 6 | 7 | 8 | 9 | 10 | MultiThreadedDebug 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /wpcap/wpcap-cmake.bat: -------------------------------------------------------------------------------- 1 | for /f "usebackq delims=#" %%a in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -version 17 -property installationPath`) do set CMAKE="%%a\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" 2 | set GENERATOR=Visual Studio 17 2022 3 | set NPCAP_SDK=..\..\npcap-sdk-1.14 4 | set AIRPCAP_SDK=..\..\Airpcap_Devpack 5 | set CFG_FLAGS=/guard:cf 6 | 7 | mkdir build-win32 8 | cd build-win32 9 | %CMAKE% -A Win32 -DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE -DOpenSSL_FOUND=FALSE -DCMAKE_C_FLAGS_INIT=%CFG_FLAGS% -DCMAKE_SHARED_LINKER_FLAGS_INIT=%CFG_FLAGS% -DPacket_ROOT=..\%NPCAP_SDK% -DLIBRARY_NAME=wpcap -DAirPcap_ROOT=..\%AIRPCAP_SDK% -G "%GENERATOR%" ..\libpcap\ 10 | cd .. 11 | 12 | mkdir build-x64 13 | cd build-x64 14 | %CMAKE% -A x64 -DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE -DOpenSSL_FOUND=FALSE -DCMAKE_C_FLAGS_INIT=%CFG_FLAGS% -DCMAKE_SHARED_LINKER_FLAGS_INIT=%CFG_FLAGS% -DPacket_ROOT=..\%NPCAP_SDK% -DLIBRARY_NAME=wpcap -DAirPcap_ROOT=..\%AIRPCAP_SDK% -G "%GENERATOR%" ..\libpcap\ 15 | cd .. 16 | 17 | rem AirPcap does not have ARM64 libs 18 | mkdir build-ARM64 19 | cd build-ARM64 20 | %CMAKE% -A ARM64 -DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE -DOpenSSL_FOUND=FALSE -DCMAKE_C_FLAGS_INIT=%CFG_FLAGS% -DCMAKE_SHARED_LINKER_FLAGS_INIT=%CFG_FLAGS% -DPacket_ROOT=..\%NPCAP_SDK% -DLIBRARY_NAME=wpcap -G "%GENERATOR%" ..\libpcap\ 21 | cd .. 22 | --------------------------------------------------------------------------------