Author Topic: File Packing  (Read 7762 times)

0 Members and 1 Guest are viewing this topic.

Offline Blaze

  • x86
  • Hero Member
  • *****
  • Posts: 7136
  • Canadian
    • View Profile
    • Maide
File Packing
« on: September 05, 2005, 07:48:26 pm »
How does file packing work? I've searched google and haven't found anything other then SP2 fixes :-\.

I'm working on a project similiar to winzip/rar for the fun/experience and I'm wondering if its amazingly difficult or not..
And like a fool I believed myself, and thought I was somebody else...

Offline Newby

  • Moderator
  • Hero Member
  • *****
  • Posts: 10877
  • Thrash!
    • View Profile
Re: File Packing
« Reply #1 on: September 05, 2005, 07:59:07 pm »
Check out this document. It might help you.
- Newby
http://www.x86labs.org

Quote
[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: File Packing
« Reply #2 on: September 05, 2005, 08:14:38 pm »
I wrote a little packing thing called JoPaQ (ripped from MoPaQ (MPQ)) once. It was pretty simple.

(DWORD) Number of Files
For each file {
  (DWORD) Name Length (word?)
  (VOID) File Name
  (DWORD) File Length (might want to make this a qword, whatever)
  (VOID) File Data
}

The DWORD+VOID combination is somewhat of a pascal string. I still have the code laying arround somewhere, although it never really worked.
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: File Packing
« Reply #3 on: September 06, 2005, 03:22:02 pm »
google://huffman encoding

Huffman encoding is compression, not packing, but I assume that's what you're looking for. 

Offline Koga73

  • Newbie
  • *
  • Posts: 19
  • I'm new here!
    • View Profile
Re: File Packing
« Reply #4 on: September 14, 2005, 10:26:58 pm »
Well, if your looking for a packer (itll recude the size of exes, works great, the exe will still run normally once packed), look up a program called UPX or ProcDump. And as for file compression, search for RLE, run length encryption. It works good for files with lots of repeats, such as:

111111111123456
becomes
10~123456

simple

Offline Blaze

  • x86
  • Hero Member
  • *****
  • Posts: 7136
  • Canadian
    • View Profile
    • Maide
Re: File Packing
« Reply #5 on: September 14, 2005, 10:36:05 pm »
...?
And like a fool I believed myself, and thought I was somebody else...

Offline Koga73

  • Newbie
  • *
  • Posts: 19
  • I'm new here!
    • View Profile
Re: File Packing
« Reply #6 on: September 14, 2005, 10:51:55 pm »
ok, you read the binary of a file your wanting to compress. Then, you look for areas that have 4 or more of the same character all next to each other, so lets say you load it in as binary, and you see the following:

abcddddddddefghhhhijklmnnnnnnopqrstuvwxyzzzzzz

Well, using rle, you would make it:

abc8~defg4~hijklm6~nopqrstuvwxy6~z

It reduced the size from 47 characters to 34.

So, now, save the file as a .BLZ or something, lol. Then, to make the file usable again... go thro, and reexpand all the stuff you compressed.

Thats for the compression part, as for packing files and making a bunch of files into one... just take each individual files biary, and put it all into one file. The depacker will just rebreak it apart into many files.

Offline Blaze

  • x86
  • Hero Member
  • *****
  • Posts: 7136
  • Canadian
    • View Profile
    • Maide
Re: File Packing
« Reply #7 on: September 15, 2005, 12:04:33 am »
I  understood what you orginally posted..  :-[

I was just wondering why you were suggesting I use another program.  I also don't think rle is very realalistic for using on excutable.
And like a fool I believed myself, and thought I was somebody else...

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: File Packing
« Reply #8 on: September 15, 2005, 12:51:19 am »
I also don't think rle is very realalistic for using on excutable.

It's not.

Offline Koga73

  • Newbie
  • *
  • Posts: 19
  • I'm new here!
    • View Profile
Re: File Packing
« Reply #9 on: September 20, 2005, 03:33:49 pm »
i just figured id mention some exe compressors, there pretty cool. They can comperss an exe, and the exe can still run perfectly without havign to be decompressed. How do these work?

UPX and ProcDump are some examples.

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: File Packing
« Reply #10 on: September 20, 2005, 06:05:12 pm »
i just figured id mention some exe compressors, there pretty cool. They can comperss an exe, and the exe can still run perfectly without havign to be decompressed. How do these work?

UPX and ProcDump are some examples.

I suppose it would depend on the operating system.  If it had a feature that detected and decrompressed the file data on the fly when it detected it was compressed, that would work.  Test the execution speeds of the same programs compressed and un-compressed and see if they're around the same.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: File Packing
« Reply #11 on: September 20, 2005, 08:49:34 pm »
i just figured id mention some exe compressors, there pretty cool. They can comperss an exe, and the exe can still run perfectly without havign to be decompressed. How do these work?

UPX and ProcDump are some examples.

I suppose it would depend on the operating system.  If it had a feature that detected and decrompressed the file data on the fly when it detected it was compressed, that would work.  Test the execution speeds of the same programs compressed and un-compressed and see if they're around the same.

Generally, they're uncompressed when they're loaded.  So the load time will be slightly higher, but the overall run time will be mostly the same. 

Offline rabbit

  • x86
  • Hero Member
  • *****
  • Posts: 8092
  • I speak for the entire clan (except Joe)
    • View Profile
Re: File Packing
« Reply #12 on: September 20, 2005, 09:28:21 pm »
Yep.  The file is compressed into itself with instructions of how to decompress the file when it runs, then run it (instead of just running).  I love UPX :P

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: File Packing
« Reply #13 on: September 20, 2005, 10:44:43 pm »
Generally, they're uncompressed when they're loaded.  So the load time will be slightly higher, but the overall run time will be mostly the same. 
Sorry, that's what I meant.