AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GUI for UPX packer

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Rajat



Joined: 28 Mar 2004
Posts: 1718

PostPosted: Tue Jun 22, 2004 3:52 pm    Post subject: GUI for UPX packer Reply with quote

I kept suffering with the crappy (atleast the ones i happened to use) GUIs available for UPX, the best exe packer around (incidentally used used by AHK too).
About time i wrote my own. Though I'm sure not many ppl will find uses for it as its mostly a power user (geeky?) thing. Much about the same reason why my Address Bar->Cmd prompt script is not used by many : )



It'll remember the preferences from one use to another

Requirements:
UPX
http://upx.sourceforge.net

For easiest usage create a shortcut to this script in sendto folder (type sendto in start menu > run window)


Code:

;___________________________________________
;_______GUI for UPX_________________________

WinTitle = Rajat's UPX GUI Frontend
;___________________________________________

SetFormat, float, 0.2
SetBatchLines, 10ms

ifnotexist, %a_scriptdir%\upx.exe
{
   Msgbox, UPX.exe not found!
   Exitapp
}


input = %1%
ifnotexist, %input%, FileSelectFile, input, 1,, Select File to porcess:
ifnotexist, %input%, exitapp




Gui, Font,  S11 CMaroon Bold, Verdana
Gui, Add, Text, x7 y8 w290 h30, UPX Compressor / Decompressor
Gui, Font, ,
Gui, Add, Button, x37 y48 w90 h30, Compress
Gui, Add, Button, x157 y48 w90 h30, Decompress
Gui, Add, ComboBox, x157 y88 w80 h170 vlev, 1|2|3|4|5|6|7|8|9|-best||
Gui, Add, CheckBox, x17 y118 w130 h20 vres, Compress Resources
Gui, Add, CheckBox, x17 y148 w130 h20 vico, Compress Icons
Gui, Add, CheckBox, x17 y178 w130 h20 vexp, Compress Exports
Gui, Add, CheckBox, x157 y118 w130 h20 vfor, Force Compression
Gui, Add, CheckBox, x157 y148 w130 h20 vrel, Strip Relocations
Gui, Add, CheckBox, x157 y178 w130 h20 vbak, Make Backup
Gui, Add, Text, x7 y208 w290 h30, %input%
Gui, Add, Text, x27 y88 w100 h20, Compression Level :
Gui, Show, x258 y168 h247 w307, %WinTitle%


;getting previous preferences
IniRead, lev, %a_scriptdir%\upx.ini, UPX, Lev
IniRead, res, %a_scriptdir%\upx.ini, UPX, Res
IniRead, ico, %a_scriptdir%\upx.ini, UPX, Ico
IniRead, exp, %a_scriptdir%\upx.ini, UPX, Exp
IniRead, for, %a_scriptdir%\upx.ini, UPX, For
IniRead, rel, %a_scriptdir%\upx.ini, UPX, Rel
IniRead, bak, %a_scriptdir%\upx.ini, UPX, Bak


;loading previous preferences
Control, Choose, %lev%, ComboBox1, %Wintitle%

IfEqual, res, 1, Control, check,, Button3, %WinTitle%
IfEqual, ico, 1, Control, check,, Button4, %WinTitle%
IfEqual, exp, 1, Control, check,, Button5, %WinTitle%
IfEqual, for, 1, Control, check,, Button6, %WinTitle%
IfEqual, rel, 1, Control, check,, Button7, %WinTitle%
IfEqual, bak, 1, Control, check,, Button8, %WinTitle%


Return


GuiClose:
   ExitApp
Return



ButtonCompress:
   Gui, Submit
   Gosub, IniWrite
   SetEnv, cmdline, %cmdline% -%lev%
   
   IfEqual, res, 1, SetEnv, cmdline, %cmdline% --compress-resources=1
   IfEqual, res, 0, SetEnv, cmdline, %cmdline% --compress-resources=0
   
   IfEqual, ico, 1, SetEnv, cmdline, %cmdline% --compress-icons=1
   IfEqual, ico, 0, SetEnv, cmdline, %cmdline% --compress-icons=0

   IfEqual, exp, 1, SetEnv, cmdline, %cmdline% --compress-exports=1
   IfEqual, exp, 0, SetEnv, cmdline, %cmdline% --compress-exports=0
   
   IfEqual, for, 1, SetEnv, cmdline, %cmdline% --force
   
   IfEqual, rel, 1, SetEnv, cmdline, %cmdline% --strip-relocs=1
   IfEqual, rel, 0, SetEnv, cmdline, %cmdline% --strip-relocs=0
   
   
   IfEqual, bak, 1, FileCopy, %input%, %input%.bak
      
   FileGetSize, osize, %input%, k
   envadd, osize, 0.0

   runwait, %comspec% /c %a_scriptdir%\upx.exe %cmdline% "%input%">"%Temp%\upxlog.txt",,hide
   
   FileGetSize, nsize, %input%, k
   envadd, nsize, 0.0
   
   diff = %nsize%
   
   diff *= 100

   diff /= %osize%
   
   StringTrimRight, osize, osize, 3
   StringTrimRight, nsize, nsize, 3
   
   Msgbox, 260, %Label%, Original size`t`t%osize% Kb`nNew size`t`t`t%nsize% Kb`nChange`t`t`t%diff%`%`n`n Do you want to have detailed information?
   IfMsgbox, yes, IfExist, %Temp%\upxlog.txt, run, %Temp%\upxlog.txt
   Exitapp
Return




ButtonDeCompress:
   Gui, Submit
   Gosub, IniWrite
   FileGetSize, osize, %input%, k
   envadd, osize, 0.0

   runwait, %comspec% /c %a_scriptdir%\upx.exe -d "%input%">"%Temp%\upxlog.txt",,hide
   
   FileGetSize, nsize, %input%, k
   envadd, nsize, 0.0
   
   diff = %nsize%
   
   diff *= 100

   diff /= %osize%
   
   StringTrimRight, osize, osize, 3
   StringTrimRight, nsize, nsize, 3
   
   Msgbox, 260, %Label%, Original size`t`t%osize% Kb`nNew size`t`t`t%nsize% Kb`nChange`t`t`t%diff%`%`n`n Do you want to have detailed information?
   IfMsgbox, yes, IfExist, %Temp%\upxlog.txt, run, %Temp%\upxlog.txt
   Exitapp
Return



IniWrite:
   IniWrite, %lev%, %a_scriptdir%\upx.ini, UPX, Lev
   IniWrite, %res%, %a_scriptdir%\upx.ini, UPX, Res
   IniWrite, %ico%, %a_scriptdir%\upx.ini, UPX, Ico
   IniWrite, %exp%, %a_scriptdir%\upx.ini, UPX, Exp
   IniWrite, %for%, %a_scriptdir%\upx.ini, UPX, For
   IniWrite, %rel%, %a_scriptdir%\upx.ini, UPX, Rel
   IniWrite, %bak%, %a_scriptdir%\upx.ini, UPX, Bak
Return   

_________________
Back to top
View user's profile Send private message
Rajat



Joined: 28 Mar 2004
Posts: 1718

PostPosted: Mon Oct 18, 2004 12:31 pm    Post subject: Reply with quote

about time i did it... updated the script to use ahk gui.
_________________
Back to top
View user's profile Send private message
Guest






PostPosted: Sun Feb 05, 2006 5:55 pm    Post subject: Reply with quote

Wow nice script Smile

It's kinda like
http://upxshell.sourceforge.net/
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group