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