Subversion Repositories Kolibri OS

Rev

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

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