Subversion Repositories Kolibri OS

Rev

Rev 139 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 139 Rev 485
1
; @RCHER - Deflate unpacker v2.0 beta
1
; @RCHER - Deflate unpacker v2.0 beta
2
;
2
;
3
; Written in pure assembler by Ivushkin Andrey aka Willow
3
; Written in pure assembler by Ivushkin Andrey aka Willow
4
;
4
;
5
; Created: May 6, 2005
5
; Created: May 6, 2005
6
;
6
;
7
; Last changed: August 26, 2006
7
; Last changed: August 26, 2006
8
;
8
;
9
; Compile with FASM
9
; Compile with FASM
10
 
10
 
11
SYS equ meos
11
SYS equ meos
12
OUTBUF equ 4*1024*1024
12
OUTBUF equ 4*1024*1024
13
png_imag = output+OUTBUF
13
png_imag = output+OUTBUF
14
PARAM_PTR = os_work;png_image
14
PARAM_PTR = os_work;png_image
15
MEMINIT=next_code;output
15
MEMINIT=next_code;output
16
DUMPFILE equ '/hd0/1/out.txt'
16
DUMPFILE equ '/hd0/1/out.txt'
17
 
17
 
18
SHOW_RBLOCK equ 0;1
18
SHOW_RBLOCK equ 0;1
19
SHOW_PNG_SEC equ 0;1
19
SHOW_PNG_SEC equ 0;1
20
SHOW_METH equ 0;1
20
SHOW_METH equ 0;1
21
FILE_NUM equ 15;8
21
FILE_NUM equ 15;8
22
MEMORY equ 0x800000
22
MEMORY equ 0x800000
23
 
23
 
24
BITS equ 16
24
BITS equ 16
25
BUFSIZE equ 32
25
BUFSIZE equ 32
26
BUFPTR equ area
26
BUFPTR equ area
27
 
27
 
28
PASSW_LEN equ 32
28
PASSW_LEN equ 32
29
NO_STOPS equ 1
29
NO_STOPS equ 1
30
SHOW_CHARS equ 0
30
SHOW_CHARS equ 0
31
BSIZE equ 512
31
BSIZE equ 512
32
INBUF equ BUFSIZE*BSIZE*2
32
INBUF equ BUFSIZE*BSIZE*2
33
IGNORE_DIRS equ 0
33
IGNORE_DIRS equ 0
34
 
34
 
35
MOVE_SLINE_LEV equ 8
35
MOVE_SLINE_LEV equ 8
36
 
36
 
37
DECRYPT_MODE equ 100b
37
DECRYPT_MODE equ 100b
38
PNG_MODE equ 10b
38
PNG_MODE equ 10b
39
TAR_MODE equ 1000b
39
TAR_MODE equ 1000b
40
STAY_MODE equ 10000b
40
STAY_MODE equ 10000b
41
IPC_MODE equ 100000b
41
IPC_MODE equ 100000b
42
RAW_MODE equ 1000000b
42
RAW_MODE equ 1000000b
43
THREAD_YES equ 10000000b
43
THREAD_YES equ 10000000b
44
LIST_MODE equ 100000000b
44
LIST_MODE equ 100000000b
45
MEM_MODE equ 1000000000b
45
MEM_MODE equ 1000000000b
46
FIND_MODE equ 10000000000b
46
FIND_MODE equ 10000000000b
47
 
47
 
48
if SYS eq win
48
if SYS eq win
49
format PE console
49
format PE console
50
entry start
50
entry start
51
;match =win,SYS
51
;match =win,SYS
52
;{
52
;{
53
;    include 'D:\Ivushkin\projects\fasmw\INCLUDE\win32a.inc'
53
;    include 'D:\Ivushkin\projects\fasmw\INCLUDE\win32a.inc'
54
;}
54
;}
55
else
55
else
56
use32
56
use32
57
 
57
 
58
  org    0x0
58
  org    0x0
59
 
59
 
60
  db     'MENUET01'
60
  db     'MENUET01'
61
  dd     0x01
61
  dd     0x01
62
  dd     start
62
  dd     start
63
  dd     I_END
63
  dd     I_END
64
  dd     MEMINIT
64
  dd     MEMINIT
