Rev 4911 | Rev 4913 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4591 | hidnplayr | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GUI ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
3 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
4 | |||
5 | ;----------------------------------------------------------------------------- |
||
6 | ; Color scheme |
||
7 | |||
8 | BLACK_ON_WHITE equ 0 |
||
9 | MOVIEOS equ 1 |
||
10 | WHITE_ON_BLACK equ 2 |
||
11 | |||
12 | ; format - 0xRRGGBB |
||
13 | if COLOR_THEME eq MOVIEOS |
||
14 | |||
15 | COLOR_BG_NORMAL = 0x1d272f |
||
16 | COLOR_BG_BREAKPOINT = 0x0000aa |
||
17 | COLOR_BG_SELECTED = 0xec9300 |
||
18 | COLOR_LINE = 0x00b9a0 |
||
19 | COLOR_TXT_NORMAL = 0xffffff |
||
20 | COLOR_TXT_INACTIVE = 0x8f7948 |
||
21 | COLOR_TXT_CHANGED = 0xec9300 |
||
4886 | hidnplayr | 22 | COLOR_TXT_LABEL = 0x22b14c |
4591 | hidnplayr | 23 | COLOR_TXT_SELECTED = 0x1d272f |
4888 | hidnplayr | 24 | COLOR_TXT_HEX = 0xec9300 |
4886 | hidnplayr | 25 | COLOR_TXT_BREAKPOINT = 0xec9300 |
4591 | hidnplayr | 26 | |
27 | else if COLOR_THEME eq WHITE_ON_BLACK |
||
28 | |||
29 | COLOR_BG_NORMAL = 0x101010 ; dark grey |
||
30 | COLOR_BG_BREAKPOINT = 0xFF0000 ; red |
||
31 | COLOR_BG_SELECTED = 0x0000FF ; blue |
||
32 | COLOR_LINE = 0xFFFFFF ; white |
||
33 | COLOR_TXT_NORMAL = 0xFFFFFF ; white |
||
34 | COLOR_TXT_INACTIVE = 0x808080 ; grey |
||
35 | COLOR_TXT_CHANGED = 0x00AA00 ; green |
||
4886 | hidnplayr | 36 | COLOR_TXT_LABEL = COLOR_TXT_NORMAL |
4591 | hidnplayr | 37 | COLOR_TXT_SELECTED = 0xFFFFFF ; white |
4888 | hidnplayr | 38 | COLOR_TXT_HEX = COLOR_TXT_NORMAL |
4886 | hidnplayr | 39 | COLOR_TXT_BREAKPOINT = COLOR_TXT_NORMAL |
4591 | hidnplayr | 40 | |
41 | else ; BLACK ON WHITE |
||
42 | |||
43 | COLOR_BG_NORMAL = 0xffffff ; white |
||
44 | COLOR_BG_BREAKPOINT = 0xFF0000 ; red |
||
45 | COLOR_BG_SELECTED = 0x0000FF ; blue |
||
46 | COLOR_LINE = 0x000000 ; black |
||
47 | COLOR_TXT_NORMAL = 0x000000 ; black |
||
48 | COLOR_TXT_INACTIVE = 0x808080 ; grey |
||
49 | COLOR_TXT_CHANGED = 0x00AA00 ; green |
||
4886 | hidnplayr | 50 | COLOR_TXT_LABEL = COLOR_TXT_NORMAL |
4591 | hidnplayr | 51 | COLOR_TXT_SELECTED = 0xFFFFFF ; white |
4888 | hidnplayr | 52 | COLOR_TXT_HEX = COLOR_TXT_NORMAL |
4886 | hidnplayr | 53 | COLOR_TXT_BREAKPOINT = COLOR_TXT_NORMAL |
4591 | hidnplayr | 54 | |
55 | end if |
||
56 | |||
57 | ;----------------------------------------------------------------------------- |
||
58 | |||
59 | data_width equ 80 |
||
60 | data_x_pos equ 12 |
||
61 | data_x_size equ data_width*6 |
||
62 | |||
63 | title_x_pos equ 30 |
||
4908 | hidnplayr | 64 | title_y_pos equ 8 |
4591 | hidnplayr | 65 | title_y_size equ 10 |
66 | |||
67 | ;dump_y_pos equ (registers_y_pos + registers_y_size + 5) |
||
68 | dump_y_pos equ (title_y_pos + title_y_size) |
||
69 | dump_height equ 6 |
||
70 | dump_y_size equ (dump_height*10) |
||
71 | |||
72 | disasm_y_pos equ (dump_y_pos + dump_y_size + 4) |
||
73 | disasm_height equ 18 |
||
74 | disasm_y_size equ (disasm_height*10) |
||
75 | |||
76 | messages_width equ data_width |
||
77 | messages_height equ 8 |
||
78 | messages_x_pos equ data_x_pos |
||
79 | messages_y_pos equ (disasm_y_pos + disasm_y_size + 4) |
||
80 | messages_x_size equ messages_width*6 |
||
81 | messages_y_size equ messages_height*10 |
||
82 | |||
83 | cmdline_width equ data_width |
||
84 | cmdline_x_pos equ data_x_pos |
||
85 | cmdline_y_pos equ (messages_y_pos + messages_y_size + 4) |
||
86 | cmdline_x_size equ messages_x_size |
||
87 | cmdline_y_size equ 10 |
||
88 | |||
89 | registers_x_pos equ (data_x_pos + messages_x_size + 4) |
||
90 | registers_y_pos equ (title_y_pos + title_y_size - 3) |
||
4906 | Serge | 91 | registers_x_size equ 134+2*6 |
4591 | hidnplayr | 92 | registers_y_size equ (cmdline_y_pos + cmdline_y_size - registers_y_pos+1) |
93 | |||
4908 | hidnplayr | 94 | wnd_x_size equ (data_x_pos + messages_x_size + data_x_pos + registers_x_size+3) + 10 |
4591 | hidnplayr | 95 | wnd_y_size equ (cmdline_y_pos + cmdline_y_size + data_x_pos) |
96 | |||
97 | ;----------------------------------------------------------------------------- |
||
98 | ; Entry point |
||
99 | |||
100 | ; TODO: split all gui part in independent function, move entry point into mtdbg.asm |
||
101 | |||
102 | start: |
||
4890 | hidnplayr | 103 | ; initialize process heap |
4591 | hidnplayr | 104 | mcall 68, 11 |
4902 | Serge | 105 | |
106 | push eax |
||
107 | fstcw word [esp] |
||
4909 | Serge | 108 | pop eax |
109 | and ax, not (3 shl 10) |
||
110 | or ax, 1 shl 10 ; set round-to-minus infinity mode |
||
111 | push eax |
||
4902 | Serge | 112 | fldcw word [esp] |
113 | pop eax |
||
114 | |||
4591 | hidnplayr | 115 | mov edi, messages |
116 | mov ecx, messages_width*messages_height |
||
117 | mov al, ' ' |
||
118 | rep stosb |
||
119 | xor eax, eax |
||
120 | mov [messages_pos], eax |
||
121 | mov [cmdline_len], eax |
||
122 | mov [cmdline_pos], eax |
||
123 | mov edi, needzerostart |
||
124 | mov ecx, (needzeroend-needzerostart+3)/4 |
||
125 | rep stosd |
||
126 | mov esi, begin_str |
||
127 | call put_message_nodraw |
||
4890 | hidnplayr | 128 | ; set event mask - default events and debugging events |
4591 | hidnplayr | 129 | mcall 40, 0x107 |
4890 | hidnplayr | 130 | ; set debug messages buffer |
4591 | hidnplayr | 131 | mov ecx, dbgbufsize |
132 | mov dword [ecx], 256 |
||
133 | xor ebx, ebx |
||
134 | mov [ecx+4], ebx |
||
135 | mov al, 69 |
||
136 | mcall |
||
137 | mov esi, i_param |
||
138 | call get_arg.skip_spaces |
||
139 | test al, al |
||
140 | jz dodraw |
||
141 | push esi |
||
142 | call draw_window |
||
143 | pop esi |
||
144 | call OnLoadInit |
||
145 | jmp waitevent |
||
146 | |||
147 | dodraw: |
||
148 | call draw_window |
||
149 | |||
150 | waitevent: |
||
151 | mcall 10 |
||
152 | cmp al, 9 |
||
153 | jz debugmsg |
||
154 | dec eax |
||
155 | jz dodraw |
||
156 | dec eax |
||
157 | jz keypressed |
||
158 | dec eax |
||
159 | jnz waitevent |
||
4890 | hidnplayr | 160 | ; button pressed - we have only one button (close) |
4591 | hidnplayr | 161 | mcall -1 |
162 | |||
163 | ; TODO: split in more independent function |
||
164 | keypressed: |
||
165 | mov al, 2 |
||
166 | mcall |
||
167 | shr eax, 8 |
||
168 | cmp al, 8 |
||
169 | jz .backspace |
||
170 | cmp al, 0xB0 |
||
171 | jz .left |
||
172 | cmp al, 0xB3 |
||
173 | jz .right |
||
174 | cmp al, 0x0D |
||
175 | jz .enter |
||
176 | cmp al, 0xB6 |
||
177 | jz .del |
||
178 | cmp al, 0xB4 |
||
179 | jz .home |
||
180 | cmp al, 0xB5 |
||
181 | jz .end |
||
182 | cmp al, 0xB1 |
||
183 | jz .down |
||
184 | cmp al, 0xB2 |
||
4594 | hidnplayr | 185 | jz .up |
186 | cmp ah, 0x41 |
||
187 | jz F7 |
||
188 | cmp ah, 0x42 |
||
189 | jz F8 |
||
190 | cmp [cmdline_len], cmdline_width |
||
4591 | hidnplayr | 191 | jae waitevent |
192 | push eax |
||
193 | call clear_cmdline_end |
||
194 | pop eax |
||
195 | mov edi, cmdline |
||
196 | mov ecx, [cmdline_len] |
||
197 | add edi, ecx |
||
198 | lea esi, [edi-1] |
||
199 | sub ecx, [cmdline_pos] |
||
200 | std |
||
201 | rep movsb |
||
202 | cld |
||
203 | stosb |
||
204 | inc [cmdline_len] |
||
205 | call draw_cmdline_end |
||
206 | inc [cmdline_pos] |
||
207 | call draw_cursor |
||
208 | jmp waitevent |
||
209 | |||
210 | .backspace: |
||
211 | cmp [cmdline_pos], 0 |
||
212 | jz waitevent |
||
213 | dec [cmdline_pos] |
||
214 | |||
215 | .delchar: |
||
216 | call clear_cmdline_end |
||
217 | mov edi, [cmdline_pos] |
||
218 | dec [cmdline_len] |
||
219 | mov ecx, [cmdline_len] |
||
220 | sub ecx, edi |
||
221 | add edi, cmdline |
||
222 | lea esi, [edi+1] |
||
223 | rep movsb |
||
224 | call draw_cmdline_end |
||
225 | call draw_cursor |
||
226 | jmp waitevent |
||
227 | |||
228 | .del: |
||
229 | mov eax, [cmdline_pos] |
||
230 | cmp eax, [cmdline_len] |
||
231 | jae waitevent |
||
232 | jmp .delchar |
||
233 | |||
234 | .left: |
||
235 | cmp [cmdline_pos], 0 |
||
236 | jz waitevent |
||
237 | call hide_cursor |
||
238 | dec [cmdline_pos] |
||
239 | call draw_cursor |
||
240 | jmp waitevent |
||
241 | |||
242 | .right: |
||
243 | mov eax, [cmdline_pos] |
||
244 | cmp eax, [cmdline_len] |
||
245 | jae waitevent |
||
246 | call hide_cursor |
||
247 | inc [cmdline_pos] |
||
248 | call draw_cursor |
||
249 | jmp waitevent |
||
250 | |||
251 | .home: |
||
252 | call hide_cursor |
||
253 | and [cmdline_pos], 0 |
||
254 | call draw_cursor |
||
255 | jmp waitevent |
||
256 | |||
257 | .end: |
||
258 | call hide_cursor |
||
259 | mov eax, [cmdline_len] |
||
260 | mov [cmdline_pos], eax |
||
261 | call draw_cursor |
||
262 | |||
263 | .up: |
||
264 | .down: |
||
265 | jmp waitevent |
||
266 | |||
4890 | hidnplayr | 267 | ; We also trying to execute previous command, if empty command_line |
4591 | hidnplayr | 268 | .enter: |
269 | mov ecx, [cmdline_len] |
||
270 | test ecx, ecx |
||
271 | jnz .exec_cur |
||
272 | mov cl, byte [cmdline_prev] |
||
273 | cmp cl, 0 |
||
274 | jz waitevent |
||
275 | |||
276 | .exec_prev: |
||
277 | mov esi, cmdline_prev |
||
278 | jmp .exec |
||
279 | |||
280 | .exec_cur: |
||
281 | mov esi, cmdline |
||
282 | |||
283 | .exec: |
||
284 | mov byte [esi+ecx], 0 |
||
285 | and [cmdline_pos], 0 |
||
286 | push esi |
||
287 | call clear_cmdline_end |
||
288 | call draw_cursor |
||
289 | pop esi |
||
290 | and [cmdline_len], 0 |
||
4890 | hidnplayr | 291 | ; skip leading spaces |
4591 | hidnplayr | 292 | call get_arg.skip_spaces |
293 | cmp al, 0 |
||
294 | jz waitevent |
||
4890 | hidnplayr | 295 | ; now esi points to command |
4591 | hidnplayr | 296 | push esi |
297 | mov esi, prompt |
||
298 | call put_message_nodraw |
||
299 | pop esi |
||
300 | push esi |
||
301 | call put_message_nodraw |
||
302 | |||
303 | ; TODO: add meaningful name |
||
304 | z1: |
||
305 | mov esi, newline |
||
306 | call put_message |
||
307 | pop esi |
||
308 | push esi |
||
309 | call get_arg |
||
310 | mov [curarg], esi |
||
311 | pop edi |
||
312 | mov esi, commands |
||
313 | call find_cmd |
||
314 | mov eax, aUnknownCommand |
||
315 | jc .x11 |
||
316 | |||
4890 | hidnplayr | 317 | ; check command requirements |
318 | ; flags field: |
||
319 | ; &1: command may be called without parameters |
||
320 | ; &2: command may be called with parameters |
||
321 | ; &4: command may be called without loaded program |
||
322 | ; &8: command may be called with loaded program |
||
4591 | hidnplayr | 323 | mov eax, [esi+8] |
324 | mov ecx, [curarg] |
||
325 | cmp byte [ecx], 0 |
||
326 | jz .noargs |
||
327 | test byte [esi+16], 2 |
||
328 | jz .x11 |
||
329 | jmp @f |
||
330 | |||
331 | .noargs: |
||
332 | test byte [esi+16], 1 |
||
333 | jz .x11 |
||
334 | |||
335 | @@: |
||
336 | cmp [debuggee_pid], 0 |
||
337 | jz .nodebuggee |
||
338 | mov eax, aAlreadyLoaded |
||
339 | test byte [esi+16], 8 |
||
340 | jz .x11 |
||
341 | jmp .x9 |
||
342 | |||
343 | .nodebuggee: |
||
344 | mov eax, need_debuggee |
||
345 | test byte [esi+16], 4 |
||
346 | jnz .x9 |
||
347 | |||
348 | .x11: |
||
349 | xchg esi, eax |
||
350 | call put_message |
||
351 | |||
4890 | hidnplayr | 352 | ; store cmdline for repeating |
4591 | hidnplayr | 353 | .x10: |
354 | mov esi, cmdline |
||
355 | mov ecx, [cmdline_len] |
||
356 | |||
357 | @@: |
||
358 | cmp ecx, 0 |
||
359 | jle .we |
||
360 | mov al, [esi + ecx] |
||
361 | mov [cmdline_prev + ecx], al |
||
362 | dec ecx |
||
363 | jmp @b |
||
364 | |||
365 | .we: |
||
366 | mov [cmdline_len], 0 |
||
367 | jmp waitevent |
||
368 | |||
369 | .x9: |
||
370 | call dword [esi+4] |
||
371 | jmp .x10 |
||
372 | |||
373 | ;----------------------------------------------------------------------------- |
||
374 | ; Cmdline handling |
||
375 | |||
376 | clear_cmdline_end: |
||
377 | mov ebx, [cmdline_pos] |
||
378 | mov ecx, [cmdline_len] |
||
379 | sub ecx, ebx |
||
380 | imul ebx, 6 |
||
381 | imul ecx, 6 |
||
382 | inc ecx |
||
383 | add ebx, cmdline_x_pos |
||
384 | shl ebx, 16 |
||
385 | or ebx, ecx |
||
4908 | hidnplayr | 386 | mov ecx, [cmdline_y_pos_dd] |
387 | mov cx, cmdline_y_size |
||
4591 | hidnplayr | 388 | mov edx, COLOR_BG_NORMAL |
389 | ; draw container rectangle/box for cmdline |
||
390 | mcall 13 |
||
391 | ret |
||
392 | |||
393 | draw_cmdline: |
||
394 | xor ebx, ebx |
||
395 | jmp @f |
||
396 | |||
397 | ; TODO: make it local |
||
398 | draw_cmdline_end: |
||
399 | mov ebx, [cmdline_pos] |
||
400 | |||
401 | @@: |
||
402 | mov esi, [cmdline_len] |
||
403 | sub esi, ebx |
||
4890 | hidnplayr | 404 | |
4591 | hidnplayr | 405 | mov ecx, COLOR_TXT_NORMAL |
406 | lea edx, [cmdline+ebx] |
||
407 | imul ebx, 6 |
||
408 | add ebx, cmdline_x_pos |
||
409 | shl ebx, 16 |
||
4908 | hidnplayr | 410 | mov bx, word[cmdline_y_pos_dd+4] |
411 | inc bx |
||
4890 | hidnplayr | 412 | ; draw a text string in the window |
4591 | hidnplayr | 413 | mcall 4 |
414 | ret |
||
415 | |||
416 | ;----------------------------------------------------------------------------- |
||
417 | ; Working with messages |
||
418 | ; in: esi->ASCIIZ message |
||
419 | put_message_nodraw: |
||
420 | mov edx, [messages_pos] |
||
421 | |||
422 | .m: |
||
423 | lea edi, [messages+edx] |
||
424 | |||
425 | .l: |
||
426 | lodsb |
||
427 | cmp al, 0 |
||
428 | jz .done |
||
429 | call test_scroll |
||
430 | cmp al, 10 |
||
431 | jz .newline |
||
432 | cmp al, '%' |
||
433 | jnz @f |
||
434 | cmp dword [esp], z1 |
||
435 | jnz .format |
||
436 | |||
437 | @@: |
||
438 | stosb |
||
439 | inc edx |
||
440 | jmp .l |
||
441 | |||
442 | .newline: |
||
443 | push edx |
||
444 | mov ecx, messages_width |
||
445 | xor eax, eax |
||
446 | xchg eax, edx |
||
447 | div ecx |
||
448 | xchg eax, edx |
||
449 | pop edx |
||
450 | test eax, eax |
||
451 | jz .m |
||
452 | sub edx, eax |
||
453 | add edx, ecx |
||
454 | jmp .m |
||
455 | |||
456 | .done: |
||
457 | mov [messages_pos], edx |
||
458 | ret |
||
459 | |||
4890 | hidnplayr | 460 | ; at this moment all format specs must be % |
4591 | hidnplayr | 461 | .format: |
462 | lodsb ; get |
||
463 | sub al, '0' |
||
464 | movzx ecx, al |
||
465 | lodsb |
||
466 | pop eax |
||
467 | pop ebp |
||
468 | push eax |
||
4890 | hidnplayr | 469 | ; write number in ebp with ecx digits |
4591 | hidnplayr | 470 | dec ecx |
471 | shl ecx, 2 |
||
472 | |||
473 | .writenibble: |
||
474 | push ecx |
||
475 | call test_scroll |
||
476 | pop ecx |
||
477 | mov eax, ebp |
||
478 | shr eax, cl |
||
479 | and al, 0xF |
||
480 | cmp al, 10 |
||
481 | sbb al, 69h |
||
482 | das |
||
483 | stosb |
||
484 | inc edx |
||
485 | sub ecx, 4 |
||
486 | jns .writenibble |
||
487 | jmp .l |
||
488 | |||
489 | test_scroll: |
||
490 | cmp edx, messages_width*messages_height |
||
491 | jnz .ret |
||
492 | push esi |
||
493 | mov edi, messages |
||
494 | lea esi, [edi+messages_width] |
||
495 | mov ecx, (messages_height-1)*messages_width/4 |
||
496 | rep movsd |
||
497 | push eax |
||
498 | mov al, ' ' |
||
499 | push edi |
||
500 | push messages_width |
||
501 | pop ecx |
||
502 | sub edx, ecx |
||
503 | rep stosb |
||
504 | pop edi |
||
505 | pop eax |
||
506 | pop esi |
||
507 | |||
508 | .ret: |
||
509 | ret |
||
510 | |||
511 | ;----------------------------------------------------------------------------- |
||
512 | |||
513 | put_message: |
||
514 | call put_message_nodraw |
||
515 | |||
516 | draw_messages: |
||
4890 | hidnplayr | 517 | ; draw container rectangle/box |
4908 | hidnplayr | 518 | mov ebx, messages_x_pos shl 16 |
519 | add ebx, [messages_x_size_dd+4] |
||
520 | mov ecx, [messages_y_pos_dd] |
||
521 | mov cx, messages_y_size |
||
522 | mcall 13, , , COLOR_BG_NORMAL |
||
4591 | hidnplayr | 523 | mov edx, messages |
524 | push messages_width |
||
525 | pop esi |
||
526 | mov ecx, COLOR_TXT_NORMAL |
||
4908 | hidnplayr | 527 | mov ebx, messages_x_pos*10000h |
528 | mov bx, word[messages_y_pos_dd+4] |
||
4591 | hidnplayr | 529 | |
530 | @@: |
||
531 | ; display text string in the window |
||
532 | mcall 4 |
||
533 | add edx, esi |
||
534 | add ebx, 10 |
||
535 | cmp edx, messages+messages_width*messages_height |
||
536 | jb @b |
||
537 | ret |
||
538 | |||
539 | ;----------------------------------------------------------------------------- |
||
540 | ; Show/hide cursor in command line |
||
541 | |||
542 | ; TODO: make it cursor.draw and cursor.hide ??? |
||
543 | draw_cursor: |
||
4908 | hidnplayr | 544 | mov ecx, [cmdline_y_pos_dd+2] |
545 | add cx, cmdline_y_size-1 |
||
4591 | hidnplayr | 546 | mov ebx, [cmdline_pos] |
547 | imul ebx, 6 |
||
548 | add ebx, cmdline_x_pos |
||
549 | mov edx, ebx |
||
550 | shl ebx, 16 |
||
551 | or ebx, edx |
||
4888 | hidnplayr | 552 | mov edx, COLOR_TXT_NORMAL |
553 | ; draw line |
||
4591 | hidnplayr | 554 | mcall 38 |
555 | ret |
||
556 | |||
557 | hide_cursor: |
||
558 | mov ebx, [cmdline_pos] |
||
559 | imul ebx, 6 |
||
560 | add ebx, cmdline_x_pos |
||
561 | shl ebx, 16 |
||
562 | inc ebx |
||
4908 | hidnplayr | 563 | mov ecx, [cmdline_y_pos_dd] |
564 | mov cx, cmdline_y_size |
||
4591 | hidnplayr | 565 | mov edx, COLOR_BG_NORMAL |
566 | ; draw container rectangle/box |
||
567 | mcall 13 |
||
568 | mov ebx, [cmdline_pos] |
||
569 | cmp ebx, [cmdline_len] |
||
570 | jae .ret |
||
571 | ; setting up text color scheme and attributes |
||
572 | mov ecx, COLOR_TXT_NORMAL |
||
573 | lea edx, [cmdline+ebx] |
||
574 | imul ebx, 6 |
||
575 | add ebx, cmdline_x_pos |
||
576 | shl ebx, 16 |
||
4908 | hidnplayr | 577 | mov bx, word[cmdline_y_pos_dd+4] |
578 | inc bx |
||
4591 | hidnplayr | 579 | push 1 |
580 | pop esi |
||
581 | ; draw text string in the window |
||
582 | mcall 4 |
||
583 | |||
584 | .ret: |
||
585 | ret |
||
586 | |||
587 | ;----------------------------------------------------------------------------- |
||
588 | ; Draw program window title |
||
589 | |||
590 | ; FIXME: something wrong here |
||
591 | redraw_title: |
||
592 | ; draw container rectangle/box |
||
4908 | hidnplayr | 593 | mov ebx, [data_x_size_dd+4] |
594 | add ebx, title_x_pos*10000h+data_x_pos-title_x_pos |
||
595 | mcall 13, , title_y_pos*10000h+title_y_size, COLOR_BG_NORMAL |
||
4591 | hidnplayr | 596 | |
597 | draw_title: |
||
598 | mcall 38, (data_x_pos-2)*10000h+title_x_pos-5, (title_y_pos+5)*10001h, COLOR_LINE |
||
599 | push NoPrgLoaded_len |
||
600 | pop esi |
||
601 | cmp [debuggee_pid], 0 |
||
602 | jz @f |
||
603 | mov esi, [prgname_len] |
||
604 | |||
605 | @@: |
||
606 | imul ebx, esi, 6 |
||
607 | add ebx, title_x_pos+4 |
||
608 | shl ebx, 16 |
||
4908 | hidnplayr | 609 | mov bx, data_x_pos-10-5-6*7 |
610 | add bx, word[data_x_size_dd+4] |
||
4591 | hidnplayr | 611 | cmp [bSuspended], 0 |
612 | jz @f |
||
613 | add ebx, 6 |
||
614 | |||
615 | @@: |
||
616 | ; draw line with COLOR_LINE (in edx) |
||
617 | mcall |
||
4908 | hidnplayr | 618 | mov ebx, [data_x_size_dd+2] |
619 | add ebx, (data_x_pos-10+4)*0x10000 + data_x_pos+2 |
||
4591 | hidnplayr | 620 | ; draw line with COLOR_LINE (in edx) |
621 | mcall |
||
622 | mov al, 4 |
||
623 | mov ebx, title_x_pos*10000h+title_y_pos |
||
624 | ; setting up text color scheme and attributes |
||
625 | mov ecx, COLOR_TXT_NORMAL |
||
626 | mov edx, NoPrgLoaded_str |
||
627 | cmp [debuggee_pid], 0 |
||
628 | jz @f |
||
629 | mov edx, [prgname_ptr] |
||
630 | |||
631 | @@: |
||
632 | ; draw text string in the window |
||
633 | mcall |
||
634 | cmp [debuggee_pid], 0 |
||
635 | jz .nodebuggee |
||
4908 | hidnplayr | 636 | mov ebx, [data_x_size_dd] |
637 | add ebx, (data_x_pos-10-6*7)*10000h + title_y_pos |
||
4591 | hidnplayr | 638 | mov edx, aRunning |
639 | push 7 |
||
640 | pop esi |
||
641 | cmp [bSuspended], 0 |
||
642 | jz @f |
||
643 | add ebx, 6*10000h |
||
644 | mov edx, aPaused |
||
645 | dec esi |
||
646 | |||
647 | @@: |
||
648 | ; draw line with COLOR_LINE (in edx) in one case |
||
649 | ; and draw text string with color COLOR_TXT_NORMAL (in ecx) in another |
||
650 | mcall |
||
651 | ret |
||
652 | |||
653 | .nodebuggee: |
||
654 | mov al, 38 |
||
4908 | hidnplayr | 655 | mov ebx, [data_x_size_dd+2] |
656 | add ebx, (data_x_pos-10-6*7-5)*0x10000 + data_x_pos+2 |
||
4591 | hidnplayr | 657 | mov ecx, (title_y_pos+5)*10001h |
658 | mov edx, COLOR_LINE |
||
659 | jmp @b |
||
660 | |||
661 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
662 | ;;;;;;;;;;;;;;;;;;; REGISTERS PANEL ;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
663 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
664 | |||
665 | ;----------------------------------------------------------------------------- |
||
666 | ; Display common register content |
||
667 | |||
668 | ; TODO: add format support (e.g. numerical value, or address offset/pointer) |
||
669 | |||
670 | ; in: esi->value, edx->string, ecx = string length, ebx = coord |
||
671 | draw_register: |
||
4906 | Serge | 672 | push esi |
4591 | hidnplayr | 673 | push edx |
674 | push ecx |
||
4906 | Serge | 675 | push ebp |
4890 | hidnplayr | 676 | |
4906 | Serge | 677 | mov ebp, ecx |
678 | |||
4907 | Serge | 679 | mov eax, [esi] |
680 | |||
4591 | hidnplayr | 681 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
682 | cmp [debuggee_pid], 0 |
||
683 | jz .cd |
||
684 | cmp [bSuspended], 0 |
||
685 | jz .cd |
||
4890 | hidnplayr | 686 | |
4591 | hidnplayr | 687 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
4906 | Serge | 688 | cmp eax, dword [esi+oldcontext-context] |
689 | je .cd |
||
4591 | hidnplayr | 690 | mov ecx, (COLOR_TXT_CHANGED or 0x40000000) |
4906 | Serge | 691 | .cd: |
692 | push eax ;store reg value |
||
4591 | hidnplayr | 693 | |
4906 | Serge | 694 | mov esi, ebp |
4591 | hidnplayr | 695 | ; draw a text string in the window |
696 | mcall 4 |
||
4906 | Serge | 697 | |
4591 | hidnplayr | 698 | imul esi, 60000h |
699 | lea edx, [ebx+esi] |
||
700 | mov esi, ecx |
||
701 | pop ecx |
||
4890 | hidnplayr | 702 | |
4591 | hidnplayr | 703 | ; draw a number in the window |
4906 | Serge | 704 | rol ecx, 16 |
705 | mcall 47, 0x00040100 |
||
4591 | hidnplayr | 706 | |
4906 | Serge | 707 | shr ecx, 16 |
708 | add edx, (4*6+3) shl 16 |
||
709 | mcall 47 |
||
4900 | Serge | 710 | |
4906 | Serge | 711 | pop ebp |
4900 | Serge | 712 | pop ecx |
4591 | hidnplayr | 713 | pop edx |
4906 | Serge | 714 | pop esi |
4591 | hidnplayr | 715 | add edx, ecx |
716 | ret |
||
717 | |||
718 | ;----------------------------------------------------------------------------- |
||
4900 | Serge | 719 | ; Display FPU register (ST0 - ST7) content |
720 | ; |
||
4906 | Serge | 721 | ; in: ebp->index, ebx = coord |
722 | |||
4900 | Serge | 723 | draw_fpu_register_2: |
724 | |||
725 | .str_buf equ esp |
||
4912 | Serge | 726 | .cvt_buf equ .str_buf+32 |
727 | .bcd_man equ .cvt_buf+16 |
||
728 | .bcd_exp equ .bcd_man+10 |
||
729 | .exp equ .bcd_exp+10 |
||
4910 | Serge | 730 | .tmp equ .exp+4 |
4912 | Serge | 731 | .lcl_end equ .tmp+4 |
4900 | Serge | 732 | |
4912 | Serge | 733 | sub esp, 32+16+10+10+4+4 |
4900 | Serge | 734 | |
4901 | Serge | 735 | mov edi, .str_buf |
4912 | Serge | 736 | shl ebp, 16 |
737 | lea eax, ['ST0:'+ebp] |
||
4901 | Serge | 738 | stosd |
4912 | Serge | 739 | mov eax, 0x20202020 |
4901 | Serge | 740 | stosd |
741 | stosd |
||
742 | stosd |
||
4912 | Serge | 743 | stosd |
744 | stosd |
||
4901 | Serge | 745 | |
4909 | Serge | 746 | ;int3 |
747 | ;nop |
||
748 | |||
4901 | Serge | 749 | movzx eax, word [_fsw] |
750 | shr eax, 11 |
||
751 | add eax, ebp |
||
4912 | Serge | 752 | shr ebp, 12 |
4901 | Serge | 753 | and eax, 7 |
754 | bt dword [_ftw], eax |
||
755 | jc .A6M |
||
756 | |||
4912 | Serge | 757 | mov dword [.str_buf+8],' emp' |
758 | mov word [.str_buf+8+4],'ty' |
||
4901 | Serge | 759 | jmp .display |
760 | |||
4912 | Serge | 761 | mov cx, [_st0+ebp+8] |
4901 | Serge | 762 | and cx, 0x7FFF ;clear sign flag |
763 | jz .A6M |
||
764 | |||
765 | cmp cx, 0x7FFF |
||
766 | jne .decode |
||
767 | |||
4912 | Serge | 768 | mov dword [.str_buf+6], ' inv' |
769 | mov dword [.str_buf+6+4], 'alid' |
||
4901 | Serge | 770 | jmp .display |
771 | |||
772 | .A6M: |
||
773 | |||
4912 | Serge | 774 | mov eax, dword [_st0+ebp] |
775 | or eax, dword [_st0+ebp+4] |
||
4901 | Serge | 776 | jnz .decode |
777 | |||
4912 | Serge | 778 | mov dword [.str_buf+10], ' 0.0' |
4901 | Serge | 779 | jmp .display |
780 | |||
781 | .decode: |
||
4912 | Serge | 782 | fld tword [_st0+ebp] |
4910 | Serge | 783 | fabs |
784 | fld st0 |
||
4900 | Serge | 785 | fldlg2 |
4910 | Serge | 786 | fld st1 |
4900 | Serge | 787 | fyl2x |
788 | frndint |
||
4910 | Serge | 789 | fist dword [.exp] |
4900 | Serge | 790 | fld st0 |
791 | fbstp tword [.bcd_exp] |
||
4910 | Serge | 792 | |
4900 | Serge | 793 | fldl2t |
794 | fmulp |
||
795 | fld st0 |
||
796 | frndint |
||
797 | fxch |
||
798 | fsub st,st1 |
||
799 | |||
800 | f2xm1 |
||
801 | fld1 |
||
802 | faddp |
||
803 | fscale |
||
804 | fstp st1 |
||
805 | fdivp |
||
4910 | Serge | 806 | |
807 | fist dword [.tmp] |
||
808 | cmp dword [.tmp], 10 |
||
809 | jae .fixup |
||
810 | |||
811 | fstp st1 |
||
812 | jmp .done |
||
813 | |||
814 | .fixup: |
||
815 | fstp st0 |
||
816 | |||
817 | inc dword [.exp] |
||
818 | fild dword [.exp] |
||
819 | fld st0 |
||
4912 | Serge | 820 | fbstp tword [.bcd_exp] |
4910 | Serge | 821 | |
822 | fldl2t |
||
823 | fmulp |
||
824 | fld st0 |
||
825 | frndint |
||
826 | fxch |
||
4912 | Serge | 827 | fsub st,st1 |
4910 | Serge | 828 | |
829 | f2xm1 |
||
830 | fld1 |
||
831 | faddp |
||
832 | fscale |
||
4912 | Serge | 833 | fstp st1 |
4910 | Serge | 834 | fdivp |
835 | .done: |
||
4912 | Serge | 836 | fimul dword [n_digits] |
4900 | Serge | 837 | fbstp tword [.bcd_man] |
838 | |||
4912 | Serge | 839 | lea edi, [.cvt_buf] |
840 | mov edx, dword [.bcd_man] |
||
841 | mov ecx, 8 |
||
842 | @@: |
||
843 | xor eax, eax |
||
844 | shld eax, edx, 4 |
||
4900 | Serge | 845 | stosb |
4912 | Serge | 846 | shl edx, 4 |
847 | loop @B |
||
4900 | Serge | 848 | |
4912 | Serge | 849 | lea esi, [.cvt_buf+7] |
850 | lea edi, [.str_buf+13] |
||
851 | mov ecx, 7 |
||
852 | mov ah, 0x30 |
||
853 | std |
||
854 | .skip_z: |
||
855 | lodsb |
||
4900 | Serge | 856 | test al, al |
4912 | Serge | 857 | jnz .body |
858 | loop .skip_z |
||
859 | .body: |
||
860 | add al, ah |
||
4900 | Serge | 861 | stosb |
4912 | Serge | 862 | lodsb |
863 | jcxz .point |
||
864 | loop .body |
||
865 | .point: |
||
866 | dec edi |
||
867 | add al, ah |
||
868 | mov ah, '.' |
||
4900 | Serge | 869 | stosw |
870 | |||
4912 | Serge | 871 | bt word [_st0+ebp+8], 15 |
872 | jnc .m_sign |
||
4900 | Serge | 873 | mov al, '-' |
4912 | Serge | 874 | mov [edi+1], al |
4901 | Serge | 875 | |
4912 | Serge | 876 | .m_sign: |
877 | cld |
||
4900 | Serge | 878 | |
4912 | Serge | 879 | mov dx, word [.bcd_exp] |
880 | test dx, dx |
||
881 | jz .display |
||
4900 | Serge | 882 | |
4912 | Serge | 883 | lea edi, [.str_buf+15] |
884 | mov ax, 'E ' |
||
885 | cmp byte [.bcd_exp+9], 0x80 |
||
886 | jne .w_e_sign |
||
887 | mov ax, 'E-' |
||
4901 | Serge | 888 | |
4912 | Serge | 889 | .w_e_sign: |
890 | stosw |
||
4901 | Serge | 891 | |
4912 | Serge | 892 | mov ecx, 4 |
893 | .skip_lz: |
||
894 | xor eax, eax |
||
895 | shld ax,dx,4 |
||
896 | shl dx, 4 |
||
897 | test al, al |
||
898 | jnz .w_exp |
||
899 | loop .skip_lz |
||
900 | .w_exp: |
||
901 | add al, 0x30 |
||
4900 | Serge | 902 | stosb |
4912 | Serge | 903 | xor eax, eax |
904 | shld ax, dx, 4 |
||
905 | shl dx,4 |
||
906 | loop .w_exp |
||
4901 | Serge | 907 | |
908 | .display: |
||
909 | |||
4900 | Serge | 910 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
911 | cmp [debuggee_pid], 0 |
||
912 | jz .do_label |
||
913 | cmp [bSuspended], 0 |
||
914 | jz .do_label |
||
915 | |||
916 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
||
917 | |||
4912 | Serge | 918 | mov eax, dword [_st0+ebp] |
919 | cmp eax, dword [_st0+(oldcontext-context)+ebp] |
||
4900 | Serge | 920 | jne .scol |
921 | |||
4912 | Serge | 922 | mov eax, dword [_st0+ebp+4] |
923 | cmp eax, dword [_st0+(oldcontext-context)+ebp+4] |
||
4900 | Serge | 924 | jne .scol |
925 | |||
4912 | Serge | 926 | mov ax, word [_st0+ebp+8] |
927 | cmp ax, word [_st0+(oldcontext-context)+ebp+8] |
||
4900 | Serge | 928 | je .do_label |
929 | |||
930 | .scol: |
||
931 | mov ecx, (COLOR_TXT_CHANGED or 0x40000000) |
||
932 | |||
933 | .do_label: |
||
934 | ; draw a text string in the window |
||
935 | |||
936 | mov eax, 4 |
||
4912 | Serge | 937 | mov esi, 21 |
938 | mov edx, .str_buf |
||
4900 | Serge | 939 | mov edi, COLOR_BG_NORMAL |
940 | int 0x40 |
||
941 | |||
4912 | Serge | 942 | shr ebp, 4 |
943 | add esp, 32+16+10+10+4+4 |
||
4900 | Serge | 944 | |
945 | ret |
||
946 | |||
947 | |||
948 | ;----------------------------------------------------------------------------- |
||
4591 | hidnplayr | 949 | ; Show FPU MMX register content |
950 | ; |
||
4906 | Serge | 951 | ; in: ebp index, ebx = coord |
4890 | hidnplayr | 952 | |
4906 | Serge | 953 | draw_mmx_register_2: |
954 | |||
955 | shl ebp, 4 |
||
956 | |||
4591 | hidnplayr | 957 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
958 | cmp [debuggee_pid], 0 |
||
959 | jz .cd |
||
960 | cmp [bSuspended], 0 |
||
961 | jz .cd |
||
4890 | hidnplayr | 962 | |
4591 | hidnplayr | 963 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
964 | |||
4906 | Serge | 965 | mov eax, dword [_mm0+ebp] |
966 | cmp eax, dword [_mm0+(oldcontext-context)+ebp] |
||
967 | jne .scol |
||
968 | |||
969 | mov eax, dword [_mm0+ebp+4] |
||
970 | cmp eax, dword [_mm0+(oldcontext-context)+ebp+4] |
||
971 | je .cd |
||
972 | |||
973 | .scol: |
||
4591 | hidnplayr | 974 | mov ecx, (COLOR_TXT_CHANGED or 0x40000000) |
4906 | Serge | 975 | .cd: |
976 | mov eax, ebp |
||
977 | shl eax, 16-4 |
||
978 | add eax, 'MM0=' |
||
979 | push eax ;write label into stack |
||
4591 | hidnplayr | 980 | |
981 | ; draw a text string in the window |
||
4890 | hidnplayr | 982 | |
4906 | Serge | 983 | mov eax, 4 |
984 | mov esi, eax |
||
985 | mov edx, esp |
||
986 | mov edi, COLOR_BG_NORMAL |
||
987 | int 0x40 |
||
988 | |||
4591 | hidnplayr | 989 | mov esi, ecx |
4906 | Serge | 990 | mov [esp], ebx |
991 | |||
992 | mov ecx, dword [_mm0+ebp+4] |
||
993 | rol ecx, 16 |
||
994 | lea edx, [ebx+0x180000] |
||
995 | mov ebx, 0x00040100 |
||
996 | mcall 47 ;word #3 |
||
997 | |||
998 | shr ecx, 16 |
||
999 | add edx, (4*6+3) shl 16 |
||
1000 | mcall 47 ;word #2 |
||
1001 | |||
1002 | mov ecx, dword [_mm0+ebp] |
||
1003 | rol ecx, 16 |
||
1004 | add edx, (4*6+3) shl 16 |
||
1005 | mcall 47 ;word #1 |
||
1006 | |||
1007 | shr ecx, 16 |
||
1008 | add edx, (4*6+3) shl 16 |
||
1009 | mcall 47 ;word #0 |
||
1010 | |||
4895 | Serge | 1011 | pop ebx |
4906 | Serge | 1012 | |
1013 | shr ebp, 4 |
||
4591 | hidnplayr | 1014 | ret |
1015 | |||
1016 | ; TODO add SSE registers |
||
1017 | ; TODO add AVX registers |
||
1018 | |||
1019 | ;----------------------------------------------------------------------------- |
||
1020 | ; Display contents of EFLAGS register |
||
1021 | draw_flag: |
||
1022 | movzx edi, byte [edx+7] |
||
1023 | bt [_eflags], edi |
||
1024 | jc .on |
||
1025 | or byte [edx], 20h |
||
1026 | jmp .onoff |
||
1027 | |||
1028 | .on: |
||
1029 | and byte [edx], not 20h |
||
1030 | |||
1031 | .onoff: |
||
1032 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
||
1033 | cmp [debuggee_pid], 0 |
||
1034 | jz .doit |
||
1035 | cmp [bSuspended], 0 |
||
1036 | jz .doit |
||
4890 | hidnplayr | 1037 | |
4591 | hidnplayr | 1038 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
1039 | bt [_eflags], edi |
||
1040 | lahf |
||
1041 | bt dword [_eflags + oldcontext - context], edi |
||
1042 | rcl ah, 1 |
||
1043 | test ah, 3 |
||
1044 | jp .doit |
||
1045 | mov ecx, (COLOR_TXT_CHANGED or 0x40000000) |
||
1046 | |||
1047 | .doit: |
||
1048 | mov ah, 0 |
||
1049 | mov edi, COLOR_BG_NORMAL |
||
1050 | ; draw a text string in the window in one case |
||
1051 | ; and a number in another |
||
1052 | ; color scheme same as for previously called function (was in ecx) |
||
1053 | mcall |
||
1054 | ret |
||
1055 | |||
1056 | ;----------------------------------------------------------------------------- |
||
1057 | ; Draw registers frame title |
||
1058 | |||
1059 | ; Also show current register set (common + MMX, SSE or AVX) |
||
1060 | draw_reg_title: |
||
1061 | mov edi, COLOR_BG_NORMAL |
||
1062 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
||
1063 | mov esi, 7 |
||
1064 | cmp [reg_mode], REG_MODE_CPU |
||
1065 | jz @f |
||
1066 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
||
1067 | @@: |
||
1068 | mov edx, aMain |
||
1069 | ; draw a text string in the window |
||
4908 | hidnplayr | 1070 | mov ebx, [registers_x_pos_dd] |
1071 | add ebx, 4*10000h+registers_y_pos+2 |
||
1072 | mcall 4 |
||
4888 | hidnplayr | 1073 | |
4591 | hidnplayr | 1074 | cmp [reg_mode], REG_MODE_SSE |
1075 | jz @f |
||
1076 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
||
1077 | @@: |
||
1078 | mov edx, aSSE |
||
1079 | ; draw a text string in the window |
||
4908 | hidnplayr | 1080 | mov ebx, [registers_x_pos_dd] |
1081 | add ebx, 46*10000h+registers_y_pos+2 |
||
1082 | mcall 4 |
||
4888 | hidnplayr | 1083 | |
4591 | hidnplayr | 1084 | cmp [reg_mode], REG_MODE_AVX |
1085 | jz @f |
||
1086 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
||
1087 | @@: |
||
1088 | mov edx, aAVX |
||
1089 | ; draw a text string in the window |
||
4908 | hidnplayr | 1090 | mov ebx, [registers_x_pos_dd] |
1091 | add ebx, 88*10000h+registers_y_pos+2 |
||
1092 | mcall 4 |
||
4591 | hidnplayr | 1093 | ret |
1094 | |||
1095 | ;----------------------------------------------------------------------------- |
||
1096 | ; Display common registers set + MMX + FPU |
||
1097 | |||
1098 | draw_main_registers: |
||
4888 | hidnplayr | 1099 | ; TODO: add support for FPU ST0-ST7 registers |
4591 | hidnplayr | 1100 | mov edi, COLOR_BG_NORMAL |
1101 | mov esi, _eax |
||
1102 | push 4 |
||
1103 | pop ecx |
||
1104 | mov edx, regs_strs |
||
4908 | hidnplayr | 1105 | mov ebx, [registers_x_pos_dd] |
1106 | add ebx, 2*10000h+registers_y_pos+22 |
||
4591 | hidnplayr | 1107 | call draw_register |
4908 | hidnplayr | 1108 | mov ebx, [registers_x_pos_dd] |
1109 | add ebx, 2*10000h+registers_y_pos+32 |
||
4591 | hidnplayr | 1110 | add esi, _ebx-_eax |
1111 | call draw_register |
||
4908 | hidnplayr | 1112 | mov ebx, [registers_x_pos_dd] |
1113 | add ebx, 2*10000h+registers_y_pos+42 |
||
4591 | hidnplayr | 1114 | add esi, _ecx-_ebx |
1115 | call draw_register |
||
4908 | hidnplayr | 1116 | mov ebx, [registers_x_pos_dd] |
1117 | add ebx, 2*10000h+registers_y_pos+52 |
||
4591 | hidnplayr | 1118 | add esi, _edx-_ecx |
1119 | call draw_register |
||
4908 | hidnplayr | 1120 | mov ebx, [registers_x_pos_dd] |
1121 | add ebx, 2*10000h+registers_y_pos+62 |
||
4591 | hidnplayr | 1122 | add esi, _esi-_edx |
1123 | call draw_register |
||
4908 | hidnplayr | 1124 | mov ebx, [registers_x_pos_dd] |
1125 | add ebx, 2*10000h+registers_y_pos+72 |
||
4591 | hidnplayr | 1126 | add esi, _edi-_esi |
1127 | call draw_register |
||
4908 | hidnplayr | 1128 | mov ebx, [registers_x_pos_dd] |
1129 | add ebx, 2*10000h+registers_y_pos+82 |
||
4591 | hidnplayr | 1130 | add esi, _ebp-_edi |
1131 | call draw_register |
||
4908 | hidnplayr | 1132 | mov ebx, [registers_x_pos_dd] |
1133 | add ebx, 2*10000h+registers_y_pos+92 |
||
4591 | hidnplayr | 1134 | add esi, _esp-_ebp |
1135 | call draw_register |
||
4908 | hidnplayr | 1136 | mov ebx, [registers_x_pos_dd] |
1137 | add ebx, 2*10000h+registers_y_pos+102 |
||
4591 | hidnplayr | 1138 | add esi, _eip-_esp |
1139 | call draw_register |
||
4908 | hidnplayr | 1140 | mov ebx, [registers_x_pos_dd] |
1141 | add ebx, 2*10000h+registers_y_pos+112 |
||
4895 | Serge | 1142 | |
4591 | hidnplayr | 1143 | mov cl, 7 |
1144 | add esi, _eflags-_eip |
||
1145 | call draw_register |
||
4895 | Serge | 1146 | mov cl, 4 |
4591 | hidnplayr | 1147 | |
1148 | ; MMX registers |
||
4895 | Serge | 1149 | |
4900 | Serge | 1150 | push ebp |
1151 | |||
4895 | Serge | 1152 | push 8 |
4906 | Serge | 1153 | xor ebp, ebp |
4908 | hidnplayr | 1154 | mov ebx, [registers_x_pos_dd] |
1155 | add ebx, 2*10000h+registers_y_pos+142 |
||
4895 | Serge | 1156 | |
1157 | align 4 |
||
1158 | .draw_mmx_regs: |
||
1159 | |||
4906 | Serge | 1160 | call draw_mmx_register_2 |
4895 | Serge | 1161 | add ebx, 10 |
4906 | Serge | 1162 | inc ebp |
4895 | Serge | 1163 | dec dword [esp] |
1164 | jnz .draw_mmx_regs |
||
4890 | hidnplayr | 1165 | |
4895 | Serge | 1166 | ;FPU registers |
1167 | |||
4900 | Serge | 1168 | ;int3 |
4906 | Serge | 1169 | ;nop |
4900 | Serge | 1170 | |
4895 | Serge | 1171 | mov [esp], byte 8 |
4900 | Serge | 1172 | xor ebp, ebp |
4908 | hidnplayr | 1173 | mov ebx, [registers_x_pos_dd] |
1174 | add ebx, 2*10000h+registers_y_pos+232 |
||
4895 | Serge | 1175 | |
1176 | align 4 |
||
1177 | .draw_fpu_regs: |
||
1178 | |||
4900 | Serge | 1179 | call draw_fpu_register_2 |
4895 | Serge | 1180 | add ebx, 10 |
4900 | Serge | 1181 | inc ebp |
4895 | Serge | 1182 | dec dword [esp] |
1183 | jnz .draw_fpu_regs |
||
1184 | pop eax ;restore stack |
||
4900 | Serge | 1185 | pop ebp |
4895 | Serge | 1186 | |
4591 | hidnplayr | 1187 | mov ecx, COLOR_TXT_INACTIVE |
1188 | cmp [debuggee_pid], 0 |
||
1189 | jz @f |
||
1190 | cmp [bSuspended], 0 |
||
1191 | jz @f |
||
4889 | hidnplayr | 1192 | mov ecx, COLOR_TXT_NORMAL |
4591 | hidnplayr | 1193 | @@: |
1194 | mov edx, aColon |
||
1195 | xor esi, esi |
||
1196 | inc esi |
||
4908 | hidnplayr | 1197 | mov ebx, [registers_x_pos_dd] |
1198 | add ebx, 10*10000h+registers_y_pos+122 |
||
1199 | mcall 4 |
||
4591 | hidnplayr | 1200 | mov edx, flags |
1201 | |||
1202 | @@: |
||
1203 | add ebx, 2*6*10000h |
||
1204 | call draw_flag |
||
1205 | inc edx |
||
1206 | cmp dl, flags_bits and 0xFF |
||
1207 | jnz @b |
||
1208 | ret |
||
1209 | |||
1210 | ;----------------------------------------------------------------------------- |
||
1211 | ; Draw SSE registers set |
||
1212 | |||
1213 | draw_sse_registers: |
||
4888 | hidnplayr | 1214 | |
4591 | hidnplayr | 1215 | ret |
1216 | |||
1217 | ;----------------------------------------------------------------------------- |
||
1218 | ; Draw AVX registers set |
||
1219 | |||
1220 | draw_avx_registers: |
||
4888 | hidnplayr | 1221 | |
4591 | hidnplayr | 1222 | ret |
1223 | |||
1224 | ;----------------------------------------------------------------------------- |
||
1225 | ; Draw all registers sets |
||
1226 | draw_registers: |
||
4888 | hidnplayr | 1227 | |
1228 | ; draw container rectangle/box with COLOR_BG_NORMAL |
||
4908 | hidnplayr | 1229 | mov ebx, [registers_x_pos_dd] |
1230 | add ebx, (-1)*10000h+(registers_x_size+2) |
||
1231 | mov ecx, [registers_y_size_dd+4] |
||
1232 | add ecx, (registers_y_pos-1)*10000h+2 |
||
1233 | mcall 13, , , COLOR_BG_NORMAL |
||
4591 | hidnplayr | 1234 | call draw_reg_title |
4888 | hidnplayr | 1235 | |
1236 | .redraw: |
||
4591 | hidnplayr | 1237 | cmp [reg_mode], REG_MODE_CPU |
1238 | jnz @f |
||
1239 | call draw_main_registers |
||
1240 | ret |
||
1241 | |||
1242 | @@: |
||
1243 | cmp [reg_mode], REG_MODE_SSE |
||
1244 | jnz @f |
||
1245 | call draw_sse_registers |
||
1246 | ret |
||
1247 | |||
1248 | @@: |
||
1249 | call draw_avx_registers |
||
1250 | ret |
||
1251 | |||
1252 | ;----------------------------------------------------------------------------- |
||
1253 | ; Display memory dump |
||
1254 | |||
1255 | draw_dump: |
||
1256 | ; draw container rectangle/box in the window |
||
4908 | hidnplayr | 1257 | mov ebx, [data_x_size_dd+4] |
1258 | add ebx, data_x_pos*10000h |
||
1259 | mcall 13, , dump_y_pos*10000h+dump_y_size, COLOR_BG_NORMAL |
||
4591 | hidnplayr | 1260 | |
1261 | .redraw: |
||
4888 | hidnplayr | 1262 | ; addresses |
4591 | hidnplayr | 1263 | mov ebx, 80100h |
1264 | mov edx, data_x_pos*10000h + dump_y_pos |
||
1265 | mov ecx, [dumppos] |
||
1266 | mov edi, COLOR_BG_NORMAL |
||
1267 | mov esi, (COLOR_TXT_INACTIVE or 0x40000000) |
||
1268 | cmp [debuggee_pid], 0 |
||
1269 | jz @f |
||
1270 | cmp [bSuspended], 0 |
||
1271 | jz @f |
||
1272 | mov esi, (COLOR_TXT_NORMAL or 0x40000000) |
||
1273 | @@: |
||
4888 | hidnplayr | 1274 | ; draw a number in the window |
4591 | hidnplayr | 1275 | mcall 47 |
1276 | add ecx, 10h |
||
1277 | add edx, 10 |
||
1278 | cmp dl, dump_y_pos + dump_y_size |
||
1279 | jb @b |
||
4888 | hidnplayr | 1280 | ; hex dump of data |
4591 | hidnplayr | 1281 | mov ecx, dumpdata |
1282 | push ecx |
||
1283 | xor ebx, ebx |
||
1284 | mov edx, (data_x_pos+12*6)*10000h + dump_y_pos |
||
1285 | cmp [dumpread], ebx |
||
1286 | jz .hexdumpdone1 |
||
1287 | |||
1288 | .hexdumploop1: |
||
1289 | push ebx |
||
1290 | mov ebx, 20101h |
||
4888 | hidnplayr | 1291 | ; draw a number in the window |
4591 | hidnplayr | 1292 | mcall |
1293 | pop ebx |
||
1294 | add edx, 3*6*10000h |
||
1295 | inc ecx |
||
1296 | inc ebx |
||
1297 | test bl, 15 |
||
1298 | jz .16 |
||
1299 | test bl, 7 |
||
1300 | jnz @f |
||
1301 | add edx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h |
||
1302 | |||
1303 | .16: |
||
1304 | add edx, 10 - 6*(3*10h+2)*10000h |
||
1305 | |||
1306 | @@: |
||
1307 | cmp ebx, [dumpread] |
||
1308 | jb .hexdumploop1 |
||
1309 | |||
1310 | .hexdumpdone1: |
||
1311 | mov al, 4 |
||
1312 | ; copy color value from esi to ecx |
||
1313 | ; to draw text string with 'mcall 4' |
||
1314 | mov ecx, esi |
||
1315 | xchg ebx, edx |
||
1316 | push 2 |
||
1317 | pop esi |
||
1318 | |||
1319 | .hexdumploop2: |
||
1320 | cmp edx, dump_height*10h |
||
1321 | jae .hexdumpdone2 |
||
1322 | push edx |
||
1323 | mov edx, aQuests |
||
1324 | ; draw text string with color in ecx, copied from esi |
||
1325 | mcall |
||
1326 | pop edx |
||
1327 | add ebx, 3*6*10000h |
||
1328 | inc edx |
||
1329 | test dl, 15 |
||
1330 | jz .16x |
||
1331 | test dl, 7 |
||
1332 | jnz .hexdumploop2 |
||
1333 | add ebx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h |
||
1334 | |||
1335 | .16x: |
||
1336 | add ebx, 10 - 6*(3*10h+2)*10000h |
||
1337 | jmp .hexdumploop2 |
||
1338 | |||
1339 | .hexdumpdone2: |
||
1340 | dec esi |
||
4890 | hidnplayr | 1341 | ; colon, minus signs |
4591 | hidnplayr | 1342 | mov ebx, (data_x_pos+8*6)*10000h + dump_y_pos |
1343 | mov edx, aColon |
||
1344 | |||
1345 | @@: |
||
1346 | mcall |
||
1347 | add ebx, 10 |
||
1348 | cmp bl, dump_y_pos+dump_height*10 |
||
1349 | jb @b |
||
1350 | mov ebx, (data_x_pos+(12+3*8)*6)*10000h + dump_y_pos |
||
1351 | mov edx, aMinus |
||
1352 | |||
1353 | @@: |
||
1354 | mcall |
||
1355 | add ebx, 10 |
||
1356 | cmp bl, dump_y_pos+dump_height*10 |
||
1357 | jb @b |
||
4890 | hidnplayr | 1358 | ; ASCII data |
4591 | hidnplayr | 1359 | mov ebx, (data_x_pos+(12+3*10h+2+2)*6)*10000h + dump_y_pos |
1360 | pop edx |
||
1361 | push dump_height*10h |
||
1362 | |||
1363 | .asciiloop: |
||
1364 | push edx |
||
1365 | cmp byte [edx], 20h |
||
1366 | jae @f |
||
1367 | mov edx, aPoint |
||
1368 | |||
1369 | @@: |
||
1370 | ; draw a text string in the window, color in ecx |
||
1371 | mcall |
||
1372 | pop edx |
||
1373 | inc edx |
||
1374 | add ebx, 6*10000h |
||
1375 | dec dword [esp] |
||
1376 | jz .asciidone |
||
1377 | test byte [esp], 15 |
||
1378 | jnz .asciiloop |
||
1379 | add ebx, 10 - 6*10h*10000h |
||
1380 | jmp .asciiloop |
||
1381 | |||
1382 | .asciidone: |
||
1383 | pop ecx |
||
1384 | ret |
||
1385 | |||
1386 | ;----------------------------------------------------------------------------- |
||
1387 | ; Display disassembled code |
||
1388 | |||
1389 | draw_disasm: |
||
1390 | |||
1391 | mov eax, [disasm_start_pos] |
||
1392 | mov [disasm_cur_pos], eax |
||
1393 | and [disasm_cur_str], 0 |
||
1394 | |||
1395 | .loop: |
||
1396 | mov eax, [disasm_cur_pos] |
||
1397 | call find_symbol |
||
1398 | jc .nosymb |
||
1399 | mov ebx, [disasm_cur_str] |
||
1400 | imul ebx, 10 |
||
1401 | push ebx |
||
1402 | lea ecx, [ebx+disasm_y_pos-1] |
||
1403 | shl ecx, 16 |
||
1404 | mov cl, 11 |
||
1405 | ; setting up background color for disassembled text |
||
1406 | mov edx, COLOR_BG_NORMAL |
||
1407 | ; draw container rectangle/box with color COLOR_BG_NORMAL (was 0xFFFFFF - white) |
||
4908 | hidnplayr | 1408 | mov ebx, [data_x_size_dd+4] |
1409 | add ebx, data_x_pos*10000h |
||
1410 | mcall 13 |
||
4591 | hidnplayr | 1411 | pop ebx |
1412 | ; copy color value from edx (COLOR_BG_NORMAL) |
||
1413 | mov edi, edx |
||
1414 | add ebx, (data_x_pos+6*2)*10000h+disasm_y_pos |
||
1415 | mov edx, esi |
||
1416 | |||
1417 | @@: |
||
1418 | lodsb |
||
1419 | test al, al |
||
1420 | jnz @b |
||
1421 | mov byte [esi-1], ':' |
||
1422 | sub esi, edx |
||
1423 | ; normal color |
||
1424 | ; was 0x40000000 |
||
4886 | hidnplayr | 1425 | mov ecx, (COLOR_TXT_LABEL or 0x40000000) |
4591 | hidnplayr | 1426 | mov al, 4 |
1427 | ; draw a text string in the window with color COLOR_TXT_NORMAL in ecx |
||
1428 | mcall |
||
1429 | mov byte [esi+edx-1], 0 |
||
1430 | lea esi, [esi*3] |
||
1431 | movzx ecx, bx |
||
1432 | shr ebx, 16 |
||
1433 | lea ebx, [ebx+esi*2] |
||
1434 | shl ecx, 16 |
||
1435 | mov cl, 10 |
||
1436 | imul ebx, 10001h |
||
4908 | hidnplayr | 1437 | sub bx, data_x_pos |
1438 | sub bx, word[data_x_size_dd+4] |
||
4591 | hidnplayr | 1439 | neg bx |
1440 | mov al, 13 |
||
1441 | ; copy color value from edi |
||
1442 | mov edx, edi |
||
1443 | ; draw container rectangle/box for disassembled text, color in edx |
||
1444 | mcall |
||
1445 | inc [disasm_cur_str] |
||
4908 | hidnplayr | 1446 | mov eax, [disasm_height_dd] |
1447 | cmp [disasm_cur_str], eax |
||
4591 | hidnplayr | 1448 | jae .loopend |
1449 | |||
1450 | .nosymb: |
||
1451 | push [disasm_cur_pos] |
||
1452 | call disasm_instr |
||
1453 | pop ebp |
||
1454 | jc .loopend |
||
4886 | hidnplayr | 1455 | mov edx, COLOR_BG_NORMAL |
4591 | hidnplayr | 1456 | mov esi, COLOR_TXT_NORMAL |
4908 | hidnplayr | 1457 | mov ebx, data_x_pos*10000h |
1458 | add ebx, [data_x_size_dd+4] |
||
4591 | hidnplayr | 1459 | mov ecx, [disasm_cur_str] |
1460 | imul ecx, 10*10000h |
||
1461 | add ecx, (disasm_y_pos-1)*10000h + 10 |
||
1462 | mov eax, ebp |
||
1463 | pushad |
||
1464 | call find_enabled_breakpoint |
||
1465 | popad |
||
4886 | hidnplayr | 1466 | jnz .nobp |
4591 | hidnplayr | 1467 | mov edx, COLOR_BG_BREAKPOINT |
4886 | hidnplayr | 1468 | mov esi, COLOR_TXT_BREAKPOINT |
1469 | .nobp: |
||
4591 | hidnplayr | 1470 | |
1471 | mov eax, [_eip] |
||
1472 | cmp eax, ebp |
||
4886 | hidnplayr | 1473 | jnz .notcurrent |
4591 | hidnplayr | 1474 | mov edx, COLOR_BG_SELECTED |
1475 | mov esi, COLOR_TXT_SELECTED |
||
4886 | hidnplayr | 1476 | .notcurrent: |
1477 | push esi ; Save color value for disassembled text |
||
4591 | hidnplayr | 1478 | |
1479 | ; draw container rectangle/box for disassembled text |
||
1480 | ; color in edx |
||
1481 | mcall 13 |
||
4890 | hidnplayr | 1482 | |
4591 | hidnplayr | 1483 | mov edx, [disasm_cur_str] |
1484 | imul edx, 10 |
||
1485 | add edx, data_x_pos*10000h + disasm_y_pos |
||
1486 | ; draw a number in the window, color in esi |
||
1487 | mcall 47, 80100h, ebp |
||
4890 | hidnplayr | 1488 | |
4591 | hidnplayr | 1489 | lea ebx, [edx+8*6*10000h] |
4886 | hidnplayr | 1490 | mov ecx, esi ; text color |
4591 | hidnplayr | 1491 | push 2 |
1492 | pop esi |
||
1493 | mov edx, aColon |
||
4886 | hidnplayr | 1494 | ; draw the colon |
4591 | hidnplayr | 1495 | mcall 4 |
1496 | push 9 |
||
1497 | pop edi |
||
1498 | lea edx, [ebx+2*6*10000h] |
||
1499 | mov ecx, ebp |
||
1500 | sub ecx, [disasm_start_pos] |
||
1501 | add ecx, disasm_buffer |
||
1502 | |||
4888 | hidnplayr | 1503 | mov esi, COLOR_TXT_HEX |
4886 | hidnplayr | 1504 | mov eax, [_eip] |
1505 | cmp eax, ebp |
||
1506 | jnz @f |
||
1507 | mov esi, COLOR_TXT_SELECTED |
||
1508 | @@: |
||
4591 | hidnplayr | 1509 | .drawhex: |
1510 | ; draw a number in the window, color in esi |
||
1511 | mcall 47, 20101h |
||
1512 | add edx, 6*3*10000h |
||
1513 | inc ecx |
||
1514 | inc ebp |
||
1515 | cmp ebp, [disasm_cur_pos] |
||
1516 | jae .hexdone |
||
1517 | dec edi |
||
1518 | jnz .drawhex |
||
1519 | push esi |
||
1520 | mov esi, [disasm_cur_pos] |
||
1521 | dec esi |
||
1522 | cmp esi, ebp |
||
1523 | pop esi |
||
1524 | jbe .drawhex |
||
4890 | hidnplayr | 1525 | |
4591 | hidnplayr | 1526 | lea ebx, [edx-6*10000h] |
1527 | ; copy color value from esi |
||
1528 | mov ecx, esi |
||
1529 | push 3 |
||
1530 | pop esi |
||
1531 | mov edx, aDots |
||
1532 | ; draw a text string in the window, color in ecx |
||
1533 | mcall 4 |
||
1534 | |||
1535 | .hexdone: |
||
4886 | hidnplayr | 1536 | pop esi |
4591 | hidnplayr | 1537 | xor eax, eax |
1538 | mov edi, disasm_string |
||
1539 | mov edx, edi |
||
1540 | or ecx, -1 |
||
1541 | repnz scasb |
||
1542 | not ecx |
||
1543 | dec ecx |
||
1544 | xchg ecx, esi |
||
1545 | mov ebx, [disasm_cur_str] |
||
1546 | imul ebx, 10 |
||
1547 | add ebx, (data_x_pos+6*40)*10000h+disasm_y_pos |
||
4890 | hidnplayr | 1548 | |
4591 | hidnplayr | 1549 | ; draw a text string in the window, color in ecx |
1550 | mcall 4 |
||
1551 | inc [disasm_cur_str] |
||
4908 | hidnplayr | 1552 | mov eax, [disasm_height_dd] |
1553 | cmp [disasm_cur_str], eax |
||
4591 | hidnplayr | 1554 | jb .loop |
1555 | |||
1556 | .loopend: |
||
4908 | hidnplayr | 1557 | mov ecx, [disasm_height_dd] |
4591 | hidnplayr | 1558 | sub ecx, [disasm_cur_str] |
1559 | jz @f |
||
1560 | imul ecx, 10 |
||
1561 | inc ecx |
||
4908 | hidnplayr | 1562 | mov eax, disasm_y_pos |
1563 | add eax, [disasm_y_size_dd+4] |
||
4591 | hidnplayr | 1564 | sub eax, ecx |
1565 | shl eax, 16 |
||
1566 | add ecx, eax |
||
4890 | hidnplayr | 1567 | ; Draw filled rectangle |
4908 | hidnplayr | 1568 | mov ebx, [data_x_size_dd+4] |
1569 | add ebx, data_x_pos*10000h |
||
1570 | mcall 13, , , COLOR_BG_NORMAL |
||
4591 | hidnplayr | 1571 | |
1572 | @@: |
||
1573 | ret |
||
1574 | |||
1575 | ;----------------------------------------------------------------------------- |
||
1576 | |||
1577 | ; TODO: cleanup of this function, make some global labels local |
||
1578 | update_disasm_eip: |
||
1579 | ; test if instruction at eip is showed |
||
4908 | hidnplayr | 1580 | mov ecx, [disasm_height_dd+4] |
4591 | hidnplayr | 1581 | mov eax, [disasm_start_pos] |
1582 | mov [disasm_cur_pos], eax |
||
1583 | |||
1584 | .l: |
||
1585 | mov eax, [disasm_cur_pos] |
||
1586 | call find_symbol |
||
1587 | jc @f |
||
1588 | dec ecx |
||
1589 | jz .m |
||
1590 | |||
1591 | @@: |
||
1592 | cmp [_eip], eax |
||
4890 | hidnplayr | 1593 | jz draw_disasm |
4591 | hidnplayr | 1594 | push ecx |
1595 | call disasm_instr |
||
1596 | pop ecx |
||
1597 | jc .m |
||
1598 | loop .l |
||
1599 | |||
1600 | .m: |
||
1601 | |||
1602 | update_disasm_eip_force: |
||
1603 | mov eax, [_eip] |
||
1604 | mov [disasm_start_pos], eax |
||
1605 | |||
1606 | update_disasm: |
||
1607 | cmp [debuggee_pid], 0 |
||
1608 | jz .no |
||
4890 | hidnplayr | 1609 | |
4591 | hidnplayr | 1610 | mcall 69, 6, [debuggee_pid], 256, [disasm_start_pos], disasm_buffer |
1611 | cmp eax, -1 |
||
1612 | jnz @f |
||
1613 | mov esi, read_mem_err |
||
1614 | call put_message |
||
1615 | |||
1616 | .no: |
||
1617 | xor eax, eax |
||
1618 | |||
1619 | @@: |
||
1620 | mov [disasm_buf_size], eax |
||
1621 | call restore_from_breaks |
||
4890 | hidnplayr | 1622 | jmp draw_disasm |
4591 | hidnplayr | 1623 | |
1624 | |||
1625 | ;----------------------------------------------------------------------------- |
||
1626 | ; Draw main window |
||
1627 | |||
1628 | draw_window: |
||
4890 | hidnplayr | 1629 | ; start window redraw |
4591 | hidnplayr | 1630 | mcall 12, 1 |
1631 | |||
4890 | hidnplayr | 1632 | ; define window |
4908 | hidnplayr | 1633 | mcall 0, wnd_x_size, wnd_y_size, (COLOR_BG_NORMAL or 0x33000000), ,caption_str |
4591 | hidnplayr | 1634 | |
4908 | hidnplayr | 1635 | ; Get actual window size |
1636 | mcall 9, thread_info, -1 |
||
4591 | hidnplayr | 1637 | |
4908 | hidnplayr | 1638 | ; Check if window is rolled up |
1639 | test [thread_info.wnd_state], 100b |
||
1640 | jnz .done |
||
1641 | |||
1642 | ; Check if window isnt smaller then permisseable |
||
1643 | mov eax, [thread_info.box.width] ; window xsize |
||
1644 | mov ebx, [thread_info.box.height] ; ysize |
||
1645 | mov edx, [thread_info.client_box.width] ; work area xsize |
||
1646 | mov esi, [thread_info.client_box.height] ; ysize |
||
1647 | sub eax, edx |
||
1648 | sub ebx, esi |
||
1649 | |||
1650 | cmp edx, wnd_x_size |
||
1651 | jae .x_ok |
||
1652 | mov edx, wnd_x_size |
||
1653 | .x_ok: |
||
1654 | add edx, eax |
||
1655 | |||
1656 | cmp esi, wnd_y_size |
||
1657 | jae .y_ok |
||
1658 | mov esi, wnd_y_size |
||
1659 | .y_ok: |
||
1660 | add esi, ebx |
||
1661 | mcall 67, -1, -1 ; set the new sizes |
||
1662 | |||
1663 | ; (re)calculate coordinates of GUI elements |
||
1664 | mov eax, [thread_info.client_box.width] |
||
1665 | sub eax, data_x_pos + data_x_pos + registers_x_size+3 |
||
1666 | mov [data_x_size_dd+4], eax |
||
1667 | mov [messages_x_size_dd+4], eax |
||
4591 | hidnplayr | 1668 | shl eax, 16 |
4908 | hidnplayr | 1669 | mov [data_x_size_dd], eax |
1670 | mov [messages_x_size_dd], eax |
||
1671 | shr eax, 16 |
||
1672 | add eax, data_x_pos + 4 |
||
1673 | mov [registers_x_pos_dd+4], eax |
||
1674 | shl eax, 16 |
||
1675 | mov [registers_x_pos_dd], eax |
||
4591 | hidnplayr | 1676 | |
4908 | hidnplayr | 1677 | mov eax, [thread_info.client_box.height] |
1678 | sub eax, cmdline_y_size + data_x_pos |
||
1679 | mov [cmdline_y_pos_dd+4], eax |
||
1680 | shl eax, 16 |
||
1681 | mov [cmdline_y_pos_dd], eax |
||
1682 | shr eax, 16 |
||
1683 | sub eax, messages_y_size + 4 |
||
1684 | mov [messages_y_pos_dd+4], eax |
||
1685 | shl eax, 16 |
||
1686 | mov [messages_y_pos_dd], eax |
||
1687 | shr eax, 16 |
||
1688 | sub eax, disasm_y_pos + 4 |
||
1689 | mov [disasm_y_size_dd+4], eax |
||
1690 | shl eax, 16 |
||
1691 | mov [disasm_y_size_dd], eax |
||
1692 | shr eax, 16 |
||
1693 | mov ecx, 10 |
||
1694 | xor edx, edx |
||
1695 | div ecx |
||
1696 | mov [disasm_height_dd], eax |
||
1697 | |||
1698 | mov eax, [thread_info.client_box.height] |
||
1699 | sub eax, data_x_pos + registers_y_pos-1 |
||
1700 | mov [registers_y_size_dd+4], eax |
||
1701 | shl eax, 16 |
||
1702 | mov [registers_y_size_dd], eax |
||
1703 | |||
4890 | hidnplayr | 1704 | ; messages frame |
4908 | hidnplayr | 1705 | mov ebx, [messages_x_size_dd+4] |
1706 | add ebx, (messages_x_pos-2)*10000h + (messages_x_pos+2) |
||
4591 | hidnplayr | 1707 | push ebx |
4908 | hidnplayr | 1708 | mov ecx, [messages_y_pos_dd+2] |
1709 | add ecx, -2*10001h |
||
4591 | hidnplayr | 1710 | mov edx, COLOR_LINE |
1711 | mcall 38 |
||
4908 | hidnplayr | 1712 | add ecx, (messages_y_size+2+2)*10001h |
4591 | hidnplayr | 1713 | mcall |
1714 | mov ebx, (messages_x_pos-2)*10001h |
||
1715 | push ebx |
||
4908 | hidnplayr | 1716 | mov ecx, [messages_y_pos_dd+2] |
1717 | add ecx, (-2*10000h) + (messages_y_size+2) |
||
4591 | hidnplayr | 1718 | mcall |
4908 | hidnplayr | 1719 | mov ebx, [messages_x_size_dd+2] |
1720 | add ebx, (messages_x_pos+2)*10001h |
||
4591 | hidnplayr | 1721 | push ebx |
1722 | mcall |
||
1723 | |||
4890 | hidnplayr | 1724 | ; command line frame |
4908 | hidnplayr | 1725 | mov ecx, [cmdline_y_pos_dd+2] |
1726 | add ecx, (-2*10000h) + (cmdline_y_size+2) |
||
4591 | hidnplayr | 1727 | pop ebx |
1728 | mcall |
||
1729 | pop ebx |
||
1730 | mcall |
||
1731 | pop ebx |
||
4908 | hidnplayr | 1732 | mov ecx, [cmdline_y_pos_dd+2] |
1733 | add ecx, (cmdline_y_size+2)*10001h |
||
1734 | |||
4591 | hidnplayr | 1735 | mcall |
4908 | hidnplayr | 1736 | mov ecx, [cmdline_y_pos_dd+2] |
1737 | add ecx, (-2*10001h) |
||
4591 | hidnplayr | 1738 | mcall |
1739 | |||
4890 | hidnplayr | 1740 | ; registers frame |
4908 | hidnplayr | 1741 | mov ebx, [registers_x_pos_dd] |
1742 | add ebx, (-2) shl 16 + (registers_x_size+3) |
||
1743 | mov ecx, (registers_y_pos-2) shl 16 + 1 |
||
1744 | mov edx, COLOR_LINE |
||
1745 | mcall 13 ; top |
||
1746 | mov ebx, [registers_x_pos_dd] |
||
1747 | add ebx, ((-2)+(registers_x_size+3)) shl 16 +1 |
||
1748 | mov ecx, [registers_y_size_dd+4] |
||
1749 | add ecx, (registers_y_pos-2) shl 16 + (+3+1) |
||
1750 | mcall ; right |
||
1751 | mov ebx, [registers_x_pos_dd] |
||
1752 | add ebx, (-2) shl 16 + (registers_x_size+3) |
||
1753 | mov ecx, [registers_y_size_dd] |
||
1754 | add ecx, ((registers_y_pos-2)+(+3)) shl 16 + 1 |
||
1755 | mcall ; bottom |
||
4591 | hidnplayr | 1756 | |
4890 | hidnplayr | 1757 | ; messages |
4591 | hidnplayr | 1758 | call draw_messages |
1759 | |||
4890 | hidnplayr | 1760 | ; command line & cursor |
4591 | hidnplayr | 1761 | call draw_cmdline |
1762 | call draw_cursor |
||
1763 | |||
4890 | hidnplayr | 1764 | ; title & registers & dump & disasm |
4591 | hidnplayr | 1765 | mov ebx, (data_x_pos-2)*10001h |
4908 | hidnplayr | 1766 | mov ecx, (title_y_pos+5)*10000h + (-2) |
1767 | add ecx, [messages_y_pos_dd+4] |
||
4591 | hidnplayr | 1768 | mov edx, COLOR_LINE |
1769 | mcall 38 |
||
4908 | hidnplayr | 1770 | mov ebx, [data_x_size_dd+2] |
1771 | add ebx, (data_x_pos+2)*10001h |
||
4591 | hidnplayr | 1772 | mcall |
4908 | hidnplayr | 1773 | mov ebx, [data_x_size_dd+4] |
1774 | add ebx, (data_x_pos-2)*10000h + (data_x_pos+2) |
||
4591 | hidnplayr | 1775 | mov ecx, (disasm_y_pos-4)*10001h |
1776 | mcall |
||
1777 | |||
4890 | hidnplayr | 1778 | ; redraw whole window again |
4591 | hidnplayr | 1779 | call redraw_title |
1780 | call draw_registers |
||
1781 | call draw_dump |
||
4890 | hidnplayr | 1782 | call draw_disasm |
4591 | hidnplayr | 1783 | |
4908 | hidnplayr | 1784 | |
1785 | .done: |
||
4890 | hidnplayr | 1786 | ; end of window redraw |
4591 | hidnplayr | 1787 | mcall 12, 2 |
1788 | ret |
||
1789 | |||
1790 | ; vim: ft=fasm tabstop=4 |
||
1791 |