Rev 5206 | Rev 5461 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4901 | Serge | 1 | ;COLOR_THEME fix BLACK_ON_WHITE |
2 | COLOR_THEME fix MOVIEOS |
||
4591 | hidnplayr | 3 | |
4 | format binary as "" |
||
542 | diamond | 5 | include '../../macros.inc' |
205 | heavyiron | 6 | use32 |
3675 | GerdtR | 7 | db 'MENUET01' |
8 | dd 1 |
||
9 | dd start |
||
10 | dd i_end |
||
11 | dd used_mem |
||
12 | dd used_mem |
||
13 | dd i_param |
||
14 | dd 0 |
||
205 | heavyiron | 15 | |
3675 | GerdtR | 16 | ;----------------------------------------------------------------------------- |
17 | |||
18 | REG_MODE_CPU equ 1 |
||
19 | REG_MODE_MMX equ 2 |
||
20 | REG_MODE_SSE equ 3 |
||
21 | REG_MODE_AVX equ 4 |
||
22 | |||
23 | ;----------------------------------------------------------------------------- |
||
24 | |||
25 | include 'gui.inc' ; GUI routines |
||
26 | |||
27 | ;----------------------------------------------------------------------------- |
||
28 | ; Find command in list |
||
29 | |||
30 | find_cmd: |
||
31 | ; all commands are case-insensitive |
||
32 | push edi |
||
33 | |||
34 | .x4: |
||
35 | mov al, [edi] |
||
36 | cmp al, 0 |
||
37 | jz .x5 |
||
38 | cmp al, 'A' |
||
39 | jb @f |
||
40 | cmp al, 'Z' |
||
41 | ja @f |
||
42 | or al, 20h |
||
43 | |||
44 | @@: |
||
45 | stosb |
||
46 | jmp .x4 |
||
47 | |||
48 | ; find command |
||
49 | .x5: |
||
50 | pop edi |
||
51 | |||
52 | .x6: |
||
53 | cmp dword [esi], 0 |
||
54 | jz .x7 |
||
55 | push esi |
||
56 | mov esi, [esi] |
||
57 | lodsb |
||
58 | movzx ecx, al |
||
59 | push edi |
||
60 | repz cmpsb |
||
61 | pop edi |
||
62 | pop esi |
||
63 | jz .x8 |
||
64 | add esi, 17 |
||
65 | jmp .x6 |
||
66 | |||
67 | .x7: |
||
68 | stc |
||
69 | |||
70 | .x8: |
||
71 | ret |
||
72 | |||
205 | heavyiron | 73 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
3675 | GerdtR | 74 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DEBUGGING ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
205 | heavyiron | 75 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
76 | |||
3675 | GerdtR | 77 | ;----------------------------------------------------------------------------- |
78 | ; Help event |
||
205 | heavyiron | 79 | |
3675 | GerdtR | 80 | OnHelp: |
81 | mov esi, help_msg |
||
82 | mov edi, [curarg] |
||
83 | cmp byte [edi], 0 |
||
84 | jz .x |
||
85 | mov esi, help_groups |
||
86 | call find_cmd |
||
87 | jc .nocmd |
||
88 | mov esi, [esi+12] |
||
205 | heavyiron | 89 | |
3675 | GerdtR | 90 | .x: |
91 | jmp put_message |
||
205 | heavyiron | 92 | |
3675 | GerdtR | 93 | .nocmd: |
94 | mov esi, aUnknownCommand |
||
95 | jmp .x |
||
205 | heavyiron | 96 | |
3675 | GerdtR | 97 | ;----------------------------------------------------------------------------- |
98 | ; Quit event |
||
99 | OnQuit: |
||
100 | mcall -1 |
||
205 | heavyiron | 101 | |
3675 | GerdtR | 102 | ;----------------------------------------------------------------------------- |
103 | ; Working with debug context |
||
205 | heavyiron | 104 | |
3675 | GerdtR | 105 | get_new_context: |
106 | mov esi, context |
||
107 | mov edi, oldcontext |
||
4893 | Serge | 108 | mov ecx, (ctx_end-context)/4 |
3675 | GerdtR | 109 | rep movsd |
205 | heavyiron | 110 | |
3675 | GerdtR | 111 | get_context: |
4893 | Serge | 112 | mcall 69, 1, [debuggee_pid], ctx_end-context, context |
3675 | GerdtR | 113 | ret |
205 | heavyiron | 114 | |
3675 | GerdtR | 115 | set_context: |
116 | ;push 2 |
||
117 | ;pop ebx |
||
118 | ;push 69 |
||
119 | ;pop eax |
||
120 | ;mov ecx, [debuggee_pid] |
||
121 | ;mov esi, context |
||
122 | ;push 28h |
||
123 | ;pop edx |
||
124 | mcall 69, 2, [debuggee_pid], 28h, context |
||
125 | ret |
||
205 | heavyiron | 126 | |
3675 | GerdtR | 127 | get_dump: |
128 | mov edi, dumpdata |
||
129 | mov esi, [edi-4] |
||
130 | mov edx, dump_height*10h |
||
131 | mov ecx, edx |
||
132 | xor eax, eax |
||
133 | push edi |
||
134 | rep stosb |
||
135 | pop edi |
||
136 | ;mov ecx, [debuggee_pid] |
||
137 | ;mov al, 69 |
||
138 | ;push 6 |
||
139 | ;pop ebx |
||
140 | mcall 69, 6, [debuggee_pid] |
||
141 | cmp eax, -1 |
||
142 | jnz @f |
||
143 | mov esi, read_mem_err |
||
144 | call put_message |
||
145 | xor eax, eax |
||
205 | heavyiron | 146 | |
3675 | GerdtR | 147 | @@: |
148 | mov [edi-8], eax |
||
149 | ; call restore_from_breaks |
||
150 | ; ret |
||
205 | heavyiron | 151 | |
3675 | GerdtR | 152 | ; in: edi=buffer,eax=size,esi=address |
153 | restore_from_breaks: |
||
154 | mov ebx, breakpoints |
||
205 | heavyiron | 155 | |
3675 | GerdtR | 156 | @@: |
157 | test byte [ebx+4], 1 |
||
158 | jz .cont ; ignore invalid |
||
159 | test byte [ebx+4], 2 or 8 |
||
160 | jnz .cont ; ignore disabled and memory breaks |
||
161 | mov ecx, [ebx] |
||
162 | sub ecx, esi |
||
163 | cmp ecx, eax |
||
164 | jae .cont |
||
165 | mov dl, [ebx+5] |
||
166 | mov [edi+ecx], dl |
||
205 | heavyiron | 167 | |
3675 | GerdtR | 168 | .cont: |
169 | add ebx, 6 |
||
170 | cmp ebx, breakpoints+breakpoints_n*6 |
||
171 | jb @b |
||
172 | ret |
||
205 | heavyiron | 173 | |
3675 | GerdtR | 174 | ;----------------------------------------------------------------------------- |
175 | ; Load executable event |
||
205 | heavyiron | 176 | |
3675 | GerdtR | 177 | OnLoad: |
178 | mov esi, [curarg] |
||
205 | heavyiron | 179 | |
3675 | GerdtR | 180 | OnLoadInit: |
181 | mov edi, loadname |
||
182 | or [prgname_len], -1 |
||
183 | mov [prgname_ptr], edi |
||
205 | heavyiron | 184 | |
3675 | GerdtR | 185 | .copyname: |
186 | lodsb |
||
187 | stosb |
||
188 | inc [prgname_len] |
||
189 | cmp al, '/' |
||
190 | jnz @f |
||
191 | or [prgname_len], -1 |
||
192 | mov [prgname_ptr], edi |
||
205 | heavyiron | 193 | |
3675 | GerdtR | 194 | @@: |
195 | cmp al, ' ' |
||
196 | ja .copyname |
||
197 | mov byte [edi-1], 0 |
||
198 | and [load_params], 0 |
||
199 | dec esi |
||
200 | call get_arg.skip_spaces |
||
201 | cmp al, 0 |
||
202 | jz @f |
||
203 | mov [load_params], esi |
||
205 | heavyiron | 204 | |
3675 | GerdtR | 205 | @@: |
206 | and [dumppos], 0 |
||
207 | mov ecx, [symbols] |
||
208 | jecxz do_reload |
||
209 | mcall 68, 13 |
||
210 | and [symbols], 0 |
||
211 | and [num_symbols], 0 |
||
205 | heavyiron | 212 | |
3675 | GerdtR | 213 | ; TODO: make it local |
214 | do_reload: |
||
215 | ;push 18 |
||
216 | ;pop eax |
||
217 | ;push 7 |
||
218 | ;pop ebx |
||
219 | mcall 18, 7 |
||
220 | mov [dbgwnd], eax |
||
221 | xchg ecx, eax |
||
222 | ;push 70 |
||
223 | ;pop eax |
||
224 | ;mov ebx, fn70_load_block |
||
225 | mcall 70, fn70_load_block |
||
226 | test eax, eax |
||
227 | jns .load_ok |
||
205 | heavyiron | 228 | |
3675 | GerdtR | 229 | .load_err: |
230 | push eax |
||
231 | mov esi, load_err_msg |
||
232 | call put_message |
||
233 | pop eax |
||
234 | not eax |
||
235 | cmp eax, 0x20 |
||
236 | jae .unk_err |
||
237 | mov esi, [load_err_msgs+eax*4] |
||
238 | test esi, esi |
||
239 | jnz put_message |
||
205 | heavyiron | 240 | |
3675 | GerdtR | 241 | .unk_err: |
242 | mov esi, unk_err_msg |
||
243 | inc eax |
||
244 | push eax |
||
245 | call put_message_nodraw |
||
246 | jmp draw_messages |
||
205 | heavyiron | 247 | |
3675 | GerdtR | 248 | .load_ok: |
249 | mov [debuggee_pid], eax |
||
250 | mov [bSuspended], 1 |
||
251 | push ecx |
||
252 | call get_context |
||
253 | mov edi, oldcontext |
||
4893 | Serge | 254 | mov ecx, (ctx_end-context)/4 |
3675 | GerdtR | 255 | rep movsd |
205 | heavyiron | 256 | |
3675 | GerdtR | 257 | ; activate debugger window |
258 | pop ecx |
||
259 | ;mov bl, 3 |
||
260 | ;push 18 |
||
261 | ;pop eax |
||
262 | mcall 18, 3 |
||
263 | call redraw_title |
||
264 | call draw_registers.redraw |
||
265 | ; read and draw dump of memory |
||
266 | call get_dump |
||
267 | call draw_dump.redraw |
||
268 | call update_disasm_eip_force |
||
269 | mov esi, load_succ_msg |
||
270 | push [debuggee_pid] |
||
271 | call put_message_nodraw |
||
272 | call draw_messages |
||
273 | ; try to load symbols |
||
274 | mov esi, loadname |
||
275 | mov edi, symbolsfile |
||
276 | push edi |
||
205 | heavyiron | 277 | |
3675 | GerdtR | 278 | @@: |
279 | lodsb |
||
280 | stosb |
||
281 | test al, al |
||
282 | jnz @b |
||
283 | lea ecx, [edi-1] |
||
205 | heavyiron | 284 | |
3675 | GerdtR | 285 | @@: |
286 | dec edi |
||
287 | cmp edi, symbolsfile |
||
288 | jb @f |
||
289 | cmp byte [edi], '/' |
||
290 | jz @f |
||
291 | cmp byte [edi], '.' |
||
292 | jnz @b |
||
293 | mov ecx, edi |
||
205 | heavyiron | 294 | |
3675 | GerdtR | 295 | @@: |
4886 | hidnplayr | 296 | mov dword[ecx], '.dbg' |
297 | mov byte[ecx+4], 0 |
||
3675 | GerdtR | 298 | pop esi |
299 | mov ebp, esi |
||
4886 | hidnplayr | 300 | push ecx esi |
301 | call OnLoadSymbols.silent ; Try to load .dbg file |
||
302 | pop esi ecx |
||
303 | xor eax, eax |
||
304 | cmp [num_symbols], eax |
||
305 | jne @f |
||
306 | mov dword[ecx], '.map' ; If failed, try .map file too |
||
3675 | GerdtR | 307 | call OnLoadSymbols.silent |
4886 | hidnplayr | 308 | @@: |
309 | |||
3675 | GerdtR | 310 | ; now test for packed progs |
311 | cmp [disasm_buf_size], 100h |
||
312 | jz @f |
||
313 | ret |
||
205 | heavyiron | 314 | |
3675 | GerdtR | 315 | @@: |
316 | mov esi, mxp_nrv_sig |
||
317 | mov ebp, disasm_buffer |
||
318 | mov edi, ebp |
||
319 | push 3 |
||
320 | pop ecx |
||
321 | repz cmpsb |
||
322 | jnz .not_mxp_nrv |
||
323 | cmpsb |
||
324 | mov cl, mxp_nrv_sig_size-4 |
||
325 | repz cmpsb |
||
326 | mov esi, mxp_nrv_name |
||
327 | jz .packed |
||
205 | heavyiron | 328 | |
3675 | GerdtR | 329 | .not_mxp_nrv: |
330 | mov esi, mxp_sig |
||
331 | mov edi, ebp |
||
332 | mov cl, mxp_sig_size |
||
333 | repz cmpsb |
||
334 | mov esi, mxp_name |
||
335 | jz .packed |
||
205 | heavyiron | 336 | |
3675 | GerdtR | 337 | .not_mxp: |
338 | mov esi, mxp_lzo_sig1 |
||
339 | mov edi, ebp |
||
340 | mov cl, mxp_lzo_sig1_size |
||
341 | repz cmpsb |
||
342 | mov esi, mxp_lzo_name |
||
343 | jz .packed |
||
344 | mov esi, mxp_lzo_sig2 |
||
345 | mov edi, ebp |
||
346 | mov cl, 8 |
||
347 | repz cmpsb |
||
348 | jnz .not_mxp_lzo |
||
349 | cmpsb |
||
350 | mov cl, mxp_lzo_sig2_size - 9 |
||
351 | repz cmpsb |
||
352 | mov esi, mxp_lzo_name |
||
353 | jz .packed |
||
205 | heavyiron | 354 | |
3675 | GerdtR | 355 | .not_mxp_lzo: |
356 | mov esi, mtappack_name |
||
357 | cmp dword [ebp], 0xBF5E246A |
||
358 | jnz .not_mtappack |
||
359 | cmp dword [ebp+8], 0xEC4E8B57 |
||
360 | jnz .not_mtappack1 |
||
361 | cmp dword [ebp+12], 0x8D5EA4F3 |
||
362 | jnz .not_mtappack1 |
||
363 | cmp byte [ebp+12h], 0xE9 |
||
364 | jz .packed |
||
365 | |||
366 | .not_mtappack1: |
||
367 | cmp word [ebp+8], 0xB957 |
||
368 | jnz .not_mtappack |
||
369 | cmp dword [ebp+14], 0x575EA4F3 |
||
370 | jnz .not_mtappack2 |
||
371 | cmp byte [ebp+17h], 0xE9 |
||
372 | jz .packed |
||
373 | |||
374 | .not_mtappack2: |
||
375 | cmp dword [ebp+14], 0x5F8DA4F3 |
||
376 | jnz .not_mtappack3 |
||
377 | cmp word [ebp+18], 0xE9FC |
||
378 | jz .packed |
||
379 | |||
380 | .not_mtappack3: |
||
381 | cmp word [ebp+14], 0xA4F3 |
||
382 | jnz .not_mtappack |
||
383 | cmp byte [ebp+15h], 0xE9 |
||
384 | jz .packed |
||
385 | |||
386 | .not_mtappack: |
||
387 | ret |
||
388 | |||
389 | .packed: |
||
390 | push esi |
||
391 | mov esi, aPacked1 |
||
392 | call put_message_nodraw |
||
393 | pop esi |
||
394 | call put_message_nodraw |
||
395 | mov esi, aPacked2 |
||
396 | call put_message |
||
397 | call hide_cursor |
||
398 | ;push 40 |
||
399 | ;pop eax |
||
400 | ;push 7 |
||
401 | ;pop ebx |
||
402 | mcall 40, 7 |
||
403 | |||
404 | .wait: |
||
405 | ;push 10 |
||
406 | ;pop eax |
||
407 | mcall 10 |
||
408 | dec eax |
||
409 | jz .redraw |
||
410 | dec eax |
||
411 | jz .key |
||
412 | or eax, -1 |
||
413 | mcall |
||
414 | |||
415 | .redraw: |
||
416 | call draw_window |
||
417 | call hide_cursor |
||
418 | jmp .wait |
||
419 | |||
420 | .key: |
||
421 | mov al, 2 |
||
422 | mcall |
||
423 | cmp ah, 'y' |
||
424 | jz .yes |
||
425 | cmp ah, 'Y' |
||
426 | jz .yes |
||
427 | cmp ah, 0xD |
||
428 | jz .yes |
||
429 | cmp ah, 'n' |
||
430 | jz .no |
||
431 | cmp ah, 'N' |
||
432 | jnz .wait |
||
433 | |||
434 | .no: |
||
435 | ;push 40 |
||
436 | ;pop eax |
||
437 | ;mov ebx, 0x107 |
||
438 | mcall 40, 0x107 |
||
439 | call draw_cursor |
||
440 | mov esi, aN_str |
||
441 | jmp put_message |
||
442 | |||
443 | .yes: |
||
444 | ;push 40 |
||
445 | ;pop eax |
||
446 | ;mov ebx, 0x107 |
||
447 | mcall 40, 0x107 |
||
448 | call draw_cursor |
||
449 | mov esi, aY_str |
||
450 | call put_message |
||
451 | call OnUnpack |
||
452 | ret |
||
453 | |||
454 | ;----------------------------------------------------------------------------- |
||
455 | ; Searching signatures |
||
456 | |||
205 | heavyiron | 457 | mxp_nrv_sig: |
3675 | GerdtR | 458 | xor eax, eax |
459 | mov ecx, 0x95 ; 0xA1 for programs with parameters |
||
460 | mov [eax], ecx |
||
461 | add ecx, [eax+24h] |
||
462 | push 40h |
||
463 | pop esi |
||
464 | mov edi, [eax+20h] |
||
465 | push edi |
||
466 | rep movsb |
||
467 | jmp dword [esp] |
||
468 | pop esi |
||
469 | add esi, [eax] |
||
470 | xor edi, edi |
||
471 | |||
205 | heavyiron | 472 | mxp_nrv_sig_size = $ - mxp_nrv_sig |
473 | |||
474 | mxp_sig: |
||
3675 | GerdtR | 475 | mov ecx, 1CBh |
476 | push 46h |
||
477 | pop esi |
||
478 | mov edi, [20h] |
||
479 | rep movsb |
||
480 | mov ecx, [24h] |
||
481 | rep movsb |
||
482 | jmp dword [20h] |
||
483 | mov eax, [20h] |
||
484 | add eax, 1CBh |
||
485 | push eax |
||
486 | push dword [24h] |
||
487 | push 0 |
||
488 | push 8 |
||
489 | call $+0x25 |
||
490 | |||
205 | heavyiron | 491 | mxp_sig_size = $ - mxp_sig |
492 | |||
493 | mxp_lzo_sig1: |
||
3675 | GerdtR | 494 | xor eax, eax |
495 | mov ebp, 0FFh |
||
496 | mov ecx, 175h |
||
497 | mov [eax], ecx |
||
498 | add ecx, [eax+24h] |
||
499 | push 45h |
||
500 | pop esi |
||
501 | mov edi, [eax+20h] |
||
502 | push edi |
||
503 | rep movsb |
||
504 | jmp dword [esp] |
||
505 | pop ebx |
||
506 | add ebx, [eax] |
||
507 | xor edi, edi |
||
508 | cmp byte [ebx], 11h |
||
509 | jbe $+0x1A |
||
510 | |||
205 | heavyiron | 511 | mxp_lzo_sig1_size = $ - mxp_lzo_sig1 |
3675 | GerdtR | 512 | |
205 | heavyiron | 513 | mxp_lzo_sig2: |
3675 | GerdtR | 514 | xor eax, eax |
515 | mov ebp, 0FFh |
||
516 | mov ecx, 188h ; or 177h |
||
517 | mov [eax], ecx |
||
518 | add ecx, [eax+24h] |
||
519 | push 44h |
||
520 | pop esi |
||
521 | mov edi, [eax+20h] |
||
522 | rep movsb |
||
523 | jmp dword [eax+20h] |
||
524 | mov ebx, [eax+20h] |
||
525 | add ebx, [eax] |
||
526 | |||
205 | heavyiron | 527 | mxp_lzo_sig2_size = $ - mxp_lzo_sig2 |
528 | |||
3675 | GerdtR | 529 | ;----------------------------------------------------------------------------- |
530 | ; Reload executable event |
||
531 | |||
205 | heavyiron | 532 | OnReload: |
3675 | GerdtR | 533 | cmp [debuggee_pid], 0 |
534 | jnz terminate_reload |
||
535 | mov esi, need_debuggee |
||
536 | cmp byte [loadname], 0 |
||
537 | jnz do_reload |
||
538 | jz put_message |
||
539 | |||
540 | ; TODO: make it local |
||
205 | heavyiron | 541 | terminate_reload: |
3675 | GerdtR | 542 | mov [bReload], 1 |
543 | |||
544 | ;----------------------------------------------------------------------------- |
||
545 | ; Terminate process event |
||
546 | |||
205 | heavyiron | 547 | OnTerminate: |
3675 | GerdtR | 548 | ;mov ecx, [debuggee_pid] |
549 | ;push 8 |
||
550 | ;pop ebx |
||
551 | ;push 69 |
||
552 | ;pop eax |
||
553 | mcall 69, 8, [debuggee_pid] |
||
554 | ret |
||
555 | ;----------------------------------------------------------------------------- |
||
556 | ; Suspend process event |
||
205 | heavyiron | 557 | |
558 | AfterSuspend: |
||
3675 | GerdtR | 559 | mov [bSuspended], 1 |
560 | call get_new_context |
||
561 | call get_dump |
||
562 | call redraw_title |
||
563 | call draw_registers.redraw |
||
564 | call draw_dump.redraw |
||
565 | call update_disasm_eip |
||
566 | ret |
||
205 | heavyiron | 567 | |
568 | OnSuspend: |
||
3675 | GerdtR | 569 | ;mov ecx, [debuggee_pid] |
570 | ;push 4 |
||
571 | ;pop ebx |
||
572 | ;push 69 |
||
573 | ;pop eax |
||
574 | mcall 69, 4, [debuggee_pid] |
||
575 | call AfterSuspend |
||
576 | mov esi, aSuspended |
||
577 | jmp put_message |
||
578 | |||
579 | ;----------------------------------------------------------------------------- |
||
580 | ; Resume process event |
||
581 | |||
205 | heavyiron | 582 | DoResume: |
3675 | GerdtR | 583 | ;mov ecx, [debuggee_pid] |
584 | ;push 5 |
||
585 | ;pop ebx |
||
586 | ;push 69 |
||
587 | ;pop eax |
||
588 | mcall 69, 5, [debuggee_pid] |
||
589 | mov [bSuspended], 0 |
||
590 | ret |
||
591 | |||
205 | heavyiron | 592 | OnResume: |
3675 | GerdtR | 593 | mov esi, [curarg] |
594 | cmp byte [esi], 0 |
||
595 | jz GoOn |
||
596 | call calc_expression |
||
597 | jc .ret |
||
598 | mov eax, ebp |
||
599 | push eax |
||
600 | call find_enabled_breakpoint |
||
601 | pop eax |
||
602 | jz GoOn |
||
603 | mov bl, 5 ; valid enabled one-shot |
||
604 | call add_breakpoint |
||
605 | jnc GoOn |
||
606 | mov esi, aBreakpointLimitExceeded |
||
607 | call put_message |
||
608 | |||
609 | .ret: |
||
610 | ret |
||
611 | |||
205 | heavyiron | 612 | GoOn: |
3675 | GerdtR | 613 | ; test for enabled breakpoint at eip |
614 | mov eax, [_eip] |
||
615 | call find_enabled_breakpoint |
||
616 | jnz .nobreak |
||
617 | ; temporarily disable breakpoint, make step, enable breakpoint, continue |
||
618 | inc eax |
||
619 | mov [temp_break], eax |
||
620 | mov [bAfterGo], 1 |
||
621 | dec eax |
||
622 | call disable_breakpoint |
||
623 | call get_context |
||
624 | or byte [_eflags+1], 1 ; set TF |
||
625 | call set_context |
||
626 | and byte [_eflags+1], not 1 |
||
627 | call DoResume |
||
628 | ret |
||
629 | |||
630 | .nobreak: |
||
631 | call DoResume |
||
632 | call redraw_title |
||
633 | call draw_registers.redraw |
||
634 | call draw_dump.redraw |
||
635 | ret |
||
636 | |||
637 | ;----------------------------------------------------------------------------- |
||
638 | ; Detach process event |
||
639 | |||
205 | heavyiron | 640 | OnDetach: |
3675 | GerdtR | 641 | ;mov ecx, [debuggee_pid] |
642 | ;push 3 |
||
643 | ;pop ebx |
||
644 | ;push 69 |
||
645 | ;pop eax |
||
646 | mcall 69, 3, [debuggee_pid] |
||
647 | and [debuggee_pid], 0 |
||
648 | call redraw_title |
||
649 | call draw_registers.redraw |
||
650 | call draw_dump.redraw |
||
651 | call free_symbols |
||
652 | mov esi, aContinued |
||
653 | jmp put_message |
||
205 | heavyiron | 654 | |
655 | after_go_exception: |
||
3675 | GerdtR | 656 | push eax |
657 | mov eax, [temp_break] |
||
658 | dec eax |
||
659 | push esi |
||
660 | call enable_breakpoint |
||
661 | ; in any case, clear TF and RF |
||
662 | call get_new_context |
||
663 | and [_eflags], not 10100h ; clear TF,RF |
||
664 | call set_context |
||
665 | xor edx, edx |
||
666 | mov [temp_break], edx |
||
667 | xchg dl, [bAfterGo] |
||
668 | pop esi |
||
669 | pop eax |
||
670 | cmp dl, 2 |
||
671 | jnz @f |
||
672 | lodsd |
||
673 | push esi |
||
674 | call get_dump |
||
675 | jmp exception.done |
||
205 | heavyiron | 676 | |
3675 | GerdtR | 677 | @@: |
678 | test eax, eax |
||
679 | jz .notint1 |
||
680 | ; if exception is result of single step, simply ignore it and continue |
||
681 | test dword [esi], 0xF |
||
682 | jnz dbgmsgstart.5 |
||
683 | lodsd |
||
684 | push esi |
||
685 | mov esi, oldcontext |
||
686 | mov edi, context |
||
687 | mov ecx, 28h/4 |
||
688 | rep movsd |
||
689 | call DoResume |
||
690 | jmp dbgmsgend |
||
691 | |||
692 | .notint1: |
||
693 | ; in other case, work as without temp_break |
||
694 | lodsd |
||
695 | push esi |
||
696 | push eax |
||
697 | jmp exception.4 |
||
698 | |||
699 | .notour: |
||
700 | |||
701 | ; TODO: split it out |
||
205 | heavyiron | 702 | debugmsg: |
3675 | GerdtR | 703 | neg [dbgbufsize] |
704 | mov esi, dbgbuf |
||
705 | |||
706 | ; TODO: make it local |
||
205 | heavyiron | 707 | dbgmsgstart: |
3675 | GerdtR | 708 | lodsd |
709 | ; push eax esi |
||
710 | ; push dword [esi] |
||
711 | ; mov esi, dbgmsg_str |
||
712 | ; call put_message_nodraw |
||
713 | ; pop esi eax |
||
714 | add esi, 4 |
||
715 | dec eax |
||
716 | jz exception |
||
717 | dec eax |
||
718 | jz terminated |
||
719 | mov [bSuspended], 1 |
||
720 | cmp [bAfterGo], 0 |
||
721 | jnz after_go_exception |
||
722 | push esi |
||
723 | call get_new_context |
||
724 | and [_eflags], not 10100h ; clear TF,RF |
||
725 | call set_context |
||
726 | pop esi |
||
727 | |||
728 | ; TODO: WTF? Need for meaning label names |
||
729 | .5: |
||
730 | push esi |
||
731 | call get_dump |
||
732 | pop esi |
||
733 | lodsd |
||
734 | xor ecx, ecx |
||
735 | |||
736 | .6: |
||
737 | bt eax, ecx |
||
738 | jnc .7 |
||
739 | mov ebx, [drx_break+ecx*4] |
||
740 | test ebx, ebx |
||
741 | jz .7 |
||
742 | pushad |
||
743 | dec ebx |
||
744 | push ebx |
||
745 | mov esi, aBreakStop |
||
746 | call put_message_nodraw |
||
747 | popad |
||
748 | |||
749 | .7: |
||
750 | inc ecx |
||
751 | cmp cl, 4 |
||
752 | jb .6 |
||
753 | push esi |
||
754 | jmp exception.done_draw |
||
755 | |||
756 | ; TODO: make it local |
||
205 | heavyiron | 757 | terminated: |
3675 | GerdtR | 758 | push esi |
759 | mov esi, terminated_msg |
||
760 | call put_message |
||
761 | and [debuggee_pid], 0 |
||
762 | and [temp_break], 0 |
||
763 | mov [bAfterGo], 0 |
||
764 | xor eax, eax |
||
765 | mov ecx, breakpoints_n*6/4+4 |
||
766 | mov edi, breakpoints |
||
767 | rep stosd |
||
768 | cmp [bReload], 1 |
||
769 | sbb [bReload], -1 |
||
770 | jnz exception.done |
||
771 | call free_symbols |
||
772 | jmp exception.done |
||
773 | |||
205 | heavyiron | 774 | exception: |
3675 | GerdtR | 775 | mov [bSuspended], 1 |
776 | cmp [bAfterGo], 0 |
||
777 | jnz after_go_exception |
||
778 | lodsd |
||
779 | push esi |
||
780 | push eax |
||
781 | call get_new_context |
||
782 | and [_eflags], not 10100h ; clear TF,RF |
||
783 | call set_context |
||
784 | |||
785 | ; TODO: fix for useful name |
||
786 | .4: |
||
787 | call get_dump |
||
788 | pop eax |
||
789 | ; int3 command generates exception 0D, #GP |
||
790 | push eax |
||
791 | cmp al, 0Dh |
||
792 | jnz .notdbg |
||
793 | ; check for 0xCC byte at eip |
||
794 | push 0 |
||
5460 | hidnplayr | 795 | mcall 69, 6, [debuggee_pid], 1, [_eip], esp |
3675 | GerdtR | 796 | pop eax |
797 | cmp al, 0xCC |
||
5460 | hidnplayr | 798 | je .int3 |
799 | ; check for 0xCD03 word at eip |
||
800 | push 0 |
||
801 | inc edx |
||
802 | mcall 69;, 6, [debuggee_pid], 2, [_eip], esp |
||
803 | pop eax |
||
804 | cmp ax, 0x03CD |
||
805 | jne .notdbg |
||
806 | mov eax, [_eip] |
||
807 | inc [_eip] |
||
808 | inc [_eip] |
||
809 | jmp .user_int3_ |
||
810 | .int3: |
||
3675 | GerdtR | 811 | ; this is either dbg breakpoint or int3 cmd in debuggee |
812 | mov eax, [_eip] |
||
813 | call find_enabled_breakpoint |
||
814 | jnz .user_int3 |
||
815 | ; dbg breakpoint; clear if one-shot |
||
816 | pop ecx |
||
817 | push eax |
||
818 | mov esi, aBreakStop |
||
819 | test byte [edi+4], 4 |
||
820 | jz .put_msg_eax |
||
821 | pop ecx |
||
822 | call clear_breakpoint |
||
823 | jmp .done |
||
824 | |||
825 | .user_int3: |
||
826 | mov eax, [_eip] |
||
827 | inc [_eip] |
||
5460 | hidnplayr | 828 | .user_int3_: |
3675 | GerdtR | 829 | pop ecx |
830 | push eax |
||
831 | call set_context |
||
832 | mov esi, aUserBreak |
||
833 | jmp .put_msg_eax |
||
834 | |||
835 | .notdbg: |
||
836 | mov esi, aException |
||
837 | |||
838 | .put_msg_eax: |
||
839 | call put_message_nodraw |
||
840 | |||
841 | .done_draw: |
||
842 | call draw_messages |
||
843 | |||
844 | .done: |
||
845 | ;push 18 |
||
846 | ;pop eax |
||
847 | ;push 3 |
||
848 | ;pop ebx |
||
849 | ;mov ecx, [dbgwnd] |
||
850 | mcall 18, 3, [dbgwnd] ; activate dbg window |
||
851 | call redraw_title |
||
852 | call draw_registers.redraw |
||
853 | call draw_dump.redraw |
||
854 | call update_disasm_eip |
||
855 | |||
205 | heavyiron | 856 | dbgmsgend: |
3675 | GerdtR | 857 | pop esi |
858 | mov ecx, [dbgbuflen] |
||
859 | add ecx, dbgbuf |
||
860 | cmp esi, ecx |
||
861 | jnz dbgmsgstart |
||
862 | and [dbgbuflen], 0 |
||
863 | neg [dbgbufsize] |
||
864 | cmp [bReload], 2 |
||
865 | jnz @f |
||
866 | mov [bReload], 0 |
||
867 | call do_reload |
||
205 | heavyiron | 868 | |
3675 | GerdtR | 869 | @@: |
870 | jmp waitevent |
||
871 | |||
872 | ; TODO: make it local |
||
4590 | clevermous | 873 | F7: |
3675 | GerdtR | 874 | cmp [debuggee_pid], 0 |
875 | jz .no |
||
876 | call OnStep |
||
877 | |||
878 | .no: |
||
879 | jmp waitevent |
||
880 | |||
881 | ; TODO: make it local |
||
4590 | clevermous | 882 | F8: |
3675 | GerdtR | 883 | cmp [debuggee_pid], 0 |
4590 | clevermous | 884 | jz F7.no |
3675 | GerdtR | 885 | call OnProceed |
4590 | clevermous | 886 | jmp F7.no |
205 | heavyiron | 887 | |
3675 | GerdtR | 888 | ;----------------------------------------------------------------------------- |
889 | ; Step execution event |
||
890 | |||
891 | ;Here we get [ |
||
4443 | clevermous | 892 | OnStepMultiple: |
3675 | GerdtR | 893 | cmp [bSuspended], 0 |
4443 | clevermous | 894 | jz OnStep.running |
895 | mov [step_num], 1 |
||
3675 | GerdtR | 896 | mov esi, [curarg] |
4443 | clevermous | 897 | test esi, esi |
898 | jz .do |
||
3675 | GerdtR | 899 | cmp byte [esi], 0 |
4443 | clevermous | 900 | jz .do |
3675 | GerdtR | 901 | call get_hex_number |
902 | jc .ret |
||
903 | cmp eax, 0 ; check if lesser or equal than 0 |
||
904 | jle .ret |
||
905 | mov [step_num], eax |
||
4443 | clevermous | 906 | .do: |
907 | call OnStep |
||
908 | dec [step_num] |
||
909 | jnz .do |
||
910 | .ret: |
||
911 | ret |
||
205 | heavyiron | 912 | |
4443 | clevermous | 913 | OnStep: |
914 | cmp [bSuspended], 0 |
||
915 | jz .running |
||
3675 | GerdtR | 916 | call get_context |
917 | or byte [_eflags+1], 1 ; set TF |
||
918 | call set_context |
||
919 | and byte [_eflags+1], not 1 |
||
920 | ; if instruction at eip is "int xx", set one-shot breakpoint immediately after |
||
921 | mov eax, [_eip] |
||
922 | call find_enabled_breakpoint |
||
923 | jnz @f |
||
924 | cmp byte [edi+5], 0xCD |
||
925 | jz .int |
||
926 | |||
927 | @@: |
||
928 | push 0 |
||
929 | ;push 69 |
||
930 | ;pop eax |
||
931 | ;push 6 |
||
932 | ;pop ebx |
||
933 | ;mov ecx, [debuggee_pid] |
||
934 | ;push 3 |
||
935 | ;pop edx |
||
936 | ;mov edi, esp |
||
937 | ;mov esi, [_eip] |
||
938 | mcall 69, 6, [debuggee_pid], 3, [_eip], esp |
||
939 | cmp eax, edx |
||
940 | pop eax |
||
941 | jnz .doit |
||
942 | cmp al, 0xCD |
||
943 | jz .int |
||
944 | cmp ax, 0x050F |
||
945 | jz .syscall |
||
946 | cmp ax, 0x340F |
||
947 | jz .sysenter |
||
948 | |||
949 | ; resume process |
||
950 | .doit: |
||
951 | call GoOn |
||
952 | cmp [bAfterGo], 0 |
||
953 | jz @f |
||
954 | mov [bAfterGo], 2 |
||
955 | |||
956 | @@: |
||
957 | ret |
||
958 | |||
959 | ; return address is [ebp-4] |
||
960 | .sysenter: |
||
961 | push 0 |
||
962 | ;push 69 |
||
963 | ;pop eax |
||
964 | inc edx ; read 4 bytes |
||
965 | mov esi, [_ebp] |
||
966 | sub esi, 4 |
||
967 | mcall 69 |
||
968 | cmp eax, edx |
||
969 | pop eax |
||
970 | jnz .syscall |
||
971 | push eax |
||
972 | and byte [_eflags+1], not 1 |
||
973 | call set_context |
||
974 | pop eax |
||
975 | jmp @f |
||
976 | |||
977 | .syscall: |
||
978 | and byte [_eflags+1], not 1 ; clear TF - avoid system halt (!) |
||
979 | call set_context |
||
980 | |||
981 | .int: |
||
982 | mov eax, [_eip] |
||
983 | inc eax |
||
984 | inc eax |
||
985 | |||
986 | @@: |
||
987 | push eax |
||
988 | call find_enabled_breakpoint |
||
989 | pop eax |
||
990 | jz .doit |
||
991 | ; there is no enabled breakpoint yet; set temporary breakpoint |
||
992 | mov bl, 5 |
||
993 | call add_breakpoint |
||
994 | jmp .doit |
||
995 | |||
996 | .running: |
||
997 | mov esi, aRunningErr |
||
998 | jmp put_message |
||
999 | |||
1000 | ;----------------------------------------------------------------------------- |
||
1001 | ; Proceed process event |
||
5206 | clevermous | 1002 | ;Here we get [ |
1003 | OnProceedMultiple: |
||
3675 | GerdtR | 1004 | cmp [bSuspended], 0 |
1005 | jz OnStep.running |
||
5206 | clevermous | 1006 | mov [proc_num], 1 |
3675 | GerdtR | 1007 | mov esi, [curarg] |
5206 | clevermous | 1008 | test esi, esi |
1009 | jz .do |
||
3675 | GerdtR | 1010 | cmp byte [esi], 0 |
5206 | clevermous | 1011 | jz .do |
3675 | GerdtR | 1012 | call get_hex_number |
1013 | jc .ret |
||
5206 | clevermous | 1014 | cmp eax, 0 ; check if lesser or equal than 0 |
3675 | GerdtR | 1015 | jle .ret |
1016 | mov [proc_num], eax |
||
1017 | mov [curarg], 0 |
||
5206 | clevermous | 1018 | .do: |
1019 | call OnProceed |
||
1020 | dec [proc_num] |
||
1021 | jnz .do |
||
1022 | .ret: |
||
1023 | ret |
||
205 | heavyiron | 1024 | |
5206 | clevermous | 1025 | |
1026 | OnProceed: |
||
1027 | cmp [bSuspended], 0 |
||
1028 | jz OnStep.running |
||
3675 | GerdtR | 1029 | mov esi, [_eip] |
205 | heavyiron | 1030 | |
3675 | GerdtR | 1031 | @@: |
1032 | call get_byte_nobreak |
||
4443 | clevermous | 1033 | jc OnStep |
3675 | GerdtR | 1034 | inc esi |
1035 | ; skip prefixes |
||
1036 | call is_prefix |
||
1037 | jz @b |
||
1038 | cmp al, 0xE8 ; call |
||
1039 | jnz @f |
||
1040 | add esi, 4 |
||
1041 | jmp .doit |
||
205 | heavyiron | 1042 | |
3675 | GerdtR | 1043 | ; A4,A5 = movs; A6,A7 = cmps |
1044 | @@: |
||
1045 | cmp al, 0xA4 |
||
1046 | jb @f |
||
1047 | cmp al, 0xA8 |
||
1048 | jb .doit |
||
205 | heavyiron | 1049 | |
3675 | GerdtR | 1050 | ; AA,AB = stos; AC,AD = lods; AE,AF = scas |
1051 | @@: |
||
1052 | cmp al, 0xAA |
||
1053 | jb @f |
||
1054 | cmp al, 0xB0 |
||
1055 | jb .doit |
||
205 | heavyiron | 1056 | |
3675 | GerdtR | 1057 | ; E0 = loopnz; E1 = loopz; E2 = loop |
1058 | @@: |
||
1059 | cmp al, 0xE0 |
||
1060 | jb .noloop |
||
1061 | cmp al, 0xE2 |
||
1062 | ja .noloop |
||
1063 | inc esi |
||
1064 | jmp .doit |
||
205 | heavyiron | 1065 | |
3675 | GerdtR | 1066 | ; FF /2 = call |
1067 | .noloop: |
||
1068 | cmp al, 0xFF |
||
4443 | clevermous | 1069 | jnz OnStep |
3675 | GerdtR | 1070 | call get_byte_nobreak |
4443 | clevermous | 1071 | jc OnStep |
3675 | GerdtR | 1072 | inc esi |
1073 | mov cl, al |
||
1074 | and al, 00111000b |
||
1075 | cmp al, 00010000b |
||
4443 | clevermous | 1076 | jnz OnStep |
3675 | GerdtR | 1077 | ; skip instruction |
1078 | mov al, cl |
||
1079 | and eax, 7 |
||
1080 | shr cl, 6 |
||
1081 | jz .mod0 |
||
1082 | jp .doit |
||
1083 | cmp al, 4 |
||
1084 | jnz @f |
||
1085 | inc esi |
||
205 | heavyiron | 1086 | |
3675 | GerdtR | 1087 | @@: |
1088 | inc esi |
||
1089 | dec cl |
||
1090 | jz @f |
||
1091 | add esi, 3 |
||
205 | heavyiron | 1092 | |
3675 | GerdtR | 1093 | @@: |
1094 | jmp .doit |
||
205 | heavyiron | 1095 | |
3675 | GerdtR | 1096 | .mod0: |
1097 | cmp al, 4 |
||
1098 | jnz @f |
||
1099 | call get_byte_nobreak |
||
4443 | clevermous | 1100 | jc OnStep |
3675 | GerdtR | 1101 | inc esi |
1102 | and al, 7 |
||
205 | heavyiron | 1103 | |
3675 | GerdtR | 1104 | @@: |
1105 | cmp al, 5 |
||
1106 | jnz .doit |
||
1107 | add esi, 4 |
||
205 | heavyiron | 1108 | |
3675 | GerdtR | 1109 | .doit: |
1110 | ; insert one-shot breakpoint at esi and resume |
||
1111 | call get_byte_nobreak |
||
4443 | clevermous | 1112 | jc OnStep |
3675 | GerdtR | 1113 | mov eax, esi |
1114 | call find_enabled_breakpoint |
||
1115 | jz @f |
||
1116 | mov eax, esi |
||
1117 | mov bl, 5 |
||
1118 | call add_breakpoint |
||
1119 | jmp OnStep.doit |
||
1120 | |||
1121 | @@: |
||
1122 | ret |
||
1123 | |||
1124 | ;----------------------------------------------------------------------------- |
||
1125 | ; Read next byte of machine code |
||
1126 | |||
1127 | get_byte_nobreak: |
||
1128 | mov eax, esi |
||
1129 | call find_enabled_breakpoint |
||
1130 | jnz .nobreak |
||
1131 | mov al, [edi+5] |
||
1132 | clc |
||
1133 | ret |
||
4893 | Serge | 1134 | |
3675 | GerdtR | 1135 | .nobreak: |
1136 | ;push 69 |
||
1137 | ;pop eax |
||
1138 | ;push 6 |
||
1139 | ;pop ebx |
||
1140 | ;mov ecx, [debuggee_pid] |
||
1141 | xor edx, edx |
||
1142 | push edx |
||
1143 | inc edx |
||
1144 | mov edi, esp |
||
1145 | mcall 69, 6, [debuggee_pid] |
||
1146 | dec eax |
||
1147 | clc |
||
1148 | jz @f |
||
1149 | stc |
||
4893 | Serge | 1150 | |
3675 | GerdtR | 1151 | @@: |
1152 | pop eax |
||
1153 | ret |
||
1154 | |||
1155 | include 'parser.inc' |
||
1156 | |||
1157 | ;----------------------------------------------------------------------------- |
||
1158 | ; Calculate expression event |
||
1159 | |||
205 | heavyiron | 1160 | OnCalc: |
3675 | GerdtR | 1161 | mov esi, [curarg] |
1162 | call calc_expression |
||
1163 | jc .ret |
||
1164 | push ebp |
||
1165 | mov esi, calc_string |
||
1166 | call put_message_nodraw |
||
1167 | jmp draw_messages |
||
4893 | Serge | 1168 | |
3675 | GerdtR | 1169 | .ret: |
1170 | ret |
||
205 | heavyiron | 1171 | |
3675 | GerdtR | 1172 | ;----------------------------------------------------------------------------- |
1173 | ; Dump memory event |
||
1174 | |||
205 | heavyiron | 1175 | OnDump: |
3675 | GerdtR | 1176 | mov esi, [curarg] |
1177 | cmp byte [esi], 0 |
||
1178 | jnz .param |
||
1179 | add [dumppos], dump_height*10h |
||
1180 | jmp .doit |
||
4893 | Serge | 1181 | |
3675 | GerdtR | 1182 | .param: |
1183 | call calc_expression |
||
1184 | jc .ret |
||
1185 | mov [dumppos], ebp |
||
205 | heavyiron | 1186 | |
3675 | GerdtR | 1187 | .doit: |
1188 | call get_dump |
||
1189 | call draw_dump.redraw |
||
1190 | |||
1191 | .ret: |
||
1192 | ret |
||
1193 | |||
1194 | ;----------------------------------------------------------------------------- |
||
1195 | ; Dissassemble block of executable event |
||
1196 | |||
205 | heavyiron | 1197 | OnUnassemble: |
3675 | GerdtR | 1198 | mov esi, [curarg] |
1199 | cmp byte [esi], 0 |
||
1200 | jnz .param |
||
1201 | mov eax, [disasm_start_pos] |
||
4908 | hidnplayr | 1202 | mov ecx, [disasm_height_dd] |
3675 | GerdtR | 1203 | mov [disasm_cur_pos], eax |
205 | heavyiron | 1204 | |
3675 | GerdtR | 1205 | .l: |
1206 | mov eax, [disasm_cur_pos] |
||
1207 | call find_symbol |
||
1208 | jc @f |
||
1209 | dec ecx |
||
1210 | jz .m |
||
1211 | |||
1212 | @@: |
||
1213 | push ecx |
||
1214 | call disasm_instr |
||
1215 | pop ecx |
||
1216 | jc .err |
||
1217 | loop .l |
||
1218 | |||
1219 | .m: |
||
1220 | mov eax, [disasm_cur_pos] |
||
1221 | jmp .doit |
||
1222 | |||
1223 | .param: |
||
1224 | call calc_expression |
||
1225 | jc .ret |
||
1226 | mov eax, ebp |
||
1227 | |||
1228 | .doit: |
||
1229 | push eax |
||
1230 | push [disasm_start_pos] |
||
1231 | mov [disasm_start_pos], eax |
||
1232 | call update_disasm |
||
1233 | pop [disasm_start_pos] |
||
1234 | pop eax |
||
1235 | cmp [disasm_cur_str], 0 |
||
1236 | jz @f |
||
1237 | mov [disasm_start_pos], eax |
||
1238 | |||
1239 | .ret: |
||
1240 | ret |
||
1241 | |||
1242 | @@: |
||
1243 | call update_disasm |
||
1244 | |||
1245 | .err: |
||
1246 | mov esi, aInvAddr |
||
1247 | jmp put_message |
||
1248 | |||
1249 | ;----------------------------------------------------------------------------- |
||
1250 | ; Access to register value event |
||
1251 | |||
205 | heavyiron | 1252 | OnReg: |
3675 | GerdtR | 1253 | mov esi, [curarg] |
1254 | call get_arg.skip_spaces |
||
1255 | call find_reg |
||
1256 | jnc @f |
||
205 | heavyiron | 1257 | |
3675 | GerdtR | 1258 | .err: |
1259 | mov esi, RSyntax |
||
1260 | jmp put_message |
||
1261 | |||
1262 | @@: |
||
1263 | call get_arg.skip_spaces |
||
1264 | test al, al |
||
1265 | jz .err |
||
1266 | cmp al, '=' |
||
1267 | jnz @f |
||
1268 | inc esi |
||
1269 | call get_arg.skip_spaces |
||
1270 | test al, al |
||
1271 | jz .err |
||
1272 | |||
1273 | @@: |
||
1274 | push edi |
||
1275 | call calc_expression |
||
1276 | pop edi |
||
1277 | jc .ret |
||
1278 | ; now edi=register id, ebp=value |
||
1279 | cmp [bSuspended], 0 |
||
1280 | mov esi, aRunningErr |
||
1281 | jz put_message |
||
1282 | xchg eax, ebp |
||
1283 | cmp edi, 24 |
||
1284 | jz .eip |
||
1285 | sub edi, 4 |
||
1286 | jb .8lo |
||
1287 | sub edi, 4 |
||
1288 | jb .8hi |
||
1289 | sub edi, 8 |
||
1290 | jb .16 |
||
1291 | mov [_eax+edi*4], eax |
||
1292 | jmp .ret |
||
1293 | |||
1294 | .16: |
||
1295 | mov word [_eax+(edi+8)*4], ax |
||
1296 | jmp .ret |
||
1297 | |||
1298 | .8lo: |
||
1299 | mov byte [_eax+(edi+4)*4], al |
||
1300 | jmp .ret |
||
1301 | |||
1302 | .8hi: |
||
1303 | mov byte [_eax+(edi+4)*4+1], al |
||
1304 | jmp .ret |
||
1305 | |||
1306 | .eip: |
||
1307 | mov [_eip], eax |
||
1308 | call update_disasm_eip |
||
1309 | |||
1310 | .ret: |
||
1311 | call set_context |
||
1312 | jmp draw_registers.redraw |
||
1313 | |||
1314 | ;----------------------------------------------------------------------------- |
||
1315 | ; Breakpoints manipulation |
||
205 | heavyiron | 1316 | OnBp: |
3675 | GerdtR | 1317 | mov esi, [curarg] |
1318 | call calc_expression |
||
1319 | jc .ret |
||
1320 | xchg eax, ebp |
||
1321 | push eax |
||
1322 | call find_breakpoint |
||
1323 | inc eax |
||
1324 | pop eax |
||
1325 | jz .notfound |
||
1326 | mov esi, aDuplicateBreakpoint |
||
1327 | jmp .sayerr |
||
205 | heavyiron | 1328 | |
3675 | GerdtR | 1329 | .notfound: |
1330 | mov bl, 1 |
||
1331 | call add_breakpoint |
||
1332 | jnc .ret |
||
1333 | mov esi, aBreakpointLimitExceeded |
||
1334 | |||
1335 | .sayerr: |
||
1336 | call put_message |
||
1337 | |||
1338 | .ret: |
||
4890 | hidnplayr | 1339 | jmp draw_disasm |
3675 | GerdtR | 1340 | |
205 | heavyiron | 1341 | OnBpmb: |
3675 | GerdtR | 1342 | mov dh, 0011b |
1343 | jmp DoBpm |
||
1344 | |||
205 | heavyiron | 1345 | OnBpmw: |
3675 | GerdtR | 1346 | mov dh, 0111b |
1347 | jmp DoBpm |
||
1348 | |||
205 | heavyiron | 1349 | OnBpmd: |
3675 | GerdtR | 1350 | mov dh, 1111b |
1351 | |||
205 | heavyiron | 1352 | DoBpm: |
3675 | GerdtR | 1353 | mov esi, [curarg] |
1354 | cmp byte [esi], 'w' |
||
1355 | jnz @f |
||
1356 | and dh, not 2 |
||
1357 | inc esi |
||
205 | heavyiron | 1358 | |
3675 | GerdtR | 1359 | @@: |
1360 | push edx |
||
1361 | call calc_expression |
||
1362 | pop edx |
||
1363 | jnc @f |
||
1364 | ret |
||
1365 | |||
1366 | ; ebp = expression, dh = flags |
||
1367 | @@: |
||
1368 | movzx eax, dh |
||
1369 | shr eax, 2 |
||
1370 | test ebp, eax |
||
1371 | jz @f |
||
1372 | mov esi, aUnaligned |
||
1373 | jmp put_message |
||
1374 | |||
1375 | @@: |
||
1376 | mov eax, ebp |
||
1377 | mov bl, 0Bh |
||
1378 | call add_breakpoint |
||
1379 | jnc @f |
||
1380 | mov esi, aBreakpointLimitExceeded |
||
1381 | jmp put_message |
||
1382 | |||
1383 | ; now find index |
||
1384 | @@: |
||
1385 | push eax |
||
1386 | xor ecx, ecx |
||
1387 | |||
1388 | .l1: |
||
1389 | cmp [drx_break+ecx*4], 0 |
||
1390 | jnz .l2 |
||
1391 | ;push 69 |
||
1392 | ;pop eax |
||
1393 | push ecx |
||
1394 | mov dl, cl |
||
1395 | ;mov ecx, [debuggee_pid] |
||
1396 | mov esi, ebp |
||
1397 | ;push 9 |
||
1398 | ;pop ebx |
||
1399 | mcall 69, 9, [debuggee_pid] |
||
1400 | test eax, eax |
||
1401 | jz .ok |
||
1402 | pop ecx |
||
1403 | |||
1404 | .l2: |
||
1405 | inc ecx |
||
1406 | cmp ecx, 4 |
||
1407 | jb .l1 |
||
1408 | pop eax |
||
1409 | call clear_breakpoint |
||
1410 | mov esi, aBreakpointLimitExceeded |
||
1411 | jmp put_message |
||
1412 | |||
1413 | .ok: |
||
1414 | pop ecx |
||
1415 | pop eax |
||
1416 | and byte [edi], not 2 ; breakpoint is enabled |
||
1417 | shl dl, 6 |
||
1418 | or dl, dh |
||
1419 | mov byte [edi+1], dl |
||
1420 | inc eax |
||
1421 | mov [drx_break+ecx*4], eax |
||
1422 | ret |
||
1423 | |||
205 | heavyiron | 1424 | OnBc: |
3675 | GerdtR | 1425 | mov esi, [curarg] |
205 | heavyiron | 1426 | |
3675 | GerdtR | 1427 | @@: |
1428 | call get_hex_number |
||
1429 | jc OnBp.ret |
||
1430 | call clear_breakpoint |
||
1431 | jmp @b |
||
1432 | |||
205 | heavyiron | 1433 | OnBd: |
3675 | GerdtR | 1434 | mov esi, [curarg] |
205 | heavyiron | 1435 | |
3675 | GerdtR | 1436 | @@: |
1437 | call get_hex_number |
||
1438 | jc OnBp.ret |
||
1439 | call disable_breakpoint |
||
1440 | jmp @b |
||
1441 | |||
205 | heavyiron | 1442 | OnBe: |
3675 | GerdtR | 1443 | mov esi, [curarg] |
205 | heavyiron | 1444 | |
3675 | GerdtR | 1445 | @@: |
1446 | call get_hex_number |
||
1447 | jc OnBp.ret |
||
1448 | push eax |
||
1449 | call find_enabled_breakpoint |
||
1450 | pop eax |
||
1451 | jz .err |
||
1452 | call enable_breakpoint |
||
1453 | jmp @b |
||
1454 | |||
1455 | .err: |
||
1456 | mov esi, OnBeErrMsg |
||
1457 | jmp put_message |
||
1458 | |||
1459 | ; TODO: split it out in parser.inc |
||
205 | heavyiron | 1460 | get_hex_number: |
3675 | GerdtR | 1461 | call get_arg.skip_spaces |
1462 | xor ecx, ecx |
||
1463 | xor edx, edx |
||
205 | heavyiron | 1464 | |
3675 | GerdtR | 1465 | @@: |
1466 | lodsb |
||
1467 | call is_hex_digit |
||
1468 | jc .ret |
||
1469 | shl edx, 4 |
||
1470 | or dl, al |
||
1471 | inc ecx |
||
1472 | jmp @b |
||
1473 | |||
1474 | .ret: |
||
1475 | dec esi |
||
1476 | cmp ecx, 1 |
||
1477 | xchg eax, edx |
||
1478 | ret |
||
1479 | |||
1480 | ;----------------------------------------------------------------------------- |
||
1481 | ; Breakpoints list event |
||
1482 | |||
205 | heavyiron | 1483 | OnBl: |
3675 | GerdtR | 1484 | mov esi, [curarg] |
1485 | cmp byte [esi], 0 |
||
1486 | jz .listall |
||
1487 | call get_hex_number |
||
1488 | jc .ret |
||
1489 | cmp eax, breakpoints_n |
||
1490 | jae .err |
||
1491 | push eax |
||
1492 | add eax, eax |
||
1493 | lea edi, [breakpoints + eax + eax*2] |
||
1494 | pop eax |
||
1495 | test byte [edi+4], 1 |
||
1496 | jz .err |
||
1497 | call show_break_info |
||
205 | heavyiron | 1498 | |
3675 | GerdtR | 1499 | .ret: |
1500 | ret |
||
1501 | |||
1502 | .err: |
||
1503 | mov esi, aInvalidBreak |
||
1504 | jmp put_message |
||
1505 | |||
1506 | .listall: |
||
1507 | mov edi, breakpoints |
||
1508 | xor eax, eax |
||
1509 | |||
1510 | @@: |
||
1511 | test byte [edi+4], 1 |
||
1512 | jz .cont |
||
1513 | push edi eax |
||
1514 | call show_break_info |
||
1515 | pop eax edi |
||
1516 | |||
1517 | .cont: |
||
1518 | add edi, 6 |
||
1519 | inc eax |
||
1520 | cmp eax, breakpoints_n |
||
1521 | jb @b |
||
1522 | ret |
||
1523 | |||
1524 | ;----------------------------------------------------------------------------- |
||
4893 | Serge | 1525 | |
205 | heavyiron | 1526 | show_break_info: |
3675 | GerdtR | 1527 | push edi |
1528 | test byte [edi+4], 8 |
||
1529 | jnz .dr |
||
1530 | push dword [edi] |
||
1531 | push eax |
||
1532 | mov esi, aBreakNum |
||
1533 | call put_message_nodraw |
||
1534 | jmp .cmn |
||
205 | heavyiron | 1535 | |
3675 | GerdtR | 1536 | .dr: |
1537 | push eax |
||
1538 | mov esi, aMemBreak1 |
||
1539 | call put_message_nodraw |
||
1540 | pop edi |
||
1541 | push edi |
||
1542 | mov esi, aMemBreak2 |
||
1543 | test byte [edi+5], 2 |
||
1544 | jz @f |
||
1545 | mov esi, aMemBreak3 |
||
1546 | |||
1547 | @@: |
||
1548 | call put_message_nodraw |
||
1549 | pop edi |
||
1550 | push edi |
||
1551 | mov esi, aMemBreak6 |
||
1552 | test byte [edi+5], 8 |
||
1553 | jnz @f |
||
1554 | mov esi, aMemBreak5 |
||
1555 | test byte [edi+5], 4 |
||
1556 | jnz @f |
||
1557 | mov esi, aMemBreak4 |
||
1558 | |||
1559 | @@: |
||
1560 | call put_message_nodraw |
||
1561 | pop edi |
||
1562 | push edi |
||
1563 | push dword [edi] |
||
1564 | mov esi, aMemBreak7 |
||
1565 | call put_message_nodraw |
||
1566 | |||
1567 | .cmn: |
||
1568 | pop edi |
||
1569 | test byte [edi+4], 2 |
||
1570 | jz @f |
||
1571 | push edi |
||
1572 | mov esi, aDisabled |
||
1573 | call put_message_nodraw |
||
1574 | pop edi |
||
1575 | |||
1576 | @@: |
||
1577 | test byte [edi+4], 4 |
||
1578 | jz @f |
||
1579 | mov esi, aOneShot |
||
1580 | call put_message_nodraw |
||
1581 | |||
1582 | @@: |
||
1583 | mov esi, newline |
||
1584 | jmp put_message |
||
1585 | |||
1586 | ;----------------------------------------------------------------------------- |
||
1587 | ; Add breakpoint |
||
1588 | ; in: EAX = address; BL = flags |
||
1589 | ; out: CF = 1 => error |
||
1590 | ; CF = 0 and EAX = breakpoint number |
||
1591 | |||
205 | heavyiron | 1592 | add_breakpoint: |
3675 | GerdtR | 1593 | xor ecx, ecx |
1594 | mov edi, breakpoints |
||
205 | heavyiron | 1595 | |
3675 | GerdtR | 1596 | @@: |
1597 | test byte [edi+4], 1 |
||
1598 | jz .found |
||
1599 | add edi, 6 |
||
1600 | inc ecx |
||
1601 | cmp ecx, breakpoints_n |
||
1602 | jb @b |
||
1603 | stc |
||
1604 | ret |
||
1605 | |||
1606 | .found: |
||
1607 | stosd |
||
1608 | xchg eax, ecx |
||
1609 | mov [edi], bl |
||
1610 | test bl, 2 |
||
1611 | jnz @f |
||
1612 | or byte [edi], 2 |
||
1613 | push eax |
||
1614 | call enable_breakpoint |
||
1615 | pop eax |
||
1616 | |||
1617 | @@: |
||
1618 | clc |
||
1619 | ret |
||
1620 | |||
1621 | ;----------------------------------------------------------------------------- |
||
1622 | ; Remove breakpoint |
||
1623 | |||
205 | heavyiron | 1624 | clear_breakpoint: |
3675 | GerdtR | 1625 | cmp eax, breakpoints_n |
1626 | jae .ret |
||
1627 | mov ecx, 4 |
||
1628 | inc eax |
||
205 | heavyiron | 1629 | |
3675 | GerdtR | 1630 | .1: |
1631 | cmp [drx_break-4+ecx*4], eax |
||
1632 | jnz @f |
||
1633 | and [drx_break-4+ecx*4], 0 |
||
1634 | |||
1635 | @@: |
||
1636 | loop .1 |
||
1637 | dec eax |
||
1638 | push eax |
||
1639 | add eax, eax |
||
1640 | lea edi, [breakpoints + eax + eax*2 + 4] |
||
1641 | test byte [edi], 1 |
||
1642 | pop eax |
||
1643 | jz .ret |
||
1644 | push edi |
||
1645 | call disable_breakpoint |
||
1646 | pop edi |
||
1647 | mov byte [edi], 0 |
||
1648 | |||
1649 | .ret: |
||
1650 | ret |
||
1651 | |||
1652 | ;----------------------------------------------------------------------------- |
||
1653 | ; Disable breakpoint |
||
1654 | |||
205 | heavyiron | 1655 | disable_breakpoint: |
3675 | GerdtR | 1656 | cmp eax, breakpoints_n |
1657 | jae .ret |
||
1658 | add eax, eax |
||
1659 | lea edi, [breakpoints + eax + eax*2 + 5] |
||
1660 | test byte [edi-1], 1 |
||
1661 | jz .ret |
||
1662 | test byte [edi-1], 2 |
||
1663 | jnz .ret |
||
1664 | or byte [edi-1], 2 |
||
1665 | test byte [edi-1], 8 |
||
1666 | jnz .dr |
||
1667 | push esi |
||
1668 | ;push 7 |
||
1669 | ;pop ebx |
||
1670 | ;push 69 |
||
1671 | ;pop eax |
||
1672 | ;mov ecx, [debuggee_pid] |
||
1673 | ;xor edx, edx |
||
1674 | ;inc edx |
||
1675 | ;mov esi, [edi-5] |
||
1676 | mcall 69, 7, [debuggee_pid], 1, [edi-5] |
||
1677 | pop esi |
||
205 | heavyiron | 1678 | |
3675 | GerdtR | 1679 | .ret: |
1680 | ret |
||
1681 | |||
1682 | .dr: |
||
1683 | mov dl, [edi] |
||
1684 | shr dl, 6 |
||
1685 | mov dh, 80h |
||
1686 | ;push 69 |
||
1687 | ;pop eax |
||
1688 | ;push 9 |
||
1689 | ;pop ebx |
||
1690 | ;mov ecx, [debuggee_pid] |
||
1691 | mcall 69, 9, [debuggee_pid] |
||
1692 | ret |
||
1693 | |||
1694 | ;----------------------------------------------------------------------------- |
||
1695 | ; Enable breakpoint |
||
1696 | |||
205 | heavyiron | 1697 | enable_breakpoint: |
3675 | GerdtR | 1698 | push esi |
1699 | cmp eax, breakpoints_n |
||
1700 | jae .ret |
||
1701 | add eax, eax |
||
1702 | lea edi, [breakpoints + eax + eax*2 + 5] |
||
1703 | test byte [edi-1], 1 |
||
1704 | jz .ret |
||
1705 | test byte [edi-1], 2 |
||
1706 | jz .ret |
||
1707 | and byte [edi-1], not 2 |
||
1708 | test byte [edi-1], 8 |
||
1709 | jnz .dr |
||
1710 | ;push 6 |
||
1711 | ;pop ebx |
||
1712 | ;push 69 |
||
1713 | ;pop eax |
||
1714 | ;mov esi, [edi-5] |
||
1715 | ;mov ecx, [debuggee_pid] |
||
1716 | ;xor edx, edx |
||
1717 | ;inc edx |
||
1718 | mcall 69, 6, [debuggee_pid], 1, [edi-5] |
||
1719 | dec eax |
||
1720 | jnz .err |
||
1721 | ;mov al, 69 |
||
1722 | push 0xCC |
||
1723 | mov edi, esp |
||
1724 | inc ebx |
||
1725 | mcall 69 |
||
1726 | pop eax |
||
205 | heavyiron | 1727 | |
3675 | GerdtR | 1728 | .ret: |
1729 | pop esi |
||
1730 | ret |
||
205 | heavyiron | 1731 | |
3675 | GerdtR | 1732 | .err: |
1733 | or byte [edi-1], 2 |
||
1734 | mov esi, aBreakErr |
||
1735 | call put_message |
||
1736 | pop esi |
||
1737 | ret |
||
205 | heavyiron | 1738 | |
3675 | GerdtR | 1739 | .dr: |
1740 | ;push 9 |
||
1741 | ;pop ebx |
||
1742 | ;push 69 |
||
1743 | ;pop eax |
||
1744 | mov esi, [edi-5] |
||
1745 | ;mov ecx, [debuggee_pid] |
||
1746 | mov dl, [edi] |
||
1747 | shr dl, 6 |
||
1748 | mov dh, [edi] |
||
1749 | and dh, 0xF |
||
1750 | mcall 69, 9, [debuggee_pid] |
||
1751 | test eax, eax |
||
1752 | jnz .err |
||
1753 | pop esi |
||
1754 | ret |
||
205 | heavyiron | 1755 | |
3675 | GerdtR | 1756 | ;----------------------------------------------------------------------------- |
1757 | ; Find breakpoint |
||
542 | diamond | 1758 | |
3675 | GerdtR | 1759 | find_breakpoint: |
1760 | xor ecx, ecx |
||
1761 | xchg eax, ecx |
||
1762 | mov edi, breakpoints |
||
542 | diamond | 1763 | |
3675 | GerdtR | 1764 | @@: |
1765 | test byte [edi+4], 1 |
||
1766 | jz .cont |
||
1767 | test byte [edi+4], 8 |
||
1768 | jnz .cont |
||
1769 | cmp [edi], ecx |
||
1770 | jz .found |
||
542 | diamond | 1771 | |
3675 | GerdtR | 1772 | .cont: |
1773 | add edi, 6 |
||
1774 | inc eax |
||
1775 | cmp eax, breakpoints_n |
||
1776 | jb @b |
||
1777 | or eax, -1 |
||
542 | diamond | 1778 | |
3675 | GerdtR | 1779 | .found: |
1780 | ret |
||
542 | diamond | 1781 | |
3675 | GerdtR | 1782 | ;----------------------------------------------------------------------------- |
1783 | ; |
||
542 | diamond | 1784 | |
3675 | GerdtR | 1785 | find_enabled_breakpoint: |
1786 | xor ecx, ecx |
||
1787 | xchg eax, ecx |
||
1788 | mov edi, breakpoints |
||
542 | diamond | 1789 | |
3675 | GerdtR | 1790 | @@: |
1791 | test byte [edi+4], 1 |
||
1792 | jz .cont |
||
1793 | test byte [edi+4], 2 or 8 |
||
1794 | jnz .cont |
||
1795 | cmp [edi], ecx |
||
1796 | jz .found |
||
542 | diamond | 1797 | |
3675 | GerdtR | 1798 | .cont: |
1799 | add edi, 6 |
||
1800 | inc eax |
||
1801 | cmp eax, breakpoints_n |
||
1802 | jb @b |
||
1803 | or eax, -1 |
||
205 | heavyiron | 1804 | |
3675 | GerdtR | 1805 | .found: |
1806 | ret |
||
205 | heavyiron | 1807 | |
3675 | GerdtR | 1808 | ; TODO: add find_disabled_breakpoint |
205 | heavyiron | 1809 | |
3675 | GerdtR | 1810 | ;----------------------------------------------------------------------------- |
1811 | ; Unpack executable event |
||
205 | heavyiron | 1812 | |
3675 | GerdtR | 1813 | OnUnpack: |
1814 | ; program must be loaded - checked when command was parsed |
||
1815 | ; program must be stopped |
||
1816 | mov esi, aRunningErr |
||
1817 | cmp [bSuspended], 0 |
||
1818 | jz put_message |
||
1819 | ; all breakpoints must be disabled |
||
1820 | mov edi, breakpoints |
||
205 | heavyiron | 1821 | |
3675 | GerdtR | 1822 | @@: |
1823 | test byte [edi+4], 1 |
||
1824 | jz .cont |
||
1825 | test byte [edi+4], 2 |
||
1826 | jnz .cont |
||
1827 | mov esi, aEnabledBreakErr |
||
1828 | jmp put_message |
||
205 | heavyiron | 1829 | |
3675 | GerdtR | 1830 | .cont: |
1831 | add edi, 6 |
||
1832 | cmp edi, breakpoints+breakpoints_n*6 |
||
1833 | jb @b |
||
1834 | ; ok, now do it |
||
1835 | ; set breakpoint on 0xC dword access |
||
1836 | push 9 |
||
1837 | pop ebx |
||
1838 | mov ecx, [debuggee_pid] |
||
1839 | mov dx, 1111b*256 |
||
1840 | push 0xC |
||
1841 | pop esi |
||
205 | heavyiron | 1842 | |
3675 | GerdtR | 1843 | @@: |
1844 | ;push 69 |
||
1845 | ;pop eax |
||
1846 | mcall 69 |
||
1847 | test eax, eax |
||
1848 | jz .breakok |
||
1849 | inc edx |
||
1850 | cmp dl, 4 |
||
1851 | jb @b |
||
809 | diamond | 1852 | |
3675 | GerdtR | 1853 | .breakok: |
1854 | call GoOn |
||
809 | diamond | 1855 | |
3675 | GerdtR | 1856 | ; now wait for event |
1857 | .wait: |
||
1858 | ;push 10 |
||
1859 | ;pop eax |
||
1860 | mcall 10 |
||
1861 | dec eax |
||
1862 | jz .redraw |
||
1863 | dec eax |
||
1864 | jz .key |
||
1865 | dec eax |
||
1866 | jnz .debug |
||
1867 | ; button; we have only one button, close |
||
1868 | or eax, -1 |
||
1869 | mcall |
||
205 | heavyiron | 1870 | |
3675 | GerdtR | 1871 | .redraw: |
1872 | call draw_window |
||
1873 | jmp .wait |
||
205 | heavyiron | 1874 | |
3675 | GerdtR | 1875 | .key: |
1876 | mov al, 2 |
||
1877 | mcall |
||
1878 | cmp ah, 3 ; Ctrl+C |
||
1879 | jnz .wait |
||
205 | heavyiron | 1880 | |
3675 | GerdtR | 1881 | .userbreak: |
1882 | mov esi, aInterrupted |
||
205 | heavyiron | 1883 | |
3675 | GerdtR | 1884 | .x1: |
1885 | push edx esi |
||
1886 | call put_message |
||
1887 | pop esi edx |
||
1888 | or dh, 80h |
||
1889 | ;push 69 |
||
1890 | ;pop eax |
||
1891 | ;push 9 |
||
1892 | ;pop ebx |
||
1893 | ;mov ecx, [debuggee_pid] |
||
1894 | mcall 69, 9, [debuggee_pid] |
||
1895 | cmp esi, aUnpacked |
||
1896 | jnz OnSuspend |
||
1897 | jmp AfterSuspend |
||
205 | heavyiron | 1898 | |
3675 | GerdtR | 1899 | .debug: |
1900 | cmp [dbgbuflen], 4*3 |
||
1901 | jnz .notour |
||
1902 | cmp dword [dbgbuf], 3 |
||
1903 | jnz .notour |
||
1904 | test byte [dbgbuf+8], 1 |
||
1905 | jnz .our |
||
205 | heavyiron | 1906 | |
3675 | GerdtR | 1907 | .notour: |
1908 | mov esi, aInterrupted |
||
1909 | push edx |
||
1910 | call put_message |
||
1911 | pop edx |
||
1912 | or dh, 80h |
||
1913 | ;push 69 |
||
1914 | ;pop eax |
||
1915 | ;push 9 |
||
1916 | ;pop ebx |
||
1917 | ;mov ecx, [debuggee_pid] |
||
1918 | mcall 69, 9, [debuggee_pid] |
||
1919 | jmp debugmsg |
||
205 | heavyiron | 1920 | |
3675 | GerdtR | 1921 | .our: |
1922 | and [dbgbuflen], 0 |
||
1923 | push edx |
||
1924 | call get_context |
||
1925 | push eax |
||
1926 | ;mov al, 69 |
||
1927 | ;mov bl, 6 |
||
1928 | ;mov ecx, [debuggee_pid] |
||
1929 | ;mov edi, esp |
||
1930 | ;push 4 |
||
1931 | ;pop edx |
||
1932 | ;push 0xC |
||
1933 | ;pop esi |
||
1934 | mcall 69, 6, [debuggee_pid], 4, 0xC, esp |
||
1935 | pop eax |
||
1936 | pop edx |
||
1937 | cmp eax, [_eip] |
||
1938 | jz .done |
||
1939 | call DoResume |
||
1940 | jmp .wait |
||
205 | heavyiron | 1941 | |
3675 | GerdtR | 1942 | .done: |
1943 | mov esi, aUnpacked |
||
1944 | jmp .x1 |
||
809 | diamond | 1945 | |
3675 | GerdtR | 1946 | ;----------------------------------------------------------------------------- |
4886 | hidnplayr | 1947 | ; Include Symbol parser |
205 | heavyiron | 1948 | |
4886 | hidnplayr | 1949 | include 'symbols.inc' |
205 | heavyiron | 1950 | |
3675 | GerdtR | 1951 | ;----------------------------------------------------------------------------- |
1952 | ; Include disassembler engine |
||
1953 | |||
1954 | include 'disasm.inc' |
||
1955 | |||
205 | heavyiron | 1956 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1957 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1958 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1959 | |||
4886 | hidnplayr | 1960 | caption_str db 'Kolibri Debugger',0 |
205 | heavyiron | 1961 | |
4913 | hidnplayr | 1962 | begin_str db 'Kolibri Debugger, version 0.35',10 |
4591 | hidnplayr | 1963 | db 'Hint: type "help" for help, "quit" to quit' |
3675 | GerdtR | 1964 | newline db 10,0 |
1965 | prompt db '> ',0 |
||
1966 | |||
205 | heavyiron | 1967 | help_groups: |
3675 | GerdtR | 1968 | dd aControl, 0, 0, help_control_msg |
1969 | db 0 |
||
1970 | dd aData, 0, 0, help_data_msg |
||
1971 | db 0 |
||
1972 | dd aBreakpoints, 0, 0, help_breaks_msg |
||
1973 | db 0 |
||
1974 | |||
1975 | ;----------------------------------------------------------------------------- |
||
1976 | ; Commands format definitions |
||
1977 | |||
1978 | ; TODO: make it with macros |
||
1979 | |||
205 | heavyiron | 1980 | ; flags field: |
1981 | ; &1: command may be called without parameters |
||
1982 | ; &2: command may be called with parameters |
||
1983 | ; &4: command may be called without loaded program |
||
1984 | ; &8: command may be called with loaded program |
||
1985 | commands: |
||
3675 | GerdtR | 1986 | dd _aH, OnHelp, HelpSyntax, HelpHelp |
1987 | db 0Fh |
||
1988 | dd aHelp, OnHelp, HelpSyntax, HelpHelp |
||
1989 | db 0Fh |
||
1990 | dd aQuit, OnQuit, QuitSyntax, QuitHelp |
||
1991 | db 0Dh |
||
1992 | dd aLoad, OnLoad, LoadSyntax, LoadHelp |
||
1993 | db 6 |
||
1994 | dd aReload, OnReload, ReloadSyntax, ReloadHelp |
||
1995 | db 0Dh |
||
1996 | dd aTerminate, OnTerminate, TerminateSyntax, TerminateHelp |
||
1997 | db 9 |
||
1998 | dd aDetach, OnDetach, DetachSyntax, DetachHelp |
||
1999 | db 9 |
||
2000 | dd aSuspend, OnSuspend, SuspendSyntax, SuspendHelp |
||
2001 | db 9 |
||
2002 | dd aResume, OnResume, ResumeSyntax, ResumeHelp |
||
2003 | db 0Bh |
||
4443 | clevermous | 2004 | dd aStep, OnStepMultiple, StepSyntax, StepHelp |
3675 | GerdtR | 2005 | db 0Bh |
5206 | clevermous | 2006 | dd aProceed, OnProceedMultiple, ProceedSyntax, ProceedHelp |
3675 | GerdtR | 2007 | db 0Bh |
2008 | dd aCalc, OnCalc, CalcSyntax, CalcHelp |
||
2009 | db 0Eh |
||
2010 | dd aDump, OnDump, DumpSyntax, DumpHelp |
||
2011 | db 0Bh |
||
2012 | dd aUnassemble, OnUnassemble, UnassembleSyntax, UnassembleHelp |
||
2013 | db 0Bh |
||
2014 | dd aBp, OnBp, BpSyntax, BpHelp |
||
2015 | db 0Ah |
||
2016 | dd aBpm, OnBpmb, BpmSyntax, BpmHelp |
||
2017 | db 0Ah |
||
2018 | dd aBpmb, OnBpmb, BpmSyntax, BpmHelp |
||
2019 | db 0Ah |
||
2020 | dd aBpmw, OnBpmw, BpmSyntax, BpmHelp |
||
2021 | db 0Ah |
||
2022 | dd aBpmd, OnBpmd, BpmSyntax, BpmHelp |
||
2023 | db 0Ah |
||
2024 | dd aBl, OnBl, BlSyntax, BlHelp |
||
2025 | db 0Bh |
||
2026 | dd aBc, OnBc, BcSyntax, BcHelp |
||
2027 | db 0Ah |
||
2028 | dd aBd, OnBd, BdSyntax, BdHelp |
||
2029 | db 0Ah |
||
2030 | dd aBe, OnBe, BeSyntax, BeHelp |
||
2031 | db 0Ah |
||
2032 | dd aReg, OnReg, RSyntax, RHelp |
||
2033 | db 0Ah |
||
2034 | dd aUnpack, OnUnpack, UnpackSyntax, UnpackHelp |
||
2035 | db 9 |
||
2036 | dd aLoadSymbols, OnLoadSymbols, LoadSymbolsSyntax, LoadSymbolsHelp |
||
2037 | db 0Ah |
||
2038 | dd 0 |
||
205 | heavyiron | 2039 | |
3675 | GerdtR | 2040 | ;----------------------------------------------------------------------------- |
2041 | ; Help messages for commands groups |
||
2042 | |||
2043 | aHelp db 5,'help',0 |
||
2044 | _aH db 2,'h',0 |
||
2045 | HelpHelp db 'Help on specified function',10 |
||
2046 | HelpSyntax db 'Usage: h or help [group | command]',10,0 |
||
2047 | |||
2048 | help_msg db 'List of known command groups:',10 |
||
2049 | db '"help control" - display list of control commands',10 |
||
2050 | db '"help data" - display list of commands concerning data',10 |
||
2051 | db '"help breakpoints" - display list of commands concerning breakpoints',10,0 |
||
2052 | |||
2053 | ; Control commands group |
||
2054 | |||
2055 | aControl db 8,'control',0 |
||
2056 | help_control_msg db 'List of control commands:',10 |
||
2057 | db 'h = help - help',10 |
||
2058 | db 'quit - exit from debugger',10 |
||
2059 | db 'load |
||
2060 | db 'reload - reload debugging program',10 |
||
2061 | db 'load-symbols |
||
2062 | db 'terminate - terminate loaded program',10 |
||
2063 | db 'detach - detach from debugging program',10 |
||
2064 | db 'stop - suspend execution of debugging program',10 |
||
2065 | db 'g [ |
||
4590 | clevermous | 2066 | db 's [ |
2067 | db 'p [ |
||
3675 | GerdtR | 2068 | db 'unpack - try to bypass unpacker code (heuristic)',10,0 |
2069 | |||
2070 | ; Data commands group |
||
2071 | |||
2072 | aData db 5,'data',0 |
||
2073 | help_data_msg db 'List of data commands:',10 |
||
2074 | db '? |
||
2075 | db 'd [ |
||
2076 | db 'u [ |
||
2077 | db 'r |
||
2078 | db 'r |
||
4893 | Serge | 2079 | |
3675 | GerdtR | 2080 | ; Breakpoints commands group |
2081 | |||
205 | heavyiron | 2082 | aBreakpoints db 12,'breakpoints',0 |
3675 | GerdtR | 2083 | help_breaks_msg db 'List of breakpoints commands:',10 |
2084 | db 'bp |
||
2085 | db 'bpm[b|w|d] |
||
2086 | db 'bl [ |
||
2087 | db 'bc |
||
2088 | db 'bd |
||
2089 | db 'be |
||
205 | heavyiron | 2090 | |
3675 | GerdtR | 2091 | ;----------------------------------------------------------------------------- |
2092 | ; Individual command help messages |
||
205 | heavyiron | 2093 | |
3675 | GerdtR | 2094 | aQuit db 5,'quit',0 |
2095 | QuitHelp db 'Quit from debugger',10 |
||
2096 | QuitSyntax db 'Usage: quit',10,0 |
||
205 | heavyiron | 2097 | |
3675 | GerdtR | 2098 | aLoad db 5,'load',0 |
2099 | LoadHelp db 'Load program for debugging',10 |
||
2100 | LoadSyntax db 'Usage: load |
||
205 | heavyiron | 2101 | |
3675 | GerdtR | 2102 | aReload db 7,'reload',0 |
2103 | ReloadHelp db 'Reload debugging program (restart debug session)',10 |
||
2104 | ReloadSyntax db 'Usage: reload',10,0 |
||
2105 | |||
2106 | aTerminate db 10,'terminate',0 |
||
205 | heavyiron | 2107 | TerminateHelp db 'Terminate debugged program',10 |
2108 | TerminateSyntax db 'Usage: terminate',10,0 |
||
2109 | |||
3675 | GerdtR | 2110 | aDetach db 7,'detach',0 |
2111 | DetachHelp db 'Detach from debugged program',10 |
||
2112 | DetachSyntax db 'Usage: detach',10,0 |
||
205 | heavyiron | 2113 | |
3675 | GerdtR | 2114 | aSuspend db 5,'stop',0 |
2115 | SuspendHelp db 'Suspend execution of debugged program',10 |
||
205 | heavyiron | 2116 | SuspendSyntax db 'Usage: stop',10,0 |
2117 | |||
3675 | GerdtR | 2118 | aResume db 2,'g',0 |
2119 | ResumeHelp db 'Go (resume execution of debugged program)',10 |
||
2120 | ResumeSyntax db 'Usage: g',10 |
||
2121 | db ' or: g |
||
205 | heavyiron | 2122 | |
3675 | GerdtR | 2123 | aStep db 2,'s',0 |
2124 | StepHelp db 'Make step in debugged program',10 |
||
2125 | StepSyntax db 'Usage: s [ |
||
205 | heavyiron | 2126 | |
3675 | GerdtR | 2127 | aProceed db 2,'p',0 |
2128 | ProceedHelp db 'Make wide step in debugged program (step over CALL, REPxx, LOOP)',10 |
||
2129 | ProceedSyntax db 'Usage: p [ |
||
205 | heavyiron | 2130 | |
3675 | GerdtR | 2131 | aDump db 2,'d',0 |
2132 | DumpHelp db 'Dump data of debugged program',10 |
||
2133 | DumpSyntax db 'Usage: d |
||
2134 | db ' or: d - continue current dump',10,0 |
||
205 | heavyiron | 2135 | |
3675 | GerdtR | 2136 | aCalc db 2,'?',0 |
2137 | CalcHelp db 'Calculate value of expression',10 |
||
2138 | CalcSyntax db 'Usage: ? |
||
205 | heavyiron | 2139 | |
3675 | GerdtR | 2140 | aUnassemble db 2,'u',0 |
205 | heavyiron | 2141 | UnassembleHelp db 'Unassemble',10 |
3675 | GerdtR | 2142 | UnassembleSyntax db 'Usage: u |
2143 | db ' or: u - continue current unassemble screen',10,0 |
||
205 | heavyiron | 2144 | |
3675 | GerdtR | 2145 | aReg db 2,'r',0 |
2146 | RHelp db 'Set register value',10 |
||
2147 | RSyntax db 'Usage: r |
||
2148 | db ' or: r |
||
205 | heavyiron | 2149 | |
3675 | GerdtR | 2150 | aBp db 3,'bp',0 |
2151 | BpHelp db 'set BreakPoint on execution',10 |
||
2152 | BpSyntax db 'Usage: bp |
||
205 | heavyiron | 2153 | |
3675 | GerdtR | 2154 | aBpm db 4,'bpm',0 |
2155 | aBpmb db 5,'bpmb',0 |
||
2156 | aBpmw db 5,'bpmw',0 |
||
2157 | aBpmd db 5,'bpmd',0 |
||
2158 | BpmHelp db 'set BreakPoint on Memory access',10 |
||
2159 | db 'Maximum 4 breakpoints of this type are allowed',10 |
||
2160 | db 'Note that for this breaks debugger is activated after access',10 |
||
2161 | BpmSyntax db 'Usage: bpmb [w] |
||
2162 | db ' bpmw [w] |
||
2163 | db ' bpmd [w] |
||
2164 | db ' bpm is synonym for bpmd',10 |
||
2165 | db '"w" means break only on writes (default is on read/write)',10,0 |
||
205 | heavyiron | 2166 | |
3675 | GerdtR | 2167 | aBl db 3,'bl',0 |
2168 | BlHelp db 'Breakpoint List',10 |
||
2169 | BlSyntax db 'Usage: bl - list all breakpoints',10 |
||
2170 | db ' bl |
||
205 | heavyiron | 2171 | |
3675 | GerdtR | 2172 | aBc db 3,'bc',0 |
2173 | BcHelp db 'Breakpoint Clear',10 |
||
2174 | BcSyntax db 'Usage: bc |
||
2175 | db 'Examples: bc 2',10 |
||
2176 | db ' bc 1 3 4 A',10,0 |
||
205 | heavyiron | 2177 | |
3675 | GerdtR | 2178 | aBd db 3,'bd',0 |
2179 | BdHelp db 'Breakpoint Disable',10 |
||
2180 | BdSyntax db 'Usage: bd |
||
2181 | db 'Examples: bd 2',10 |
||
2182 | db ' bd 1 3 4 A',10,0 |
||
205 | heavyiron | 2183 | |
3675 | GerdtR | 2184 | aBe db 3,'be',0 |
2185 | BeHelp db 'Breakpoint Enable',10 |
||
2186 | BeSyntax db 'Usage: be |
||
2187 | db 'Examples: be 2',10 |
||
2188 | db ' be 1 3 4 A',10,0 |
||
205 | heavyiron | 2189 | |
3675 | GerdtR | 2190 | aUnpack db 7,'unpack',0 |
2191 | UnpackHelp db 'Try to bypass unpacker code',10 |
||
2192 | UnpackSyntax db 'Usage: unpack',10,0 |
||
205 | heavyiron | 2193 | |
3675 | GerdtR | 2194 | aLoadSymbols db 13,'load-symbols',0 |
542 | diamond | 2195 | LoadSymbolsHelp db 'Load symbolic information for executable',10 |
2196 | LoadSymbolsSyntax db 'Usage: load-symbols |
||
2197 | |||
205 | heavyiron | 2198 | aUnknownCommand db 'Unknown command',10,0 |
2199 | |||
3675 | GerdtR | 2200 | ;----------------------------------------------------------------------------- |
2201 | ; Error messages |
||
2202 | |||
2203 | load_err_msg db 'Cannot load program. ',0 |
||
2204 | unk_err_msg db 'Unknown error code -%4X',10,0 |
||
2205 | aCannotLoadFile db 'Cannot load file. ',0 |
||
2206 | unk_err_msg2 db 'Unknown error code %4X.',10,0 |
||
205 | heavyiron | 2207 | load_err_msgs: |
3675 | GerdtR | 2208 | dd .1, 0, .3, 0, .5, .6, 0, 0, .9, .A, 0, 0, 0, 0, 0, 0 |
2209 | dd 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, .1E, .1F, .20 |
||
2210 | .1 db 'HD undefined.',10,0 |
||
2211 | .3 db 'Unknown FS.',10,0 |
||
2212 | .5 db 'File not found.',10,0 |
||
2213 | .6 db 'Unexpected EOF.',10,0 |
||
2214 | .9 db 'FAT table corrupted.',10,0 |
||
2215 | .A db 'Access denied.',10,0 |
||
2216 | .1E db 'No memory.',10,0 |
||
2217 | .1F db 'Not Menuet/Kolibri executable.',10,0 |
||
2218 | .20 db 'Too many processes.',10,0 |
||
2219 | load_succ_msg db 'Program loaded successfully! PID=%4X. Use "g" to run.',10,0 |
||
2220 | need_debuggee db 'No program loaded. Use "load" command.',10,0 |
||
2221 | aAlreadyLoaded db 'Program is already loaded. Use "terminate" or "detach" commands',10,0 |
||
2222 | terminated_msg db 'Program terminated.',10,0 |
||
2223 | aException db 'Debugged program caused an exception %2X. ' |
||
2224 | aSuspended db 'Suspended',10,0 |
||
2225 | aContinued db 'Continuing',10,0 |
||
2226 | aRunningErr db 'Program is running',10,0 |
||
2227 | read_mem_err db 'ERROR: cannot read process memory!!!',10,0 |
||
205 | heavyiron | 2228 | aBreakpointLimitExceeded db 'Breakpoint limit exceeded',10,0 |
3675 | GerdtR | 2229 | aBreakErr db 'Cannot activate breakpoint, it will be disabled',10,0 |
2230 | aDuplicateBreakpoint db 'Duplicate breakpoint',10,0 |
||
2231 | aInvalidBreak db 'Invalid breakpoint number',10,0 |
||
2232 | OnBeErrMsg db 'There is already enabled breakpoint on this address',10,0 |
||
2233 | aBreakNum db '%2X: at %8X',0 |
||
2234 | aMemBreak1 db '%2X: on ',0 |
||
2235 | aMemBreak2 db 'read from ',0 |
||
2236 | aMemBreak3 db 'access of ',0 |
||
2237 | aMemBreak4 db 'byte',0 |
||
2238 | aMemBreak5 db 'word',0 |
||
2239 | aMemBreak6 db 'dword',0 |
||
2240 | aMemBreak7 db ' at %8X',0 |
||
2241 | aOneShot db ', one-shot',0 |
||
2242 | aDisabled db ', disabled',0 |
||
2243 | aBreakStop db 'Breakpoint #%2X',10,0 |
||
2244 | aUserBreak db 'int3 command at %8X',10,0 |
||
2245 | ;dbgmsg_str db 'Debug message for process %4X.',10,0 |
||
2246 | aInvAddr db 'Invalid address',10,0 |
||
2247 | NoPrgLoaded_str db 'No program loaded' |
||
205 | heavyiron | 2248 | NoPrgLoaded_len = $ - NoPrgLoaded_str |
3675 | GerdtR | 2249 | aRunning db 'Running' |
2250 | aPaused db 'Paused' |
||
4914 | Serge | 2251 | |
2252 | aFPU db '[ FPU ]' |
||
2253 | aMMX db '[ MMX ]' |
||
5460 | hidnplayr | 2254 | aSSE db '[SSE32]' |
2255 | aSSE2 db '[SSE64]' |
||
2256 | aMMX128 db '[MMX128]' |
||
4914 | Serge | 2257 | |
4591 | hidnplayr | 2258 | aAVX db '[ AVX ]' |
2259 | aMSR db '[ MSR ]' |
||
3675 | GerdtR | 2260 | aPoint db 0x1C |
2261 | aMinus db '-' |
||
2262 | aColon db ':' |
||
2263 | aSpace db ' ' |
||
2264 | aQuests db '??' |
||
2265 | aDots db '...' |
||
2266 | aParseError db 'Parse error',10,0 |
||
2267 | aDivByZero db 'Division by 0',10,0 |
||
2268 | calc_string db '%8X',10,0 |
||
2269 | aNoMemory db 'No memory',10,0 |
||
2270 | aSymbolsLoaded db 'Symbols loaded',10,0 |
||
2271 | aUnaligned db 'Unaligned address',10,0 |
||
2272 | aEnabledBreakErr db 'Enabled breakpoints are not allowed',10,0 |
||
2273 | aInterrupted db 'Interrupted',10,0 |
||
2274 | aUnpacked db 'Unpacked successful!',10,0 |
||
2275 | aPacked1 db 'Program is probably packed with ',0 |
||
2276 | aPacked2 db '.',10,'Try to unpack automatically? [y/n]: ',0 |
||
2277 | aY_str db 'y',10,0 |
||
2278 | aN_str db 'n',10,0 |
||
2279 | mxp_nrv_name db 'mxp_nrv',0 |
||
2280 | mxp_name db 'mxp',0 |
||
2281 | mxp_lzo_name db 'mxp_lzo',0 |
||
2282 | mtappack_name db 'mtappack',0 |
||
2283 | flags db 'CPAZSDO' |
||
2284 | flags_bits db 0,2,4,6,7,10,11 |
||
2285 | |||
2286 | ;----------------------------------------------------------------------------- |
||
2287 | ; Registers strings |
||
2288 | |||
205 | heavyiron | 2289 | regs_strs: |
4886 | hidnplayr | 2290 | db 'EAX=' |
2291 | db 'EBX=' |
||
2292 | db 'ECX=' |
||
2293 | db 'EDX=' |
||
2294 | db 'ESI=' |
||
2295 | db 'EDI=' |
||
2296 | db 'EBP=' |
||
2297 | db 'ESP=' |
||
2298 | db 'EIP=' |
||
2299 | db 'EFLAGS=' |
||
2300 | |||
3675 | GerdtR | 2301 | sse_strs: |
4886 | hidnplayr | 2302 | db '-XMM0-' |
2303 | db '-XMM1-' |
||
2304 | db '-XMM2-' |
||
2305 | db '-XMM3-' |
||
2306 | db '-XMM4-' |
||
2307 | db '-XMM5-' |
||
2308 | db '-XMM6-' |
||
2309 | db '-XMM7-' |
||
3675 | GerdtR | 2310 | avx_strs: |
4886 | hidnplayr | 2311 | db '-YMM0-' |
2312 | db '-YMM1-' |
||
2313 | db '-YMM2-' |
||
2314 | db '-YMM3-' |
||
2315 | db '-YMM4-' |
||
2316 | db '-YMM5-' |
||
2317 | db '-YMM6-' |
||
2318 | db '-YMM7-' |
||
205 | heavyiron | 2319 | |
4910 | Serge | 2320 | align 4 |
4912 | Serge | 2321 | n_digits dd 10000000 |
4914 | Serge | 2322 | |
2323 | btn2_tab dd aFPU |
||
2324 | dd aMMX |
||
2325 | btn3_tab dd aSSE2 |
||
2326 | dd aMMX128 |
||
2327 | dd aSSE |
||
2328 | |||
4886 | hidnplayr | 2329 | reg_mode db 1 |
205 | heavyiron | 2330 | |
4909 | Serge | 2331 | |
3675 | GerdtR | 2332 | include 'disasm_tbl.inc' |
205 | heavyiron | 2333 | |
2334 | reg_table: |
||
4886 | hidnplayr | 2335 | db 2,'al',0 |
2336 | db 2,'cl',1 |
||
2337 | db 2,'dl',2 |
||
2338 | db 2,'bl',3 |
||
2339 | db 2,'ah',4 |
||
2340 | db 2,'ch',5 |
||
2341 | db 2,'dh',6 |
||
2342 | db 2,'bh',7 |
||
2343 | db 2,'ax',8 |
||
2344 | db 2,'cx',9 |
||
2345 | db 2,'dx',10 |
||
2346 | db 2,'bx',11 |
||
2347 | db 2,'sp',12 |
||
2348 | db 2,'bp',13 |
||
2349 | db 2,'si',14 |
||
2350 | db 2,'di',15 |
||
2351 | db 3,'eax',16 |
||
2352 | db 3,'ecx',17 |
||
2353 | db 3,'edx',18 |
||
2354 | db 3,'ebx',19 |
||
2355 | db 3,'esp',20 |
||
2356 | db 3,'ebp',21 |
||
2357 | db 3,'esi',22 |
||
2358 | db 3,'edi',23 |
||
2359 | db 3,'eip',24 |
||
2360 | db 0 |
||
205 | heavyiron | 2361 | |
542 | diamond | 2362 | IncludeIGlobals |
2363 | |||
2364 | fn70_read_block: |
||
4886 | hidnplayr | 2365 | dd 0 |
2366 | dq 0 |
||
2367 | dd ? |
||
2368 | dd ? |
||
2369 | db 0 |
||
2370 | dd ? |
||
542 | diamond | 2371 | |
2372 | fn70_attr_block: |
||
4886 | hidnplayr | 2373 | dd 5 |
2374 | dd 0,0,0 |
||
2375 | dd fileattr |
||
2376 | db 0 |
||
2377 | dd ? |
||
542 | diamond | 2378 | |
205 | heavyiron | 2379 | fn70_load_block: |
4886 | hidnplayr | 2380 | dd 7 |
2381 | dd 1 |
||
2382 | load_params dd 0 |
||
2383 | dd 0 |
||
2384 | dd 0 |
||
205 | heavyiron | 2385 | i_end: |
2386 | loadname: |
||
4886 | hidnplayr | 2387 | db 0 |
2388 | rb 255 |
||
205 | heavyiron | 2389 | |
4886 | hidnplayr | 2390 | symbolsfile rb 260 |
542 | diamond | 2391 | |
205 | heavyiron | 2392 | prgname_ptr dd ? |
2393 | prgname_len dd ? |
||
2394 | |||
542 | diamond | 2395 | IncludeUGlobals |
2396 | |||
4914 | Serge | 2397 | align 4 |
2398 | debuggee_pid dd ? |
||
4886 | hidnplayr | 2399 | dbgwnd dd ? |
4914 | Serge | 2400 | temp_break dd ? |
205 | heavyiron | 2401 | |
4914 | Serge | 2402 | |
2403 | fpu_mode db ? |
||
2404 | sse_mode db ? |
||
2405 | bSuspended db ? |
||
2406 | bAfterGo db ? |
||
2407 | |||
2408 | |||
2409 | messages_pos dd ? |
||
4886 | hidnplayr | 2410 | messages rb messages_height*messages_width |
205 | heavyiron | 2411 | |
4886 | hidnplayr | 2412 | cmdline rb cmdline_width+1 |
2413 | cmdline_len dd ? |
||
2414 | cmdline_pos dd ? |
||
2415 | curarg dd ? |
||
205 | heavyiron | 2416 | |
4886 | hidnplayr | 2417 | cmdline_prev rb cmdline_width+1 |
205 | heavyiron | 2418 | |
4886 | hidnplayr | 2419 | was_temp_break db ? |
2420 | symbol_section db ? |
||
205 | heavyiron | 2421 | |
4886 | hidnplayr | 2422 | dbgbufsize dd ? |
2423 | dbgbuflen dd ? |
||
2424 | dbgbuf rb 256 |
||
542 | diamond | 2425 | |
4886 | hidnplayr | 2426 | fileattr rb 40 |
3675 | GerdtR | 2427 | |
4893 | Serge | 2428 | ;keep aligned !!! |
2429 | ;do not change layout !!! |
||
2430 | |||
2431 | align 16 |
||
205 | heavyiron | 2432 | needzerostart: |
2433 | context: |
||
4886 | hidnplayr | 2434 | _eip dd ? |
2435 | _eflags dd ? |
||
2436 | _eax dd ? |
||
2437 | _ecx dd ? |
||
2438 | _edx dd ? |
||
2439 | _ebx dd ? |
||
2440 | _esp dd ? |
||
2441 | _ebp dd ? |
||
2442 | _esi dd ? |
||
2443 | _edi dd ? |
||
205 | heavyiron | 2444 | |
4893 | Serge | 2445 | _ctx_flags: |
4908 | hidnplayr | 2446 | dd ? |
2447 | dd ? |
||
205 | heavyiron | 2448 | |
4893 | Serge | 2449 | _sse_flags: |
4900 | Serge | 2450 | |
2451 | |||
2452 | _fcw dw ? |
||
2453 | _fsw dw ? |
||
2454 | _ftw db ? |
||
2455 | db ? |
||
2456 | _fop dw ? |
||
2457 | _fpu_ip dd ? |
||
2458 | dw ? |
||
2459 | dw ? |
||
2460 | |||
4908 | hidnplayr | 2461 | dq ? |
2462 | dq ? |
||
4893 | Serge | 2463 | |
3675 | GerdtR | 2464 | fpu_context: |
4893 | Serge | 2465 | mmx_context: |
2466 | _st0: |
||
2467 | _mm0: rq 2 |
||
2468 | _st1: |
||
2469 | _mm1: rq 2 |
||
2470 | _st2: |
||
2471 | _mm2: rq 2 |
||
2472 | _st3: |
||
2473 | _mm3: rq 2 |
||
2474 | _st4: |
||
2475 | _mm4: rq 2 |
||
2476 | _st5: |
||
2477 | _mm5: rq 2 |
||
2478 | _st6: |
||
2479 | _mm6: rq 2 |
||
2480 | _st7: |
||
2481 | _mm7: rq 2 |
||
3675 | GerdtR | 2482 | |
2483 | sse_context: |
||
4893 | Serge | 2484 | _xmm0 rq 2 |
2485 | _xmm1 rq 2 |
||
2486 | _xmm2 rq 2 |
||
2487 | _xmm3 rq 2 |
||
2488 | _xmm4 rq 2 |
||
2489 | _xmm5 rq 2 |
||
2490 | _xmm6 rq 2 |
||
2491 | _xmm7 rq 2 |
||
2492 | ctx_end: |
||
3675 | GerdtR | 2493 | |
4893 | Serge | 2494 | oldcontext rb _ctx_flags-context |
4901 | Serge | 2495 | rb 32 |
4893 | Serge | 2496 | |
2497 | oldfpucontext: |
||
2498 | oldmmxcontext: rb sse_context-fpu_context |
||
2499 | oldssecontext: rb ctx_end-sse_context |
||
2500 | |||
2501 | if 0 |
||
3675 | GerdtR | 2502 | avx_context: |
4886 | hidnplayr | 2503 | _ymm0 dq 4 dup ? |
2504 | _ymm1 dq 4 dup ? |
||
2505 | _ymm2 dq 4 dup ? |
||
2506 | _ymm3 dq 4 dup ? |
||
2507 | _ymm4 dq 4 dup ? |
||
2508 | _ymm5 dq 4 dup ? |
||
2509 | _ymm6 dq 4 dup ? |
||
2510 | _ymm7 dq 4 dup ? |
||
3675 | GerdtR | 2511 | oldavxcontext rb $-avx_context |
4893 | Serge | 2512 | end if |
3675 | GerdtR | 2513 | |
4893 | Serge | 2514 | |
4906 | Serge | 2515 | step_num dd ? |
2516 | proc_num dd ? |
||
4886 | hidnplayr | 2517 | dumpread dd ? |
2518 | dumppos dd ? |
||
2519 | dumpdata rb dump_height*10h |
||
3675 | GerdtR | 2520 | |
205 | heavyiron | 2521 | ; breakpoint structure: |
2522 | ; dword +0: address |
||
2523 | ; byte +4: flags |
||
2524 | ; bit 0: 1 <=> breakpoint valid |
||
2525 | ; bit 1: 1 <=> breakpoint disabled |
||
2526 | ; bit 2: 1 <=> one-shot breakpoint |
||
2527 | ; bit 3: 1 <=> DRx breakpoint |
||
2528 | ; byte +5: overwritten byte |
||
2529 | ; for DRx breaks: flags + (index shl 6) |
||
2530 | breakpoints_n = 256 |
||
4886 | hidnplayr | 2531 | breakpoints rb breakpoints_n*6 |
2532 | drx_break rd 4 |
||
205 | heavyiron | 2533 | |
4886 | hidnplayr | 2534 | disasm_buf_size dd ? |
205 | heavyiron | 2535 | |
4886 | hidnplayr | 2536 | symbols dd ? |
2537 | num_symbols dd ? |
||
542 | diamond | 2538 | |
4886 | hidnplayr | 2539 | bReload db ? |
205 | heavyiron | 2540 | |
2541 | needzeroend: |
||
2542 | |||
4886 | hidnplayr | 2543 | disasm_buffer rb 256 |
2544 | disasm_start_pos dd ? |
||
2545 | disasm_cur_pos dd ? |
||
2546 | disasm_cur_str dd ? |
||
2547 | disasm_string rb 256 |
||
205 | heavyiron | 2548 | |
4913 | hidnplayr | 2549 | thread_info process_information |
4908 | hidnplayr | 2550 | |
4913 | hidnplayr | 2551 | ;----------------------------------------------------------------------------- |
2552 | ; Coordinates and sizes for GUI |
||
2553 | |||
2554 | data_x_size_dd dd ?, ? |
||
2555 | messages_x_size_dd dd ?, ? |
||
2556 | registers_x_pos_dd dd ?, ? |
||
2557 | |||
2558 | disasm_height_dd dd ? |
||
2559 | disasm_y_size_dd dd ?, ? |
||
2560 | messages_y_pos_dd dd ?, ? |
||
2561 | cmdline_y_pos_dd dd ?, ? |
||
2562 | registers_y_size_dd dd ?, ? |
||
2563 | |||
4886 | hidnplayr | 2564 | i_param rb 256 |
205 | heavyiron | 2565 | |
2566 | ; stack |
||
3675 | GerdtR | 2567 | align 400h |
2568 | rb 400h |
||
205 | heavyiron | 2569 | used_mem: |
3675 | GerdtR | 2570 | |
2571 | ; vim: ft=fasm tabstop=4=>=>=>=> |
||
2572 |