65
  dd     main_stack_top;MEMORY-2048
65
  dd     main_stack_top;MEMORY-2048
66
if  PARAM_PTR eq param
66
if  PARAM_PTR eq param
67
  dd     0
67
  dd     0
68
else
68
else
69
  dd     PARAM_PTR
69
  dd     PARAM_PTR
70
end if
70
end if
71
  dd     0x0
71
  dd     0x0
72
 
72
 
73
if  PARAM_PTR eq param
73
if  PARAM_PTR eq param
74
  param db 'N'
74
  param db 'N'
75
  db '000015'
75
  db '000015'
76
  db '/hd/1/zip/gz/fasm-1~1.tgz',0
76
  db '/hd/1/zip/gz/fasm-1~1.tgz',0
77
end if
77
end if
78
;match =meos,SYS
78
;match =meos,SYS
79
;{
79
;{
80
    include "macros.inc"
80
    include "..\..\..\macros.inc"
81
;    purge mov
81
;    purge mov
82
    include "debug.inc"
82
    include "debug.inc"
83
    include 'dump.inc'
83
    include 'dump.inc'
84
;}
84
;}
85
end if
85
end if
86
 
86
 
87
include 'lang.inc'
87
include 'lang.inc'
88
language equ lang
88
language equ lang
89
 
89
 
90
if SYS eq win
90
if SYS eq win
91
section '.text' code readable executable writeable
91
section '.text' code readable executable writeable
92
end if
92
end if
93
 
93
 
94
include "arcmacro.inc"
94
include "arcmacro.inc"
95
include "parser.inc"
95
include "parser.inc"
96
include "deflate.inc"
96
include "deflate.inc"
97
include "sys.inc"
97
include "sys.inc"
98
 
98
 
99
FileNum dd FILE_NUM
99
FileNum dd FILE_NUM
100
;FNAME equ '/hd/1/zip/pngsuite/s01n3p01.png'
100
;FNAME equ '/hd/1/zip/pngsuite/s01n3p01.png'
101
 
101
 
102
start:
102
start:
103
if SYS eq win
103
if SYS eq win
104
    invoke GetStdHandle, STD_OUTPUT_HANDLE
104
    invoke GetStdHandle, STD_OUTPUT_HANDLE
105
    mov  [cons],eax
105
    mov  [cons],eax
106
    invoke GetStdHandle, STD_INPUT_HANDLE
106
    invoke GetStdHandle, STD_INPUT_HANDLE
107
    mov  [cons_in],eax
107
    mov  [cons_in],eax
108
    Msg  0
108
    Msg  0
109
    Msg  1
109
    Msg  1
110
else
110
else
111
    Msg  0
111
    Msg  0
112
    Msg  1
112
    Msg  1
113
    mcall 40,1000101b
113
    mcall 40,1000101b
114
;    jmp again
114
;    jmp again
115
    CmdLine
115
    CmdLine
116
  cmdl:
116
  cmdl:
117
    test [Flags],LIST_MODE
117
    test [Flags],LIST_MODE
118
    jz   red
118
    jz   red
119
 
119
 
120
;    Dump [lpath],[lpath_len],os_work
120
;    Dump [lpath],[lpath_len],os_work
121
;    ud2
121
;    ud2
122
 red:
122
 red:
123
    call draw_window
123
    call draw_window
124
    mcall 12,2
124
    mcall 12,2
125
 
125
 
126
 still:
126
 still:
127
    mcall 10
127
    mcall 10
128
    cmp  eax,1
128
    cmp  eax,1
129
    je   red
129
    je   red
130
    cmp  eax,2
130
    cmp  eax,2
131
    jne  .nokey
131
    jne  .nokey
132
    mcall 2
132
    mcall 2
133
    cmp  ah,9
133
    cmp  ah,9
134
    jz   quit
134
    jz   quit
135
    jmp  still
135
    jmp  still
136
  .nokey:
136
  .nokey:
137
    cmp  eax,3
137
    cmp  eax,3
138
    jne  still
138
    jne  still
139
    mcall 17
139
    mcall 17
140
    cmp  ah,1
140
    cmp  ah,1
141
    jne  still
141
    jne  still
142
    mcall 23,30
142
    mcall 23,30
