Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
31 halyavin 1
;
2
;    NetSend(Client)
3
;
4
;    Автор: Hex
5
;    Сайт: www.mestack.narod.ru
6
;
7
;    Описание:
8
;    Программа для обмена сообщениями в сети.Клиентская часть.
9
;
10
;    Compile with FASM for Menuet
11
;    Компилируется FASM'ом для Менуэт ОС
12
;
13
 
14
 
15
use32
16
 
17
                org     0x0
18
 
131 diamond 19
                db      'MENUET01'              ; 8 byte id
20
                dd      1                       ; header version
31 halyavin 21
                dd      START                   ; program start
22
                dd      I_END                   ; program image size
131 diamond 23
                dd      mem                     ; required amount of memory
24
                dd      mem                     ; stack pointer
25
                dd      0, 0                    ; param, icon
26
 
27
include 'lang.inc'
485 heavyiron 28
include '..\..\..\macros.inc'
31 halyavin 29
 
30
START:                                  ; start of execution
31
 
32
    mov  eax,53                ; open socket
33
    mov  ebx,0
34
    mov  ecx,0x4000            ; local port
35
    mov  edx,0x5000            ; remote port
36
    mov  esi,dword [remote_ip]   ; node IP
485 heavyiron 37
    mcall
31 halyavin 38
 
39
    mov  [socketNum], eax
131 diamond 40
 
41
red:
31 halyavin 42
    call draw_window            ; at first, draw the window
43
 
44
still:
45
 
131 diamond 46
    mov  eax,10                 ; wait here for event
485 heavyiron 47
    mcall
131 diamond 48
 
49
    dec  eax
31 halyavin 50
    jz   red
131 diamond 51
    dec  eax
52
    jnz  button
53
 
31 halyavin 54
key:
131 diamond 55
    mov  al,2
485 heavyiron 56
    mcall
31 halyavin 57
    jmp  still
58
 
59
button:
131 diamond 60
    mov  al,17
485 heavyiron 61
    mcall
31 halyavin 62
 
131 diamond 63
    dec  ah                    ; button id=1 ?
31 halyavin 64
    jnz  noclose
65
    mov  eax, 53
66
    mov  ebx, 1
67
    mov  ecx, [socketNum]
485 heavyiron 68
    mcall
69
    or  eax,-1
70
    mcall
31 halyavin 71
  noclose:
131 diamond 72
; it was not close button, so it must be send code button
31 halyavin 73
 
74
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
75
;;                                              ;;
76
;;           SEND CODE TO REMOTE                ;;
77
;;                                              ;;
78
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
79
 
80
send_xcode:
81
 
82
  mov  eax,53                     ; SEND CODE TO REMOTE
83
  mov  ebx,4
84
  mov  ecx,[socketNum]
85
  mov  edx,end_message-send_data
131 diamond 86
  mov  esi,send_data
485 heavyiron 87
  mcall
131 diamond 88
 
31 halyavin 89
  jmp  still
90
 
91
 
92
;   *********************************************
93
;   *******  WINDOW DEFINITIONS AND DRAW ********
94
;   *********************************************
95
 
96
 
97
draw_window:
98
 
99
    mov  eax,12                    ; function 12:tell os about windowdraw
100
    mov  ebx,1                     ; 1, start of draw
485 heavyiron 101
    mcall
31 halyavin 102
 
103
                                   ; DRAW WINDOW
104
    mov  eax,0                     ; function 0 : define and draw window
105
    mov  ebx,100*65536+250         ; [x start] *65536 + [x size]
106
    mov  ecx,60*65536+150          ; [y start] *65536 + [y size]
485 heavyiron 107
    mov  edx,0x13ffffff            ; color of work area RRGGBB
108
    mov  edi,title                 ; WINDOW LABEL
109
    mcall
31 halyavin 110
 
111
 
112
    mov  eax,8                     ; SEND MESSAGE
113
    mov  ebx,50*65536+145
114
    mov  ecx,47*65536+13
115
    mov  edx,2
116
    mov  esi,0x667788
485 heavyiron 117
    mcall
31 halyavin 118
 
485 heavyiron 119
    mov  eax,4
31 halyavin 120
    mov  ebx,25*65536+50           ; draw info text with function 4
121
    mov  ecx,0x000000
122
    mov  edx,text
123
    mov  esi,40
124
  newline:
485 heavyiron 125
    mcall
31 halyavin 126
    add  ebx,16
131 diamond 127
    add  edx,esi
31 halyavin 128
    cmp  [edx],byte 'x'
129
    jnz  newline
130
 
131
    mov  eax,12                    ; function 12:tell os about windowdraw
132
    mov  ebx,2                     ; 2, end of draw
485 heavyiron 133
    mcall
31 halyavin 134
 
135
    ret
136
 
137
 
138
; DATA AREA
139
 
131 diamond 140
if lang eq ru
31 halyavin 141
text:
142
    db '        Послать сообщение               '
143
    db '                                        '
144
    db ' Локальный адрес : 192.168.0.1          '
145
    db ' Удалённый адрес : 192.168.0.2          '
146
    db 'Текст и адрес в конце исходника         '
131 diamond 147
    db 'x' ; <- END MARKER, DONT DELETE
148
else
149
text:
150
    db '          Send message                  '
151
    db '                                        '
152
    db ' Local  address : 192.168.0.1           '
153
    db ' Remote address : 192.168.0.2           '
154
    db 'Text and address in end of source       '
155
    db 'x' ; <- END MARKER, DONT DELETE
156
end if
31 halyavin 157
 
485 heavyiron 158
title  db  'NetSend(Client)',0
31 halyavin 159
 
160
remote_ip  db  192,168,1,2
161
 
162
send_data   db  'Привет,это тест!Hello,this is a test!'
163
end_message:
164
 
165
 
166
I_END:
131 diamond 167
align 4
168
socketNum dd ?
169
 
170
rb 32 ; this is for stack
171
 
172
mem:
173