Jump to content

[How To]: Send To>UPX Compression for EXEs


Recommended Posts

This is a consecuence of the thread "Hacking WinRAR SFX for customized installers".

Well you are a fanatic of "hex editing" or "resource hacking" so you'll find interesting the idea of a Send To> shortcut for UPX compression. You just need to download UPX for Windows and place UPX.EXE on System32. Then place the next 2 batch files on "%USERPROFILE%\SendTo".

For MakeUPX.cmd

@ECHO OFF
@ECHO.
SET EXT=%~x1
SET LCEXT=%EXT:~-1%
SET FSIZE=%~z1
IF %FSIZE%==0 GOTO END
:COMPRESS

%WINDIR%\SYSTEM32\UPX.EXE -k --best --crp-ms=999999 --force %1
:END

For ExpandUPX.cmd

@ECHO OFF
@ECHO.
SET EXT=%~x1
SET LCEXT=%EXT:~-1%
SET FSIZE=%~z1
IF %FSIZE%==0 GOTO END
:DECOMPRESS
%WINDIR%\SYSTEM32\UPX.EXE -k -d --force %1

:END

Options:

-k: switch will keep a backup of your original file like "file.xyz > file.xy~"

--force: will force de comp./decomp. of your original file

:END: down this line you can place a PAUSE line to see the result, errors and ratio.

Unattended:

You can place the files unattended by locating UPX.EXE on "$OEM$\$$" and "$Docs\YourUsername" but this last is known to have some problems so let me recommend to create a RAR-SFX archive or a self-destructing batch file to copy both cmds.

Hope that it is clear enough :). If you are interested on a direct rightclick menu entrie contact me, it will be easy.

Credits:

Well I personally don't like to have any credit on those things, first because I only had the idea and based it on a @jdoe's similar code ("Send To>MakeCAB") and @totoymola's thread :P

Edited by SiMoNsAyS
Link to comment
Share on other sites


@MCT true, you don't need it. it's just to prevent a "possible issue" and because the original code had it :P .

edit: this opens a new world in the unattended installations as RAR-SFX and 7ZIP-SFX did... i've reduced my firefox.exe file from 6mb to 2mb :blink: , once compressed on a rar it only saves a few kb but is a nice way to start...

Edited by SiMoNsAyS
Link to comment
Share on other sites

However, I don't know the purpose of this switch.

--crp-ms=999999

me neither :P

i just found it googl'ing here. i used the same command line as the script did for a win32 app and supposed it will work better :whistle:

edit: @MCT try to add a PAUSE at the end of the script to see what happens :}

Link to comment
Share on other sites

this opens a new world in the unattended installations as RAR-SFX and 7ZIP-SFX did... i've reduced my firefox.exe file from 6mb to 2mb :blink: , once compressed on a rar it only saves a few kb but is a nice way to start...

Nice, but keep this in mind:

1. A UPX'ed file will run slower.

2. If you will anyway RAR/7zip some file, then don't UPX it (because that will lead to recursive compression, thereby increasing total file size).

For example, if RARing a file of 6 MB makes it deflate to 3.5 MB, UPXing that file and then RARing it will result in 4 MB (i.e., not as small as it could have been if directly RAR'ed).

Link to comment
Share on other sites

@MCT :o , strange those switches works perfect for me

@totoymola, maybe it ignores the -k switch because you used the shortcut and not the .cmd file :unsure:

@prathapml:

1) slower... maybe, but i preffer to open a program 1 sec later and save 4mb. the term slower does not make justice on nowdays computer ;)

2) the mainly use of that information is the ability to reduce an .exe non-rared setup.

i won't use it to reduce all of my installed programs, i want to reduce setups and it will be very helpful.

about the compression ratio, well firefox.exe got down from ~6mb to ~2mb and the original xpi (firefox inside) was ~4mb and after UPX ~3,9mb so size got decresed but not too much.

@bucketbuster, yeah i observed it on some .exe files. icon got compressed to and "disappeared", that's why i recommend to use UPX'ing with installers and not main programs :whistle:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...