Rev 1212 | Rev 1228 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1212 | Rev 1214 | ||
---|---|---|---|
1 | ; |
1 | ; |
2 | ; PROCESS MANAGEMENT |
2 | ; PROCESS MANAGEMENT |
3 | ; |
3 | ; |
4 | ; VTurjanmaa |
4 | ; VTurjanmaa |
5 | ; additions by M.Lisovin lisovin@26.ru |
5 | ; additions by M.Lisovin lisovin@26.ru |
6 | ; integrated with load_lib.obj by |
6 | ; integrated with load_lib.obj by |
7 | ; Compile with FASM for Menuet |
7 | ; Compile with FASM for Menuet |
8 | ; |
8 | ; |
9 | 9 | ||
10 | use32 |
10 | use32 |
11 | org 0x0 |
11 | org 0x0 |
12 | STACK_SIZE=1024 |
12 | STACK_SIZE=1024 |
13 | offset_y=22 |
13 | offset_y=22 |
14 | offset_x=5 |
14 | offset_x=5 |
15 | db 'MENUET01' ; 8 byte id |
15 | db 'MENUET01' ; 8 byte id |
16 | dd 0x01 ; header version |
16 | dd 0x01 ; header version |
17 | dd START ; start of code |
17 | dd START ; start of code |
18 | dd I_END ; size of image |
18 | dd I_END ; size of image |
19 | dd U_END+STACK_SIZE ; memory for app |
19 | dd U_END+STACK_SIZE ; memory for app |
20 | dd U_END+STACK_SIZE ; esp |
20 | dd U_END+STACK_SIZE ; esp |
21 | dd 0x0 , 0x0 ; I_Param , I_Icon |
21 | dd 0x0 , 0x0 ; I_Param , I_Icon |
22 | 22 | ||
23 | include 'lang.inc' |
23 | include 'lang.inc' |
24 | include '../../../macros.inc' |
24 | include '../../../macros.inc' |
25 | include '../../../develop/libraries/box_lib/asm/trunk/editbox_ex.mac' |
25 | include '../../../develop/libraries/box_lib/asm/trunk/editbox_ex.mac' |
26 | include '../../../develop/libraries/box_lib/load_lib.mac' |
26 | include '../../../develop/libraries/box_lib/load_lib.mac' |
27 | display_processes=32 ; number of processes to show |
27 | display_processes=32 ; number of processes to show |
28 | @use_library ;use load lib macros |
28 | @use_library ;use load lib macros |
29 | START: ; start of execution |
29 | START: ; start of execution |
30 | 30 | ||
31 | sys_load_library library_name, cur_dir_path, library_path, system_path, \ |
31 | sys_load_library library_name, cur_dir_path, library_path, system_path, \ |
32 | err_message_found_lib, head_f_l, myimport, err_message_import, head_f_i |
32 | err_message_found_lib, head_f_l, myimport, err_message_import, head_f_i |
33 | inc eax |
33 | inc eax |
34 | jz close |
34 | jz close |
35 | ; calculate window position |
35 | ; calculate window position |
36 | ; at the center of the screen |
36 | ; at the center of the screen |
37 | call calculate_window_pos |
37 | call calculate_window_pos |
38 | 38 | ||
39 | ;main loop when process name isn't edited. |
39 | ;main loop when process name isn't edited. |
40 | red: |
40 | red: |
41 | xor ebp,ebp |
41 | xor ebp,ebp |
42 | inc ebp |
42 | inc ebp |
43 | ; mov ebp,1 |
43 | ; mov ebp,1 |
44 | call draw_window ; redraw all window |
44 | call draw_window ; redraw all window |
45 | align 16 |
45 | align 16 |
46 | still: |
46 | still: |
47 | mov eax,23 ; wait here for event |
47 | mov eax,23 ; wait here for event |
48 | mov ebx,100 ; 2 sec. |
48 | mov ebx,100 ; 2 sec. |
49 | mcall |
49 | mcall |
50 | 50 | ||
51 | dec eax ; redraw request ? |
51 | dec eax ; redraw request ? |
52 | jz red |
52 | jz red |
53 | dec eax ; key in buffer ? |
53 | dec eax ; key in buffer ? |
54 | jz key |
54 | jz key |
55 | dec eax ; button in buffer ? |
55 | dec eax ; button in buffer ? |
56 | jz button |
56 | jz button |
57 | 57 | ||
58 | push dword edit1 |
58 | push dword edit1 |
59 | call [edit_box_mouse] |
59 | call [edit_box_mouse] |
60 | 60 | ||
61 | 61 | ||
62 | still_end: |
62 | still_end: |
63 | xor ebp,ebp ; draw new state of processes |
63 | xor ebp,ebp ; draw new state of processes |
64 | call draw_window |
64 | call draw_window |
65 | jmp still |
65 | jmp still |
66 | 66 | ||
67 | 67 | ||
68 | key: ; key |
68 | key: ; key |
69 | mov eax,2 |
69 | mov eax,2 |
70 | mcall |
70 | mcall |
71 | 71 | ||
72 | cmp ah,184 ; PageUp |
72 | cmp ah,184 ; PageUp |
73 | je pgdn |
73 | je pgdn |
74 | cmp ah,183 |
74 | cmp ah,183 |
75 | je pgup ; PageDown |
75 | je pgup ; PageDown |
76 | cmp ah,27 |
76 | cmp ah,27 |
77 | je close ; Esc |
77 | je close ; Esc |
78 | 78 | ||
79 | push dword edit1 |
79 | push dword edit1 |
80 | call [edit_box_key] |
80 | call [edit_box_key] |
81 | 81 | ||
82 | jmp still_end |
82 | jmp still_end |
83 | 83 | ||
84 | button: |
84 | button: |
85 | ; get button id |
85 | ; get button id |
86 | mov eax,17 |
86 | mov eax,17 |
87 | mcall |
87 | mcall |
88 | shr eax,8 |
88 | shr eax,8 |
89 | 89 | ||
90 | ;id in [10,50] corresponds to terminate buttons. |
90 | ;id in [10,50] corresponds to terminate buttons. |
91 | cmp eax,10 |
91 | cmp eax,10 |
92 | jb noterm |
92 | jb noterm |
93 | cmp eax,50 |
93 | cmp eax,50 |
94 | jg noterm |
94 | jg noterm |
95 | 95 | ||
96 | ;calculate button index |
96 | ;calculate button index |
97 | sub eax,11 |
97 | sub eax,11 |
98 | 98 | ||
99 | ;calculate process slot |
99 | ;calculate process slot |
100 | mov ecx,[tasklist+4*eax] |
100 | mov ecx,[tasklist+4*eax] |
101 | 101 | ||
102 | ;ignore empty buttons |
102 | ;ignore empty buttons |
103 | test ecx,ecx |
103 | test ecx,ecx |
104 | jle still_end |
104 | jle still_end |
105 | ;terminate application |
105 | ;terminate application |
106 | mov eax,18 |
106 | mov eax,18 |
107 | mov ebx,2 |
107 | mov ebx,2 |
108 | mcall |
108 | mcall |
109 | jmp still_end |
109 | jmp still_end |
110 | 110 | ||
111 | noterm: |
111 | noterm: |
112 | 112 | ||
113 | ;special buttons |
113 | ;special buttons |
114 | dec eax |
114 | dec eax |
115 | jz close |
115 | jz close |
116 | 116 | ||
117 | sub eax,50 |
117 | sub eax,50 |
118 | jz pgdn ;51 |
118 | jz pgdn ;51 |
119 | dec eax |
119 | dec eax |
120 | jz pgup ;52 |
120 | jz pgup ;52 |
121 | ; dec eax |
121 | ; dec eax |
122 | ; jz read_string |
122 | ; jz read_string |
123 | dec eax |
123 | dec eax |
124 | jz program_start ;53 |
124 | jz program_start ;53 |
125 | dec eax |
125 | dec eax |
126 | jz reboot ;54 |
126 | jz reboot ;54 |
127 | jmp still_end |
127 | jmp still_end |
128 | 128 | ||
129 | ;buttons handlers |
129 | ;buttons handlers |
130 | 130 | ||
131 | pgdn: |
131 | pgdn: |
132 | sub [list_start],display_processes |
132 | sub [list_start],display_processes |
133 | ; cmp [list_start],0 |
133 | ; cmp [list_start],0 |
134 | jge still_end |
134 | jge still_end |
135 | mov [list_start],0 |
135 | mov [list_start],0 |
136 | jmp still_end |
136 | jmp still_end |
137 | 137 | ||
138 | pgup: |
138 | pgup: |
139 | mov eax,[list_add] ;maximal displayed process slot |
139 | mov eax,[list_add] ;maximal displayed process slot |
140 | mov [list_start],eax |
140 | mov [list_start],eax |
141 | jmp still_end |
141 | jmp still_end |
142 | 142 | ||
143 | program_start: |
143 | program_start: |
144 | mov eax,70 |
144 | mov eax,70 |
145 | mov ebx,file_start |
145 | mov ebx,file_start |
146 | mcall |
146 | mcall |
147 | jmp still_end |
147 | jmp still_end |
148 | 148 | ||
149 | reboot: |
149 | reboot: |
150 | mov eax,70 |
150 | mov eax,70 |
151 | mov ebx,sys_reboot |
151 | mov ebx,sys_reboot |
152 | mcall |
152 | mcall |
153 | ;close program if we going to reboot |
153 | ;close program if we going to reboot |
154 | 154 | ||
155 | close: |
155 | close: |
156 | or eax,-1 ; close this program |
156 | or eax,-1 ; close this program |
157 | mcall |
157 | mcall |
158 | 158 | ||
159 | draw_next_process: |
159 | draw_next_process: |
160 | ;input: |
160 | ;input: |
161 | ; edi - current slot |
161 | ; edi - current slot |
162 | ; [curposy] - y position |
162 | ; [curposy] - y position |
163 | ;output: |
163 | ;output: |
164 | ; edi - next slot (or -1 if no next slot) |
164 | ; edi - next slot (or -1 if no next slot) |
165 | ;registers corrupted! |
165 | ;registers corrupted! |
166 | 166 | ||
167 | ;create button |
167 | ;create button |
168 | test ebp,ebp |
168 | test ebp,ebp |
169 | jnz .nodelete |
169 | jnz .nodelete |
170 | ;delete old button |
170 | ;delete old button |
171 | mov eax,8 |
171 | mov eax,8 |
172 | mov edx,[index] |
172 | mov edx,[index] |
173 | add edx,(1 shl 31)+11 |
173 | add edx,(1 shl 31)+11 |
174 | mcall |
174 | mcall |
175 | 175 | ||
176 | .nodelete: |
176 | .nodelete: |
177 | ;create terminate process button |
177 | ;create terminate process button |
178 | mov eax,8 |
178 | mov eax,8 |
179 | mov ebx,(15-offset_x)*65536+100-offset_y |
179 | mov ebx,(15-offset_x)*65536+100-offset_y |
180 | mov ecx,[curposy] |
180 | mov ecx,[curposy] |
181 | shl ecx,16 |
181 | shl ecx,16 |
182 | mov cx,10 |
182 | mov cx,10 |
183 | mov edx,[index] |
183 | mov edx,[index] |
184 | add edx,11 |
184 | add edx,11 |
185 | mov esi,0xaabbcc |
185 | mov esi,0xaabbcc |
186 | ;contrast |
186 | ;contrast |
187 | test dword [index],1 |
187 | test dword [index],1 |
188 | jz .change_color_button |
188 | jz .change_color_button |
189 | mov esi,0x8899aa |
189 | mov esi,0x8899aa |
190 | 190 | ||
191 | .change_color_button: |
191 | .change_color_button: |
192 | mcall |
192 | mcall |
193 | 193 | ||
194 | ;draw background for proccess information |
194 | ;draw background for proccess information |
195 | mov eax,13 |
195 | mov eax,13 |
196 | mov ebx,(115-offset_x)*65536+395 |
196 | mov ebx,(115-offset_x)*65536+395 |
197 | ;ecx was already set |
197 | ;ecx was already set |
198 | mov edx,0x88ff88 |
198 | mov edx,0x88ff88 |
199 | ;contrast |
199 | ;contrast |
200 | test dword [index],1 |
200 | test dword [index],1 |
201 | jz .change_color_info |
201 | jz .change_color_info |
202 | mov edx,0xddffdd |
202 | mov edx,0xddffdd |
203 | 203 | ||
204 | .change_color_info: |
204 | .change_color_info: |
205 | mcall |
205 | mcall |
206 | 206 | ||
207 | ;nothing else should be done |
207 | ;nothing else should be done |
208 | ;if there is no process for this button |
208 | ;if there is no process for this button |
209 | test edi,edi |
209 | test edi,edi |
210 | jl .ret |
210 | jl .ret |
211 | 211 | ||
212 | ;find process |
212 | ;find process |
213 | inc edi |
213 | inc edi |
214 | ;more comfortable register for next loop |
214 | ;more comfortable register for next loop |
215 | mov ecx,edi |
215 | mov ecx,edi |
216 | ;precacluate pointer to process buffer |
216 | ;precacluate pointer to process buffer |
217 | mov ebx,process_info_buffer |
217 | mov ebx,process_info_buffer |
218 | 218 | ||
219 | ;find process loop |
219 | ;find process loop |
220 | 220 | ||
221 | .find_loop: |
221 | .find_loop: |
222 | cmp ecx,256 |
222 | cmp ecx,256 |
223 | jge .no_processes |
223 | jge .no_processes |
224 | 224 | ||
225 | ;load process information in buffer |
225 | ;load process information in buffer |
226 | mov eax,9 |
226 | mov eax,9 |
227 | ; mov ebx,process_info_buffer |
227 | ; mov ebx,process_info_buffer |
228 | mcall |
228 | mcall |
229 | 229 | ||
230 | ;if current slot greater than maximal slot, |
230 | ;if current slot greater than maximal slot, |
231 | ;there is no more proccesses. |
231 | ;there is no more proccesses. |
232 | cmp ecx,eax |
232 | cmp ecx,eax |
233 | jg .no_processes |
233 | jg .no_processes |
234 | 234 | ||
235 | ;if slot state is equal to 9, it is empty. |
235 | ;if slot state is equal to 9, it is empty. |
236 | cmp [process_info_buffer+process_information.slot_state],9 |
236 | cmp [process_info_buffer+process_information.slot_state],9 |
237 | jnz .process_found |
237 | jnz .process_found |
238 | 238 | ||
239 | inc ecx |
239 | inc ecx |
240 | jmp .find_loop |
240 | jmp .find_loop |
241 | 241 | ||
242 | .no_processes: |
242 | .no_processes: |
243 | or edi,-1 |
243 | or edi,-1 |
244 | ret |
244 | ret |
245 | 245 | ||
246 | .process_found: |
246 | .process_found: |
247 | mov edi,ecx |
247 | mov edi,ecx |
248 | mov [list_add],ecx |
248 | mov [list_add],ecx |
249 | 249 | ||
250 | ;get processor cpeed |
250 | ;get processor cpeed |
251 | ;for percent calculating |
251 | ;for percent calculating |
252 | mov eax,18 |
252 | mov eax,18 |
253 | mov ebx,5 |
253 | mov ebx,5 |
254 | mcall |
254 | mcall |
255 | 255 | ||
256 | xor edx,edx |
256 | xor edx,edx |
257 | mov ebx,100 |
257 | mov ebx,100 |
258 | div ebx |
258 | div ebx |
259 | 259 | ||
260 | ;eax = number of operation for 1% now |
260 | ;eax = number of operation for 1% now |
261 | ;calculate process cpu usage percent |
261 | ;calculate process cpu usage percent |
262 | mov ebx,eax |
262 | mov ebx,eax |
263 | mov eax,[process_info_buffer+process_information.cpu_usage] |
263 | mov eax,[process_info_buffer+process_information.cpu_usage] |
264 | ; cdq |
264 | ; cdq |
265 | xor edx,edx ; for CPU more 2 GHz - mike.dld |
265 | xor edx,edx ; for CPU more 2 GHz - mike.dld |
266 | 266 | ||
267 | div ebx |
267 | div ebx |
268 | mov [cpu_percent],eax |
268 | mov [cpu_percent],eax |
269 | 269 | ||
270 | ;set text color to display process information |
270 | ;set text color to display process information |
271 | ;([tcolor] variable) |
271 | ;([tcolor] variable) |
272 | ;0% : black |
272 | ;0% : black |
273 | ;1-80% : green |
273 | ;1-80% : green |
274 | ;81-100% : red |
274 | ;81-100% : red |
275 | test eax,eax |
275 | test eax,eax |
276 | jg .no_black |
276 | jg .no_black |
277 | mov [tcolor],eax |
277 | mov [tcolor],eax |
278 | jmp .color_set |
278 | jmp .color_set |
279 | 279 | ||
280 | .no_black: |
280 | .no_black: |
281 | cmp eax,80 |
281 | cmp eax,80 |
282 | ja .no_green |
282 | ja .no_green |
283 | mov dword [tcolor],0x107a30 |
283 | mov dword [tcolor],0x107a30 |
284 | jmp .color_set |
284 | jmp .color_set |
285 | 285 | ||
286 | .no_green: |
286 | .no_green: |
287 | mov dword [tcolor],0xac0000 |
287 | mov dword [tcolor],0xac0000 |
288 | .color_set: |
288 | .color_set: |
289 | 289 | ||
290 | ;show slot number |
290 | ;show slot number |
291 | mov eax,47 |
291 | mov eax,47 |
292 | mov ebx,2*65536+1*256 |
292 | mov ebx,2*65536+1*256 |
293 | ;ecx haven't changed since .process_found |
293 | ;ecx haven't changed since .process_found |
294 | ; mov ecx,edi |
294 | ; mov ecx,edi |
295 | mov edx,[curposy] |
295 | mov edx,[curposy] |
296 | add edx,(20-offset_x)*65536+1 |
296 | add edx,(20-offset_x)*65536+1 |
297 | mov esi,[tcolor] |
297 | mov esi,[tcolor] |
298 | mcall |
298 | mcall |
299 | 299 | ||
300 | ;show process name |
300 | ;show process name |
301 | mov eax,4 |
301 | mov eax,4 |
302 | mov ebx,[curposy] |
302 | mov ebx,[curposy] |
303 | add ebx,(50-offset_x)*65536+1 |
303 | add ebx,(50-offset_x)*65536+1 |
304 | mov ecx,[tcolor] |
304 | mov ecx,[tcolor] |
305 | mov edx,process_info_buffer.process_name |
305 | mov edx,process_info_buffer.process_name |
306 | mov esi,11 |
306 | mov esi,11 |
307 | mcall |
307 | mcall |
308 | 308 | ||
309 | ;show pid |
309 | ;show pid |
310 | mov eax,47 |
310 | mov eax,47 |
311 | mov ebx,8*65536+1*256 |
311 | mov ebx,8*65536+1*256 |
312 | mov ecx,[process_info_buffer.PID] |
312 | mov ecx,[process_info_buffer.PID] |
313 | mov edx,[curposy] |
313 | mov edx,[curposy] |
314 | add edx,(130-offset_x)*65536+1 |
314 | add edx,(130-offset_x)*65536+1 |
315 | mov esi,[tcolor] |
315 | mov esi,[tcolor] |
316 | mcall |
316 | mcall |
317 | 317 | ||
318 | ;show cpu usage |
318 | ;show cpu usage |
319 | mov ecx,[process_info_buffer.cpu_usage] |
319 | mov ecx,[process_info_buffer.cpu_usage] |
320 | add edx,60*65536 |
320 | add edx,60*65536 |
321 | mcall |
321 | mcall |
322 | 322 | ||
323 | ;show cpu percent |
323 | ;show cpu percent |
324 | mov ebx,3*65536+0*256 |
324 | mov ebx,3*65536+0*256 |
325 | mov ecx,[cpu_percent] |
325 | mov ecx,[cpu_percent] |
326 | add edx,60*65536 |
326 | add edx,60*65536 |
327 | mcall |
327 | mcall |
328 | 328 | ||
329 | ;show memory start - obsolete |
329 | ;show memory start - obsolete |
330 | mov ebx,8*65536+1*256 |
330 | mov ebx,8*65536+1*256 |
331 | mov ecx,[process_info_buffer.memory_start] |
331 | mov ecx,[process_info_buffer.memory_start] |
332 | add edx,30*65536 |
332 | add edx,30*65536 |
333 | mcall |
333 | mcall |
334 | 334 | ||
335 | ;show memory usage |
335 | ;show memory usage |
336 | mov ecx,[process_info_buffer.used_memory] |
336 | mov ecx,[process_info_buffer.used_memory] |
337 | inc ecx |
337 | inc ecx |
338 | add edx,60*65536 |
338 | add edx,60*65536 |
339 | mcall |
339 | mcall |
340 | 340 | ||
341 | ;show window stack and value |
341 | ;show window stack and value |
342 | mov ecx,dword [process_info_buffer.window_stack_position] |
342 | mov ecx,dword [process_info_buffer.window_stack_position] |
343 | add edx,60*65536 |
343 | add edx,60*65536 |
344 | mcall |
344 | mcall |
345 | 345 | ||
346 | ;show window xy size |
346 | ;show window xy size |
347 | mov ecx,[process_info_buffer.box.left] |
347 | mov ecx,[process_info_buffer.box.left] |
348 | shl ecx,16 |
348 | shl ecx,16 |
349 | add ecx,[process_info_buffer.box.top] |
349 | add ecx,[process_info_buffer.box.top] |
350 | add edx,60*65536 |
350 | add edx,60*65536 |
351 | mcall |
351 | mcall |
352 | 352 | ||
353 | .ret: |
353 | .ret: |
354 | ;build index->slot map for terminating processes. |
354 | ;build index->slot map for terminating processes. |
355 | mov eax,[index] |
355 | mov eax,[index] |
356 | mov [tasklist+4*eax],edi |
356 | mov [tasklist+4*eax],edi |
357 | ret |
357 | ret |
358 | 358 | ||
359 | ;read_string: |
359 | ;read_string: |
360 | ;clean string |
360 | ;clean string |
361 | ; mov edi,start_application |
361 | ; mov edi,start_application |
362 | ; xor eax,eax |
362 | ; xor eax,eax |
363 | ; mov ecx,60 |
363 | ; mov ecx,60 |
364 | ; cld |
364 | ; cld |
365 | ; rep stosb |
365 | ; rep stosb |
366 | ; call print_text |
366 | ; call print_text |
367 | 367 | ||
368 | ; mov edi,start_application |
368 | ; mov edi,start_application |
369 | ;edi now contains pointer to last symbol |
369 | ;edi now contains pointer to last symbol |
370 | ; jmp still1 |
370 | ; jmp still1 |
371 | 371 | ||
372 | ;read string main loop |
372 | ;read string main loop |
373 | 373 | ||
374 | f11: |
374 | f11: |
375 | ;full update |
375 | ;full update |
376 | push edi |
376 | push edi |
377 | xor ebp,ebp |
377 | xor ebp,ebp |
378 | inc ebp |
378 | inc ebp |
379 | ; mov ebp,1 |
379 | ; mov ebp,1 |
380 | call draw_window |
380 | call draw_window |
381 | pop edi |
381 | pop edi |
382 | ; |
382 | ; |
383 | ; still1: |
383 | ; still1: |
384 | ;wait for message |
384 | ;wait for message |
385 | ; mov eax,23 |
385 | ; mov eax,23 |
386 | ; mov ebx,100 |
386 | ; mov ebx,100 |
387 | ; mcall |
387 | ; mcall |
388 | ; cmp eax,1 |
388 | ; cmp eax,1 |
389 | ; je f11 |
389 | ; je f11 |
390 | ;if no message - update process information |
390 | ;if no message - update process information |
391 | ; cmp eax,0 |
391 | ; cmp eax,0 |
392 | ; jnz .message_received |
392 | ; jnz .message_received |
393 | ; push edi ;edi should be saved since draw_window |
393 | ; push edi ;edi should be saved since draw_window |
394 | ; xor ebp,ebp ;corrupt registers |
394 | ; xor ebp,ebp ;corrupt registers |
395 | ; call draw_window |
395 | ; call draw_window |
396 | ; pop edi |
396 | ; pop edi |
397 | ; jmp still1 |
397 | ; jmp still1 |
398 | ; |
398 | ; |
399 | ;.message_received: |
399 | ;.message_received: |
400 | ; cmp eax,2 |
400 | ; cmp eax,2 |
401 | ; jne read_done ;buttons message |
401 | ; jne read_done ;buttons message |
402 | ;read char |
402 | ;read char |
403 | ; mov eax,2 |
403 | ; mov eax,2 |
404 | ; mcall |
404 | ; mcall |
405 | ; shr eax,8 |
405 | ; shr eax,8 |
406 | 406 | ||
407 | ;if enter pressed, exit read string loop |
407 | ;if enter pressed, exit read string loop |
408 | ; cmp eax,13 |
408 | ; cmp eax,13 |
409 | ; je read_done |
409 | ; je read_done |
410 | ;if backslash pressed? |
410 | ;if backslash pressed? |
411 | ; cmp eax,8 |
411 | ; cmp eax,8 |
412 | ; jnz nobsl |
412 | ; jnz nobsl |
413 | ;decrease pointer to last symbol |
413 | ;decrease pointer to last symbol |
414 | ; cmp edi,start_application |
414 | ; cmp edi,start_application |
415 | ; jz still1 |
415 | ; jz still1 |
416 | ; dec edi |
416 | ; dec edi |
417 | ;fill last symbol with space because |
417 | ;fill last symbol with space because |
418 | ;print_text show all symbols |
418 | ;print_text show all symbols |
419 | ; mov [edi],byte 32 |
419 | ; mov [edi],byte 32 |
420 | ; call print_text |
420 | ; call print_text |
421 | ; jmp still1 |
421 | ; jmp still1 |
422 | ; |
422 | ; |
423 | ; nobsl: |
423 | ; nobsl: |
424 | ;write new symbol |
424 | ;write new symbol |
425 | ; mov [edi],al |
425 | ; mov [edi],al |
426 | ;display new text |
426 | ;display new text |
427 | ; call print_text |
427 | ; call print_text |
428 | ;increment pointer to last symbol |
428 | ;increment pointer to last symbol |
429 | ; inc edi |
429 | ; inc edi |
430 | ;compare with end of string |
430 | ;compare with end of string |
431 | ; mov esi,start_application |
431 | ; mov esi,start_application |
432 | ; add esi,60 |
432 | ; add esi,60 |
433 | ; cmp esi,edi |
433 | ; cmp esi,edi |
434 | ; jnz still1 |
434 | ; jnz still1 |
435 | 435 | ||
436 | ;exiting from read string loop |
436 | ;exiting from read string loop |
437 | ; |
437 | ; |
438 | ; read_done: |
438 | ; read_done: |
439 | ;terminate string for file functions |
439 | ;terminate string for file functions |
440 | ; mov [edi],byte 0 |
440 | ; mov [edi],byte 0 |
441 | 441 | ||
442 | ; call print_text |
442 | ; call print_text |
443 | ; jmp still |
443 | ; jmp still |
444 | 444 | ||
445 | ; |
445 | ; |
446 | ;print_text: |
446 | ;print_text: |
447 | ;display start_application string |
447 | ;display start_application string |
448 | 448 | ||
449 | ; pushad |
449 | ; pushad |
450 | 450 | ||
451 | ;display text background |
451 | ;display text background |
452 | ; mov eax,13 |
452 | ; mov eax,13 |
453 | ; mov ebx,64*65536+62*6 |
453 | ; mov ebx,64*65536+62*6 |
454 | ; mov ecx,400*65536+12 |
454 | ; mov ecx,400*65536+12 |
455 | ; mov edx,0xffffcc ;0xeeeeee |
455 | ; mov edx,0xffffcc ;0xeeeeee |
456 | ; mcall |
456 | ; mcall |
457 | 457 | ||
458 | ;display text |
458 | ;display text |
459 | ; mov eax,4 |
459 | ; mov eax,4 |
460 | ; mov edx,start_application ;from start_application string |
460 | ; mov edx,start_application ;from start_application string |
461 | ; mov ebx,70*65536+402 ;text center-aligned |
461 | ; mov ebx,70*65536+402 ;text center-aligned |
462 | ; xor ecx,ecx ;black text |
462 | ; xor ecx,ecx ;black text |
463 | ; mov esi,60 ;60 symbols |
463 | ; mov esi,60 ;60 symbols |
464 | ; mcall |
464 | ; mcall |
465 | 465 | ||
466 | ; popad |
466 | ; popad |
467 | ; ret |
467 | ; ret |
468 | 468 | ||
469 | window_x_size=524 |
469 | window_x_size=524 |
470 | window_y_size=430 |
470 | window_y_size=430 |
471 | 471 | ||
472 | calculate_window_pos: |
472 | calculate_window_pos: |
473 | ;set window size and position for 0 function |
473 | ;set window size and position for 0 function |
474 | ;to [winxpos] and [winypos] variables |
474 | ;to [winxpos] and [winypos] variables |
475 | 475 | ||
476 | ;get screen size |
476 | ;get screen size |
477 | mov eax,14 |
477 | mov eax,14 |
478 | mcall |
478 | mcall |
479 | mov ebx,eax |
479 | mov ebx,eax |
480 | 480 | ||
481 | ;calculate (x_screen-window_x_size)/2 |
481 | ;calculate (x_screen-window_x_size)/2 |
482 | shr ebx,16+1 |
482 | shr ebx,16+1 |
483 | sub ebx,window_x_size/2 |
483 | sub ebx,window_x_size/2 |
484 | shl ebx,16 |
484 | shl ebx,16 |
485 | mov bx,window_x_size |
485 | mov bx,window_x_size |
486 | ;winxpos=xcoord*65536+xsize |
486 | ;winxpos=xcoord*65536+xsize |
487 | mov [winxpos],ebx |
487 | mov [winxpos],ebx |
488 | 488 | ||
489 | ;calculate (y_screen-window_y_size)/2 |
489 | ;calculate (y_screen-window_y_size)/2 |
490 | and eax,0xffff |
490 | and eax,0xffff |
491 | shr eax,1 |
491 | shr eax,1 |
492 | sub eax,window_y_size/2 |
492 | sub eax,window_y_size/2 |
493 | shl eax,16 |
493 | shl eax,16 |
494 | mov ax,window_y_size |
494 | mov ax,window_y_size |
495 | ;winypos=ycoord*65536+ysize |
495 | ;winypos=ycoord*65536+ysize |
496 | mov [winypos],eax |
496 | mov [winypos],eax |
497 | 497 | ||
498 | ret |
498 | ret |
499 | 499 | ||
500 | ; ********************************************* |
500 | ; ********************************************* |
501 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
501 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
502 | ; ********************************************* |
502 | ; ********************************************* |
503 | 503 | ||
504 | align 16 |
504 | align 16 |
505 | draw_window: |
505 | draw_window: |
506 | ;ebp=1 - redraw all |
506 | ;ebp=1 - redraw all |
507 | ;ebp=0 - redraw only process information |
507 | ;ebp=0 - redraw only process information |
508 | 508 | ||
509 | test ebp,ebp |
509 | test ebp,ebp |
510 | jz .show_process_info |
510 | jz .show_process_info |
511 | 511 | ||
512 | mov eax,12 ; function 12:tell os about windowdraw |
512 | mov eax,12 ; function 12:tell os about windowdraw |
513 | ; mov ebx,1 ; 1, start of draw |
513 | ; mov ebx,1 ; 1, start of draw |
514 | xor ebx,ebx |
514 | xor ebx,ebx |
515 | inc ebx |
515 | inc ebx |
516 | mcall |
516 | mcall |
517 | 517 | ||
518 | ; DRAW WINDOW |
518 | ; DRAW WINDOW |
519 | xor eax,eax ; function 0 : define and draw window |
519 | xor eax,eax ; function 0 : define and draw window |
520 | mov ebx,[winxpos] ; [x start] *65536 + [x size] |
520 | mov ebx,[winxpos] ; [x start] *65536 + [x size] |
521 | mov ecx,[winypos] ; [y start] *65536 + [y size] |
521 | mov ecx,[winypos] ; [y start] *65536 + [y size] |
522 | mov edx,0x34ddffdd ;ffffff ; color of work area RRGGBB,8->color |
522 | mov edx,0x34ddffdd ;ffffff ; color of work area RRGGBB,8->color |
523 | mov edi,title ; WINDOW CAPTION; |
523 | mov edi,title ; WINDOW CAPTION; |
524 | mcall |
524 | mcall |
525 | 525 | ||
526 | 526 | ||
527 | add eax,4 ; function 4 : write text to window |
527 | add eax,4 ; function 4 : write text to window |
528 | mov ebx,(22-offset_x)*65536+35-offset_y ; draw info text with function 4 |
528 | mov ebx,(22-offset_x)*65536+35-offset_y ; draw info text with function 4 |
529 | xor ecx,ecx |
529 | xor ecx,ecx |
530 | mov edx,text |
530 | mov edx,text |
531 | mov esi,text_len |
531 | mov esi,text_len |
532 | mcall |
532 | mcall |
533 | 533 | ||
534 | push dword edit1 |
534 | push dword edit1 |
535 | call [edit_box_draw] |
535 | call [edit_box_draw] |
536 | 536 | ||
537 | align 16 |
537 | align 16 |
538 | .show_process_info: |
538 | .show_process_info: |
539 | mov edi,[list_start] |
539 | mov edi,[list_start] |
540 | mov [list_add],edi |
540 | mov [list_add],edi |
541 | mov dword [index],0 |
541 | mov dword [index],0 |
542 | mov dword [curposy],54-offset_y |
542 | mov dword [curposy],54-offset_y |
543 | 543 | ||
544 | .loop_draw: |
544 | .loop_draw: |
545 | call draw_next_process |
545 | call draw_next_process |
546 | inc dword [index] |
546 | inc dword [index] |
547 | add dword [curposy],10 |
547 | add dword [curposy],10 |
548 | cmp [index],display_processes |
548 | cmp [index],display_processes |
549 | jl .loop_draw |
549 | jl .loop_draw |
550 | 550 | ||
551 | test ebp,ebp |
551 | test ebp,ebp |
552 | jz .end_redraw |
552 | jz .end_redraw |
553 | mov eax,8 |
553 | mov eax,8 |
554 | mov esi,0xaabbcc |
554 | mov esi,0xaabbcc |
555 | 555 | ||
556 | ; previous page button |
556 | ; previous page button |
557 | mov ebx,(30-offset_x)*65536+96 |
557 | mov ebx,(30-offset_x)*65536+96 |
558 | mov ecx,(380-offset_y)*65536+10 |
558 | mov ecx,(380-offset_y)*65536+10 |
559 | mov edx,51 |
559 | mov edx,51 |
560 | mcall |
560 | mcall |
561 | 561 | ||
562 | ; next page button 52 |
562 | ; next page button 52 |
563 | mov ebx,(130-offset_x)*65536+96 |
563 | mov ebx,(130-offset_x)*65536+96 |
564 | inc edx |
564 | inc edx |
565 | mcall |
565 | mcall |
566 | 566 | ||
567 | ; ">" (text enter) button |
567 | ; ">" (text enter) button |
568 | ; mov ebx,30*65536+20 |
568 | ; mov ebx,30*65536+20 |
569 | add ecx,20 shl 16 |
569 | add ecx,20 shl 16 |
570 | ; inc edx |
570 | ; inc edx |
571 | ; mcall |
571 | ; mcall |
572 | 572 | ||
573 | ; run button 53 |
573 | ; run button 53 |
574 | mov ebx,(456-offset_x)*65536+50 |
574 | mov ebx,(456-offset_x)*65536+50 |
575 | inc edx |
575 | inc edx |
576 | mcall |
576 | mcall |
577 | 577 | ||
578 | ; reboot button |
578 | ; reboot button |
579 | sub ebx,120*65536 |
579 | sub ebx,120*65536 |
580 | add ebx,60 |
580 | add ebx,60 |
581 | sub ecx,20 shl 16 |
581 | sub ecx,20 shl 16 |
582 | inc edx |
582 | inc edx |
583 | mcall |
583 | mcall |
584 | 584 | ||
585 | ;"PREV PAGE", "NEXT PAGE" and "REBOOT" labels |
585 | ;"PREV PAGE", "NEXT PAGE" and "REBOOT" labels |
586 | mov eax,4 |
586 | mov eax,4 |
587 | mov ebx,(50-offset_x)*65536+382-offset_y |
587 | mov ebx,(50-offset_x)*65536+382-offset_y |
588 | xor ecx,ecx |
588 | xor ecx,ecx |
589 | mov edx,tbts |
589 | mov edx,tbts |
590 | mov esi,tbte-tbts |
590 | mov esi,tbte-tbts |
591 | mcall |
591 | mcall |
592 | 592 | ||
593 | ;">" labels |
593 | ;">" labels |
594 | ; mov eax,4 |
594 | ; mov eax,4 |
595 | ; mov ebx,40*65536+402 |
595 | ; mov ebx,40*65536+402 |
596 | ; xor ecx,ecx |
596 | ; xor ecx,ecx |
597 | ; mov edx,tbts_2 |
597 | ; mov edx,tbts_2 |
598 | ; mov esi,1 |
598 | ; mov esi,1 |
599 | ; mcall |
599 | ; mcall |
600 | 600 | ||
601 | ;"RUN" labels |
601 | ;"RUN" labels |
602 | ; mov eax,4 |
602 | ; mov eax,4 |
603 | mov ebx,(475-offset_x)*65536+402-offset_y |
603 | mov ebx,(475-offset_x)*65536+402-offset_y |
604 | xor ecx,ecx |
604 | xor ecx,ecx |
605 | mov edx,tbts_3 |
605 | mov edx,tbts_3 |
606 | mov esi,tbte_2-tbts_3 |
606 | mov esi,tbte_2-tbts_3 |
607 | mcall |
607 | mcall |
608 | 608 | ||
609 | ;print application name in text box |
609 | ;print application name in text box |
610 | ; call print_text |
610 | ; call print_text |
611 | 611 | ||
612 | mov eax,12 ; function 12:tell os about windowdraw |
612 | mov eax,12 ; function 12:tell os about windowdraw |
613 | mov ebx,2 ; 2, end of draw |
613 | mov ebx,2 ; 2, end of draw |
614 | mcall |
614 | mcall |
615 | 615 | ||
616 | .end_redraw: |
616 | .end_redraw: |
617 | ret |
617 | ret |
618 | 618 | ||
619 | 619 | ||
620 | ; DATA AREA |
620 | ; DATA AREA |
621 | system_path db '/sys/lib/' |
621 | system_path db '/sys/lib/' |
622 | library_name db 'box_lib.obj',0 |
622 | library_name db 'box_lib.obj',0 |
623 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
623 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
624 | 624 | ||
625 | err_message_found_lib db 'Sorry I cannot load library box_lib.obj',0 |
625 | err_message_found_lib db 'Sorry I cannot load library box_lib.obj',0 |
626 | head_f_i: |
626 | head_f_i: |
627 | head_f_l db 'System error',0 |
627 | head_f_l db 'System error',0 |
628 | err_message_import db 'Error on load import library box_lib.obj',0 |
628 | err_message_import db 'Error on load import library box_lib.obj',0 |
629 | 629 | ||
630 | myimport: |
630 | myimport: |
631 | 631 | ||
632 | edit_box_draw dd aEdit_box_draw |
632 | edit_box_draw dd aEdit_box_draw |
633 | edit_box_key dd aEdit_box_key |
633 | edit_box_key dd aEdit_box_key |
634 | edit_box_mouse dd aEdit_box_mouse |
634 | edit_box_mouse dd aEdit_box_mouse |
635 | ;version_ed dd aVersion_ed |
635 | ;version_ed dd aVersion_ed |
636 | 636 | ||
637 | ;check_box_draw dd aCheck_box_draw |
637 | ;check_box_draw dd aCheck_box_draw |
638 | ;check_box_mouse dd aCheck_box_mouse |
638 | ;check_box_mouse dd aCheck_box_mouse |
639 | ;version_ch dd aVersion_ch |
639 | ;version_ch dd aVersion_ch |
640 | 640 | ||
641 | ;option_box_draw dd aOption_box_draw |
641 | ;option_box_draw dd aOption_box_draw |
642 | ;option_box_mouse dd aOption_box_mouse |
642 | ;option_box_mouse dd aOption_box_mouse |
643 | ;version_op dd aVersion_op |
643 | ;version_op dd aVersion_op |
644 | 644 | ||
645 | dd 0 |
645 | dd 0 |
646 | dd 0 |
646 | dd 0 |
647 | 647 | ||
648 | aEdit_box_draw db 'edit_box',0 |
648 | aEdit_box_draw db 'edit_box',0 |
649 | aEdit_box_key db 'edit_box_key',0 |
649 | aEdit_box_key db 'edit_box_key',0 |
650 | aEdit_box_mouse db 'edit_box_mouse',0 |
650 | aEdit_box_mouse db 'edit_box_mouse',0 |
651 | ;aVersion_ed db 'version_ed',0 |
651 | ;aVersion_ed db 'version_ed',0 |
652 | 652 | ||
653 | ;aCheck_box_draw db 'check_box_draw',0 |
653 | ;aCheck_box_draw db 'check_box_draw',0 |
654 | ;aCheck_box_mouse db 'check_box_mouse',0 |
654 | ;aCheck_box_mouse db 'check_box_mouse',0 |
655 | ;aVersion_ch db 'version_ch',0 |
655 | ;aVersion_ch db 'version_ch',0 |
656 | 656 | ||
657 | ;aOption_box_draw db 'option_box_draw',0 |
657 | ;aOption_box_draw db 'option_box_draw',0 |
658 | ;aOption_box_mouse db 'option_box_mouse',0 |
658 | ;aOption_box_mouse db 'option_box_mouse',0 |
659 | ;aVersion_op db 'version_op',0 |
659 | ;aVersion_op db 'version_op',0 |
660 | 660 | ||
661 | edit1 edit_box 350,(64-offset_x),(398-offset_y),0xffffff,0x6f9480,0,0xAABBCC,0,start_application_c,start_application,ed_focus,start_application_e,start_application_e |
661 | edit1 edit_box 350,(64-offset_x),(398-offset_y),0xffffff,0x6f9480,0,0xAABBCC,0,start_application_c,start_application,mouse_dd,ed_focus,start_application_e,start_application_e |
662 | 662 | ||
663 | list_start dd 0 |
663 | list_start dd 0 |
664 | 664 | ||
665 | sys_reboot: |
665 | sys_reboot: |
666 | dd 7 |
666 | dd 7 |
667 | dd 0 |
667 | dd 0 |
668 | dd 0 |
668 | dd 0 |
669 | dd 0 |
669 | dd 0 |
670 | dd 0 |
670 | dd 0 |
671 | db '/sys/end',0 |
671 | db '/sys/end',0 |
672 | 672 | ||
673 | if lang eq de |
673 | if lang eq de |
674 | text: |
674 | text: |
675 | db 'NAME/BEENDEN PID CPU-LAST % ' |
675 | db 'NAME/BEENDEN PID CPU-LAST % ' |
676 | db 'SPEICHER START/NUTZUNG W-STACK W-SIZE' |
676 | db 'SPEICHER START/NUTZUNG W-STACK W-SIZE' |
677 | text_len = $-text |
677 | text_len = $-text |
678 | 678 | ||
679 | tbts: db 'SEITE ZURUECK SEITE VOR REBOOT SYSTEM' |
679 | tbts: db 'SEITE ZURUECK SEITE VOR REBOOT SYSTEM' |
680 | tbte: |
680 | tbte: |
681 | ;tbts_2 db '>' |
681 | ;tbts_2 db '>' |
682 | tbts_3 db 'START' |
682 | tbts_3 db 'START' |
683 | tbte_2: |
683 | tbte_2: |
684 | 684 | ||
685 | title db 'Prozesse - Ctrl/Alt/Del',0 |
685 | title db 'Prozesse - Ctrl/Alt/Del',0 |
686 | 686 | ||
687 | else if lang eq et |
687 | else if lang eq et |
688 | text: |
688 | text: |
689 | db 'NIMI/LÕPETA PID CPU-KASUTUS % ' |
689 | db 'NIMI/LÕPETA PID CPU-KASUTUS % ' |
690 | db 'MÄLU ALGUS/KASUTUS W-PUHVER W-SUURUS' |
690 | db 'MÄLU ALGUS/KASUTUS W-PUHVER W-SUURUS' |
691 | text_len = $-text |
691 | text_len = $-text |
692 | 692 | ||
693 | tbts: db 'EELMINE LEHT JÄRGMINE LEHT REBOODI SÜSTEEM' |
693 | tbts: db 'EELMINE LEHT JÄRGMINE LEHT REBOODI SÜSTEEM' |
694 | tbte: |
694 | tbte: |
695 | ;tbts_2 db '>' |
695 | ;tbts_2 db '>' |
696 | tbts_3 db 'START' |
696 | tbts_3 db 'START' |
697 | tbte_2: |
697 | tbte_2: |
698 | 698 | ||
699 | title db 'Protsessid - Ctrl/Alt/Del',0 |
699 | title db 'Protsessid - Ctrl/Alt/Del',0 |
700 | 700 | ||
701 | else |
701 | else |
702 | text: |
702 | text: |
703 | db 'NAME/TERMINATE PID CPU-USAGE % ' |
703 | db 'NAME/TERMINATE PID CPU-USAGE % ' |
704 | db 'MEMORY START/USAGE W-STACK W-SIZE' |
704 | db 'MEMORY START/USAGE W-STACK W-SIZE' |
705 | text_len = $-text |
705 | text_len = $-text |
706 | 706 | ||
707 | tbts: db 'PREV PAGE NEXT PAGE REBOOT SYSTEM' |
707 | tbts: db 'PREV PAGE NEXT PAGE REBOOT SYSTEM' |
708 | tbte: |
708 | tbte: |
709 | ;tbts_2 db '>' |
709 | ;tbts_2 db '>' |
710 | tbts_3 db 'RUN' |
710 | tbts_3 db 'RUN' |
711 | tbte_2: |
711 | tbte_2: |
712 | 712 | ||
713 | title db 'Processes - Ctrl/Alt/Del',0 |
713 | title db 'Processes - Ctrl/Alt/Del',0 |
714 | 714 | ||
715 | end if |
715 | end if |
716 | file_start: dd 7 |
716 | file_start: dd 7 |
717 | dd 0,0,0,0 |
717 | dd 0,0,0,0 |
718 | start_application: db '/sys/LAUNCHER',0 |
718 | start_application: db '/sys/LAUNCHER',0 |
719 | start_application_e=$-start_application-1 |
719 | start_application_e=$-start_application-1 |
720 | ; times 60 db 0 |
720 | ; times 60 db 0 |
721 | rb 60 |
721 | rb 60 |
722 | start_application_c=$-start_application-1 |
722 | start_application_c=$-start_application-1 |
723 | 723 | ||
724 | I_END: |
724 | I_END: |
725 | winxpos rd 1 |
725 | winxpos rd 1 |
726 | winypos rd 1 |
726 | winypos rd 1 |
727 | 727 | mouse_dd rd 1 |
|
728 | cpu_percent rd 1 |
728 | cpu_percent rd 1 |
729 | tcolor rd 1 |
729 | tcolor rd 1 |
730 | list_add rd 1 |
730 | list_add rd 1 |
731 | curposy rd 1 |
731 | curposy rd 1 |
732 | index rd 1 |
732 | index rd 1 |
733 | tasklist rd display_processes |
733 | tasklist rd display_processes |
734 | process_info_buffer process_information |
734 | process_info_buffer process_information |
735 | cur_dir_path rb 1024 |
735 | cur_dir_path rb 1024 |
736 | library_path rb 1024 |
736 | library_path rb 1024 |
737 | 737 | ||
738 | U_END: |
738 | U_END: |