Here is a small example demonstrating the use of data decompression library functions.




format PE CONSOLE 4.0

include 'include\macro\stdcall.inc'
include 'include\macro\import.inc'
include 'include\Lz32.inc'

section '.data' data readable writeable

mylzfile db 'CrazyWnd.lz',0
output db 'CrazyWnd.exe',0

section '.code' code readable executable

entry start

start:

stdcall decompress,mylzfile,output
invoke ExitProcess,0

proc decompress,LzFile,decompressed
ofs OFSTRUCT
ofd OFSTRUCT
hFileSrc dd ?
hFileDest dd ?
enter
lea eax,[ofs]
invoke LZOpenFile,[LzFile],eax,OF_READ
mov [hFileSrc],eax
lea eax,[ofd]
invoke LZOpenFile,[decompressed],eax,OF_CREATE
mov [hFileDest],eax
invoke LZCopy,[hFileSrc],[hFileDest]
invoke LZClose,[hFileSrc]
invoke LZClose,[hFileDest]
return

section '.idata' import data readable writeable

library kernel,'KERNEL32.DLL',\
lz,'lz32.dll'

kernel:
import ExitProcess,'ExitProcess'

lz:
import LZOpenFile,'LZOpenFileA',\
LZCopy,'LZCopy',\
LZClose,'LZClose'

Posted on 2003-01-13 03:01:39 by Vortex