如何修改如下结构体和公用体:

kavabyte 2003-01-28 12:36:06
如何修改以下C结构为Delphi结构,谢谢:

struct __PACKET_BUFFER__
{
BYTE Status;
BYTE AclType;
BYTE NetType;
BYTE TimeType;

ULONG AclId;

union
{
struct
{
USHORT TcpCode : 6;
USHORT Reserved : 10;
};
struct
{
USHORT TcpFin : 1;
USHORT TcpSyn : 1;
USHORT TcpRst : 1;
USHORT TcpPsh : 1;
USHORT TcpAck : 1;
USHORT TcpUrg : 1;

USHORT Direction : 1; // 0: IN, 1: OUT
USHORT SendOrRecv : 1;
USHORT Action : 8;
};
};
BYTE bReserved[2];

BYTE Protocol;
BYTE Week;
BYTE IcmpType;
BYTE IcmpSubType;

ULONG Time;
ULONG SourceIp;
ULONG DestinationIp;

union
{
ULONG Id;
struct
{
ULONG SourcePort : 16;
ULONG DestinationPort : 16;
};
};

ULONG DataBytes;
ULONG ProcessHandle;

char sProcess[16];
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////


struct __PACKET_DIRECTION__
{
ULONG Id;

struct
{
BYTE Direction : 4;
BYTE Action : 4;
};

BYTE NetType;

struct
{
BYTE AclType : 4;
BYTE Reserved : 2;
BYTE DeleteIn : 1;
BYTE DeleteOut: 1;
};

BYTE Protocol;

ULONG AclId;
ULONG Time;
ULONG ProcessHandle;
ULONG SendData;
ULONG RecvData;
ULONG LocalIp;
ULONG RemoteIp;

USHORT LocalPort;
USHORT RemotePort;

char sProcess[16];
};
...全文
23 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
kavabyte 2003-01-28
  • 打赏
  • 举报
回复
多谢几位大侠,但是我看见那里面有许多的公用体啊.
zsy_good 2003-01-28
  • 打赏
  • 举报
回复
完全匹配,那我真的错啦。我只是为了达到目的
zsy_good 2003-01-28
  • 打赏
  • 举报
回复
我哪里写的不对?还是没有初始值
copy_paste 2003-01-28
  • 打赏
  • 举报
回复
zsy_good
看这里,不是这样译的。

http://expert.csdn.net/Expert/topic/1397/1397405.xml?temp=6.853884E-02
zsy_good 2003-01-28
  • 打赏
  • 举报
回复
兄弟在学防火墙开发吧,好好学号C++在学,急于求成是不行的
这是我写的开发包,你看看


http://www.csdn.net/cnshare/soft/15/15543.shtm

这是2个结构的翻译

type
TTcpCode = record
TcpCode: Smallint;
Reserved: Smallint;
end;
TTcpFin = record
TcpFim: Smallint;
RcpSyn: Smallint;
TcpRst: Smallint;
TcpPsh: Smallint;
TcpAck: Smallint;
TcpUrg: Smallint;
Direction: Smallint;
SendOrRecv: Smallint;
Action: Smallint;
end;
TSourcePort = record
SourcePort: ULong;
DestinationPort: ULong;
end;
TID = record
ID: Ulong;
SourcePort: TSourcePort;
end;


PACKET_BUFFER = record
Status: Byte;
AclType: Byte;
NetType: Byte;
TimeType: Byte;
AclID: ULong;
TcpCode: TTcpCode;
TcpFin: TTcpFin;
bReserved: array [0..1] of byte;
Protocol: Byte;
Week: Byte;
IcmpType: Byte;
IcmpSubType: Byte;
Time: ULong;
SourceIp: ULong;
DestinationIP: Ulong;
ID: TID;
DataBytes: ULong;
ProcessHandle: ULong;
sProcess: array [0..15] of char;
end;
TDirection = record
Direction: Byte;
Action: Byte;
end;

TAclType = record
AclType: Byte;
Reserved: Byte;
DeleteIn: Byte;
DeleteOut: Byte;
end;
PACKET_DIRECTION = record
id: ULong;
Direction: TDirection;
NetType: Byte;
AclType: TAclType;
Protocol: Byte;
AclID: ULong;
Time: ULong;
Processhandle: ULong;
SendData: ULong;
RecvData: ULong;
LocalIp: ULong;
RemoteIP: ULong;
sProcess: array [0..15] of char;
end;

Randy_Mic 2003-01-28
  • 打赏
  • 举报
回复
哪儿找这么两个结构啊?够变态。。。。。

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