Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
xljiulang authored Sep 28, 2022
1 parent f75761d commit ee084bb
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,29 @@

### 如何使用
```
using var divert = new WinDivert("true", WinDivertLayer.Network);
var filter = Filter.True
.And(f => f.Network.Loopback)
.And(f => f.Tcp.DstPort == 443)
.And(f => f.Tcp.Ack == true);
using var divert = new WinDivert(filter, WinDivertLayer.Network);
using var packet = new WinDivertPacket();
var addr = new WinDivertAddress();
// 读包
divert.Recv(packet, ref addr);
while(true)
{
// 读包
divert.Recv(packet, ref addr);
// 解包
var result = packet.GetParseResult();
// 解包
var result = packet.GetParseResult();
// 改包
result.TcpHeader->DstPort = 443;
// 改包
result.TcpHeader->DstPort = 443;
// 重算checksums
packet.CalcChecksums(ref addr);
// 修改后发出
divert.Send(packet, ref addr);
// 重算checksums
packet.CalcChecksums(ref addr);
// 修改后发出
divert.Send(packet, ref addr);
}

0 comments on commit ee084bb

Please sign in to comment.