高分求懂VC、VS的高手帮我把这几句代码翻译成delphi的代码!谢谢!(300分)

  • 主题发起人 主题发起人 legoog
  • 开始时间 开始时间
L

legoog

Unregistered / Unconfirmed
GUEST, unregistred user!
unsigned char*_K_Param;
unsigned char*_T_Param;
unsigned char*LoginPack;
unsigned char*EncodeKeyStru;
SOCKET g_ClientSocket;

RXNetCommCore::RXNetCommCore(void)
{
_K_Param = new unsigned char[$10];
_T_Param = new unsigned char[$10];
EncodeKeyStru = new unsigned char[$200];
LoginPack = new unsigned char[$50];
memset(_K_Param,$00,$10);
memset(_T_Param,$00,$10);
memset(EncodeKeyStru,$00,$200);
memset(LoginPack,$00,$50);
*(DWORD*)LoginPack = $458000;
}

unsigned long RXNetCommCore::Lgoin(char* sz_UserName, char* sz_Passwd)
{
Sub1_ASMInit();
Sub2_ASMInit();
Sub3_ASMInit();
Sub4_ASMInit();
Sub5_ASMInit();
unsigned char sz_output[$20] = {0};
makeLoginPack(sz_Passwd,sz_output);
int AccountLen = strlen(sz_UserName);
LoginPack[4] = AccountLen;
for (int i = 0 ;
i <AccountLen ;
i++)
{
LoginPack[i+6] = sz_UserName;
}
LoginPack[AccountLen+6] = '/x28';
int MD5Offset = AccountLen+8;
char printMd5[$41] = {0};
for (int i_2 = 0 ;
i_2 < 20 ;
i_2++)
{
wsprintfA(printMd5+i_2*2,"%.2X",sz_output[i_2]);
}
CharLowerA(printMd5);
for (int i_3 = MD5Offset ;
i_3 < 40+MD5Offset ;
i_3 ++)
{
LoginPack[i_3] = printMd5[i_3-MD5Offset];
}
LoginPack[2] = MD5Offset+40+16-4;
SendLoginPack(LoginPack,(long)(MD5Offset+40+16));
return 0;
}
int RXNetCommCore::InitKeyStruct(DWORD _KEY_T,DWORD _KEY_K)
{
*(DWORD*)(EncodeKeyStru+$DE) = $00;
*(DWORD*)(EncodeKeyStru+$EF) = _KEY_K;
*(DWORD*)(EncodeKeyStru+$FC) = _KEY_T;
*(DWORD*)(EncodeKeyStru+$100) = $e0;
*(DWORD*)(EncodeKeyStru+$104) = $02a3;
*(DWORD*)(EncodeKeyStru+$10D) = $1;
*(DWORD*)(EncodeKeyStru+$115) = $4;
*(DWORD*)(EncodeKeyStru+$11D) =$01;
*(DWORD*)(EncodeKeyStru+$125) =$3a254698;
*(DWORD*)(EncodeKeyStru+$170) =$00170017;
return 0;
}
请帮我把以上代码翻译成delphi版的谢谢。
 
_K_Param:array of Byte;
_T_Param:array of Byte;
LoginPack:array of Byte;
EncodeKeyStru:array of Byte;
g_ClientSocket:TSocket;

procedure TRXNetCommCore.Create;
begin
SetLength(_K_Param,$10);
SetLength(_T_Param,$10);
SetLength(EncodeKeyStru,$200);
SetLength(LoginPack,$50);
FillChar(_K_Param[0],$10,0);
FillChar(_T_Param,$10,0);
FillChar(EncodeKeyStru,$200,0);
FillChar(LoginPack,$50,0);
PCardinal(LoginPack)^ = $458000;
end;

function TRXNetCommCore.Lgoin(sz_UserName:string;sz_Passwd:string):Cardinal;
var
sz_output:array [0..$20-1] of Char;
AccountLen,i,i_2,i_3,MD5Offset:Integer;
printMd5:string;
begin
Sub1_ASMInit();
Sub2_ASMInit();
Sub3_ASMInit();
Sub4_ASMInit();
Sub5_ASMInit();

FillChar(sz_output[0],$20,0);
makeLoginPack(sz_Passwd,sz_output);
AccountLen:= Length(sz_UserName);
LoginPack[4] = AccountLen;
for i:= 1 to AccountLendo
LoginPack[i+6]:= Ord(sz_UserName);
LoginPack[AccountLen+6] = $28;
MD5Offset:= AccountLen+8;
printMd5:='';
for i_2:=0 to 19do
begin
printMd5:=printMd5+IntToHex(Ord(sz_output[i_2]),2);
printMd5:=LowerCase(printMd5);

