Subversion Repositories Kolibri OS

Rev

Rev 485 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;
2
;    Remote Control Center(Server)
3
;
4
;    Автор: Hex
5
;    Сайт: www.mestack.narod.ru
6
;
7
;    Описание:
8
;    Программа, предназначенная для управления удалённым компьютером.Серверная
9
;    часть.
10
;
11
;    Compile with FASM for Menuet
12
;    Компилируется FASM'ом для Менуэт ОС
13
;
14
 
15
use32
16
 
17
                org     0x0
18
 
19
 	        db     'MENUET01'      ; 8 byte id
20
  	        dd     0x01            ; header version
21
 	        dd     START           ; start of code
22
  	        dd     I_END           ; size of image
23
  	        dd     0x5000          ; memory for app
24
  	        dd     0x5000          ; esp
25
  	        dd     0x0 , 0x0       ; I_Param , I_Icon
26
 
27
include 'lang.inc'
485 heavyiron 28
include '..\..\..\macros.inc'
31 halyavin 29
remote_ip  db  192,168,0,1
30
 
31
 
32
START:                      ; start of execution
33
 
34
    mov  eax, 53                  ; open receiver socket
35
    mov  ebx, 0
36
    mov  ecx, 0x6100              ; local port
37
    mov  edx, 0x6000              ; remote port
38
    mov  esi, dword [remote_ip]   ; remote IP
485 heavyiron 39
    mcall
31 halyavin 40
    mov  [socket],eax
41
    mov  [0],eax                  ; save for remote code
485 heavyiron 42
 
43
red:
31 halyavin 44
    call draw_window            ; at first, draw the window
45
 
46
still:
47
 
48
    mov  eax,23                 ; wait here for event
49
    mov  ebx,1
485 heavyiron 50
    mcall
31 halyavin 51
 
52
    cmp  eax,1                  ; redraw request ?
53
    jz   red
54
    cmp  eax,2                  ; key in buffer ?
55
    jz   key
56
    cmp  eax,3                  ; button in buffer ?
57
    jz   button
58
 
59
    mov  eax,53                 ; data from cluster terminal ?
60
    mov  ebx,2
61
    mov  ecx,[socket]
485 heavyiron 62
    mcall
31 halyavin 63
 
64
    cmp  eax,0
65
    jne  data_arrived
66
 
67
    jmp  still
68
 
69
key:
70
    mov  eax,2
485 heavyiron 71
    mcall
31 halyavin 72
    jmp  still
73
 
74
button:
75
 
76
    mov  eax,53
77
    mov  ebx,1
78
    mov  ecx,[socket]
485 heavyiron 79
    mcall
80
    or  eax,-1
81
    mcall
31 halyavin 82
 
83
 
84
data_arrived:
85
 
86
    mov  eax,5                 ; wait a second for everything to arrive
87
    mov  ebx,10
485 heavyiron 88
    mcall
31 halyavin 89
 
90
    mov  edi,I_END
91
 
92
  get_data:
93
 
94
    mov  eax,53
95
    mov  ebx,3
96
    mov  ecx,[socket]
485 heavyiron 97
    mcall
31 halyavin 98
 
99
    mov  [edi],bl
100
    inc  edi
101
 
102
    mov  eax,53
103
    mov  ebx,2
104
    mov  ecx,[socket]
485 heavyiron 105
    mcall
31 halyavin 106
 
107
    cmp  eax,0
108
    jne  get_data
109
 
110
    cmp  byte [I_END],'C'   ;Connect ?
111
    jne  no_con
112
    mov  eax,4
113
    mov  ebx,10*65536+60
114
    add  ebx,[y]
115
    mov  ecx,0x000000
116
    mov  edx,inp_con
132 diamond 117
    mov  esi,inp_con.len
485 heavyiron 118
    mcall
31 halyavin 119
    add  [y],10
120
 
121
    jmp  still
122
 
123
no_con:
124
    cmp  byte [I_END],'S'   ; Shutdown ?
125
    jne  no_shut
126
    mov  eax,4
