Subversion Repositories Kolibri OS

Rev

Go to most recent revision | 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.     int  0x40
  40.     mov  [socket],eax
  41.     mov  [0],eax                  ; save for remote code
  42.    
  43.     call draw_window            ; at first, draw the window
  44.    
  45. still:
  46.    
  47.     mov  eax,23                 ; wait here for event
  48.     mov  ebx,1
  49.     int  0x40
  50.    
  51.     cmp  eax,1                  ; redraw request ?
  52.     jz   red
  53.     cmp  eax,2                  ; key in buffer ?
  54.     jz   key
  55.     cmp  eax,3                  ; button in buffer ?
  56.     jz   button
  57.    
  58.     mov  eax,53                 ; data from cluster terminal ?
  59.     mov  ebx,2
  60.     mov  ecx,[socket]
  61.     int  0x40
  62.    
  63.     cmp  eax,0
  64.     jne  data_arrived
  65.    
  66.     jmp  still
  67.    
  68. red:
  69.     call draw_window
  70.     jmp  still
  71.    
  72. key:
  73.     mov  eax,2
  74.     int  0x40
  75.     jmp  still
  76.    
  77. button:
  78.    
  79.     mov  eax,53
  80.     mov  ebx,1
  81.     mov  ecx,[socket]
  82.     int  0x40
  83.     mov  eax,-1
  84.     int  0x40
  85.    
  86.    
  87. data_arrived:
  88.    
  89.     mov  eax,5                 ; wait a second for everything to arrive
  90.     mov  ebx,10
  91.     int  0x40
  92.    
  93.     mov  edi,I_END
  94.    
  95.   get_data:
  96.    
  97.     mov  eax,53
  98.     mov  ebx,3
  99.     mov  ecx,[socket]
  100.     int  0x40
  101.    
  102.     mov  [edi],bl
  103.     inc  edi
  104.    
  105.     mov  eax,53
  106.     mov  ebx,2
  107.     mov  ecx,[socket]
  108.     int  0x40
  109.    
  110.     cmp  eax,0
  111.     jne  get_data
  112.    
  113.     cmp  byte [I_END],'C'   ;Connect ?
  114.     jne  no_con
  115.     mov  eax,4
  116.     mov  ebx,10*65536+60
  117.     add  ebx,[y]
  118.     mov  ecx,0x000000
  119.     mov  edx,inp_con
  120.     mov  esi,29
  121.     int  0x40
  122.     add  [y],10
  123.  
  124.     jmp  still
  125.  
  126. no_con:
  127.     cmp  byte [I_END],'S'   ; Shutdown ?
  128.     jne  no_shut
  129.     mov  eax,4
  130.     mov  ebx,10*65536+60
  131.     add  ebx,[y]
  132.     mov  ecx,0x000000
  133.     mov  edx,inp_shut
  134.     mov  esi,26
  135.     int  0x40
  136.     add  [y],10
  137.  
  138.     mov  eax,18
  139.     mov  ebx,9
  140.     mov  ecx,2
  141.     int  0x40
  142.  
  143.     jmp  still
  144.  
  145. no_shut:
  146.     cmp  byte [I_END],'R'   ; Reboot ?
  147.     jne  no_reb
  148.     mov  eax,4
  149.     mov  ebx,10*65536+60
  150.     add  ebx,[y]
  151.     mov  ecx,0x000000
  152.     mov  edx,inp_reb
  153.     mov  esi,20
  154.     int  0x40
  155.     add  [y],10
  156.  
  157.     mov  eax,18
  158.     mov  ebx,9
  159.     mov  ecx,3
  160.     int  0x40
  161.     jmp  still
  162.  
  163. no_reb:
  164.     cmp  byte [I_END],'F'   ; Save image on floppi ?
  165.     jne  no_savefi
  166.     mov  eax,4
  167.     mov  ebx,10*65536+60
  168.     add  ebx,[y]
  169.     mov  ecx,0x000000
  170.     mov  edx,inp_savefi
  171.     mov  esi,29
  172.     int  0x40
  173.     add  [y],10
  174.  
  175.     mov  eax,18
  176.     mov  ebx,9
  177.     mov  ecx,1
  178.     int  0x40
  179.     jmp  still
  180.  
  181. no_savefi:
  182.     cmp  byte [I_END],'H'   ; Save image on hard disk ?
  183.     jne  no_savehi
  184.     mov  eax,4
  185.     mov  ebx,10*65536+60
  186.     add  ebx,[y]
  187.     mov  ecx,0x000000
  188.     mov  edx,inp_savehi
  189.     mov  esi,29
  190.     int  0x40
  191.     add  [y],10
  192.  
  193.     mov  eax,18
  194.     mov  ebx,6
  195.     mov  ecx,2
  196.     int  0x40
  197.  
  198.     jmp  still
  199.  
  200. no_savehi:
  201.     cmp  byte [I_END],'O'   ; Hot reboot ?
  202.     jne  no_hotreb
  203.     mov  eax,4
  204.     mov  ebx,10*65536+60
  205.     add  ebx,[y]
  206.     mov  ecx,0x000000
  207.     mov  edx,inp_hotreb
  208.     mov  esi,28
  209.     int  0x40
  210.     add  [y],10
  211.  
  212.     mov  eax,18
  213.     mov  ebx,9
  214.     mov  ecx,4
  215.     int  0x40
  216.     jmp  still
  217.  
  218. no_hotreb:
  219.     cmp  byte [I_END],'E'   ; Unload server ?
  220.     jne  no_com
  221.     mov  eax,4
  222.     mov  ebx,10*65536+60
  223.     add  ebx,[y]
  224.     mov  ecx,0x000000
  225.     mov  edx,inp_exit
  226.     mov  esi,28
  227.     int  0x40
  228.     add  [y],10
  229.    
  230.     call button
  231.     jmp  still
  232.  
  233. no_com:
  234.     mov  eax,4
  235.     mov  ebx,10*65536+60
  236.     add  ebx,[y]
  237.     mov  ecx,0x000000
  238.     mov  edx,inp_com
  239.     mov  esi,22
  240.     int  0x40
  241.     add  [y],10
  242.  
  243.     jmp  still
  244.    
  245. ;   *********************************************
  246. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  247. ;   *********************************************
  248.    
  249.    
  250. draw_window:
  251.    
  252.     mov  eax,12                    ; function 12:tell os about windowdraw
  253.     mov  ebx,1                     ; 1, start of draw
  254.     int  0x40
  255.    
  256.                                    ; DRAW WINDOW
  257.     mov  eax,0                     ; function 0 : define and draw window
  258.     mov  ebx,100*65536+300         ; [x start] *65536 + [x size]
  259.     mov  ecx,100*65536+330         ; [y start] *65536 + [y size]
  260.     mov  edx,0x03ffffff            ; color of work area RRGGBB
  261.     mov  esi,0x80aabbcc            ; color of grab bar  RRGGBB,8->color gl
  262.     mov  edi,0x00aabbcc            ; color of frames    RRGGBB
  263.     int  0x40
  264.    
  265.     mov  eax,8
  266.     mov  ebx,(286-19)*65536+12
  267.     mov  ecx,4*65536+12
  268.     mov  edx,1
  269.     mov  esi,0xaabbcc
  270. ;    int  0x40
  271.    
  272.                                    ; WINDOW LABEL
  273.     mov  eax,4                     ; function 4 : write text to window
  274.     mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
  275.     mov  ecx,0x00ffffff            ; color of text RRGGBB
  276.     mov  edx,labeltext             ; pointer to text beginning
  277.     mov  esi,lte-labeltext         ; text length
  278.     int  0x40
  279.    
  280.     ; Re-draw the screen text
  281.     cld
  282.     mov  ebx,10*65536+30           ; draw info text with function 4
  283.     mov  ecx,0x000000
  284.     mov  edx,text
  285.     mov  esi,40
  286.   newline:
  287.     mov  eax,4
  288.     int  0x40
  289.     add  ebx,16
  290.     add  edx,40
  291.     cmp  [edx],byte 'x'
  292.     jnz  newline
  293.    
  294.    
  295.     mov  eax,12                    ; function 12:tell os about windowdraw
  296.     mov  ebx,2                     ; 2, end of draw
  297.     int  0x40
  298.    
  299.     ret
  300.    
  301.    
  302. ; DATA AREA
  303.    
  304.    
  305. text:
  306.     db '„ ­­ë©  ¤à¥á        : 192.168.0.2       '
  307.     db 'à®á«ã訢 ¥¬ë© ¯®àâ : 0x6100            '
  308.     db '‘®áâ®ï­¨¥:                              '
  309.     db 'x <- END MARKER, DONT DELETE            '
  310.    
  311.    
  312. labeltext:  db  'Remote Control Center(Server)'
  313. lte:
  314.    
  315. socket   dd  0x0
  316. y   dd   0x10
  317. sysclock dd 0x0
  318.  
  319. inp_con db '‚­¨¬ ­¨¥, ¯®¤ª«î稫áï ª«¨¥­â!'
  320. inp_shut db 'ˆ¤ñ⠮⪫î祭¨¥ á¨á⥬ë...'
  321. inp_reb db 'ˆ¤ñâ ¯¥à¥§ £à㧪 ...'
  322. inp_savefi db '‘®å࠭塞 ¨¬¥¤¦ ­  ¤¨áª¥âã...'
  323. inp_savehi db '‘®å࠭塞 ¨¬¥¤¦ ­  †. ¤¨áª...'
  324. inp_hotreb db 'ˆ¤ñâ £®àï稩 à¥áâ àâ ï¤à ...'
  325. inp_exit db '‚ë室 ¨§ ¯à®£à ¬¬ë...'
  326. inp_com db '¥®¯®§­ ­­ ï ª®¬¬ ­¤ !'
  327. I_END:
  328.    
  329.    
  330.    
  331.    
  332.    
  333.    
  334.