Rev 4895 | Rev 4901 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4895 | Rev 4900 | ||
---|---|---|---|
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 ebx |
697 | push edx |
697 | push edx |
698 | push ecx |
698 | push ecx |
699 | push esi |
699 | push esi |
- | 700 | ||
- | 701 | sub esp, 8 |
|
- | 702 | ||
- | 703 | fld tword [esi] |
|
- | 704 | fistp qword [esp] |
|
- | 705 | ||
700 | mov eax, esi |
706 | mov eax, esi |
701 | mov esi, ecx |
707 | mov esi, ecx |
702 | 708 | ||
703 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
709 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
704 | cmp [debuggee_pid], 0 |
710 | cmp [debuggee_pid], 0 |
705 | jz .cd |
711 | jz .cd |
706 | cmp [bSuspended], 0 |
712 | cmp [bSuspended], 0 |
707 | jz .cd |
713 | jz .cd |
708 | 714 | ||
709 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
715 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
710 | push edi |
716 | push edi |
711 | mov edi, [eax] |
717 | mov edi, [eax] |
712 | cmp dword [eax+oldcontext-context], edi |
718 | cmp dword [eax+oldcontext-context], edi |
713 | pop edi |
719 | pop edi |
714 | jnz .scol |
720 | jnz .scol |
715 | push edi |
721 | push edi |
716 | mov edi, [eax+4] |
722 | mov edi, [eax+4] |
717 | cmp dword [eax+oldcontext-context+4], edi |
723 | cmp dword [eax+oldcontext-context+4], edi |
718 | pop edi |
724 | pop edi |
719 | jz .cd |
725 | jz .cd |
720 | 726 | ||
721 | .scol: |
727 | .scol: |
722 | mov ecx, (COLOR_TXT_CHANGED or 0x40000000) |
728 | mov ecx, (COLOR_TXT_CHANGED or 0x40000000) |
723 | 729 | ||
724 | .cd: |
730 | .cd: |
725 | ; draw a text string in the window |
731 | ; draw a text string in the window |
726 | mcall 4 |
732 | mcall 4 |
727 | imul esi, 60000h |
733 | imul esi, 60000h |
728 | lea edx, [ebx+esi] |
734 | lea edx, [ebx+esi] |
729 | mov esi, ecx |
735 | mov esi, ecx |
- | 736 | ||
730 | pop ecx |
737 | mov ecx, esp |
- | 738 | ||
731 | ; draw a number in the window |
739 | ; draw a number in the window |
732 | ; color is the same as for previous text draw function |
740 | ; color is the same as for previous text draw function |
733 | ; ebx : [20] show 16 chars set [30] bit - qword |
741 | ; ebx : [20] show 16 chars set [30] bit - qword |
734 | mcall 47, 40100101h |
742 | mcall 47, 40100101h |
- | 743 | add esp, 8 |
|
- | 744 | pop ecx |
|
735 | lea ebx, [edx+60000h*18] |
745 | lea ebx, [edx+60000h*18] |
736 | mov esi, ecx |
746 | mov esi, ecx |
737 | pop ecx |
747 | pop ecx |
738 | pop edx |
748 | pop edx |
739 | pop ebx |
749 | pop ebx |
740 | add edx, ecx |
750 | add edx, ecx |
741 | ret |
751 | ret |
742 | 752 | ||
743 | ;----------------------------------------------------------------------------- |
753 | ;----------------------------------------------------------------------------- |
- | 754 | ; Display FPU register (ST0 - ST7) content |
|
- | 755 | ; |
|
- | 756 | ; in: esi->value, ebx = coord |
|
- | 757 | draw_fpu_register_2: |
|
- | 758 | ||
- | 759 | .str_buf equ esp |
|
- | 760 | .bcd_man equ esp+32 |
|
- | 761 | .bcd_exp equ esp+32+12 |
|
- | 762 | ||
- | 763 | sub esp, 32+12+12 |
|
- | 764 | ||
- | 765 | mov edx, ebp |
|
- | 766 | shl edx, 4 |
|
- | 767 | ||
- | 768 | fld tword [_st0+edx] |
|
- | 769 | fldlg2 |
|
- | 770 | fld tword [_st0+edx] |
|
- | 771 | bt dword [_st0+edx+8], 15 |
|
- | 772 | jnc @f |
|
- | 773 | fabs |
|
- | 774 | @@: |
|
- | 775 | fyl2x |
|
- | 776 | frndint |
|
- | 777 | fld st0 |
|
- | 778 | fbstp tword [.bcd_exp] |
|
- | 779 | fldl2t |
|
- | 780 | fmulp |
|
- | 781 | fld st0 |
|
- | 782 | frndint |
|
- | 783 | fxch |
|
- | 784 | fsub st,st1 |
|
- | 785 | ||
- | 786 | f2xm1 |
|
- | 787 | fld1 |
|
- | 788 | faddp |
|
- | 789 | fscale |
|
- | 790 | fstp st1 |
|
- | 791 | fdivp |
|
- | 792 | fimul dword [_10000000] |
|
- | 793 | fbstp tword [.bcd_man] |
|
- | 794 | ||
- | 795 | mov eax, 0x20202020 |
|
- | 796 | mov edi, .str_buf |
|
- | 797 | stosd |
|
- | 798 | stosd |
|
- | 799 | stosd |
|
- | 800 | stosd |
|
- | 801 | ||
- | 802 | lea esi, [.bcd_man-1] |
|
- | 803 | mov edi, .str_buf |
|
- | 804 | ||
- | 805 | mov ecx, 9 |
|
- | 806 | mov eax, 0x10000 |
|
- | 807 | ||
- | 808 | mov al, [esi+ecx+1] |
|
- | 809 | cmp al, 0x80 ; check for sign |
|
- | 810 | jne .mantis_2_str |
|
- | 811 | mov al, '-' |
|
- | 812 | stosb |
|
- | 813 | ||
- | 814 | .mantis_2_str: |
|
- | 815 | ||
- | 816 | mov al, [esi+ecx] |
|
- | 817 | test al, al |
|
- | 818 | jnz @f |
|
- | 819 | ||
- | 820 | bt eax, 16 |
|
- | 821 | jc .skip_lb |
|
- | 822 | @@: |
|
- | 823 | mov ah, al |
|
- | 824 | shr al, 4 |
|
- | 825 | jnz .write_h |
|
- | 826 | ||
- | 827 | bt eax, 16 |
|
- | 828 | jc .skip_hb |
|
- | 829 | ||
- | 830 | .write_h: |
|
- | 831 | add al, 0x30 |
|
- | 832 | stosb |
|
- | 833 | btr eax, 16 |
|
- | 834 | jnc .skip_hb |
|
- | 835 | mov al, '.' |
|
- | 836 | stosb |
|
- | 837 | .skip_hb: |
|
- | 838 | mov al, ah |
|
- | 839 | and al, 0x0F |
|
- | 840 | jnz .write_lb |
|
- | 841 | ||
- | 842 | bt eax, 16 |
|
- | 843 | jc .skip_lb |
|
- | 844 | .write_lb: |
|
- | 845 | add al,0x30 |
|
- | 846 | stosb |
|
- | 847 | btr eax, 16 |
|
- | 848 | jnc .skip_lb |
|
- | 849 | mov al, '.' |
|
- | 850 | stosb |
|
- | 851 | .skip_lb: |
|
- | 852 | dec ecx |
|
- | 853 | jnz .mantis_2_str |
|
- | 854 | ||
- | 855 | mov ax, ' e' |
|
- | 856 | stosw |
|
- | 857 | ||
- | 858 | lea esi, [.bcd_exp-1] |
|
- | 859 | mov ecx, 9 |
|
- | 860 | mov eax,0x10000 |
|
- | 861 | mov al, [esi+ecx+1] |
|
- | 862 | cmp al, 0x80 |
|
- | 863 | jne .exp_2_str |
|
- | 864 | mov al, '-' |
|
- | 865 | stosb |
|
- | 866 | .exp_2_str: |
|
- | 867 | mov al, [esi+ecx] |
|
- | 868 | test al, al |
|
- | 869 | jnz @f |
|
- | 870 | ||
- | 871 | bt eax, 16 |
|
- | 872 | jc .skip_lb2 |
|
- | 873 | @@: |
|
- | 874 | mov ah, al |
|
- | 875 | shr al, 4 |
|
- | 876 | jnz .write_h2 |
|
- | 877 | ||
- | 878 | bt eax, 16 |
|
- | 879 | jc .skip_hb2 |
|
- | 880 | .write_h2: |
|
- | 881 | add al, 0x30 |
|
- | 882 | stosb |
|
- | 883 | btr eax, 16 |
|
- | 884 | stosb |
|
- | 885 | .skip_hb2: |
|
- | 886 | mov al, ah |
|
- | 887 | and al, 0x0F |
|
- | 888 | jnz .write_lb2 |
|
- | 889 | ||
- | 890 | bt eax, 16 |
|
- | 891 | jc .skip_lb2 |
|
- | 892 | .write_lb2: |
|
- | 893 | add al, 0x30 |
|
- | 894 | stosb |
|
- | 895 | btr eax, 16 |
|
- | 896 | .skip_lb2: |
|
- | 897 | dec ecx |
|
- | 898 | jnz .exp_2_str |
|
- | 899 | ||
- | 900 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
|
- | 901 | cmp [debuggee_pid], 0 |
|
- | 902 | jz .do_label |
|
- | 903 | cmp [bSuspended], 0 |
|
- | 904 | jz .do_label |
|
- | 905 | ||
- | 906 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
|
- | 907 | ||
- | 908 | mov eax, dword [_st0+edx] |
|
- | 909 | cmp eax, dword [_st0+(oldcontext-context)+edx] |
|
- | 910 | jne .scol |
|
- | 911 | ||
- | 912 | mov eax, dword [_st0+edx+4] |
|
- | 913 | cmp eax, dword [_st0+(oldcontext-context)+4] |
|
- | 914 | jne .scol |
|
- | 915 | ||
- | 916 | mov ax, word [_st0+edx+8] |
|
- | 917 | cmp ax, word [_st0+(oldcontext-context)+8] |
|
- | 918 | je .do_label |
|
- | 919 | ||
- | 920 | .scol: |
|
- | 921 | mov ecx, (COLOR_TXT_CHANGED or 0x40000000) |
|
- | 922 | ||
- | 923 | .do_label: |
|
- | 924 | ; draw a text string in the window |
|
- | 925 | ||
- | 926 | mov eax, 4 |
|
- | 927 | mov esi, eax |
|
- | 928 | lea edx, [fpu_strs+ebp*4] |
|
- | 929 | mov edi, COLOR_BG_NORMAL |
|
- | 930 | int 0x40 |
|
- | 931 | ||
- | 932 | mov esi, 16 |
|
- | 933 | mov edx, .str_buf |
|
- | 934 | add ebx, 0x180000 |
|
- | 935 | int 0x40 |
|
- | 936 | ||
- | 937 | sub ebx, 0x180000 |
|
- | 938 | add esp, 32+12+12 |
|
- | 939 | ||
- | 940 | ret |
|
- | 941 | ||
- | 942 | ||
- | 943 | ;----------------------------------------------------------------------------- |
|
744 | ; Show FPU MMX register content |
944 | ; Show FPU MMX register content |
745 | ; |
945 | ; |
746 | ; in: esi->value, edx->string, ecx = string length, ebx = coord |
946 | ; in: esi->value, edx->string, ecx = string length, ebx = coord |
747 | draw_mmx_register: |
947 | draw_mmx_register: |
748 | push ebx |
948 | push ebx |
749 | push edx |
949 | push edx |
750 | push ecx |
950 | push ecx |
751 | push esi |
951 | push esi |
752 | mov eax, esi |
952 | mov eax, esi |
753 | mov esi, ecx |
953 | mov esi, ecx |
754 | 954 | ||
755 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
955 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
756 | cmp [debuggee_pid], 0 |
956 | cmp [debuggee_pid], 0 |
757 | jz .cd |
957 | jz .cd |
758 | cmp [bSuspended], 0 |
958 | cmp [bSuspended], 0 |
759 | jz .cd |
959 | jz .cd |
760 | 960 | ||
761 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
961 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
762 | push edi |
962 | push edi |
763 | mov edi, [eax] |
963 | mov edi, [eax] |
764 | cmp dword [eax+oldcontext-context], edi |
964 | cmp dword [eax+oldcontext-context], edi |
765 | pop edi |
965 | pop edi |
766 | jnz .scol |
966 | jnz .scol |
767 | push edi |
967 | push edi |
768 | mov edi, [eax+4] |
968 | mov edi, [eax+4] |
769 | cmp dword [eax+oldcontext-context+4], edi |
969 | cmp dword [eax+oldcontext-context+4], edi |
770 | pop edi |
970 | pop edi |
771 | jz .cd |
971 | jz .cd |
772 | 972 | ||
773 | .scol: |
973 | .scol: |
774 | mov ecx, (COLOR_TXT_CHANGED or 0x40000000) |
974 | mov ecx, (COLOR_TXT_CHANGED or 0x40000000) |
775 | 975 | ||
776 | .cd: |
976 | .cd: |
777 | ; draw a text string in the window |
977 | ; draw a text string in the window |
778 | mcall 4 |
978 | mcall 4 |
779 | 979 | ||
780 | imul esi, 60000h |
980 | imul esi, 60000h |
781 | lea edx, [ebx+esi] |
981 | lea edx, [ebx+esi] |
782 | mov esi, ecx |
982 | mov esi, ecx |
783 | pop ecx |
983 | pop ecx |
784 | ; draw a number in the window |
984 | ; draw a number in the window |
785 | ; color is the same as for previous draw text function |
985 | ; color is the same as for previous draw text function |
786 | ; ebx : [20] show 16 chars set [30] bit - qword |
986 | ; ebx : [20] show 16 chars set [30] bit - qword |
787 | mcall 47, 40100101h |
987 | mcall 47, 40100101h |
788 | lea ebx, [edx+60000h*18] |
988 | lea ebx, [edx+60000h*18] |
789 | mov esi, ecx |
989 | mov esi, ecx |
790 | pop ecx |
990 | pop ecx |
791 | pop edx |
991 | pop edx |
792 | pop ebx |
992 | pop ebx |
793 | add edx, ecx |
993 | add edx, ecx |
794 | ret |
994 | ret |
795 | 995 | ||
796 | ; TODO add SSE registers |
996 | ; TODO add SSE registers |
797 | ; TODO add AVX registers |
997 | ; TODO add AVX registers |
798 | 998 | ||
799 | ;----------------------------------------------------------------------------- |
999 | ;----------------------------------------------------------------------------- |
800 | ; Display contents of EFLAGS register |
1000 | ; Display contents of EFLAGS register |
801 | draw_flag: |
1001 | draw_flag: |
802 | movzx edi, byte [edx+7] |
1002 | movzx edi, byte [edx+7] |
803 | bt [_eflags], edi |
1003 | bt [_eflags], edi |
804 | jc .on |
1004 | jc .on |
805 | or byte [edx], 20h |
1005 | or byte [edx], 20h |
806 | jmp .onoff |
1006 | jmp .onoff |
807 | 1007 | ||
808 | .on: |
1008 | .on: |
809 | and byte [edx], not 20h |
1009 | and byte [edx], not 20h |
810 | 1010 | ||
811 | .onoff: |
1011 | .onoff: |
812 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
1012 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
813 | cmp [debuggee_pid], 0 |
1013 | cmp [debuggee_pid], 0 |
814 | jz .doit |
1014 | jz .doit |
815 | cmp [bSuspended], 0 |
1015 | cmp [bSuspended], 0 |
816 | jz .doit |
1016 | jz .doit |
817 | 1017 | ||
818 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
1018 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
819 | bt [_eflags], edi |
1019 | bt [_eflags], edi |
820 | lahf |
1020 | lahf |
821 | bt dword [_eflags + oldcontext - context], edi |
1021 | bt dword [_eflags + oldcontext - context], edi |
822 | rcl ah, 1 |
1022 | rcl ah, 1 |
823 | test ah, 3 |
1023 | test ah, 3 |
824 | jp .doit |
1024 | jp .doit |
825 | mov ecx, (COLOR_TXT_CHANGED or 0x40000000) |
1025 | mov ecx, (COLOR_TXT_CHANGED or 0x40000000) |
826 | 1026 | ||
827 | .doit: |
1027 | .doit: |
828 | mov ah, 0 |
1028 | mov ah, 0 |
829 | mov edi, COLOR_BG_NORMAL |
1029 | mov edi, COLOR_BG_NORMAL |
830 | ; draw a text string in the window in one case |
1030 | ; draw a text string in the window in one case |
831 | ; and a number in another |
1031 | ; and a number in another |
832 | ; color scheme same as for previously called function (was in ecx) |
1032 | ; color scheme same as for previously called function (was in ecx) |
833 | mcall |
1033 | mcall |
834 | ret |
1034 | ret |
835 | 1035 | ||
836 | ;----------------------------------------------------------------------------- |
1036 | ;----------------------------------------------------------------------------- |
837 | ; Draw registers frame title |
1037 | ; Draw registers frame title |
838 | 1038 | ||
839 | ; Also show current register set (common + MMX, SSE or AVX) |
1039 | ; Also show current register set (common + MMX, SSE or AVX) |
840 | draw_reg_title: |
1040 | draw_reg_title: |
841 | mov edi, COLOR_BG_NORMAL |
1041 | mov edi, COLOR_BG_NORMAL |
842 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
1042 | mov ecx, (COLOR_TXT_NORMAL or 0x40000000) |
843 | mov esi, 7 |
1043 | mov esi, 7 |
844 | cmp [reg_mode], REG_MODE_CPU |
1044 | cmp [reg_mode], REG_MODE_CPU |
845 | jz @f |
1045 | jz @f |
846 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
1046 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
847 | @@: |
1047 | @@: |
848 | mov edx, aMain |
1048 | mov edx, aMain |
849 | ; draw a text string in the window |
1049 | ; draw a text string in the window |
850 | mcall 4, (registers_x_pos+4)*10000h+registers_y_pos+2 |
1050 | mcall 4, (registers_x_pos+4)*10000h+registers_y_pos+2 |
851 | 1051 | ||
852 | cmp [reg_mode], REG_MODE_SSE |
1052 | cmp [reg_mode], REG_MODE_SSE |
853 | jz @f |
1053 | jz @f |
854 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
1054 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
855 | @@: |
1055 | @@: |
856 | mov edx, aSSE |
1056 | mov edx, aSSE |
857 | ; draw a text string in the window |
1057 | ; draw a text string in the window |
858 | mcall 4, (registers_x_pos+46)*10000h+registers_y_pos+2 |
1058 | mcall 4, (registers_x_pos+46)*10000h+registers_y_pos+2 |
859 | 1059 | ||
860 | cmp [reg_mode], REG_MODE_AVX |
1060 | cmp [reg_mode], REG_MODE_AVX |
861 | jz @f |
1061 | jz @f |
862 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
1062 | mov ecx, (COLOR_TXT_INACTIVE or 0x40000000) |
863 | @@: |
1063 | @@: |
864 | mov edx, aAVX |
1064 | mov edx, aAVX |
865 | ; draw a text string in the window |
1065 | ; draw a text string in the window |
866 | mcall 4, (registers_x_pos+88)*10000h+registers_y_pos+2 |
1066 | mcall 4, (registers_x_pos+88)*10000h+registers_y_pos+2 |
867 | ret |
1067 | ret |
868 | 1068 | ||
869 | ;----------------------------------------------------------------------------- |
1069 | ;----------------------------------------------------------------------------- |
870 | ; Display common registers set + MMX + FPU |
1070 | ; Display common registers set + MMX + FPU |
871 | 1071 | ||
872 | draw_main_registers: |
1072 | draw_main_registers: |
873 | ; TODO: add support for FPU ST0-ST7 registers |
1073 | ; TODO: add support for FPU ST0-ST7 registers |
874 | mov edi, COLOR_BG_NORMAL |
1074 | mov edi, COLOR_BG_NORMAL |
875 | mov esi, _eax |
1075 | mov esi, _eax |
876 | push 4 |
1076 | push 4 |
877 | pop ecx |
1077 | pop ecx |
878 | mov edx, regs_strs |
1078 | mov edx, regs_strs |
879 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+22 |
1079 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+22 |
880 | call draw_register |
1080 | call draw_register |
881 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+32 |
1081 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+32 |
882 | add esi, _ebx-_eax |
1082 | add esi, _ebx-_eax |
883 | call draw_register |
1083 | call draw_register |
884 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+42 |
1084 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+42 |
885 | add esi, _ecx-_ebx |
1085 | add esi, _ecx-_ebx |
886 | call draw_register |
1086 | call draw_register |
887 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+52 |
1087 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+52 |
888 | add esi, _edx-_ecx |
1088 | add esi, _edx-_ecx |
889 | call draw_register |
1089 | call draw_register |
890 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+62 |
1090 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+62 |
891 | add esi, _esi-_edx |
1091 | add esi, _esi-_edx |
892 | call draw_register |
1092 | call draw_register |
893 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+72 |
1093 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+72 |
894 | add esi, _edi-_esi |
1094 | add esi, _edi-_esi |
895 | call draw_register |
1095 | call draw_register |
896 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+82 |
1096 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+82 |
897 | add esi, _ebp-_edi |
1097 | add esi, _ebp-_edi |
898 | call draw_register |
1098 | call draw_register |
899 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+92 |
1099 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+92 |
900 | add esi, _esp-_ebp |
1100 | add esi, _esp-_ebp |
901 | call draw_register |
1101 | call draw_register |
902 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+102 |
1102 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+102 |
903 | add esi, _eip-_esp |
1103 | add esi, _eip-_esp |
904 | call draw_register |
1104 | call draw_register |
905 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+112 |
1105 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+112 |
906 | 1106 | ||
907 | mov cl, 7 |
1107 | mov cl, 7 |
908 | add esi, _eflags-_eip |
1108 | add esi, _eflags-_eip |
909 | call draw_register |
1109 | call draw_register |
910 | mov cl, 4 |
1110 | mov cl, 4 |
911 | 1111 | ||
912 | ; MMX registers |
1112 | ; MMX registers |
- | 1113 | ||
- | 1114 | push ebp |
|
913 | 1115 | ||
914 | push 8 |
1116 | push 8 |
915 | mov edx, mmx_strs |
1117 | mov edx, mmx_strs |
916 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+142 |
1118 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+142 |
917 | mov esi, _mm0 |
1119 | mov esi, _mm0 |
918 | 1120 | ||
919 | align 4 |
1121 | align 4 |
920 | .draw_mmx_regs: |
1122 | .draw_mmx_regs: |
921 | 1123 | ||
922 | call draw_mmx_register |
1124 | call draw_mmx_register |
923 | add ebx, 10 |
1125 | add ebx, 10 |
924 | add esi, 16 |
1126 | add esi, 16 |
925 | dec dword [esp] |
1127 | dec dword [esp] |
926 | jnz .draw_mmx_regs |
1128 | jnz .draw_mmx_regs |
927 | 1129 | ||
928 | ;FPU registers |
1130 | ;FPU registers |
- | 1131 | ||
- | 1132 | ;int3 |
|
- | 1133 | nop |
|
929 | 1134 | ||
930 | mov [esp], byte 8 |
1135 | mov [esp], byte 8 |
931 | mov edx, fpu_strs |
1136 | xor ebp, ebp |
932 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+232 |
- | |
933 | mov esi, _st0 |
1137 | mov ebx, (registers_x_pos+2)*10000h+registers_y_pos+232 |
934 | 1138 | ||
935 | align 4 |
1139 | align 4 |
936 | .draw_fpu_regs: |
1140 | .draw_fpu_regs: |
937 | 1141 | ||
938 | call draw_fpu_register |
1142 | call draw_fpu_register_2 |
939 | add ebx, 10 |
1143 | add ebx, 10 |
940 | add esi, 16 |
1144 | inc ebp |
941 | dec dword [esp] |
1145 | dec dword [esp] |
942 | jnz .draw_fpu_regs |
1146 | jnz .draw_fpu_regs |
943 | pop eax ;restore stack |
1147 | pop eax ;restore stack |
- | 1148 | pop ebp |
|
944 | 1149 | ||
945 | mov ecx, COLOR_TXT_INACTIVE |
1150 | mov ecx, COLOR_TXT_INACTIVE |
946 | cmp [debuggee_pid], 0 |
1151 | cmp [debuggee_pid], 0 |
947 | jz @f |
1152 | jz @f |
948 | cmp [bSuspended], 0 |
1153 | cmp [bSuspended], 0 |
949 | jz @f |
1154 | jz @f |
950 | mov ecx, COLOR_TXT_NORMAL |
1155 | mov ecx, COLOR_TXT_NORMAL |
951 | @@: |
1156 | @@: |
952 | mov edx, aColon |
1157 | mov edx, aColon |
953 | xor esi, esi |
1158 | xor esi, esi |
954 | inc esi |
1159 | inc esi |
955 | mcall 4, (registers_x_pos+10)*10000h+registers_y_pos+122 |
1160 | mcall 4, (registers_x_pos+10)*10000h+registers_y_pos+122 |
956 | mov edx, flags |
1161 | mov edx, flags |
957 | 1162 | ||
958 | @@: |
1163 | @@: |
959 | add ebx, 2*6*10000h |
1164 | add ebx, 2*6*10000h |
960 | call draw_flag |
1165 | call draw_flag |
961 | inc edx |
1166 | inc edx |
962 | cmp dl, flags_bits and 0xFF |
1167 | cmp dl, flags_bits and 0xFF |
963 | jnz @b |
1168 | jnz @b |
964 | ret |
1169 | ret |
965 | 1170 | ||
966 | ;----------------------------------------------------------------------------- |
1171 | ;----------------------------------------------------------------------------- |
967 | ; Draw SSE registers set |
1172 | ; Draw SSE registers set |
968 | 1173 | ||
969 | draw_sse_registers: |
1174 | draw_sse_registers: |
970 | 1175 | ||
971 | ret |
1176 | ret |
972 | 1177 | ||
973 | ;----------------------------------------------------------------------------- |
1178 | ;----------------------------------------------------------------------------- |
974 | ; Draw AVX registers set |
1179 | ; Draw AVX registers set |
975 | 1180 | ||
976 | draw_avx_registers: |
1181 | draw_avx_registers: |
977 | 1182 | ||
978 | ret |
1183 | ret |
979 | 1184 | ||
980 | ;----------------------------------------------------------------------------- |
1185 | ;----------------------------------------------------------------------------- |
981 | ; Draw all registers sets |
1186 | ; Draw all registers sets |
982 | draw_registers: |
1187 | draw_registers: |
983 | 1188 | ||
984 | ; draw container rectangle/box with COLOR_BG_NORMAL |
1189 | ; draw container rectangle/box with 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 |
1190 | mcall 13, (registers_x_pos-1)*10000h+(registers_x_size+2), (registers_y_pos-1)*10000h+(registers_y_size+2), COLOR_BG_NORMAL |
986 | call draw_reg_title |
1191 | call draw_reg_title |
987 | 1192 | ||
988 | .redraw: |
1193 | .redraw: |
989 | cmp [reg_mode], REG_MODE_CPU |
1194 | cmp [reg_mode], REG_MODE_CPU |
990 | jnz @f |
1195 | jnz @f |
991 | call draw_main_registers |
1196 | call draw_main_registers |
992 | ret |
1197 | ret |
993 | 1198 | ||
994 | @@: |
1199 | @@: |
995 | cmp [reg_mode], REG_MODE_SSE |
1200 | cmp [reg_mode], REG_MODE_SSE |
996 | jnz @f |
1201 | jnz @f |
997 | call draw_sse_registers |
1202 | call draw_sse_registers |
998 | ret |
1203 | ret |
999 | 1204 | ||
1000 | @@: |
1205 | @@: |
1001 | call draw_avx_registers |
1206 | call draw_avx_registers |
1002 | ret |
1207 | ret |
1003 | 1208 | ||
1004 | ;----------------------------------------------------------------------------- |
1209 | ;----------------------------------------------------------------------------- |
1005 | ; Display memory dump |
1210 | ; Display memory dump |
1006 | 1211 | ||
1007 | draw_dump: |
1212 | draw_dump: |
1008 | ; draw container rectangle/box in the window |
1213 | ; draw container rectangle/box in the window |
1009 | mcall 13, data_x_pos*10000h+data_x_size, dump_y_pos*10000h+dump_y_size, COLOR_BG_NORMAL |
1214 | mcall 13, data_x_pos*10000h+data_x_size, dump_y_pos*10000h+dump_y_size, COLOR_BG_NORMAL |
1010 | 1215 | ||
1011 | .redraw: |
1216 | .redraw: |
1012 | ; addresses |
1217 | ; addresses |
1013 | mov ebx, 80100h |
1218 | mov ebx, 80100h |
1014 | mov edx, data_x_pos*10000h + dump_y_pos |
1219 | mov edx, data_x_pos*10000h + dump_y_pos |
1015 | mov ecx, [dumppos] |
1220 | mov ecx, [dumppos] |
1016 | mov edi, COLOR_BG_NORMAL |
1221 | mov edi, COLOR_BG_NORMAL |
1017 | mov esi, (COLOR_TXT_INACTIVE or 0x40000000) |
1222 | mov esi, (COLOR_TXT_INACTIVE or 0x40000000) |
1018 | cmp [debuggee_pid], 0 |
1223 | cmp [debuggee_pid], 0 |
1019 | jz @f |
1224 | jz @f |
1020 | cmp [bSuspended], 0 |
1225 | cmp [bSuspended], 0 |
1021 | jz @f |
1226 | jz @f |
1022 | mov esi, (COLOR_TXT_NORMAL or 0x40000000) |
1227 | mov esi, (COLOR_TXT_NORMAL or 0x40000000) |
1023 | @@: |
1228 | @@: |
1024 | ; draw a number in the window |
1229 | ; draw a number in the window |
1025 | mcall 47 |
1230 | mcall 47 |
1026 | add ecx, 10h |
1231 | add ecx, 10h |
1027 | add edx, 10 |
1232 | add edx, 10 |
1028 | cmp dl, dump_y_pos + dump_y_size |
1233 | cmp dl, dump_y_pos + dump_y_size |
1029 | jb @b |
1234 | jb @b |
1030 | ; hex dump of data |
1235 | ; hex dump of data |
1031 | mov ecx, dumpdata |
1236 | mov ecx, dumpdata |
1032 | push ecx |
1237 | push ecx |
1033 | xor ebx, ebx |
1238 | xor ebx, ebx |
1034 | mov edx, (data_x_pos+12*6)*10000h + dump_y_pos |
1239 | mov edx, (data_x_pos+12*6)*10000h + dump_y_pos |
1035 | cmp [dumpread], ebx |
1240 | cmp [dumpread], ebx |
1036 | jz .hexdumpdone1 |
1241 | jz .hexdumpdone1 |
1037 | 1242 | ||
1038 | .hexdumploop1: |
1243 | .hexdumploop1: |
1039 | push ebx |
1244 | push ebx |
1040 | mov ebx, 20101h |
1245 | mov ebx, 20101h |
1041 | ; draw a number in the window |
1246 | ; draw a number in the window |
1042 | mcall |
1247 | mcall |
1043 | pop ebx |
1248 | pop ebx |
1044 | add edx, 3*6*10000h |
1249 | add edx, 3*6*10000h |
1045 | inc ecx |
1250 | inc ecx |
1046 | inc ebx |
1251 | inc ebx |
1047 | test bl, 15 |
1252 | test bl, 15 |
1048 | jz .16 |
1253 | jz .16 |
1049 | test bl, 7 |
1254 | test bl, 7 |
1050 | jnz @f |
1255 | jnz @f |
1051 | add edx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h |
1256 | add edx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h |
1052 | 1257 | ||
1053 | .16: |
1258 | .16: |
1054 | add edx, 10 - 6*(3*10h+2)*10000h |
1259 | add edx, 10 - 6*(3*10h+2)*10000h |
1055 | 1260 | ||
1056 | @@: |
1261 | @@: |
1057 | cmp ebx, [dumpread] |
1262 | cmp ebx, [dumpread] |
1058 | jb .hexdumploop1 |
1263 | jb .hexdumploop1 |
1059 | 1264 | ||
1060 | .hexdumpdone1: |
1265 | .hexdumpdone1: |
1061 | mov al, 4 |
1266 | mov al, 4 |
1062 | ; copy color value from esi to ecx |
1267 | ; copy color value from esi to ecx |
1063 | ; to draw text string with 'mcall 4' |
1268 | ; to draw text string with 'mcall 4' |
1064 | mov ecx, esi |
1269 | mov ecx, esi |
1065 | xchg ebx, edx |
1270 | xchg ebx, edx |
1066 | push 2 |
1271 | push 2 |
1067 | pop esi |
1272 | pop esi |
1068 | 1273 | ||
1069 | .hexdumploop2: |
1274 | .hexdumploop2: |
1070 | cmp edx, dump_height*10h |
1275 | cmp edx, dump_height*10h |
1071 | jae .hexdumpdone2 |
1276 | jae .hexdumpdone2 |
1072 | push edx |
1277 | push edx |
1073 | mov edx, aQuests |
1278 | mov edx, aQuests |
1074 | ; draw text string with color in ecx, copied from esi |
1279 | ; draw text string with color in ecx, copied from esi |
1075 | mcall |
1280 | mcall |
1076 | pop edx |
1281 | pop edx |
1077 | add ebx, 3*6*10000h |
1282 | add ebx, 3*6*10000h |
1078 | inc edx |
1283 | inc edx |
1079 | test dl, 15 |
1284 | test dl, 15 |
1080 | jz .16x |
1285 | jz .16x |
1081 | test dl, 7 |
1286 | test dl, 7 |
1082 | jnz .hexdumploop2 |
1287 | jnz .hexdumploop2 |
1083 | add ebx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h |
1288 | add ebx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h |
1084 | 1289 | ||
1085 | .16x: |
1290 | .16x: |
1086 | add ebx, 10 - 6*(3*10h+2)*10000h |
1291 | add ebx, 10 - 6*(3*10h+2)*10000h |
1087 | jmp .hexdumploop2 |
1292 | jmp .hexdumploop2 |
1088 | 1293 | ||
1089 | .hexdumpdone2: |
1294 | .hexdumpdone2: |
1090 | dec esi |
1295 | dec esi |
1091 | ; colon, minus signs |
1296 | ; colon, minus signs |
1092 | mov ebx, (data_x_pos+8*6)*10000h + dump_y_pos |
1297 | mov ebx, (data_x_pos+8*6)*10000h + dump_y_pos |
1093 | mov edx, aColon |
1298 | mov edx, aColon |
1094 | 1299 | ||
1095 | @@: |
1300 | @@: |
1096 | mcall |
1301 | mcall |
1097 | add ebx, 10 |
1302 | add ebx, 10 |
1098 | cmp bl, dump_y_pos+dump_height*10 |
1303 | cmp bl, dump_y_pos+dump_height*10 |
1099 | jb @b |
1304 | jb @b |
1100 | mov ebx, (data_x_pos+(12+3*8)*6)*10000h + dump_y_pos |
1305 | mov ebx, (data_x_pos+(12+3*8)*6)*10000h + dump_y_pos |
1101 | mov edx, aMinus |
1306 | mov edx, aMinus |
1102 | 1307 | ||
1103 | @@: |
1308 | @@: |
1104 | mcall |
1309 | mcall |
1105 | add ebx, 10 |
1310 | add ebx, 10 |
1106 | cmp bl, dump_y_pos+dump_height*10 |
1311 | cmp bl, dump_y_pos+dump_height*10 |
1107 | jb @b |
1312 | jb @b |
1108 | ; ASCII data |
1313 | ; ASCII data |
1109 | mov ebx, (data_x_pos+(12+3*10h+2+2)*6)*10000h + dump_y_pos |
1314 | mov ebx, (data_x_pos+(12+3*10h+2+2)*6)*10000h + dump_y_pos |
1110 | pop edx |
1315 | pop edx |
1111 | push dump_height*10h |
1316 | push dump_height*10h |
1112 | 1317 | ||
1113 | .asciiloop: |
1318 | .asciiloop: |
1114 | push edx |
1319 | push edx |
1115 | cmp byte [edx], 20h |
1320 | cmp byte [edx], 20h |
1116 | jae @f |
1321 | jae @f |
1117 | mov edx, aPoint |
1322 | mov edx, aPoint |
1118 | 1323 | ||
1119 | @@: |
1324 | @@: |
1120 | ; draw a text string in the window, color in ecx |
1325 | ; draw a text string in the window, color in ecx |
1121 | mcall |
1326 | mcall |
1122 | pop edx |
1327 | pop edx |
1123 | inc edx |
1328 | inc edx |
1124 | add ebx, 6*10000h |
1329 | add ebx, 6*10000h |
1125 | dec dword [esp] |
1330 | dec dword [esp] |
1126 | jz .asciidone |
1331 | jz .asciidone |
1127 | test byte [esp], 15 |
1332 | test byte [esp], 15 |
1128 | jnz .asciiloop |
1333 | jnz .asciiloop |
1129 | add ebx, 10 - 6*10h*10000h |
1334 | add ebx, 10 - 6*10h*10000h |
1130 | jmp .asciiloop |
1335 | jmp .asciiloop |
1131 | 1336 | ||
1132 | .asciidone: |
1337 | .asciidone: |
1133 | pop ecx |
1338 | pop ecx |
1134 | ret |
1339 | ret |
1135 | 1340 | ||
1136 | ;----------------------------------------------------------------------------- |
1341 | ;----------------------------------------------------------------------------- |
1137 | ; Display disassembled code |
1342 | ; Display disassembled code |
1138 | 1343 | ||
1139 | draw_disasm: |
1344 | draw_disasm: |
1140 | 1345 | ||
1141 | mov eax, [disasm_start_pos] |
1346 | mov eax, [disasm_start_pos] |
1142 | mov [disasm_cur_pos], eax |
1347 | mov [disasm_cur_pos], eax |
1143 | and [disasm_cur_str], 0 |
1348 | and [disasm_cur_str], 0 |
1144 | 1349 | ||
1145 | .loop: |
1350 | .loop: |
1146 | mov eax, [disasm_cur_pos] |
1351 | mov eax, [disasm_cur_pos] |
1147 | call find_symbol |
1352 | call find_symbol |
1148 | jc .nosymb |
1353 | jc .nosymb |
1149 | mov ebx, [disasm_cur_str] |
1354 | mov ebx, [disasm_cur_str] |
1150 | imul ebx, 10 |
1355 | imul ebx, 10 |
1151 | push ebx |
1356 | push ebx |
1152 | lea ecx, [ebx+disasm_y_pos-1] |
1357 | lea ecx, [ebx+disasm_y_pos-1] |
1153 | shl ecx, 16 |
1358 | shl ecx, 16 |
1154 | mov cl, 11 |
1359 | mov cl, 11 |
1155 | ; setting up background color for disassembled text |
1360 | ; setting up background color for disassembled text |
1156 | mov edx, COLOR_BG_NORMAL |
1361 | mov edx, COLOR_BG_NORMAL |
1157 | ; draw container rectangle/box with color COLOR_BG_NORMAL (was 0xFFFFFF - white) |
1362 | ; draw container rectangle/box with color COLOR_BG_NORMAL (was 0xFFFFFF - white) |
1158 | mcall 13, data_x_pos*10000h+data_x_size |
1363 | mcall 13, data_x_pos*10000h+data_x_size |
1159 | pop ebx |
1364 | pop ebx |
1160 | ; copy color value from edx (COLOR_BG_NORMAL) |
1365 | ; copy color value from edx (COLOR_BG_NORMAL) |
1161 | mov edi, edx |
1366 | mov edi, edx |
1162 | add ebx, (data_x_pos+6*2)*10000h+disasm_y_pos |
1367 | add ebx, (data_x_pos+6*2)*10000h+disasm_y_pos |
1163 | mov edx, esi |
1368 | mov edx, esi |
1164 | 1369 | ||
1165 | @@: |
1370 | @@: |
1166 | lodsb |
1371 | lodsb |
1167 | test al, al |
1372 | test al, al |
1168 | jnz @b |
1373 | jnz @b |
1169 | mov byte [esi-1], ':' |
1374 | mov byte [esi-1], ':' |
1170 | sub esi, edx |
1375 | sub esi, edx |
1171 | ; normal color |
1376 | ; normal color |
1172 | ; was 0x40000000 |
1377 | ; was 0x40000000 |
1173 | mov ecx, (COLOR_TXT_LABEL or 0x40000000) |
1378 | mov ecx, (COLOR_TXT_LABEL or 0x40000000) |
1174 | mov al, 4 |
1379 | mov al, 4 |
1175 | ; draw a text string in the window with color COLOR_TXT_NORMAL in ecx |
1380 | ; draw a text string in the window with color COLOR_TXT_NORMAL in ecx |
1176 | mcall |
1381 | mcall |
1177 | mov byte [esi+edx-1], 0 |
1382 | mov byte [esi+edx-1], 0 |
1178 | lea esi, [esi*3] |
1383 | lea esi, [esi*3] |
1179 | movzx ecx, bx |
1384 | movzx ecx, bx |
1180 | shr ebx, 16 |
1385 | shr ebx, 16 |
1181 | lea ebx, [ebx+esi*2] |
1386 | lea ebx, [ebx+esi*2] |
1182 | shl ecx, 16 |
1387 | shl ecx, 16 |
1183 | mov cl, 10 |
1388 | mov cl, 10 |
1184 | imul ebx, 10001h |
1389 | imul ebx, 10001h |
1185 | sub bx, data_x_pos+data_x_size |
1390 | sub bx, data_x_pos+data_x_size |
1186 | neg bx |
1391 | neg bx |
1187 | mov al, 13 |
1392 | mov al, 13 |
1188 | ; copy color value from edi |
1393 | ; copy color value from edi |
1189 | mov edx, edi |
1394 | mov edx, edi |
1190 | ; draw container rectangle/box for disassembled text, color in edx |
1395 | ; draw container rectangle/box for disassembled text, color in edx |
1191 | mcall |
1396 | mcall |
1192 | inc [disasm_cur_str] |
1397 | inc [disasm_cur_str] |
1193 | cmp [disasm_cur_str], disasm_height |
1398 | cmp [disasm_cur_str], disasm_height |
1194 | jae .loopend |
1399 | jae .loopend |
1195 | 1400 | ||
1196 | .nosymb: |
1401 | .nosymb: |
1197 | push [disasm_cur_pos] |
1402 | push [disasm_cur_pos] |
1198 | call disasm_instr |
1403 | call disasm_instr |
1199 | pop ebp |
1404 | pop ebp |
1200 | jc .loopend |
1405 | jc .loopend |
1201 | mov edx, COLOR_BG_NORMAL |
1406 | mov edx, COLOR_BG_NORMAL |
1202 | mov esi, COLOR_TXT_NORMAL |
1407 | mov esi, COLOR_TXT_NORMAL |
1203 | mov ebx, data_x_pos*10000h + data_x_size |
1408 | mov ebx, data_x_pos*10000h + data_x_size |
1204 | mov ecx, [disasm_cur_str] |
1409 | mov ecx, [disasm_cur_str] |
1205 | imul ecx, 10*10000h |
1410 | imul ecx, 10*10000h |
1206 | add ecx, (disasm_y_pos-1)*10000h + 10 |
1411 | add ecx, (disasm_y_pos-1)*10000h + 10 |
1207 | mov eax, ebp |
1412 | mov eax, ebp |
1208 | pushad |
1413 | pushad |
1209 | call find_enabled_breakpoint |
1414 | call find_enabled_breakpoint |
1210 | popad |
1415 | popad |
1211 | jnz .nobp |
1416 | jnz .nobp |
1212 | mov edx, COLOR_BG_BREAKPOINT |
1417 | mov edx, COLOR_BG_BREAKPOINT |
1213 | mov esi, COLOR_TXT_BREAKPOINT |
1418 | mov esi, COLOR_TXT_BREAKPOINT |
1214 | .nobp: |
1419 | .nobp: |
1215 | 1420 | ||
1216 | mov eax, [_eip] |
1421 | mov eax, [_eip] |
1217 | cmp eax, ebp |
1422 | cmp eax, ebp |
1218 | jnz .notcurrent |
1423 | jnz .notcurrent |
1219 | mov edx, COLOR_BG_SELECTED |
1424 | mov edx, COLOR_BG_SELECTED |
1220 | mov esi, COLOR_TXT_SELECTED |
1425 | mov esi, COLOR_TXT_SELECTED |
1221 | .notcurrent: |
1426 | .notcurrent: |
1222 | push esi ; Save color value for disassembled text |
1427 | push esi ; Save color value for disassembled text |
1223 | 1428 | ||
1224 | ; draw container rectangle/box for disassembled text |
1429 | ; draw container rectangle/box for disassembled text |
1225 | ; color in edx |
1430 | ; color in edx |
1226 | mcall 13 |
1431 | mcall 13 |
1227 | 1432 | ||
1228 | mov edx, [disasm_cur_str] |
1433 | mov edx, [disasm_cur_str] |
1229 | imul edx, 10 |
1434 | imul edx, 10 |
1230 | add edx, data_x_pos*10000h + disasm_y_pos |
1435 | add edx, data_x_pos*10000h + disasm_y_pos |
1231 | ; draw a number in the window, color in esi |
1436 | ; draw a number in the window, color in esi |
1232 | mcall 47, 80100h, ebp |
1437 | mcall 47, 80100h, ebp |
1233 | 1438 | ||
1234 | lea ebx, [edx+8*6*10000h] |
1439 | lea ebx, [edx+8*6*10000h] |
1235 | mov ecx, esi ; text color |
1440 | mov ecx, esi ; text color |
1236 | push 2 |
1441 | push 2 |
1237 | pop esi |
1442 | pop esi |
1238 | mov edx, aColon |
1443 | mov edx, aColon |
1239 | ; draw the colon |
1444 | ; draw the colon |
1240 | mcall 4 |
1445 | mcall 4 |
1241 | push 9 |
1446 | push 9 |
1242 | pop edi |
1447 | pop edi |
1243 | lea edx, [ebx+2*6*10000h] |
1448 | lea edx, [ebx+2*6*10000h] |
1244 | mov ecx, ebp |
1449 | mov ecx, ebp |
1245 | sub ecx, [disasm_start_pos] |
1450 | sub ecx, [disasm_start_pos] |
1246 | add ecx, disasm_buffer |
1451 | add ecx, disasm_buffer |
1247 | 1452 | ||
1248 | mov esi, COLOR_TXT_HEX |
1453 | mov esi, COLOR_TXT_HEX |
1249 | mov eax, [_eip] |
1454 | mov eax, [_eip] |
1250 | cmp eax, ebp |
1455 | cmp eax, ebp |
1251 | jnz @f |
1456 | jnz @f |
1252 | mov esi, COLOR_TXT_SELECTED |
1457 | mov esi, COLOR_TXT_SELECTED |
1253 | @@: |
1458 | @@: |
1254 | .drawhex: |
1459 | .drawhex: |
1255 | ; draw a number in the window, color in esi |
1460 | ; draw a number in the window, color in esi |
1256 | mcall 47, 20101h |
1461 | mcall 47, 20101h |
1257 | add edx, 6*3*10000h |
1462 | add edx, 6*3*10000h |
1258 | inc ecx |
1463 | inc ecx |
1259 | inc ebp |
1464 | inc ebp |
1260 | cmp ebp, [disasm_cur_pos] |
1465 | cmp ebp, [disasm_cur_pos] |
1261 | jae .hexdone |
1466 | jae .hexdone |
1262 | dec edi |
1467 | dec edi |
1263 | jnz .drawhex |
1468 | jnz .drawhex |
1264 | push esi |
1469 | push esi |
1265 | mov esi, [disasm_cur_pos] |
1470 | mov esi, [disasm_cur_pos] |
1266 | dec esi |
1471 | dec esi |
1267 | cmp esi, ebp |
1472 | cmp esi, ebp |
1268 | pop esi |
1473 | pop esi |
1269 | jbe .drawhex |
1474 | jbe .drawhex |
1270 | 1475 | ||
1271 | lea ebx, [edx-6*10000h] |
1476 | lea ebx, [edx-6*10000h] |
1272 | ; copy color value from esi |
1477 | ; copy color value from esi |
1273 | mov ecx, esi |
1478 | mov ecx, esi |
1274 | push 3 |
1479 | push 3 |
1275 | pop esi |
1480 | pop esi |
1276 | mov edx, aDots |
1481 | mov edx, aDots |
1277 | ; draw a text string in the window, color in ecx |
1482 | ; draw a text string in the window, color in ecx |
1278 | mcall 4 |
1483 | mcall 4 |
1279 | 1484 | ||
1280 | .hexdone: |
1485 | .hexdone: |
1281 | pop esi |
1486 | pop esi |
1282 | xor eax, eax |
1487 | xor eax, eax |
1283 | mov edi, disasm_string |
1488 | mov edi, disasm_string |
1284 | mov edx, edi |
1489 | mov edx, edi |
1285 | or ecx, -1 |
1490 | or ecx, -1 |
1286 | repnz scasb |
1491 | repnz scasb |
1287 | not ecx |
1492 | not ecx |
1288 | dec ecx |
1493 | dec ecx |
1289 | xchg ecx, esi |
1494 | xchg ecx, esi |
1290 | mov ebx, [disasm_cur_str] |
1495 | mov ebx, [disasm_cur_str] |
1291 | imul ebx, 10 |
1496 | imul ebx, 10 |
1292 | add ebx, (data_x_pos+6*40)*10000h+disasm_y_pos |
1497 | add ebx, (data_x_pos+6*40)*10000h+disasm_y_pos |
1293 | 1498 | ||
1294 | ; draw a text string in the window, color in ecx |
1499 | ; draw a text string in the window, color in ecx |
1295 | mcall 4 |
1500 | mcall 4 |
1296 | inc [disasm_cur_str] |
1501 | inc [disasm_cur_str] |
1297 | cmp [disasm_cur_str], disasm_height |
1502 | cmp [disasm_cur_str], disasm_height |
1298 | jb .loop |
1503 | jb .loop |
1299 | 1504 | ||
1300 | .loopend: |
1505 | .loopend: |
1301 | mov ecx, disasm_height |
1506 | mov ecx, disasm_height |
1302 | sub ecx, [disasm_cur_str] |
1507 | sub ecx, [disasm_cur_str] |
1303 | jz @f |
1508 | jz @f |
1304 | imul ecx, 10 |
1509 | imul ecx, 10 |
1305 | inc ecx |
1510 | inc ecx |
1306 | mov eax, disasm_y_pos + disasm_y_size |
1511 | mov eax, disasm_y_pos + disasm_y_size |
1307 | sub eax, ecx |
1512 | sub eax, ecx |
1308 | shl eax, 16 |
1513 | shl eax, 16 |
1309 | add ecx, eax |
1514 | add ecx, eax |
1310 | ; Draw filled rectangle |
1515 | ; Draw filled rectangle |
1311 | mcall 13, data_x_pos*10000h+data_x_size, , COLOR_BG_NORMAL |
1516 | mcall 13, data_x_pos*10000h+data_x_size, , COLOR_BG_NORMAL |
1312 | 1517 | ||
1313 | @@: |
1518 | @@: |
1314 | ret |
1519 | ret |
1315 | 1520 | ||
1316 | ;----------------------------------------------------------------------------- |
1521 | ;----------------------------------------------------------------------------- |
1317 | 1522 | ||
1318 | ; TODO: cleanup of this function, make some global labels local |
1523 | ; TODO: cleanup of this function, make some global labels local |
1319 | update_disasm_eip: |
1524 | update_disasm_eip: |
1320 | ; test if instruction at eip is showed |
1525 | ; test if instruction at eip is showed |
1321 | mov ecx, disasm_height |
1526 | mov ecx, disasm_height |
1322 | mov eax, [disasm_start_pos] |
1527 | mov eax, [disasm_start_pos] |
1323 | mov [disasm_cur_pos], eax |
1528 | mov [disasm_cur_pos], eax |
1324 | 1529 | ||
1325 | .l: |
1530 | .l: |
1326 | mov eax, [disasm_cur_pos] |
1531 | mov eax, [disasm_cur_pos] |
1327 | call find_symbol |
1532 | call find_symbol |
1328 | jc @f |
1533 | jc @f |
1329 | dec ecx |
1534 | dec ecx |
1330 | jz .m |
1535 | jz .m |
1331 | 1536 | ||
1332 | @@: |
1537 | @@: |
1333 | cmp [_eip], eax |
1538 | cmp [_eip], eax |
1334 | jz draw_disasm |
1539 | jz draw_disasm |
1335 | push ecx |
1540 | push ecx |
1336 | call disasm_instr |
1541 | call disasm_instr |
1337 | pop ecx |
1542 | pop ecx |
1338 | jc .m |
1543 | jc .m |
1339 | loop .l |
1544 | loop .l |
1340 | 1545 | ||
1341 | .m: |
1546 | .m: |
1342 | 1547 | ||
1343 | update_disasm_eip_force: |
1548 | update_disasm_eip_force: |
1344 | mov eax, [_eip] |
1549 | mov eax, [_eip] |
1345 | mov [disasm_start_pos], eax |
1550 | mov [disasm_start_pos], eax |
1346 | 1551 | ||
1347 | update_disasm: |
1552 | update_disasm: |
1348 | cmp [debuggee_pid], 0 |
1553 | cmp [debuggee_pid], 0 |
1349 | jz .no |
1554 | jz .no |
1350 | 1555 | ||
1351 | mcall 69, 6, [debuggee_pid], 256, [disasm_start_pos], disasm_buffer |
1556 | mcall 69, 6, [debuggee_pid], 256, [disasm_start_pos], disasm_buffer |
1352 | cmp eax, -1 |
1557 | cmp eax, -1 |
1353 | jnz @f |
1558 | jnz @f |
1354 | mov esi, read_mem_err |
1559 | mov esi, read_mem_err |
1355 | call put_message |
1560 | call put_message |
1356 | 1561 | ||
1357 | .no: |
1562 | .no: |
1358 | xor eax, eax |
1563 | xor eax, eax |
1359 | 1564 | ||
1360 | @@: |
1565 | @@: |
1361 | mov [disasm_buf_size], eax |
1566 | mov [disasm_buf_size], eax |
1362 | call restore_from_breaks |
1567 | call restore_from_breaks |
1363 | jmp draw_disasm |
1568 | jmp draw_disasm |
1364 | 1569 | ||
1365 | 1570 | ||
1366 | ;----------------------------------------------------------------------------- |
1571 | ;----------------------------------------------------------------------------- |
1367 | ; Draw main window |
1572 | ; Draw main window |
1368 | 1573 | ||
1369 | draw_window: |
1574 | draw_window: |
1370 | ; start window redraw |
1575 | ; start window redraw |
1371 | mcall 12, 1 |
1576 | mcall 12, 1 |
1372 | 1577 | ||
1373 | ; define window |
1578 | ; define window |
1374 | mcall 0, wnd_x_size, wnd_y_size, (COLOR_BG_NORMAL or 0x54000000), , caption_str |
1579 | mcall 0, wnd_x_size, wnd_y_size, (COLOR_BG_NORMAL or 0x54000000), , caption_str |
1375 | 1580 | ||
1376 | ; clear unused areas |
1581 | ; clear unused areas |
1377 | ; get window skin height |
1582 | ; get window skin height |
1378 | mcall 48, 4 |
1583 | mcall 48, 4 |
1379 | cmp eax, title_y_pos |
1584 | cmp eax, title_y_pos |
1380 | jb @f |
1585 | jb @f |
1381 | push registers_y_pos |
1586 | push registers_y_pos |
1382 | pop eax |
1587 | pop eax |
1383 | 1588 | ||
1384 | @@: |
1589 | @@: |
1385 | push registers_y_pos |
1590 | push registers_y_pos |
1386 | pop ecx |
1591 | pop ecx |
1387 | push eax |
1592 | push eax |
1388 | sub ecx, eax |
1593 | sub ecx, eax |
1389 | shl eax, 16 |
1594 | shl eax, 16 |
1390 | add ecx, eax |
1595 | add ecx, eax |
1391 | mov ebx, 5*10000h + (wnd_x_size-9) |
1596 | mov ebx, 5*10000h + (wnd_x_size-9) |
1392 | mov edx, COLOR_BG_NORMAL |
1597 | mov edx, COLOR_BG_NORMAL |
1393 | ; draw container rectangle/box for registers information region |
1598 | ; draw container rectangle/box for registers information region |
1394 | mcall 13 |
1599 | mcall 13 |
1395 | mov ecx, (dump_y_pos+dump_y_size)*10000h + (disasm_y_pos-dump_y_pos-dump_y_size) |
1600 | mov ecx, (dump_y_pos+dump_y_size)*10000h + (disasm_y_pos-dump_y_pos-dump_y_size) |
1396 | ; draw container rectangle/box for dump memory region |
1601 | ; draw container rectangle/box for dump memory region |
1397 | mcall |
1602 | mcall |
1398 | mov ecx, (disasm_y_pos-1+disasm_y_size)*10000h + (messages_y_pos-disasm_y_pos+1-disasm_y_size) |
1603 | mov ecx, (disasm_y_pos-1+disasm_y_size)*10000h + (messages_y_pos-disasm_y_pos+1-disasm_y_size) |
1399 | ; draw container rectangle/box for disassembled code region |
1604 | ; draw container rectangle/box for disassembled code region |
1400 | mcall |
1605 | mcall |
1401 | mov ecx, (messages_y_pos+messages_y_size)*10000h + (wnd_y_size-messages_y_pos-messages_y_size-4) |
1606 | mov ecx, (messages_y_pos+messages_y_size)*10000h + (wnd_y_size-messages_y_pos-messages_y_size-4) |
1402 | ; draw container rectangle/box for messages window region |
1607 | ; draw container rectangle/box for messages window region |
1403 | mcall |
1608 | mcall |
1404 | mov ebx, 5*10000h + (data_x_pos-5) |
1609 | mov ebx, 5*10000h + (data_x_pos-5) |
1405 | pop ecx |
1610 | pop ecx |
1406 | imul ecx, 10001h |
1611 | imul ecx, 10001h |
1407 | sub cx, wnd_y_size-4 |
1612 | sub cx, wnd_y_size-4 |
1408 | neg cx |
1613 | neg cx |
1409 | ; draw container rectangle/box |
1614 | ; draw container rectangle/box |
1410 | mcall |
1615 | mcall |
1411 | mov ebx, (data_x_pos+data_x_size)*10000h + (wnd_x_size-data_x_pos-data_x_size-4) |
1616 | mov ebx, (data_x_pos+data_x_size)*10000h + (wnd_x_size-data_x_pos-data_x_size-4) |
1412 | ; draw container rectangle/box |
1617 | ; draw container rectangle/box |
1413 | mcall |
1618 | mcall |
1414 | mov ebx, 5*10000h + title_x_pos - 5 |
1619 | mov ebx, 5*10000h + title_x_pos - 5 |
1415 | mov ecx, (title_y_pos)*10000h + (title_y_size) |
1620 | mov ecx, (title_y_pos)*10000h + (title_y_size) |
1416 | ; draw container rectangle/box for dump memory region title |
1621 | ; draw container rectangle/box for dump memory region title |
1417 | mcall |
1622 | mcall |
1418 | 1623 | ||
1419 | ; messages frame |
1624 | ; messages frame |
1420 | mov ebx, (messages_x_pos-2)*10000h + (messages_x_pos+messages_x_size+2) |
1625 | mov ebx, (messages_x_pos-2)*10000h + (messages_x_pos+messages_x_size+2) |
1421 | push ebx |
1626 | push ebx |
1422 | mov ecx, (messages_y_pos-2)*10001h |
1627 | mov ecx, (messages_y_pos-2)*10001h |
1423 | mov edx, COLOR_LINE |
1628 | mov edx, COLOR_LINE |
1424 | mcall 38 |
1629 | mcall 38 |
1425 | mov ecx, (messages_y_pos+messages_y_size+2)*10001h |
1630 | mov ecx, (messages_y_pos+messages_y_size+2)*10001h |
1426 | mcall |
1631 | mcall |
1427 | mov ebx, (messages_x_pos-2)*10001h |
1632 | mov ebx, (messages_x_pos-2)*10001h |
1428 | push ebx |
1633 | push ebx |
1429 | mov ecx, (messages_y_pos-2)*10000h + (messages_y_pos+messages_y_size+2) |
1634 | mov ecx, (messages_y_pos-2)*10000h + (messages_y_pos+messages_y_size+2) |
1430 | mcall |
1635 | mcall |
1431 | mov ebx, (messages_x_pos+messages_x_size+2)*10001h |
1636 | mov ebx, (messages_x_pos+messages_x_size+2)*10001h |
1432 | push ebx |
1637 | push ebx |
1433 | mcall |
1638 | mcall |
1434 | 1639 | ||
1435 | ; command line frame |
1640 | ; command line frame |
1436 | mov ecx, (cmdline_y_pos-2)*10000h + (cmdline_y_pos+cmdline_y_size+2) |
1641 | mov ecx, (cmdline_y_pos-2)*10000h + (cmdline_y_pos+cmdline_y_size+2) |
1437 | pop ebx |
1642 | pop ebx |
1438 | mcall |
1643 | mcall |
1439 | pop ebx |
1644 | pop ebx |
1440 | mcall |
1645 | mcall |
1441 | pop ebx |
1646 | pop ebx |
1442 | mov ecx, (cmdline_y_pos+cmdline_y_size+2)*10001h |
1647 | mov ecx, (cmdline_y_pos+cmdline_y_size+2)*10001h |
1443 | mcall |
1648 | mcall |
1444 | mov ecx, (cmdline_y_pos-2)*10001h |
1649 | mov ecx, (cmdline_y_pos-2)*10001h |
1445 | mcall |
1650 | mcall |
1446 | 1651 | ||
1447 | ; registers frame |
1652 | ; registers frame |
1448 | DrawRectangle (registers_x_pos-2), (registers_y_pos-2), (registers_x_size+3), (registers_y_size+3), COLOR_LINE |
1653 | DrawRectangle (registers_x_pos-2), (registers_y_pos-2), (registers_x_size+3), (registers_y_size+3), COLOR_LINE |
1449 | ; draw container rectangle/box for registers information window region |
1654 | ; draw container rectangle/box for registers information window region |
1450 | 1655 | ||
1451 | ; messages |
1656 | ; messages |
1452 | call draw_messages |
1657 | call draw_messages |
1453 | 1658 | ||
1454 | ; command line & cursor |
1659 | ; command line & cursor |
1455 | call draw_cmdline |
1660 | call draw_cmdline |
1456 | call draw_cursor |
1661 | call draw_cursor |
1457 | 1662 | ||
1458 | ; title & registers & dump & disasm |
1663 | ; title & registers & dump & disasm |
1459 | mov ebx, (data_x_pos-2)*10001h |
1664 | mov ebx, (data_x_pos-2)*10001h |
1460 | mov ecx, (title_y_pos+5)*10000h + (messages_y_pos-2) |
1665 | mov ecx, (title_y_pos+5)*10000h + (messages_y_pos-2) |
1461 | mov edx, COLOR_LINE |
1666 | mov edx, COLOR_LINE |
1462 | mcall 38 |
1667 | mcall 38 |
1463 | mov ebx, (data_x_pos+data_x_size+2)*10001h |
1668 | mov ebx, (data_x_pos+data_x_size+2)*10001h |
1464 | mcall |
1669 | mcall |
1465 | mov ebx, (data_x_pos-2)*10000h + (data_x_pos+data_x_size+2) |
1670 | mov ebx, (data_x_pos-2)*10000h + (data_x_pos+data_x_size+2) |
1466 | mov ecx, (disasm_y_pos-4)*10001h |
1671 | mov ecx, (disasm_y_pos-4)*10001h |
1467 | mcall |
1672 | mcall |
1468 | 1673 | ||
1469 | ; redraw whole window again |
1674 | ; redraw whole window again |
1470 | call redraw_title |
1675 | call redraw_title |
1471 | call draw_registers |
1676 | call draw_registers |
1472 | call draw_dump |
1677 | call draw_dump |
1473 | call draw_disasm |
1678 | call draw_disasm |
1474 | 1679 | ||
1475 | ; end of window redraw |
1680 | ; end of window redraw |
1476 | mcall 12, 2 |
1681 | mcall 12, 2 |
1477 | ret |
1682 | ret |
1478 | 1683 | ||
1479 | ; vim: ft=fasm tabstop=4 |
1684 | ; vim: ft=fasm tabstop=4 |