Subversion Repositories Kolibri OS

Rev

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

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