/programs/other/archer/trunk/dump.inc |
---|
File deleted |
/programs/other/archer/trunk/@RCHER.ASM |
---|
1,4 → 1,4 |
; @RCHER - Deflate unpacker v2.0 beta |
; @RCHER - DEflate unpacker v1.0 |
; |
; Written in pure assembler by Ivushkin Andrey aka Willow |
; |
8,17 → 8,15 |
; |
; Compile with FASM |
SYS equ meos |
OUTBUF equ 4*1024*1024 |
png_imag = output+OUTBUF |
PARAM_PTR = os_work;png_image |
MEMINIT=next_code;output |
PARAM_PTR equ png_image |
DUMPFILE equ '/hd/1/out.txt' |
SHOW_RBLOCK equ 0;1 |
SHOW_PNG_SEC equ 0;1 |
SHOW_METH equ 0;1 |
FILE_NUM equ 15;8 |
FILE_NUM equ 0 |
MEMORY equ 0x800000 |
BITS equ 16 |
30,6 → 28,7 |
SHOW_CHARS equ 0 |
BSIZE equ 512 |
INBUF equ BUFSIZE*BSIZE*2 |
OUTBUF equ 4*1024*1024 |
IGNORE_DIRS equ 0 |
MOVE_SLINE_LEV equ 8 |
41,9 → 40,6 |
IPC_MODE equ 100000b |
RAW_MODE equ 1000000b |
THREAD_YES equ 10000000b |
LIST_MODE equ 100000000b |
MEM_MODE equ 1000000000b |
FIND_MODE equ 10000000000b |
if SYS eq win |
format PE console |
61,8 → 57,8 |
dd 0x01 |
dd start |
dd I_END |
dd MEMINIT |
dd main_stack;MEMORY-2048 |
dd MEMORY |
dd MEMORY-2048 |
if PARAM_PTR eq param |
dd 0 |
else |
69,11 → 65,12 |
dd PARAM_PTR |
end if |
dd 0x0 |
include "lang.inc" |
if PARAM_PTR eq param |
param db 'N' |
db '000015' |
db '/hd/1/zip/gz/fasm-1~1.tgz',0 |
param db 'RQ' |
db '000037' |
db '/hd/1/zip/png.zip',0 |
end if |
;match =meos,SYS |
;{ |
80,17 → 77,14 |
include "macros.inc" |
; purge mov |
include "debug.inc" |
include 'dump.inc' |
;} |
end if |
include 'lang.inc' |
language equ lang |
language equ en |
if SYS eq win |
section '.text' code readable executable writeable |
end if |
include "arcmacro.inc" |
include "parser.inc" |
include "deflate.inc" |
113,12 → 107,6 |
mcall 40,10000101b |
; jmp again |
CmdLine |
cmdl: |
test [Flags],LIST_MODE |
jz red |
; Dump [lpath],[lpath_len],os_work |
; ud2 |
red: |
call draw_window |
mcall 12,2 |
146,15 → 134,12 |
mcall -1 |
.noquit: |
mcall 17 |
mcall 64,1,MEMINIT |
QueryFile |
mov [FileNum],FILE_NUM |
and [FileNum],0 |
test eax,eax |
jnz still |
end if |
again: |
; Dump Flags,4,os_work |
mov [fat_],fat |
Newline |
xor eax,eax |
; and [Flags],STAY_MODE |
168,11 → 153,6 |
Msg 14 |
jmp quit |
.sizeok2: |
call KillViewer |
xor eax,eax |
mov ecx,(child_stack-fat)/4 |
mov edi,fat |
rep stosd |
mov [filesize],ebx |
test [Flags],RAW_MODE |
jz .norawm |
233,37 → 213,13 |
jmp exit |
.sizeok1: |
if ~ SYS eq win |
call KillViewer |
end if |
Msg 39 ; unpacking PNG |
mov ecx,[unp_size] |
add ecx,output |
mov [png_],ecx |
mov eax,[PNG_info.Width] |
imul eax,[PNG_info.Height] |
lea eax,[eax+eax*2] |
add ecx,eax |
; dps 'Mem=' |
; dpd ecx |
mcall 64,1 |
test eax,eax |
jz .ok |
Msg 41 |
jmp exit |
.ok: |
Msg 39 |
mov edi,[outp] |
call Deflate.blkbegin |
jmp .defl_end |
.sizeok: |
mov ecx,[unp_size] |
dpd ecx |
add ecx,output |
; mov [png_],ecx |
mcall 64,1 |
test eax,eax |
jz .ok2 |
Msg 41 |
jmp exit |
.ok2: |
call Deflate ; <=========== |
.defl_end: |
test [bits],7 |
296,8 → 252,6 |
pop ecx esi |
jmp .skipAdler |
.skipCRC: |
; dps 'Out=' |
; dpd ecx |
call UAdler |
Msg 10 |
mov eax,[Adler32] |
329,9 → 283,6 |
else |
test [Flags],PNG_MODE |
jnz .nosave |
test [Flags],LIST_MODE |
jnz quit |
test [Flags],TAR_MODE |
jnz .nomsg |
Msg 37 |
338,11 → 289,9 |
.nomsg: |
mov [outfile.out],ebx |
mcall 58,outfile |
; dps 'Before Quit1' |
; ud2 |
test [Flags],TAR_MODE |
jz exit.pad |
; call StartPad |
jnz .nosave |
call StartPad |
.nosave: |
end if |
test [Flags],PNG_MODE |
351,7 → 300,7 |
mov edi,filters |
mov ecx,6 |
rep stosd |
mov edi,[png_] |
mov edi,png_image |
mov esi,output |
;// |
mov [outp],edi |
371,7 → 320,7 |
call RunViewer |
and [arc_base],0 |
and [Flags],STAY_MODE |
; dps 'Before Quit2' |
quit: |
QueryFile |
test eax,eax |
383,10 → 332,7 |
test [Flags],TAR_MODE |
jz .notar |
Msg 37 |
test [Flags],LIST_MODE |
jne quit |
mcall 58,outfile |
.pad: |
call StartPad |
.notar: |
Msg 12 |
406,19 → 352,16 |
else |
jz still |
end if |
; Dump output,255,os_work |
; ud2 |
; mov ecx,dumpf_len |
; mov esi,dumpfile |
; mov edi,filename |
; rep movsb |
; call OpenFile |
; test ebx,ebx |
; jz again.sizebadq |
mov ecx,dumpf_len |
mov esi,dumpfile |
mov edi,filename |
rep movsb |
call OpenFile |
test ebx,ebx |
jz again.sizebadq |
call TarParse |
mov ecx,[FileNum] |
call TarFindN |
; dpd [outfile.size] |
cmp [outfile.size],0 |
jz again.sizebadq |
mov ebx,esi |
/programs/other/archer/trunk/arcmacro.inc |
---|
177,7 → 177,6 |
' ',\ ;38 |
<'®¤£®â®¢ª ¨§®¡à ¦¥¨ï...',13,10>,\ ;39 |
<'ª ¦¨â¥ "R" ¤«ï ®¡à ¡®âª¨ áëàëå ¤ ëå. ⬥ .',13,10>,\ ;40 |
<'¥ å¢ â ¥â ¯ ¬ïâ¨! ⬥ .',13,10>,\ ; 41 |
' ',\ ; |
' ',\ ; |
' ',\ ; |
186,6 → 185,7 |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' <- ¥¨§¢¥áâë© ¬¥â®¤ ᦠâ¨ï',\ ;50 |
' <- § è¨ä஢ ',\ ;51 |
<'¥ ZIP à娢',13,10> ; 52 |
232,7 → 232,6 |
' ',\ ;38 |
<'Preparing bitmap...',13,10>,\ ;39 |
<'Specify "R" to force raw data. Abort.',13,10>,\ ;40 |
<'Not enough memory! Abort.',13,10>,\ ; |
' ',\ ; |
' ',\ ; |
' ',\ ; |
241,6 → 240,7 |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' <- unknown compression method',\ ;50 |
' <- encrypted',\ ;51 |
<'Not a ZIP archive',13,10> ; 52 |
/programs/other/archer/trunk/data.inc |
---|
84,11 → 84,6 |
Dheader rb 12 |
Dpassword rb PASSW_LEN |
png_ dd ? |
fat_ dd ? |
fat_fnum dd ? |
lpath dd ? |
lpath_len dd ? |
png_bpp dd ? |
sline_len dd ? |
IDATcount dd ? |
125,15 → 120,6 |
hclen db ? |
max_len dw ? |
fat: |
rb 4096;512 |
child_stack: |
rb 1024 |
main_stack: |
area: |
rb INBUF |
os_work rb 4*1024 |
bl_count rb BITS |
next_code rw BITS |
157,10 → 143,16 |
Distance rw 32 |
Dist_c rw 32 |
area: |
rb INBUF |
os_work rb 4*1024 |
output: |
;rb OUTBUF |
rb OUTBUF |
;png_image: |
png_image: |
if SYS eq win |
rb OUTBUF |
end if |
/programs/other/archer/trunk/debug.inc |
---|
73,16 → 73,10 |
@@: |
ret |
_debug_crlf db 13, 10, 0 |
macro newline |
{ |
pushf |
pushad |
mov edx, _debug_crlf |
call debug_outstr |
popad |
popf |
dps <13,10> |
} |
macro print message |
/programs/other/archer/trunk/deflate.inc |
---|
128,7 → 128,7 |
end if |
pusha |
xor eax,eax |
mov ecx,(output-bl_count) / 4 |
mov ecx,(area-bl_count) / 4 |
mov edi,bl_count |
rep stosd |
popa |
/programs/other/archer/trunk/macros.inc |
---|
143,6 → 143,9 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 177,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
/programs/other/archer/trunk/parser.inc |
---|
22,86 → 22,12 |
rep movsb |
mov dword[edi],0x00a0d |
call DebugPrint |
; mcall 10 |
; mcall 2 |
popa |
call Add2Fat |
ret |
Add2Fat: |
; edx - ptr, ecx - len |
pusha |
test [Flags],LIST_MODE |
jz .ex |
mov ebp,8 |
mov edi,edx |
lea ebx,[edx+ecx] |
mov ecx,[lpath_len] |
cmp ecx,1 |
je .lbl |
mov esi,[lpath] |
repe cmpsb |
jne .full |
mov eax,[lpath_len] |
sub dword[esp+24],eax;path_len-path |
cmp edi,ebx |
je .full |
mov edx,edi |
.lbl: |
mov ecx,[esp+24] |
mov al,'/' |
repne scasb |
mov eax,[fat_] |
mov ecx,[esp+24] |
jne .nofol |
cmp edi,ebx |
jne .full |
lea ecx,[edi-1] |
sub ecx,edx |
or byte[eax+11],0x10 |
; sub edx,ecx |
.nofol: |
push [fat_fnum] |
pop dword[eax+12] |
mov edi,eax |
mov esi,edx |
.lp1: |
mov bl,[esi] |
lea edx,[eax+ebp] |
inc esi |
cmp bl,'.' |
jne .nodot |
lea edi,[eax+ebp] |
mov ebp,11 |
jmp .ll |
.nodot: |
cmp edi,edx |
jae .ll |
mov [edi],bl |
inc edi |
.ll: |
loop .lp1 |
mov ecx,11 |
dec eax |
.lp2: |
cmp byte[eax+ecx],0 |
jne .no0 |
mov byte[eax+ecx],' ' |
.no0: |
loop .lp2 |
cmp eax,child_stack-1 |
jae .full |
add [fat_],32 |
.full: |
inc [fat_fnum] |
.ex: |
popa |
ret |
;path db '/';'fasm/examples/elfexe/' |
;path_len: |
; Parse routines: |
; out: edx= 0 if all ok, 1 - central dir, 2-EOD |
; 50 - encrypted |
152,19 → 78,16 |
popa |
end if |
Newline |
; Dump fat,160,os_work |
ret |
ZipFindN: |
; ecx - file # |
Msg 33 |
or [Flags],FIND_MODE |
cmp ecx,[file_count] |
jae .err |
push ecx |
call ResetFile |
.nxt: |
call ZipCrawl |
cmp edx,51 |
je .ok2 |
188,7 → 111,6 |
add esi,eax |
mov edx,5 |
.ex: |
and [Flags],-1-FIND_MODE |
push edx |
Msg edx |
pop edx |
237,8 → 159,6 |
cmp byte[edx+ecx-1],'/' |
je .skipdp |
end if |
test [Flags],FIND_MODE |
jnz .skipdp |
call PrintFilename |
.skipdp: |
movzx ecx,word[esi+28] |
332,19 → 252,7 |
mov [PNG_info.Width],eax |
mov eax,[PNG_info.Height] |
bswap eax |
mov ebx,eax |
mov [PNG_info.Height],eax |
call scanline_calc |
; dps 'All=' |
cmp [PNG_info.Color_type],3 |
jne .nopal |
shl eax,3 |
inc eax |
.nopal: |
inc eax |
imul eax,ebx |
mov [unp_size],eax |
; dpd eax |
add esi,25 |
cmp byte[esi-5],0 |
rep_err e,52,29 |
515,8 → 423,7 |
ret |
TarParse: |
mov esi,output |
; call ResetFile |
call ResetFile |
.nxt: |
call TarCrawl |
; wait |
529,9 → 436,8 |
inc [file_count] |
.skipinc: |
add eax,ecx |
; mov ebx,1 |
add esi,eax |
; call FileSeek |
mov ebx,1 |
call FileSeek |
jmp .nxt |
TarFindN: |
541,8 → 447,7 |
cmp ecx,[file_count] |
jae .err |
push ecx |
mov esi,output |
; call ResetFile |
call ResetFile |
.nxt: |
call TarCrawl |
if IGNORE_DIRS eq 1 |
556,9 → 461,8 |
dec dword[esp] |
.seek: |
add eax,ecx |
; mov ebx,1 |
add esi,eax |
; call FileSeek |
mov ebx,1 |
call FileSeek |
jmp .nxt |
.err: |
mov edx,4 |
655,8 → 559,13 |
.err: |
ret |
scanline_calc: |
movzx ecx,byte[PNG_info.Color_type] |
; Created: May 31, 2005 |
FiltCall: |
dd PngFilter.nofilt,Filt_sub,Filt_up,Filt_av,Filt_paeth,PngFilter.nofilt |
PngFilter: |
; esi - filtered uncompressed image data |
; edi - destination |
mov cl,[PNG_info.Color_type] |
mov eax,1 |
cmp cl,3 |
je .palette |
685,15 → 594,6 |
jnz .noz2 |
inc eax |
.noz2: |
ret |
; Created: May 31, 2005 |
FiltCall: |
dd PngFilter.nofilt,Filt_sub,Filt_up,Filt_av,Filt_paeth,PngFilter.nofilt |
PngFilter: |
; esi - filtered uncompressed image data |
; edi - destination |
call scanline_calc |
mov [sline_len],eax ; scanline length |
push edi |
and [Flags],not 1 |
/programs/other/archer/trunk/sys.inc |
---|
105,7 → 105,7 |
else |
test [Flags],THREAD_YES |
jnz .ex |
mcall 51,1,thread,child_stack;MEMORY |
mcall 51,1,thread,MEMORY |
mov [child],eax |
end if |
.ex: |
191,7 → 191,7 |
mov ecx,[PNG_info.Width] |
shl ecx,16 |
add ecx,[PNG_info.Height] |
mcall 7,[png_],,10 shl 16+25 |
mcall 7,png_image,,10 shl 16+25 |
mcall 12,2 |
.still: |
mcall 10 |
208,7 → 208,6 |
jne .still |
.close: |
and [child],0 |
mcall 64,1,MEMINIT |
mcall -1 |
KillViewer: |
257,68 → 256,7 |
mov ecx,255 |
mov edi,filename |
rep movsb |
; test [Flags],LIST_MODE |
; jz again |
xor eax,eax |
mov edi,filename |
mov ecx,255 |
repne scasb |
cmp byte[edi-2],'/' |
je .slash |
mov byte[edi-1],'/' |
inc edi |
.slash: |
; Dump filename,255,os_work |
; ud2 |
mov ecx,edi |
; dec ecx |
mov edx,ecx |
mov dword[Finfo],13 |
; mov dword[Finfo.count],1 |
mov edi,filename+5 |
sub ecx,edi |
.lp: |
mov al,'/' |
repne scasb |
; jne .ex |
; dpd ecx |
and byte[edi-1],0 |
mcall 58,Finfo |
mov byte[edi-1],'/' |
test ebx,32 |
jz .lp |
test [Flags],LIST_MODE |
jne .listm |
and byte[edi-1],0 |
; Dump filename,255,os_work |
jmp .agg |
; ud2 |
.listm: |
lea esi,[edi-1+ecx] |
lea edi,[esi+1] |
std |
rep movsb |
and byte[edi],0 |
cld |
; dpd filename |
inc edi |
dpd edi |
cmp edx,edi |
jne .slash2 |
; cmp byte[edi],'/' |
; je .slash2 |
mov byte[edi],'/' |
inc edx |
.slash2: |
sub edx,edi |
mov [lpath],edi |
mov [lpath_len],edx |
dpd edx |
.agg: |
mov dword[Finfo],0 |
; ud2 |
jmp again;cmdl |
jmp again |
.yespar: |
cmp al,'N' |
jne .nonum |
362,10 → 300,6 |
call get_6ASCII_num |
jmp .fofs |
.noofs2: |
cmp al,'L' |
jne .nolist |
or [Flags],LIST_MODE |
.nolist: |
jmp .parse |
get_6ASCII_num: |
385,20 → 319,8 |
} |
StartPad: |
; mcall 19,editorcmd,dumpfile |
pusha |
mov esi,[outfile.size] |
; dpd esi |
mov [par_fsize],esi |
mcall 19,editorcmd,editor_par |
mov ecx,eax |
mcall 5,20 |
mcall 60,2,,[outfile.out];output |
mcall 64,1,MEMINIT |
popa |
mcall 19,editorcmd,dumpfile |
ret |
editorcmd db 'TINYPAD ' |
editor_par db '*' |
par_fsize dd ? |
end if |