143
    cmp  eax,3
143
    cmp  eax,3
144
    jne  .noquit
144
    jne  .noquit
145
    call KillViewer
145
    call KillViewer
146
    mcall -1
146
    mcall -1
147
  .noquit:
147
  .noquit:
148
    mcall 17
148
    mcall 17
149
    mcall 64,1,MEMINIT
149
    mcall 64,1,MEMINIT
150
    QueryFile
150
    QueryFile
151
    mov  [FileNum],FILE_NUM
151
    mov  [FileNum],FILE_NUM
152
    test eax,eax
152
    test eax,eax
153
    jnz  still
153
    jnz  still
154
end if
154
end if
155
again:
155
again:
156
;    Dump Flags,4,os_work
156
;    Dump Flags,4,os_work
157
    mov  [fat_],fat
157
    mov  [fat_],fat
158
    Newline
158
    Newline
159
    xor  eax,eax
159
    xor  eax,eax
160
;    and  [Flags],STAY_MODE
160
;    and  [Flags],STAY_MODE
161
    and  [CRC32],eax
161
    and  [CRC32],eax
162
    and  [IDATsize],eax
162
    and  [IDATsize],eax
163
    mov  [Adler32],1
163
    mov  [Adler32],1
164
    call OpenFile
164
    call OpenFile
165
    test ebx,ebx
165
    test ebx,ebx
166
    jnz   .sizeok2
166
    jnz   .sizeok2
167
  .sizebad2:
167
  .sizebad2:
168
    Msg  14
168
    Msg  14
169
    jmp  quit
169
    jmp  quit
170
  .sizeok2:
170
  .sizeok2:
171
    call KillViewer
171
    call KillViewer
172
    xor  eax,eax
172
    xor  eax,eax
173
    mov  ecx,(child_stack-fat)/4
173
    mov  ecx,(child_stack-fat)/4
174
    mov  edi,fat
174
    mov  edi,fat
175
    rep  stosd
175
    rep  stosd
176
    mov  [filesize],ebx
176
    mov  [filesize],ebx
177
    test [Flags],RAW_MODE
177
    test [Flags],RAW_MODE
178
    jz   .norawm
178
    jz   .norawm
179
    mov  eax,[arc_base]
179
    mov  eax,[arc_base]
180
    xor  ebx,ebx
180
    xor  ebx,ebx
181
    call FileSeek
181
    call FileSeek
182
    jmp  .sizeok
182
    jmp  .sizeok
183
  .norawm:
183
  .norawm:
184
    call SfxParse
184
    call SfxParse
185
 
185
 
186
    call ZipParse
186
    call ZipParse
187
    cmp  edx,52
187
    cmp  edx,52
188
    je   .notzip
188
    je   .notzip
189
    mov  ecx,[FileNum]
189
    mov  ecx,[FileNum]
190
    call ZipFindN
190
    call ZipFindN
191
    cmp  edx,4
191
    cmp  edx,4
192
    je   quit
192
    je   quit
193
    test [Flags],DECRYPT_MODE
193
    test [Flags],DECRYPT_MODE
194
    jz   .nopass
194
    jz   .nopass
195
    call ZipDecrypt
195
    call ZipDecrypt
196
    push esi
196
    push esi
197
    mov  ecx,31
197
    mov  ecx,31
198
  ._:
198
  ._:
199
    mov  al,[esi]
199
    mov  al,[esi]
200
    push eax
200
    push eax
201
    call decrypt_byte
201
    call decrypt_byte
202
    xor  al,byte[esp]
202
    xor  al,byte[esp]
203
    add  esp,4
203
    add  esp,4
204
    call UKeys
204
    call UKeys
205
    mov  [esi],al
205
    mov  [esi],al
206
    inc  esi
206
    inc  esi
207
    loop ._
207
    loop ._
208
    pop  esi
208
    pop  esi
209
    ud2
209
    ud2
210
  .nopass:
210
  .nopass:
211
    cmp  [unp_size],0
211
    cmp  [unp_size],0
212
    jne  .sizeok
212
    jne  .sizeok
213
  .sizebadq:
213
  .sizebadq:
214
    Msg  13
214
    Msg  13
215
    jmp  quit
215
    jmp  quit
