├── Tdx ├── XTdi.cpp ├── main.cpp ├── precomp.h ├── XKWinUndef.h ├── Tdx.vcxproj.filters ├── XTdi.h └── Tdx.vcxproj ├── .vs └── Tdx │ └── v14 │ └── .suo ├── README.md ├── .gitattributes ├── .gitignore └── Tdx.sln /Tdx/XTdi.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuhuibeishadiao/Tdx/HEAD/Tdx/XTdi.cpp -------------------------------------------------------------------------------- /Tdx/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuhuibeishadiao/Tdx/HEAD/Tdx/main.cpp -------------------------------------------------------------------------------- /Tdx/precomp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuhuibeishadiao/Tdx/HEAD/Tdx/precomp.h -------------------------------------------------------------------------------- /.vs/Tdx/v14/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuhuibeishadiao/Tdx/HEAD/.vs/Tdx/v14/.suo -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 稳定Tdx网络过滤框架 2 | 支持xp ~ win10 x86 x64 3 | 4 | 如果遇到无法解释的符号 添加tdi.lib即可 5 | -------------------------------------------------------------------------------- /Tdx/XKWinUndef.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhuhuibeishadiao/Tdx/HEAD/Tdx/XKWinUndef.h -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /Tdx/Tdx.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;mfcribbon-ms 15 | 16 | 17 | {8E41214B-6785-4CFE-B992-037D68949A14} 18 | inf;inv;inx;mof;mc; 19 | 20 | 21 | 22 | 23 | Source Files 24 | 25 | 26 | Source Files 27 | 28 | 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | -------------------------------------------------------------------------------- /Tdx.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25123.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tdx", "Tdx\Tdx.vcxproj", "{6E661E23-2B0C-40B0-9A8D-4DA47D77A206}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|ARM = Debug|ARM 11 | Debug|ARM64 = Debug|ARM64 12 | Debug|x64 = Debug|x64 13 | Debug|x86 = Debug|x86 14 | Release|ARM = Release|ARM 15 | Release|ARM64 = Release|ARM64 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Debug|ARM.ActiveCfg = Debug|ARM 21 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Debug|ARM.Build.0 = Debug|ARM 22 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Debug|ARM.Deploy.0 = Debug|ARM 23 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Debug|ARM64.ActiveCfg = Debug|ARM64 24 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Debug|ARM64.Build.0 = Debug|ARM64 25 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Debug|ARM64.Deploy.0 = Debug|ARM64 26 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Debug|x64.ActiveCfg = Debug|x64 27 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Debug|x64.Build.0 = Debug|x64 28 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Debug|x64.Deploy.0 = Debug|x64 29 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Debug|x86.ActiveCfg = Debug|Win32 30 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Debug|x86.Build.0 = Debug|Win32 31 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Debug|x86.Deploy.0 = Debug|Win32 32 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Release|ARM.ActiveCfg = Release|ARM 33 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Release|ARM.Build.0 = Release|ARM 34 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Release|ARM.Deploy.0 = Release|ARM 35 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Release|ARM64.ActiveCfg = Release|ARM64 36 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Release|ARM64.Build.0 = Release|ARM64 37 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Release|ARM64.Deploy.0 = Release|ARM64 38 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Release|x64.ActiveCfg = Release|x64 39 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Release|x64.Build.0 = Release|x64 40 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Release|x64.Deploy.0 = Release|x64 41 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Release|x86.ActiveCfg = Release|Win32 42 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Release|x86.Build.0 = Release|Win32 43 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206}.Release|x86.Deploy.0 = Release|Win32 44 | EndGlobalSection 45 | GlobalSection(SolutionProperties) = preSolution 46 | HideSolutionNode = FALSE 47 | EndGlobalSection 48 | EndGlobal 49 | -------------------------------------------------------------------------------- /Tdx/XTdi.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef XTDI_HEAD_DEIFNE_ 3 | #define XTDI_HEAD_DEIFNE_ 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | #include 10 | 11 | #define XTDI_PROTO_TCP 6 12 | #define XTDI_PROTO_UDP 17 13 | 14 | #define x_alloc(isize) ExAllocatePool(NonPagedPool, isize) 15 | #define x_free(pdata) ExFreePool(pdata) 16 | #define x_alloc_tag(isize, utag) ExAllocatePoolWithTag(NonPagedPool, isize, utag) 17 | #define x_free_tag(pdata, utag) ExFreePoolWithTag(pdata, utag) 18 | 19 | 20 | NTSTATUS tdi_event_receive_datagram( 21 | IN PVOID TdiEventContext, 22 | IN LONG SourceAddressLength, 23 | IN PVOID SourceAddress, 24 | IN LONG OptionsLength, 25 | IN PVOID Options, 26 | IN ULONG ReceiveDatagramFlags, 27 | IN ULONG BytesIndicated, 28 | IN ULONG BytesAvailable, 29 | OUT ULONG *BytesTaken, 30 | IN PVOID Tsdu, 31 | OUT PIRP *IoRequestPacket); 32 | NTSTATUS tdi_event_receive( 33 | __in_opt PVOID TdiEventContext, 34 | __in_opt CONNECTION_CONTEXT ConnectionContext, 35 | __in ULONG ReceiveFlags, 36 | __in ULONG BytesIndicated, 37 | __in ULONG BytesAvailable, 38 | __out ULONG *BytesTaken, 39 | __in PVOID Tsdu, // pointer describing this TSDU, typically a lump of bytes 40 | __out_opt PIRP *IoRequestPacket // TdiReceive IRP if MORE_PROCESSING_REQUIRED. 41 | ); 42 | 43 | typedef struct _xt_tdi 44 | { 45 | PDRIVER_OBJECT drvobj; 46 | PDEVICE_OBJECT drvobj_tcp; // TCP Filter 47 | PDEVICE_OBJECT drvobj_udp; // UDP Filter 48 | PDEVICE_OBJECT drvobj_ioctrl; // User Program Used 49 | } xt_tdi, *pxt_tdi; 50 | 51 | typedef struct _xt_devext 52 | { 53 | PDEVICE_OBJECT lower_device; 54 | CHAR protocol; // TCP=6 or UDP=17 55 | }xt_devext, *pxt_devext; 56 | 57 | extern xt_tdi g_xttdi; 58 | 59 | extern NTSTATUS xtdi_init(PDRIVER_OBJECT drvobj); 60 | extern NTSTATUS xtdi_deinit(); 61 | 62 | extern NTSTATUS xtdi_hook_tcp(); 63 | extern NTSTATUS xtdi_unhook_tcp(); 64 | extern NTSTATUS xtdi_hook_udp(); 65 | extern NTSTATUS xtdi_unhook_udp(); 66 | 67 | extern BOOLEAN xtdi_hookcheck_tcp(); 68 | extern BOOLEAN xtdi_hookcheck_udp(); 69 | 70 | 71 | extern NTSTATUS xtdi_dispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp); 72 | 73 | 74 | typedef enum WIN_VER_DETAIL { 75 | WINDOWS_VERSION_NONE, 76 | WINDOWS_VERSION_2K, 77 | WINDOWS_VERSION_XP, 78 | WINDOWS_VERSION_XP_64, 79 | WINDOWS_VERSION_2K3, 80 | WINDOWS_VERSION_2K3_SP1_SP2, 81 | WINDOWS_VERSION_VISTA, 82 | WINDOWS_VERSION_WIN7, 83 | WINDOWS_VERSION_WIN7_64 84 | } WIN_VER_DETAIL; 85 | extern WIN_VER_DETAIL g_osver; 86 | extern WIN_VER_DETAIL GetWindowsVersion(); 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /Tdx/Tdx.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | Debug 22 | ARM 23 | 24 | 25 | Release 26 | ARM 27 | 28 | 29 | Debug 30 | ARM64 31 | 32 | 33 | Release 34 | ARM64 35 | 36 | 37 | 38 | {6E661E23-2B0C-40B0-9A8D-4DA47D77A206} 39 | {dd38f7fc-d7bd-488b-9242-7d8754cde80d} 40 | v4.5 41 | 12.0 42 | Debug 43 | Win32 44 | Tdx 45 | 46 | 47 | 48 | Windows7 49 | true 50 | WindowsKernelModeDriver10.0 51 | Driver 52 | WDM 53 | 54 | 55 | Windows10 56 | false 57 | WindowsKernelModeDriver10.0 58 | Driver 59 | WDM 60 | 61 | 62 | Windows7 63 | true 64 | WindowsKernelModeDriver10.0 65 | Driver 66 | WDM 67 | 68 | 69 | Windows10 70 | false 71 | WindowsKernelModeDriver10.0 72 | Driver 73 | WDM 74 | 75 | 76 | Windows10 77 | true 78 | WindowsKernelModeDriver10.0 79 | Driver 80 | WDM 81 | 82 | 83 | Windows10 84 | false 85 | WindowsKernelModeDriver10.0 86 | Driver 87 | WDM 88 | 89 | 90 | Windows10 91 | true 92 | WindowsKernelModeDriver10.0 93 | Driver 94 | WDM 95 | 96 | 97 | Windows10 98 | false 99 | WindowsKernelModeDriver10.0 100 | Driver 101 | WDM 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | DbgengKernelDebugger 113 | 114 | 115 | DbgengKernelDebugger 116 | 117 | 118 | DbgengKernelDebugger 119 | 120 | 121 | DbgengKernelDebugger 122 | 123 | 124 | DbgengKernelDebugger 125 | 126 | 127 | DbgengKernelDebugger 128 | 129 | 130 | DbgengKernelDebugger 131 | 132 | 133 | DbgengKernelDebugger 134 | 135 | 136 | 137 | false 138 | 139 | 140 | 141 | 142 | false 143 | 144 | 145 | tdi.lib;%(AdditionalDependencies) 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | --------------------------------------------------------------------------------