A:增加日志输出

This commit is contained in:
jimmy committed 2025-05-30 20:44:10 +08:00
1 parent a6f32164f6
commit e2f0d78d97
6 files changed
+64 -44

No files matched your search

+6
View File
@@ -16,6 +16,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Test", "Common.Test\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Wpf", "Common.Wpf\Common.Wpf.csproj", "{293477FA-3C1C-429F-9FBA-AD16A3E402BC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Net", "Common.Net\Common.Net.csproj", "{AEE55360-757E-4B63-9478-2F201B95266A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -54,5 +56,9 @@ Global
{293477FA-3C1C-429F-9FBA-AD16A3E402BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{293477FA-3C1C-429F-9FBA-AD16A3E402BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{293477FA-3C1C-429F-9FBA-AD16A3E402BC}.Release|Any CPU.Build.0 = Release|Any CPU
{AEE55360-757E-4B63-9478-2F201B95266A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AEE55360-757E-4B63-9478-2F201B95266A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AEE55360-757E-4B63-9478-2F201B95266A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AEE55360-757E-4B63-9478-2F201B95266A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
+5
View File
@@ -1,13 +1,18 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AApplication_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6412d4331611499aab4eb63809a2a83bf60910_003Fd6_003F8ef46f2c_003FApplication_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AArray_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F211e6f3b24fa438a92f1815153647ce2c8f908_003Fc8_003F8670d075_003FArray_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADefaultInterpolatedStringHandler_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F211e6f3b24fa438a92f1815153647ce2c8f908_003Fe4_003Fdb4307f5_003FDefaultInterpolatedStringHandler_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFileVersionInfo_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F7fad91e527c1434bb313ddbc78144605b8a0_003F3f_003F911bc64d_003FFileVersionInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFile_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F211e6f3b24fa438a92f1815153647ce2c8f908_003F71_003F40854420_003FFile_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIWebSocketConnection_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa7d96aff8e344c1d9aa8042f229d493cae00_003Fc1_003Fb154f2eb_003FIWebSocketConnection_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AKernelTraceEventParser_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F25b12134b1124ffbab73641db2e54e5b310830_003F24_003Fd19d02f2_003FKernelTraceEventParser_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ALazy_00601_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F211e6f3b24fa438a92f1815153647ce2c8f908_003F74_003F173162e6_003FLazy_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ALogger_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F59d0b425a1244469855c0039f03f864c27e00_003F43_003F8a29b095_003FLogger_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMonitor_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F211e6f3b24fa438a92f1815153647ce2c8f908_003Fb5_003F0c446809_003FMonitor_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANetworkInterface_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F9c72a65889eb40ae9d8e0f130d1572e0268a0_003F34_003F49f5e6ff_003FNetworkInterface_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AProcess_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F4a26a752ec6249c4a090905d31c0cdfa528a0_003F8f_003F7037e590_003FProcess_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AReadOnlyCollectionBase_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F4c1fd115dbe5414db1b4da1de3e96c5819910_003F04_003Fcae9fe22_003FReadOnlyCollectionBase_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AString_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F211e6f3b24fa438a92f1815153647ce2c8f908_003Ff1_003F7b5a67e3_003FString_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATimer_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F211e6f3b24fa438a92f1815153647ce2c8f908_003Fa8_003F04476824_003FTimer_002Ecs_002Fz_003A2_002D1/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATimer_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Ffe2ae574758f4da99bb3bfcba69a0a40b6928_003F7f_003Fb5cb1e21_003FTimer_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AWebView2_002Ecs_002Fl_003AC_0021_003FUsers_003Fcharlatans_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F8aca2f2c90e1454c825fc8b69c53a97e14268_003F06_003F22dc0e77_003FWebView2_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
+9 -8
View File
@@ -1,4 +1,5 @@
using System.Text;
using Common.Logger;
using WinDivertNet.WinDivertWrapper;
namespace WinDivertNet;
@@ -7,7 +8,7 @@ class Program
{
static void Main(string[] args)
{
Console.WriteLine("WinDivert 捕获启动...");
Log.Information("WinDivert 捕获启动...");
PacketSniffer.Start();
}
@@ -20,7 +21,7 @@ class Program
var checkResult = controller.CheckFilter("tcp.DstPort == 80");
if (!checkResult.IsValid)
{
Console.WriteLine($"过滤器语法错误: {checkResult.ErrorMessage}");
Log.Information($"过滤器语法错误: {checkResult.ErrorMessage}");
return;
}
@@ -34,12 +35,12 @@ class Program
if (!success)
{
Console.WriteLine("打开 WinDivert 失败!");
Log.Information("打开 WinDivert 失败!");
return;
}
Console.WriteLine("开始监听 HTTP 流量...");
Console.WriteLine("按 ESC 键退出");
Log.Information("开始监听 HTTP 流量...");
Log.Information("按 ESC 键退出");
// 设置队列长度
controller.SetParam(WinDivert.WINDIVERT_PARAM_QUEUE_LENGTH, 8192);
@@ -66,14 +67,14 @@ class Program
ushort srcPort = headers.TcpHeader.SrcPort;
ushort dstPort = headers.TcpHeader.DstPort;
Console.WriteLine($"捕获到 TCP 数据包: {srcIp}:{srcPort} -> {dstIp}:{dstPort}");
Log.Information($"捕获到 TCP 数据包: {srcIp}:{srcPort} -> {dstIp}:{dstPort}");
// 如果有数据,则尝试输出前 100 个字节
if (headers.Data != null && headers.DataLength > 0)
{
int len = (int)Math.Min(headers.DataLength, 100);
string data = Encoding.ASCII.GetString(headers.Data, 0, len);
Console.WriteLine($"数据内容: {data}");
Log.Information($"数据内容: {data}");
}
}
}
@@ -91,7 +92,7 @@ class Program
// 关闭 WinDivert
controller.Close();
Console.WriteLine("监听结束!");
Log.Information("监听结束!");
}
}
}
+4
View File
@@ -12,4 +12,8 @@
<None Remove="WinDivert\WinDivert64.sys" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj" />
</ItemGroup>
</Project>
+36 -34
View File
@@ -1,3 +1,5 @@
using Common.Logger;
namespace WinDivertNet.WinDivertWrapper;
using System;
@@ -7,7 +9,7 @@ public static class PacketSniffer
{
public static void Start1()
{
Console.WriteLine($"进入 12313 ");
Log.Information($"进入 12313 ");
var handle = WinDivert.Open("true", WinDivert.WINDIVERT_LAYER_NETWORK, 0, WinDivert.WINDIVERT_FLAG_SNIFF);
byte[] buffer = new byte[65535];
@@ -25,13 +27,13 @@ public static class PacketSniffer
}
catch (Exception ex)
{
Console.WriteLine($"接收数据包时出错: {ex.Message}");
Log.Information($"接收数据包时出错: {ex.Message}");
}
}
void ParsePacketAndLog(byte[] buffer, uint length, WinDivert.WINDIVERT_ADDRESS addr)
{
Console.WriteLine($"length: {length}");
Log.Information($"length: {length}");
if (buffer == null || length == 0)
return;
@@ -55,7 +57,7 @@ public static class PacketSniffer
string srcIpStr = $"{buffer[12]}.{buffer[13]}.{buffer[14]}.{buffer[15]}";
string dstIpStr = $"{buffer[16]}.{buffer[17]}.{buffer[18]}.{buffer[19]}";
Console.WriteLine($"IPv4: Src={srcIpStr}, Dst={dstIpStr}, Protocol={protocol}");
Log.Information($"IPv4: Src={srcIpStr}, Dst={dstIpStr}, Protocol={protocol}");
// 如果有足够的数据,解析 TCP 或 UDP
if (length >= (uint)(headerLength + 4) && (protocol == 6 || protocol == 17))
@@ -67,11 +69,11 @@ public static class PacketSniffer
if (protocol == 6) // TCP
{
Console.WriteLine($"TCP: SrcPort={srcPort}, DstPort={dstPort}");
Log.Information($"TCP: SrcPort={srcPort}, DstPort={dstPort}");
}
else if (protocol == 17) // UDP
{
Console.WriteLine($"UDP: SrcPort={srcPort}, DstPort={dstPort}");
Log.Information($"UDP: SrcPort={srcPort}, DstPort={dstPort}");
}
}
}
@@ -84,14 +86,14 @@ public static class PacketSniffer
}
catch (Exception ex)
{
Console.WriteLine($"解析数据包时出错: {ex.Message}");
Log.Information($"解析数据包时出错: {ex.Message}");
}
}
}
public static void Start()
{
Console.WriteLine("WinDivert调试工具启动...");
Log.Information("WinDivert调试工具启动...");
// 检查是否以管理员身份运行
bool isAdmin = new System.Security.Principal.WindowsPrincipal(
@@ -100,12 +102,12 @@ public static class PacketSniffer
if (!isAdmin)
{
Console.WriteLine("错误: 此程序需要管理员权限才能使用WinDivert!");
Console.WriteLine("请右键点击程序,选择'以管理员身份运行'然后重试。");
Log.Information("错误: 此程序需要管理员权限才能使用WinDivert!");
Log.Information("请右键点击程序,选择'以管理员身份运行'然后重试。");
return;
}
Console.WriteLine("步骤1: 尝试打开WinDivert...");
Log.Information("步骤1: 尝试打开WinDivert...");
// 最简单的过滤器
string filter = "true";
@@ -116,15 +118,15 @@ public static class PacketSniffer
if (handle == IntPtr.Zero)
{
int errorCode = Marshal.GetLastWin32Error();
Console.WriteLine($"错误: 无法打开WinDivert,错误码: {errorCode}");
Log.Information($"错误: 无法打开WinDivert,错误码: {errorCode}");
PrintWin32Error(errorCode);
return;
}
Console.WriteLine("成功: WinDivert句柄已打开");
Log.Information("成功: WinDivert句柄已打开");
// 尝试接收一个数据包
Console.WriteLine("\n步骤2: 尝试接收数据包...");
Log.Information("\n步骤2: 尝试接收数据包...");
// 为数据包分配缓冲区
byte[] buffer = new byte[65535]; // 最大以太网帧大小
@@ -139,52 +141,52 @@ public static class PacketSniffer
uint readLen = 0;
// 尝试直接使用基本的Recv函数
Console.WriteLine("尝试WinDivertRecv...");
Log.Information("尝试WinDivertRecv...");
bool recvResult = WinDivert.WinDivertRecv(handle, buffer, (uint)buffer.Length, ref addr, ref readLen);
if (!recvResult)
{
int errorCode = Marshal.GetLastWin32Error();
Console.WriteLine($"错误: WinDivertRecv失败,错误码: {errorCode}");
Log.Information($"错误: WinDivertRecv失败,错误码: {errorCode}");
PrintWin32Error(errorCode);
}
else
{
Console.WriteLine($"成功: 接收到数据包,大小: {readLen} 字节");
Log.Information($"成功: 接收到数据包,大小: {readLen} 字节");
// 打印数据包的前16个字节
string hexData = BitConverter.ToString(buffer, 0, Math.Min((int)readLen, 16));
Console.WriteLine($"数据包前16字节: {hexData}");
Log.Information($"数据包前16字节: {hexData}");
}
// 重置并尝试使用Ex版本
readLen = 0;
addr = new WinDivert.WINDIVERT_ADDRESS { Reserved = new byte[8] };
Console.WriteLine("\n尝试WinDivertRecvEx...");
Log.Information("\n尝试WinDivertRecvEx...");
bool recvExResult =
WinDivert.WinDivertRecvEx(handle, buffer, (uint)buffer.Length, 0, ref addr, ref readLen, IntPtr.Zero);
if (!recvExResult)
{
int errorCode = Marshal.GetLastWin32Error();
Console.WriteLine($"错误: WinDivertRecvEx失败,错误码: {errorCode}");
Log.Information($"错误: WinDivertRecvEx失败,错误码: {errorCode}");
PrintWin32Error(errorCode);
}
else
{
Console.WriteLine($"成功: 接收到数据包,大小: {readLen} 字节");
Log.Information($"成功: 接收到数据包,大小: {readLen} 字节");
// 打印数据包的前16个字节
string hexData = BitConverter.ToString(buffer, 0, Math.Min((int)readLen, 16));
Console.WriteLine($"数据包前16字节: {hexData}");
Log.Information($"数据包前16字节: {hexData}");
}
// 最后关闭句柄
WinDivert.WinDivertClose(handle);
Console.WriteLine("\nWinDivert句柄已关闭");
Log.Information("\nWinDivert句柄已关闭");
Console.WriteLine("\n调试信息收集完成。请检查以上输出以确定问题所在。");
Log.Information("\n调试信息收集完成。请检查以上输出以确定问题所在。");
}
// 辅助函数:打印Win32错误信息
@@ -193,34 +195,34 @@ public static class PacketSniffer
switch (errorCode)
{
case 5:
Console.WriteLine("访问被拒绝。请确认程序以管理员权限运行。");
Log.Information("访问被拒绝。请确认程序以管理员权限运行。");
break;
case 87:
Console.WriteLine("参数错误。过滤器语法可能不正确。");
Log.Information("参数错误。过滤器语法可能不正确。");
break;
case 123:
Console.WriteLine("文件名、目录名或卷标语法不正确。请检查WinDivert.dll是否位于正确的路径。");
Log.Information("文件名、目录名或卷标语法不正确。请检查WinDivert.dll是否位于正确的路径。");
break;
case 126:
Console.WriteLine("找不到指定的模块。无法找到WinDivert.dll文件。");
Log.Information("找不到指定的模块。无法找到WinDivert.dll文件。");
break;
case 193:
Console.WriteLine("不是有效的Win32应用程序。WinDivert.dll可能是错误的版本(32位/64位)。");
Log.Information("不是有效的Win32应用程序。WinDivert.dll可能是错误的版本(32位/64位)。");
break;
case 997:
Console.WriteLine("正在进行重叠操作。WinDivert可能需要异步调用。");
Log.Information("正在进行重叠操作。WinDivert可能需要异步调用。");
break;
case 995:
Console.WriteLine("由于线程退出或应用程序请求,已中止I/O操作。");
Log.Information("由于线程退出或应用程序请求,已中止I/O操作。");
break;
case 998:
Console.WriteLine("无效访问WinDivert。请检查是否有另一个进程正在使用相同的过滤器。");
Log.Information("无效访问WinDivert。请检查是否有另一个进程正在使用相同的过滤器。");
break;
case 1450:
Console.WriteLine("系统资源不足,无法完成请求的服务。");
Log.Information("系统资源不足,无法完成请求的服务。");
break;
default:
Console.WriteLine($"未知错误。Windows错误码: {errorCode}");
Log.Information($"未知错误。Windows错误码: {errorCode}");
break;
}
}
@@ -1,3 +1,5 @@
using Common.Logger;
namespace WinDivertNet.WinDivertWrapper;
using System;
@@ -56,7 +58,7 @@ public class WinDivertController : IDisposable
if (_handle == IntPtr.Zero)
{
int errorCode = Marshal.GetLastWin32Error();
Console.WriteLine($"WinDivert打开失败,错误码: {errorCode}");
Log.Information($"WinDivert打开失败,错误码: {errorCode}");
}
return IsValid;
@@ -102,7 +104,7 @@ public class WinDivertController : IDisposable
uint readLen = 0;
if (WinDivert.Recv(_handle, buffer, (uint)buffer.Length, ref addr, ref readLen))
{
Console.WriteLine($"Receive: {readLen}");
Log.Information($"Receive: {readLen}");
return readLen;
}