Subversion Repositories Kolibri OS

Rev

Rev 6620 | Rev 7832 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1688 mario79 1
;---------------------------------------------------------------------
2
; Kpack - Kolibri Packer
1671 mario79 3
; Kolibri version
4
; Written by diamond in 2006, 2007 specially for KolibriOS
5
;
7829 leency 6
; Disassemled and corrected in 2010-2011 specially for FASM
1671 mario79 7
;            by Marat Zakiyanov aka Mario79, aka Mario
8
;
9
; Uses LZMA compression library by Igor Pavlov
10
; (for more information on LZMA and 7-Zip visit http://www.7-zip.org)
11
; (plain-C packer and ASM unpacker are ported by diamond)
12
;---------------------------------------------------------------------
13
use32
14
	org	0
15
 
16
	db 'MENUET01'
17
	dd 1
1681 mario79 18
	dd START
19
	dd IM_END
1688 mario79 20
	dd I_END
1681 mario79 21
	dd stacktop
22
	dd params
1686 mario79 23
	dd cur_dir_path
1671 mario79 24
;---------------------------------------------------------------------
1702 Lrz 25
include '../../../config.inc'		;for nightbuild
1688 mario79 26
include '../../../macros.inc'
7829 leency 27
include '../../../gui_patterns.inc'
1686 mario79 28
include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
29
include '../../../develop/libraries/box_lib/load_lib.mac'
30
  @use_library
1681 mario79 31
 
1671 mario79 32
START:
1686 mario79 33
	mcall	68,11
5591 pavelyakov 34
	mcall	40,0x80000027
1686 mario79 35
 
1688 mario79 36
load_libraries l_libs_start,load_lib_end
37
	cmp eax,-1
38
	je exit
39
 
3178 IgorA 40
	init_checkboxes2 check1,check1_end
41
	;push	check1
42
	;call	[init_checkbox]
3177 IgorA 43
 
1671 mario79 44
	call	clear_messages
45
; set default path = /RD/1/
46
	mov	esi,defpath
47
	mov	edi,path
48
	mov	[edi-4],dword 6
49
	movsw
50
	movsd
51
; get system window info
1688 mario79 52
	xor	eax,eax
53
	cmp	[params],al
54
	je	default
55
 
56
	mov	edi,path
1671 mario79 57
	mov	esi,params
1688 mario79 58
	call	copy_1
1681 mario79 59
 
1688 mario79 60
	sub	esi,2
61
	std
62
@@:
63
	lodsb
64
	dec	edi
65
	cmp	al,byte '/'
66
	jnz	@r
67
 
68
	mov	[edi-1],byte 0
1671 mario79 69
	mov	edi,inname
1688 mario79 70
	add	esi,2
71
	push	esi
72
	call	copy_1
73
	pop	esi
1671 mario79 74
	mov	edi,outname
1688 mario79 75
	call	copy_1
76
;---------------------------------------------------------------------
7829 leency 77
	call set_editbox_position_all
1688 mario79 78
;---------------------------------------------------------------------
1671 mario79 79
	call	draw_window
80
	call	pack
1688 mario79 81
	jmp	OD_initialization
82
;*********************************************************************
1671 mario79 83
default:
84
	mov	esi,definoutname
85
	mov	edi,esi
86
	xor	ecx,ecx
87
	xor	eax,eax
88
	dec	ecx
89
	repnz	scasb
90
	not	ecx
91
	dec	ecx
92
	mov	[innamelen],ecx
93
	push	ecx
94
	push	esi
95
	mov	edi,inname
96
	rep	movsb
97
	pop	esi
98
	pop	ecx
99
	mov	[outnamelen],ecx
100
	mov	edi,outname
101
	rep	movsb
102
;---------------------------------------------------------------------
1688 mario79 103
	call	set_editbox_position_all
104
;---------------------------------------------------------------------
105
OD_initialization:
1686 mario79 106
;OpenDialog	initialisation
107
	push    dword OpenDialog_data
108
	call    [OpenDialog_Init]
109
;---------------------------------------------------------------------
110
red:
1671 mario79 111
	call	draw_window
1681 mario79 112
;--------------------------------------
1686 mario79 113
still:
1681 mario79 114
	mcall	10
1671 mario79 115
	dec	eax
1686 mario79 116
	jz	red
1681 mario79 117
 
1671 mario79 118
	dec	eax
1686 mario79 119
	jz	key
1681 mario79 120
 
1671 mario79 121
	dec	eax
1686 mario79 122
	jz	button
123
 
124
	push	dword edit1
125
	call	[edit_box_mouse]
126
 
127
	push	dword edit2
128
	call	[edit_box_mouse]
129
 
130
	push	dword edit3
131
	call	[edit_box_mouse]
132
 
1713 mario79 133
	push	dword check1
134
	call	[check_box_mouse]
135
 
1686 mario79 136
	jmp	still
137
;*********************************************************************
1713 mario79 138
tell_compress_mess:
139
	push	compressing_len
140
	pop	ecx
141
	mov	esi,compressing_str
142
	call	write_string
143
	ret
144
;*********************************************************************
145
clear_mess_and_displogo:
146
	call	refresh_editbox_data
147
; clear messages
148
	call	clear_messages
149
; display logo
150
	mov	esi,info_str
151
	push	info_len
152
	pop	ecx
153
	call	write_string
154
	ret
155
;*********************************************************************
1688 mario79 156
clear_messages:
157
	xor	eax,eax
158
	mov	ecx,80*20/4+1
159
	mov	edi,message_mem
160
	rep	stosd
161
	ret
162
;*********************************************************************
163
exit:
164
	xor	eax,eax
165
	dec	eax
166
	mcall
167
;*********************************************************************
1686 mario79 168
button:
1671 mario79 169
; button pressed
1681 mario79 170
	mcall	17
1671 mario79 171
	xchg	al,ah
172
	cmp	al,7
173
	jz	but7
1681 mario79 174
 
1671 mario79 175
	dec	eax
176
	jz	exit
1681 mario79 177
 
1671 mario79 178
	dec	eax
179
	jnz	nopack
1681 mario79 180
 
3178 IgorA 181
	bt dword[check1.flags],1
182
	jc	@f
1713 mario79 183
 
1671 mario79 184
	call	pack
1686 mario79 185
	jmp	still
1713 mario79 186
;---------------------------------------------------------------------
187
@@:
188
	call	kerpack
189
	jmp	still
1671 mario79 190
;---------------------------------------------------------------------
191
nopack:
192
	dec	eax
193
	jnz	nounpack
1713 mario79 194
 
1671 mario79 195
	call	unpack
1686 mario79 196
	jmp	still
1713 mario79 197
;---------------------------------------------------------------------
1671 mario79 198
but7:
199
	call	clear_messages
200
; display logo
201
	mov	esi,info_str
202
	push	info_len
203
	pop	ecx
204
	call	write_string
205
; display info
206
	mov	esi,usage_str
207
	mov	ecx,usage_len
208
	call	write_string
1686 mario79 209
	jmp	still
1671 mario79 210
;---------------------------------------------------------------------
211
nounpack:
212
	dec	eax
1686 mario79 213
	jnz	still
1681 mario79 214
 
1686 mario79 215
	call	OpenDialog_start
216
	jmp	still
217
;*********************************************************************
218
OpenDialog_start:
1688 mario79 219
	mov	esi,path
220
	mov	edi,temp_dir_pach
221
	call	copy_1
222
 
1686 mario79 223
	push    dword OpenDialog_data
224
	call    [OpenDialog_Start]
225
	cmp	[OpenDialog_data.status],1
226
	jne	@f
1681 mario79 227
 
1686 mario79 228
	mov	esi,filename_area
229
	mov	edi,inname
230
	call	copy_1
1681 mario79 231
 
1686 mario79 232
	mov	esi,filename_area
233
	mov	edi,outname
234
	call	copy_1
235
 
236
	mov	esi,temp_dir_pach
237
	mov	edi,path
238
	call	copy_1
239
 
1688 mario79 240
	call	refresh_editbox_data
241
 
1686 mario79 242
	call	set_editbox_position_all
1681 mario79 243
 
1686 mario79 244
	call	draw_editbox
1671 mario79 245
@@:
1686 mario79 246
	ret
247
;*********************************************************************
248
copy_1:
1671 mario79 249
	xor	eax,eax
1686 mario79 250
	cld
1671 mario79 251
@@:
1686 mario79 252
	lodsb
253
	stosb
1671 mario79 254
	test	eax,eax
1686 mario79 255
	jnz	@r
1671 mario79 256
	ret
1686 mario79 257
;*********************************************************************
1688 mario79 258
refresh_editbox_data:
259
	mov	esi,inname
260
	mov	edi,innamelen
261
	call	refresh_data
262
 
263
	mov	esi,outname
264
	mov	edi,outnamelen
265
	call	refresh_data
266
 
267
	mov	esi,path
268
	mov	edi,pathlen
269
	call	refresh_data
270
 
271
	ret
272
;*********************************************************************
273
refresh_data:
274
	push	esi
275
	xor	eax,eax
276
	cld
277
@@:
278
	lodsb
279
	test	eax,eax
280
	jnz	@r
281
	pop	eax
282
	sub	esi,eax
283
	dec	esi
284
	mov	[edi],esi
285
	ret
286
;*********************************************************************
1686 mario79 287
set_editbox_position_all:
288
	mov	ebx,inname
289
	mov	edi,edit1
290
	call	set_editbox_position
1681 mario79 291
 
1686 mario79 292
	mov	ebx,outname
293
	mov	edi,edit2
294
	call	set_editbox_position
1681 mario79 295
 
1686 mario79 296
	mov	ebx,path
297
	mov	edi,edit3
298
	call	set_editbox_position
1671 mario79 299
	ret
1686 mario79 300
;*********************************************************************
301
key:
302
	mcall	2
1681 mario79 303
 
1686 mario79 304
	push	dword edit1
305
	call	[edit_box_key]
1681 mario79 306
 
1686 mario79 307
	push	dword edit2
308
	call	[edit_box_key]
1681 mario79 309
 
1686 mario79 310
	push	dword edit3
311
	call	[edit_box_key]
1681 mario79 312
 
1686 mario79 313
	jmp	still
314
;*********************************************************************
1671 mario79 315
get_full_name:
316
	push	esi
317
	mov	esi,path
318
	mov	ecx,[esi-4]
319
	mov	edi,fullname
320
	rep	movsb
321
	mov	al,'/'
322
	cmp	[edi-1],al
323
	jz	@f
1681 mario79 324
 
1671 mario79 325
	stosb
1681 mario79 326
;--------------------------------------
1671 mario79 327
@@:
328
	pop	esi
329
	cmp	[esi],al
330
	jnz	@f
1681 mario79 331
 
1671 mario79 332
	mov	edi,fullname
1681 mario79 333
;--------------------------------------
1671 mario79 334
@@:
335
	mov	ecx,[esi-4]
336
	rep	movsb
337
	xor	eax,eax
338
	stosb
339
	ret
1686 mario79 340
;*********************************************************************
1671 mario79 341
write_string:
342
; in: esi=pointer, ecx=length
343
	mov	edx,[message_cur_pos]
1681 mario79 344
;--------------------------------------
1671 mario79 345
x1:
346
	lea	edi,[message_mem+edx]
1681 mario79 347
;--------------------------------------
1671 mario79 348
do_write_char:
349
	lodsb
350
	cmp	al,10
351
	jz	newline
1681 mario79 352
 
1671 mario79 353
	stosb
354
	inc	edx
355
	loop	do_write_char
356
	jmp	x2
357
;---------------------------------------------------------------------
358
newline:
359
	xor	eax,eax
360
	stosb
361
	xchg	eax,edx
362
	push	ecx
363
	push	eax
364
	mov	ecx,80
365
	div	ecx
366
	pop	eax
367
	xchg	eax,edx
368
	sub	edx,eax
369
	add	edx,ecx
370
	pop	ecx
371
	loop	x1
1681 mario79 372
;--------------------------------------
1671 mario79 373
x2:
374
	mov	[message_cur_pos],edx
375
; update window
7829 leency 376
	call draw_log_area
1681 mario79 377
;--------------------------------------
1671 mario79 378
draw_messages:
7829 leency 379
	mov	ebx,12 shl 16 + LOG_Y + 7
1671 mario79 380
	mov	edi,message_mem
1681 mario79 381
;--------------------------------------
1671 mario79 382
@@:
383
	push	edi
384
	xor	eax,eax
385
	push	80
386
	pop	ecx
387
	repnz	scasb
388
	sub	ecx,79
389
	neg	ecx
390
	mov	esi,ecx
391
	pop	edi
7829 leency 392
	mcall	4,,0xB0000000,edi
393
	add	ebx,16
1671 mario79 394
	add	edi,80
395
	cmp	edi,message_cur_pos
396
	jb	@b
1681 mario79 397
 
1671 mario79 398
	ret
1686 mario79 399
;*********************************************************************
7829 leency 400
draw_log_area:
401
	DrawRectangle 5, LOG_Y, WIN_W-12, LOG_H, [sc.work_graph]
402
	mcall	13, <6,WIN_W-13>, , 0xFFFfff
403
	ret
404
;*********************************************************************
1671 mario79 405
draw_window:
406
; start redraw
7829 leency 407
	mcall	12,1
408
	mcall	48,3,sc,40
409
	;--------------------------------------
410
	edit_boxes_set_sys_color edit1,editboxes_end,sc
411
	check_boxes_set_sys_color2 check1,check1_end,sc
412
	;--------------------------------------
413
; define window
414
	mcall 48,4
415
 
416
	mov	ecx,100 shl 16 + WIN_H
417
	add ecx, eax
2673 leency 418
 
7829 leency 419
	mov	edx,[sc.work]
1688 mario79 420
	add	edx,34000000h
1681 mario79 421
	xor	esi,esi
1688 mario79 422
	xor	edi,edi
7829 leency 423
	mcall	0,<250,WIN_W+10>,,,,caption_str
1686 mario79 424
	mcall	9,procinfo,-1
2058 mario79 425
 
426
	mov	eax,[procinfo+70] ;status of window
427
	test	eax,100b
428
	jne	.end
1686 mario79 429
;--------------------------------------
430
; draw lines and frame
7829 leency 431
	call    draw_log_area
1686 mario79 432
; draw buttons
2262 mario79 433
	call	draw_buttons
1686 mario79 434
; draw messages
435
	call	draw_messages
436
; draw editbox's
437
	call	draw_editbox
438
; end redraw
2058 mario79 439
.end:
1686 mario79 440
	mcall	12,2
441
	ret
442
;*********************************************************************
443
draw_editbox:
444
	push	dword edit1
445
	call	[edit_box_draw]
1713 mario79 446
 
1686 mario79 447
	push	dword edit2
448
	call	[edit_box_draw]
1713 mario79 449
 
1686 mario79 450
	push	dword edit3
451
	call	[edit_box_draw]
1713 mario79 452
 
7829 leency 453
	mov eax,[sc.work_text]
454
	or eax, 0x90000000
455
	mov	[check1.text_color], eax
1713 mario79 456
	push	dword check1
457
	call	[check_box_draw]
1686 mario79 458
	ret
459
;*********************************************************************
460
set_editbox_position:
461
	mov	esi,ebx
462
	cld
463
@@:
464
	lodsb
465
	test	al,al
466
	jne	@r
467
	sub	esi,ebx
468
	mov	eax,esi
469
	dec	eax
470
	mov	[edi+48], eax  ;ed_size
471
	mov	[edi+52], eax  ;ed_pos
472
	ret
473
;*********************************************************************
2262 mario79 474
draw_buttons:
1671 mario79 475
; define compress button
1681 mario79 476
	mov	cx,18
7829 leency 477
	mcall	8,, <3, 20>,2,[sc.work_button]
1671 mario79 478
; uncompress button
479
	inc	edx
7829 leency 480
	add	ecx,LINE_H shl 16
1681 mario79 481
	mcall
1671 mario79 482
; question button
483
	push	esi
484
	mov	dl,7
7829 leency 485
	mcall	,,
486
	mov ecx,[sc.work_button_text]
487
	or  ecx,0x90000000
488
	mov edx,aQuestion
489
	mcall  4,
1671 mario79 490
	pop	esi
7829 leency 491
; define Path button
492
	mcall	8,<6,64>,,4
493
; text on Path button
4978 Akyltist 494
	mov	ebx,8 shl 16+5
1671 mario79 495
	mov	al,4
7829 leency 496
	mov	ecx,[sc.work_text]
1671 mario79 497
	push	buttons1names
498
	pop	edx
499
	push	8
500
	pop	esi
1681 mario79 501
;--------------------------------------
7829 leency 502
; text on settings buttons
503
	mov ecx, [sc.work_text]
504
	or ecx, 0x10000000
505
	mcall , <8, 5>, , buttons1names, 8
506
 
1671 mario79 507
	add	edx,esi
7829 leency 508
	add	ebx,LINE_H
2273 leency 509
	mcall
510
	add	edx,esi
7829 leency 511
	add	ebx,LINE_H
512
	mov	ecx,[sc.work_button_text]
513
	or ecx, 0x10000000
514
	sub ebx, 10 shl 16
2273 leency 515
	mcall
1671 mario79 516
; text on compress and decompress buttons
4978 Akyltist 517
	or	ecx,0x80000000
7829 leency 518
	mcall	,,,aCompress
519
	mcall	,,,aDecompress
1671 mario79 520
	ret
1686 mario79 521
;*********************************************************************
522
;Pack procedures
523
include 'packpoc.inc'
1671 mario79 524
;---------------------------------------------------------------------
1686 mario79 525
;UnPack procedures
526
include 'upacproc.inc'
1671 mario79 527
;---------------------------------------------------------------------
528
;lzma_compress:
529
include 'lzma_compress.inc'
530
;---------------------------------------------------------------------
531
;lzma_set_dict_size:
532
include 'lzma_set_dict_size.inc'
533
;---------------------------------------------------------------------
534
;lzma_decompress:
535
include	'lzma_decompress.inc'
536
;---------------------------------------------------------------------
1713 mario79 537
;kerpack code:
538
include	'kerpack.inc'
539
;---------------------------------------------------------------------
1681 mario79 540
;initialized variables and constants
541
include 'const_var.inc'
1671 mario79 542
;---------------------------------------------------------------------
543
IM_END:
544
;---------------------------------------------------------------------
1681 mario79 545
;uninitialized data
546
include 'data.inc'
1671 mario79 547
;---------------------------------------------------------------------
548
I_END:
549
;---------------------------------------------------------------------