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