Rev 6196 | Rev 6695 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6196 | Rev 6688 | ||
---|---|---|---|
Line 1... | Line -... | ||
1 | ; Run with OpenDialog ; |
- | |
2 | - | ||
3 | - | ||
4 | - | ||
5 | org 0 |
- | |
6 | use32 |
- | |
7 | - | ||
8 | STACK_SIZE equ 256 |
- | |
9 | REDRAW_EVENT equ 1 |
- | |
10 | KEY_EVENT equ 2 |
- | |
11 | BUTTON_EVENT equ 3 |
- | |
12 | MOUSE_EVENT equ 6 |
- | |
13 | - | ||
14 | BUTTON_RUN equ 10 |
- | |
15 | BUTTON_BROWSE equ 20 |
- | |
16 | - | ||
17 | MENUET01 db 'MENUET01' |
- | |
18 | version dd 1 |
- | |
19 | program.start dd start_ |
- | |
20 | program.end dd end_ |
- | |
21 | program.memory dd end_ + STACK_SIZE |
- | |
22 | program.stack dd end_ + STACK_SIZE |
- | |
23 | program.params dd 0 |
- | |
24 | program.path dd 0 |
- | |
25 | - | ||
26 | include 'lang.inc' |
- | |
27 | - | ||
28 | ; ======================================================================= ; |
- | |
29 | start_: |
- | |
30 | ; set.event |
- | |
31 | mov eax, 40 |
- | |
32 | mov ebx, 39 |
- | |
33 | int 64 |
- | |
34 | - | ||
35 | push sz_box_lib |
- | |
36 | call load.library |
- | |
37 | mov [box_lib], eax |
- | |
38 | - | ||
39 | push dword[box_lib] |
- | |
40 | push sz_edit_box |
- | |
41 | call getprocaddress |
- | |
42 | mov [edit_box_draw], eax |
- | |
43 | - | ||
44 | push dword[box_lib] |
- | |
45 | push sz_edit_box_key |
- | |
46 | call getprocaddress |
- | |
47 | mov [edit_box_key], eax |
- | |
48 | - | ||
49 | push dword[box_lib] |
- | |
50 | push sz_edit_box_mouse |
- | |
51 | call getprocaddress |
- | |
52 | mov [edit_box_mouse], eax |
- | |
53 | - | ||
54 | push dword[box_lib] |
- | |
55 | push sz_edit_box_set_text |
- | |
56 | call getprocaddress |
- | |
57 | mov [edit_box_set_text], eax |
- | |
58 | - | ||
59 | push sz_proc_lib |
- | |
60 | call load.library |
- | |
61 | mov [proc_lib], eax |
- | |
62 | - | ||
63 | push dword[proc_lib] |
- | |
64 | push sz_OpenDialog_init |
- | |
65 | call getprocaddress |
- | |
66 | mov [opendialog_init], eax |
- | |
67 | - | ||
68 | push dword[proc_lib] |
- | |
69 | push sz_OpenDialog_start |
- | |
70 | call getprocaddress |
- | |
71 | mov [opendialog_start], eax |
- | |
72 | - | ||
73 | - | ||
74 | ; memory.allocate: |
- | |
75 | mov eax, 68 |
- | |
76 | mov ebx, 12 |
- | |
77 | mov ecx, 4096 + 4096 + 4096 |
- | |
78 | int 64 |
- | |
79 | - | ||
80 | mov [od.procinfo], eax |
- | |
81 | - | ||
82 | add eax, 1024 |
- | |
83 | mov [od.filename_area], eax |
- | |
84 | - | ||
85 | add eax, 4096 - 1024 |
- | |
86 | mov [od.opendir_path], eax |
- | |
87 | - | ||
88 | add eax, 4096 |
- | |
89 | mov [od.openfile_path], eax |
- | |
90 | - | ||
91 | push od |
- | |
92 | call [opendialog_init] |
- | |
93 | - | ||
94 | - | ||
95 | ; get.screen.size |
- | |
96 | mov eax, 61 |
- | |
97 | mov ebx, 1 |
- | |
98 | int 64 |
- | |
99 | - | ||
100 | mov [screen], eax |
- | |
101 | movzx eax, word[screen.width] |
- | |
102 | shr eax, 3 |
- | |
103 | lea eax, [eax*2 + eax] |
- | |
104 | add eax, 72 |
- | |
105 | mov [window.width], eax |
- | |
106 | - | ||
107 | ; skin.height |
- | |
108 | mov eax, 48 |
- | |
109 | mov ebx, 4 |
- | |
110 | int 64 |
- | |
111 | - | ||
112 | add eax, 64 |
- | |
113 | mov [window.height], eax |
- | |
114 | - | ||
115 | movzx eax, word[screen.width] |
- | |
116 | sub eax, [window.width] |
- | |
117 | shr eax, 1 |
- | |
118 | mov [window.left], eax |
- | |
119 | - | ||
120 | movzx eax, word[screen.height] |
- | |
121 | sub eax, [window.height] |
- | |
122 | sub eax, 24 |
- | |
123 | mov [window.top], eax |
- | |
124 | - | ||
125 | mov eax, [window.width] |
- | |
126 | sub eax, 20 |
- | |
127 | mov [edit1.width], eax |
- | |
128 | - | ||
129 | mov eax, [od.openfile_path] |
- | |
130 | mov [edit1.text], eax |
- | |
131 | - | ||
132 | - | ||
133 | call on_redraw |
- | |
134 | ; ----------------------- ; |
- | |
135 | .loop: |
- | |
136 | ; wait.event |
- | |
137 | mov eax, 10 |
- | |
138 | int 64 |
- | |
139 | cmp eax, REDRAW_EVENT |
- | |
140 | jne .check_key |
- | |
141 | call on_redraw |
- | |
142 | jmp .loop |
- | |
143 | ; ----------------------- ; |
- | |
144 | .check_key: |
- | |
145 | cmp eax, KEY_EVENT |
- | |
146 | jne .check_button |
- | |
147 | mov eax, 2 |
- | |
148 | int 64 |
- | |
149 | cmp ah, 13 |
- | |
150 | jne .no_key_enter |
- | |
151 | call on_button_run |
- | |
152 | jmp .loop |
- | |
153 | ; ----------------------- ; |
- | |
154 | .no_key_enter: |
- | |
155 | cmp ah, 185 |
- | |
156 | jne .no_key_insert |
- | |
157 | call on_button_browse |
- | |
158 | jmp .loop |
- | |
159 | .no_key_insert: |
- | |
160 | push edit1 |
- | |
161 | call [edit_box_key] |
- | |
162 | jmp .loop |
- | |
163 | ; ----------------------- ; |
- | |
164 | .check_button: |
- | |
165 | cmp eax, BUTTON_EVENT |
- | |
166 | jne .check_mouse |
- | |
167 | ; get.button.number |
- | |
168 | mov eax, 17 |
- | |
169 | int 64 |
- | |
170 | cmp ah, 1 |
- | |
171 | jne .check_button_run |
- | |
172 | ; program.terminate |
- | |
173 | or eax, -1 |
- | |
174 | int 64 |
- | |
175 | ; ----------------------- ; |
- | |
176 | .check_button_run: |
- | |
177 | cmp ah, BUTTON_RUN |
- | |
178 | jne .check_button_browse |
- | |
179 | call on_button_run |
- | |
180 | jmp .loop |
- | |
181 | ; ----------------------- ; |
- | |
182 | .check_button_browse: |
- | |
183 | cmp ah, BUTTON_BROWSE |
- | |
184 | jne .loop |
- | |
185 | call on_button_browse |
- | |
186 | jmp .loop |
- | |
187 | ; ----------------------- ; |
- | |
188 | .check_mouse: |
- | |
189 | cmp eax, MOUSE_EVENT |
- | |
190 | jne .loop |
- | |
191 | push edit1 |
- | |
192 | call [edit_box_mouse] |
- | |
193 | jmp .loop |
- | |
194 | - | ||
195 | - | ||
196 | ; ======================================================================= ; |
- | |
197 | on_button_run: |
- | |
198 | push dword[edit1.text] |
- | |
199 | call extractrunpathandparams |
- | |
200 | - | ||
201 | ;file.run: |
- | |
202 | mov eax, 70 |
- | |
203 | mov ebx, file_info |
- | |
204 | int 64 |
- | |
205 | - | ||
206 | mov dl, byte[lastendpath] |
- | |
207 | mov ecx, [ptrlastendpath] |
- | |
208 | mov [ecx], dl |
- | |
209 | - | ||
210 | test eax, eax |
- | |
211 | jnge .error |
- | |
212 | mov [runresult], dword sz_Program_run_successfully |
- | |
213 | jmp .exit |
- | |
214 | - | ||
215 | .error: |
- | |
216 | ; ----------------------- ; |
- | |
217 | .5: |
- | |
218 | cmp al, -5 |
- | |
219 | jne .31 |
- | |
220 | mov [runresult], dword sz_File_not_found |
- | |
221 | jmp .exit |
- | |
222 | ; ----------------------- ; |
- | |
223 | .31: |
- | |
224 | cmp al, -31 |
- | |
225 | jne .32 |
- | |
226 | mov [runresult], dword sz_File_is_not_executable |
- | |
227 | jmp .exit |
- | |
228 | ; ----------------------- ; |
- | |
229 | .32: |
- | |
230 | cmp al, -32 |
- | |
231 | jne .10 |
- | |
232 | mov [runresult], dword sz_Too_many_processes |
- | |
233 | jmp .exit |
- | |
234 | ; ----------------------- ; |
- | |
235 | .10: |
- | |
236 | cmp al, -10 |
- | |
237 | jne .30 |
- | |
238 | mov [runresult], dword sz_Access_denied |
- | |
239 | jmp .exit |
- | |
240 | ; ----------------------- ; |
- | |
241 | .30: |
- | |
242 | cmp al, -30 |
- | |
243 | jne .unknown |
- | |
244 | mov [runresult], dword sz_Out_of_memory |
- | |
245 | jmp .exit |
- | |
246 | ; ----------------------- ; |
- | |
247 | .unknown: |
- | |
248 | mov [runresult], dword sz_Unknown_error |
- | |
249 | ; ----------------------- ; |
- | |
250 | .exit: |
- | |
251 | call on_redraw |
- | |
252 | ret |
- | |
253 | - | ||
254 | ; ======================================================================= ; |
- | |
255 | on_button_browse: |
- | |
256 | push od |
- | |
257 | call [opendialog_start] |
- | |
258 | - | ||
259 | mov eax, [od.status] |
- | |
260 | test eax, eax |
- | |
261 | je .exit |
- | |
262 | - | ||
263 | ;======== if space exist in filepath, then quote filepath |
- | |
264 | mov eax, [od.openfile_path] |
- | |
265 | ; ----------------------- ; |
- | |
266 | .check_space: |
- | |
267 | cmp [eax], byte 0 |
- | |
268 | je .no_space |
- | |
269 | cmp [eax], byte 32 ;space |
- | |
270 | je .space |
- | |
271 | inc eax |
- | |
272 | jmp .check_space |
- | |
273 | .space: |
- | |
274 | ; ----------------------- ; |
- | |
275 | .find_end_zero: |
- | |
276 | inc eax |
- | |
277 | cmp [eax], byte 0 |
- | |
278 | jne .find_end_zero |
- | |
279 | mov [eax + 2], byte 0 |
- | |
280 | mov [eax + 1], byte 34 ; quote |
- | |
281 | ; ----------------------- ; |
- | |
282 | .shift_path: |
- | |
283 | dec eax |
- | |
284 | - | ||
285 | mov dl, byte [eax ] |
- | |
286 | mov [eax + 1], dl |
- | |
287 | - | ||
288 | cmp eax, [od.openfile_path] |
- | |
289 | jne .shift_path |
- | |
290 | mov [eax ], byte 34 ; quote |
- | |
291 | - | ||
292 | .no_space: |
- | |
293 | ;================================= |
- | |
294 | - | ||
295 | push dword[od.openfile_path] |
- | |
296 | push edit1 |
- | |
297 | call [edit_box_set_text] |
- | |
298 | ; ----------------------- ; |
- | |
299 | .exit: |
- | |
300 | ret |
- | |
301 | - | ||
302 | - | ||
303 | ; ======================================================================= ; |
- | |
304 | on_redraw: |
- | |
305 | ; redraw.start |
- | |
306 | mov eax, 12 |
- | |
307 | mov ebx, 1 |
- | |
308 | int 64 |
- | |
309 | ; get.standart.colors |
- | |
310 | mov eax, 48 |
- | |
311 | mov ebx, 3 |
- | |
312 | mov ecx, sc |
- | |
313 | mov edx, 40 |
- | |
314 | int 64 |
- | |
315 | - | ||
316 | mov eax, [sc.work_graph] |
- | |
317 | mov [edit1.shift_color], eax |
- | |
318 | - | ||
319 | mov eax, [sc.work_graph] |
- | |
320 | mov [edit1.focus_border_color], eax |
- | |
321 | - | ||
322 | mov eax, [sc.frames] |
- | |
323 | mov [edit1.blur_border_color], eax |
- | |
324 | - | ||
325 | mov eax, [sc.work_text] |
- | |
326 | mov [edit1.text_color], eax |
- | |
327 | - | ||
328 | ; draw.window |
- | |
329 | xor eax, eax |
- | |
330 | mov ebx, [window.left] |
- | |
331 | shl ebx, 16 |
- | |
332 | add ebx, [window.width] |
- | |
333 | mov ecx, [window.top] |
- | |
334 | shl ecx, 16 |
- | |
335 | add ecx, [window.height] |
- | |
336 | mov edx, [sc.work] |
- | |
337 | or edx, 34000000h |
- | |
338 | mov edi, sz_run |
- | |
339 | int 64 |
- | |
340 | - | ||
341 | mov eax, [window.width] |
- | |
342 | sub eax, 318 |
- | |
343 | shr eax, 1 |
- | |
344 | sub eax, 5 |
- | |
345 | push eax |
- | |
346 | push 5 |
- | |
347 | push sz_Type_name_of_program |
- | |
348 | push dword [sc.work_text] |
- | |
349 | call draw.text |
- | |
350 | - | ||
351 | ; ====================| browse button |==================== |
- | |
352 | push 20 |
- | |
353 | push 5 |
- | |
354 | push 38 |
- | |
355 | push 42 |
- | |
356 | push 17 |
- | |
357 | call draw.button |
- | |
358 | - | ||
359 | push 3 |
- | |
360 | push 42 |
- | |
361 | push sz_browse |
- | |
362 | push dword [sc.work_button_text] |
- | |
363 | call draw.text |
- | |
364 | - | ||
365 | ; ====================| run button |==================== |
- | |
366 | push 10 |
- | |
367 | mov eax, [window.width] |
- | |
368 | sub eax, 57 |
- | |
369 | push eax |
- | |
370 | push 38 |
- | |
371 | push 42 |
- | |
372 | push 17 |
- | |
373 | call draw.button |
- | |
374 | - | ||
375 | mov eax, [window.width] |
- | |
376 | sub eax, 56 |
- | |
377 | push eax |
- | |
378 | push 42 |
- | |
379 | push sz_run |
- | |
380 | push dword [sc.work_button_text] |
- | |
381 | call draw.text |
- | |
382 | ; ===================================================== |
- | |
383 | - | ||
384 | mov eax, 57 |
- | |
385 | push eax |
- | |
386 | mov eax, [window.height] |
- | |
387 | sub eax, 44 |
- | |
388 | push eax |
- | |
389 | push dword[runresult] |
- | |
390 | push dword [sc.work_text] |
- | |
391 | call draw.text |
- | |
392 | - | ||
393 | push edit1 |
- | |
394 | call [edit_box_draw] |
- | |
395 | - | ||
396 | ; redraw.finish |
- | |
397 | mov eax, 12 |
- | |
398 | mov ebx, 2 |
- | |
399 | int 64 |
- | |
400 | - | ||
401 | ret |
- | |
402 | - | ||
403 | - | ||
404 | ; ======================================================================= ; |
- | |
405 | extractrunpathandparams: |
- | |
406 | xor ecx, ecx |
- | |
407 | - | ||
408 | mov eax, [esp + 4] |
- | |
409 | mov [runpath], eax |
- | |
410 | - | ||
411 | movzx eax, byte [eax] |
- | |
412 | cmp eax, 34 |
- | |
413 | jne .start_without_quote |
- | |
414 | - | ||
415 | inc ecx |
- | |
416 | ; ----------------------- ; |
- | |
417 | .loop1: |
- | |
418 | mov eax, [runpath] |
- | |
419 | movzx eax, byte [eax + ecx] |
- | |
420 | cmp eax, 34 |
- | |
421 | jne .not_quote |
- | |
422 | - | ||
423 | mov eax, [runpath] |
- | |
424 | mov [eax + ecx], byte 0 |
- | |
425 | - | ||
426 | mov eax, [runpath] |
- | |
427 | add eax, ecx |
- | |
428 | mov [ptrlastendpath], eax |
- | |
429 | mov [lastendpath], byte 34 |
- | |
430 | inc ecx |
- | |
431 | ; ----------------------- ; |
- | |
432 | .skip_space1: |
- | |
433 | mov eax, [runpath] |
- | |
434 | movzx eax, byte [eax + ecx] |
- | |
435 | cmp al, 32 |
- | |
436 | jne .skipped1 |
- | |
437 | inc ecx |
- | |
438 | jmp .skip_space1 |
- | |
439 | ; ----------------------- ; |
- | |
440 | .skipped1: |
- | |
441 | mov eax, [runpath] |
- | |
442 | add eax, ecx |
- | |
443 | mov [runparams], eax |
- | |
444 | inc dword [runpath] |
- | |
445 | jmp .exit |
- | |
446 | ; ----------------------- ; |
- | |
447 | .not_quote: |
- | |
448 | mov eax, [runpath] |
- | |
449 | movzx eax, byte [eax + ecx] |
- | |
450 | - | ||
451 | test eax, eax |
- | |
452 | jne .not_zero1 |
- | |
453 | mov eax, [runpath] |
- | |
454 | add eax, ecx |
- | |
455 | mov [runparams], eax |
- | |
456 | mov eax, [runpath] |
- | |
457 | add eax, ecx |
- | |
458 | mov [ptrlastendpath], eax |
- | |
459 | mov [lastendpath], byte 0 |
- | |
460 | jmp .exit |
- | |
461 | ; ----------------------- ; |
- | |
462 | .not_zero1: |
- | |
463 | inc ecx |
- | |
464 | jmp .loop1 |
- | |
465 | ; ----------------------- ; |
- | |
466 | .start_without_quote: |
- | |
467 | ; ----------------------- ; |
- | |
468 | .loop2: |
- | |
469 | mov eax, [runpath] |
- | |
470 | movzx eax, byte [eax + ecx] |
- | |
471 | cmp eax, 32 |
- | |
472 | jne .not_space |
- | |
473 | - | ||
474 | mov eax, [runpath] |
- | |
475 | mov [eax + ecx], byte 0 |
- | |
476 | - | ||
477 | mov eax, [runpath] |
- | |
478 | add eax, ecx |
- | |
479 | mov [ptrlastendpath], eax |
- | |
480 | mov [lastendpath], byte 32 |
- | |
481 | inc ecx |
- | |
482 | ; ----------------------- ; |
- | |
483 | .skip_space2: |
- | |
484 | mov eax, [runpath] |
- | |
485 | movzx eax, byte [eax + ecx] |
- | |
486 | cmp al, 32 |
- | |
487 | jne .skipped2 |
- | |
488 | inc ecx |
- | |
489 | jmp .skip_space2 |
- | |
490 | ; ----------------------- ; |
- | |
491 | .skipped2: |
- | |
492 | mov eax, [runpath] |
- | |
493 | add eax, ecx |
- | |
494 | mov [runparams], eax |
- | |
495 | jmp .exit |
- | |
496 | ; ----------------------- ; |
- | |
497 | .not_space: |
- | |
498 | mov eax, [runpath] |
- | |
499 | movzx eax, byte [eax + ecx] |
- | |
500 | - | ||
501 | test eax, eax |
- | |
502 | jne .not_zero2 |
- | |
503 | mov eax, [runpath] |
- | |
504 | add eax, ecx |
- | |
505 | mov [runparams], eax |
- | |
506 | mov eax, [runpath] |
- | |
507 | add eax, ecx |
- | |
508 | mov [ptrlastendpath], eax |
- | |
509 | mov [lastendpath], byte 0 |
- | |
510 | jmp .exit |
- | |
511 | ; ----------------------- ; |
- | |
512 | .not_zero2: |
- | |
513 | inc ecx |
- | |
514 | jmp .loop2 |
- | |
515 | ; ----------------------- ; |
- | |
516 | .exit: |
- | |
517 | ret 4 |
- | |
518 | - | ||
519 | ; ======================================================================= ; |
- | |
520 | draw.button: |
- | |
521 | mov eax, 8 |
- | |
522 | mov ebx, [esp + 16] |
- | |
523 | shl ebx, 16 |
- | |
524 | add ebx, [esp + 8] |
- | |
525 | mov ecx, [esp + 12] |
- | |
526 | shl ecx, 16 |
- | |
527 | add ecx, [esp + 4] |
- | |
528 | mov edx, [esp + 20] |
- | |
529 | mov esi, [sc.work_button] |
- | |
530 | int 64 |
- | |
531 | ret 20 |
- | |
532 | ; ======================================================================= ; |
- | |
533 | draw.text: |
- | |
534 | mov eax, 4 |
- | |
535 | mov ebx, [esp + 16] |
- | |
536 | shl ebx, 16 |
- | |
537 | add ebx, [esp + 12] |
- | |
538 | mov ecx, 2147483648 |
- | |
539 | or ecx, [esp + 4] |
- | |
540 | mov edx, [esp + 8] |
- | |
541 | int 64 |
- | |
542 | ret 16 |
- | |
543 | ; ======================================================================= ; |
- | |
544 | load.library: |
- | |
545 | mov eax, 68 |
- | |
546 | mov ebx, 19 |
- | |
547 | mov ecx, [esp + 4] |
- | |
548 | int 64 |
- | |
549 | ret 4 |
- | |
550 | ; ======================================================================= ; |
- | |
551 | getprocaddress: |
- | |
552 | mov edx, [esp + 8] ; hlib |
- | |
553 | xor eax, eax |
- | |
554 | test edx, edx ; If hlib = 0 then goto .end |
- | |
555 | jz .end |
- | |
556 | ; ----------------------- ; |
- | |
557 | .next: |
- | |
558 | cmp [edx], dword 0 ; If end of export table then goto .end |
- | |
559 | jz .end |
- | |
560 | - | ||
561 | xor eax, eax |
- | |
562 | mov esi, [edx] |
- | |
563 | mov edi, [esp + 4] ; name |
- | |
564 | ; ----------------------- ; |
- | |
565 | .next_: |
- | |
566 | lodsb |
- | |
567 | scasb |
- | |
568 | jne .fail |
- | |
569 | or al, al |
- | |
570 | jnz .next_ |
- | |
571 | jmp .ok |
- | |
572 | ; ----------------------- ; |
- | |
573 | .fail: |
- | |
574 | add edx, 8 |
- | |
575 | jmp .next |
- | |
576 | ; ----------------------- ; |
- | |
577 | .ok: ; return address |
- | |
578 | mov eax, [edx + 4] |
- | |
579 | ; ----------------------- ; |
- | |
580 | .end: |
- | |
581 | ret 8 |
- | |
582 | - | ||
583 | - | ||
584 | - | ||
585 | file_info: |
- | |
586 | dd 7 |
- | |
587 | dd 0 |
- | |
588 | runparams: |
- | |
589 | dd 0 |
- | |
590 | dd 0 |
- | |
591 | dd 0 |
- | |
592 | db 0 |
- | |
593 | runpath: |
- | |
594 | dd 0 |
- | |
595 | - | ||
596 | - | ||
597 | screen: |
- | |
598 | .height dw 0 |
- | |
599 | .width dw 0 |
- | |
600 | - | ||
601 | window: |
- | |
602 | .left dd 0 |
- | |
603 | .top dd 0 |
- | |
604 | .width dd 0 |
- | |
605 | .height dd 0 |
- | |
606 | - | ||
607 | box_lib dd 0 |
- | |
608 | - | ||
609 | edit1: |
- | |
610 | .width dd 0 |
- | |
611 | .left dd 5 |
- | |
612 | .top dd 19 |
- | |
613 | .color dd 0ffffffffh |
- | |
614 | .shift_color dd 0 |
- | |
615 | .focus_border_color dd 0 |
- | |
616 | .blur_border_color dd 0 |
- | |
617 | .text_color dd 0 |
- | |
618 | .max dd 4096 |
- | |
619 | .text dd 0 |
- | |
620 | .mouse_variable dd 0 |
- | |
621 | .flags dd 0x4002 ; always focus |
- | |
622 | .size dd 0 |
- | |
623 | .pos dd 0 |
- | |
624 | .offset dd 0 |
- | |
625 | .cl_curs_x dd 0 |
- | |
626 | .cl_curs_y dd 0 |
- | |
627 | .shift dd 0 |
- | |
628 | .shift_old dd 0 |
- | |
629 | - | ||
630 | edit_box_draw dd 0 |
- | |
631 | edit_box_key dd 0 |
- | |
632 | edit_box_mouse dd 0 |
- | |
633 | edit_box_set_text dd 0 |
- | |
634 | - | ||
635 | sc: |
- | |
636 | .frames dd 0 |
- | |
637 | .grab dd 0 |
- | |
638 | .work_3d_dark dd 0 |
- | |
639 | .work_3d_light dd 0 |
- | |
640 | .grab_text dd 0 |
- | |
641 | .work dd 0 |
- | |
642 | .work_button dd 0 |
- | |
643 | .work_button_text dd 0 |
- | |
644 | .work_text dd 0 |
- | |
645 | .work_graph dd 0 |
- | |
646 | - | ||
647 | proc_lib dd 0 |
- | |
648 | - | ||
649 | od: |
- | |
650 | .mode dd 0 |
- | |
651 | .procinfo dd 0 |
- | |
652 | .com_area_name dd sz_FFFFFFFF_open_dialog |
- | |
653 | .com_area dd 0 |
- | |
654 | .opendir_path dd 0 |
- | |
655 | .dir_default_path dd sz_SYS |
- | |
656 | .start_path dd sz_opendial_path |
- | |
657 | .draw_window dd on_redraw |
- | |
658 | .status dd 0 |
- | |
659 | .openfile_path dd 0 |
- | |
660 | .filename_area dd 0 |
- | |
661 | .filter_area dd filefilter |
- | |
662 | .x_size dw 414 |
- | |
663 | .x_start dw 0 |
- | |
664 | .y_size dw 414 |
- | |
665 | .y_start dw 0 |
- | |
666 | - | ||
667 | opendialog_init dd 0 |
- | |
668 | opendialog_start dd 0 |
- | |
669 | - | ||
670 | filefilter dd 0 |
- | |
671 | runresult dd sz_empty |
- | |
672 | - | ||
673 | lastendpath db 0 |
- | |
674 | ptrlastendpath dd 0 |
- | |
675 | - | ||
676 | sz_empty db 0 |
- | |
677 | - | ||
678 | sz_box_lib db "/sys/lib/box_lib.obj",0 |
- | |
679 | sz_edit_box db "edit_box",0 |
- | |
680 | sz_edit_box_key db "edit_box_key",0 |
- | |
681 | sz_edit_box_mouse db "edit_box_mouse",0 |
- | |
682 | sz_edit_box_set_text db "edit_box_set_text",0 |
- | |
683 | - | ||
684 | sz_proc_lib db "/sys/lib/proc_lib.obj",0 |
- | |
685 | sz_OpenDialog_init db "OpenDialog_init",0 |
- | |
686 | sz_OpenDialog_start db "OpenDialog_start",0 |
- | |
687 | sz_FFFFFFFF_open_dialog db "FFFFFFFF_open_dialog",0 |
- | |
688 | sz_SYS db "/sys",0 |
- | |
689 | sz_opendial_path db "/sys/File managers/opendial",0 |
- | |
690 | - | ||
691 | if lang eq it |
- | |
692 | sz_Program_run_successfully db "Programma eseguito correttamente",0 |
- | |
693 | sz_File_not_found db "File non trovato",0 |
- | |
694 | sz_File_is_not_executable db "File non eseguibile",0 |
- | |
695 | sz_Too_many_processes db "Troppi processi",0 |
- | |
696 | sz_Access_denied db "Accesso negato",0 |
- | |
697 | sz_Out_of_memory db "Out of memory",0 |
- | |
698 | sz_Unknown_error db "Errore sconosciuto",0 |
- | |
699 | - | ||
700 | sz_Type_name_of_program db "Digita il nome del programma per eseguirlo",0 |
- | |
701 | - | ||
702 | sz_run db "Esegui ",0 |
- | |
703 | sz_browse db " Naviga",0 |
- | |
704 | - | ||
705 | else |
- | |
706 | sz_Program_run_successfully db "Program run successfully",0 |
- | |
707 | sz_File_not_found db "File not found",0 |
- | |
708 | sz_File_is_not_executable db "File is not executable",0 |
- | |
709 | sz_Too_many_processes db "Too many processes",0 |
- | |
710 | sz_Access_denied db "Access denied",0 |
- | |
711 | sz_Out_of_memory db "Out of memory",0 |
- | |
712 | sz_Unknown_error db "Unknown error",0 |
- | |
713 | - | ||
714 | sz_Type_name_of_program db "Type name of program, and Kolibri will run it for you",0 |
- | |
715 | - | ||
716 | sz_run db " Run ",0 |
1 | ; Run with OpenDialog ; org 0 use32 STACK_SIZE equ 256 REDRAW_EVENT equ 1 KEY_EVENT equ 2 BUTTON_EVENT equ 3 MOUSE_EVENT equ 6 BUTTON_RUN equ 10 BUTTON_BROWSE equ 20 MENUET01 db 'MENUET01' version dd 1 program.start dd start_ program.end dd end_ program.memory dd end_ + STACK_SIZE program.stack dd end_ + STACK_SIZE program.params dd 0 program.path dd 0 include 'lang.inc' ; ======================================================================= ; start_: ; set.event mov eax, 40 mov ebx, 39 int 64 push sz_box_lib call load.library mov [box_lib], eax push dword[box_lib] push sz_edit_box call getprocaddress mov [edit_box_draw], eax push dword[box_lib] push sz_edit_box_key call getprocaddress mov [edit_box_key], eax push dword[box_lib] push sz_edit_box_mouse call getprocaddress mov [edit_box_mouse], eax push dword[box_lib] push sz_edit_box_set_text call getprocaddress mov [edit_box_set_text], eax push sz_proc_lib call load.library mov [proc_lib], eax push dword[proc_lib] push sz_OpenDialog_init call getprocaddress mov [opendialog_init], eax push dword[proc_lib] push sz_OpenDialog_start call getprocaddress mov [opendialog_start], eax ; memory.allocate: mov eax, 68 mov ebx, 12 mov ecx, 4096 + 4096 + 4096 int 64 mov [od.procinfo], eax add eax, 1024 mov [od.filename_area], eax add eax, 4096 - 1024 mov [od.opendir_path], eax add eax, 4096 mov [od.openfile_path], eax push od call [opendialog_init] ; get.screen.size mov eax, 61 mov ebx, 1 int 64 mov [screen], eax movzx eax, word[screen.width] shr eax, 3 lea eax, [eax*2 + eax] add eax, 8 mov [window.width], eax ; skin.height mov eax, 48 mov ebx, 4 int 64 add eax, 80 mov [window.height], eax movzx eax, word[screen.width] sub eax, [window.width] shr eax, 1 mov [window.left], eax movzx eax, word[screen.height] sub eax, [window.height] sub eax, 24 mov [window.top], eax mov eax, [window.width] sub eax, 46 mov [edit1.width], eax mov eax, [od.openfile_path] mov [edit1.text], eax call on_redraw ; ----------------------- ; .loop: ; wait.event mov eax, 10 int 64 cmp eax, REDRAW_EVENT jne .check_key call on_redraw jmp .loop ; ----------------------- ; .check_key: cmp eax, KEY_EVENT jne .check_button mov eax, 2 int 64 cmp ah, 13 jne .no_key_enter call on_button_run jmp .loop ; ----------------------- ; .no_key_enter: cmp ah, 185 jne .no_key_insert call on_button_browse jmp .loop .no_key_insert: push edit1 call [edit_box_key] jmp .loop ; ----------------------- ; .check_button: cmp eax, BUTTON_EVENT jne .check_mouse ; get.button.number mov eax, 17 int 64 cmp ah, 1 jne .check_button_run ; program.terminate or eax, -1 int 64 ; ----------------------- ; .check_button_run: cmp ah, BUTTON_RUN jne .check_button_browse call on_button_run jmp .loop ; ----------------------- ; .check_button_browse: cmp ah, BUTTON_BROWSE jne .loop call on_button_browse jmp .loop ; ----------------------- ; .check_mouse: cmp eax, MOUSE_EVENT jne .loop push edit1 call [edit_box_mouse] jmp .loop ; ======================================================================= ; on_button_run: push dword[edit1.text] call extractrunpathandparams ;file.run: mov eax, 70 mov ebx, file_info int 64 mov dl, byte[lastendpath] mov ecx, [ptrlastendpath] mov [ecx], dl test eax, eax jnge .error mov [runresult], dword sz_Program_run_successfully jmp .exit .error: ; ----------------------- ; .5: cmp al, -5 jne .31 mov [runresult], dword sz_File_not_found jmp .exit ; ----------------------- ; .31: cmp al, -31 jne .32 mov [runresult], dword sz_File_is_not_executable jmp .exit ; ----------------------- ; .32: cmp al, -32 jne .10 mov [runresult], dword sz_Too_many_processes jmp .exit ; ----------------------- ; .10: cmp al, -10 jne .30 mov [runresult], dword sz_Access_denied jmp .exit ; ----------------------- ; .30: cmp al, -30 jne .unknown mov [runresult], dword sz_Out_of_memory jmp .exit ; ----------------------- ; .unknown: mov [runresult], dword sz_Unknown_error ; ----------------------- ; .exit: call on_redraw ret ; ======================================================================= ; on_button_browse: push od call [opendialog_start] mov eax, [od.status] test eax, eax je .exit ;======== if space exist in filepath, then quote filepath mov eax, [od.openfile_path] ; ----------------------- ; .check_space: cmp [eax], byte 0 je .no_space cmp [eax], byte 32 ;space je .space inc eax jmp .check_space .space: ; ----------------------- ; .find_end_zero: inc eax cmp [eax], byte 0 jne .find_end_zero mov [eax + 2], byte 0 mov [eax + 1], byte 34 ; quote ; ----------------------- ; .shift_path: dec eax mov dl, byte [eax ] mov [eax + 1], dl cmp eax, [od.openfile_path] jne .shift_path mov [eax ], byte 34 ; quote .no_space: ;================================= push dword[od.openfile_path] push edit1 call [edit_box_set_text] ; ----------------------- ; .exit: ret ; ======================================================================= ; on_redraw: ; redraw.start mov eax, 12 mov ebx, 1 int 64 ; get.standart.colors mov eax, 48 mov ebx, 3 mov ecx, sc mov edx, 40 int 64 mov eax, [sc.work_graph] mov [edit1.shift_color], eax mov eax, [sc.work_graph] mov [edit1.focus_border_color], eax mov eax, [sc.frames] mov [edit1.blur_border_color], eax mov eax, [sc.work_text] mov [edit1.text_color], eax ; draw.window xor eax, eax mov ebx, [window.left] shl ebx, 16 add ebx, [window.width] mov ecx, [window.top] shl ecx, 16 add ecx, [window.height] mov edx, [sc.work] or edx, 34000000h mov edi, title int 64 mov eax, [window.width] sub eax, 318 shr eax, 1 sub eax, 5 push 5;eax push 5 push sz_Type_name_of_program push dword [sc.work_text] call draw.text ; ====================| browse button |==================== push 20 mov eax, [window.width] sub eax, 36 push eax push 19 push 19 push 14 call draw.button mov eax, [window.width] sub eax, 46 push eax push 22 push sz_browse push dword [sc.work_button_text] call draw.text ; ====================| run button |==================== push 10 push 5 push 38 mov eax, [window.width] sub eax, 22 push eax push 17 call draw.button mov eax, [window.width] sub eax, 31 push edx xor edx, edx mov ebx, 2 div ebx pop edx push eax push 42 push sz_run push dword [sc.work_button_text] call draw.text ; ===================================================== mov eax, 5 push eax mov eax, [window.height] sub eax, 40 push eax push dword[runresult] push dword [sc.work_text] call draw.text push edit1 call [edit_box_draw] ; redraw.finish mov eax, 12 mov ebx, 2 int 64 ret ; ======================================================================= ; extractrunpathandparams: xor ecx, ecx mov eax, [esp + 4] mov [runpath], eax movzx eax, byte [eax] cmp eax, 34 jne .start_without_quote inc ecx ; ----------------------- ; .loop1: mov eax, [runpath] movzx eax, byte [eax + ecx] cmp eax, 34 jne .not_quote mov eax, [runpath] mov [eax + ecx], byte 0 mov eax, [runpath] add eax, ecx mov [ptrlastendpath], eax mov [lastendpath], byte 34 inc ecx ; ----------------------- ; .skip_space1: mov eax, [runpath] movzx eax, byte [eax + ecx] cmp al, 32 jne .skipped1 inc ecx jmp .skip_space1 ; ----------------------- ; .skipped1: mov eax, [runpath] add eax, ecx mov [runparams], eax inc dword [runpath] jmp .exit ; ----------------------- ; .not_quote: mov eax, [runpath] movzx eax, byte [eax + ecx] test eax, eax jne .not_zero1 mov eax, [runpath] add eax, ecx mov [runparams], eax mov eax, [runpath] add eax, ecx mov [ptrlastendpath], eax mov [lastendpath], byte 0 jmp .exit ; ----------------------- ; .not_zero1: inc ecx jmp .loop1 ; ----------------------- ; .start_without_quote: ; ----------------------- ; .loop2: mov eax, [runpath] movzx eax, byte [eax + ecx] cmp eax, 32 jne .not_space mov eax, [runpath] mov [eax + ecx], byte 0 mov eax, [runpath] add eax, ecx mov [ptrlastendpath], eax mov [lastendpath], byte 32 inc ecx ; ----------------------- ; .skip_space2: mov eax, [runpath] movzx eax, byte [eax + ecx] cmp al, 32 jne .skipped2 inc ecx jmp .skip_space2 ; ----------------------- ; .skipped2: mov eax, [runpath] add eax, ecx mov [runparams], eax jmp .exit ; ----------------------- ; .not_space: mov eax, [runpath] movzx eax, byte [eax + ecx] test eax, eax jne .not_zero2 mov eax, [runpath] add eax, ecx mov [runparams], eax mov eax, [runpath] add eax, ecx mov [ptrlastendpath], eax mov [lastendpath], byte 0 jmp .exit ; ----------------------- ; .not_zero2: inc ecx jmp .loop2 ; ----------------------- ; .exit: ret 4 ; ======================================================================= ; draw.button: mov eax, 8 mov ebx, [esp + 16] shl ebx, 16 add ebx, [esp + 8] mov ecx, [esp + 12] shl ecx, 16 add ecx, [esp + 4] mov edx, [esp + 20] mov esi, [sc.work_button] int 64 ret 20 ; ======================================================================= ; draw.text: mov eax, 4 mov ebx, [esp + 16] shl ebx, 16 add ebx, [esp + 12] mov ecx, 2147483648 or ecx, [esp + 4] mov edx, [esp + 8] int 64 ret 16 ; ======================================================================= ; load.library: mov eax, 68 mov ebx, 19 mov ecx, [esp + 4] int 64 ret 4 ; ======================================================================= ; getprocaddress: mov edx, [esp + 8] ; hlib xor eax, eax test edx, edx ; If hlib = 0 then goto .end jz .end ; ----------------------- ; .next: cmp [edx], dword 0 ; If end of export table then goto .end jz .end xor eax, eax mov esi, [edx] mov edi, [esp + 4] ; name ; ----------------------- ; .next_: lodsb scasb jne .fail or al, al jnz .next_ jmp .ok ; ----------------------- ; .fail: add edx, 8 jmp .next ; ----------------------- ; .ok: ; return address mov eax, [edx + 4] ; ----------------------- ; .end: ret 8 file_info: dd 7 dd 0 runparams: dd 0 dd 0 dd 0 db 0 runpath: dd 0 screen: .height dw 0 .width dw 0 window: .left dd 0 .top dd 0 .width dd 0 .height dd 0 box_lib dd 0 edit1: .width dd 0 .left dd 5 .top dd 19 .color dd 0ffffffffh .shift_color dd 0 .focus_border_color dd 0 .blur_border_color dd 0 .text_color dd 0x90000000 .max dd 4096 .text dd 0 .mouse_variable dd 0 .flags dd 0x4002 ; always focus .size dd 0 .pos dd 0 .offset dd 0 .cl_curs_x dd 0 .cl_curs_y dd 0 .shift dd 0 .shift_old dd 0 edit_box_draw dd 0 edit_box_key dd 0 edit_box_mouse dd 0 edit_box_set_text dd 0 sc: .frames dd 0 .grab dd 0 .grab_button dd 0 .grab_button_text dd 0 .grab_text dd 0 .work dd 0 .work_button dd 0 .work_button_text dd 0 .work_text dd 0 .work_graph dd 0 proc_lib dd 0 od: .mode dd 0 .procinfo dd 0 .com_area_name dd sz_FFFFFFFF_open_dialog .com_area dd 0 .opendir_path dd 0 .dir_default_path dd sz_SYS .start_path dd sz_opendial_path .draw_window dd on_redraw .status dd 0 .openfile_path dd 0 .filename_area dd 0 .filter_area dd filefilter .x_size dw 414 .x_start dw 0 .y_size dw 414 .y_start dw 0 opendialog_init dd 0 opendialog_start dd 0 filefilter dd 0 runresult dd sz_empty lastendpath db 0 ptrlastendpath dd 0 sz_empty db 0 sz_box_lib db "/sys/lib/box_lib.obj",0 sz_edit_box db "edit_box",0 sz_edit_box_key db "edit_box_key",0 sz_edit_box_mouse db "edit_box_mouse",0 sz_edit_box_set_text db "edit_box_set_text",0 sz_proc_lib db "/sys/lib/proc_lib.obj",0 sz_OpenDialog_init db "OpenDialog_init",0 sz_OpenDialog_start db "OpenDialog_start",0 sz_FFFFFFFF_open_dialog db "FFFFFFFF_open_dialog",0 sz_SYS db "/sys",0 sz_opendial_path db "/sys/File managers/opendial",0 if lang eq it sz_Program_run_successfully db "Programma eseguito correttamente",0 sz_File_not_found db "File non trovato",0 sz_File_is_not_executable db "File non eseguibile",0 sz_Too_many_processes db "Troppi processi",0 sz_Access_denied db "Accesso negato",0 sz_Out_of_memory db "Out of memory",0 sz_Unknown_error db "Errore sconosciuto",0 sz_Type_name_of_program db "Digita il nome del programma per eseguirlo",0 sz_run db "Esegui ",0 sz_browse db " ...",0 title db "Esegui ",0 else if lang eq ru sz_Program_run_successfully db "à®£à ¬¬ § ¯ãé¥ ãᯥè®",0 sz_File_not_found db " ©« ¥ ©¤¥",0 sz_File_is_not_executable db " ©« ¥ ï¥âáï ¨á¯®«ï¥¬ë¬",0 sz_Too_many_processes db "«¨èª®¬ ¬®£® ¯à®æ¥áᮢ",0 sz_Access_denied db "®áâ㯠§ ¯à¥é¥",0 sz_Out_of_memory db "¥¤®áâ â®ç® ¯ ¬ïâ¨",0 sz_Unknown_error db "¥¨§¢¥áâ ï ®è¨¡ª ",0 sz_Type_name_of_program db "¢¥¤¨â¥ §¢ ¨¥ ¯à®£à ¬¬ë",0 sz_run db " ¯ãáâ¨âì",0 sz_browse db " ...",0 title db " ¯ã᪠¯à®£à ¬¬ë" else sz_Program_run_successfully db "Program run successfully",0 sz_File_not_found db "File not found",0 sz_File_is_not_executable db "File is not executable",0 sz_Too_many_processes db "Too many processes",0 sz_Access_denied db "Access denied",0 sz_Out_of_memory db "Out of memory",0 sz_Unknown_error db "Unknown error",0 sz_Type_name_of_program db "Type name of program, and Kolibri will run it for you",0 sz_run db " Run ",0 sz_browse db " ...",0 title db " Run ",0 end if end_: |
717 | sz_browse db " Browse ",0 |
- | |
718 | end if |
- | |
719 | ; ======================================================================= ; |
- | |
720 | end_: |
- | |
721 | - | ||
722 | 2 |