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