修改无效handle的判断
This commit is contained in:
parent
b4623ddb60
commit
a16844c0ea
@ -62,10 +62,9 @@ namespace FastGithub.PacketIntercept.Dns
|
||||
await Task.Yield();
|
||||
|
||||
var handle = WinDivert.WinDivertOpen(DNS_FILTER, WinDivertLayer.Network, 0, WinDivertOpenFlags.None);
|
||||
if (handle == IntPtr.MaxValue || handle == IntPtr.Zero)
|
||||
if (handle == new IntPtr(unchecked((long)ulong.MaxValue)))
|
||||
{
|
||||
const int ERROR_INVALID_HANDLE = 0x6;
|
||||
throw new Win32Exception(ERROR_INVALID_HANDLE, "打开驱动失败");
|
||||
throw new Win32Exception();
|
||||
}
|
||||
|
||||
cancellationToken.Register(hwnd =>
|
||||
|
||||
@ -50,10 +50,9 @@ namespace FastGithub.PacketIntercept.Tcp
|
||||
await Task.Yield();
|
||||
|
||||
var handle = WinDivert.WinDivertOpen(this.filter, WinDivertLayer.Network, 0, WinDivertOpenFlags.None);
|
||||
if (handle == IntPtr.MaxValue || handle == IntPtr.Zero)
|
||||
if (handle == new IntPtr(unchecked((long)ulong.MaxValue)))
|
||||
{
|
||||
const int ERROR_INVALID_HANDLE = 0x6;
|
||||
throw new Win32Exception(ERROR_INVALID_HANDLE, "打开驱动失败");
|
||||
throw new Win32Exception();
|
||||
}
|
||||
|
||||
this.logger.LogInformation($"tcp://{IPAddress.Loopback}:{BinaryPrimitives.ReverseEndianness(this.oldServerPort)} => tcp://{IPAddress.Loopback}:{BinaryPrimitives.ReverseEndianness(this.newServerPort)}");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user