Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Func;
- interface
- Uses
- Windows,SysUtils,Classes, Dialogs;
- Type
- TByteArr = array of byte;
- TByteArray = array of byte;
- type T_ItemList = Record // Cada Item tem 464 bytes
- Name : Array [0..63] of Byte;
- NameEnglish : Array [0..63] of Byte;
- Descrition : Array [0..127] of Byte;
- Unk : Array [0..207] of byte;
- End;
- Procedure ReadItemList;
- function StrToArray(const Hexstr: String): TByteArr;
- function bintoAscii(const bin: array of byte): AnsiString;
- Function CountStr(Str: String):Integer;
- implementation
- Procedure ReadItemList;
- var
- f,N : TFileStream;
- buffer : array of BYTE;
- local : string;
- I,j, size : Integer;
- Key1,Key2 : string;
- cipherTable : TByteArr;
- cipherLength: integer;
- par : boolean;
- sign : Integer;
- myFile : TextFile;
- ListItem :ARRAY OF T_ItemList;
- begin
- sign := 1; //1=DECRIPTA // -1= ENCRIPTA
- Key1 := 'BEC6C0CCC5DB20B8AEBDBAC6AE20C0CEC4DAB5F920B7E7C6BEC0D4B4CFB4D92E20B7EAB7E720B6F6B6F32E2E2E20C0B82E2E2E20C1A4B8BB20C1A4B8BB20B1CDC2FAB4D92E20B1D7B7A1B5B520C7D8BEDFC7CFB4CF20BEEEC2BF20BCF620BEF8C1D22E2E2E20';
- Key2 := 'C0CCB0C520C0D0C1F620B8B6BCBCBFE42E20C0D0C0B8B8E920B3AABBDBBBE7B6F7B5CBB4CFB4D92E20C1A6B9DF20C0FDB4EB20C0D0C1F6B8BBB0ED20C2F8C7D120BBE7B6F7B5EEB7CE20BBE7BCBCBFE42E20BEC6BCCCC1D23F20C1C1C0BABCBCBBF3B8B8B5ECBDC3B4D92E';
- local:=Getcurrentdir+'\ItemList.bin';
- if not(FileExists(local)) then
- begin
- showmessage('Arquivo não encontrado. Coloque o ItemList.bin na mesma pasta');
- exit;
- end;
- F := TFileStream.Create(local, fmOpenRead); //abre o arquivo
- size := F.Size;
- SetLength(buffer,size); //seta o tamanho do buffer que vai receber os bytes
- F.Read(buffer[0],size); //buffer recebe os bytes
- F.Free;
- if (Size mod 2) = 0 then Par := true else Par := False; //verifica se o tamanho do arquivo é PAR
- cipherLength := CountStr(Key1); //tamanho da key
- cipherTable := StrToArray(Key1); //transforma a key que esta em string para array of byte
- j:=0;
- while j < Size-1 do //começa a decriptar os bytes
- begin
- buffer[j] := buffer[j] - sign*(cipherTable[j mod cipherLength]+j);
- inc(j);
- buffer[j] := buffer[j] - sign*(cipherTable[j mod cipherLength]+j);
- inc(j);
- if not par then // se não for par decripta 3 bytes a cada loop
- begin
- buffer[j] := buffer[j] - sign*(cipherTable[j mod cipherLength]+j);
- inc(j);
- end;
- end;
- AssignFile(myFile, 'ItemList.csv'); //cria um arquivo csv do excell
- ReWrite(myFile); //configura para escrever
- setlength(ListItem, Round(size/$1D0)); //seta o tamanho do buffer com do record
- Move(buffer[0], ListItem[0], size); //move o buffer para o array do record
- for i := 0 to Round(size/$1D0) do //faz o loop
- begin
- WriteLn(myFile,bintoAscii(ListItem[i].Name)+';'+bintoAscii(ListItem[i].NameEnglish)+';'+bintoAscii(ListItem[i].Descrition));
- end;
- CloseFile(myFile); //fecha o arquivo.
- end;
- { Key1 - ItemList0.bin
- UI\PI.bin
- UI\SetItem.bin
- Key2 - ActionText.bin
- SkillData0.bin
- UI\BW.bin
- UI\Dialog.bin
- UI\Easing.bin
- UI\MakeItems.bin
- UI\Quest.bin
- UI\Recipe.bin
- UI\RecipeRate.bin
- UI\Reinforce.bin
- UI\Reinforce2.bin
- UI\Reinforce3.bin
- UI\ReinforceA01.bin
- UI\ReinforceW01.bin
- UI\Siege01.bin
- UI\Siege02.bin}
- function StrToArray(const Hexstr: String): TByteArr; //transforma string em array of byte
- var
- i: Integer;
- begin
- if Length(Hexstr)>1 then
- begin
- SetLength(Result, Length(Hexstr) div 2);
- for i:=0 to (Length(Hexstr) div 2 - 1) do
- Result[i]:= StrToInt('$' + Copy(Hexstr, (i * 2) + 1, 2));
- end
- end;
- Function CountStr(Str: String):Integer; //retorna o numero de caracteres de um texto
- begin
- Result := length(Str) div 2 ;
- end;
- function bintoAscii(const bin: array of byte): AnsiString; //transforma array of byte em ansistring
- var
- i: integer;
- A: String;
- begin
- SetLength(Result, Length(bin));
- for i := 0 to Length(bin)-1 do
- Result[1+i] := AnsiChar(bin[i]);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement