Subversion Repositories Kolibri OS

Rev

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