You are here

How UPX works?

15 posts / 0 new
Last post
Aciago
Aciago's picture
Offline
Last seen: 11 months 3 weeks ago
Joined: 2007-01-24 14:23
How UPX works?

Hi,

I have been downloading and using some "so called Portable Apps" from portablefreeware, and sometimes games... those apps are not really portables but they are self contained in a folder and write to the same folder and don't use the registry, so they can be used as portable... but some of them are huge (i.e. games).

After reading a lot about upx on this forum, I downloaded it and give it a try to reduce the size of those apps.

But my question is... how UPX works? not how to use it (I just downloaded Jazz-upx form here: http://www.rtsoftware.org/) but how it works... I mean, once I UPX and exe file and all the dlls in a folder, when I run that exe, what happens? it just works? or first decompress in a folder I-don't-know and stays there? or decompress in a folder that, after work, disappear? or what?

Thanks in advance for your answers.

EDIT: BTW, I just found this http://www.portablefreeware.com/?id=716, is a portable GUI for UPX

nycjv321
Offline
Last seen: 16 years 2 months ago
Joined: 2006-06-04 15:53
well

Im not entirely sure although I think im fairly right how it works but when you compress an executable file with a exe compressor in this case upx it will compress it using some algorithm to make it smaller(most of the times gotta include the size of the stub if this is the case try FSG another cool PE compressor) and then it will add a stub containing the "decompresser" to the begining of the executable, hope that explains it

Slackware 12 for system
MCP (For XP and Server 2003)
Network + Certified
aim is "nycjv321" (minus quotes)

Aciago
Aciago's picture
Offline
Last seen: 11 months 3 weeks ago
Joined: 2007-01-24 14:23
nop

:s

I didn't understood... imagine that I'm a 4 years old kid and explain it again... Wink

I mean... the compressed exe works (for a normal ignorant user) as the normal exe? is there any problem or I can just use it?

------------------
If a packet hits a pocket on a socket on a port,
and the bus is interrupted as a very last resort,
and the address of the memory makes your floppy disk abort,
then the socket packet pocket has an error to report Biggrin

If a packet hits a pocket on a socket on a port,
and the bus is interrupted as a very last resort,
and the address of the memory makes your floppy disk abort,
then the socket packet pocket has an error to report Biggrin

nycjv321
Offline
Last seen: 16 years 2 months ago
Joined: 2006-06-04 15:53
LOL

o ok
Ummm

"I mean... the compressed exe works (for a normal ignorant user) as the normal exe? is there any problem or I can just use it?"

nope use it and enjoy although I wouldn't in cases were space is not an issue since it does increase memory usage a "tad" (remember upx uses lossless compression so the -d option will restore it to its original size)

"I didn't understood... imagine that I'm a 4 years old kid and explain it again..."
LOL you asked Smile

When an exe is executed it has a "starting point" (Im being simple) with upx it compresses the data of the exe, after the "starting point" were the code(alot of other things data etc... etc...) is and then adds the code at that starting point to decompress it? Does that make sense? So you then end user has nothing to worry about(manual decompression as with sfx's or archives) just a smaller exe to click and use?

Slackware 12 for system
MCP (For XP and Server 2003)
Network + Certified
aim is "nycjv321" (minus quotes)

Aciago
Aciago's picture
Offline
Last seen: 11 months 3 weeks ago
Joined: 2007-01-24 14:23
ok

Now I got it... thanks.

Another question... and when I finish using the exe file and close it, it's all compressed as before?

Yesterday I did a test... since I don't know if PApps are compressed I used an old exe file that I still have in my PDrive and that I know it is not UPX... mirc.exe (v. 6.21), it compressed from 1.98 Mb to 848 Kb, but when double-click nothing happens...

I did the test whit UPX-Tool, UPX-Tool+ and Jazz-UPX... in both three cases nothing happens when click on the exe file... :s

Just to be sure, I double-click in the normal uncompressed mirc.exe and works immediately... what I did wrong?

------------------
If a packet hits a pocket on a socket on a port,
and the bus is interrupted as a very last resort,
and the address of the memory makes your floppy disk abort,
then the socket packet pocket has an error to report Biggrin

If a packet hits a pocket on a socket on a port,
and the bus is interrupted as a very last resort,
and the address of the memory makes your floppy disk abort,
then the socket packet pocket has an error to report Biggrin

nycjv321
Offline
Last seen: 16 years 2 months ago
Joined: 2006-06-04 15:53
...

"Another question... and when I finish using the exe file and close it, it's all compressed as before?"
Yes Everything is decompressed in RAM, (that is why apps compressed with all exe compressors use more RAM)

"Yesterday I did a test... since I don't know if PApps are compressed I used an old exe file that I still have in my PDrive and that I know it is not UPX... mirc.exe (v. 6.21), it compressed from 1.98 Mb to 848 Kb, but when double-click nothing happens..."

Well I use UPX from a Command Prompt (the 1337 way! xD j/k)
go to start>run> type "cmd" (no quotes) then type "cd 'dir upx.exe is located'"
(remember NO QUOTES)remember you can open explorer and copy address location ex. F:\upx and paste it within cmd

so now it would be "cd f:\upx" (no quotes) now press enter now type upx and see if it responds back, if so copy the exe or dll you want to compress and paste it to the directory of upx (or manually specify where the exe is i dont think you want to try :)) now type "upx nameofexe.exe" (remember if u type the name partially u can press "tab" for auto completion feature read the documents (open with notepade :)) within upx directory and look for other switchs to type for example if the exe doesnt compress try "upx -l nameofexe.exe"(to list if it already compressed) or "upx -d nameofexe.exe" (if you want to decompress it to orinally state) or for some exe's where compression matters type "upx --lzma nameofexe.exe" (this compresses it with LZMA format the same format that 7-zip archives use this option ALMOST always gives better compression just a little bit more memory usage)

for "mirc.exe" try the -l switch if it says it might already be compressed or is protected from being compressed (some coders do this to make there exe tamper proof ) then you can compress it the -f switch will sometimes get around this but rarely some exe are just not compatible try the upx forums(if it is not compressed and is not a "suspicious" file (upx will say if it is) and they will say whats went wrong (upx does NOT support .net apps Smile btw) Rememember to read the docs and read the output that upx feeds to you in command prompt.

Slackware 12 for system
MCP (For XP and Server 2003)
Network + Certified
aim is "nycjv321" (minus quotes)

Aciago
Aciago's picture
Offline
Last seen: 11 months 3 weeks ago
Joined: 2007-01-24 14:23
Thanks

I will try that...

If a packet hits a pocket on a socket on a port,
and the bus is interrupted as a very last resort,
and the address of the memory makes your floppy disk abort,
then the socket packet pocket has an error to report Biggrin

Bahamut
Bahamut's picture
Offline
Last seen: 12 years 10 months ago
Joined: 2006-04-07 08:44
for some exe's where

for some exe's where compression matters type "upx --lzma nameofexe.exe" (this compresses it with LZMA format the same format that 7-zip archives use this option ALMOST always gives better compression just a little bit more memory usage)
LZMA does not give better compression. I have tested it thoroughly ever since the option was available, and it has never has been the best method for anything I've tested. Using the --best and --all-methods switches usually gives the best results without taking a long time. --brute and --ultra-brute may produce more compression (there is a very slim chance, though), but it takes a lot longer.

Vintage!

nycjv321
Offline
Last seen: 16 years 2 months ago
Joined: 2006-06-04 15:53
well

what are the sizes of the exes?( exe's bigger then 400kb you should notice a difference Beee If your using small intros 64kb's or exes with data that cant be compressed (ex. portable apps launchers) then of course the compression shouldnt be better. i would recommend FSG for that matter)but your prolly right anyway Smile i always just use -9 if i have to use it. and you havent replied to my last message on this post

Slackware 12 for system
MCP (For XP and Server 2003)
Network + Certified
aim is "nycjv321" (minus quotes)

Bahamut
Bahamut's picture
Offline
Last seen: 12 years 10 months ago
Joined: 2006-04-07 08:44
There's not usually much of

There's not usually much of a difference, but LZMA takes much more memory and time to decompress anyway, so even if LZMA did have better compression, it might not be worth it on older machines.

Vintage!

nycjv321
Offline
Last seen: 16 years 2 months ago
Joined: 2006-06-04 15:53
...

yes true but I was writing the that post aiming it towards newer Machines (past p3 lol anything above p3 and you "shouldn't" notice a difference, and if you do then it is no different(as much as) then the --best switch and now it is time to either upgrade to a newer Pc or go to friends house and steal a better one j/k), As I Said i usually just use the -9 switch, any compression format that has better compression is always going to use more ram, it all depends on the user

Slackware 12 for system
MCP (For XP and Server 2003)
Network + Certified
aim is "nycjv321" (minus quotes)

Bahamut
Bahamut's picture
Offline
Last seen: 12 years 10 months ago
Joined: 2006-04-07 08:44
any compression format that

any compression format that has better compression is always going to use more ram
No. That is a good general rule, but it is not always true (I pointed out in my post that LZMA will almost never provide better compression for UPX). LZMA is a super heavyweight for compression. It will usually have the best compression, but it uses a lot of RAM and is slow. It was designed for general binary files, unlike the other methods UPX uses which are generally more efficient for executables (and also consider decompression speed a priority).

Vintage!

Bahamut
Bahamut's picture
Offline
Last seen: 12 years 10 months ago
Joined: 2006-04-07 08:44
Jazz-UPX includes a very old

Jazz-UPX includes a very old version of UPX. Get the latest version (with the latest docs) at upx.sf.net. The docs included should answer your questions. If you have any more, you should ask the UPX developers.

Vintage!

nycjv321
Offline
Last seen: 16 years 2 months ago
Joined: 2006-06-04 15:53
so

whats wrong with my response? Except for upgrading I said to check docs and talk with the programmers of upx for extra help and more?

Slackware 12 for system
MCP (For XP and Server 2003)
Network + Certified
aim is "nycjv321" (minus quotes)

Bahamut
Bahamut's picture
Offline
Last seen: 12 years 10 months ago
Joined: 2006-04-07 08:44
I missed your post. That's

I missed your post. That's all.

Vintage!

Log in or register to post comments