127
    mov  ebx,10*65536+60
128
    add  ebx,[y]
129
    mov  ecx,0x000000
130
    mov  edx,inp_shut
132 diamond 131
    mov  esi,inp_shut.len
485 heavyiron 132
    mcall
31 halyavin 133
    add  [y],10
134
 
135
    mov  eax,18
136
    mov  ebx,9
137
    mov  ecx,2
485 heavyiron 138
    mcall
31 halyavin 139
 
140
    jmp  still
141
 
142
no_shut:
143
    cmp  byte [I_END],'R'   ; Reboot ?
144
    jne  no_reb
145
    mov  eax,4
146
    mov  ebx,10*65536+60
147
    add  ebx,[y]
148
    mov  ecx,0x000000
149
    mov  edx,inp_reb
132 diamond 150
    mov  esi,inp_reb.len
485 heavyiron 151
    mcall
31 halyavin 152
    add  [y],10
153
 
154
    mov  eax,18
155
    mov  ebx,9
156
    mov  ecx,3
485 heavyiron 157
    mcall
31 halyavin 158
    jmp  still
159
 
160
no_reb:
161
    cmp  byte [I_END],'F'   ; Save image on floppi ?
162
    jne  no_savefi
163
    mov  eax,4
164
    mov  ebx,10*65536+60
165
    add  ebx,[y]
166
    mov  ecx,0x000000
167
    mov  edx,inp_savefi
132 diamond 168
    mov  esi,inp_savefi.len
485 heavyiron 169
    mcall
31 halyavin 170
    add  [y],10
171
 
172
    mov  eax,18
173
    mov  ebx,9
174
    mov  ecx,1
485 heavyiron 175
    mcall
31 halyavin 176
    jmp  still
177
 
178
no_savefi:
179
    cmp  byte [I_END],'H'   ; Save image on hard disk ?
180
    jne  no_savehi
181
    mov  eax,4
182
    mov  ebx,10*65536+60
183
    add  ebx,[y]
184
    mov  ecx,0x000000
185
    mov  edx,inp_savehi
132 diamond 186
    mov  esi,inp_savehi.len
485 heavyiron 187
    mcall
31 halyavin 188
    add  [y],10
189
 
190
    mov  eax,18
191
    mov  ebx,6
192
    mov  ecx,2
485 heavyiron 193
    mcall
31 halyavin 194
 
195
    jmp  still
196
 
197
no_savehi:
198
    cmp  byte [I_END],'O'   ; Hot reboot ?
199
    jne  no_hotreb
200
    mov  eax,4
201
    mov  ebx,10*65536+60
202
    add  ebx,[y]
203
    mov  ecx,0x000000
204
    mov  edx,inp_hotreb
132 diamond 205
    mov  esi,inp_hotreb.len
485 heavyiron 206
    mcall
31 halyavin 207
    add  [y],10
208
 
209
    mov  eax,18
210
    mov  ebx,9
211
    mov  ecx,4
485 heavyiron 212
    mcall
31 halyavin 213
    jmp  still
214
 
215
no_hotreb:
216
    cmp  byte [I_END],'E'   ; Unload server ?
217
    jne  no_com
218
    mov  eax,4
219
    mov  ebx,10*65536+60
220
    add  ebx,[y]
221
    mov  ecx,0x000000
222
    mov  edx,inp_exit
132 diamond 223
    mov  esi,inp_exit.len
485 heavyiron 224
    mcall
31 halyavin 225
    add  [y],10
226
 
227
    call button
228
    jmp  still
229
 
230
no_com:
231
    mov  eax,4
232
    mov  ebx,10*65536+60
233
    add  ebx,[y]
234
    mov  ecx,0x000000
235
    mov  edx,inp_com
132 diamond 236
    mov  esi,inp_com.len
485 heavyiron 237
    mcall
31 halyavin 238
    add  [y],10
239
 
240
    jmp  still
241
 
242
;   *********************************************
243
;   *******  WINDOW DEFINITIONS AND DRAW ********
244
;   *********************************************
245
 
246
 
247
draw_window:
248
 