216
  .notzip:
216
  .notzip:
217
    call GzipParse
217
    call GzipParse
218
    test edx,edx
218
    test edx,edx
219
    jne   .notgzip
219
    jne   .notgzip
220
    jmp  .sizeok
220
    jmp  .sizeok
221
  .notgzip:
221
  .notgzip:
222
    call PngParse
222
    call PngParse
223
    test edx,edx
223
    test edx,edx
224
    jz  .sizeok1
224
    jz  .sizeok1
225
    cmp  edx,21
225
    cmp  edx,21
226
    je   .sizebad
226
    je   .sizebad
227
    test [Flags],RAW_MODE
227
    test [Flags],RAW_MODE
228
    jne  .sizeok
228
    jne  .sizeok
229
    Msg  40
229
    Msg  40
230
    jmp  exit
230
    jmp  exit
231
  .sizebad:
231
  .sizebad:
232
    Msg  17
232
    Msg  17
233
    jmp  exit
233
    jmp  exit
234
  .sizeok1:
234
  .sizeok1:
235
  if ~ SYS eq win
235
  if ~ SYS eq win
236
  end if
236
  end if
237
    Msg  39          ; unpacking PNG
237
    Msg  39          ; unpacking PNG
238
    mov  ecx,[unp_size]
238
    mov  ecx,[unp_size]
239
    add  ecx,output
239
    add  ecx,output
240
    mov  [png_],ecx
240
    mov  [png_],ecx
241
    mov  eax,[PNG_info.Width]
241
    mov  eax,[PNG_info.Width]
242
    imul eax,[PNG_info.Height]
242
    imul eax,[PNG_info.Height]
243
    lea  eax,[eax+eax*2]
243
    lea  eax,[eax+eax*2]
244
    add  ecx,eax
244
    add  ecx,eax
245
;    dps  'Mem='
245
;    dps  'Mem='
246
;    dpd  ecx
246
;    dpd  ecx
247
    mcall 64,1
247
    mcall 64,1
248
    test eax,eax
248
    test eax,eax
249
    jz   .ok
249
    jz   .ok
250
    Msg  41
250
    Msg  41
251
    jmp  exit
251
    jmp  exit
252
  .ok:
252
  .ok:
253
    mov  edi,[outp]
253
    mov  edi,[outp]
254
    call Deflate.blkbegin
254
    call Deflate.blkbegin
255
    jmp  .defl_end
255
    jmp  .defl_end
256
  .sizeok:
256
  .sizeok:
257
    mov  ecx,[unp_size]
257
    mov  ecx,[unp_size]
258
    dpd  ecx
258
    dpd  ecx
259
    add  ecx,output
259
    add  ecx,output
260
;    mov  [png_],ecx
260
;    mov  [png_],ecx
261
    mcall 64,1
261
    mcall 64,1
262
    test eax,eax
262
    test eax,eax
263
    jz   .ok2
263
    jz   .ok2
264
    Msg  41
264
    Msg  41
265
    jmp  exit
265
    jmp  exit
266
  .ok2:
266
  .ok2:
267
    call Deflate                ; <===========
267
    call Deflate                ; <===========
268
  .defl_end:
268
  .defl_end:
269
    test [bits],7
269
    test [bits],7
270
    jnz  .esi_ok
270
    jnz  .esi_ok
271
    dec  esi
271
    dec  esi
272
  .esi_ok:
272
  .esi_ok:
273
    push dword[esi] ; <- Adler !!!
273
    push dword[esi] ; <- Adler !!!
274
    mov  esi,output
274
    mov  esi,output
275
    sub  edi,esi
275
    sub  edi,esi
276
    mov  ecx,edi
276
    mov  ecx,edi
277
    mov  [outfile.size],ecx
277
    mov  [outfile.size],ecx
278
    test [Flags],RAW_MODE
278
    test [Flags],RAW_MODE
279
    jnz  .skipAdler
279
    jnz  .skipAdler
280
    test [Flags],PNG_MODE
280
    test [Flags],PNG_MODE
281
    jnz  .skipCRC
281
    jnz  .skipCRC
282
    push esi ecx
282
    push esi ecx
283
    call UCRC
283
    call UCRC
284
    Msg  11
284
    Msg  11
