Showing posts with label compression. Show all posts
Showing posts with label compression. Show all posts

20 April 2013

A Simple BAT to EXE Wrapper

I'm looking for a straightforward way to execute bat file inside bash and vice versa (execute shellscript in cmd box). At first I thinking about an encrypter that store content of batch file as string that later feed into shell invocation. But that's appear to be daunting to me right now :-D

I look around sourceforge and codeplex for existing solution, as expected there are several project based on 7z sfx but all of them (sorry if I missed) popped up new cmd window and can't work when called from PATH environment (aka different Curernt Directory).

So I decide to take 7zip SFX source code and apply some patches:

- To have 3 predefined environment variables replacement at RunProgram:
   %%T=temp directory where bat file extracted (supplied by oficial 7zip)
   %%S=path where sfx module located that is the exe file (similar to 7zsfxmod)
   %%W=path of current directory where sfx called (this is what I need)
- Assign CreateProcess's ApplicationName as COMSPEC environment
- Disabling progress bar, thus no need to set Progress="no"
- Redirect IO and prevent popped up windows as described in SO question here
- Finally, Change the sfx's submodule from gui to console using editbin or postw32 (of freepascal)

And it works :) (for my case)

Here you go:
http://osspack32.googlecode.com/files/7zSDcon.sfx

the patched main.cpp of SFXsetup (CPP) and the example converted bat (my old app Cabit, a Cabinet archiver):
http://osspack32.googlecode.com/files/cabit.exe
it use config file:

;!@Install@!UTF-8!
RunProgram="/c cd /d %%W && %%T\\cabit.bat "
;!@InstallEnd@!

Meaning after extraction run cabit.bat under the corrected working directory. Also note the extra space after the bat filename is important otherwise argument will not passed.
Then as usual do copy /b  7zSDcon.sfx+config.7z+cabit.7z cabit.exe

Unfortunately Igor Pavlov haven't publish the source code of his super small sfx (only 27kb) otherwise it would be neater.

I might gonna make sfxmaker or sort of with PE resource/icon insertion ability. Should be easy using wrc and linkres2exe tools.

13 August 2011

7zsfx with dirid

I build custom 7zip SFX with complete DIRID <-> CSIDL conversion
binary is based on 1.500.2100 beta branch, browse here -> http://svn.7zsfx.info

with this conversion (see stickies here) I can use for example:
proper registry injection:
reg add HKLM\bla\bla /v configfile /t REG_SZ /d "%16412%\something.txt"
service creation:
sc create daemon binpath= %11%\something.sys type= kernel start= boot DisplayName= blablabla
or any proper file operation... therefore could no longer rely on inf script

12 November 2010

Two monster that beat 7-zip

This is just a remark for my experience way back 5 years ago. That time I just barely heard about 7-zip and found a monster called WinRK (still in version 2.16). I conduct a benchmark (just a little) to my amusement today.

The test file is unfortunately just one: emule.exe (damn that WinRK is too slow for my processor). Here is:

emule 0.50 : 5.49MB
WinRK : 1.25MB
Uharc : 1.65MB
7-zip : 1.68MB
WinRAR : 1.79MB

All set at best (slowest) setting, WinRK did insane deep analysis for an exe file and took 6 min. to complete! (not multi-threaded) while game warez cracker's de-facto choice UHARC is the one that better with a little time overhead. I choose Emule because it is already a composite file, have few megabytes of unicode text, dozens bitmap images and the binary itself. Zip and BZip2 result is more than 2MB.

Analysis did take important part of compressing especially in solid mode. While 7-zip and others separate executable from data file by file extension (not by actual content) then sorted based on similarity (again only by filename) this often lead to inefficiency (in compression not time) due to mis-detection unless you came up with your own filelist. WinRK took this seriously, maybe their compression method isn't much better than LZMA (7zip) but their analysis did! It has some passes where it will chop most file into more edible chunks before compressing like no others. Imagine if I had to compress the whole Gimp with WinRK! probably will take the whole night :)) on my E2160.

If you are someone with obsessive-compulsive personality disorder try WinRK! maybe version 3 have multithreaded support? (note: it's not free)

16 June 2010

CabIt : A Re-Interface of Makecab and Expand

Recently during updating my unattended Windows XP CD, I create a small utility (eek written in batch) called CabIt. That time I try to achieved a much compressed DRIVER.CAB for the CD and find out that cabtool (an opensource utility) didn't satisfied me.

Later I'm puzzling with makecab.exe a builtin tool in Windows to create Cabinet file. No luck.. it always generate *.??_ file :(  only after googling a while I found Cabinet SDK from M$ that dated way back in 1997!

But guess what I found? Cabinet format indeed support "solid archiving" at that time! "Solid" which is a (marketing) term that popularized by WinRAR and followed by 7Zip is what M$ called (an ambiguous term) "folder" to explain the same functionality (Compressing a set of files as a union). Also I found out detailed info how to make a DDF file that needed by makecab.exe to properly produce .cab file. So CabIt is born, basically as an automatic DDF generator.

02 September 2009

7-Zip 9.07 beta LZMA2 vs LZMA

Being fully supported through compression method option, lzma2 has the same setting as older LZMA. And its time for some test. I prepare a set of files in which contained a lot of binary, a huge english dictionary plain text, some html, couple of waves and few already compressed file.

The fileset size before compression is 199MB (1822 files)
My System : E2160 Oced at 2,9Ghz; 2GB DDR2-667; rAID0 HHD on XP-32

with LZMA (ultra)
time: 1:41
compressed: 57.4MB

with LZMA2 (ultra)
time: 1:39
compressed: 57.3MB

A very slightly faster and better :D, but it still beta anyway and afterall both beat rar/zip/bz2/gzip by far.

02 August 2009

7-Zip 9 beta has new LZMA2 format

After trying the beta version for about 2 month. I just recently know that it support .xz extension (use LZMA2 compression). Later it revealed that .xz only available when we compress single file that's why I kind of skip that new format.

Interesting enough the LZMA2 didn't have advantage over old LZMA (.7z). In my test regardless the file type (plain-text or binary) LZMA2 result is on par with LZMA infact in some binary (Mplayer.exe file) LZMA beat the new format a bit. Worse, LZMA2 required more than twice memory (a mere 2GB) at the same "maximum" setting.

Maybe this is why 7-zip 9 still in beta. We should wait then...