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