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