285
    mov  eax,[CRC32]
285
    mov  eax,[CRC32]
286
    mov  edx,36
286
    mov  edx,36
287
    cmp  eax,[CRC_check]
287
    cmp  eax,[CRC_check]
288
    je   .crcok
288
    je   .crcok
289
    dec  edx
289
    dec  edx
290
  .crcok:
290
  .crcok:
291
    Msg  edx
291
    Msg  edx
292
  if  SYS eq win
292
  if  SYS eq win
293
  else
293
  else
294
    dph  eax
294
    dph  eax
295
  end if
295
  end if
296
    pop  ecx esi
296
    pop  ecx esi
297
    jmp  .skipAdler
297
    jmp  .skipAdler
298
  .skipCRC:
298
  .skipCRC:
299
;    dps  'Out='
299
;    dps  'Out='
300
;    dpd  ecx
300
;    dpd  ecx
301
    call UAdler
301
    call UAdler
302
    Msg  10
302
    Msg  10
303
    mov  eax,[Adler32]
303
    mov  eax,[Adler32]
304
    bswap eax   ; <- calculated Adler !!!
304
    bswap eax   ; <- calculated Adler !!!
305
    mov  edx,36
305
    mov  edx,36
306
    cmp  eax,[esp]
306
    cmp  eax,[esp]
307
    je   .adlok
307
    je   .adlok
308
    dec  edx
308
    dec  edx
309
  .adlok:
309
  .adlok:
310
    Msg  edx
310
    Msg  edx
311
  if  SYS eq win
311
  if  SYS eq win
312
  else
312
  else
313
    dph  eax
313
    dph  eax
314
  end if
314
  end if
315
  .skipAdler:
315
  .skipAdler:
316
    pop  eax
316
    pop  eax
317
    Newline
317
    Newline
318
  .nomoreIDAT:
318
  .nomoreIDAT:
319
    mov  ebx,output
319
    mov  ebx,output
320
if SYS eq win
320
if SYS eq win
321
    Msg 37
321
    Msg 37
322
    invoke CloseHandle, [hnd]
322
    invoke CloseHandle, [hnd]
323
 
323
 
324
    invoke CreateFile,dumpfile,GENERIC_WRITE, FILE_SHARE_WRITE, NULL, \
324
    invoke CreateFile,dumpfile,GENERIC_WRITE, FILE_SHARE_WRITE, NULL, \
325
    CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL
325
    CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL
326
    mov  [hnd],eax
326
    mov  [hnd],eax
327
    invoke WriteFile, eax,ebx,[outfile.size],cparam1,NULL
327
    invoke WriteFile, eax,ebx,[outfile.size],cparam1,NULL
328
    invoke CloseHandle, [hnd]
328
    invoke CloseHandle, [hnd]
329
else
329
else
330
    test [Flags],PNG_MODE
330
    test [Flags],PNG_MODE
331
    jnz  .nosave
331
    jnz  .nosave
332
    test [Flags],LIST_MODE
332
    test [Flags],LIST_MODE
333
    jnz  quit
333
    jnz  quit
334
 
334
 
335
    test [Flags],TAR_MODE
335
    test [Flags],TAR_MODE
336
    jnz  .nomsg
336
    jnz  .nomsg
337
    Msg 37
337
    Msg 37
338
  .nomsg:
338
  .nomsg:
339
    mov  [outfile.out],ebx
339
    mov  [outfile.out],ebx
340
    mcall 70,outfile
340
    mcall 70,outfile
341
;       dps  'Before Quit1'
341
;       dps  'Before Quit1'
342
;    ud2
342
;    ud2
343
    test [Flags],TAR_MODE
343
    test [Flags],TAR_MODE
344
    jz   exit.pad
344
    jz   exit.pad
345
;    call StartPad
345
;    call StartPad
346
  .nosave:
346
  .nosave:
347
end if
347
end if
348
    test  [Flags],PNG_MODE
348
    test  [Flags],PNG_MODE
349
    jz   NoPng
349
    jz   NoPng
350
      xor  eax,eax
350
      xor  eax,eax
351
      mov  edi,filters
351
      mov  edi,filters
352
      mov  ecx,6
352
      mov  ecx,6
353
      rep  stosd
