增加驱动异常日志
This commit is contained in:
parent
38a20863a6
commit
f2b248f18d
@ -5,6 +5,7 @@ using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@ -62,6 +63,7 @@ namespace FastGithub.PacketIntercept.Dns
|
||||
var handle = WinDivert.WinDivertOpen(DNS_FILTER, WinDivertLayer.Network, 0, WinDivertOpenFlags.None);
|
||||
if (handle == IntPtr.MaxValue || handle == IntPtr.Zero)
|
||||
{
|
||||
this.logger.LogError($"打开驱动失败");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -93,6 +95,11 @@ namespace FastGithub.PacketIntercept.Dns
|
||||
WinDivert.WinDivertSend(handle, winDivertBuffer, packetLength, ref winDivertAddress);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var exception = new Win32Exception(Marshal.GetLastWin32Error());
|
||||
this.logger.LogError(exception.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using System.ComponentModel;
|
||||
using System.Net;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@ -50,6 +52,7 @@ namespace FastGithub.PacketIntercept.Tcp
|
||||
var handle = WinDivert.WinDivertOpen(this.filter, WinDivertLayer.Network, 0, WinDivertOpenFlags.None);
|
||||
if (handle == IntPtr.MaxValue || handle == IntPtr.Zero)
|
||||
{
|
||||
this.logger.LogError($"打开驱动失败");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -77,6 +80,11 @@ namespace FastGithub.PacketIntercept.Tcp
|
||||
WinDivert.WinDivertSend(handle, winDivertBuffer, packetLength, ref winDivertAddress);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var exception = new Win32Exception(Marshal.GetLastWin32Error());
|
||||
this.logger.LogError(exception.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user