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