353
      rep  stosd
354
      mov  edi,[png_]
354
      mov  edi,[png_]
355
      mov  esi,output
355
      mov  esi,output
356
;//
356
;//
357
      mov  [outp],edi
357
      mov  [outp],edi
358
;//
358
;//
359
      call PngFilter
359
      call PngFilter
360
      call FiltStats
360
      call FiltStats
361
      mov  [outfile.size],edi
361
      mov  [outfile.size],edi
362
      mov  ebx,[outp];png_image
362
      mov  ebx,[outp];png_image
363
if  SYS eq win
363
if  SYS eq win
364
  exit:
364
  exit:
365
    Msg  12
365
    Msg  12
366
    invoke CreateFile,outfile,GENERIC_WRITE, FILE_SHARE_WRITE, NULL, \
366
    invoke CreateFile,outfile,GENERIC_WRITE, FILE_SHARE_WRITE, NULL, \
367
    CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL
367
    CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL
368
    mov  [hnd],eax
368
    mov  [hnd],eax
369
    invoke WriteFile, eax,ebx,[outfile.size],cparam1,NULL
369
    invoke WriteFile, eax,ebx,[outfile.size],cparam1,NULL
370
    invoke CloseHandle, [hnd]
370
    invoke CloseHandle, [hnd]
371
       call  RunViewer
371
       call  RunViewer
372
       and  [arc_base],0
372
       and  [arc_base],0
373
    and  [Flags],STAY_MODE
373
    and  [Flags],STAY_MODE
374
;       dps  'Before Quit2'
374
;       dps  'Before Quit2'
375
  quit:    
375
  quit:    
376
    QueryFile
376
    QueryFile
377
    test eax,eax
377
    test eax,eax
378
    jnz  again
378
    jnz  again
379
    invoke ExitProcess,0
379
    invoke ExitProcess,0
380
else
380
else
381
  exit:
381
  exit:
382
    mov  [outfile.out],ebx
382
    mov  [outfile.out],ebx
383
    test [Flags],TAR_MODE
383
    test [Flags],TAR_MODE
384
    jz   .notar
384
    jz   .notar
385
    Msg  37
385
    Msg  37
386
    test [Flags],LIST_MODE
386
    test [Flags],LIST_MODE
387
    jne  quit
387
    jne  quit
388
    mcall 70,outfile
388
    mcall 70,outfile
389
  .pad:
389
  .pad:
390
    call StartPad
390
    call StartPad
391
  .notar:
391
  .notar:
392
    Msg  12
392
    Msg  12
393
       call  RunViewer
393
       call  RunViewer
394
       and  [arc_base],0
394
       and  [arc_base],0
395
    and  [Flags],STAY_MODE
395
    and  [Flags],STAY_MODE
396
quit:
396
quit:
397
    test [Flags],STAY_MODE
397
    test [Flags],STAY_MODE
398
    jnz  red
398
    jnz  red
399
    mcall -1
399
    mcall -1
400
end if
400
end if
401
 
401
 
402
NoPng:
402
NoPng:
403
    test  [Flags],TAR_MODE
403
    test  [Flags],TAR_MODE
404
  if SYS eq win
404
  if SYS eq win
405
    jz  quit
405
    jz  quit
406
  else
406
  else
407
    jz    still
407
    jz    still
408
  end if
408
  end if
409
;    Dump output,255,os_work
409
;    Dump output,255,os_work
410
;    ud2
410
;    ud2
411
;    mov   ecx,dumpf_len
411
;    mov   ecx,dumpf_len
412
;    mov   esi,dumpfile
412
;    mov   esi,dumpfile
413
;    mov   edi,filename
413
;    mov   edi,filename
414
;    rep   movsb
414
;    rep   movsb
415
;    call  OpenFile
415
;    call  OpenFile
416
;    test  ebx,ebx
416
;    test  ebx,ebx
417
;    jz    again.sizebadq
417
;    jz    again.sizebadq
418
    call  TarParse
418
    call  TarParse
419
    mov   ecx,[FileNum]
419
    mov   ecx,[FileNum]
420
    call  TarFindN
420
    call  TarFindN
421
;    dpd   [outfile.size]
421
;    dpd   [outfile.size]
422
    cmp   [outfile.size],0
