Rev 4889 | Rev 4895 | 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 | |||
4738 | leency | 5 | macro DrawRectangle x, y, w, h, color |
6 | { |
||
4886 | hidnplayr | 7 | mcall 13, x shl 16 + w, y shl 16 + 1, color ; top |
8 | mcall , x shl 16 + 1, y shl 16 + h, color ; left |
||
9 | mcall , (x+w) shl 16 +1, y shl 16 + (h+1), color ; right |
||
10 | mcall , x shl 16 + w, (y+h) shl 16 + 1, color ; bottom |
||
4738 | leency | 11 | } |
12 | |||
4591 | hidnplayr | 13 | ;----------------------------------------------------------------------------- |
14 | ; Color scheme |
||
15 | |||
16 | BLACK_ON_WHITE equ 0 |
||
17 | MOVIEOS equ 1 |
||
18 | WHITE_ON_BLACK equ 2 |
||
19 | |||
20 | ; format - 0xRRGGBB |
||
21 | if COLOR_THEME eq MOVIEOS |
||
22 | |||
23 | COLOR_BG_NORMAL = 0x1d272f |
||
24 | COLOR_BG_BREAKPOINT = 0x0000aa |
||
25 | COLOR_BG_SELECTED = 0xec9300 |
||
26 | COLOR_LINE = 0x00b9a0 |
||
27 | COLOR_TXT_NORMAL = 0xffffff |
||
28 | COLOR_TXT_INACTIVE = 0x8f7948 |
||
29 | COLOR_TXT_CHANGED = 0xec9300 |
||
4886 | hidnplayr | 30 | COLOR_TXT_LABEL = 0x22b14c |
4591 | hidnplayr | 31 | COLOR_TXT_SELECTED = 0x1d272f |
4888 | hidnplayr | 32 | COLOR_TXT_HEX = 0xec9300 |
4886 | hidnplayr | 33 | COLOR_TXT_BREAKPOINT = 0xec9300 |
4591 | hidnplayr | 34 | |
35 | else if COLOR_THEME eq WHITE_ON_BLACK |
||
36 | |||
37 | COLOR_BG_NORMAL = 0x101010 ; dark grey |
||
38 | COLOR_BG_BREAKPOINT = 0xFF0000 ; red |
||
39 | COLOR_BG_SELECTED = 0x0000FF ; blue |
||
40 | COLOR_LINE = 0xFFFFFF ; white |
||
41 | COLOR_TXT_NORMAL = 0xFFFFFF ; white |
||
42 | COLOR_TXT_INACTIVE = 0x808080 ; grey |
||
43 | COLOR_TXT_CHANGED = 0x00AA00 ; green |
||
4886 | hidnplayr | 44 | COLOR_TXT_LABEL = COLOR_TXT_NORMAL |
4591 | hidnplayr | 45 | COLOR_TXT_SELECTED = 0xFFFFFF ; white |
4888 | hidnplayr | 46 | COLOR_TXT_HEX = COLOR_TXT_NORMAL |
4886 | hidnplayr | 47 | COLOR_TXT_BREAKPOINT = COLOR_TXT_NORMAL |
4591 | hidnplayr | 48 | |
49 | else ; BLACK ON WHITE |
||
50 | |||
51 | COLOR_BG_NORMAL = 0xffffff ; white |
||
52 | COLOR_BG_BREAKPOINT = 0xFF0000 ; red |
||
53 | COLOR_BG_SELECTED = 0x0000FF ; blue |
||
54 | COLOR_LINE = 0x000000 ; black |
||
55 | COLOR_TXT_NORMAL = 0x000000 ; black |
||
56 | COLOR_TXT_INACTIVE = 0x808080 ; grey |
||
57 | COLOR_TXT_CHANGED = 0x00AA00 ; green |
||
4886 | hidnplayr | 58 | COLOR_TXT_LABEL = COLOR_TXT_NORMAL |
4591 | hidnplayr | 59 | COLOR_TXT_SELECTED = 0xFFFFFF ; white |
4888 | hidnplayr | 60 | COLOR_TXT_HEX = COLOR_TXT_NORMAL |
4886 | hidnplayr | 61 | COLOR_TXT_BREAKPOINT = COLOR_TXT_NORMAL |
4591 | hidnplayr | 62 | |
63 | end if |
||
64 | |||
65 | ;----------------------------------------------------------------------------- |
||
66 | |||
67 | data_width equ 80 |
||
68 | data_x_pos equ 12 |
||
69 | data_x_size equ data_width*6 |
||
70 | |||
71 | title_x_pos equ 30 |
||
72 | title_y_pos equ 32 |
||
73 | title_y_size equ 10 |
||
74 | |||
75 | ;dump_y_pos equ (registers_y_pos + registers_y_size + 5) |
||
76 | dump_y_pos equ (title_y_pos + title_y_size) |
||
77 | dump_height equ 6 |
||
78 | dump_y_size equ (dump_height*10) |
||
79 | |||
80 | disasm_y_pos equ (dump_y_pos + dump_y_size + 4) |
||
81 | disasm_height equ 18 |
||
82 | disasm_y_size equ (disasm_height*10) |
||
83 | |||
84 | messages_width equ data_width |
||
85 | messages_height equ 8 |
||
86 | messages_x_pos equ data_x_pos |
||
87 | messages_y_pos equ (disasm_y_pos + disasm_y_size + 4) |
||
88 | messages_x_size equ messages_width*6 |
||
89 | messages_y_size equ messages_height*10 |
||
90 | |||
91 | cmdline_width equ data_width |
||
92 | cmdline_x_pos equ data_x_pos |
||
93 | cmdline_y_pos equ (messages_y_pos + messages_y_size + 4) |
||
94 | cmdline_x_size equ messages_x_size |
||
95 | cmdline_y_size equ 10 |
||
96 | |||
97 | registers_x_pos equ (data_x_pos + messages_x_size + 4) |
||
98 | registers_y_pos equ (title_y_pos + title_y_size - 3) |
||
99 | registers_x_size equ 134 |
||
100 | registers_y_size equ (cmdline_y_pos + cmdline_y_size - registers_y_pos+1) |
||
101 | |||
102 | wnd_x_size equ (data_x_pos + messages_x_size + data_x_pos + registers_x_size+3) |
||
103 | wnd_y_size equ (cmdline_y_pos + cmdline_y_size + data_x_pos) |
||
104 | |||
105 | ;----------------------------------------------------------------------------- |
||
106 | ; Entry point |
||
107 | |||
108 | ; TODO: split all gui part in independent function, move entry point into mtdbg.asm |
||
109 | |||
110 | start: |
||
4890 | hidnplayr | 111 | ; initialize process heap |
4591 | hidnplayr | 112 | mcall 68, 11 |
113 | mov edi, messages |
||
114 | mov ecx, messages_width*messages_height |
||
115 | mov al, ' ' |
||
116 | rep stosb |
||
117 | xor eax, eax |
||
118 | mov [messages_pos], eax |
||
119 | mov [cmdline_len], eax |
||
120 | mov [cmdline_pos], eax |
||
121 | mov edi, needzerostart |
||
122 | mov ecx, (needzeroend-needzerostart+3)/4 |
||
123 | rep stosd |
||
124 | mov esi, begin_str |
||
125 | call put_message_nodraw |
||
4890 | hidnplayr | 126 | ; set event mask - default events and debugging events |
4591 | hidnplayr | 127 | mcall 40, 0x107 |
4890 | hidnplayr | 128 | ; set debug messages buffer |
4591 | hidnplayr | 129 | mov ecx, dbgbufsize |
130 | mov dword [ecx], 256 |
||
131 | xor ebx, ebx |
||
132 | mov [ecx+4], ebx |
||
133 | mov al, 69 |
||
134 | mcall |
||
135 | mov esi, i_param |
||
136 | call get_arg.skip_spaces |
||
137 | test al, al |
||
138 | jz dodraw |
||
139 | push esi |
||
140 | call draw_window |
||
141 | pop esi |
||
142 | call OnLoadInit |
||
143 | jmp waitevent |
||
144 | |||
145 | dodraw: |
||
146 | call draw_window |
||
147 | |||
148 | waitevent: |
||
149 | mcall 10 |
||
150 | cmp al, 9 |
||
151 | jz debugmsg |
||
152 | dec eax |
||
153 | jz dodraw |
||
154 | dec eax |
||
155 | jz keypressed |
||
156 | dec eax |
||
157 | jnz waitevent |
||
4890 | hidnplayr | 158 | ; button pressed - we have only one button (close) |
4591 | hidnplayr | 159 | mcall -1 |
160 | |||
161 | ; TODO: split in more independent function |
||
162 | keypressed: |
||
163 | mov al, 2 |
||
164 | mcall |
||
165 | shr eax, 8 |
||
166 | cmp al, 8 |
||
167 | jz .backspace |
||
168 | cmp al, 0xB0 |
||
169 | jz .left |
||
170 | cmp al, 0xB3 |
||
171 | jz .right |
||
172 | cmp al, 0x0D |
||
173 | jz .enter |
||
174 | cmp al, 0xB6 |
||
175 | jz .del |
||
176 | cmp al, 0xB4 |
||
177 | jz .home |
||
178 | cmp al, 0xB5 |
||
179 | jz .end |
||
180 | cmp al, 0xB1 |
||
181 | jz .down |
||
182 | cmp al, 0xB2 |
||
4594 | hidnplayr | 183 | jz .up |
184 | cmp ah, 0x41 |
||
185 | jz F7 |
||
186 | cmp ah, 0x42 |
||
187 | jz F8 |
||
188 | cmp [cmdline_len], cmdline_width |
||
4591 | hidnplayr | 189 | jae waitevent |
190 | push eax |
||
191 | call clear_cmdline_end |
||
192 | pop eax |
||
193 | mov edi, cmdline |
||
194 | mov ecx, [cmdline_len] |
||
195 | add edi, ecx |
||
196 | lea esi, [edi-1] |
||
197 | sub ecx, [cmdline_pos] |
||
198 | std |
||
199 | rep movsb |
||
200 | cld |
||
201 | stosb |
||
202 | inc [cmdline_len] |
||
203 | call draw_cmdline_end |
||
204 | inc [cmdline_pos] |
||
205 | call draw_cursor |
||
206 | jmp waitevent |
||
207 | |||
208 | .backspace: |
||
209 | cmp [cmdline_pos], 0 |
||
210 | jz waitevent |
||
211 | dec [cmdline_pos] |
||
212 | |||
213 | .delchar: |
||
214 | call clear_cmdline_end |
||
215 | mov edi, [cmdline_pos] |
||
216 | dec [cmdline_len] |
||
217 | mov ecx, [cmdline_len] |
||
218 | sub ecx, edi |
||
219 | add edi, cmdline |
||
220 | lea esi, [edi+1] |
||
221 | rep movsb |
||
222 | call draw_cmdline_end |
||
223 | call draw_cursor |
||
224 | jmp waitevent |
||
225 | |||
226 | .del: |
||
227 | mov eax, [cmdline_pos] |
||
228 | cmp eax, [cmdline_len] |
||
229 | jae waitevent |
||
230 | jmp .delchar |
||
231 | |||
232 | .left: |
||
233 | cmp [cmdline_pos], 0 |
||
234 | jz waitevent |
||
235 | call hide_cursor |
||
236 | dec [cmdline_pos] |
||
237 | call draw_cursor |
||
238 | jmp waitevent |
||
239 | |||
240 | .right: |
||
241 | mov eax, [cmdline_pos] |
||
242 | cmp eax, [cmdline_len] |
||
243 | jae waitevent |
||
244 | call hide_cursor |
||
245 | inc [cmdline_pos] |
||
246 | call draw_cursor |
||
247 | jmp waitevent |
||
248 | |||
249 | .home: |
||
250 | call hide_cursor |
||
251 | and [cmdline_pos], 0 |
||
252 | call draw_cursor |
||
253 | jmp waitevent |
||
254 | |||
255 | .end: |
||
256 | call hide_cursor |
||
257 | mov eax, [cmdline_len] |
||
258 | mov [cmdline_pos], eax |
||
259 | call draw_cursor |
||
260 | |||
261 | .up: |
||
262 | .down: |
||
263 | jmp waitevent |
||
264 | |||
4890 | hidnplayr | 265 | ; We also trying to execute previous command, if empty command_line |
4591 | hidnplayr | 266 | .enter: |
267 | mov ecx, [cmdline_len] |
||
268 | test ecx, ecx |
||
269 | jnz .exec_cur |
||
270 | mov cl, byte [cmdline_prev] |
||
271 | cmp cl, 0 |
||
272 | jz waitevent |
||
273 | |||
274 | .exec_prev: |
||
275 | mov esi, cmdline_prev |
||
276 | jmp .exec |
||
277 | |||
278 | .exec_cur: |
||
279 | mov esi, cmdline |
||
280 | |||
281 | .exec: |
||
282 | mov byte [esi+ecx], 0 |
||
283 | and [cmdline_pos], 0 |
||
284 | push esi |
||
285 | call clear_cmdline_end |
||
286 | call draw_cursor |
||
287 | pop esi |
||
288 | and [cmdline_len], 0 |
||
4890 | hidnplayr | 289 | ; skip leading spaces |
4591 | hidnplayr | 290 | call get_arg.skip_spaces |
291 | cmp al, 0 |
||
292 | jz waitevent |
||
4890 | hidnplayr | 293 | ; now esi points to command |
4591 | hidnplayr | 294 | push esi |
295 | mov esi, prompt |
||
296 | call put_message_nodraw |
||
297 | pop esi |
||
298 | push esi |
||
299 | call put_message_nodraw |
||
300 | |||
301 | ; TODO: add meaningful name |
||
302 | z1: |
||
303 | mov esi, newline |
||
304 | call put_message |
||
305 | pop esi |
||
306 | push esi |
||
307 | call get_arg |
||
308 | mov [curarg], esi |
||
309 | pop edi |
||
310 | mov esi, commands |
||
311 | call find_cmd |
||
312 | mov eax, aUnknownCommand |
||
313 | jc .x11 |
||
314 | |||
4890 | hidnplayr | 315 | ; check command requirements |
316 | ; flags field: |
||
317 | ; &1: command may be called without parameters |
||
318 | ; &2: command may be called with parameters |
||
319 | ; &4: command may be called without loaded program |
||
320 | ; &8: command may be called with loaded program |
||
4591 | hidnplayr | 321 | mov eax, [esi+8] |
322 | mov ecx, [curarg] |
||
323 | cmp byte [ecx], 0 |
||
324 | jz .noargs |
||
325 | test byte [esi+16], 2 |
||
326 | jz .x11 |
||
327 | jmp @f |
||
328 | |||
329 | .noargs: |
||
330 | test byte [esi+16], 1 |
||
331 | jz .x11 |
||
332 | |||
333 | @@: |
||
334 | cmp [debuggee_pid], 0 |
||
335 | jz .nodebuggee |
||
336 | mov eax, aAlreadyLoaded |
||
337 | test byte [esi+16], 8 |
||
338 | jz .x11 |
||
339 | jmp .x9 |
||
340 | |||
341 | .nodebuggee: |
||
342 | mov eax, need_debuggee |
||
343 | test byte [esi+16], 4 |
||
344 | jnz .x9 |
||
345 | |||
346 | .x11: |
||
347 | xchg esi, eax |
||
348 | call put_message |
||
349 | |||
4890 | hidnplayr | 350 | ; store cmdline for repeating |
4591 | hidnplayr | 351 | .x10: |
352 | mov esi, cmdline |
||
353 | mov ecx, [cmdline_len] |
||
354 | |||
355 | @@: |
||
356 | cmp ecx, 0 |
||
357 | jle .we |
||
358 | mov al, [esi + ecx] |
||
359 | mov [cmdline_prev + ecx], al |
||
360 | dec ecx |
||
361 | jmp @b |
||
362 | |||
363 | .we: |
||
364 | mov [cmdline_len], 0 |
||
365 | jmp waitevent |
||
366 | |||
367 | .x9: |
||
368 | call dword [esi+4] |
||
369 | jmp .x10 |
||
370 | |||
371 | ;----------------------------------------------------------------------------- |
||
372 | ; Cmdline handling |
||
373 | |||
374 | clear_cmdline_end: |
||
375 | mov ebx, [cmdline_pos] |
||
376 | mov ecx, [cmdline_len] |
||
377 | sub ecx, ebx |
||
378 | imul ebx, 6 |
||
379 | imul ecx, 6 |
||
380 | inc ecx |
||
381 | add ebx, cmdline_x_pos |
||
382 | shl ebx, 16 |
||
383 | or ebx, ecx |
||
384 | mov ecx, cmdline_y_pos*10000h + cmdline_y_size |
||
385 | mov edx, COLOR_BG_NORMAL |
||
386 | ; draw container rectangle/box for cmdline |
||
387 | mcall 13 |
||
388 | ret |
||
389 | |||
390 | draw_cmdline: |
||
391 | xor ebx, ebx |
||
392 | jmp @f |
||
393 | |||
394 | ; TODO: make it local |
||
395 | draw_cmdline_end: |
||
396 | mov ebx, [cmdline_pos] |
||
397 | |||
398 | @@: |
||
399 | mov esi, [cmdline_len] |
||
400 | sub esi, ebx |
||
4890 | hidnplayr | 401 | |
4591 | hidnplayr | 402 | mov ecx, COLOR_TXT_NORMAL |
403 | lea edx, [cmdline+ebx] |
||
404 | imul ebx, 6 |
||
405 | add ebx, cmdline_x_pos |
||
406 | shl ebx, 16 |
||
407 | or ebx, cmdline_y_pos+1 |
||
4890 | hidnplayr | 408 | ; draw a text string in the window |
4591 | hidnplayr | 409 | mcall 4 |
410 | ret |
||
411 | |||
412 | ;----------------------------------------------------------------------------- |
||
413 | ; Working with messages |
||
414 | ; in: esi->ASCIIZ message |
||
415 | put_message_nodraw: |
||
416 | mov edx, [messages_pos] |
||
417 | |||
418 | .m: |
||
419 | lea edi, [messages+edx] |
||
420 | |||
421 | .l: |
||
422 | lodsb |
||
423 | cmp al, 0 |
||
424 | jz .done |
||
425 | call test_scroll |
||
426 | cmp al, 10 |
||
427 | jz .newline |
||
428 | cmp al, '%' |
||
429 | jnz @f |
||
430 | cmp dword [esp], z1 |
||
431 | jnz .format |
||
432 | |||
433 | @@: |
||
434 | stosb |
||
435 | inc edx |
||
436 | jmp .l |
||
437 | |||
438 | .newline: |
||
439 | push edx |
||
440 | mov ecx, messages_width |
||
441 | xor eax, eax |
||
442 | xchg eax, edx |
||
443 | div ecx |
||
444 | xchg eax, edx |
||
445 | pop edx |
||
446 | test eax, eax |
||
447 | jz .m |
||
448 | sub edx, eax |
||
449 | add edx, ecx |
||
450 | jmp .m |
||
451 | |||
452 | .done: |
||
453 | mov [messages_pos], edx |
||
454 | ret |
||
455 | |||
4890 | hidnplayr | 456 | ; at this moment all format specs must be % |
4591 | hidnplayr | 457 | .format: |
458 | lodsb ; get |
||
459 | sub al, '0' |
||
460 | movzx ecx, al |
||
461 | lodsb |
||
462 | pop eax |
||
463 | pop ebp |
||
464 | push eax |
||
4890 | hidnplayr | 465 | ; write number in ebp with ecx digits |
4591 | hidnplayr | 466 | dec ecx |
467 | shl ecx, 2 |
||
468 | |||
469 | .writenibble: |
||
470 | push ecx |
||
471 | call test_scroll |
||
472 | pop ecx |
||
473 | mov eax, ebp |
||
474 | shr eax, cl |
||
475 | and al, 0xF |
||
476 | cmp al, 10 |
||
477 | sbb al, 69h |
||
478 | das |
||
479 | stosb |
||
480 | inc edx |
||
481 | sub ecx, 4 |
||
482 | jns .writenibble |
||
483 | jmp .l |
||
484 | |||
485 | test_scroll: |
||
486 | cmp edx, messages_width*messages_height |
||
487 | jnz .ret |
||
488 | push esi |
||
489 | mov edi, messages |
||
490 | lea esi, [edi+messages_width] |
||
491 | mov ecx, (messages_height-1)*messages_width/4 |
||
492 | rep movsd |
||
493 | push eax |
||
494 | mov al, ' ' |
||
495 | push edi |
||
496 | push messages_width |
||
497 | pop ecx |
||
498 | sub edx, ecx |
||
499 | rep stosb |
||
500 | pop edi |
||
501 | pop eax |
||
502 | pop esi |
||
503 | |||
504 | .ret: |
||
505 | ret |
||
506 | |||
507 | ;----------------------------------------------------------------------------- |
||
508 | |||
509 | put_message: |
||
510 | call put_message_nodraw |
||
511 | |||
512 | draw_messages: |
||
4890 | hidnplayr | 513 | ; draw container rectangle/box |
4591 | hidnplayr | 514 | mcall 13, messages_x_pos*10000h+messages_x_size, messages_y_pos*10000h+messages_y_size, COLOR_BG_NORMAL |
515 | mov edx, messages |
||
516 | push messages_width |
||
517 | pop esi |
||
518 | mov ecx, COLOR_TXT_NORMAL |
||
519 | mov ebx, messages_x_pos*10000h+messages_y_pos |
||
520 | |||
521 | @@: |
||
522 | ; display text string in the window |
||
523 | mcall 4 |
||
524 | add edx, esi |
||
525 | add ebx, 10 |
||
526 | cmp edx, messages+messages_width*messages_height |
||
527 | jb @b |
||
528 | ret |
||
529 | |||
530 | ;----------------------------------------------------------------------------- |
||
531 | ; Show/hide cursor in command line |
||
532 | |||
533 | ; TODO: make it cursor.draw and cursor.hide ??? |
||
534 | draw_cursor: |
||
535 | mov ecx, cmdline_y_pos*10001h+cmdline_y_size-1 |
||
536 | mov ebx, [cmdline_pos] |
||
537 | imul ebx, 6 |
||
538 | add ebx, cmdline_x_pos |
||
539 | mov edx, ebx |
||
540 | shl ebx, 16 |
||
541 | or ebx, edx |
||
4888 | hidnplayr | 542 | mov edx, COLOR_TXT_NORMAL |
543 | ; draw line |
||
4591 | hidnplayr | 544 | mcall 38 |
545 | ret |
||
546 | |||
547 | hide_cursor: |
||
548 | mov ebx, [cmdline_pos] |
||
549 | imul ebx, 6 |
||
550 | add ebx, cmdline_x_pos |
||
551 | shl ebx, 16 |
||
552 | inc ebx |
||
553 | mov ecx, cmdline_y_pos*10000h + cmdline_y_size |
||
554 | mov edx, COLOR_BG_NORMAL |
||
555 | ; draw container rectangle/box |
||
556 | mcall 13 |
||
557 | mov ebx, [cmdline_pos] |
||
558 | cmp ebx, [cmdline_len] |
||
559 | jae .ret |
||
560 | ; setting up text color scheme and attributes |
||
561 | mov ecx, COLOR_TXT_NORMAL |
||
562 | lea edx, [cmdline+ebx] |
||
563 | imul ebx, 6 |
||
564 | add ebx, cmdline_x_pos |
||
565 | shl ebx, 16 |
||
566 | or ebx, cmdline_y_pos+1 |
||
567 | push 1 |
||
568 | pop esi |
||
569 | ; draw text string in the window |
||
570 | mcall 4 |
||
571 | |||
572 | .ret: |
||
573 | ret |
||
574 | |||
575 | ;----------------------------------------------------------------------------- |
||
576 | ; Draw program window title |
||
577 | |||
578 | ; FIXME: something wrong here |
||
579 | redraw_title: |
||
580 | ; draw container rectangle/box |
||
581 | mcall 13, title_x_pos*10000h+data_x_pos+data_x_size-title_x_pos, title_y_pos*10000h+title_y_size, COLOR_BG_NORMAL |
||
582 | |||
583 | draw_title: |
||
584 | mcall 38, (data_x_pos-2)*10000h+title_x_pos-5, (title_y_pos+5)*10001h, COLOR_LINE |
||
585 | push NoPrgLoaded_len |
||
586 | pop esi |
||
587 | cmp [debuggee_pid], 0 |
||
588 | jz @f |
||
589 | mov esi, [prgname_len] |
||
590 | |||
591 | @@: |
||
592 | imul ebx, esi, 6 |
||
593 | add ebx, title_x_pos+4 |
||
594 | shl ebx, 16 |
||
595 | mov bx, data_x_pos+data_x_size-10-5-6*7 |
||
596 | cmp [bSuspended], 0 |
||
597 | jz @f |
||
598 | add ebx, 6 |
||
599 | |||
600 | @@: |
||
601 | ; draw line with COLOR_LINE (in edx) |
||
602 | mcall |
||
603 | mov ebx, (data_x_pos+data_x_size-10+4)*0x10000 + data_x_pos+data_x_size+2 |
||
604 | ; draw line with COLOR_LINE (in edx) |
||
605 | mcall |
||
606 | mov al, 4 |
||
607 | mov ebx, title_x_pos*10000h+title_y_pos |
||
608 | ; setting up text color scheme and attributes |
||
609 | mov ecx, COLOR_TXT_NORMAL |
||
610 | mov edx, NoPrgLoaded_str |
||
611 | cmp [debuggee_pid], 0 |
||
612 | jz @f |
||
613 | mov edx, [prgname_ptr] |
||
614 | |||
615 | @@: |
||
616 | ; draw text string in the window |
||
617 | mcall |
||
618 | cmp [debuggee_pid], 0 |
||
619 | jz .nodebuggee |
||
620 | mov ebx, (data_x_pos+data_x_size-10-6*7)*10000h + title_y_pos |
||
621 | mov edx, aRunning |
||
622 | push 7 |
||
623 | pop esi |
||
624 | cmp [bSuspended], 0 |
||
625 | jz @f |
||
626 | add ebx, 6*10000h |
||
627 | mov edx, aPaused |
||
628 | dec esi |
||
629 | |||
630 | @@: |
||
631 | ; draw line with COLOR_LINE (in edx) in one case |
||
632 | ; and draw text string with color COLOR_TXT_NORMAL (in ecx) in another |
||
633 | mcall |
||
634 | ret |
||
635 | |||
636 | .nodebuggee: |
||
637 | mov al, 38 |
||
638 | mov ebx, (data_x_pos+data_x_size-10-6*7-5)*0x10000 + data_x_pos+data_x_size+2 |
||
639 | mov ecx, (title_y_pos+5)*10001h |
||
640 | mov edx, COLOR_LINE |
||
641 | jmp @b |
||
642 | |||
643 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
644 | ;;;;;;;;;;;;;;;;;;; REGISTERS PANEL ;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
645 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
646 | |||
647 | ;----------------------------------------------------------------------------- |
||
648 | ; Display common register content |
||
649 | |||
650 | ; TODO: add format support (e.g. numerical value, or address offset/pointer) |
||
651 | |||
652 | ; in: esi->value, edx->string, ecx = string length, ebx = coord |
||
653 | draw_register: |
||
654 | push edx |
||
655 | push ecx |
||
656 | push esi |
||
657 | mov eax, esi |
||
658 | mov esi, ecx |
||
4890 | hidnplayr | 659 | |
4591 | hidnplayr | 660 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
661 | cmp [debuggee_pid], 0 |
||
662 | jz .cd |
||
663 | cmp [bSuspended], 0 |
||
664 | jz .cd |
||
4890 | hidnplayr | 665 | |
4591 | hidnplayr | 666 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
667 | push edi |
||
668 | mov edi, [eax] |
||
669 | cmp dword [eax+oldcontext-context], edi |
||
670 | pop edi |
||
671 | jz .cd |
||
672 | mov ecx, (COLOR_TXT_CHANGED or 0x40000000) |
||
673 | |||
674 | .cd: |
||
675 | ; draw a text string in the window |
||
676 | mcall 4 |
||
677 | imul esi, 60000h |
||
678 | lea edx, [ebx+esi] |
||
679 | mov esi, ecx |
||
680 | pop ecx |
||
4890 | hidnplayr | 681 | |
4591 | hidnplayr | 682 | ; draw a number in the window |
683 | mcall 47, 80101h |
||
684 | lea ebx, [edx+60000h*18] |
||
685 | mov esi, ecx |
||
686 | pop ecx |
||
687 | pop edx |
||
688 | add edx, ecx |
||
689 | ret |
||
690 | |||
691 | ;----------------------------------------------------------------------------- |
||
692 | ; Display FPU register (ST0 - ST7) content |
||
693 | ; |
||
694 | ; in: esi->value, edx->string, ecx = string length, ebx = coord |
||
695 | draw_fpu_register: |
||
696 | push edx |
||
697 | push ecx |
||
698 | push esi |
||
699 | mov eax, esi |
||
700 | mov esi, ecx |
||
4890 | hidnplayr | 701 | |
4591 | hidnplayr | 702 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
703 | cmp [debuggee_pid], 0 |
||
704 | jz .cd |
||
705 | cmp [bSuspended], 0 |
||
706 | jz .cd |
||
4890 | hidnplayr | 707 | |
4591 | hidnplayr | 708 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
709 | push edi |
||
710 | mov edi, [eax] |
||
711 | cmp dword [eax+oldcontext-context], edi |
||
712 | pop edi |
||
713 | jnz .scol |
||
714 | push edi |
||
715 | mov edi, [eax+4] |
||
716 | cmp dword [eax+oldcontext-context+4], edi |
||
717 | pop edi |
||
718 | jz .cd |
||
719 | |||
720 | .scol: |
||
721 | mov ecx, (COLOR_TXT_CHANGED or 0x40000000) |
||
722 | |||
723 | .cd: |
||
724 | ; draw a text string in the window |
||
725 | mcall 4 |
||
726 | imul esi, 60000h |
||
727 | lea edx, [ebx+esi] |
||
728 | mov esi, ecx |
||
729 | pop ecx |
||
730 | ; draw a number in the window |
||
731 | ; color is the same as for previous text draw function |
||
732 | ; ebx : [20] show 16 chars set [30] bit - qword |
||
733 | mcall 47, 40100101h |
||
734 | lea ebx, [edx+60000h*18] |
||
735 | mov esi, ecx |
||
736 | pop ecx |
||
737 | pop edx |
||
738 | add edx, ecx |
||
739 | ret |
||
740 | |||
741 | ;----------------------------------------------------------------------------- |
||
742 | ; Show FPU MMX register content |
||
743 | ; |
||
744 | ; in: esi->value, edx->string, ecx = string length, ebx = coord |
||
745 | draw_mmx_register: |
||
746 | push edx |
||
747 | push ecx |
||
748 | push esi |
||
749 | mov eax, esi |
||
750 | mov esi, ecx |
||
4890 | hidnplayr | 751 | |
4591 | hidnplayr | 752 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
753 | cmp [debuggee_pid], 0 |
||
754 | jz .cd |
||
755 | cmp [bSuspended], 0 |
||
756 | jz .cd |
||
4890 | hidnplayr | 757 | |
4591 | hidnplayr | 758 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
759 | push edi |
||
760 | mov edi, [eax] |
||
761 | cmp dword [eax+oldcontext-context], edi |
||
762 | pop edi |
||
763 | jnz .scol |
||
764 | push edi |
||
765 | mov edi, [eax+4] |
||
766 | cmp dword [eax+oldcontext-context+4], edi |
||
767 | pop edi |
||
768 | jz .cd |
||
769 | |||
770 | .scol: |
||
771 | mov ecx, (COLOR_TXT_CHANGED or 0x40000000) |
||
772 | |||
773 | .cd: |
||
774 | ; draw a text string in the window |
||
775 | mcall 4 |
||
4890 | hidnplayr | 776 | |
4591 | hidnplayr | 777 | imul esi, 60000h |
778 | lea edx, [ebx+esi] |
||
779 | mov esi, ecx |
||
780 | pop ecx |
||
781 | ; draw a number in the window |
||
782 | ; color is the same as for previous draw text function |
||
783 | ; ebx : [20] show 16 chars set [30] bit - qword |
||
784 | mcall 47, 40100101h |
||
785 | lea ebx, [edx+60000h*18] |
||
786 | mov esi, ecx |
||
787 | pop ecx |
||
788 | pop edx |
||
789 | add edx, ecx |
||
790 | ret |
||
791 | |||
792 | ; TODO add SSE registers |
||
793 | ; TODO add AVX registers |
||
794 | |||
795 | ;----------------------------------------------------------------------------- |
||
796 | ; Display contents of EFLAGS register |
||
797 | draw_flag: |
||
798 | movzx edi, byte [edx+7] |
||
799 | bt [_eflags], edi |
||
800 | jc .on |
||
801 | or byte [edx], 20h |
||
802 | jmp .onoff |
||
803 | |||
804 | .on: |
||
805 | and byte [edx], not 20h |
||
806 | |||
807 | .onoff: |
||
808 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
||
809 | cmp [debuggee_pid], 0 |
||
810 | jz .doit |
||
811 | cmp [bSuspended], 0 |
||
812 | jz .doit |
||
4890 | hidnplayr | 813 | |
4591 | hidnplayr | 814 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
815 | bt [_eflags], edi |
||
816 | lahf |
||
817 | bt dword [_eflags + oldcontext - context], edi |
||
818 | rcl ah, 1 |
||
819 | test ah, 3 |
||
820 | jp .doit |
||
821 | mov ecx, (COLOR_TXT_CHANGED or 0x40000000) |
||
822 | |||
823 | .doit: |
||
824 | mov ah, 0 |
||
825 | mov edi, COLOR_BG_NORMAL |
||
826 | ; draw a text string in the window in one case |
||
827 | ; and a number in another |
||
828 | ; color scheme same as for previously called function (was in ecx) |
||
829 | mcall |
||
830 | ret |
||
831 | |||
832 | ;----------------------------------------------------------------------------- |
||
833 | ; Draw registers frame title |
||
834 | |||
835 | ; Also show current register set (common + MMX, SSE or AVX) |
||
836 | draw_reg_title: |
||
837 | mov edi, COLOR_BG_NORMAL |
||
838 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
||
839 | mov esi, 7 |
||
840 | cmp [reg_mode], REG_MODE_CPU |
||
841 | jz @f |
||
842 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
||
843 | @@: |
||
844 | mov edx, aMain |
||
845 | ; draw a text string in the window |
||
846 | mcall 4, (registers_x_pos+4)*10000h+registers_y_pos+2 |
||
4888 | hidnplayr | 847 | |
4591 | hidnplayr | 848 | cmp [reg_mode], REG_MODE_SSE |
849 | jz @f |
||
850 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
||
851 | @@: |
||
852 | mov edx, aSSE |
||
853 | ; draw a text string in the window |
||
854 | mcall 4, (registers_x_pos+46)*10000h+registers_y_pos+2 |
||
4888 | hidnplayr | 855 | |
4591 | hidnplayr | 856 | cmp [reg_mode], REG_MODE_AVX |
857 | jz @f |
||
858 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
||
859 | @@: |
||
860 | mov edx, aAVX |
||
861 | ; draw a text string in the window |
||
862 | mcall 4, (registers_x_pos+88)*10000h+registers_y_pos+2 |
||
863 | ret |
||
864 | |||
865 | ;----------------------------------------------------------------------------- |
||
866 | ; Display common registers set + MMX + FPU |
||
867 | |||
868 | draw_main_registers: |
||
4888 | hidnplayr | 869 | ; TODO: add support for FPU ST0-ST7 registers |
4591 | hidnplayr | 870 | mov edi, COLOR_BG_NORMAL |
871 | mov esi, _eax |
||
872 | push 4 |
||
873 | pop ecx |
||
874 | mov edx, regs_strs |
||
875 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+22 |
||
876 | call draw_register |
||
877 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+32 |
||
878 | add esi, _ebx-_eax |
||
879 | call draw_register |
||
880 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+42 |
||
881 | add esi, _ecx-_ebx |
||
882 | call draw_register |
||
883 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+52 |
||
884 | add esi, _edx-_ecx |
||
885 | call draw_register |
||
886 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+62 |
||
887 | add esi, _esi-_edx |
||
888 | call draw_register |
||
889 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+72 |
||
890 | add esi, _edi-_esi |
||
891 | call draw_register |
||
892 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+82 |
||
893 | add esi, _ebp-_edi |
||
894 | call draw_register |
||
895 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+92 |
||
896 | add esi, _esp-_ebp |
||
897 | call draw_register |
||
898 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+102 |
||
899 | add esi, _eip-_esp |
||
900 | call draw_register |
||
901 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+112 |
||
902 | push cx |
||
903 | mov cl, 7 |
||
904 | add esi, _eflags-_eip |
||
905 | call draw_register |
||
906 | pop cx |
||
907 | |||
908 | ; MMX registers |
||
909 | mov edx, mmx_strs |
||
910 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+142 |
||
911 | mov esi, _mm0 |
||
912 | call draw_mmx_register |
||
913 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+152 |
||
914 | add esi, _mm1-_mm0 |
||
915 | call draw_mmx_register |
||
916 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+162 |
||
917 | add esi, _mm2-_mm1 |
||
918 | call draw_mmx_register |
||
919 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+172 |
||
920 | add esi, _mm3-_mm2 |
||
921 | call draw_mmx_register |
||
922 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+182 |
||
923 | add esi, _mm4-_mm3 |
||
924 | call draw_mmx_register |
||
925 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+192 |
||
926 | add esi, _mm5-_mm4 |
||
927 | call draw_mmx_register |
||
928 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+202 |
||
929 | add esi, _mm6-_mm5 |
||
930 | call draw_mmx_register |
||
931 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+212 |
||
932 | add esi, _mm7-_mm6 |
||
933 | call draw_mmx_register |
||
4890 | hidnplayr | 934 | |
4591 | hidnplayr | 935 | mov ecx, COLOR_TXT_INACTIVE |
936 | cmp [debuggee_pid], 0 |
||
937 | jz @f |
||
938 | cmp [bSuspended], 0 |
||
939 | jz @f |
||
4889 | hidnplayr | 940 | mov ecx, COLOR_TXT_NORMAL |
4591 | hidnplayr | 941 | @@: |
942 | mov edx, aColon |
||
943 | xor esi, esi |
||
944 | inc esi |
||
945 | mcall 4, (registers_x_pos+10)*10000h+registers_y_pos+122 |
||
946 | mov edx, flags |
||
947 | |||
948 | @@: |
||
949 | add ebx, 2*6*10000h |
||
950 | call draw_flag |
||
951 | inc edx |
||
952 | cmp dl, flags_bits and 0xFF |
||
953 | jnz @b |
||
954 | ret |
||
955 | |||
956 | ;----------------------------------------------------------------------------- |
||
957 | ; Draw SSE registers set |
||
958 | |||
959 | draw_sse_registers: |
||
4888 | hidnplayr | 960 | |
4591 | hidnplayr | 961 | ret |
962 | |||
963 | ;----------------------------------------------------------------------------- |
||
964 | ; Draw AVX registers set |
||
965 | |||
966 | draw_avx_registers: |
||
4888 | hidnplayr | 967 | |
4591 | hidnplayr | 968 | ret |
969 | |||
970 | ;----------------------------------------------------------------------------- |
||
971 | ; Draw all registers sets |
||
972 | draw_registers: |
||
4888 | hidnplayr | 973 | |
974 | ; draw container rectangle/box with COLOR_BG_NORMAL |
||
975 | mcall 13, (registers_x_pos-1)*10000h+(registers_x_size+2), (registers_y_pos-1)*10000h+(registers_y_size+2), COLOR_BG_NORMAL |
||
4591 | hidnplayr | 976 | call draw_reg_title |
4888 | hidnplayr | 977 | |
978 | .redraw: |
||
4591 | hidnplayr | 979 | cmp [reg_mode], REG_MODE_CPU |
980 | jnz @f |
||
981 | call draw_main_registers |
||
982 | ret |
||
983 | |||
984 | @@: |
||
985 | cmp [reg_mode], REG_MODE_SSE |
||
986 | jnz @f |
||
987 | call draw_sse_registers |
||
988 | ret |
||
989 | |||
990 | @@: |
||
991 | call draw_avx_registers |
||
992 | ret |
||
993 | |||
994 | ;----------------------------------------------------------------------------- |
||
995 | ; Display memory dump |
||
996 | |||
997 | draw_dump: |
||
998 | ; draw container rectangle/box in the window |
||
999 | mcall 13, data_x_pos*10000h+data_x_size, dump_y_pos*10000h+dump_y_size, COLOR_BG_NORMAL |
||
1000 | |||
1001 | .redraw: |
||
4888 | hidnplayr | 1002 | ; addresses |
4591 | hidnplayr | 1003 | mov ebx, 80100h |
1004 | mov edx, data_x_pos*10000h + dump_y_pos |
||
1005 | mov ecx, [dumppos] |
||
1006 | mov edi, COLOR_BG_NORMAL |
||
1007 | mov esi, (COLOR_TXT_INACTIVE or 0x40000000) |
||
1008 | cmp [debuggee_pid], 0 |
||
1009 | jz @f |
||
1010 | cmp [bSuspended], 0 |
||
1011 | jz @f |
||
1012 | mov esi, (COLOR_TXT_NORMAL or 0x40000000) |
||
1013 | @@: |
||
4888 | hidnplayr | 1014 | ; draw a number in the window |
4591 | hidnplayr | 1015 | mcall 47 |
1016 | add ecx, 10h |
||
1017 | add edx, 10 |
||
1018 | cmp dl, dump_y_pos + dump_y_size |
||
1019 | jb @b |
||
4888 | hidnplayr | 1020 | ; hex dump of data |
4591 | hidnplayr | 1021 | mov ecx, dumpdata |
1022 | push ecx |
||
1023 | xor ebx, ebx |
||
1024 | mov edx, (data_x_pos+12*6)*10000h + dump_y_pos |
||
1025 | cmp [dumpread], ebx |
||
1026 | jz .hexdumpdone1 |
||
1027 | |||
1028 | .hexdumploop1: |
||
1029 | push ebx |
||
1030 | mov ebx, 20101h |
||
4888 | hidnplayr | 1031 | ; draw a number in the window |
4591 | hidnplayr | 1032 | mcall |
1033 | pop ebx |
||
1034 | add edx, 3*6*10000h |
||
1035 | inc ecx |
||
1036 | inc ebx |
||
1037 | test bl, 15 |
||
1038 | jz .16 |
||
1039 | test bl, 7 |
||
1040 | jnz @f |
||
1041 | add edx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h |
||
1042 | |||
1043 | .16: |
||
1044 | add edx, 10 - 6*(3*10h+2)*10000h |
||
1045 | |||
1046 | @@: |
||
1047 | cmp ebx, [dumpread] |
||
1048 | jb .hexdumploop1 |
||
1049 | |||
1050 | .hexdumpdone1: |
||
1051 | mov al, 4 |
||
1052 | ; copy color value from esi to ecx |
||
1053 | ; to draw text string with 'mcall 4' |
||
1054 | mov ecx, esi |
||
1055 | xchg ebx, edx |
||
1056 | push 2 |
||
1057 | pop esi |
||
1058 | |||
1059 | .hexdumploop2: |
||
1060 | cmp edx, dump_height*10h |
||
1061 | jae .hexdumpdone2 |
||
1062 | push edx |
||
1063 | mov edx, aQuests |
||
1064 | ; draw text string with color in ecx, copied from esi |
||
1065 | mcall |
||
1066 | pop edx |
||
1067 | add ebx, 3*6*10000h |
||
1068 | inc edx |
||
1069 | test dl, 15 |
||
1070 | jz .16x |
||
1071 | test dl, 7 |
||
1072 | jnz .hexdumploop2 |
||
1073 | add ebx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h |
||
1074 | |||
1075 | .16x: |
||
1076 | add ebx, 10 - 6*(3*10h+2)*10000h |
||
1077 | jmp .hexdumploop2 |
||
1078 | |||
1079 | .hexdumpdone2: |
||
1080 | dec esi |
||
4890 | hidnplayr | 1081 | ; colon, minus signs |
4591 | hidnplayr | 1082 | mov ebx, (data_x_pos+8*6)*10000h + dump_y_pos |
1083 | mov edx, aColon |
||
1084 | |||
1085 | @@: |
||
1086 | mcall |
||
1087 | add ebx, 10 |
||
1088 | cmp bl, dump_y_pos+dump_height*10 |
||
1089 | jb @b |
||
1090 | mov ebx, (data_x_pos+(12+3*8)*6)*10000h + dump_y_pos |
||
1091 | mov edx, aMinus |
||
1092 | |||
1093 | @@: |
||
1094 | mcall |
||
1095 | add ebx, 10 |
||
1096 | cmp bl, dump_y_pos+dump_height*10 |
||
1097 | jb @b |
||
4890 | hidnplayr | 1098 | ; ASCII data |
4591 | hidnplayr | 1099 | mov ebx, (data_x_pos+(12+3*10h+2+2)*6)*10000h + dump_y_pos |
1100 | pop edx |
||
1101 | push dump_height*10h |
||
1102 | |||
1103 | .asciiloop: |
||
1104 | push edx |
||
1105 | cmp byte [edx], 20h |
||
1106 | jae @f |
||
1107 | mov edx, aPoint |
||
1108 | |||
1109 | @@: |
||
1110 | ; draw a text string in the window, color in ecx |
||
1111 | mcall |
||
1112 | pop edx |
||
1113 | inc edx |
||
1114 | add ebx, 6*10000h |
||
1115 | dec dword [esp] |
||
1116 | jz .asciidone |
||
1117 | test byte [esp], 15 |
||
1118 | jnz .asciiloop |
||
1119 | add ebx, 10 - 6*10h*10000h |
||
1120 | jmp .asciiloop |
||
1121 | |||
1122 | .asciidone: |
||
1123 | pop ecx |
||
1124 | ret |
||
1125 | |||
1126 | ;----------------------------------------------------------------------------- |
||
1127 | ; Display disassembled code |
||
1128 | |||
1129 | draw_disasm: |
||
1130 | |||
1131 | mov eax, [disasm_start_pos] |
||
1132 | mov [disasm_cur_pos], eax |
||
1133 | and [disasm_cur_str], 0 |
||
1134 | |||
1135 | .loop: |
||
1136 | mov eax, [disasm_cur_pos] |
||
1137 | call find_symbol |
||
1138 | jc .nosymb |
||
1139 | mov ebx, [disasm_cur_str] |
||
1140 | imul ebx, 10 |
||
1141 | push ebx |
||
1142 | lea ecx, [ebx+disasm_y_pos-1] |
||
1143 | shl ecx, 16 |
||
1144 | mov cl, 11 |
||
1145 | ; setting up background color for disassembled text |
||
1146 | mov edx, COLOR_BG_NORMAL |
||
1147 | ; draw container rectangle/box with color COLOR_BG_NORMAL (was 0xFFFFFF - white) |
||
1148 | mcall 13, data_x_pos*10000h+data_x_size |
||
1149 | pop ebx |
||
1150 | ; copy color value from edx (COLOR_BG_NORMAL) |
||
1151 | mov edi, edx |
||
1152 | add ebx, (data_x_pos+6*2)*10000h+disasm_y_pos |
||
1153 | mov edx, esi |
||
1154 | |||
1155 | @@: |
||
1156 | lodsb |
||
1157 | test al, al |
||
1158 | jnz @b |
||
1159 | mov byte [esi-1], ':' |
||
1160 | sub esi, edx |
||
1161 | ; normal color |
||
1162 | ; was 0x40000000 |
||
4886 | hidnplayr | 1163 | mov ecx, (COLOR_TXT_LABEL or 0x40000000) |
4591 | hidnplayr | 1164 | mov al, 4 |
1165 | ; draw a text string in the window with color COLOR_TXT_NORMAL in ecx |
||
1166 | mcall |
||
1167 | mov byte [esi+edx-1], 0 |
||
1168 | lea esi, [esi*3] |
||
1169 | movzx ecx, bx |
||
1170 | shr ebx, 16 |
||
1171 | lea ebx, [ebx+esi*2] |
||
1172 | shl ecx, 16 |
||
1173 | mov cl, 10 |
||
1174 | imul ebx, 10001h |
||
1175 | sub bx, data_x_pos+data_x_size |
||
1176 | neg bx |
||
1177 | mov al, 13 |
||
1178 | ; copy color value from edi |
||
1179 | mov edx, edi |
||
1180 | ; draw container rectangle/box for disassembled text, color in edx |
||
1181 | mcall |
||
1182 | inc [disasm_cur_str] |
||
1183 | cmp [disasm_cur_str], disasm_height |
||
1184 | jae .loopend |
||
1185 | |||
1186 | .nosymb: |
||
1187 | push [disasm_cur_pos] |
||
1188 | call disasm_instr |
||
1189 | pop ebp |
||
1190 | jc .loopend |
||
4886 | hidnplayr | 1191 | mov edx, COLOR_BG_NORMAL |
4591 | hidnplayr | 1192 | mov esi, COLOR_TXT_NORMAL |
1193 | mov ebx, data_x_pos*10000h + data_x_size |
||
1194 | mov ecx, [disasm_cur_str] |
||
1195 | imul ecx, 10*10000h |
||
1196 | add ecx, (disasm_y_pos-1)*10000h + 10 |
||
1197 | mov eax, ebp |
||
1198 | pushad |
||
1199 | call find_enabled_breakpoint |
||
1200 | popad |
||
4886 | hidnplayr | 1201 | jnz .nobp |
4591 | hidnplayr | 1202 | mov edx, COLOR_BG_BREAKPOINT |
4886 | hidnplayr | 1203 | mov esi, COLOR_TXT_BREAKPOINT |
1204 | .nobp: |
||
4591 | hidnplayr | 1205 | |
1206 | mov eax, [_eip] |
||
1207 | cmp eax, ebp |
||
4886 | hidnplayr | 1208 | jnz .notcurrent |
4591 | hidnplayr | 1209 | mov edx, COLOR_BG_SELECTED |
1210 | mov esi, COLOR_TXT_SELECTED |
||
4886 | hidnplayr | 1211 | .notcurrent: |
1212 | push esi ; Save color value for disassembled text |
||
4591 | hidnplayr | 1213 | |
1214 | ; draw container rectangle/box for disassembled text |
||
1215 | ; color in edx |
||
1216 | mcall 13 |
||
4890 | hidnplayr | 1217 | |
4591 | hidnplayr | 1218 | mov edx, [disasm_cur_str] |
1219 | imul edx, 10 |
||
1220 | add edx, data_x_pos*10000h + disasm_y_pos |
||
1221 | ; draw a number in the window, color in esi |
||
1222 | mcall 47, 80100h, ebp |
||
4890 | hidnplayr | 1223 | |
4591 | hidnplayr | 1224 | lea ebx, [edx+8*6*10000h] |
4886 | hidnplayr | 1225 | mov ecx, esi ; text color |
4591 | hidnplayr | 1226 | push 2 |
1227 | pop esi |
||
1228 | mov edx, aColon |
||
4886 | hidnplayr | 1229 | ; draw the colon |
4591 | hidnplayr | 1230 | mcall 4 |
1231 | push 9 |
||
1232 | pop edi |
||
1233 | lea edx, [ebx+2*6*10000h] |
||
1234 | mov ecx, ebp |
||
1235 | sub ecx, [disasm_start_pos] |
||
1236 | add ecx, disasm_buffer |
||
1237 | |||
4888 | hidnplayr | 1238 | mov esi, COLOR_TXT_HEX |
4886 | hidnplayr | 1239 | mov eax, [_eip] |
1240 | cmp eax, ebp |
||
1241 | jnz @f |
||
1242 | mov esi, COLOR_TXT_SELECTED |
||
1243 | @@: |
||
4591 | hidnplayr | 1244 | .drawhex: |
1245 | ; draw a number in the window, color in esi |
||
1246 | mcall 47, 20101h |
||
1247 | add edx, 6*3*10000h |
||
1248 | inc ecx |
||
1249 | inc ebp |
||
1250 | cmp ebp, [disasm_cur_pos] |
||
1251 | jae .hexdone |
||
1252 | dec edi |
||
1253 | jnz .drawhex |
||
1254 | push esi |
||
1255 | mov esi, [disasm_cur_pos] |
||
1256 | dec esi |
||
1257 | cmp esi, ebp |
||
1258 | pop esi |
||
1259 | jbe .drawhex |
||
4890 | hidnplayr | 1260 | |
4591 | hidnplayr | 1261 | lea ebx, [edx-6*10000h] |
1262 | ; copy color value from esi |
||
1263 | mov ecx, esi |
||
1264 | push 3 |
||
1265 | pop esi |
||
1266 | mov edx, aDots |
||
1267 | ; draw a text string in the window, color in ecx |
||
1268 | mcall 4 |
||
1269 | |||
1270 | .hexdone: |
||
4886 | hidnplayr | 1271 | pop esi |
4591 | hidnplayr | 1272 | xor eax, eax |
1273 | mov edi, disasm_string |
||
1274 | mov edx, edi |
||
1275 | or ecx, -1 |
||
1276 | repnz scasb |
||
1277 | not ecx |
||
1278 | dec ecx |
||
1279 | xchg ecx, esi |
||
1280 | mov ebx, [disasm_cur_str] |
||
1281 | imul ebx, 10 |
||
1282 | add ebx, (data_x_pos+6*40)*10000h+disasm_y_pos |
||
4890 | hidnplayr | 1283 | |
4591 | hidnplayr | 1284 | ; draw a text string in the window, color in ecx |
1285 | mcall 4 |
||
1286 | inc [disasm_cur_str] |
||
1287 | cmp [disasm_cur_str], disasm_height |
||
1288 | jb .loop |
||
1289 | |||
1290 | .loopend: |
||
1291 | mov ecx, disasm_height |
||
1292 | sub ecx, [disasm_cur_str] |
||
1293 | jz @f |
||
1294 | imul ecx, 10 |
||
1295 | inc ecx |
||
1296 | mov eax, disasm_y_pos + disasm_y_size |
||
1297 | sub eax, ecx |
||
1298 | shl eax, 16 |
||
1299 | add ecx, eax |
||
4890 | hidnplayr | 1300 | ; Draw filled rectangle |
1301 | mcall 13, data_x_pos*10000h+data_x_size, , COLOR_BG_NORMAL |
||
4591 | hidnplayr | 1302 | |
1303 | @@: |
||
1304 | ret |
||
1305 | |||
1306 | ;----------------------------------------------------------------------------- |
||
1307 | |||
1308 | ; TODO: cleanup of this function, make some global labels local |
||
1309 | update_disasm_eip: |
||
1310 | ; test if instruction at eip is showed |
||
1311 | mov ecx, disasm_height |
||
1312 | mov eax, [disasm_start_pos] |
||
1313 | mov [disasm_cur_pos], eax |
||
1314 | |||
1315 | .l: |
||
1316 | mov eax, [disasm_cur_pos] |
||
1317 | call find_symbol |
||
1318 | jc @f |
||
1319 | dec ecx |
||
1320 | jz .m |
||
1321 | |||
1322 | @@: |
||
1323 | cmp [_eip], eax |
||
4890 | hidnplayr | 1324 | jz draw_disasm |
4591 | hidnplayr | 1325 | push ecx |
1326 | call disasm_instr |
||
1327 | pop ecx |
||
1328 | jc .m |
||
1329 | loop .l |
||
1330 | |||
1331 | .m: |
||
1332 | |||
1333 | update_disasm_eip_force: |
||
1334 | mov eax, [_eip] |
||
1335 | mov [disasm_start_pos], eax |
||
1336 | |||
1337 | update_disasm: |
||
1338 | cmp [debuggee_pid], 0 |
||
1339 | jz .no |
||
4890 | hidnplayr | 1340 | |
4591 | hidnplayr | 1341 | mcall 69, 6, [debuggee_pid], 256, [disasm_start_pos], disasm_buffer |
1342 | cmp eax, -1 |
||
1343 | jnz @f |
||
1344 | mov esi, read_mem_err |
||
1345 | call put_message |
||
1346 | |||
1347 | .no: |
||
1348 | xor eax, eax |
||
1349 | |||
1350 | @@: |
||
1351 | mov [disasm_buf_size], eax |
||
1352 | call restore_from_breaks |
||
4890 | hidnplayr | 1353 | jmp draw_disasm |
4591 | hidnplayr | 1354 | |
1355 | |||
1356 | ;----------------------------------------------------------------------------- |
||
1357 | ; Draw main window |
||
1358 | |||
1359 | draw_window: |
||
4890 | hidnplayr | 1360 | ; start window redraw |
4591 | hidnplayr | 1361 | mcall 12, 1 |
1362 | |||
4890 | hidnplayr | 1363 | ; define window |
4594 | hidnplayr | 1364 | mcall 0, wnd_x_size, wnd_y_size, (COLOR_BG_NORMAL or 0x54000000), , caption_str |
4591 | hidnplayr | 1365 | |
4890 | hidnplayr | 1366 | ; clear unused areas |
4591 | hidnplayr | 1367 | ; get window skin height |
1368 | mcall 48, 4 |
||
1369 | cmp eax, title_y_pos |
||
1370 | jb @f |
||
1371 | push registers_y_pos |
||
1372 | pop eax |
||
1373 | |||
1374 | @@: |
||
1375 | push registers_y_pos |
||
1376 | pop ecx |
||
1377 | push eax |
||
1378 | sub ecx, eax |
||
1379 | shl eax, 16 |
||
1380 | add ecx, eax |
||
1381 | mov ebx, 5*10000h + (wnd_x_size-9) |
||
1382 | mov edx, COLOR_BG_NORMAL |
||
1383 | ; draw container rectangle/box for registers information region |
||
1384 | mcall 13 |
||
1385 | mov ecx, (dump_y_pos+dump_y_size)*10000h + (disasm_y_pos-dump_y_pos-dump_y_size) |
||
1386 | ; draw container rectangle/box for dump memory region |
||
1387 | mcall |
||
1388 | mov ecx, (disasm_y_pos-1+disasm_y_size)*10000h + (messages_y_pos-disasm_y_pos+1-disasm_y_size) |
||
1389 | ; draw container rectangle/box for disassembled code region |
||
1390 | mcall |
||
1391 | mov ecx, (messages_y_pos+messages_y_size)*10000h + (wnd_y_size-messages_y_pos-messages_y_size-4) |
||
1392 | ; draw container rectangle/box for messages window region |
||
1393 | mcall |
||
1394 | mov ebx, 5*10000h + (data_x_pos-5) |
||
1395 | pop ecx |
||
1396 | imul ecx, 10001h |
||
1397 | sub cx, wnd_y_size-4 |
||
1398 | neg cx |
||
1399 | ; draw container rectangle/box |
||
1400 | mcall |
||
1401 | mov ebx, (data_x_pos+data_x_size)*10000h + (wnd_x_size-data_x_pos-data_x_size-4) |
||
1402 | ; draw container rectangle/box |
||
1403 | mcall |
||
1404 | mov ebx, 5*10000h + title_x_pos - 5 |
||
1405 | mov ecx, (title_y_pos)*10000h + (title_y_size) |
||
1406 | ; draw container rectangle/box for dump memory region title |
||
1407 | mcall |
||
1408 | |||
4890 | hidnplayr | 1409 | ; messages frame |
4591 | hidnplayr | 1410 | mov ebx, (messages_x_pos-2)*10000h + (messages_x_pos+messages_x_size+2) |
1411 | push ebx |
||
1412 | mov ecx, (messages_y_pos-2)*10001h |
||
1413 | mov edx, COLOR_LINE |
||
1414 | mcall 38 |
||
1415 | mov ecx, (messages_y_pos+messages_y_size+2)*10001h |
||
1416 | mcall |
||
1417 | mov ebx, (messages_x_pos-2)*10001h |
||
1418 | push ebx |
||
1419 | mov ecx, (messages_y_pos-2)*10000h + (messages_y_pos+messages_y_size+2) |
||
1420 | mcall |
||
1421 | mov ebx, (messages_x_pos+messages_x_size+2)*10001h |
||
1422 | push ebx |
||
1423 | mcall |
||
1424 | |||
4890 | hidnplayr | 1425 | ; command line frame |
4591 | hidnplayr | 1426 | mov ecx, (cmdline_y_pos-2)*10000h + (cmdline_y_pos+cmdline_y_size+2) |
1427 | pop ebx |
||
1428 | mcall |
||
1429 | pop ebx |
||
1430 | mcall |
||
1431 | pop ebx |
||
1432 | mov ecx, (cmdline_y_pos+cmdline_y_size+2)*10001h |
||
1433 | mcall |
||
1434 | mov ecx, (cmdline_y_pos-2)*10001h |
||
1435 | mcall |
||
1436 | |||
4890 | hidnplayr | 1437 | ; registers frame |
4888 | hidnplayr | 1438 | DrawRectangle (registers_x_pos-2), (registers_y_pos-2), (registers_x_size+3), (registers_y_size+3), COLOR_LINE |
4890 | hidnplayr | 1439 | ; draw container rectangle/box for registers information window region |
4591 | hidnplayr | 1440 | |
4890 | hidnplayr | 1441 | ; messages |
4591 | hidnplayr | 1442 | call draw_messages |
1443 | |||
4890 | hidnplayr | 1444 | ; command line & cursor |
4591 | hidnplayr | 1445 | call draw_cmdline |
1446 | call draw_cursor |
||
1447 | |||
4890 | hidnplayr | 1448 | ; title & registers & dump & disasm |
4591 | hidnplayr | 1449 | mov ebx, (data_x_pos-2)*10001h |
1450 | mov ecx, (title_y_pos+5)*10000h + (messages_y_pos-2) |
||
1451 | mov edx, COLOR_LINE |
||
1452 | mcall 38 |
||
1453 | mov ebx, (data_x_pos+data_x_size+2)*10001h |
||
1454 | mcall |
||
1455 | mov ebx, (data_x_pos-2)*10000h + (data_x_pos+data_x_size+2) |
||
1456 | mov ecx, (disasm_y_pos-4)*10001h |
||
1457 | mcall |
||
1458 | |||
4890 | hidnplayr | 1459 | ; redraw whole window again |
4591 | hidnplayr | 1460 | call redraw_title |
1461 | call draw_registers |
||
1462 | call draw_dump |
||
4890 | hidnplayr | 1463 | call draw_disasm |
4591 | hidnplayr | 1464 | |
4890 | hidnplayr | 1465 | ; end of window redraw |
4591 | hidnplayr | 1466 | mcall 12, 2 |
1467 | ret |
||
1468 | |||
1469 | ; vim: ft=fasm tabstop=4 |
||
1470 |