C代码转Delphi 高手帮忙谢谢啊! 10
下面的代码麻烦帮忙转成Delphi的代码,谢谢了!intMY_EncFunc(intGameKey,intData,intlen){intLen;inti;intdata...
下面的代码麻烦帮忙转成Delphi 的代码,谢谢了!
int MY_EncFunc(int GameKey, int Data, int len)
{
int Len;
int i;
int data;
int result;
char value1;
unsigned __int8 value_data;
char value2;
unsigned __int8 v10;
Len = len;
i = 0;
if ( len > 0 )
{
data = Data;
do
{
value1 = *(BYTE *)(*(BYTE *)(GameKey + 0x404) + GameKey + 4) ^ *(BYTE *)(i + data);
*(BYTE *)(i + data) ^= *(BYTE *)(*(BYTE *)(GameKey + 0x404) + GameKey + 4);
value_data = value1 + *(BYTE *)(*(BYTE *)(GameKey + 0x404) + GameKey + 0x204);
*(BYTE *)(i + data) = value_data;
value2 = value_data ^ *(BYTE *)(*(BYTE *)(GameKey + 0x405) + GameKey + 0x104);
*(BYTE *)(i + data) = value2;
result = *(BYTE *)(GameKey + 0x405);
*(BYTE *)(&result) = value2 + *(BYTE *)(result + GameKey + 0x304);
v10 = (BYTE)result >> 4;
*(BYTE *)(&result) = 16 * (BYTE)result;
*(BYTE *)(i + data) = (BYTE)result | v10;
++*(WORD *)(GameKey + 0x404);
++i;
}
while ( i < Len );
}
return result;
}
int MY_Decfunc(int GameKey, int data, int len)
{
int Len;
int i;
int Data;
int result;
char value1;
unsigned __int8 value_data;
char value2;
int value3;
Len = len;
i = 0;
if ( len > 0 )
{
Data = data;
do
{
value1 = (unsigned __int8)(16 * *(BYTE *)(i + Data)) | (unsigned __int8)(*(BYTE *)(i + Data) >> 4);
*(BYTE *)(i + Data) = (unsigned __int8)(16 * *(BYTE *)(i + Data)) | (unsigned __int8)(*(BYTE *)(i + Data) >> 4);
value_data = value1 - *(BYTE *)(*(BYTE *)(GameKey + 0x407) + GameKey + 0x304);
*(BYTE *)(i + Data) = value_data;
value2 = value_data ^ *(BYTE *)(*(BYTE *)(GameKey + 0x407) + GameKey + 0x104);
*(BYTE *)(i + Data) = value_data ^ *(BYTE *)(*(BYTE *)(GameKey + 0x407) + GameKey + 0x104);
result = *(BYTE *)(GameKey + 0x406);
value3 = *(BYTE *)(GameKey + 0x406);
*(BYTE *)(&result) = value2 - *(BYTE *)(value3 + GameKey + 0x204);
*(BYTE *)(i + Data) = value2 - *(BYTE *)(value3 + GameKey + 0x204);
*(BYTE *)(i + Data) = (BYTE)result ^ *(BYTE *)(*(BYTE *)(GameKey + 0x406) + GameKey + 4);
++*(WORD *)(GameKey + 0x406);
++i;
}
while ( i < Len );
}
return result;
} 展开
int MY_EncFunc(int GameKey, int Data, int len)
{
int Len;
int i;
int data;
int result;
char value1;
unsigned __int8 value_data;
char value2;
unsigned __int8 v10;
Len = len;
i = 0;
if ( len > 0 )
{
data = Data;
do
{
value1 = *(BYTE *)(*(BYTE *)(GameKey + 0x404) + GameKey + 4) ^ *(BYTE *)(i + data);
*(BYTE *)(i + data) ^= *(BYTE *)(*(BYTE *)(GameKey + 0x404) + GameKey + 4);
value_data = value1 + *(BYTE *)(*(BYTE *)(GameKey + 0x404) + GameKey + 0x204);
*(BYTE *)(i + data) = value_data;
value2 = value_data ^ *(BYTE *)(*(BYTE *)(GameKey + 0x405) + GameKey + 0x104);
*(BYTE *)(i + data) = value2;
result = *(BYTE *)(GameKey + 0x405);
*(BYTE *)(&result) = value2 + *(BYTE *)(result + GameKey + 0x304);
v10 = (BYTE)result >> 4;
*(BYTE *)(&result) = 16 * (BYTE)result;
*(BYTE *)(i + data) = (BYTE)result | v10;
++*(WORD *)(GameKey + 0x404);
++i;
}
while ( i < Len );
}
return result;
}
int MY_Decfunc(int GameKey, int data, int len)
{
int Len;
int i;
int Data;
int result;
char value1;
unsigned __int8 value_data;
char value2;
int value3;
Len = len;
i = 0;
if ( len > 0 )
{
Data = data;
do
{
value1 = (unsigned __int8)(16 * *(BYTE *)(i + Data)) | (unsigned __int8)(*(BYTE *)(i + Data) >> 4);
*(BYTE *)(i + Data) = (unsigned __int8)(16 * *(BYTE *)(i + Data)) | (unsigned __int8)(*(BYTE *)(i + Data) >> 4);
value_data = value1 - *(BYTE *)(*(BYTE *)(GameKey + 0x407) + GameKey + 0x304);
*(BYTE *)(i + Data) = value_data;
value2 = value_data ^ *(BYTE *)(*(BYTE *)(GameKey + 0x407) + GameKey + 0x104);
*(BYTE *)(i + Data) = value_data ^ *(BYTE *)(*(BYTE *)(GameKey + 0x407) + GameKey + 0x104);
result = *(BYTE *)(GameKey + 0x406);
value3 = *(BYTE *)(GameKey + 0x406);
*(BYTE *)(&result) = value2 - *(BYTE *)(value3 + GameKey + 0x204);
*(BYTE *)(i + Data) = value2 - *(BYTE *)(value3 + GameKey + 0x204);
*(BYTE *)(i + Data) = (BYTE)result ^ *(BYTE *)(*(BYTE *)(GameKey + 0x406) + GameKey + 4);
++*(WORD *)(GameKey + 0x406);
++i;
}
while ( i < Len );
}
return result;
} 展开
1个回答
展开全部
function My_EncFunc(GameKey:Integer;Data:Integer;len:Integer):Integer;
type
PBytes=^Byte;
PInt=^Integer;
var
_Len,i,_Data,_Result:Integer;
value1,value2:Char;
value_data,v10:byte;
begin
_Len:=len;
i:=0;
if _Len>0 then
begin
_Data:=Data;
repeat
{value1 = *(BYTE *)(*(BYTE *)(GameKey + 0x404) + GameKey + 4) ^ *(BYTE *)(i + data);}
value1:=Char((PBytes(PBytes(GameKey+$404)^+GameKey+4)^) xor (PBytes(i+_Data)^));
{*(BYTE *)(i + data) ^= *(BYTE *)(*(BYTE *)(GameKey + 0x404) + GameKey + 4);}
PBytes(i+_Data)^:=PBytes(i+_Data)^ xor (PBytes(PBytes(GameKey+$404)^+GameKey+4)^);
{value_data = value1 + *(BYTE *)(*(BYTE *)(GameKey + 0x404) + GameKey + 0x204);}
value_data:= Byte(value1)+PBytes(PBytes(GameKey+$404)^+GameKey+$204)^;
{*(BYTE *)(i + data) = value_data;}
PBytes(i+_Data)^:=value_data;
{value2 = value_data ^ *(BYTE *)(*(BYTE *)(GameKey + 0x405) + GameKey + 0x104);}
value2:= char(Byte(value_data) xor PBytes(PBytes(GameKey+$405)^+GameKey+$104)^);
{*(BYTE *)(i + data) = value2;}
PBytes(i+_Data)^:=Byte(value2);
{result = *(BYTE *)(GameKey + 0x405);}
_Result:=PInt(GameKey+$405)^;
{*(BYTE *)(&result) = value2 + *(BYTE *)(result + GameKey + 0x304);}
PBytes(@_Result)^:=Byte(value2)+PBytes(_Result+GameKey+$304)^;
{ v10 = (BYTE)result >> 4;}
v10:=Byte(_Result) shr 4;
{*(BYTE *)(&result) = 16 * (BYTE)result;}
PBytes(@_Result)^:=Byte(16*Byte(_Result));
{*(BYTE *)(i + data) = (BYTE)result | v10;}
PBytes(i+_Data)^:=Byte(_Result) or v10;
{++*(WORD *)(GameKey + 0x404);}
Inc(PInt(GameKey+$404)^);
{++i;}
inc(i);
until (i>=_Len) ;
end;
My_EncFunc:=_Result;
{你程序有毛病吧,有可能返回未知的值,在_Len<=0时}
end;
{int MY_Decfunc(int GameKey, int data, int len)}
function MY_Decfunc(GameKey:Integer;data:Integer;len:Integer):Integer;
{
int Len;
int i;
int Data;
int result;
char value1;
unsigned __int8 value_data;
char value2;
int value3;
}
type
PBytes=^Byte;
PInt=^Integer;
var
_Len,i,_Data,_Result,value3:Integer;
value2,value1:Char;
value_data:Byte;
begin
_Len:=len;
i:=0;
if _Len>0 then
begin
_Data:=data;
repeat
{value1 = (unsigned __int8)(16 * *(BYTE *)(i + Data)) | (unsigned __int8)(*(BYTE *)(i + Data) >> 4);}
value1:=Char(byte(PBytes(i+_Data)^*16) or (Byte(PBytes(i+_Data)^ shr 4)));
{*(BYTE *)(i + Data) = (unsigned __int8)(16 * *(BYTE *)(i + Data)) | (unsigned __int8)(*(BYTE *)(i + Data) >> 4);}
PBytes(i+_Data)^:=byte(PBytes(i+_Data)^*16) or (Byte(PBytes(i+_Data)^ shr 4));
{value_data = value1 - *(BYTE *)(*(BYTE *)(GameKey + 0x407) + GameKey + 0x304);}
value_data:=Byte(value1)-(PBytes(PBytes(GameKey+$407)^+GameKey+$304)^);
{*(BYTE *)(i + Data) = value_data;}
PBytes(i+_Data)^:=value_data;
{value2 = value_data ^ *(BYTE *)(*(BYTE *)(GameKey + 0x407) + GameKey + 0x104);}
value2:=Char(value_data xor PBytes(PBytes(GameKey+$407)^+GameKey+$104)^);
{*(BYTE *)(i + Data) = value_data ^ *(BYTE *)(*(BYTE *)(GameKey + 0x407) + GameKey + 0x104);}
PBytes(i+_Data)^:=value_data xor PBytes(PBytes(GameKey+$407)^+GameKey+$104)^;
{result = *(BYTE *)(GameKey + 0x406);}
_Result:=PBytes(GameKey+$406)^;
{value3 = *(BYTE *)(GameKey + 0x406);}
value3:=PBytes(GameKey+$406)^;
{*(BYTE *)(&result) = value2 - *(BYTE *)(value3 + GameKey + 0x204);}
PBytes(@_Result)^:=Byte(value2)-PBytes(value3+GameKey+$204)^;
{*(BYTE *)(i + Data) = value2 - *(BYTE *)(value3 + GameKey + 0x204);}
PBytes(i+_Data)^:=Byte(value2)-PBytes(value3+GameKey+$204)^;
{*(BYTE *)(i + Data) = (BYTE)result ^ *(BYTE *)(*(BYTE *)(GameKey + 0x406) + GameKey + 4);}
PBytes(i+_Data)^:=Byte(_Result) xor PBytes(PBytes(GameKey+$406)^+GameKey+4)^;
{++*(WORD *)(GameKey + 0x406);}
inc(PInt(GameKey+$406)^);
inc(i);
until i>=_Len ;
end;
MY_Decfunc:=_Result;
end;
type
PBytes=^Byte;
PInt=^Integer;
var
_Len,i,_Data,_Result:Integer;
value1,value2:Char;
value_data,v10:byte;
begin
_Len:=len;
i:=0;
if _Len>0 then
begin
_Data:=Data;
repeat
{value1 = *(BYTE *)(*(BYTE *)(GameKey + 0x404) + GameKey + 4) ^ *(BYTE *)(i + data);}
value1:=Char((PBytes(PBytes(GameKey+$404)^+GameKey+4)^) xor (PBytes(i+_Data)^));
{*(BYTE *)(i + data) ^= *(BYTE *)(*(BYTE *)(GameKey + 0x404) + GameKey + 4);}
PBytes(i+_Data)^:=PBytes(i+_Data)^ xor (PBytes(PBytes(GameKey+$404)^+GameKey+4)^);
{value_data = value1 + *(BYTE *)(*(BYTE *)(GameKey + 0x404) + GameKey + 0x204);}
value_data:= Byte(value1)+PBytes(PBytes(GameKey+$404)^+GameKey+$204)^;
{*(BYTE *)(i + data) = value_data;}
PBytes(i+_Data)^:=value_data;
{value2 = value_data ^ *(BYTE *)(*(BYTE *)(GameKey + 0x405) + GameKey + 0x104);}
value2:= char(Byte(value_data) xor PBytes(PBytes(GameKey+$405)^+GameKey+$104)^);
{*(BYTE *)(i + data) = value2;}
PBytes(i+_Data)^:=Byte(value2);
{result = *(BYTE *)(GameKey + 0x405);}
_Result:=PInt(GameKey+$405)^;
{*(BYTE *)(&result) = value2 + *(BYTE *)(result + GameKey + 0x304);}
PBytes(@_Result)^:=Byte(value2)+PBytes(_Result+GameKey+$304)^;
{ v10 = (BYTE)result >> 4;}
v10:=Byte(_Result) shr 4;
{*(BYTE *)(&result) = 16 * (BYTE)result;}
PBytes(@_Result)^:=Byte(16*Byte(_Result));
{*(BYTE *)(i + data) = (BYTE)result | v10;}
PBytes(i+_Data)^:=Byte(_Result) or v10;
{++*(WORD *)(GameKey + 0x404);}
Inc(PInt(GameKey+$404)^);
{++i;}
inc(i);
until (i>=_Len) ;
end;
My_EncFunc:=_Result;
{你程序有毛病吧,有可能返回未知的值,在_Len<=0时}
end;
{int MY_Decfunc(int GameKey, int data, int len)}
function MY_Decfunc(GameKey:Integer;data:Integer;len:Integer):Integer;
{
int Len;
int i;
int Data;
int result;
char value1;
unsigned __int8 value_data;
char value2;
int value3;
}
type
PBytes=^Byte;
PInt=^Integer;
var
_Len,i,_Data,_Result,value3:Integer;
value2,value1:Char;
value_data:Byte;
begin
_Len:=len;
i:=0;
if _Len>0 then
begin
_Data:=data;
repeat
{value1 = (unsigned __int8)(16 * *(BYTE *)(i + Data)) | (unsigned __int8)(*(BYTE *)(i + Data) >> 4);}
value1:=Char(byte(PBytes(i+_Data)^*16) or (Byte(PBytes(i+_Data)^ shr 4)));
{*(BYTE *)(i + Data) = (unsigned __int8)(16 * *(BYTE *)(i + Data)) | (unsigned __int8)(*(BYTE *)(i + Data) >> 4);}
PBytes(i+_Data)^:=byte(PBytes(i+_Data)^*16) or (Byte(PBytes(i+_Data)^ shr 4));
{value_data = value1 - *(BYTE *)(*(BYTE *)(GameKey + 0x407) + GameKey + 0x304);}
value_data:=Byte(value1)-(PBytes(PBytes(GameKey+$407)^+GameKey+$304)^);
{*(BYTE *)(i + Data) = value_data;}
PBytes(i+_Data)^:=value_data;
{value2 = value_data ^ *(BYTE *)(*(BYTE *)(GameKey + 0x407) + GameKey + 0x104);}
value2:=Char(value_data xor PBytes(PBytes(GameKey+$407)^+GameKey+$104)^);
{*(BYTE *)(i + Data) = value_data ^ *(BYTE *)(*(BYTE *)(GameKey + 0x407) + GameKey + 0x104);}
PBytes(i+_Data)^:=value_data xor PBytes(PBytes(GameKey+$407)^+GameKey+$104)^;
{result = *(BYTE *)(GameKey + 0x406);}
_Result:=PBytes(GameKey+$406)^;
{value3 = *(BYTE *)(GameKey + 0x406);}
value3:=PBytes(GameKey+$406)^;
{*(BYTE *)(&result) = value2 - *(BYTE *)(value3 + GameKey + 0x204);}
PBytes(@_Result)^:=Byte(value2)-PBytes(value3+GameKey+$204)^;
{*(BYTE *)(i + Data) = value2 - *(BYTE *)(value3 + GameKey + 0x204);}
PBytes(i+_Data)^:=Byte(value2)-PBytes(value3+GameKey+$204)^;
{*(BYTE *)(i + Data) = (BYTE)result ^ *(BYTE *)(*(BYTE *)(GameKey + 0x406) + GameKey + 4);}
PBytes(i+_Data)^:=Byte(_Result) xor PBytes(PBytes(GameKey+$406)^+GameKey+4)^;
{++*(WORD *)(GameKey + 0x406);}
inc(PInt(GameKey+$406)^);
inc(i);
until i>=_Len ;
end;
MY_Decfunc:=_Result;
end;
追问
你给的这个列子一调用 就报错,,麻烦你给个调用时的列子好吗?谢谢了
追答
说明你的源程序就有错误!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询