相关疑难解决方法(0)

将字节数组转换为托管结构

更新:这个问题的答案帮助我在GitHub上编写了开源项目AlicanC的Modern Warfare 2 Tool.您可以看到我如何在MW2Packets.cs中读取这些数据包以及我编写的扩展,以读取Extensions.cs中的大端数据.

我在我的C#应用​​程序中使用Pcap.Net捕获" 使命召唤:现代战争2"的 UDP数据包.我从图书馆收到了一封.我试图像字符串一样解析它,但是效果不好.byte[]

byte[]我有一个通用的数据包报头,然后具体到数据包类型,然后约在大堂每个玩家信息的另一头.

一个乐于助人的人为我检查了一些数据包并想出了这些结构:

// Fields are big endian unless specified otherwise.
struct packet_header
{
    uint16_t magic;
    uint16_t packet_size;
    uint32_t unknown1;
    uint32_t unknown2;
    uint32_t unknown3;
    uint32_t unknown4;
    uint16_t unknown5;
    uint16_t unknown6;
    uint32_t unknown7;
    uint32_t unknown8;
    cstring_t packet_type; // \0 terminated string
};

// Fields are little endian unless specified otherwise.
struct header_partystate //Header for the "partystate" packet type
{
    uint32_t unknown1;
    uint8_t …
Run Code Online (Sandbox Code Playgroud)

c# structure bytearray pcap.net

17
推荐指数
5
解决办法
4万
查看次数

标签 统计

bytearray ×1

c# ×1

pcap.net ×1

structure ×1