├── .gitignore ├── LICENSE ├── README.md ├── cygwin ├── Makefile ├── README.md └── build_all.bat ├── examples ├── cpp │ ├── capture │ │ ├── README.md │ │ ├── capture.cpp │ │ ├── capture.vcxproj │ │ ├── capture.vcxproj.filters │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── vcpkg-configuration.json │ │ └── vcpkg.json │ ├── common │ │ ├── README.md │ │ ├── dhcp_typedefs.h │ │ ├── iphelper │ │ │ ├── network_adapter_info.h │ │ │ └── process_lookup.h │ │ ├── iphlp.h │ │ ├── log │ │ │ └── log.h │ │ ├── ndisapi │ │ │ ├── dual_packet_filter.h │ │ │ ├── fastio_packet_filter.h │ │ │ ├── local_redirect.h │ │ │ ├── network_adapter.h │ │ │ ├── queued_packet_filter.h │ │ │ ├── simple_packet_filter.h │ │ │ └── udp_proxy.h │ │ ├── net │ │ │ ├── ip_address.h │ │ │ ├── ip_endpoint.h │ │ │ ├── ip_subnet.h │ │ │ ├── ipv6_helper.h │ │ │ └── mac_address.h │ │ ├── pcap │ │ │ ├── pcap.h │ │ │ └── pcap_file_storage.h │ │ ├── proxy │ │ │ ├── proxy_common.h │ │ │ ├── socks5_common.h │ │ │ ├── socks5_tcp_proxy_socket.h │ │ │ ├── tcp_proxy_server.h │ │ │ └── tcp_proxy_socket.h │ │ ├── tools │ │ │ └── strings.h │ │ └── winsys │ │ │ ├── event.h │ │ │ ├── io_completion_port.h │ │ │ └── object.h │ ├── dns_proxy │ │ ├── README.md │ │ ├── dns_proxy.cpp │ │ ├── dns_proxy.vcxproj │ │ ├── dns_proxy.vcxproj.filters │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── vcpkg-configuration.json │ │ └── vcpkg.json │ ├── dnstrace │ │ ├── README.md │ │ ├── dnstrace.cpp │ │ ├── dnstrace.vcxproj │ │ ├── dnstrace.vcxproj.filters │ │ ├── stdafx.cpp │ │ ├── stdafx.h │ │ ├── targetver.h │ │ ├── vcpkg-configuration.json │ │ └── vcpkg.json │ ├── ethernet_bridge │ │ ├── EthernetBridge.cpp │ │ ├── EthernetBridge.h │ │ ├── NetworkAdapter.cpp │ │ ├── NetworkAdapter.h │ │ ├── README.md │ │ ├── ebridge.cpp │ │ ├── ebridge.h │ │ ├── ebridge.vcxproj │ │ ├── ebridge.vcxproj.filters │ │ ├── stdafx.cpp │ │ ├── stdafx.h │ │ ├── targetver.h │ │ ├── vcpkg-configuration.json │ │ └── vcpkg.json │ ├── hyperscan │ │ ├── README.md │ │ ├── hyperscan.cpp │ │ ├── hyperscan.vcxproj │ │ ├── hyperscan.vcxproj.filters │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── vcpkg-configuration.json │ │ └── vcpkg.json │ ├── ipv6_parser │ │ ├── README.md │ │ ├── ipv6_parser.cpp │ │ ├── ipv6_parser.vcxproj │ │ ├── ipv6_parser.vcxproj.filters │ │ ├── ipv6_parser.vcxproj.user │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── vcpkg-configuration.json │ │ └── vcpkg.json │ ├── pcapplusplus │ │ ├── README.md │ │ ├── pcapplusplus.cpp │ │ ├── pcapplusplus.vcxproj │ │ ├── pcapplusplus.vcxproj.filters │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── vcpkg-configuration.json │ │ └── vcpkg.json │ ├── rebind │ │ ├── README.md │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── rebind.cpp │ │ ├── rebind.vcxproj │ │ ├── rebind.vcxproj.filters │ │ ├── vcpkg-configuration.json │ │ └── vcpkg.json │ ├── sni_inspector │ │ ├── README.md │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── sni_inspector.cpp │ │ ├── sni_inspector.vcxproj │ │ ├── sni_inspector.vcxproj.filters │ │ ├── vcpkg-configuration.json │ │ └── vcpkg.json │ ├── socksify │ │ ├── README.md │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── socksify.cpp │ │ ├── socksify.vcxproj │ │ ├── socksify.vcxproj.filters │ │ ├── socksify.vcxproj.user │ │ ├── vcpkg-configuration.json │ │ └── vcpkg.json │ └── udp2tcp │ │ ├── README.md │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── udp2tcp.cpp │ │ ├── udp2tcp.vcxproj │ │ ├── udp2tcp.vcxproj.filters │ │ ├── vcpkg-configuration.json │ │ └── vcpkg.json ├── dotNet │ └── TestDotNet │ │ ├── App.config │ │ ├── Program.cs │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ ├── README.md │ │ ├── TestDotNet.csproj │ │ └── packages.config └── legacy │ ├── CSharp │ ├── CSharp.sln │ ├── Filter │ │ ├── Filter.csproj │ │ ├── Filter.csproj.user │ │ ├── Program.cs │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ ├── FilterStats │ │ ├── FilterStats.csproj │ │ ├── Program.cs │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ ├── ListAdapters │ │ ├── ListAdapters.csproj │ │ ├── Program.cs │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ ├── NdisApi │ │ ├── IPStructs.cs │ │ ├── NdisApiWrapper.csproj │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── Win32Api.cs │ │ └── ndisapi.cs │ ├── NdisRequest │ │ ├── NdisRequest.csproj │ │ ├── Program.cs │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ ├── PacketSniffer │ │ ├── PacketSniffer.csproj │ │ ├── Program.cs │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ ├── PassThru │ │ ├── PassThru.csproj │ │ ├── PassThru.csproj.user │ │ ├── Program.cs │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ └── ndisapi.cs │ ├── Delphi │ ├── ListAdapters │ │ ├── ListAdapters.cfg │ │ ├── ListAdapters.dof │ │ └── ListAdapters.dpr │ ├── PacketSniffer │ │ ├── PacketSniffer.cfg │ │ ├── PacketSniffer.dof │ │ └── PacketSniffer.dpr │ ├── PassThru │ │ ├── PassThru.cfg │ │ ├── PassThru.dof │ │ └── PassThru.dpr │ ├── iphlp.pas │ ├── ndisrequest │ │ ├── ndisrequest.cfg │ │ ├── ndisrequest.dof │ │ └── ndisrequest.dpr │ └── winpkf.pas │ └── MSVC │ ├── filter │ ├── StdAfx.cpp │ ├── StdAfx.h │ ├── filter.cpp │ ├── filter.dsp │ ├── filter.vcxproj │ ├── filter.vcxproj.filters │ └── iphlp.h │ ├── filterstats │ ├── StdAfx.cpp │ ├── StdAfx.h │ ├── filterstats.cpp │ ├── filterstats.dsp │ ├── filterstats.vcxproj │ ├── filterstats.vcxproj.filters │ └── iphlp.h │ ├── gretunnel │ ├── StdAfx.cpp │ ├── StdAfx.h │ ├── gretunnel.cpp │ ├── gretunnel.dsp │ ├── gretunnel.vcxproj │ ├── gretunnel.vcxproj.filters │ └── iphlp.h │ ├── legacy.vc6.dsw │ ├── legacy.vs2012.sln │ ├── lfnemu │ ├── AckTimerLayer.cpp │ ├── AckTimerLayer.h │ ├── Common.cpp │ ├── Common.h │ ├── Finalization.cpp │ ├── Finalization.h │ ├── Initialization.cpp │ ├── Initialization.h │ ├── PacketDelayerLayer.cpp │ ├── PacketDelayerLayer.h │ ├── PacketDropperLayer.cpp │ ├── PacketDropperLayer.h │ ├── StdAfx.cpp │ ├── StdAfx.h │ ├── iphlp.h │ ├── lfnemu.cpp │ ├── lfnemu.dsp │ ├── lfnemu.h │ ├── lfnemu.rc │ ├── lfnemu.vcproj │ ├── lfnemu.vcxproj │ ├── lfnemu.vcxproj.filters │ ├── ndisInterfaceLayer.cpp │ ├── ndisInterfaceLayer.h │ └── resource.h │ ├── listadapters │ ├── StdAfx.cpp │ ├── StdAfx.h │ ├── listadapters.cpp │ ├── listadapters.dsp │ ├── listadapters.vcxproj │ └── listadapters.vcxproj.filters │ ├── ndisrequest │ ├── StdAfx.cpp │ ├── StdAfx.h │ ├── ndisrequest.cpp │ ├── ndisrequest.dsp │ ├── ndisrequest.vcxproj │ └── ndisrequest.vcxproj.filters │ ├── packetsniffer │ ├── StdAfx.cpp │ ├── StdAfx.h │ ├── iphlp.h │ ├── packetsniffer.cpp │ ├── packetsniffer.dsp │ ├── packetsniffer.vcxproj │ └── packetsniffer.vcxproj.filters │ ├── packthru │ ├── StdAfx.cpp │ ├── StdAfx.h │ ├── iphlp.h │ ├── packthru.cpp │ ├── packthru.dsp │ ├── packthru.vcxproj │ └── packthru.vcxproj.filters │ ├── passthru │ ├── StdAfx.cpp │ ├── StdAfx.h │ ├── iphlp.h │ ├── passthru.cpp │ ├── passthru.dsp │ ├── passthru.vcxproj │ └── passthru.vcxproj.filters │ ├── snat │ ├── NetcardProp.cpp │ ├── NetcardProp.h │ ├── NetworkInterface.cpp │ ├── NetworkInterface.h │ ├── iphlp.h │ ├── res │ │ ├── main.ico │ │ ├── modem.ico │ │ ├── netcard.ico │ │ ├── snat.ico │ │ ├── snat.manifest │ │ └── snat.rc2 │ ├── resource.h │ ├── snat.cpp │ ├── snat.h │ ├── snat.rc │ ├── snat.vcxproj │ ├── snat.vcxproj.filters │ ├── snatDlg.cpp │ ├── snatDlg.h │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h │ └── wwwcensor │ ├── StdAfx.cpp │ ├── StdAfx.h │ ├── iphlp.h │ ├── wwwcensor.cpp │ ├── wwwcensor.dsp │ ├── wwwcensor.vcxproj │ └── wwwcensor.vcxproj.filters ├── include ├── Common.h └── ndisapi.h ├── ndisapi.dll ├── ndisapi.def ├── ndisapidll.vcxproj └── ndisapidll.vcxproj.filters ├── ndisapi.lib ├── ndisapilib.vcxproj └── ndisapilib.vcxproj.filters ├── ndisapi.net ├── AssemblyInfo.cpp ├── Stdafx.h ├── app.ico ├── app.rc ├── ndisapicl.cpp ├── ndisapicl.h ├── ndisapicl.vcxproj ├── ndisapicl.vcxproj.filters └── resource.h ├── ndisapi.sln ├── ndisapi.vc6 ├── ndisapi.def └── ndisapi.dsp ├── ndisapi.vs2012 ├── ndisapi.def ├── ndisapi.vcxproj └── ndisapi.vcxproj.filters ├── ndisapi ├── iphlp.h ├── ndisapi.cpp ├── ndisapi.rc ├── precomp.h └── resource.h └── tools.cmd /.gitignore: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio. 3 | ################################################################################ 4 | 5 | *.vsidx 6 | *.suo 7 | *.db 8 | *.db-shm 9 | *.db-wal 10 | *.opendb 11 | *.cs 12 | *.cache 13 | *.cpp 14 | *.tlog 15 | *.lastbuildstate 16 | *.dll 17 | *.lib 18 | *.exp 19 | *.pdb 20 | *.exe 21 | *.user 22 | /examples/cpp/hyperscan/vcpkg_installed/x64-windows 23 | *.log 24 | *.recipe 25 | *.ilk 26 | *.obj 27 | *.pch 28 | *.txt 29 | *.idb 30 | /examples/cpp/pcapplusplus/vcpkg_installed/x64-windows 31 | /examples/dotNet/TestDotNet/.vs/TestDotNet.csproj.dtbcache.json 32 | *.ipch 33 | *.metagen 34 | /bin/examples/.net/ARM64/Debug 35 | /bin/examples/.net/ARM64/Release 36 | /bin/examples/.net/x64/Debug 37 | /bin/examples/.net/x64/Release 38 | /bin/examples/.net/x86/Debug 39 | /bin/examples/.net/x86/Release 40 | *.iobj 41 | *.ipdb 42 | *.CopyComplete 43 | /examples/cpp/capture/vcpkg_installed 44 | /examples/cpp/dnstrace/vcpkg_installed 45 | /examples/cpp/dns_proxy/vcpkg_installed 46 | /examples/cpp/ethernet_bridge/vcpkg_installed 47 | /examples/cpp/hyperscan/vcpkg_installed/x86-windows 48 | /examples/cpp/ipv6_parser/vcpkg_installed 49 | /examples/cpp/pcapplusplus/vcpkg_installed/x86-windows 50 | /examples/cpp/rebind/vcpkg_installed 51 | /examples/cpp/sni_inspector/vcpkg_installed 52 | /examples/cpp/socksify/vcpkg_installed 53 | /examples/cpp/udp2tcp/vcpkg_installed 54 | *.res 55 | /packages 56 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Vadim Smirnov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /cygwin/README.md: -------------------------------------------------------------------------------- 1 | # NDISAPI Library for Cygwin 2 | 3 | This directory contains the Makefile and instructions to build the Cygwin variant of the NDISAPI static library and basic example applications. 4 | 5 | ## Prerequisites 6 | 7 | - Cygwin environment with `g++` and standard build tools installed. 8 | - Source files for the `ndisapi` library and examples. 9 | 10 | ## Building the Library 11 | 12 | 1. Open your Cygwin terminal. 13 | 2. Navigate to the `cygwin` directory within the `ndisapi` library repository. 14 | 3. Run `make` to build the static library and all basic examples. 15 | 16 | ```bash 17 | make 18 | ``` 19 | 20 | This will compile the `ndisapi` static library and the following example applications: 21 | 22 | - `listadapters` 23 | - `packthru` 24 | - `filter` 25 | - `filterstats` 26 | - `gretunnel` 27 | - `ndisrequest` 28 | - `packetsniffer` 29 | - `passthru` 30 | - `wwwcensor` 31 | 32 | ## Cleaning Build Artifacts 33 | 34 | To clean up all build artifacts, run: 35 | 36 | ```bash 37 | make clean 38 | ``` 39 | 40 | ## Example Usage 41 | 42 | After building, you can run the example applications directly from the `bin` directory. For instance, to run `listadapters`: 43 | 44 | ```bash 45 | ./bin/x64/Release/listadapters 46 | ``` 47 | 48 | (Adjust the path based on your build architecture and configuration.) 49 | 50 | ## Demo Output 51 | 52 | Here are brief examples of the output you can expect from running the `listadapters` and `packthru` samples: 53 | 54 | ### listadapters 55 | 56 | ```bash 57 | $ ./bin/x64/Release/listadapters 58 | The following network interfaces are available to MSTCP: 59 | 1) Ethernet. 60 | Internal Name: \DEVICE\{...} 61 | Current MAC: B04F13FB9614 62 | ... 63 | 2) Local Area Connection* 2. 64 | Internal Name: \DEVICE\{...} 65 | Current MAC: 3E219C3EC44D 66 | ... 67 | ... (additional interfaces listed here) ... 68 | ``` 69 | 70 | ### packthru 71 | 72 | ```bash 73 | $ ./bin/x64/Release/packthru 4 5 74 | 1 packet received from the driver 75 | 76 | 4 - Interface --> MSTCP 77 | Packet size = 42 78 | Source MAC: 50FF20902F15 79 | Destination MAC: FFFFFFFFFFFF 80 | ... (packet details) ... 81 | Sending 1 packets to protocols 82 | ... (additional packet details) ... 83 | Filtering complete 84 | ``` 85 | 86 | These outputs are just excerpts to demonstrate the format. When you run these samples in your environment, you'll see detailed information specific to your network interfaces and traffic. 87 | 88 | ## Notes 89 | 90 | - The provided Makefile is configured for the Cygwin environment. For other environments, modifications may be necessary. 91 | -------------------------------------------------------------------------------- /cygwin/build_all.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SETLOCAL 3 | 4 | ECHO Building for x86 Debug... 5 | make ARCH=x86 CONFIG=Debug 6 | 7 | ECHO Building for x86 Release... 8 | make ARCH=x86 CONFIG=Release 9 | 10 | ECHO Building for x64 Debug... 11 | make ARCH=x64 CONFIG=Debug 12 | 13 | ECHO Building for x64 Release... 14 | make ARCH=x64 CONFIG=Release 15 | 16 | ENDLOCAL 17 | ECHO Build process completed. 18 | -------------------------------------------------------------------------------- /examples/cpp/capture/README.md: -------------------------------------------------------------------------------- 1 | # Capture Packet Filter 2 | 3 | ## Overview 4 | 5 | This project is an example of how to intercept network packets, write packet data into a file, and pass them on, facilitating packet analysis and troubleshooting. The `Windows Packet Filter` driver must be loaded for the program to run. 6 | 7 | ## Code Description 8 | 9 | The main function of this program initiates a unique pointer to a `ndisapi::fastio_packet_filter` object. This object has two main lambda functions: 10 | 11 | 1. The first lambda function is triggered for each incoming packet. It writes the packet data to a file and then passes the packet back to the filter. 12 | 2. The second lambda function is triggered for each outgoing packet. It writes the packet data to the file and then passes the packet back to the filter. 13 | 14 | After initialization, the program checks whether the `Windows Packet Filter` driver is loaded. If not, the program exits. If the driver is loaded, the program displays a list of available network interfaces and prompts the user to select an interface for filtering. 15 | 16 | The user is then prompted to enter a filename where the packet capture will be saved. If the file opens successfully, the program begins filtering traffic on the selected interface. The user can stop filtering at any time by pressing any key. 17 | 18 | ## Usage 19 | 20 | Compile and run the program. Follow the prompts to choose a network interface and specify a filename for the capture. Press any key to stop filtering. 21 | 22 | -------------------------------------------------------------------------------- /examples/cpp/capture/capture.cpp: -------------------------------------------------------------------------------- 1 | // capture.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include "pch.h" 5 | #include 6 | 7 | int main() 8 | { 9 | try 10 | { 11 | std::string file_name; 12 | pcap::pcap_file_storage file_stream; 13 | 14 | auto ndis_api = std::make_unique( 15 | [&file_stream](HANDLE, INTERMEDIATE_BUFFER& buffer) 16 | { 17 | file_stream << buffer; 18 | 19 | return ndisapi::fastio_packet_filter::packet_action::pass; 20 | }, 21 | [&file_stream](HANDLE, INTERMEDIATE_BUFFER& buffer) 22 | { 23 | file_stream << buffer; 24 | 25 | return ndisapi::fastio_packet_filter::packet_action::pass; 26 | }, true); 27 | 28 | if (ndis_api->IsDriverLoaded()) 29 | { 30 | std::cout << "WinpkFilter is loaded" << std::endl << std::endl; 31 | } 32 | else 33 | { 34 | std::cout << "WinpkFilter is not loaded" << std::endl << std::endl; 35 | return 1; 36 | } 37 | 38 | std::cout << "Available network interfaces:" << std::endl << std::endl; 39 | size_t index = 0; 40 | for (auto& e : ndis_api->get_interface_names_list()) 41 | { 42 | std::cout << ++index << ")\t" << e << std::endl; 43 | } 44 | 45 | std::cout << std::endl << "Select interface to filter:"; 46 | std::cin >> index; 47 | 48 | if (index > ndis_api->get_interface_names_list().size()) 49 | { 50 | std::cout << "Wrong parameter was selected. Out of range." << std::endl; 51 | return 0; 52 | } 53 | 54 | std::cout << std::endl << "Enter filename to save the capture:"; 55 | std::cin >> file_name; 56 | 57 | file_stream.open(file_name); 58 | 59 | if (!file_stream) 60 | { 61 | std::cout << "Failed to open " << file_name << "\n"; 62 | return 0; 63 | } 64 | 65 | ndis_api->start_filter(index - 1); 66 | 67 | std::cout << "Press any key to stop filtering" << std::endl; 68 | 69 | std::ignore = _getch(); 70 | 71 | std::cout << "Exiting..." << std::endl; 72 | } 73 | catch (const std::exception& ex) 74 | { 75 | std::cout << "Exception occurred: " << ex.what() << std::endl; 76 | } 77 | 78 | return 0; 79 | } 80 | -------------------------------------------------------------------------------- /examples/cpp/capture/capture.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;ipp;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 | {f58d99f8-6dfc-44e1-9ff2-381efcda5d4d} 18 | 19 | 20 | {b7bffef8-2d56-4887-94c9-a3a5c019c40c} 21 | 22 | 23 | {f8f844ac-af18-47de-9cc8-a3859a76d08b} 24 | 25 | 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files\common\ndisapi 32 | 33 | 34 | Header Files\common\pcap 35 | 36 | 37 | Header Files\common\pcap 38 | 39 | 40 | 41 | 42 | Source Files 43 | 44 | 45 | Source Files 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /examples/cpp/capture/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed 2 | 3 | #include "pch.h" 4 | 5 | // In general, ignore this file, but keep it around if you are using pre-compiled headers. 6 | -------------------------------------------------------------------------------- /examples/cpp/capture/pch.h: -------------------------------------------------------------------------------- 1 | // Tips for Getting Started: 2 | // 1. Use the Solution Explorer window to add/manage files 3 | // 2. Use the Team Explorer window to connect to source control 4 | // 3. Use the Output window to see build output and other messages 5 | // 4. Use the Error List window to view errors 6 | // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project 7 | // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file 8 | 9 | #ifndef PCH_H 10 | #define PCH_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #include "../../../include/common.h" 45 | #include "../../../include/ndisapi.h" 46 | #include "../common/pcap/pcap.h" 47 | #include "../common/pcap/pcap_file_storage.h" 48 | #include "../common/iphlp.h" 49 | #include "../common/winsys/object.h" 50 | #include "../common/winsys/event.h" 51 | #include "../common/net/mac_address.h" 52 | #include "../common/net/ip_address.h" 53 | #include "../common/net/ip_subnet.h" 54 | #include "../common/iphelper/network_adapter_info.h" 55 | #include "../common/ndisapi/network_adapter.h" 56 | #include "../common/ndisapi/fastio_packet_filter.h" 57 | 58 | #endif //PCH_H 59 | -------------------------------------------------------------------------------- /examples/cpp/capture/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "10b7a178346f3f0abef60cecd5130e295afd8da4", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /examples/cpp/capture/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "ms-gsl" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /examples/cpp/common/README.md: -------------------------------------------------------------------------------- 1 | # netlib 2 | 3 | Utility C++ classes used for the network development. 4 | -------------------------------------------------------------------------------- /examples/cpp/common/log/log.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace netlib::log 4 | { 5 | enum class log_level : uint32_t 6 | { 7 | error = 0, 8 | info = 1, 9 | debug = 2, 10 | all = 3, 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /examples/cpp/common/pcap/pcap.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiresock/ndisapi/417b8734e844083a10236387fba705d94a2d6bc9/examples/cpp/common/pcap/pcap.h -------------------------------------------------------------------------------- /examples/cpp/common/proxy/proxy_common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace proxy 4 | { 5 | template 6 | constexpr bool false_v = false; 7 | 8 | enum class proxy_io_operation 9 | { 10 | relay_io_read, 11 | relay_io_write, 12 | negotiate_io_read, 13 | negotiate_io_write, 14 | inject_io_write 15 | }; 16 | 17 | // -------------------------------------------------------------------------------- 18 | /// 19 | /// Used to pass data required to negotiate connection to the remote proxy 20 | /// 21 | // -------------------------------------------------------------------------------- 22 | template 23 | struct negotiate_context 24 | { 25 | negotiate_context(const T& remote_address, const uint16_t remote_port) 26 | : remote_address(remote_address), 27 | remote_port(remote_port) 28 | { 29 | } 30 | 31 | virtual ~negotiate_context() = default; 32 | 33 | 34 | negotiate_context(const negotiate_context& other) 35 | : remote_address(other.remote_address), 36 | remote_port(other.remote_port) 37 | { 38 | } 39 | 40 | negotiate_context(negotiate_context&& other) noexcept 41 | : remote_address(std::move(other.remote_address)), 42 | remote_port(other.remote_port) 43 | { 44 | } 45 | 46 | negotiate_context& operator=(const negotiate_context& other) 47 | { 48 | if (this == &other) 49 | return *this; 50 | 51 | remote_address = other.remote_address; 52 | remote_port = other.remote_port; 53 | return *this; 54 | } 55 | 56 | negotiate_context& operator=(negotiate_context&& other) noexcept 57 | { 58 | if (this == &other) 59 | return *this; 60 | 61 | remote_address = std::move(other.remote_address); 62 | remote_port = other.remote_port; 63 | return *this; 64 | } 65 | 66 | T remote_address; 67 | uint16_t remote_port; 68 | }; 69 | } 70 | -------------------------------------------------------------------------------- /examples/cpp/common/tools/strings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace tools::strings 7 | { 8 | inline std::wstring to_wstring(const std::string& str) 9 | { 10 | int requiredSize = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0); 11 | if (requiredSize == 0) 12 | { 13 | // Handle error 14 | return L""; 15 | } 16 | 17 | std::wstring wstr(requiredSize - 1, '\0'); 18 | int result = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, &wstr[0], requiredSize); 19 | if (result == 0) 20 | { 21 | // Handle error 22 | return L""; 23 | } 24 | 25 | return wstr; 26 | } 27 | 28 | inline std::string to_string(const std::wstring& wstr) 29 | { 30 | int requiredSize = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, NULL, 0, NULL, NULL); 31 | if (requiredSize == 0) 32 | { 33 | // Handle error 34 | return ""; 35 | } 36 | 37 | std::string str(requiredSize - 1, '\0'); 38 | int result = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &str[0], requiredSize, NULL, NULL); 39 | if (result == 0) 40 | { 41 | // Handle error 42 | return ""; 43 | } 44 | 45 | return str; 46 | } 47 | 48 | inline std::vector split_string(const std::string& input, const char sep) 49 | { 50 | std::stringstream ss(input); 51 | std::string segment; 52 | std::vector strings; 53 | 54 | while (std::getline(ss, segment, sep)) 55 | { 56 | strings.push_back(segment); 57 | } 58 | 59 | return strings; 60 | } 61 | 62 | inline std::vector split_string(const std::wstring& input, const wchar_t sep) 63 | { 64 | std::wstringstream wss(input); 65 | std::wstring segment; 66 | std::vector strings; 67 | 68 | while (std::getline(wss, segment, sep)) 69 | { 70 | strings.push_back(segment); 71 | } 72 | 73 | return strings; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /examples/cpp/common/winsys/event.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #pragma warning( push ) 4 | #pragma warning( disable : 26456 ) 5 | 6 | namespace winsys 7 | { 8 | // -------------------------------------------------------------------------------- 9 | /// 10 | /// Simple wrapper for Windows event object 11 | /// 12 | // -------------------------------------------------------------------------------- 13 | class safe_event final : public safe_object_handle 14 | { 15 | public: 16 | /// 17 | /// Constructs safe_event from the even object handle 18 | /// 19 | // ReSharper disable once CppParameterMayBeConst 20 | explicit safe_event(HANDLE handle = nullptr) noexcept: safe_object_handle(handle) 21 | { 22 | } 23 | 24 | /// 25 | /// Deleted copy constructor 26 | /// 27 | safe_event(const safe_event& other) = delete; 28 | 29 | /// 30 | /// Move constructor 31 | /// 32 | /// Object instance to move from 33 | safe_event(safe_event&& other) noexcept 34 | : safe_object_handle{std::move(other)} 35 | { 36 | } 37 | 38 | /// 39 | /// Deleted copy assignment 40 | /// 41 | safe_event& operator=(const safe_event& other) = delete; 42 | 43 | /// 44 | /// Move assignment 45 | /// 46 | /// Object instance to move from 47 | /// this object instance 48 | safe_event& operator=(safe_event&& other) noexcept 49 | { 50 | if (this == &other) 51 | return *this; 52 | safe_object_handle::operator =(std::move(other)); 53 | return *this; 54 | } 55 | 56 | /// 57 | /// Default destructor 58 | /// 59 | ~safe_event() = default; 60 | 61 | /// 62 | /// Waits on the event 63 | /// 64 | /// Wait timeout in milliseconds 65 | /// value returned by WaitForSingleObject 66 | [[nodiscard]] unsigned wait(const unsigned dw_milliseconds) const noexcept 67 | { 68 | return WaitForSingleObject(get(), dw_milliseconds); 69 | } 70 | 71 | /// 72 | /// Signals the event object 73 | /// 74 | /// true if the function succeeds, false otherwise 75 | [[nodiscard]] bool signal() const noexcept 76 | { 77 | return SetEvent(get()) ? true : false; 78 | } 79 | 80 | /// 81 | /// Resets event 82 | /// 83 | /// true if the function succeeds, false otherwise 84 | [[nodiscard]] bool reset_event() const noexcept 85 | { 86 | return ResetEvent(get()) ? true : false; 87 | } 88 | }; 89 | } 90 | #pragma warning( pop ) 91 | -------------------------------------------------------------------------------- /examples/cpp/common/winsys/object.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #pragma warning( push ) 4 | #pragma warning( disable : 26456 ) 5 | 6 | namespace winsys 7 | { 8 | // -------------------------------------------------------------------------------- 9 | /// 10 | /// simple wrapper class for Windows handle 11 | /// 12 | // -------------------------------------------------------------------------------- 13 | class safe_object_handle : public std::unique_ptr, void(*)(HANDLE)> 14 | { 15 | public: 16 | /// 17 | /// Constructs the object from the existing handle value 18 | /// 19 | /// 20 | // ReSharper disable once CppParameterMayBeConst 21 | explicit safe_object_handle(HANDLE handle) noexcept: unique_ptr(handle, &safe_object_handle::close) 22 | { 23 | } 24 | 25 | /// 26 | /// Deleted copy constructor 27 | /// 28 | safe_object_handle(const safe_object_handle& other) = delete; 29 | 30 | /// 31 | /// Move constructor 32 | /// 33 | /// Object instance to move from 34 | safe_object_handle(safe_object_handle&& other) noexcept 35 | : std::unique_ptr, void(*)(HANDLE)>{std::move(other)} 36 | { 37 | } 38 | 39 | /// 40 | /// Deleted copy assignment 41 | /// 42 | safe_object_handle& operator=(const safe_object_handle& other) = delete; 43 | 44 | /// 45 | /// Move assignment 46 | /// 47 | /// Object instance to move from 48 | /// this object reference 49 | safe_object_handle& operator=(safe_object_handle&& other) noexcept 50 | { 51 | if (this == &other) 52 | return *this; 53 | std::unique_ptr, void(*)(HANDLE)>::operator =(std::move(other)); 54 | return *this; 55 | } 56 | 57 | /// 58 | /// Default destructor 59 | /// 60 | /// 61 | ~safe_object_handle() = default; 62 | 63 | /// 64 | /// Returns the stored handle value 65 | /// 66 | explicit operator HANDLE() const noexcept 67 | { 68 | return get(); 69 | } 70 | 71 | /// 72 | /// Checks the stored handle value for validity 73 | /// 74 | /// true if valid, false otherwise 75 | [[nodiscard]] bool valid() const noexcept 76 | { 77 | return ((get() != INVALID_HANDLE_VALUE) && (get() != nullptr)); 78 | } 79 | 80 | private: 81 | /// 82 | /// deleter for the stored windows handle (calls CloseHandle for the handle) 83 | /// 84 | /// windows handle to close 85 | // ReSharper disable once CppParameterMayBeConst 86 | static void close(HANDLE handle) noexcept 87 | { 88 | if ((handle != INVALID_HANDLE_VALUE) && (handle != nullptr)) 89 | CloseHandle(handle); 90 | } 91 | }; 92 | } 93 | #pragma warning( pop ) 94 | -------------------------------------------------------------------------------- /examples/cpp/dns_proxy/README.md: -------------------------------------------------------------------------------- 1 | # DNS Proxy Server 2 | 3 | ## Overview 4 | 5 | This is a basic DNS Proxy Server application implemented in C++. It allows you to intercept and redirect all DNS packets to a specified DNS server. This is useful for network monitoring, debugging, and other networking tasks. 6 | 7 | ## Code Description 8 | 9 | The `main()` function of the program begins by prompting the user to input the IP address of the DNS server where the DNS requests will be forwarded. 10 | 11 | The application then creates an instance of `ndisapi::udp_proxy_server` which is designed to handle the redirection of UDP traffic. The main logic of redirection is encapsulated in a lambda function passed to the `ndisapi::udp_proxy_server` constructor. This function checks whether the remote port is 53 (the standard DNS port). If it is, it redirects the request to the specified DNS server. If not, it simply returns without any redirection. 12 | 13 | The application also sets up a logging function, `log_printer`, to display messages about the status of the application. This function is thread-safe. 14 | 15 | Finally, the application starts the proxy server and waits for the user to press any key to stop the filtering process. 16 | 17 | If any exception occurs during the execution, it is caught and displayed in the console. 18 | 19 | ## Usage 20 | 21 | Compile and run the program. You will be prompted to enter the IP address of the DNS server where the DNS requests should be forwarded. Press any key to stop filtering. 22 | -------------------------------------------------------------------------------- /examples/cpp/dns_proxy/dns_proxy.cpp: -------------------------------------------------------------------------------- 1 | // dns_proxy.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include "pch.h" 5 | #include 6 | 7 | void log_printer(const char* log) 8 | { 9 | static std::mutex log_lock; // NOLINT(clang-diagnostic-exit-time-destructors) 10 | 11 | std::lock_guard lock(log_lock); 12 | 13 | std::cout << log << std::endl; 14 | } 15 | 16 | int main() 17 | { 18 | try { 19 | std::string dns_address; 20 | std::cout << std::endl << "DNS server IP address to forward requests to: "; 21 | std::cin >> dns_address; 22 | auto dns_server_ip_address_v4 = net::ip_address_v4(dns_address); 23 | 24 | // Redirects all DNS packet to dns_server_ip_address_v4:53 25 | ndisapi::udp_proxy_server> proxy([&dns_server_ip_address_v4]( 26 | const net::ip_address_v4 local_address, const uint16_t local_port, const net::ip_address_v4 remote_address, const uint16_t remote_port)-> 27 | std::tuple>::negotiate_context_t>> 29 | { 30 | if (remote_port == 53) 31 | { 32 | std::cout << "Redirecting DNS " << local_address << ":" << local_port << " -> " << remote_address << ":" << remote_port << " to " << dns_server_ip_address_v4 << ":53\n"; 33 | return std::make_tuple(dns_server_ip_address_v4, 53, nullptr); 34 | } 35 | 36 | return std::make_tuple(net::ip_address_v4{}, 0, nullptr); 37 | }, dns_server_ip_address_v4, log_printer, ndisapi::log_level::all); 38 | 39 | proxy.start(); 40 | 41 | std::cout << "Press any key to stop filtering" << std::endl; 42 | 43 | std::ignore = _getch(); 44 | 45 | std::cout << "Exiting..." << std::endl; 46 | } 47 | catch(const std::exception& ex) 48 | { 49 | std::cout << "exception occurred: " << ex.what() << std::endl; 50 | } 51 | 52 | return 0; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /examples/cpp/dns_proxy/dns_proxy.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;ipp;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 | {f58d99f8-6dfc-44e1-9ff2-381efcda5d4d} 18 | 19 | 20 | {b7bffef8-2d56-4887-94c9-a3a5c019c40c} 21 | 22 | 23 | {eb22a31a-14c4-4b91-91b0-c92764cf0635} 24 | 25 | 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files\common\net 32 | 33 | 34 | Header Files\common\ndisapi 35 | 36 | 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/cpp/dns_proxy/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed 2 | 3 | #include "pch.h" 4 | 5 | // In general, ignore this file, but keep it around if you are using pre-compiled headers. 6 | -------------------------------------------------------------------------------- /examples/cpp/dns_proxy/pch.h: -------------------------------------------------------------------------------- 1 | // Tips for Getting Started: 2 | // 1. Use the Solution Explorer window to add/manage files 3 | // 2. Use the Team Explorer window to connect to source control 4 | // 3. Use the Output window to see build output and other messages 5 | // 4. Use the Error List window to view errors 6 | // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project 7 | // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file 8 | 9 | #ifndef PCH_H 10 | #define PCH_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #include "../../../include/common.h" 45 | #include "../../../include/ndisapi.h" 46 | #include "../common/iphlp.h" 47 | #include "../common/winsys/object.h" 48 | #include "../common/winsys/event.h" 49 | #include "../common/net/mac_address.h" 50 | #include "../common/net/ip_address.h" 51 | #include "../common/net/ipv6_helper.h" 52 | #include "../common/net/ip_subnet.h" 53 | #include "../common/iphelper/network_adapter_info.h" 54 | #include "../common/ndisapi/network_adapter.h" 55 | #include "../common/ndisapi/simple_packet_filter.h" 56 | #include "../common/proxy/proxy_common.h" 57 | #include "../common/ndisapi/udp_proxy.h" 58 | 59 | #endif //PCH_H 60 | -------------------------------------------------------------------------------- /examples/cpp/dns_proxy/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "10b7a178346f3f0abef60cecd5130e295afd8da4", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /examples/cpp/dns_proxy/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "ms-gsl" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /examples/cpp/dnstrace/README.md: -------------------------------------------------------------------------------- 1 | # DNS Tracer 2 | 3 | `dnstrace` is a console application written in C++. It provides a detailed trace of DNS (Domain Name System) responses by parsing the DNS packet structure. This can be useful for network debugging, security monitoring, and research purposes.This sample also demonstares how to link NDISAPI statically and dynamically (using corresponding congigurations). 4 | 5 | ## Features 6 | 7 | - Parses and prints out key elements from IP, UDP, and DNS headers. 8 | - Extracts and displays DNS response data, including record types like A, NS, CNAME, SOA, WKS, PTR, MX, AAA, SRV and ANY. 9 | - Uses `Windows Packet Filter` to filter the network traffic. 10 | - Allows the user to select a network interface to filter. 11 | - Handles IPv4 and IPv6 addresses. 12 | 13 | ## How it works 14 | 15 | The application captures packets coming from the DNS server (port 53) using `Windows Packet Filter`. It then parses these packets, extracting the IP, UDP, and DNS headers. For each DNS response, it extracts and prints out the DNS record type and data. The application continues to run until the user interrupts it. 16 | 17 | ## Prerequisites 18 | 19 | - The `Windows Packet Filter` driver must be loaded on your system to use this application. 20 | 21 | ## Usage 22 | 23 | Run the application from the command line with: 24 | 25 | ```bash 26 | ./dnstrace 27 | ``` 28 | 29 | If the `Windows Packet Filter` driver is loaded, the application will print a list of available network interfaces. Select the interface you want to filter by entering its number. The application will start capturing and parsing DNS responses on that interface. 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /examples/cpp/dnstrace/dnstrace.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiresock/ndisapi/417b8734e844083a10236387fba705d94a2d6bc9/examples/cpp/dnstrace/dnstrace.cpp -------------------------------------------------------------------------------- /examples/cpp/dnstrace/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiresock/ndisapi/417b8734e844083a10236387fba705d94a2d6bc9/examples/cpp/dnstrace/stdafx.cpp -------------------------------------------------------------------------------- /examples/cpp/dnstrace/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiresock/ndisapi/417b8734e844083a10236387fba705d94a2d6bc9/examples/cpp/dnstrace/stdafx.h -------------------------------------------------------------------------------- /examples/cpp/dnstrace/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiresock/ndisapi/417b8734e844083a10236387fba705d94a2d6bc9/examples/cpp/dnstrace/targetver.h -------------------------------------------------------------------------------- /examples/cpp/dnstrace/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "10b7a178346f3f0abef60cecd5130e295afd8da4", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /examples/cpp/dnstrace/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "ms-gsl" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /examples/cpp/ethernet_bridge/NetworkAdapter.cpp: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------- 2 | /// 3 | /// Module Name: NetworkAdapter.cpp 4 | /// Abstract: Network interface wrapper class definitions 5 | /// 6 | // -------------------------------------------------------------------------------- 7 | 8 | #include "stdafx.h" 9 | 10 | // Set network filter for the interface 11 | inline unsigned long network_adapter::get_hw_filter() const 12 | { 13 | unsigned long result = 0; 14 | 15 | api_.GetHwPacketFilter(current_mode_.hAdapterHandle, &result); 16 | 17 | return result; 18 | } 19 | 20 | void network_adapter::release() 21 | { 22 | // This function releases packets in the adapter queue and stops listening the interface 23 | [[maybe_unused]] auto event_result = event_.signal(); 24 | 25 | // Restore old packet filter (not for WLAN as we don't modify it) 26 | if (!is_wlan() && network_filter_) 27 | { 28 | [[maybe_unused]] auto hw_result = set_hw_filter(network_filter_); 29 | } 30 | 31 | // Reset adapter mode and flush the packet queue 32 | current_mode_.dwFlags = 0; 33 | 34 | api_.SetAdapterMode(¤t_mode_); 35 | api_.FlushAdapterPacketQueue(current_mode_.hAdapterHandle); 36 | } 37 | 38 | void network_adapter::set_mode(const unsigned flags) 39 | { 40 | current_mode_.dwFlags = flags; 41 | 42 | api_.SetAdapterMode(¤t_mode_); 43 | } 44 | 45 | void network_adapter::set_mac_for_ip(const net::ip_address_v4& ip, unsigned char* mac) 46 | { 47 | std::lock_guard guard(ip_to_mac_mutex_); 48 | 49 | ip_to_mac_[ip] = net::mac_address(mac); 50 | } 51 | 52 | net::mac_address network_adapter::get_mac_by_ip(const net::ip_address_v4& ip) 53 | { 54 | std::lock_guard guard(ip_to_mac_mutex_); 55 | 56 | if (const auto search = ip_to_mac_.find(ip); search != ip_to_mac_.end()) 57 | { 58 | return search->second; 59 | } 60 | 61 | return net::mac_address(); 62 | } 63 | 64 | void network_adapter::initialize_interface() noexcept 65 | { 66 | // 67 | // Saves original packet filter 68 | // 69 | network_filter_ = get_hw_filter(); 70 | 71 | // 72 | // Query physical media for the network interface to check is this is WLAN network adapter 73 | // 74 | const auto phys_medium_request = reinterpret_cast(new char[sizeof(PACKET_OID_DATA) + sizeof(DWORD) 75 | - 1]); 76 | phys_medium_request->Length = sizeof(DWORD); 77 | phys_medium_request->Oid = OID_GEN_PHYSICAL_MEDIUM; 78 | 79 | phys_medium_request->hAdapterHandle = current_mode_.hAdapterHandle; 80 | if (api_.NdisrdRequest(phys_medium_request, FALSE)) 81 | { 82 | if (static_cast(*reinterpret_cast(phys_medium_request->Data)) == 83 | NdisPhysicalMedium::NdisPhysicalMediumNative802_11) 84 | { 85 | is_wlan_ = true; 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /examples/cpp/ethernet_bridge/README.md: -------------------------------------------------------------------------------- 1 | # EthernetBridge 2 | 3 | The EthernetBridge example is a simple C++ program that implements an Ethernet bridge. An Ethernet bridge is a network device that connects two or more Ethernet networks together by forwarding frames between the networks based on their MAC addresses. 4 | 5 | ## Code Overview 6 | 7 | init() - This function initializes the bridge. It performs the following operations: 8 | 9 | 1. Opens the network interfaces. 10 | 2. Creates a list of MAC addresses for each network interface. 11 | 3. Creates a table of MAC addresses to network interfaces. 12 | 13 | run() - This function is the main loop of the bridge. It continuously receives frames from the network interfaces and forwards them to the appropriate network. It performs the following operations: 14 | 15 | 1. Receives a frame from a network interface. 16 | 2. Looks up the destination MAC address in the table of MAC addresses to network interfaces. 17 | 3. If the destination MAC address is found, forwards the frame to the network interface associated with the destination MAC address. 18 | 4. If the destination MAC address is not found, drops the frame. 19 | 20 | ## Acknowledgments 21 | 22 | - The code uses the NDISAPI to open and manage network interfaces. 23 | - The code uses a table of MAC addresses to network interfaces to keep track of which network interface is associated with each MAC address. 24 | - The code uses a loop to continuously receive frames from the network interfaces and forward them to the appropriate network. 25 | - The code drops frames that do not have a destination MAC address. 26 | 27 | ## More information 28 | Please read this [blog post](https://www.ntkernel.com/bridging-networks-with-windows-packet-filter/) 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /examples/cpp/ethernet_bridge/ebridge.cpp: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------- 2 | /// 3 | /// Module Name: ebridge.cpp 4 | /// Abstract: Defines the entry point for the console application 5 | /// 6 | // -------------------------------------------------------------------------------- 7 | 8 | #include "stdafx.h" 9 | 10 | int main(int argc, char* argv[]) 11 | { 12 | ethernet_bridge ether_bridge; 13 | size_t num, index = 0; 14 | 15 | // Check if driver was loaded properly 16 | if (!ether_bridge.IsDriverLoaded()) 17 | { 18 | cout << "Driver not installed on this system of failed to load. Please install WinpkFilter drivers first." << 19 | endl; 20 | return 0; 21 | } 22 | 23 | cout << "Available network interfaces:" << endl << endl; 24 | for (auto& [friendly, native] : ether_bridge.get_interface_list()) 25 | { 26 | cout << ++index << ") " << friendly << endl; 27 | } 28 | 29 | cout << endl; 30 | 31 | cout << "Enter number of interfaces to bridge: "; 32 | cin >> num; 33 | 34 | std::vector interfaces; 35 | interfaces.reserve(num); 36 | 37 | for (size_t i = 0; i < num; i++) 38 | { 39 | cout << "Enter interface index:"; 40 | cin >> index; 41 | interfaces.push_back(index - 1); 42 | } 43 | 44 | try 45 | { 46 | if (ether_bridge.start_bridge(interfaces)) 47 | cout << "Ethernet Bridge has started successfully!" << endl; 48 | else 49 | cout << "Ethernet Bridge has failed to start!" << endl; 50 | } 51 | catch (const std::system_error& error) 52 | { 53 | std::cout << "Error: " << error.code() 54 | << " - " << error.code().message() << '\n'; 55 | 56 | return 0; 57 | } 58 | 59 | cout << "Press any key to stop bridging" << endl; 60 | 61 | std::ignore = _getch(); 62 | 63 | printf("Exiting... \n"); 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /examples/cpp/ethernet_bridge/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------- 2 | /// 3 | /// Module Name: stdafx.cpp 4 | /// Abstract: source file that includes just the standard includes 5 | /// 6 | // -------------------------------------------------------------------------------- 7 | 8 | #include "stdafx.h" 9 | 10 | // TODO: reference any additional headers you need in STDAFX.H 11 | // and not in this file 12 | -------------------------------------------------------------------------------- /examples/cpp/ethernet_bridge/stdafx.h: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------- 2 | /// 3 | /// include file for standard system include files,or project specific include 4 | /// files that are used frequently, but are changed infrequently 5 | /// 6 | // -------------------------------------------------------------------------------- 7 | 8 | #pragma once 9 | 10 | #include "targetver.h" 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | using namespace std; 38 | 39 | #include "../../../include/common.h" 40 | #include "../../../include/ndisapi.h" 41 | #include "../common/iphlp.h" 42 | #include "../common/dhcp_typedefs.h" 43 | #include "../common/net/ip_address.h" 44 | #include "../common/net/mac_address.h" 45 | #include "../common/winsys/object.h" 46 | #include "../common/winsys/event.h" 47 | #include "../common/pcap/pcap.h" 48 | #include "../common/pcap/pcap_file_storage.h" 49 | #include "NetworkAdapter.h" 50 | #include "EthernetBridge.h" 51 | 52 | -------------------------------------------------------------------------------- /examples/cpp/ethernet_bridge/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiresock/ndisapi/417b8734e844083a10236387fba705d94a2d6bc9/examples/cpp/ethernet_bridge/targetver.h -------------------------------------------------------------------------------- /examples/cpp/ethernet_bridge/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "10b7a178346f3f0abef60cecd5130e295afd8da4", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /examples/cpp/ethernet_bridge/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "ms-gsl" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /examples/cpp/hyperscan/README.md: -------------------------------------------------------------------------------- 1 | # Hyperscan: Network Packet Analysis Example 2 | 3 | ## Overview 4 | 5 | `Hyperscan` is a high-performance example application showcasing the integration of the [Hyperscan](https://github.com/intel/hyperscan) and [llhttp](https://github.com/nodejs/llhttp) libraries. This application intercepts network packets, parses them, detects HTTP protocol sessions, and applies the HTTP protocol parsing on the detected sessions using `llhttp`. 6 | 7 | This practical application can significantly contribute to network security and monitoring efforts, enabling the identification and in-depth analysis of HTTP traffic within a network. 8 | 9 | ## Key Features 10 | 11 | - High-performance network packet interception 12 | - HTTP protocol session detection 13 | - In-depth HTTP protocol parsing for detected sessions 14 | - Utilization of Hyperscan and llhttp libraries 15 | 16 | ## Limitations 17 | 18 | Please note that this example application is not engineered to handle TCP packet retransmissions or reordering. Therefore, it might not perform optimally on unreliable connections. It is specifically designed and optimized for high-quality, reliable connections. 19 | 20 | ## Installation 21 | 22 | ### Prerequisites 23 | 24 | Ensure you have the following installed on your system: 25 | 26 | - Hyperscan 5.2 or later (including headers and libraries) 27 | - llhttp headers and libraries 28 | 29 | ### Installation Steps 30 | 31 | You can use `vcpkg` to install the required Hyperscan and llhttp libraries: 32 | 33 | Install Hyperscan: 34 | 35 | ```bash 36 | vcpkg install hyperscan:x86-windows-static hyperscan:x64-windows-static 37 | ``` 38 | 39 | Install llhttp: 40 | 41 | ```bash 42 | vcpkg install llhttp:x86-windows-static llhttp:x64-windows-static 43 | ``` 44 | 45 | With these libraries installed, you're ready to compile and run the hyperscan application. 46 | -------------------------------------------------------------------------------- /examples/cpp/hyperscan/hyperscan.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;ipp;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 | {f58d99f8-6dfc-44e1-9ff2-381efcda5d4d} 18 | 19 | 20 | {b7bffef8-2d56-4887-94c9-a3a5c019c40c} 21 | 22 | 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files\common\ndisapi 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /examples/cpp/hyperscan/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed 2 | 3 | #include "pch.h" 4 | 5 | // In general, ignore this file, but keep it around if you are using pre-compiled headers. 6 | -------------------------------------------------------------------------------- /examples/cpp/hyperscan/pch.h: -------------------------------------------------------------------------------- 1 | // Tips for Getting Started: 2 | // 1. Use the Solution Explorer window to add/manage files 3 | // 2. Use the Team Explorer window to connect to source control 4 | // 3. Use the Output window to see build output and other messages 5 | // 4. Use the Error List window to view errors 6 | // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project 7 | // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file 8 | 9 | #ifndef PCH_H 10 | #define PCH_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | #include "../../../include/common.h" 48 | #include "../../../include/ndisapi.h" 49 | #include "../common/iphlp.h" 50 | #include "../common/winsys/object.h" 51 | #include "../common/winsys/event.h" 52 | #include "../common/net/mac_address.h" 53 | #include "../common/net/ip_address.h" 54 | #include "../common/net/ip_subnet.h" 55 | #include "../common/net/ip_endpoint.h" 56 | #include "../common/iphelper/network_adapter_info.h" 57 | #include "../common/ndisapi/network_adapter.h" 58 | #include "../common/ndisapi/queued_packet_filter.h" 59 | 60 | #endif //PCH_H 61 | -------------------------------------------------------------------------------- /examples/cpp/hyperscan/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "10b7a178346f3f0abef60cecd5130e295afd8da4", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /examples/cpp/hyperscan/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "ms-gsl", 4 | "hyperscan", 5 | "llhttp" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /examples/cpp/ipv6_parser/README.md: -------------------------------------------------------------------------------- 1 | # IPv6 Parser 2 | 3 | This project demonstrates the useage of `ipv6_parser` class for parsing IPv6 headers and finding the transport payload. 4 | 5 | ## Main Functionality 6 | 7 | The `ipv6_parser::find_transport_header` function is used to parse IP headers until the transport payload. It takes a pointer to the IP header and the size of the IP packet in octets as inputs, and returns a pointer to the IP packet payload (TCP, UDP, ICMPv6, etc.) and protocol. 8 | 9 | The `main` function uses `ndisapi::fastio_packet_filter` to intercept IPv6 packets. It then uses the `find_transport_header` function to parse the IP headers, and if the protocol is TCP, it performs process lookups. 10 | 11 | ## Dependencies 12 | 13 | - You must have `Windows Packet Filter` installed on your machine to build and run this project. 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/cpp/ipv6_parser/ipv6_parser.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;ipp;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 | {f58d99f8-6dfc-44e1-9ff2-381efcda5d4d} 18 | 19 | 20 | {b7bffef8-2d56-4887-94c9-a3a5c019c40c} 21 | 22 | 23 | {2af56194-a0fc-4538-b6b1-050933047be6} 24 | 25 | 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files\common\ndisapi 32 | 33 | 34 | Header Files\common\iphelper 35 | 36 | 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/cpp/ipv6_parser/ipv6_parser.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/cpp/ipv6_parser/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed 2 | 3 | #include "pch.h" 4 | 5 | // In general, ignore this file, but keep it around if you are using pre-compiled headers. 6 | -------------------------------------------------------------------------------- /examples/cpp/ipv6_parser/pch.h: -------------------------------------------------------------------------------- 1 | // Tips for Getting Started: 2 | // 1. Use the Solution Explorer window to add/manage files 3 | // 2. Use the Team Explorer window to connect to source control 4 | // 3. Use the Output window to see build output and other messages 5 | // 4. Use the Error List window to view errors 6 | // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project 7 | // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file 8 | 9 | #ifndef PCH_H 10 | #define PCH_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #include "../../../include/common.h" 44 | #include "../../../include/ndisapi.h" 45 | #include "../common/iphlp.h" 46 | #include "../common/winsys/object.h" 47 | #include "../common/winsys/event.h" 48 | #include "../common/net/mac_address.h" 49 | #include "../common/net/ip_address.h" 50 | #include "../common/net/ip_subnet.h" 51 | #include "../common/net/ip_endpoint.h" 52 | #include "../common/iphelper/process_lookup.h" 53 | #include "../common/iphelper/network_adapter_info.h" 54 | #include "../common/ndisapi/network_adapter.h" 55 | #include "../common/ndisapi/fastio_packet_filter.h" 56 | 57 | #endif //PCH_H 58 | -------------------------------------------------------------------------------- /examples/cpp/ipv6_parser/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "10b7a178346f3f0abef60cecd5130e295afd8da4", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /examples/cpp/ipv6_parser/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "ms-gsl" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /examples/cpp/pcapplusplus/README.md: -------------------------------------------------------------------------------- 1 | # PcapPlusPlus Demo 2 | 3 | This project leverages the [PcapPlusPlus](https://github.com/seladb/PcapPlusPlus) library to intercept network packets, specifically focusing on extracting the Server Name Indication (SNI) from HTTPS packets. The program also performs Transport Layer Security (TLS) fingerprinting to identify the specific version of TLS being utilized. 4 | 5 | ## Getting Started 6 | 7 | These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. 8 | 9 | ### Prerequisites 10 | 11 | - The `Windows Packet Filter` driver must be loaded on your system to use this application. 12 | - This project depends on the PcapPlusPlus library. You will need to install this library and its static triplets using [vcpkg](https://github.com/microsoft/vcpkg), a C++ library manager. 13 | 14 | For a 32-bit Windows system, you can install the necessary triplet with the following command: 15 | 16 | ```bash 17 | vcpkg install pcapplusplus --triplet x86-windows-static 18 | ``` 19 | 20 | For a 64-bit Windows system, use the following command instead: 21 | 22 | ```bash 23 | vcpkg install pcapplusplus --triplet x64-windows-static 24 | ``` 25 | 26 | ### Running the Project 27 | 28 | After you've installed the PcapPlusPlus library, you can now build and run the project to start intercepting network packets and extracting SNI information from HTTPS packets. 29 | 30 | ## Features 31 | 32 | - Network Packet Interception: The application captures and analyzes network packets in real-time. 33 | - SNI Extraction: It can extract the Server Name Indication (SNI) from HTTPS packets. 34 | - TLS Fingerprinting: The application can also identify the specific version of Transport Layer Security (TLS) being used. 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /examples/cpp/pcapplusplus/pcapplusplus.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;ipp;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 | {f58d99f8-6dfc-44e1-9ff2-381efcda5d4d} 18 | 19 | 20 | {b7bffef8-2d56-4887-94c9-a3a5c019c40c} 21 | 22 | 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files\common\ndisapi 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /examples/cpp/pcapplusplus/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed 2 | 3 | #include "pch.h" 4 | 5 | // In general, ignore this file, but keep it around if you are using pre-compiled headers. 6 | -------------------------------------------------------------------------------- /examples/cpp/pcapplusplus/pch.h: -------------------------------------------------------------------------------- 1 | // Tips for Getting Started: 2 | // 1. Use the Solution Explorer window to add/manage files 3 | // 2. Use the Team Explorer window to connect to source control 4 | // 3. Use the Output window to see build output and other messages 5 | // 4. Use the Error List window to view errors 6 | // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project 7 | // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file 8 | 9 | #ifndef PCH_H 10 | #define PCH_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #include "../../../include/common.h" 44 | #include "../../../include/ndisapi.h" 45 | #include "../common/iphlp.h" 46 | #include "../common/winsys/object.h" 47 | #include "../common/winsys/event.h" 48 | #include "../common/net/mac_address.h" 49 | #include "../common/net/ip_address.h" 50 | #include "../common/net/ip_subnet.h" 51 | #include "../common/iphelper/network_adapter_info.h" 52 | #include "../common/ndisapi/network_adapter.h" 53 | #include "../common/ndisapi/simple_packet_filter.h" 54 | 55 | #endif //PCH_H 56 | -------------------------------------------------------------------------------- /examples/cpp/pcapplusplus/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "10b7a178346f3f0abef60cecd5130e295afd8da4", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /examples/cpp/pcapplusplus/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "ms-gsl", 4 | "pcapplusplus" 5 | ], 6 | "builtin-baseline": "7476f0d4e77d3333fbb249657df8251c28c4faae", 7 | "overrides": [ 8 | { 9 | "name": "winpcap", 10 | "version": "4.1.3#10" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /examples/cpp/rebind/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed 2 | 3 | #include "pch.h" 4 | 5 | // In general, ignore this file, but keep it around if you are using pre-compiled headers. -------------------------------------------------------------------------------- /examples/cpp/rebind/pch.h: -------------------------------------------------------------------------------- 1 | // Tips for Getting Started: 2 | // 1. Use the Solution Explorer window to add/manage files 3 | // 2. Use the Team Explorer window to connect to source control 4 | // 3. Use the Output window to see build output and other messages 5 | // 4. Use the Error List window to view errors 6 | // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project 7 | // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file 8 | 9 | #ifndef PCH_H 10 | #define PCH_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include "../../../include/common.h" 46 | #include "../../../include/ndisapi.h" 47 | #include "../common/iphlp.h" 48 | #include "../common/winsys/object.h" 49 | #include "../common/winsys/event.h" 50 | #include "../common/net/mac_address.h" 51 | #include "../common/net/ip_address.h" 52 | #include "../common/net/ip_endpoint.h" 53 | #include "../common/pcap/pcap.h" 54 | #include "../common/pcap/pcap_file_storage.h" 55 | #include "../common/net/ip_subnet.h" 56 | #include "../common/iphelper/network_adapter_info.h" 57 | #include "../common/iphelper/process_lookup.h" 58 | #include "../common/ndisapi/network_adapter.h" 59 | #include "../common/ndisapi/dual_packet_filter.h" 60 | #include "../common/tools/strings.h" 61 | 62 | #endif //PCH_H 63 | -------------------------------------------------------------------------------- /examples/cpp/rebind/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "10b7a178346f3f0abef60cecd5130e295afd8da4", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /examples/cpp/rebind/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "ms-gsl" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /examples/cpp/sni_inspector/README.md: -------------------------------------------------------------------------------- 1 | # SNI Inspector 2 | 3 | The `sni_inspector` is a C++ program that inspects the Server Name Indication (SNI) extension of TLS/SSL connections and Host from HTTP packets. This program utilizes the Windows Packet Filter driver to intercept and analyze network traffic. 4 | 5 | ## Overview 6 | 7 | This program follows these steps: 8 | 9 | 1. It checks if the WinpkFilter driver is loaded. 10 | 2. If the driver is loaded, it displays a list of available network interfaces. 11 | 3. The user can select an interface to filter. 12 | 4. It starts filtering traffic on the selected interface and writes the hostnames from the SNI extension of each TLS/SSL connection and Host from HTTP packets to the console. 13 | 5. The program continues filtering until the user presses a key. 14 | 15 | This tool can be valuable for troubleshooting TLS/SSL connection issues or for monitoring server traffic. 16 | 17 | ## Prerequisites 18 | 19 | The program depends on the the Windows Packet Filter (WinpkFilter) driver. Ensure you have the WinpkFilter driver installed and loaded on your system. 20 | -------------------------------------------------------------------------------- /examples/cpp/sni_inspector/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed 2 | 3 | #include "pch.h" 4 | 5 | // In general, ignore this file, but keep it around if you are using pre-compiled headers. 6 | -------------------------------------------------------------------------------- /examples/cpp/sni_inspector/pch.h: -------------------------------------------------------------------------------- 1 | // Tips for Getting Started: 2 | // 1. Use the Solution Explorer window to add/manage files 3 | // 2. Use the Team Explorer window to connect to source control 4 | // 3. Use the Output window to see build output and other messages 5 | // 4. Use the Error List window to view errors 6 | // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project 7 | // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file 8 | 9 | #ifndef PCH_H 10 | #define PCH_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #include "../../../include/common.h" 44 | #include "../../../include/ndisapi.h" 45 | #include "../common/iphlp.h" 46 | #include "../common/winsys/object.h" 47 | #include "../common/winsys/event.h" 48 | #include "../common/net/mac_address.h" 49 | #include "../common/net/ip_address.h" 50 | #include "../common/net/ip_subnet.h" 51 | #include "../common/iphelper/network_adapter_info.h" 52 | #include "../common/ndisapi/network_adapter.h" 53 | #include "../common/ndisapi/fastio_packet_filter.h" 54 | #include "../common/ndisapi/local_redirect.h" 55 | 56 | #endif //PCH_H 57 | -------------------------------------------------------------------------------- /examples/cpp/sni_inspector/sni_inspector.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;ipp;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 | {f58d99f8-6dfc-44e1-9ff2-381efcda5d4d} 18 | 19 | 20 | {b7bffef8-2d56-4887-94c9-a3a5c019c40c} 21 | 22 | 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files\common\ndisapi 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /examples/cpp/sni_inspector/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "10b7a178346f3f0abef60cecd5130e295afd8da4", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /examples/cpp/sni_inspector/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "ms-gsl" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /examples/cpp/socksify/README.md: -------------------------------------------------------------------------------- 1 | # Windows Packet Filter Socksify Example 2 | 3 | This example demonstrates how to use the Windows Packet Filter to redirect the selected local process through a specified SOCKS5 proxy. In this case, we will redirect Firefox browser traffic through an SSH tunnel. 4 | 5 | ## Prerequisites 6 | 7 | * Local SOCKS5 proxy (e.g., using an SSH command such as `ssh user@domain.com -D 8080`) 8 | 9 | ## Usage 10 | 11 | 1. Start your local SOCKS5 proxy. For example, using an SSH command: 12 | 13 | ``` 14 | ssh user@domain.com -D 8080 15 | ``` 16 | 17 | This command will expose a SOCKS5 proxy on localhost 127.0.0.1:8080. 18 | 19 | 2. Run the socksify.exe tool and follow the prompts: 20 | 21 | ``` 22 | D:\projects\winpkfilter\ndisapi\tools_bin_x64\tools\amd64>socksify.exe 23 | WinpkFilter is loaded 24 | 25 | Available network interfaces: 26 | 27 | 28 | 29 | Select interface to filter: 30 | 31 | Application name to socksify: 32 | 33 | SOCKS5 proxy IP address: 34 | 35 | SOCKS5 proxy port: 36 | 37 | Local port for the transparent TCP proxy server: 38 | 39 | SOCKS5 USERNAME[optional]: 40 | 41 | SOCKS5 PASSWORD[optional]: 42 | ``` 43 | 44 | Example: 45 | 46 | ``` 47 | Select interface to filter: 12 48 | 49 | Application name to socksify: firefox 50 | 51 | SOCKS5 proxy IP address: 127.0.0.1 52 | 53 | SOCKS5 proxy port: 8080 54 | 55 | Local port for the transparent TCP proxy server: 9000 56 | 57 | SOCKS5 USERNAME[optional]: 58 | 59 | SOCKS5 PASSWORD[optional]: 60 | No suitable username or password specified, using anonymous authentication with SOCKS5 proxy 61 | Press any key to stop filtering 62 | Redirect entry was found for the port 50946 is 13.32.110.25:443 63 | Redirect entry was found for the port 50948 is 34.160.90.233:443 64 | Redirect entry was found for the port 50949 is 34.160.90.233:443 65 | Redirect entry was found for the port 50950 is 34.160.90.233:443 66 | ... 67 | ``` 68 | After completing these steps, all traffic from the specified application (in this case, the Firefox browser) will be redirected through the transparent local proxy running on the specified local port (e.g., 9000), and then through the SOCKS5 proxy exposed by the SSH command at 127.0.0.1:8080. 69 | -------------------------------------------------------------------------------- /examples/cpp/socksify/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed 2 | 3 | #include "pch.h" 4 | 5 | // In general, ignore this file, but keep it around if you are using pre-compiled headers. 6 | -------------------------------------------------------------------------------- /examples/cpp/socksify/pch.h: -------------------------------------------------------------------------------- 1 | // Tips for Getting Started: 2 | // 1. Use the Solution Explorer window to add/manage files 3 | // 2. Use the Team Explorer window to connect to source control 4 | // 3. Use the Output window to see build output and other messages 5 | // 4. Use the Error List window to view errors 6 | // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project 7 | // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file 8 | 9 | #ifndef PCH_H 10 | #define PCH_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #include "../../../include/common.h" 45 | #include "../../../include/ndisapi.h" 46 | #include "../common/iphlp.h" 47 | #include "../common/winsys/object.h" 48 | #include "../common/winsys/event.h" 49 | #include "../common/winsys/io_completion_port.h" 50 | #include "../common/net/mac_address.h" 51 | #include "../common/net/ip_address.h" 52 | #include "../common/net/ip_subnet.h" 53 | #include "../common/net/ip_endpoint.h" 54 | #include "../common/log/log.h" 55 | #include "../common/iphelper/network_adapter_info.h" 56 | #include "../common/ndisapi/network_adapter.h" 57 | #include "../common/ndisapi/simple_packet_filter.h" 58 | #include "../common/ndisapi/local_redirect.h" 59 | #include "../common/proxy/proxy_common.h" 60 | #include "../common/proxy/tcp_proxy_socket.h" 61 | #include "../common/proxy/socks5_common.h" 62 | #include "../common/proxy/socks5_tcp_proxy_socket.h" 63 | #include "../common/proxy/tcp_proxy_server.h" 64 | #include "../common/iphelper/process_lookup.h" 65 | 66 | #endif //PCH_H 67 | -------------------------------------------------------------------------------- /examples/cpp/socksify/socksify.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/cpp/socksify/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "10b7a178346f3f0abef60cecd5130e295afd8da4", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /examples/cpp/socksify/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "ms-gsl" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /examples/cpp/udp2tcp/README.md: -------------------------------------------------------------------------------- 1 | # UDP to TCP Converter 2 | 3 | This C++ program acts as a UDP to TCP (and vice versa) converter, using Windows Packet Filter to intercept and modify network packets. 4 | 5 | ## Running the Application 6 | 7 | After building the project, you can run the application with the following command: 8 | 9 | `./udp2tcp` 10 | 11 | The application will prompt you to select a network interface and specify the server or client mode as well as the UDP port number. 12 | 13 | ## How it Works 14 | 15 | The application uses the Windows Packet Filter (WinpkFilter) library to intercept network packets. The `load_filters` function sets up three filters: 16 | 17 | 1. Incoming TCP packets with a specific port are redirected and processed to convert TCP to UDP. 18 | 2. Outgoing UDP packets with a specific port are redirected and processed to convert UDP to TCP. 19 | 3. All other packets are passed without processing in user mode. 20 | 21 | In the `main` function, the application creates a `simple_packet_filter` object with two lambda functions. The first lambda function handles incoming TCP packets and converts them to UDP. The second lambda function handles outgoing UDP packets and converts them to TCP. 22 | -------------------------------------------------------------------------------- /examples/cpp/udp2tcp/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed 2 | 3 | #include "pch.h" 4 | 5 | // In general, ignore this file, but keep it around if you are using pre-compiled headers. -------------------------------------------------------------------------------- /examples/cpp/udp2tcp/pch.h: -------------------------------------------------------------------------------- 1 | // Tips for Getting Started: 2 | // 1. Use the Solution Explorer window to add/manage files 3 | // 2. Use the Team Explorer window to connect to source control 4 | // 3. Use the Output window to see build output and other messages 5 | // 4. Use the Error List window to view errors 6 | // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project 7 | // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file 8 | 9 | #ifndef PCH_H 10 | #define PCH_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include "../../../include/common.h" 46 | #include "../../../include/ndisapi.h" 47 | #include "../common/iphlp.h" 48 | #include "../common/winsys/object.h" 49 | #include "../common/winsys/event.h" 50 | #include "../common/net/mac_address.h" 51 | #include "../common/net/ip_address.h" 52 | #include "../common/pcap/pcap.h" 53 | #include "../common/pcap/pcap_file_storage.h" 54 | #include "../common/net/ip_subnet.h" 55 | #include "../common/iphelper/network_adapter_info.h" 56 | #include "../common/ndisapi/network_adapter.h" 57 | #include "../common/ndisapi/simple_packet_filter.h" 58 | 59 | #endif //PCH_H 60 | -------------------------------------------------------------------------------- /examples/cpp/udp2tcp/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "10b7a178346f3f0abef60cecd5130e295afd8da4", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /examples/cpp/udp2tcp/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "ms-gsl" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /examples/dotNet/TestDotNet/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /examples/dotNet/TestDotNet/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("TestDotNet")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("NT Kernel Resources")] 11 | [assembly: AssemblyProduct("TestDotNet")] 12 | [assembly: AssemblyCopyright("Copyright © NT Kernel Resources 2018")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("c5ad5596-0073-4453-b8de-63659b9f0004")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /examples/dotNet/TestDotNet/README.md: -------------------------------------------------------------------------------- 1 | # TestDotNet 2 | 3 | C# sample demonstrates the NDISAPI usage in several filtering scenarios. Available ion x86 and x64 configurations. AnyCPU configuration is not available due to the C++/CLI nature of ndisapi.net wrapper (see https://github.com/kevin-marshall/Managed.AnyCPU for the workaround). Projects references PacketDotNet (https://github.com/chmorgan/packetnet) for dumping network packets headers. 4 | 5 | 6 | -------------------------------------------------------------------------------- /examples/dotNet/TestDotNet/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/Filter/Filter.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | publish\ 5 | 6 | 7 | 8 | 9 | 10 | en-US 11 | false 12 | 13 | 14 | 10 3 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/Filter/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Filter")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Filter")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("8570825c-b1dc-4290-96bb-b89c07bc1aa7")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/FilterStats/FilterStats.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {9D8EB301-283C-4EA1-A07C-3BAFD433C82A} 7 | Exe 8 | Properties 9 | FilterStats 10 | FilterStats 11 | v2.0 12 | 512 13 | 14 | 15 | AnyCPU 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | false 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | ..\bin\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | {188c7ee3-7cd5-44ca-819a-c400474493bf} 46 | NdisApiWrapper 47 | 48 | 49 | 50 | 57 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/FilterStats/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NdisApiWrapper; 3 | 4 | namespace FilterStats 5 | { 6 | static class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | try 11 | { 12 | if (args.Length < 1) 13 | { 14 | Console.WriteLine( 15 | "Command line syntax:\r\n\tfilterstats.exe [DoReset] \r\n\tDoReset - 1 to reset filters counters / 0 - query counters without reset."); 16 | return; 17 | } 18 | 19 | var reset = Convert.ToInt32(args[0]) == 1; 20 | 21 | var driverPtr = Ndisapi.OpenFilterDriver(); 22 | if (!Ndisapi.IsDriverLoaded(driverPtr)) 23 | { 24 | Console.WriteLine("Driver not installed on this system of failed to load."); 25 | return; 26 | } 27 | 28 | // Get number of filters loaded 29 | var filtersCount = 0u; 30 | Ndisapi.GetPacketFilterTableSize(driverPtr, ref filtersCount); 31 | 32 | Console.WriteLine("{0} filters loaded into the driver", filtersCount); 33 | 34 | if (filtersCount == 0) return; 35 | 36 | var filtersTable = new STATIC_FILTER_TABLE {m_TableSize = filtersCount}; 37 | 38 | // if reset flag is set then query filters table with reset and without reset otherwise 39 | if (reset) 40 | { 41 | Ndisapi.GetPacketFilterTableResetStats(driverPtr, ref filtersTable); 42 | } 43 | else 44 | { 45 | Ndisapi.GetPacketFilterTable(driverPtr, ref filtersTable); 46 | } 47 | 48 | Console.WriteLine("Statistics for the loaded filters:"); 49 | 50 | for (var i = 0; i < filtersTable.m_TableSize; ++i) 51 | { 52 | Console.WriteLine("Filter {0}: ", i); 53 | Console.WriteLine("\tIncoming packets counter = {0}", filtersTable.m_StaticFilters[i].m_PacketsIn); 54 | Console.WriteLine("\tIncoming bytes counter = {0}", filtersTable.m_StaticFilters[i].m_BytesIn); 55 | Console.WriteLine("\tOutgoing packets counter = {0}", filtersTable.m_StaticFilters[i].m_PacketsOut); 56 | Console.WriteLine("\tOutgoing bytes counter = {0}", filtersTable.m_StaticFilters[i].m_BytesOut); 57 | Console.WriteLine("\tLast reset = {0}", new DateTime(1980, 1, 1).AddSeconds(filtersTable.m_StaticFilters[i].m_LastReset).ToLocalTime()); 58 | } 59 | } 60 | catch (Exception ex) 61 | { 62 | Console.WriteLine(ex); 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/FilterStats/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FilterStats")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FilterStats")] 13 | [assembly: AssemblyCopyright("Copyright © 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("5ed63074-b49b-4ca4-a042-06f4816a2d72")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/ListAdapters/ListAdapters.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.50727 7 | 2.0 8 | {85B1406A-F58E-429F-97DF-79AC394D82C4} 9 | Exe 10 | Properties 11 | ListAdapters 12 | ListAdapters 13 | 14 | 15 | 16 | 17 | 3.5 18 | v2.0 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | true 29 | AnyCPU 30 | 31 | 32 | pdbonly 33 | true 34 | ..\bin\ 35 | TRACE 36 | prompt 37 | 4 38 | true 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | {188c7ee3-7cd5-44ca-819a-c400474493bf} 52 | NdisApiWrapper 53 | 54 | 55 | 56 | 63 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/ListAdapters/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ListAdapters")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ListAdapters")] 13 | [assembly: AssemblyCopyright("Copyright © 2008")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e01f54d6-1c4e-4d21-a712-efdfd49a0097")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | [assembly: AssemblyVersion("1.0.0.0")] 33 | [assembly: AssemblyFileVersion("1.0.0.0")] 34 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/NdisApi/NdisApiWrapper.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {188C7EE3-7CD5-44CA-819A-C400474493BF} 9 | Library 10 | Properties 11 | NdisApiWrapper 12 | NdisApiWrapper 13 | v2.0 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | true 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | true 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 54 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/NdisApi/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("NdisApi")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NdisApi")] 13 | [assembly: AssemblyCopyright("Copyright © 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("f4221e08-4b3c-4f91-a2af-2a1e5c4ccf6c")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/NdisApi/Win32Api.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace NdisApiWrapper 5 | { 6 | public struct Win32Api 7 | { 8 | public const int MAX_PATH = 260; 9 | 10 | public const int VER_PLATFORM_WIN32s = 0; 11 | public const int VER_PLATFORM_WIN32_WINDOWS = 1; 12 | public const int VER_PLATFORM_WIN32_NT = 2; 13 | 14 | public const uint INFINITE = 4294967295; 15 | 16 | [DllImport("kernel32", EntryPoint = "GetVersionExA")] 17 | public static extern int GetVersionEx(ref OSVERSIONINFO lpVersionInformation); 18 | [System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "CreateEventA")] 19 | public static extern int CreateEvent(ref SECURITY_ATTRIBUTES lpEventAttributes, int bManualReset, int bInitialState, string lpName); 20 | [System.Runtime.InteropServices.DllImport("kernel32.dll")] 21 | public static extern int ResetEvent(int hEvent); 22 | [System.Runtime.InteropServices.DllImport("kernel32.dll")] 23 | public static extern int CloseHandle(int hObject); 24 | [System.Runtime.InteropServices.DllImport("kernel32.dll")] 25 | public static extern int WaitForSingleObject(int hHandle, int dwMilliseconds); 26 | 27 | //[System.Runtime.InteropServices.DllImport("kernel32", EntryPoint = "RtlMoveMemory")] 28 | //public static extern void CopyMemory(ref object pDst, ref object pSrc, int ByteLen); 29 | 30 | [DllImport("kernel32", EntryPoint = "RtlZeroMemory")] 31 | public static extern void ZeroMemory(IntPtr Destination, int Length); 32 | public static void ZeroMemory(object obj) 33 | { 34 | GCHandle gc = GCHandle.Alloc(obj); 35 | ZeroMemory(GCHandle.ToIntPtr(gc), Marshal.SizeOf(obj)); 36 | gc.Free(); 37 | } 38 | 39 | [System.Runtime.InteropServices.DllImport("kernel32")] 40 | public static extern void Sleep(int dwMilliseconds); 41 | [System.Runtime.InteropServices.DllImport("ws2_32.dll")] 42 | public static extern short htons(short hostshort); 43 | } 44 | 45 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 46 | public struct OSVERSIONINFO 47 | { 48 | public int dwOSVersionInfoSize; 49 | public int dwMajorVersion; 50 | public int dwMinorVersion; 51 | public int dwBuildNumber; 52 | public int dwPlatformId; 53 | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] 54 | public byte[] szCSDVersion; 55 | 56 | public static OSVERSIONINFO GetVersion() 57 | { 58 | OSVERSIONINFO res = new OSVERSIONINFO(); 59 | res.dwOSVersionInfoSize = Marshal.SizeOf(res); 60 | Win32Api.GetVersionEx(ref res); 61 | return res; 62 | } 63 | } 64 | public struct SECURITY_ATTRIBUTES 65 | { 66 | public int nLength; 67 | public int lpSecurityDescriptor; 68 | public int bInheritHandle; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/NdisRequest/NdisRequest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {87CEFC9E-FDD5-4499-8844-AACCE1A8A99B} 8 | Exe 9 | Properties 10 | NdisRequest 11 | NdisRequest 12 | v2.0 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | ..\bin\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | {188c7ee3-7cd5-44ca-819a-c400474493bf} 47 | NdisApiWrapper 48 | 49 | 50 | 51 | 58 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/NdisRequest/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("NdisRequest")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NdisRequest")] 13 | [assembly: AssemblyCopyright("Copyright © 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a1aa7b39-0c27-4054-87e6-9b6653b358b1")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/PacketSniffer/PacketSniffer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.50727 7 | 2.0 8 | {EE907D70-7D34-4A21-8DB3-895D7815BC58} 9 | Exe 10 | Properties 11 | PacketSniffer 12 | PacketSniffer 13 | 14 | 15 | 16 | 17 | 3.5 18 | v2.0 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | true 29 | AnyCPU 30 | 31 | 32 | pdbonly 33 | true 34 | ..\bin\ 35 | TRACE 36 | prompt 37 | 4 38 | true 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | {188c7ee3-7cd5-44ca-819a-c400474493bf} 52 | NdisApiWrapper 53 | 54 | 55 | 56 | 63 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/PacketSniffer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PacketSniffer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("PacketSniffer")] 13 | [assembly: AssemblyCopyright("Copyright © 2008")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3a8d9665-00dd-40e3-806f-045b32fd48b8")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | [assembly: AssemblyVersion("1.0.0.0")] 33 | [assembly: AssemblyFileVersion("1.0.0.0")] 34 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/PassThru/PassThru.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.50727 7 | 2.0 8 | {79600DBD-517F-4EEA-9C47-7AAF5D0BC862} 9 | Exe 10 | Properties 11 | PassThru 12 | PassThru 13 | 14 | 15 | 16 | 17 | 3.5 18 | v2.0 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | true 29 | AnyCPU 30 | 31 | 32 | pdbonly 33 | true 34 | ..\bin\ 35 | TRACE 36 | prompt 37 | 4 38 | true 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | {188c7ee3-7cd5-44ca-819a-c400474493bf} 52 | NdisApiWrapper 53 | 54 | 55 | 56 | 63 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/PassThru/PassThru.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 11 100 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/legacy/CSharp/PassThru/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PassThru")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("PassThru")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2008")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("9b98b762-e56e-429f-9501-c8b18c8b6c5c")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | [assembly: AssemblyVersion("1.0.0.0")] 33 | [assembly: AssemblyFileVersion("1.0.0.0")] 34 | -------------------------------------------------------------------------------- /examples/legacy/Delphi/ListAdapters/ListAdapters.cfg: -------------------------------------------------------------------------------- 1 | -$A8 2 | -$B- 3 | -$C+ 4 | -$D+ 5 | -$E- 6 | -$F- 7 | -$G+ 8 | -$H+ 9 | -$I+ 10 | -$J- 11 | -$K- 12 | -$L+ 13 | -$M- 14 | -$N+ 15 | -$O+ 16 | -$P+ 17 | -$Q- 18 | -$R- 19 | -$S- 20 | -$T- 21 | -$U- 22 | -$V+ 23 | -$W- 24 | -$X+ 25 | -$YD 26 | -$Z1 27 | -cg 28 | -AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; 29 | -H+ 30 | -W+ 31 | -M 32 | -$M16384,1048576 33 | -K$00400000 34 | -E"..\bin" 35 | -LE"c:\program files\borland\delphi7\Projects\Bpl" 36 | -LN"c:\program files\borland\delphi7\Projects\Bpl" 37 | -w-UNSAFE_TYPE 38 | -w-UNSAFE_CODE 39 | -w-UNSAFE_CAST 40 | -------------------------------------------------------------------------------- /examples/legacy/Delphi/PacketSniffer/PacketSniffer.cfg: -------------------------------------------------------------------------------- 1 | -$A8 2 | -$B- 3 | -$C+ 4 | -$D+ 5 | -$E- 6 | -$F- 7 | -$G+ 8 | -$H+ 9 | -$I+ 10 | -$J- 11 | -$K- 12 | -$L+ 13 | -$M- 14 | -$N+ 15 | -$O+ 16 | -$P+ 17 | -$Q- 18 | -$R- 19 | -$S- 20 | -$T- 21 | -$U- 22 | -$V+ 23 | -$W- 24 | -$X+ 25 | -$YD 26 | -$Z1 27 | -cg 28 | -AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; 29 | -H+ 30 | -W+ 31 | -M 32 | -$M16384,1048576 33 | -K$00400000 34 | -E"..\bin" 35 | -LE"c:\program files\borland\delphi7\Projects\Bpl" 36 | -LN"c:\program files\borland\delphi7\Projects\Bpl" 37 | -w-UNSAFE_TYPE 38 | -w-UNSAFE_CODE 39 | -w-UNSAFE_CAST 40 | -------------------------------------------------------------------------------- /examples/legacy/Delphi/PassThru/PassThru.cfg: -------------------------------------------------------------------------------- 1 | -$A8 2 | -$B- 3 | -$C+ 4 | -$D+ 5 | -$E- 6 | -$F- 7 | -$G+ 8 | -$H+ 9 | -$I+ 10 | -$J- 11 | -$K- 12 | -$L+ 13 | -$M- 14 | -$N+ 15 | -$O+ 16 | -$P+ 17 | -$Q- 18 | -$R- 19 | -$S- 20 | -$T- 21 | -$U- 22 | -$V+ 23 | -$W- 24 | -$X+ 25 | -$YD 26 | -$Z1 27 | -cg 28 | -AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; 29 | -H+ 30 | -W+ 31 | -M 32 | -$M16384,1048576 33 | -K$00400000 34 | -E"..\bin" 35 | -LE"c:\program files\borland\delphi7\Projects\Bpl" 36 | -LN"c:\program files\borland\delphi7\Projects\Bpl" 37 | -w-UNSAFE_TYPE 38 | -w-UNSAFE_CODE 39 | -w-UNSAFE_CAST 40 | -------------------------------------------------------------------------------- /examples/legacy/Delphi/iphlp.pas: -------------------------------------------------------------------------------- 1 | { Windows Packet Filter Kit 3.0 } 2 | { Copyright(C) 2000-2010 NT Kernel Resources } 3 | { mailto: ndisrd@ntkernel.com } 4 | 5 | unit iphlp; 6 | 7 | interface 8 | 9 | uses Windows; 10 | 11 | const 12 | ETH_ALEN = 6; // Octets in one ethernet addr 13 | ARPHRD_ETHER = $01; 14 | ARPOP_REQUEST = $01; 15 | ARPOP_REPLY = $02; 16 | 17 | ETH_P_IP = $0800; // Internet Protocol packet 18 | ETH_P_RARP = $8035; // Reverse Addr Res packet 19 | ETH_P_ARP = $0806; // Address Resolution packet 20 | 21 | // Protocols 22 | 23 | IPPROTO_IP = 0; // dummy for IP 24 | IPPROTO_ICMP = 1; // control message protocol 25 | IPPROTO_IGMP = 2; // group management protocol 26 | IPPROTO_GGP = 3; // gateway^2 (deprecated) 27 | IPPROTO_TCP = 6; // tcp 28 | IPPROTO_PUP = 12; // pup 29 | IPPROTO_UDP = 17; // user datagram protocol 30 | IPPROTO_IDP = 22; // xns idp 31 | IPPROTO_ND = 77; // UNOFFICIAL net disk proto 32 | 33 | IPPROTO_RAW = 255; // raw IP packet 34 | IPPROTO_MAX = 256; 35 | 36 | // 37 | // Ethernet Header 38 | // 39 | type 40 | TEtherHeaderPtr = ^TEtherHeader; 41 | TEtherHeader = packed record 42 | h_dest: array [1..ETH_ALEN] of Byte; { destination eth addr } 43 | h_source: array [1..ETH_ALEN] of Byte; { source ether addr } 44 | h_proto: Word; { packet type ID field } 45 | end; 46 | 47 | // 48 | // IP header 49 | // 50 | type 51 | TIPHeaderPtr = ^TIPHeader; 52 | TIPHeader = packed record 53 | VerLen: Byte; 54 | TOS: Byte; 55 | TotalLen: Word; 56 | Identifer: Word; 57 | FragOffsets: Word; 58 | TTL: Byte; 59 | Protocol: Byte; 60 | CheckSum: Word; 61 | SourceIp: DWORD; 62 | DestIp: DWORD; 63 | Options: DWORD; 64 | end; 65 | 66 | // 67 | // TCP header 68 | // 69 | TTCPHeaderPtr = ^TTCPHeader; 70 | TTCPHeader = packed record 71 | SourcePort:Word; 72 | DestPort:Word; 73 | SequenceNumber:DWord; 74 | AcknowledgementNumber:DWord; 75 | Offset:Byte; //only left 4 bits. Header length in 32-bit segments 76 | Flags:Byte; 77 | Window:Word; 78 | Checksum:Word; //includes speudo header instead of TCP header. 79 | UrgentPointer:Word; 80 | end; 81 | 82 | // 83 | // UDP header 84 | // 85 | TUDPHeaderPtr = ^TUDPHeader; 86 | TUDPHeader = packed record 87 | SourcePort:Word; 88 | DestPort:Word; 89 | Length:Word; 90 | Checksum:Word; 91 | end; 92 | 93 | 94 | implementation 95 | 96 | end. 97 | -------------------------------------------------------------------------------- /examples/legacy/Delphi/ndisrequest/ndisrequest.cfg: -------------------------------------------------------------------------------- 1 | -$A8 2 | -$B- 3 | -$C+ 4 | -$D+ 5 | -$E- 6 | -$F- 7 | -$G+ 8 | -$H+ 9 | -$I+ 10 | -$J- 11 | -$K- 12 | -$L+ 13 | -$M- 14 | -$N+ 15 | -$O+ 16 | -$P+ 17 | -$Q- 18 | -$R- 19 | -$S- 20 | -$T- 21 | -$U- 22 | -$V+ 23 | -$W- 24 | -$X+ 25 | -$YD 26 | -$Z1 27 | -cg 28 | -AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; 29 | -H+ 30 | -W+ 31 | -M 32 | -$M16384,1048576 33 | -K$00400000 34 | -E"..\bin" 35 | -LE"c:\program files\borland\delphi7\Projects\Bpl" 36 | -LN"c:\program files\borland\delphi7\Projects\Bpl" 37 | -w-UNSAFE_TYPE 38 | -w-UNSAFE_CODE 39 | -w-UNSAFE_CAST 40 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/filter/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.cpp */ 8 | /* */ 9 | /* Abstract: source file that includes just the standard includes */ 10 | /* */ 11 | /*************************************************************************/ 12 | 13 | #include "stdafx.h" 14 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/filter/StdAfx.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.h */ 8 | /* */ 9 | /* Abstract: include file for standard system include files, */ 10 | /* or project specific include files that are used frequently, but */ 11 | /* are changed infrequently */ 12 | /* */ 13 | /*************************************************************************/ 14 | 15 | #if !defined(AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_) 16 | #define AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_ 17 | 18 | #if _MSC_VER > 1000 19 | #pragma once 20 | #endif // _MSC_VER > 1000 21 | 22 | #ifndef WIN32_LEAN_AND_MEAN 23 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 24 | #endif // WIN32_LEAN_AND_MEAN 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "..\..\..\..\include\common.h" 33 | #include "..\..\..\..\include\ndisapi.h" 34 | #include "iphlp.h" 35 | 36 | //{{AFX_INSERT_LOCATION}} 37 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 38 | 39 | #endif // !defined(AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_) 40 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/filter/filter.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {f38ef434-04cb-4288-9908-c83b44e5888c} 6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat 7 | 8 | 9 | {6f573063-1e7b-4500-b980-d7817a1a8dbd} 10 | h;hpp;hxx;hm;inl 11 | 12 | 13 | {cd950b59-825f-4363-9273-d7408a8582bd} 14 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 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 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/filterstats/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.cpp */ 8 | /* */ 9 | /* Abstract: source file that includes just the standard includes */ 10 | /* */ 11 | /*************************************************************************/ 12 | 13 | #include "stdafx.h" 14 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/filterstats/StdAfx.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.h */ 8 | /* */ 9 | /* Abstract: include file for standard system include files, */ 10 | /* or project specific include files that are used frequently, but */ 11 | /* are changed infrequently */ 12 | /* */ 13 | /*************************************************************************/ 14 | 15 | #if !defined(AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_) 16 | #define AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_ 17 | 18 | #if _MSC_VER > 1000 19 | #pragma once 20 | #endif // _MSC_VER > 1000 21 | 22 | #ifndef WIN32_LEAN_AND_MEAN 23 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 24 | #endif // WIN32_LEAN_AND_MEAN 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "..\..\..\..\include\common.h" 33 | #include "..\..\..\..\include\ndisapi.h" 34 | #include "iphlp.h" 35 | 36 | //{{AFX_INSERT_LOCATION}} 37 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 38 | 39 | #endif // !defined(AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_) 40 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/filterstats/filterstats.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: filterstats.cpp */ 8 | /* */ 9 | /* Abstract: Defines the entry point for the console application */ 10 | /* */ 11 | /*************************************************************************/ 12 | #include "stdafx.h" 13 | 14 | int main(int argc, char* argv[]) 15 | { 16 | CNdisApi api; 17 | 18 | if (argc < 2) 19 | { 20 | printf ("Command line syntax:\n\tfilterstats.exe [DoReset] \n\tDoReset - 1 to reset filters counters / 0 - query counters without reset.\n"); 21 | 22 | return 0; 23 | } 24 | 25 | DWORD bReset = atoi(argv[1]); 26 | 27 | if(!api.IsDriverLoaded()) 28 | { 29 | printf ("Driver not installed on this system of failed to load.\n"); 30 | return 0; 31 | } 32 | 33 | // Get number of filters loaded 34 | DWORD dwFilterNum = 0; 35 | api.GetPacketFilterTableSize(&dwFilterNum); 36 | 37 | printf ("%d filters loaded into the driver \n", dwFilterNum); 38 | 39 | if (dwFilterNum) 40 | { 41 | DWORD dwTableSize = sizeof (STATIC_FILTER_TABLE) + (dwFilterNum - ANY_SIZE)*sizeof(STATIC_FILTER); 42 | 43 | PSTATIC_FILTER_TABLE pFilterTable = (PSTATIC_FILTER_TABLE)malloc(dwTableSize); 44 | 45 | if (pFilterTable) 46 | { 47 | // Initialize table size 48 | pFilterTable->m_TableSize = dwFilterNum; 49 | 50 | // if reset flag is set then query filters table with reset and without reset otherwise 51 | if (!bReset) 52 | api.GetPacketFilterTable (pFilterTable); 53 | else 54 | api.GetPacketFilterTableResetStats (pFilterTable); 55 | 56 | printf ("Statistics for the loaded filters:\n"); 57 | 58 | for (unsigned i = 0; i < pFilterTable->m_TableSize; ++i) 59 | { 60 | printf ("Filter %d: \n", i); 61 | printf ("\tIncoming packets counter = %llu \n", pFilterTable->m_StaticFilters[i].m_PacketsIn.QuadPart); 62 | printf ("\tIncoming bytes counter = %llu \n", pFilterTable->m_StaticFilters[i].m_BytesIn.QuadPart); 63 | printf ("\tOutgoing packets counter = %llu \n", pFilterTable->m_StaticFilters[i].m_PacketsOut.QuadPart); 64 | printf ("\tOutgoing bytes counter = %llu \n", pFilterTable->m_StaticFilters[i].m_BytesOut.QuadPart); 65 | printf ("\tLast reset = %d \n", pFilterTable->m_StaticFilters[i].m_LastReset); 66 | } 67 | 68 | free (pFilterTable); 69 | } 70 | } 71 | 72 | return 0; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/filterstats/filterstats.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {a870b09a-08d1-426f-aebe-bbf91f9d0bb2} 6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat 7 | 8 | 9 | {cb648a7a-7c73-4291-bf83-5f80e4b9f7b8} 10 | h;hpp;hxx;hm;inl 11 | 12 | 13 | {e0c42497-f018-49e6-8451-e44c93f6e62d} 14 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 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 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/gretunnel/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.cpp */ 8 | /* */ 9 | /* Abstract: source file that includes just the standard includes */ 10 | /* */ 11 | /*************************************************************************/ 12 | 13 | #include "stdafx.h" 14 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/gretunnel/StdAfx.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.h */ 8 | /* */ 9 | /* Abstract: include file for standard system include files, */ 10 | /* or project specific include files that are used frequently, but */ 11 | /* are changed infrequently */ 12 | /* */ 13 | /*************************************************************************/ 14 | 15 | #if !defined(AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_) 16 | #define AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_ 17 | 18 | #if _MSC_VER > 1000 19 | #pragma once 20 | #endif // _MSC_VER > 1000 21 | 22 | #ifndef WIN32_LEAN_AND_MEAN 23 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 24 | #endif // WIN32_LEAN_AND_MEAN 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "..\..\..\..\include\common.h" 33 | #include "..\..\..\..\include\ndisapi.h" 34 | #include "iphlp.h" 35 | 36 | //{{AFX_INSERT_LOCATION}} 37 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 38 | 39 | #endif // !defined(AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_) 40 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/gretunnel/gretunnel.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {62cf1c17-5339-432a-9f69-9db8ded394fc} 6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat 7 | 8 | 9 | {70b38b6b-c589-4a2d-b229-e81988c98bc6} 10 | h;hpp;hxx;hm;inl 11 | 12 | 13 | {07e0bdbf-40c7-4951-bcc2-5e3fee31925a} 14 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 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 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/lfnemu/AckTimerLayer.h: -------------------------------------------------------------------------------- 1 | #ifndef _ACKTIMERLAYER_H 2 | #define _ACKTIMERLAYER_H 3 | 4 | #include "Common.h" 5 | 6 | namespace acktl { 7 | 8 | int initLayer(UINT aTimeout, void* aNextLayer, void* aNextLayerUp); 9 | int haltLayer(void); 10 | void AckTimerLayer(PETH_REQUEST pRequest); 11 | } 12 | 13 | #endif //_ACKTIMERLAYER_H -------------------------------------------------------------------------------- /examples/legacy/MSVC/lfnemu/Common.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Common.h" 3 | 4 | TCP_AdapterList AdList; 5 | CNdisApi api; 6 | DWORD dwAdapterCount; 7 | HANDLE hEvent[33]; 8 | BOOL bPausing = false; 9 | BOOL bExitSignal = false; 10 | BOOL bUsePAcketCount = false; 11 | 12 | DWORD dwDelayFrecuency = 0; 13 | DWORD dwDelayPktCount = 0; 14 | DWORD dwDelayLength; 15 | DWORD dwDelayDelta; 16 | DWORD dwPktRemaining; 17 | HANDLE hCountPktsSentEv; 18 | std::vector vFlushBuffer; 19 | 20 | bool usePacketDropperLayer = false; 21 | bool usePacketDelayerLayer = false; 22 | bool useAckTimerLayer = false; 23 | 24 | void (*topLayerDownward)(PETH_REQUEST pRequest) = 0; 25 | void (*bottomLayerUpward)(PETH_REQUEST pRequest) = 0; 26 | 27 | CRITICAL_SECTION csMapLock; 28 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/lfnemu/Common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_DEFINITIONS_H 2 | #define _COMMON_DEFINITIONS_H 3 | 4 | #define E_INITHANDLES 0x00000001 5 | #define E_INVALIDOPTION 0x00000002 6 | #define E_DRIVERNOTPRESENT 0x00000003 7 | #define E_INITEVENT 0x00000004 8 | #define E_ATENTIONTHREAD 0x00000005 9 | 10 | #define ALL_PACKETS INFINITE 11 | 12 | extern TCP_AdapterList AdList; 13 | extern CNdisApi api; 14 | extern DWORD dwAdapterCount; 15 | extern HANDLE hEvent[33]; 16 | extern BOOL bPausing; 17 | extern BOOL bExitSignal; 18 | extern BOOL bUsePAcketCount; 19 | 20 | extern DWORD dwDelayFrecuency; 21 | extern DWORD dwDelayPktCount; 22 | extern DWORD dwDelayLength; 23 | extern DWORD dwDelayDelta; 24 | extern DWORD dwPktRemaining; 25 | extern HANDLE hCountPktsSentEv; 26 | extern std::vector vFlushBuffer; 27 | 28 | extern CRITICAL_SECTION csMapLock; 29 | 30 | extern bool usePacketDropperLayer; 31 | extern bool usePacketDelayerLayer; 32 | //extern bool useAckTimerLayer; 33 | 34 | extern void (*topLayerDownward)(PETH_REQUEST pRequest); 35 | extern void (*bottomLayerUpward)(PETH_REQUEST pRequest); 36 | 37 | extern void ReleaseInterface(); 38 | extern DWORD FlushNBufferedPackets(BOOL bSend, UINT count); 39 | 40 | #endif //_COMMON_DEFINITIONS_H -------------------------------------------------------------------------------- /examples/legacy/MSVC/lfnemu/Finalization.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Finalization.h" 3 | 4 | // 5 | // Function sends n (if specified) or all buffered TCP stream. If count was 6 | // used, it returns Count - Sent, that is the remaining packets that could've 7 | // been sent. 8 | // 9 | DWORD FlushNBufferedPackets(BOOL bSend, UINT count) 10 | { 11 | std::vector::iterator theIterator; 12 | 13 | for (theIterator = vFlushBuffer.begin(); theIterator != 14 | vFlushBuffer.end(); theIterator++) 15 | { 16 | if(bSend) 17 | { 18 | // Place packet on the network interface 19 | api.SendPacketToAdapter((PETH_REQUEST)(*theIterator)); 20 | } 21 | 22 | if (bUsePAcketCount && (!--count)) 23 | { 24 | vFlushBuffer.erase(vFlushBuffer.begin(), ++theIterator); 25 | return 0; 26 | } 27 | 28 | delete (*theIterator); 29 | } 30 | 31 | vFlushBuffer.clear(); 32 | return (bUsePAcketCount? 0: count); 33 | } 34 | 35 | 36 | void ReleaseHandles() 37 | { 38 | // This function releases packets in the adapter queue and stops listening the interface 39 | ADAPTER_MODE Mode; 40 | 41 | for(UINT nCount = 0; nCount < dwAdapterCount - 1; nCount++) 42 | { 43 | Mode.dwFlags = 0; 44 | Mode.hAdapterHandle = (HANDLE)AdList.m_nAdapterHandle[nCount]; 45 | 46 | // Set NULL event to release previously set event object 47 | api.SetPacketEvent(AdList.m_nAdapterHandle[nCount], NULL); 48 | 49 | // Close Event 50 | if (hEvent[nCount+1]) 51 | CloseHandle ( hEvent[nCount+1] ); 52 | 53 | // Set default adapter mode 54 | api.SetAdapterMode(&Mode); 55 | 56 | // Empty adapter packets queue 57 | api.FlushAdapterPacketQueue (AdList.m_nAdapterHandle[nCount]); 58 | } 59 | 60 | } 61 | 62 | void ReleaseInterface() 63 | { 64 | if (usePacketDropperLayer){ 65 | _tprintf(_T("Halting Packet dropper...")); 66 | _tprintf(_T("%s"), pdropl::haltLayer()? _T("Ok\n"): _T("FAILED\n")); 67 | } 68 | 69 | if (usePacketDelayerLayer){ 70 | _tprintf(_T("Halting Packet Delayer...")); 71 | _tprintf(_T("%s"), pdl::haltLayer()? _T("Ok\n"): _T("FAILED\n")); 72 | } 73 | 74 | ReleaseHandles(); 75 | 76 | if (hEvent[0]) 77 | CloseHandle ( hEvent[0] ); 78 | 79 | if (hCountPktsSentEv) 80 | CloseHandle(hCountPktsSentEv); 81 | 82 | std::vector::iterator theIterator; 83 | 84 | ::EnterCriticalSection(&csMapLock); 85 | 86 | for (theIterator = vFlushBuffer.begin(); theIterator != vFlushBuffer.end(); 87 | theIterator++) 88 | { 89 | FlushNBufferedPackets(FALSE, ALL_PACKETS); 90 | } 91 | 92 | vFlushBuffer.clear(); 93 | 94 | ::LeaveCriticalSection(&csMapLock); 95 | 96 | ::DeleteCriticalSection(&csMapLock); 97 | } 98 | 99 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/lfnemu/Finalization.h: -------------------------------------------------------------------------------- 1 | #ifndef _FINALIZATION_H 2 | #define _FINALIZATION_H 3 | 4 | #include "Common.h" 5 | #include "PacketDelayerLayer.h" 6 | #include "PacketDropperLayer.h" 7 | 8 | void ReleaseHandles(); 9 | void ReleaseInterface(); 10 | 11 | #endif //_FINALIZATION_H -------------------------------------------------------------------------------- /examples/legacy/MSVC/lfnemu/Initialization.h: -------------------------------------------------------------------------------- 1 | #ifndef _INITIALIZATION_H 2 | #define _INITIALIZATION_H 3 | 4 | #include "Common.h" 5 | #include "ndisInterfaceLayer.h" 6 | #include "PacketDelayerLayer.h" 7 | #include "PacketDropperLayer.h" 8 | 9 | int initialize(int argc, LPCTSTR argv[]); 10 | int InitHandles(); 11 | 12 | #endif //_INITIALIZATION_H -------------------------------------------------------------------------------- /examples/legacy/MSVC/lfnemu/PacketDelayerLayer.h: -------------------------------------------------------------------------------- 1 | #ifndef _PACKET_DELAYER_LAYER_H 2 | #define _PACKET_DELAYER_LAYER_H 3 | 4 | #include "Common.h" 5 | 6 | namespace pdl { 7 | 8 | int initLayer(UINT aDownwardDelayLapse, UINT anUpwardDelayLapse, 9 | void* aNextLayerDown, void* aNextLayerUp); 10 | int haltLayer(void); 11 | void PacketDelayerLayer(PETH_REQUEST pRequest); 12 | } 13 | 14 | #endif //_PACKET_DELAYER_LAYER_H -------------------------------------------------------------------------------- /examples/legacy/MSVC/lfnemu/PacketDropperLayer.h: -------------------------------------------------------------------------------- 1 | #ifndef _PACKETDROPPERLAYER_H 2 | #define _PACKETDROPPERLAYER_H 3 | 4 | #include "Common.h" 5 | 6 | namespace pdropl { 7 | 8 | int initLayer(UINT anIncomingDropThreshold, UINT anIncomingDropCount, 9 | UINT anOutgoingDropThreshold, UINT anOutgoingDropCount, 10 | void* aNextLayerDown, void* aNextLayerUp); 11 | int haltLayer(void); 12 | void PacketDropperLayer(PETH_REQUEST pRequest); 13 | } 14 | 15 | #endif //_PACKETDROPPERLAYER_H -------------------------------------------------------------------------------- /examples/legacy/MSVC/lfnemu/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // LFNEmulator.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/lfnemu/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__52478BAB_A15E_4C0E_B3C8_A4AC56BCCCCF__INCLUDED_) 7 | #define AFX_STDAFX_H__52478BAB_A15E_4C0E_B3C8_A4AC56BCCCCF__INCLUDED_ 8 | 9 | #if _MSC_VER > 1000 10 | #pragma once 11 | #endif // _MSC_VER > 1000 12 | 13 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 14 | 15 | // TODO: reference additional headers your program requires here 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "..\..\..\..\include\common.h" 27 | #include "..\..\..\..\include\ndisapi.h" 28 | #include "iphlp.h" 29 | 30 | //{{AFX_INSERT_LOCATION}} 31 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 32 | 33 | #endif // !defined(AFX_STDAFX_H__52478BAB_A15E_4C0E_B3C8_A4AC56BCCCCF__INCLUDED_) 34 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/lfnemu/lfnemu.cpp: -------------------------------------------------------------------------------- 1 | // lfnemu.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "lfnemu.h" 6 | #include 7 | 8 | int mainLoop(void); 9 | 10 | int main(int argc, LPCTSTR argv[]) 11 | { 12 | int result; 13 | 14 | if ((result = initialize(argc, argv)) != 0) 15 | return result; 16 | 17 | return mainLoop(); 18 | } 19 | 20 | 21 | int mainLoop() 22 | { 23 | DWORD dwEvent; 24 | PETH_REQUEST pRequest; 25 | PINTERMEDIATE_BUFFER aux; 26 | 27 | pRequest = (PETH_REQUEST) malloc(sizeof(ETH_REQUEST)); 28 | ZeroMemory(pRequest, sizeof(ETH_REQUEST)); 29 | pRequest->EthPacket.Buffer = (PINTERMEDIATE_BUFFER) 30 | malloc(sizeof(INTERMEDIATE_BUFFER)); 31 | ZeroMemory(pRequest->EthPacket.Buffer, sizeof(INTERMEDIATE_BUFFER)); 32 | 33 | while (!bExitSignal) 34 | { 35 | dwEvent = WaitForMultipleObjects (dwAdapterCount, hEvent, FALSE, 36 | INFINITE ); 37 | 38 | ResetEvent(hEvent[dwEvent]); 39 | 40 | if (bExitSignal) // Are we exiting? 41 | break; 42 | 43 | if (!dwEvent) 44 | { 45 | /* Excerpt from WinpkFilter documentation: 46 | "This event when TCP/IP bound adapter's list changes (an 47 | example this happens on plug/unplug network card, 48 | disable/enable network connection or etc.). Usually you 49 | should call GetTcpipBoundAdaptersInfo and renew your adapter 50 | associated structures on this event." 51 | 52 | In this code, dwEvent = 0 holds the event mentioned above. 53 | */ 54 | ReleaseHandles(); 55 | 56 | if(!InitHandles()) 57 | return E_INITHANDLES; 58 | 59 | continue; 60 | } 61 | 62 | pRequest->hAdapterHandle = (HANDLE) AdList.m_nAdapterHandle[dwEvent-1]; 63 | while(api.ReadPacket(pRequest)) 64 | { 65 | if (pRequest->EthPacket.Buffer->m_dwDeviceFlags == 66 | PACKET_FLAG_ON_SEND){ 67 | 68 | // Give packet to the topmost layer 69 | topLayerDownward(pRequest); 70 | } 71 | else { 72 | 73 | // Packet is headed up. Hand it to the bottom layer of our stack 74 | bottomLayerUpward(pRequest); 75 | } 76 | 77 | // Initialize pRequest for next use 78 | pRequest = (PETH_REQUEST) malloc(sizeof(ETH_REQUEST)); 79 | aux = (PINTERMEDIATE_BUFFER) malloc(sizeof(INTERMEDIATE_BUFFER)); 80 | ZeroMemory(pRequest, sizeof(ETH_REQUEST)); 81 | ZeroMemory(aux, sizeof(INTERMEDIATE_BUFFER)); 82 | pRequest->EthPacket.Buffer = aux; 83 | pRequest->hAdapterHandle = 84 | (HANDLE) AdList.m_nAdapterHandle[dwEvent-1]; 85 | } // while 86 | } // while 87 | 88 | free(pRequest->EthPacket.Buffer); 89 | free(pRequest); 90 | 91 | return 0; 92 | } 93 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/lfnemu/lfnemu.h: -------------------------------------------------------------------------------- 1 | #ifndef _FLNEMULATOR_H 2 | #define _FLNEMULATOR_H 3 | 4 | #include "Common.h" 5 | #include "Finalization.h" 6 | #include "Initialization.h" 7 | 8 | #endif //_FLNEMULATOR_H -------------------------------------------------------------------------------- /examples/legacy/MSVC/lfnemu/lfnemu.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiresock/ndisapi/417b8734e844083a10236387fba705d94a2d6bc9/examples/legacy/MSVC/lfnemu/lfnemu.rc -------------------------------------------------------------------------------- /examples/legacy/MSVC/lfnemu/ndisInterfaceLayer.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "ndisInterfaceLayer.h" 3 | 4 | void ndisBottomLayer(PETH_REQUEST pRequest) 5 | { 6 | api.SendPacketToAdapter(pRequest); 7 | free(pRequest->EthPacket.Buffer); 8 | free(pRequest); 9 | } 10 | 11 | void ndisTopLayer(PETH_REQUEST pRequest) 12 | { 13 | api.SendPacketToMstcp(pRequest); 14 | free(pRequest->EthPacket.Buffer); 15 | free(pRequest); 16 | } 17 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/lfnemu/ndisInterfaceLayer.h: -------------------------------------------------------------------------------- 1 | #ifndef _NDISINTERFACELAYER_H 2 | #define _NDISINTERFACELAYER_H 3 | 4 | #include "Common.h" 5 | 6 | // NDIS Lower Layer variables and functions 7 | void ndisBottomLayer(PETH_REQUEST pRequest); 8 | void ndisTopLayer(PETH_REQUEST pRequest); 9 | 10 | #endif //_NDISINTERFACELAYER_H -------------------------------------------------------------------------------- /examples/legacy/MSVC/lfnemu/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by lfnemu.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 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/listadapters/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.cpp */ 8 | /* */ 9 | /* Abstract: source file that includes just the standard includes */ 10 | /* */ 11 | /*************************************************************************/ 12 | 13 | #include "stdafx.h" 14 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/listadapters/StdAfx.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.h */ 8 | /* */ 9 | /* Abstract: include file for standard system include files, */ 10 | /* or project specific include files that are used frequently, but */ 11 | /* are changed infrequently */ 12 | /* */ 13 | /*************************************************************************/ 14 | 15 | #if !defined(AFX_STDAFX_H__95FC7C90_B16C_4D28_94EA_FEBE5E608D6F__INCLUDED_) 16 | #define AFX_STDAFX_H__95FC7C90_B16C_4D28_94EA_FEBE5E608D6F__INCLUDED_ 17 | 18 | #if _MSC_VER > 1000 19 | #pragma once 20 | #endif // _MSC_VER > 1000 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "..\..\..\..\include\common.h" 28 | #include "..\..\..\..\include\ndisapi.h" 29 | 30 | //{{AFX_INSERT_LOCATION}} 31 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 32 | 33 | #endif // !defined(AFX_STDAFX_H__95FC7C90_B16C_4D28_94EA_FEBE5E608D6F__INCLUDED_) 34 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/listadapters/listadapters.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {2630330f-5e8d-4aa7-8970-ac3edad63f4c} 6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat 7 | 8 | 9 | {91efea92-825e-4356-8cba-2d143d7ed690} 10 | h;hpp;hxx;hm;inl 11 | 12 | 13 | {cd4911bd-5cdf-43fc-b098-8e2d430c316c} 14 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/ndisrequest/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.cpp */ 8 | /* */ 9 | /* Abstract: source file that includes just the standard includes */ 10 | /* */ 11 | /*************************************************************************/ 12 | #include "stdafx.h" 13 | 14 | // TODO: reference any additional headers you need in STDAFX.H 15 | // and not in this file 16 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/ndisrequest/StdAfx.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.h */ 8 | /* */ 9 | /* Abstract: include file for standard system include files, */ 10 | /* or project specific include files that are used frequently, but */ 11 | /* are changed infrequently */ 12 | /* */ 13 | /*************************************************************************/ 14 | 15 | #if !defined(AFX_STDAFX_H__5C1BE8DE_CD55_45F0_B27F_8CF89E9FFE21__INCLUDED_) 16 | #define AFX_STDAFX_H__5C1BE8DE_CD55_45F0_B27F_8CF89E9FFE21__INCLUDED_ 17 | 18 | #if _MSC_VER > 1000 19 | #pragma once 20 | #endif // _MSC_VER > 1000 21 | 22 | #ifndef WIN32_LEAN_AND_MEAN 23 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 24 | #endif // WIN32_LEAN_AND_MEAN 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "..\..\..\..\include\common.h" 32 | #include "..\..\..\..\include\ndisapi.h" 33 | 34 | //{{AFX_INSERT_LOCATION}} 35 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 36 | 37 | #endif // !defined(AFX_STDAFX_H__5C1BE8DE_CD55_45F0_B27F_8CF89E9FFE21__INCLUDED_) 38 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/ndisrequest/ndisrequest.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {0524854c-9ef2-4013-a50d-db7c674516de} 6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat 7 | 8 | 9 | {ae0ff05c-ee2f-4d0c-81ec-2c02fd40c7d8} 10 | h;hpp;hxx;hm;inl 11 | 12 | 13 | {557eac6e-b237-4273-87aa-0c2f0c2da481} 14 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/packetsniffer/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.cpp */ 8 | /* */ 9 | /* Abstract: source file that includes just the standard includes */ 10 | /* */ 11 | /*************************************************************************/ 12 | 13 | #include "stdafx.h" 14 | 15 | // TODO: reference any additional headers you need in STDAFX.H 16 | // and not in this file 17 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/packetsniffer/StdAfx.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.h */ 8 | /* */ 9 | /* Abstract: include file for standard system include files, */ 10 | /* or project specific include files that are used frequently, but */ 11 | /* are changed infrequently */ 12 | /* */ 13 | /*************************************************************************/ 14 | 15 | #if !defined(AFX_STDAFX_H__090BD577_3479_4129_82EA_36B3F0A5D7E9__INCLUDED_) 16 | #define AFX_STDAFX_H__090BD577_3479_4129_82EA_36B3F0A5D7E9__INCLUDED_ 17 | 18 | #if _MSC_VER > 1000 19 | #pragma once 20 | #endif // _MSC_VER > 1000 21 | 22 | #ifndef WIN32_LEAN_AND_MEAN 23 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 24 | #endif // WIN32_LEAN_AND_MEAN 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "..\..\..\..\include\common.h" 33 | #include "..\..\..\..\include\ndisapi.h" 34 | #include "iphlp.h" 35 | 36 | //{{AFX_INSERT_LOCATION}} 37 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 38 | 39 | #endif // !defined(AFX_STDAFX_H__090BD577_3479_4129_82EA_36B3F0A5D7E9__INCLUDED_) 40 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/packetsniffer/packetsniffer.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {39727a77-02e6-474e-8d5e-36c618f934e6} 6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat 7 | 8 | 9 | {e025a8bc-8f75-40fd-b9c9-78128e52f83c} 10 | h;hpp;hxx;hm;inl 11 | 12 | 13 | {e350fb76-394f-4928-88ba-d14fae4db01f} 14 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 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 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/packthru/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.cpp */ 8 | /* */ 9 | /* Abstract: source file that includes just the standard includes */ 10 | /* */ 11 | /*************************************************************************/ 12 | 13 | #include "stdafx.h" 14 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/packthru/StdAfx.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.h */ 8 | /* */ 9 | /* Abstract: include file for standard system include files, */ 10 | /* or project specific include files that are used frequently, but */ 11 | /* are changed infrequently */ 12 | /* */ 13 | /*************************************************************************/ 14 | 15 | #if !defined(AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_) 16 | #define AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_ 17 | 18 | #if _MSC_VER > 1000 19 | #pragma once 20 | #endif // _MSC_VER > 1000 21 | 22 | #ifndef WIN32_LEAN_AND_MEAN 23 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 24 | #endif // WIN32_LEAN_AND_MEAN 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "..\..\..\..\include\common.h" 33 | #include "..\..\..\..\include\ndisapi.h" 34 | #include "iphlp.h" 35 | 36 | //{{AFX_INSERT_LOCATION}} 37 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 38 | 39 | #endif // !defined(AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_) 40 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/packthru/packthru.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {fe27ab83-bf1c-4679-9147-a1845a52c37b} 6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat 7 | 8 | 9 | {f3999c5f-3130-4df2-99d2-58e40806c43e} 10 | h;hpp;hxx;hm;inl 11 | 12 | 13 | {be9549a9-4c13-4339-9be8-5b6591420f6f} 14 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 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 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/passthru/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.cpp */ 8 | /* */ 9 | /* Abstract: source file that includes just the standard includes */ 10 | /* */ 11 | /*************************************************************************/ 12 | 13 | #include "stdafx.h" 14 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/passthru/StdAfx.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.h */ 8 | /* */ 9 | /* Abstract: include file for standard system include files, */ 10 | /* or project specific include files that are used frequently, but */ 11 | /* are changed infrequently */ 12 | /* */ 13 | /*************************************************************************/ 14 | 15 | #if !defined(AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_) 16 | #define AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_ 17 | 18 | #if _MSC_VER > 1000 19 | #pragma once 20 | #endif // _MSC_VER > 1000 21 | 22 | #ifndef WIN32_LEAN_AND_MEAN 23 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 24 | #endif // WIN32_LEAN_AND_MEAN 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "..\..\..\..\include\common.h" 33 | #include "..\..\..\..\include\ndisapi.h" 34 | #include "iphlp.h" 35 | 36 | //{{AFX_INSERT_LOCATION}} 37 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 38 | 39 | #endif // !defined(AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_) 40 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/passthru/passthru.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {0dbb96b2-1c5d-461b-a5a5-facf2ca91571} 6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat 7 | 8 | 9 | {10e919ea-4840-4e19-9804-3587ce652b6d} 10 | h;hpp;hxx;hm;inl 11 | 12 | 13 | {0facd835-345a-437e-ba1e-f11ddf190288} 14 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 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 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/snat/NetcardProp.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* Module Name: NetcardProp.h */ 7 | /* */ 8 | /* Abstract: CNetcardProp dialog declarations */ 9 | /* */ 10 | /* */ 11 | /*************************************************************************/ 12 | 13 | #pragma once 14 | #include "NetworkInterface.h" 15 | #include "afxcmn.h" 16 | #include "afxwin.h" 17 | 18 | // CNetcardProp dialog 19 | 20 | class CNetcardProp : public CDialog 21 | { 22 | DECLARE_DYNAMIC(CNetcardProp) 23 | 24 | public: 25 | CNetcardProp(CWnd* pParent = NULL); // standard constructor 26 | virtual ~CNetcardProp(); 27 | 28 | // Dialog Data 29 | enum { IDD = IDD_INTERFACE_PROPERTIES }; 30 | 31 | protected: 32 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 33 | 34 | DECLARE_MESSAGE_MAP() 35 | public: 36 | virtual BOOL OnInitDialog(); 37 | 38 | CNetworkInterface* m_pNetworkInterface; // points to associated CNetworkInterface structure 39 | CListCtrl m_IpList; // control for the list of IP's 40 | CIPAddressCtrl m_NATIp; // control for configuring NAT IP 41 | CComboBox m_NATStatus; // control for setting NAT status for the interface 42 | CIPAddressCtrl m_NatDNS;// control for setting NAT DNS ip address for the interface 43 | CButton m_ClientDNS;// control for setting DNS spoofing status for the interface 44 | 45 | afx_msg void OnCbnSelchangeCombonat(); 46 | afx_msg void OnNMDblclkListIp(NMHDR *pNMHDR, LRESULT *pResult); 47 | afx_msg void OnIpnFieldchangedIpaddress1(NMHDR *pNMHDR, LRESULT *pResult); 48 | afx_msg void OnBnClickedCheck1(); 49 | 50 | 51 | afx_msg void OnBnClickedOk(); 52 | }; 53 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/snat/res/main.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiresock/ndisapi/417b8734e844083a10236387fba705d94a2d6bc9/examples/legacy/MSVC/snat/res/main.ico -------------------------------------------------------------------------------- /examples/legacy/MSVC/snat/res/modem.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiresock/ndisapi/417b8734e844083a10236387fba705d94a2d6bc9/examples/legacy/MSVC/snat/res/modem.ico -------------------------------------------------------------------------------- /examples/legacy/MSVC/snat/res/netcard.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiresock/ndisapi/417b8734e844083a10236387fba705d94a2d6bc9/examples/legacy/MSVC/snat/res/netcard.ico -------------------------------------------------------------------------------- /examples/legacy/MSVC/snat/res/snat.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiresock/ndisapi/417b8734e844083a10236387fba705d94a2d6bc9/examples/legacy/MSVC/snat/res/snat.ico -------------------------------------------------------------------------------- /examples/legacy/MSVC/snat/res/snat.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | Your app description here 10 | 11 | 12 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/snat/res/snat.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // snat.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/legacy/MSVC/snat/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by snat.rc 4 | // 5 | #define IDM_ABOUTBOX 0x0010 6 | #define IDD_ABOUTBOX 100 7 | #define IDS_ABOUTBOX 101 8 | #define IDD_SNAT_DIALOG 102 9 | #define IDR_MAINFRAME 128 10 | #define IDI_NETCARD 129 11 | #define IDI_MODEM 130 12 | #define IDD_INTERFACE_PROPERTIES 131 13 | #define IDC_ADAPTERS 1000 14 | #define IDC_NETCARD 1001 15 | #define IDC_MACADDR 1002 16 | #define IDC_INTNAME 1003 17 | #define IDC_LIST1 1004 18 | #define IDC_LISTIP 1004 19 | #define IDC_IPADDRESSNAT 1005 20 | #define IDC_COMBONAT 1007 21 | #define IDC_BUTTONSTART 1008 22 | #define IDC_STATICIP 1010 23 | #define IDC_CHECK_DNS 1012 24 | #define IDC_IPADDRESSDNS 1014 25 | #define IDC_STATIC_DNS 1015 26 | 27 | // Next default values for new objects 28 | // 29 | #ifdef APSTUDIO_INVOKED 30 | #ifndef APSTUDIO_READONLY_SYMBOLS 31 | #define _APS_NEXT_RESOURCE_VALUE 136 32 | #define _APS_NEXT_COMMAND_VALUE 32771 33 | #define _APS_NEXT_CONTROL_VALUE 1016 34 | #define _APS_NEXT_SYMED_VALUE 101 35 | #endif 36 | #endif 37 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/snat/snat.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* Module Name: snat.cpp */ 7 | /* */ 8 | /* Abstract: Defines the class behaviors for the application */ 9 | /* */ 10 | /* */ 11 | /*************************************************************************/ 12 | 13 | #include "stdafx.h" 14 | #include "snat.h" 15 | #include "snatDlg.h" 16 | 17 | #ifdef _DEBUG 18 | #define new DEBUG_NEW 19 | #endif 20 | 21 | 22 | // CsnatApp 23 | 24 | BEGIN_MESSAGE_MAP(CsnatApp, CWinApp) 25 | ON_COMMAND(ID_HELP, CWinApp::OnHelp) 26 | END_MESSAGE_MAP() 27 | 28 | 29 | // CsnatApp construction 30 | 31 | CsnatApp::CsnatApp() 32 | { 33 | // TODO: add construction code here, 34 | // Place all significant initialization in InitInstance 35 | } 36 | 37 | 38 | // The one and only CsnatApp object 39 | 40 | CsnatApp theApp; 41 | 42 | 43 | // CsnatApp initialization 44 | 45 | BOOL CsnatApp::InitInstance() 46 | { 47 | // InitCommonControls() is required on Windows XP if an application 48 | // manifest specifies use of ComCtl32.dll version 6 or later to enable 49 | // visual styles. Otherwise, any window creation will fail. 50 | InitCommonControls(); 51 | 52 | CWinApp::InitInstance(); 53 | 54 | AfxEnableControlContainer(); 55 | 56 | // Standard initialization 57 | // If you are not using these features and wish to reduce the size 58 | // of your final executable, you should remove from the following 59 | // the specific initialization routines you do not need 60 | // Change the registry key under which our settings are stored 61 | // TODO: You should modify this string to be something appropriate 62 | // such as the name of your company or organization 63 | SetRegistryKey(_T("NT Kernel Resources")); 64 | 65 | CsnatDlg dlg; 66 | m_pMainWnd = &dlg; 67 | INT_PTR nResponse = dlg.DoModal(); 68 | 69 | // Since the dialog has been closed, return FALSE so that we exit the 70 | // application, rather than start the application's message pump. 71 | return FALSE; 72 | } 73 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/snat/snat.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* Module Name: snat.h */ 7 | /* */ 8 | /* Abstract: main header file for the SNAT application */ 9 | /* */ 10 | /* */ 11 | /*************************************************************************/ 12 | 13 | #pragma once 14 | 15 | #ifndef __AFXWIN_H__ 16 | #error include 'stdafx.h' before including this file for PCH 17 | #endif 18 | 19 | #include "resource.h" // main symbols 20 | 21 | 22 | // CsnatApp: 23 | // See snat.cpp for the implementation of this class 24 | // 25 | 26 | class CsnatApp : public CWinApp 27 | { 28 | public: 29 | CsnatApp(); 30 | 31 | // Overrides 32 | public: 33 | virtual BOOL InitInstance(); 34 | 35 | // Implementation 36 | 37 | DECLARE_MESSAGE_MAP() 38 | }; 39 | 40 | extern CsnatApp theApp; -------------------------------------------------------------------------------- /examples/legacy/MSVC/snat/snat.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;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 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 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 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 | 58 | 59 | Resource Files 60 | 61 | 62 | Resource Files 63 | 64 | 65 | Resource Files 66 | 67 | 68 | Resource Files 69 | 70 | 71 | 72 | 73 | Resource Files 74 | 75 | 76 | 77 | 78 | Resource Files 79 | 80 | 81 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/snat/stdafx.cpp: -------------------------------------------------------------------------------- 1 | 2 | // stdafx.cpp : source file that includes just the standard includes 3 | // MFCApplication1.pch will be the pre-compiled header 4 | // stdafx.obj will contain the pre-compiled type information 5 | 6 | #include "stdafx.h" 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/snat/stdafx.h: -------------------------------------------------------------------------------- 1 | 2 | // stdafx.h : include file for standard system include files, 3 | // or project specific include files that are used frequently, 4 | // but are changed infrequently 5 | 6 | #pragma once 7 | 8 | #ifndef VC_EXTRALEAN 9 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 10 | #endif 11 | 12 | #include "targetver.h" 13 | 14 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 15 | 16 | // turns off MFC's hiding of some common and often safely ignored warning messages 17 | #define _AFX_ALL_WARNINGS 18 | 19 | #include // MFC core and standard components 20 | #include // MFC extensions 21 | 22 | 23 | #include // MFC Automation classes 24 | 25 | 26 | 27 | #ifndef _AFX_NO_OLE_SUPPORT 28 | #include // MFC support for Internet Explorer 4 Common Controls 29 | #endif 30 | #ifndef _AFX_NO_AFXCMN_SUPPORT 31 | #include // MFC support for Windows Common Controls 32 | #endif // _AFX_NO_AFXCMN_SUPPORT 33 | 34 | #include // MFC support for ribbons and control bars 35 | 36 | 37 | #include 38 | 39 | #include 40 | 41 | #include "..\..\..\..\include\common.h" 42 | #include "..\..\..\..\include\ndisapi.h" 43 | 44 | #ifdef _UNICODE 45 | #if defined _M_IX86 46 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") 47 | #elif defined _M_X64 48 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") 49 | #else 50 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") 51 | #endif 52 | #endif 53 | 54 | 55 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/snat/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | //#include 9 | 10 | #define _WIN32_WINNT 0x4000 11 | 12 | #include 13 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/wwwcensor/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.cpp */ 8 | /* */ 9 | /* Abstract: source file that includes just the standard includes */ 10 | /* */ 11 | /*************************************************************************/ 12 | 13 | #include "stdafx.h" 14 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/wwwcensor/StdAfx.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2016 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.h */ 8 | /* */ 9 | /* Abstract: include file for standard system include files, */ 10 | /* or project specific include files that are used frequently, but */ 11 | /* are changed infrequently */ 12 | /* */ 13 | /*************************************************************************/ 14 | 15 | #if !defined(AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_) 16 | #define AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_ 17 | 18 | #if _MSC_VER > 1000 19 | #pragma once 20 | #endif // _MSC_VER > 1000 21 | 22 | #ifndef WIN32_LEAN_AND_MEAN 23 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 24 | #endif // WIN32_LEAN_AND_MEAN 25 | 26 | #define _CRT_SECURE_NO_WARNINGS 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include "..\..\..\..\include\common.h" 35 | #include "..\..\..\..\include\ndisapi.h" 36 | #include "iphlp.h" 37 | 38 | //{{AFX_INSERT_LOCATION}} 39 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 40 | 41 | #endif // !defined(AFX_STDAFX_H__8CD24513_169B_47A9_859B_9A99FF8266DA__INCLUDED_) 42 | -------------------------------------------------------------------------------- /examples/legacy/MSVC/wwwcensor/wwwcensor.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {a776016f-b729-452e-8acd-bef74d949601} 6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat 7 | 8 | 9 | {bc987f04-ce8b-4714-b97c-4fc083c4fe95} 10 | h;hpp;hxx;hm;inl 11 | 12 | 13 | {8f8c7378-af83-4964-b208-0c7d25665ca7} 14 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 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 | -------------------------------------------------------------------------------- /ndisapi.dll/ndisapi.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | OpenFilterDriver 3 | CloseFilterDriver 4 | GetDriverVersion 5 | GetTcpipBoundAdaptersInfo 6 | SendPacketToMstcp 7 | SendPacketToAdapter 8 | SendPacketsToMstcp 9 | SendPacketsToAdapter 10 | ReadPacket 11 | ReadPackets 12 | SetAdapterMode 13 | GetAdapterMode 14 | FlushAdapterPacketQueue 15 | GetAdapterPacketQueueSize 16 | SetPacketEvent 17 | SetWANEvent 18 | SetAdapterListChangeEvent 19 | NdisrdRequest 20 | GetRasLinks 21 | SetHwPacketFilter 22 | GetHwPacketFilter 23 | SetHwPacketFilterEvent 24 | SetPacketFilterTable 25 | AddStaticFilterFront 26 | AddStaticFilterBack 27 | InsertStaticFilter 28 | RemoveStaticFilter 29 | ResetPacketFilterTable 30 | GetPacketFilterTableSize 31 | GetPacketFilterTable 32 | GetPacketFilterTableResetStats 33 | EnablePacketFilterCache 34 | DisablePacketFilterCache 35 | EnablePacketFragmentCache 36 | DisablePacketFragmentCache 37 | SetMTUDecrement 38 | GetMTUDecrement 39 | SetAdaptersStartupMode 40 | GetAdaptersStartupMode 41 | SetPoolSize 42 | GetPoolSize 43 | IsDriverLoaded 44 | InitializeFastIo 45 | AddSecondaryFastIo 46 | ReadPacketsUnsorted 47 | SendPacketsToAdaptersUnsorted 48 | SendPacketsToMstcpUnsorted 49 | GetIntermediateBufferPoolSize 50 | GetBytesReturned 51 | IsNdiswanIp 52 | IsNdiswanIpv6 53 | IsNdiswanBh 54 | ConvertWindowsNTAdapterName 55 | ConvertWindows2000AdapterName 56 | ConvertWindows9xAdapterName 57 | RecalculateIPChecksum 58 | RecalculateICMPChecksum 59 | RecalculateTCPChecksum 60 | RecalculateUDPChecksum -------------------------------------------------------------------------------- /ndisapi.dll/ndisapidll.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 | Source Files 25 | 26 | 27 | 28 | 29 | Header Files 30 | 31 | 32 | Header Files 33 | 34 | 35 | Header Files 36 | 37 | 38 | Header Files 39 | 40 | 41 | Header Files 42 | 43 | 44 | 45 | 46 | Resource Files 47 | 48 | 49 | -------------------------------------------------------------------------------- /ndisapi.lib/ndisapilib.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 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | 35 | 36 | Source Files 37 | 38 | 39 | 40 | 41 | Resource Files 42 | 43 | 44 | -------------------------------------------------------------------------------- /ndisapi.net/AssemblyInfo.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | using namespace System; 4 | using namespace System::Reflection; 5 | using namespace System::Runtime::CompilerServices; 6 | using namespace System::Runtime::InteropServices; 7 | using namespace System::Security::Permissions; 8 | 9 | // 10 | // General Information about an assembly is controlled through the following 11 | // set of attributes. Change these attribute values to modify the information 12 | // associated with an assembly. 13 | // 14 | [assembly:AssemblyTitleAttribute(L"ndisapicl")]; 15 | [assembly:AssemblyDescriptionAttribute(L"")]; 16 | [assembly:AssemblyConfigurationAttribute(L"")]; 17 | [assembly:AssemblyCompanyAttribute(L"NT KERNEL")]; 18 | [assembly:AssemblyProductAttribute(L"ndisapicl")]; 19 | [assembly:AssemblyCopyrightAttribute(L"Copyright (c) NT KERNEL 2000-2024")]; 20 | [assembly:AssemblyTrademarkAttribute(L"")]; 21 | [assembly:AssemblyCultureAttribute(L"")]; 22 | 23 | // 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the value, or you can default the Revision and Build Numbers 32 | // by using the '*' as shown below: 33 | 34 | [assembly:AssemblyVersionAttribute("3.6.1.1")]; 35 | 36 | [assembly:ComVisible(false)]; 37 | 38 | [assembly:CLSCompliantAttribute(true)]; -------------------------------------------------------------------------------- /ndisapi.net/Stdafx.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2018 NT Kernel Resources. */ 3 | /* All Rights Reserved. */ 4 | /* http://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: stdafx.h */ 8 | /* */ 9 | /* Abstract: include file for standard system include files, */ 10 | /* or project specific include files that are used frequently, */ 11 | /* but are changed infrequently */ 12 | /* */ 13 | /* Environment: */ 14 | /* .NET User mode */ 15 | /* */ 16 | /*************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #include "ndisapicl.h" 32 | #include "../include/common.h" 33 | #include "../include/ndisapi.h" 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ndisapi.net/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiresock/ndisapi/417b8734e844083a10236387fba705d94a2d6bc9/ndisapi.net/app.ico -------------------------------------------------------------------------------- /ndisapi.net/app.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiresock/ndisapi/417b8734e844083a10236387fba705d94a2d6bc9/ndisapi.net/app.rc -------------------------------------------------------------------------------- /ndisapi.net/ndisapicl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiresock/ndisapi/417b8734e844083a10236387fba705d94a2d6bc9/ndisapi.net/ndisapicl.h -------------------------------------------------------------------------------- /ndisapi.net/ndisapicl.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 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | Source Files 46 | 47 | 48 | 49 | 50 | Resource Files 51 | 52 | 53 | Resource Files 54 | 55 | 56 | 57 | 58 | Resource Files 59 | 60 | 61 | -------------------------------------------------------------------------------- /ndisapi.net/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by app.rc 4 | -------------------------------------------------------------------------------- /ndisapi.vc6/ndisapi.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | OpenFilterDriver 3 | CloseFilterDriver 4 | GetDriverVersion 5 | GetTcpipBoundAdaptersInfo 6 | SendPacketToMstcp 7 | SendPacketToAdapter 8 | SendPacketsToMstcp 9 | SendPacketsToAdapter 10 | ReadPacket 11 | ReadPackets 12 | SetAdapterMode 13 | GetAdapterMode 14 | FlushAdapterPacketQueue 15 | GetAdapterPacketQueueSize 16 | SetPacketEvent 17 | SetWANEvent 18 | SetAdapterListChangeEvent 19 | NdisrdRequest 20 | GetRasLinks 21 | SetHwPacketFilter 22 | GetHwPacketFilter 23 | SetHwPacketFilterEvent 24 | SetPacketFilterTable 25 | AddStaticFilterFront 26 | AddStaticFilterBack 27 | InsertStaticFilter 28 | RemoveStaticFilter 29 | ResetPacketFilterTable 30 | GetPacketFilterTableSize 31 | GetPacketFilterTable 32 | GetPacketFilterTableResetStats 33 | EnablePacketFilterCache 34 | DisablePacketFilterCache 35 | EnablePacketFragmentCache 36 | DisablePacketFragmentCache 37 | SetMTUDecrement 38 | GetMTUDecrement 39 | SetAdaptersStartupMode 40 | GetAdaptersStartupMode 41 | SetPoolSize 42 | GetPoolSize 43 | IsDriverLoaded 44 | InitializeFastIo 45 | AddSecondaryFastIo 46 | ReadPacketsUnsorted 47 | SendPacketsToAdaptersUnsorted 48 | SendPacketsToMstcpUnsorted 49 | GetIntermediateBufferPoolSize 50 | GetBytesReturned 51 | IsNdiswanIp 52 | IsNdiswanIpv6 53 | IsNdiswanBh 54 | ConvertWindowsNTAdapterName 55 | ConvertWindows2000AdapterName 56 | ConvertWindows9xAdapterName 57 | RecalculateIPChecksum 58 | RecalculateICMPChecksum 59 | RecalculateTCPChecksum 60 | RecalculateUDPChecksum -------------------------------------------------------------------------------- /ndisapi.vs2012/ndisapi.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | OpenFilterDriver 3 | CloseFilterDriver 4 | GetDriverVersion 5 | GetTcpipBoundAdaptersInfo 6 | SendPacketToMstcp 7 | SendPacketToAdapter 8 | SendPacketsToMstcp 9 | SendPacketsToAdapter 10 | ReadPacket 11 | ReadPackets 12 | SetAdapterMode 13 | GetAdapterMode 14 | FlushAdapterPacketQueue 15 | GetAdapterPacketQueueSize 16 | SetPacketEvent 17 | SetWANEvent 18 | SetAdapterListChangeEvent 19 | NdisrdRequest 20 | GetRasLinks 21 | SetHwPacketFilter 22 | GetHwPacketFilter 23 | SetHwPacketFilterEvent 24 | SetPacketFilterTable 25 | AddStaticFilterFront 26 | AddStaticFilterBack 27 | InsertStaticFilter 28 | RemoveStaticFilter 29 | ResetPacketFilterTable 30 | GetPacketFilterTableSize 31 | GetPacketFilterTable 32 | GetPacketFilterTableResetStats 33 | EnablePacketFilterCache 34 | DisablePacketFilterCache 35 | EnablePacketFragmentCache 36 | DisablePacketFragmentCache 37 | SetMTUDecrement 38 | GetMTUDecrement 39 | SetAdaptersStartupMode 40 | GetAdaptersStartupMode 41 | SetPoolSize 42 | GetPoolSize 43 | IsDriverLoaded 44 | InitializeFastIo 45 | AddSecondaryFastIo 46 | ReadPacketsUnsorted 47 | SendPacketsToAdaptersUnsorted 48 | SendPacketsToMstcpUnsorted 49 | GetIntermediateBufferPoolSize 50 | GetBytesReturned 51 | IsNdiswanIp 52 | IsNdiswanIpv6 53 | IsNdiswanBh 54 | ConvertWindowsNTAdapterName 55 | ConvertWindows2000AdapterName 56 | ConvertWindows9xAdapterName 57 | RecalculateIPChecksum 58 | RecalculateICMPChecksum 59 | RecalculateTCPChecksum 60 | RecalculateUDPChecksum -------------------------------------------------------------------------------- /ndisapi.vs2012/ndisapi.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 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | 35 | 36 | Source Files 37 | 38 | 39 | 40 | 41 | Resource Files 42 | 43 | 44 | 45 | 46 | Source Files 47 | 48 | 49 | -------------------------------------------------------------------------------- /ndisapi/ndisapi.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wiresock/ndisapi/417b8734e844083a10236387fba705d94a2d6bc9/ndisapi/ndisapi.rc -------------------------------------------------------------------------------- /ndisapi/precomp.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* Copyright (c) 2000-2024 NT KERNEL. */ 3 | /* All Rights Reserved. */ 4 | /* https://www.ntkernel.com */ 5 | /* ndisrd@ntkernel.com */ 6 | /* */ 7 | /* Module Name: precomp.h */ 8 | /* */ 9 | /* Description: Cumulative include header */ 10 | /* */ 11 | /* Environment: */ 12 | /* User mode */ 13 | /* */ 14 | /*************************************************************************/ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #ifdef CYGWIN_BUILD 26 | #include // For strcasecmp 27 | #include // For strcpy, strcat 28 | #include // For wcscpy, wcscat 29 | #define _stricmp strcasecmp 30 | #ifdef UNICODE 31 | // Define _tcscpy, etc. for Unicode under non-Windows 32 | #define _tcscpy wcscpy 33 | #define _tcscat wcscat 34 | #define TCHAR wchar_t 35 | // ... other wide character (wchar_t) functions as needed ... 36 | #else 37 | // Define _tcscpy, etc. for non-Unicode under non-Windows 38 | #define _tcscpy strcpy 39 | #define _tcscat strcat 40 | // ... other single-byte (char) functions as needed ... 41 | #endif // UNICODE 42 | #endif // CYGWIN_BUILD 43 | 44 | #include "../include/common.h" 45 | #include "../include/ndisapi.h" 46 | #include "iphlp.h" 47 | -------------------------------------------------------------------------------- /ndisapi/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by ndisapi.rc 4 | // 5 | 6 | // Next default values for new objects 7 | // 8 | #ifdef APSTUDIO_INVOKED 9 | #ifndef APSTUDIO_READONLY_SYMBOLS 10 | #define _APS_NEXT_RESOURCE_VALUE 101 11 | #define _APS_NEXT_COMMAND_VALUE 40001 12 | #define _APS_NEXT_CONTROL_VALUE 1001 13 | #define _APS_NEXT_SYMED_VALUE 101 14 | #endif 15 | #endif 16 | --------------------------------------------------------------------------------