- function StrtoUnicode(Str:string):string;
- var
- s: string;
- i, j, k: integer;
- a: array [1..1000] of char;
- begin
- s:='';
- StringToWideChar(Str, @(a[1]), 500);
- i:=1;
- while ((a[i]<>#0) or (a[i+1]<>#0)) do
- begin
- j:=Integer(a[i]); k:=Integer(a[i+1]);
- s:=s+Copy(Format('%X ',[j*$100+k+$10000]) ,2,4);
- i:=i+2;
- end;
- Result:=s;
- end;
- function FanXie(Ans:String):string;
- var
- Str1,Str2,Str3,Str4:String;
- begin
- Str1:=Copy(Ans,7,2);
- Str2:=Copy(Ans,5,2);
- Str3:=Copy(Ans,3,2);
- Str4:=Copy(Ans,1,2);
- FanXie:=Str1+Str2+Str3+Str4;
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- var
- BaoTou:string;
- BaoGu,BaoGu1,BaoMyID,BaoYouId,BaoL1,BaoL2,BaoWei:String;
- BaoString,BaoLen:String;
- TextOne,TextTwo:String;
- L1,L2:Integer;
- begin
- BaoTou:='250019000000'; //包头
- BaoGu:='74100000'; //固定包
- BaoGu1:='00000005'; //固定包
- BaoWei:='000000000000000000000000000000000000';//包尾 这里没去弄
- BaoMyID:=IntToHex(StrToInt(Edit3.Text),8); //自己ID
- BaoYouId:=IntToHex(StrToInt(Edit2.Text),8);//对方ID
- TextOne:=StrtoUnicode(Edit1.Text); //主题
- TextTwo:=StrtoUnicode(Memo1.Text); //内容
- L1:=round(length(TextOne) / 2);//获取主题长
- L2:=round(length(TextTwo) / 2);//获取内容长
- BaoL1:=IntToHex(L1,2); //主题长转换
- BaoL2:='80'+IntToHex(L2,2); //内容长转换 这里的80没搞懂 测试都能OK
- BaoString:=BaoTou+'00000000'+BaoGu+BaoMyId+BaoGu1+BaoYouId+BaoL1+TextOne+BaoL2+TextTwo+BaoWei;
- BaoLen:=FanXie(IntToHex(round(length(BaoString) / 2 - 10),8));
- BaoString:=BaoTou+BaoLen+BaoGu+BaoMyId+BaoGu1+BaoYouId+BaoL1+TextOne+BaoL2+TextTwo+BaoWei;
- Memo2.Text:=BaoString;
- end;
完美世界 邮件发包结构分析
最新推荐文章于 2024-08-19 22:45:00 发布