Register for your free account! | Forgot your password?

You last visited: Today at 21:00

  • Please register to post and access all features, it's quick, easy and FREE!

 

[Source - Delphi]Compress/Decompress *.enc files

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Oct 2007
Posts: 54
Received Thanks: 15
[Source - Delphi]Compress/Decompress *.enc files

Decompress and Compress works 100% corect!

Keys:
Code:
const
  Xorkey: array [0 .. 3] of Byte = ($92, $65, $67, $57);
Decompress:
Code:
procedure DecompressFile(const SourceFile, DestFile: string);
var
  SourceStream: TStream;
  ZLibStream: TStream;
  DestStream: TStream;
  DecSize: Cardinal;
  Ms: TStream;
  i: Integer;
  Data: TBytes;
  MsOut: TStream;
begin
  SourceStream := TFileStream.Create(SourceFile, fmOpenRead);
  Ms := TMemoryStream.Create;
  MsOut := TMemoryStream.Create;

  Ms.CopyFrom(SourceStream, SourceStream.Size);
  Ms.Position := 0;

  SetLength(Data, Ms.Size);
  Ms.Read(Data[0], Ms.Size);
  DecSize := PDword(@Data[0])^;

  for i := 0 to 3 do
   Data[i + 4] := Data[i + 4] xor Xorkey[i mod 4];

  MsOut.Size := Length(Data);
  MsOut.Write(Data[0], Length(Data));
  MsOut.Position := 4;
  try
    ZLibStream := TZDecompressionStream.Create(MsOut, -15);
    try
      DestStream := TFileStream.Create(DestFile, fmCreate or fmShareExclusive);
      try
        ZLibStream.Read(Data[0], SizeOf(DecSize));
        DestStream.Write(Data[0],SizeOf(DecSize));
        DestStream.CopyFrom(ZLibStream, DecSize -4);
      finally
        DestStream.Free;
      end;
    finally
      ZLibStream.Free;
    end;
  finally
    SourceStream.Free;
    Ms.Free;
    MsOut.Free;
  end;
end;
Compress:
Code:
procedure CompressFile(const SourceFile, DestFile: string);
var
  SourceStream: TStream;
  ZLibStream: TStream;
  DestStream: TStream;
  DecSize, FixShit: Integer;
  i: Integer;
  Data: TBytes;
begin
  SourceStream := TFileStream.Create(SourceFile, fmOpenRead);
  try
    DecSize := SourceStream.Size;
    DestStream := TFileStream.Create(DestFile, fmCreate or fmShareExclusive);

    DestStream.Write(DecSize,SizeOf(DecSize));
    try
      ZLibStream := TZCompressionStream.Create(DestStream, zcFastest , -15, 8, zsDefault);
      try
       repeat
        FixShit := SourceStream.Read(DecSize, SizeOf(DecSize));
        ZLibStream.Write(DecSize, FixShit);
       until FixShit = 0;
      finally
        ZLibStream.Free;
      end;

      SetLength(Data, DestStream.Size);
      DestStream.Position := 0;
      DestStream.Read(Data[0],Length(Data));
      DestStream.Position := 0;

       for i := 0 to 3 do
        Data[i + 4] := Data[i + 4] xor Xorkey[i mod 4];

      DestStream.Write(Data[0],Length(Data));
    finally
      DestStream.Free;
    end;
  finally
    SourceStream.Free;
  end;
end;
Code:
uses
 ZLibEx;
U need ZLibex.pas and u can download it from link below:
Code:
http://www.base2ti.com/?id=delphi.zlib
Credits for shore only me (Gunz) r Mauka @Rz

You must register and activate your account in order to view images.

Atached binary file (WIP - Work in Progress)!
Attached Files
File Type: rar Project7.rar (323.4 KB, 690 views)



krotkin is offline  
Thanks
3 Users
Old   #2
 
elite*gold: 20
Join Date: Apr 2008
Posts: 2,929
Received Thanks: 1,755
Moved to pserver dev.


PunkS7yle is offline  
Thanks
1 User
Old   #3
 
elite*gold: 0
Join Date: Oct 2007
Posts: 54
Received Thanks: 15
Fixe Compression and updated tool

Code:
procedure CompressFile(const SourceFile, DestFile: string);
var
  SourceStream: TStream;
  ZLibStream: TStream;
  DestStream: TStream;
  DecSize, FixShit: Integer;
  i: Integer;
  Data: TBytes;
begin
  SourceStream := TFileStream.Create(SourceFile, fmOpenRead);
  try
    DecSize := SourceStream.Size;
    DestStream := TFileStream.Create(DestFile, fmCreate or fmShareExclusive);

    DestStream.Write(DecSize,SizeOf(DecSize));
    try
      ZLibStream := TZCompressionStream.Create(DestStream, zcFastest , -15, 8, zsDefault);
      try
       repeat
        FixShit := SourceStream.Read(DecSize, SizeOf(DecSize));
        ZLibStream.Write(DecSize, FixShit);
       until FixShit = 0;
      finally
        ZLibStream.Free;
      end;

      SetLength(Data, DestStream.Size);
      DestStream.Position := 0;
      DestStream.Read(Data[0],Length(Data));
      DestStream.Position := 0;

       for i := 0 to 3 do
        Data[i + 4] := Data[i + 4] xor Xorkey[i mod 4];

      DestStream.Write(Data[0],Length(Data));
    finally
      DestStream.Free;
    end;
  finally
    SourceStream.Free;
  end;
end;
Have fun with it!

Finished and tool
Attached Files
File Type: rar F_F.rar (324.2 KB, 366 views)
krotkin is offline  
Old   #4
 
elite*gold: 0
Join Date: Dec 2010
Posts: 7
Received Thanks: 0
May i ask what is the purpose of compress/decompress?


takashi92000 is offline  
Old   #5
 
elite*gold: 0
Join Date: Jan 2011
Posts: 2
Received Thanks: 0
What is it ?
iloveyby is offline  
Old   #6
 
elite*gold: 0
Join Date: Nov 2010
Posts: 11
Received Thanks: 0
is this for borland delphi file?this is for what?unpack?
1234nick is offline  
Old   #7
 
elite*gold: 0
Join Date: May 2011
Posts: 43
Received Thanks: 2
GUYS PLEASE XD I DONT KNOW HOW I GET THESE XOR's OR "Key's"
PLEASE PLEASE PLEASE give me the XOR for Cabal Moon Night XD PLEAAAAAAASE ^^


BLINDROCK is offline  
Reply



« Previous Thread | Next Thread »

Similar Threads
I need Metin2 AutoAttack (Delphi Source Code)
I need Delphi Source Code to Metin2 AutoAttack help me please
11 Replies - General Coding
[DELPHI] Source: FaceTarget (WoW)
Hi there, ive made a lil code to Face (and turn camera) to the selected Target (GUID) by doing Math ;) maybe some1 needs this. (i'm using it...
1 Replies - General Coding
BOI SpeedHack with Source (Delphi coded)
hi @ all i got an idea to make my own speedhack what is multiclent complatible :D // edit // new pointers does not work, i'll try to fix this ...
16 Replies - Battle of the Immortals
how to compress .epk files?
hi i need to copress .epk files for metin2 i have allready extrated them any one can help? thanks
2 Replies - Video Art
How to Compress again files. EPK. EIX.
I was extracted and edited some files, now i wanna compress it to EPK and replace for orgiginal one. How to do it?
7 Replies - Metin2 Main - Discussions / Questions



All times are GMT +1. The time now is 21:00.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2017 elitepvpers All Rights Reserved.