for i_3:= MD5Offset to 40+MD5Offsetdo
LoginPack[i_3] = Ord(printMd5[i_3-MD5Offset]);
LoginPack[2] = MD5Offset+40+16-4;
SendLoginPack(LoginPack,MD5Offset+40+16);
Result:=0;
end;

function TRXNetCommCore.InitKeyStruct(_KEY_T:Cardinal;_KEY_K:Cardinal):Integer;
begin

PCardinal(LongInt(EncodeKeyStru)+$DE) = $00;
PCardinal(LongInt(EncodeKeyStru)+$EF)^ = _KEY_K;
PCardinal(LongInt(EncodeKeyStru)+$FC)^ = _KEY_T;
PCardinal(LongInt(EncodeKeyStru)+$100)^ = $e0;
PCardinal(LongInt(EncodeKeyStru)+$104)^ = $02a3;
PCardinal(LongInt(EncodeKeyStru)+$10D)^ = $1;
PCardinal(LongInt(EncodeKeyStru)+$115)^ = $4;
PCardinal(LongInt(EncodeKeyStru)+$11D)^ =$01;
PCardinal(LongInt(EncodeKeyStru)+$125)^ =$3a254698;
PCardinal(LongInt(EncodeKeyStru)+$170)^ =$00170017;
Result:=0;
end;
 
K_Param:array of Byte;
_T_Param:array of Byte;
LoginPack:array of Byte;
EncodeKeyStru:array of Byte;
g_ClientSocket:TSocket;

constructor TRXNetCommCore.Create;
begin
SetLength(_K_Param,$10);
SetLength(_T_Param,$10);
SetLength(EncodeKeyStru,$200);
SetLength(LoginPack,$50);
FillChar(_K_Param[0],$10,0);
FillChar(_T_Param,$10,0);
FillChar(EncodeKeyStru,$200,0);
FillChar(LoginPack,$50,0);
PCardinal(LoginPack)^ = $458000;
end;

function TRXNetCommCore.Lgoin(sz_UserName:string;sz_Passwd:string):Cardinal;
var
sz_output:array [0..$20-1] of Char;
AccountLen,i,i_2,i_3,MD5Offset:Integer;
printMd5:string;
begin
Sub1_ASMInit();
Sub2_ASMInit();
Sub3_ASMInit();
Sub4_ASMInit();
Sub5_ASMInit();

FillChar(sz_output[0],$20,0);
makeLoginPack(sz_Passwd,sz_output);
AccountLen:= Length(sz_UserName);
LoginPack[4] = AccountLen;
for i:= 1 to AccountLendo
LoginPack[i+6]:= Ord(sz_UserName);
LoginPack[AccountLen+6] = $28;
MD5Offset:= AccountLen+8;
printMd5:='';
for i_2:=0 to 19do
begin
printMd5:=printMd5+IntToHex(Ord(sz_output[i_2]),2);
printMd5:=LowerCase(printMd5);

for i_3:= MD5Offset to 40+MD5Offsetdo
LoginPack[i_3] = Ord(printMd5[i_3-MD5Offset]);
LoginPack[2] = MD5Offset+40+16-4;
SendLoginPack(LoginPack,MD5Offset+40+16);
Result:=0;
end;

function TRXNetCommCore.InitKeyStruct(_KEY_T:Cardinal;_KEY_K:Cardinal):Integer;
begin

PCardinal(LongInt(EncodeKeyStru)+$DE) = $00;
PCardinal(LongInt(EncodeKeyStru)+$EF)^ = _KEY_K;
PCardinal(LongInt(EncodeKeyStru)+$FC)^ = _KEY_T;
PCardinal(LongInt(EncodeKeyStru)+$100)^ = $e0;
PCardinal(LongInt(EncodeKeyStru)+$104)^ = $02a3;
PCardinal(LongInt(EncodeKeyStru)+$10D)^ = $1;
PCardinal(LongInt(EncodeKeyStru)+$115)^ = $4;
PCardinal(LongInt(EncodeKeyStru)+$11D)^ =$01;
PCardinal(LongInt(EncodeKeyStru)+$125)^ =$3a254698;
PCardinal(LongInt(EncodeKeyStru)+$170)^ =$00170017;
Result:=0;
end;
 
后退
顶部