Subversion Repositories Kolibri OS

Rev

Rev 1373 | Rev 1385 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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