249
    mov  eax,12                    ; function 12:tell os about windowdraw
250
    mov  ebx,1                     ; 1, start of draw
485 heavyiron 251
    mcall
31 halyavin 252
 
253
                                   ; DRAW WINDOW
254
    mov  eax,0                     ; function 0 : define and draw window
255
    mov  ebx,100*65536+300         ; [x start] *65536 + [x size]
256
    mov  ecx,100*65536+330         ; [y start] *65536 + [y size]
551 spraid 257
    mov  edx,0x14ffffff            ; color of work area RRGGBB
485 heavyiron 258
    mov  edi,title                 ; WINDOW LABEL
259
    mcall
31 halyavin 260
 
261
 
262
    ; Re-draw the screen text
263
    cld
485 heavyiron 264
    mov  eax,4
31 halyavin 265
    mov  ebx,10*65536+30           ; draw info text with function 4
266
    mov  ecx,0x000000
267
    mov  edx,text
268
    mov  esi,40
269
  newline:
485 heavyiron 270
    mcall
31 halyavin 271
    add  ebx,16
272
    add  edx,40
273
    cmp  [edx],byte 'x'
274
    jnz  newline
275
 
276
 
277
    mov  eax,12                    ; function 12:tell os about windowdraw
278
    mov  ebx,2                     ; 2, end of draw
485 heavyiron 279
    mcall
31 halyavin 280
 
281
    ret
282
 
283
 
284
; DATA AREA
285
 
286
 
287
text:
132 diamond 288
if lang eq ru
31 halyavin 289
    db 'Данный адрес        : 192.168.0.2       '
290
    db 'Прослушиваемый порт : 0x6100            '
291
    db 'Состояние:                              '
132 diamond 292
    db 'x' ; <- END MARKER, DONT DELETE
293
else
294
    db 'This address        : 192.168.0.2       '
295
    db 'Used port           : 0x6100            '
296
    db 'Status:                                 '
297
    db 'x' ; <- END MARKER, DONT DELETE
298
end if
31 halyavin 299
 
485 heavyiron 300
title  db  'Remote Control Center(Server)',0
31 halyavin 301
 
302
socket   dd  0x0
303
y   dd   0x10
304
sysclock dd 0x0
305
 
132 diamond 306
if lang eq ru
31 halyavin 307
inp_con db 'Внимание, подключился клиент!'
132 diamond 308
.len = $-inp_con
31 halyavin 309
inp_shut db 'Идёт отключение системы...'
132 diamond 310
.len = $-inp_shut
31 halyavin 311
inp_reb db 'Идёт перезагрузка...'
132 diamond 312
.len = $-inp_reb
31 halyavin 313
inp_savefi db 'Сохраняем имедж на дискету...'
132 diamond 314
.len = $-inp_savefi
31 halyavin 315
inp_savehi db 'Сохраняем имедж на Ж. диск...'
132 diamond 316
.len = $-inp_savehi
31 halyavin 317
inp_hotreb db 'Идёт горячий рестарт ядра...'
132 diamond 318
.len = $-inp_hotreb
31 halyavin 319
inp_exit db 'Выход из программы...'
132 diamond 320
.len = $-inp_exit
31 halyavin 321
inp_com db 'Неопознанная комманда!'
132 diamond 322
.len = $-inp_com
323
else
324
inp_con db 'Note, client has been connected!'
325
.len = $-inp_con
326
inp_shut db 'Turn off in progress...'
327
.len = $-inp_shut
328
inp_reb db 'Reboot in progress...'
329
.len = $-inp_reb
330
inp_savefi db 'Saving image to floppy...'
331
.len = $-inp_savefi
332
inp_savehi db 'Saving image to hard disk...'
333
.len = $-inp_savehi
334
inp_hotreb db 'Kernel restart in progress...'
335
.len = $-inp_hotreb
336
inp_exit db 'Exiting from program...'
337
.len = $-inp_exit
338
inp_com db 'Unknown command!'
339
.len = $-inp_com
340
end if
31 halyavin 341
I_END: