Subversion Repositories Kolibri OS

Rev

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

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