Rev 113 | Rev 379 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 113 | Rev 115 | ||
---|---|---|---|
Line 19... | Line 19... | ||
19 | debug_set_event_data: |
19 | debug_set_event_data: |
20 | ; in: ebx = pointer |
20 | ; in: ebx = pointer |
21 | ; destroys eax |
21 | ; destroys eax |
22 | mov eax, [0x3000] |
22 | mov eax, [0x3000] |
23 | shl eax, 8 |
23 | shl eax, 8 |
24 | mov [eax+0x80000+0xBC], ebx |
24 | mov [eax+0x80000+APPDATA.dbg_event_mem], ebx |
25 | ret |
25 | ret |
Line 26... | Line 26... | ||
26 | 26 | ||
27 | get_debuggee_slot: |
27 | get_debuggee_slot: |
28 | ; in: ebx=PID |
28 | ; in: ebx=PID |
Line 35... | Line 35... | ||
35 | test eax, eax |
35 | test eax, eax |
36 | jz .ret_bad |
36 | jz .ret_bad |
37 | shl eax, 5 |
37 | shl eax, 5 |
38 | push ebx |
38 | push ebx |
39 | mov ebx, [0x3000] |
39 | mov ebx, [0x3000] |
40 | cmp [0x80000+eax*8+0xAC], ebx |
40 | cmp [0x80000+eax*8+APPDATA.debugger_slot], ebx |
41 | pop ebx |
41 | pop ebx |
42 | jnz .ret_bad |
42 | jnz .ret_bad |
43 | ; clc ; automatically |
43 | ; clc ; automatically |
44 | ret |
44 | ret |
45 | .ret_bad: |
45 | .ret_bad: |
Line 49... | Line 49... | ||
49 | debug_detach: |
49 | debug_detach: |
50 | ; in: ebx=pid |
50 | ; in: ebx=pid |
51 | ; destroys eax,ebx |
51 | ; destroys eax,ebx |
52 | call get_debuggee_slot |
52 | call get_debuggee_slot |
53 | jc .ret |
53 | jc .ret |
54 | and dword [eax*8+0x80000+0xAC], 0 |
54 | and dword [eax*8+0x80000+APPDATA.debugger_slot], 0 |
55 | call do_resume |
55 | call do_resume |
56 | .ret: |
56 | .ret: |
57 | sti |
57 | sti |
58 | ret |
58 | ret |
Line 70... | Line 70... | ||
70 | debug_suspend: |
70 | debug_suspend: |
71 | ; in: ebx=pid |
71 | ; in: ebx=pid |
72 | ; destroys eax,ebx |
72 | ; destroys eax,ebx |
73 | call get_debuggee_slot |
73 | call get_debuggee_slot |
74 | jc .ret |
74 | jc .ret |
75 | mov bl, [0x3000+eax+0xA] ; process state |
75 | mov bl, [0x3000+eax+TASKDATA.state] ; process state |
76 | test bl, bl |
76 | test bl, bl |
77 | jz .1 |
77 | jz .1 |
78 | cmp bl, 5 |
78 | cmp bl, 5 |
79 | jnz .ret |
79 | jnz .ret |
80 | mov bl, 2 |
80 | mov bl, 2 |
81 | .2: mov [0x3000+eax+0xA], bl |
81 | .2: mov [0x3000+eax+TASKDATA.state], bl |
82 | .ret: |
82 | .ret: |
83 | sti |
83 | sti |
84 | ret |
84 | ret |
85 | .1: |
85 | .1: |
86 | inc ebx |
86 | inc ebx |
87 | jmp .2 |
87 | jmp .2 |
Line 88... | Line 88... | ||
88 | 88 | ||
89 | do_resume: |
89 | do_resume: |
90 | mov bl, [0x3000+eax+0xA] |
90 | mov bl, [0x3000+eax+TASKDATA.state] |
91 | cmp bl, 1 |
91 | cmp bl, 1 |
92 | jz .1 |
92 | jz .1 |
93 | cmp bl, 2 |
93 | cmp bl, 2 |
94 | jnz .ret |
94 | jnz .ret |
95 | mov bl, 5 |
95 | mov bl, 5 |
96 | .2: mov [0x3000+eax+0xA], bl |
96 | .2: mov [0x3000+eax+TASKDATA.state], bl |
97 | .ret: ret |
97 | .ret: ret |
98 | .1: dec ebx |
98 | .1: dec ebx |
Line 99... | Line 99... | ||
99 | jmp .2 |
99 | jmp .2 |
Line 225... | Line 225... | ||
225 | 225 | ||
226 | debug_set_drx: |
226 | debug_set_drx: |
227 | call get_debuggee_slot |
227 | call get_debuggee_slot |
228 | jc .errret |
228 | jc .errret |
229 | mov ebp, eax |
229 | mov ebp, eax |
230 | lea eax, [eax*8+0x80000+0xC0] |
230 | lea eax, [eax*8+0x80000+APPDATA.dbg_regs] |
231 | ; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3 |
231 | ; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3 |
232 | ; [eax+10]=dr7 |
232 | ; [eax+10]=dr7 |
233 | add edx, std_application_base_address |
233 | add edx, std_application_base_address |
234 | jc .errret |
234 | jc .errret |
Line 356... | Line 356... | ||
356 | mov edi, [timer_ticks] |
356 | mov edi, [timer_ticks] |
357 | add edi, 500 ; 5 sec timeout |
357 | add edi, 500 ; 5 sec timeout |
358 | .1: |
358 | .1: |
359 | mov eax, ebp |
359 | mov eax, ebp |
360 | shl eax, 8 |
360 | shl eax, 8 |
361 | mov edx, [0x80000+eax+0xBC] |
361 | mov edx, [0x80000+eax+APPDATA.dbg_event_mem] |
362 | test edx, edx |
362 | test edx, edx |
363 | jz .ret |
363 | jz .ret |
364 | ; read buffer header |
364 | ; read buffer header |
365 | push ecx |
365 | push ecx |
366 | push eax |
366 | push eax |
Line 412... | Line 412... | ||
412 | pop ecx |
412 | pop ecx |
413 | call write_process_memory |
413 | call write_process_memory |
414 | ; new debug event |
414 | ; new debug event |
415 | mov eax, ebp |
415 | mov eax, ebp |
416 | shl eax, 8 |
416 | shl eax, 8 |
417 | or byte [0x80000+eax+0xA8+1], 1 ; set flag 100h |
417 | or byte [0x80000+eax+APPDATA.event_mask+1], 1 ; set flag 100h |
418 | .ret: |
418 | .ret: |
419 | ret |
419 | ret |
Line 420... | Line 420... | ||
420 | 420 | ||
421 | debug_exc: |
421 | debug_exc: |
Line 430... | Line 430... | ||
430 | jns @f |
430 | jns @f |
431 | ; this is exception from task switch |
431 | ; this is exception from task switch |
432 | ; set DRx registers for task and continue |
432 | ; set DRx registers for task and continue |
433 | mov eax, [0x3000] |
433 | mov eax, [0x3000] |
434 | shl eax, 8 |
434 | shl eax, 8 |
435 | add eax, 0x80000+0xC0 |
435 | add eax, 0x80000+APPDATA.dbg_regs |
436 | mov ecx, [eax+0] |
436 | mov ecx, [eax+0] |
437 | mov dr0, ecx |
437 | mov dr0, ecx |
438 | mov ecx, [eax+4] |
438 | mov ecx, [eax+4] |
439 | mov dr1, ecx |
439 | mov dr1, ecx |
440 | mov ecx, [eax+8] |
440 | mov ecx, [eax+8] |
Line 453... | Line 453... | ||
453 | mov dr6, eax |
453 | mov dr6, eax |
454 | ; test if debugging |
454 | ; test if debugging |
455 | cli |
455 | cli |
456 | mov eax, [0x3000] |
456 | mov eax, [0x3000] |
457 | shl eax, 8 |
457 | shl eax, 8 |
458 | mov eax, [0x80000+eax+0xAC] |
458 | mov eax, [0x80000+eax+APPDATA.debugger_slot] |
459 | test eax, eax |
459 | test eax, eax |
460 | jnz .debug |
460 | jnz .debug |
461 | sti |
461 | sti |
462 | ; not debuggee => say error and terminate |
462 | ; not debuggee => say error and terminate |
463 | add esp, 28h+4 |
463 | add esp, 28h+4 |
464 | mov [error_interrupt], 1 |
464 | mov [error_interrupt], 1 |
465 | call show_error_parameters |
465 | call show_error_parameters |
466 | mov edx, [0x3010] |
466 | mov edx, [0x3010] |
467 | mov byte [edx+0xA], 4 |
467 | mov byte [edx+TASKDATA.state], 4 |
468 | jmp change_task |
468 | jmp change_task |
469 | .debug: |
469 | .debug: |
470 | ; we are debugged process, notify debugger and suspend ourself |
470 | ; we are debugged process, notify debugger and suspend ourself |
471 | ; eax=debugger PID |
471 | ; eax=debugger PID |
472 | pop edx |
472 | pop edx |
Line 482... | Line 482... | ||
482 | inc ecx |
482 | inc ecx |
483 | cmp cl, not 10h |
483 | cmp cl, not 10h |
484 | jnz .l1 |
484 | jnz .l1 |
485 | push edx ; DR6 image |
485 | push edx ; DR6 image |
486 | mov ecx, [0x3010] |
486 | mov ecx, [0x3010] |
487 | push dword [ecx+4] ; PID |
487 | push dword [ecx+TASKDATA.pid] ; PID |
488 | push 12 |
488 | push 12 |
489 | pop ecx |
489 | pop ecx |
490 | push 3 ; 3 = debug exception |
490 | push 3 ; 3 = debug exception |
491 | call debugger_notify |
491 | call debugger_notify |
492 | pop ecx |
492 | pop ecx |
493 | pop ecx |
493 | pop ecx |
494 | pop ecx |
494 | pop ecx |
495 | mov edx, [0x3010] |
495 | mov edx, [0x3010] |
496 | mov byte [edx+0xA], 1 ; suspended |
496 | mov byte [edx+TASKDATA.state], 1 ; suspended |
497 | call change_task |
497 | call change_task |
498 | restore_ring3_context |
498 | restore_ring3_context |
499 | iretd |
499 | iretd |