422
    cmp   [outfile.size],0
423
    jz    again.sizebadq
423
    jz    again.sizebadq
424
    mov   ebx,esi
424
    mov   ebx,esi
425
    jmp   exit
425
    jmp   exit
426
 
426
 
427
if ~ SYS eq win
427
if ~ SYS eq win
428
draw_window:
428
draw_window:
429
    mcall 12,1
429
    mcall 12,1
430
    mov  ebx,15
430
    mov  ebx,15
431
    mov  ecx,ebx
431
    mov  ecx,ebx
432
    mov  edx,0x0e26830
432
    mov  edx,0x0e26830
433
    mov  edi,edx
433
    mov  edi,edx
434
    mcall 0,,,,0x1f2a870
434
    mcall 0,,,,0x1f2a870
435
    mcall 8,,,1+1 shl 30
435
    mcall 8,,,1+1 shl 30
436
    mcall 4,<6,5>,0x10d0d0d0,msgs+5,1
436
    mcall 4,<6,5>,0x10d0d0d0,msgs+5,1
437
    mcall ,<5,5>,0x10202020
437
    mcall ,<5,5>,0x10202020
438
    ret
438
    ret
439
end if
439
end if
440
 
440
 
441
include 'data.inc'
441
include 'data.inc'
442
 
442
 
443
if SYS eq win
443
if SYS eq win
444
section '.idata' import data readable writeable
444
section '.idata' import data readable writeable
445
 
445
 
446
  library kernel,'KERNEL32.DLL',\
446
  library kernel,'KERNEL32.DLL',\
447
          comdlg,'COMDLG32.DLL',\
447
          comdlg,'COMDLG32.DLL',\
448
          user,'USER32.DLL'
448
          user,'USER32.DLL'
449
 
449
 
450
  import kernel,\
450
  import kernel,\
451
     CreateFile,'CreateFileA',\
451
     CreateFile,'CreateFileA',\
452
     GetFileSize,'GetFileSize',\
452
     GetFileSize,'GetFileSize',\
453
     ReadFile,'ReadFile',\
453
     ReadFile,'ReadFile',\
454
     WriteFile,'WriteFile',\
454
     WriteFile,'WriteFile',\
455
     SetFilePointer,'SetFilePointer',\
455
     SetFilePointer,'SetFilePointer',\
456
     CloseHandle,'CloseHandle',\
456
     CloseHandle,'CloseHandle',\
457
        GetStdHandle,'GetStdHandle',\
457
        GetStdHandle,'GetStdHandle',\
458
        WriteConsole,'WriteConsoleA',\
458
        WriteConsole,'WriteConsoleA',\
459
        ReadConsole,'ReadConsoleA',\
459
        ReadConsole,'ReadConsoleA',\
460
        CreateProcess,'CreateProcessA',\
460
        CreateProcess,'CreateProcessA',\
461
        WritePrivateProfileString,'WritePrivateProfileStringA',\    
461
        WritePrivateProfileString,'WritePrivateProfileStringA',\    
462
        ExitProcess,'ExitProcess'
462
        ExitProcess,'ExitProcess'
463
 
463
 
464
  import comdlg,\
464
  import comdlg,\
465
     GetOpenFileName,'GetOpenFileNameA'
465
     GetOpenFileName,'GetOpenFileNameA'
466
 
466
 
467
  import user,\
467
  import user,\
468
        wsprintf,'wsprintfA',\
468
        wsprintf,'wsprintfA',\
469
        SendMessage,'SendMessageA',\
469
        SendMessage,'SendMessageA',\
470
        FindWindowEx,'FindWindowExA',\
470
        FindWindowEx,'FindWindowExA',\
471
        WaitForInputIdle,'WaitForInputIdle'
471
        WaitForInputIdle,'WaitForInputIdle'
472
    
472
    
473
 
473
 
474
section '.reloc' fixups data readable discardable
474
section '.reloc' fixups data readable discardable
475
end if
475
end if
476
 
476
 
477
if ~ SYS in 
477
if ~ SYS in 
478
    error "Please specify SYS: meos OR win"
478
    error "Please specify SYS: meos OR win"
479
end if
479
end if
480
>
480
>