Subversion Repositories Kolibri OS

Rev

Rev 485 | Blame | Last modification | View Log | Download | RSS feed

  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'
  28. include '..\..\..\macros.inc'
  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
  39.     mcall
  40.     mov  [socket],eax
  41.     mov  [0],eax                  ; save for remote code
  42.  
  43. red:  
  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
  50.     mcall
  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]
  62.     mcall
  63.    
  64.     cmp  eax,0
  65.     jne  data_arrived
  66.    
  67.     jmp  still
  68.    
  69. key:
  70.     mov  eax,2
  71.     mcall
  72.     jmp  still
  73.    
  74. button:
  75.    
  76.     mov  eax,53
  77.     mov  ebx,1
  78.     mov  ecx,[socket]
  79.     mcall
  80.     or  eax,-1
  81.     mcall
  82.    
  83.    
  84. data_arrived:
  85.    
  86.     mov  eax,5                 ; wait a second for everything to arrive
  87.     mov  ebx,10
  88.     mcall
  89.    
  90.     mov  edi,I_END
  91.    
  92.   get_data:
  93.    
  94.     mov  eax,53
  95.     mov  ebx,3
  96.     mov  ecx,[socket]
  97.     mcall
  98.    
  99.     mov  [edi],bl
  100.     inc  edi
  101.    
  102.     mov  eax,53
  103.     mov  ebx,2
  104.     mov  ecx,[socket]
  105.     mcall
  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
  117.     mov  esi,inp_con.len
  118.     mcall
  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
  131.     mov  esi,inp_shut.len
  132.     mcall
  133.     add  [y],10
  134.  
  135.     mov  eax,18
  136.     mov  ebx,9
  137.     mov  ecx,2
  138.     mcall
  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
  150.     mov  esi,inp_reb.len
  151.     mcall
  152.     add  [y],10
  153.  
  154.     mov  eax,18
  155.     mov  ebx,9
  156.     mov  ecx,3
  157.     mcall
  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
  168.     mov  esi,inp_savefi.len
  169.     mcall
  170.     add  [y],10
  171.  
  172.     mov  eax,18
  173.     mov  ebx,9
  174.     mov  ecx,1
  175.     mcall
  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
  186.     mov  esi,inp_savehi.len
  187.     mcall
  188.     add  [y],10
  189.  
  190.     mov  eax,18
  191.     mov  ebx,6
  192.     mov  ecx,2
  193.     mcall
  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
  205.     mov  esi,inp_hotreb.len
  206.     mcall
  207.     add  [y],10
  208.  
  209.     mov  eax,18
  210.     mov  ebx,9
  211.     mov  ecx,4
  212.     mcall
  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
  223.     mov  esi,inp_exit.len
  224.     mcall
  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
  236.     mov  esi,inp_com.len
  237.     mcall
  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
  251.     mcall
  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]
  257.     mov  edx,0x14ffffff            ; color of work area RRGGBB
  258.     mov  edi,title                 ; WINDOW LABEL
  259.     mcall
  260.    
  261.    
  262.     ; Re-draw the screen text
  263.     cld
  264.     mov  eax,4
  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:
  270.     mcall
  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
  279.     mcall
  280.    
  281.     ret
  282.    
  283.    
  284. ; DATA AREA
  285.    
  286.    
  287. text:
  288. if lang eq ru
  289.     db '„ ­­ë©  ¤à¥á        : 192.168.0.2       '
  290.     db 'à®á«ã訢 ¥¬ë© ¯®àâ : 0x6100            '
  291.     db '‘®áâ®ï­¨¥:                              '
  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
  299.    
  300. title  db  'Remote Control Center(Server)',0
  301.    
  302. socket   dd  0x0
  303. y   dd   0x10
  304. sysclock dd 0x0
  305.  
  306. if lang eq ru
  307. inp_con db '‚­¨¬ ­¨¥, ¯®¤ª«î稫áï ª«¨¥­â!'
  308. .len = $-inp_con
  309. inp_shut db 'ˆ¤ñ⠮⪫î祭¨¥ á¨á⥬ë...'
  310. .len = $-inp_shut
  311. inp_reb db 'ˆ¤ñâ ¯¥à¥§ £à㧪 ...'
  312. .len = $-inp_reb
  313. inp_savefi db '‘®å࠭塞 ¨¬¥¤¦ ­  ¤¨áª¥âã...'
  314. .len = $-inp_savefi
  315. inp_savehi db '‘®å࠭塞 ¨¬¥¤¦ ­  †. ¤¨áª...'
  316. .len = $-inp_savehi
  317. inp_hotreb db 'ˆ¤ñâ £®àï稩 à¥áâ àâ ï¤à ...'
  318. .len = $-inp_hotreb
  319. inp_exit db '‚ë室 ¨§ ¯à®£à ¬¬ë...'
  320. .len = $-inp_exit
  321. inp_com db '¥®¯®§­ ­­ ï ª®¬¬ ­¤ !'
  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
  341. I_END:
  342.