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