Subversion Repositories Kolibri OS

Rev

Rev 31 | 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
 
19
                db      'MENUET00'              ; 8 byte id
20
                dd      38                      ; required os
21
                dd      START                   ; program start
22
                dd      I_END                   ; program image size
23
                dd      0x100000                ; required amount of memory
24
                dd      0x00000000              ; reserved=no extended header
25
 
26
include 'lang.inc'
27
include 'macros.inc'
28
 
29
START:                                  ; start of execution
30
 
31
    mov  eax,53                ; open socket
32
    mov  ebx,0
33
    mov  ecx,0x4000            ; local port
34
    mov  edx,0x5000            ; remote port
35
    mov  esi,dword [remote_ip]   ; node IP
36
    int  0x40
37
 
38
    mov  [socketNum], eax
39
 
40
    call draw_window            ; at first, draw the window
41
 
42
still:
43
 
44
    mov  eax,23                 ; wait here for event
45
    mov  ebx,1
46
    int  0x40
47
 
48
    cmp  eax,1                  ; redraw request ?
49
    jz   red
50
    cmp  eax,2                  ; key in buffer ?
51
    jz   key
52
    cmp  eax,3                  ; button in buffer ?
53
    jz   button
54
 
55
    jmp  still
56
 
57
red:
58
    call draw_window
59
    jmp  still
60
 
61
key:
62
    mov  eax,2
63
    int  0x40
64
    jmp  still
65
 
66
button:
67
    mov  eax,17
68
    int  0x40
69
 
70
    cmp  ah,1                  ; button id=1 ?
71
    jnz  noclose
72
    mov  eax, 53
73
    mov  ebx, 1
74
    mov  ecx, [socketNum]
75
    int  0x40
76
    mov  eax,-1
77
    int  0x40
78
  noclose:
79
 
80
    cmp  ah,2                  ; SEND CODE ?
81
    je   send_xcode
82
 
83
 
84
    jmp  still
85
 
86
 
87
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
88
;;                                              ;;
89
;;           SEND CODE TO REMOTE                ;;
90
;;                                              ;;
91
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
92
 
93
send_xcode:
94
 
95
  mov  esi,send_data              ; header
96
  mov  edi,I_END
97
  mov  ecx,end_message-send_data
98
  cld
99
  rep  movsb
100
 
101
  mov  eax,53                     ; SEND CODE TO REMOTE
102
  mov  ebx,4
103
  mov  ecx,[socketNum]
104
  mov  edx,end_message-send_data
105
  mov  esi,I_END
106
  int  0x40
107
 
108
  jmp  still
109
 
110
 
111
;   *********************************************
112
;   *******  WINDOW DEFINITIONS AND DRAW ********
113
;   *********************************************
114
 
115
 
116
draw_window:
117
 
118
    mov  eax,12                    ; function 12:tell os about windowdraw
119
    mov  ebx,1                     ; 1, start of draw
120
    int  0x40
121
 
122
                                   ; DRAW WINDOW
123
    mov  eax,0                     ; function 0 : define and draw window
124
    mov  ebx,100*65536+250         ; [x start] *65536 + [x size]
125
    mov  ecx,60*65536+150          ; [y start] *65536 + [y size]
126
    mov  edx,0x03ffffff            ; color of work area RRGGBB
127
    mov  esi,0x80aabbcc            ; color of grab bar  RRGGBB,8->color gl
128
    mov  edi,0x00aabbcc            ; color of frames    RRGGBB
129
    int  0x40
130
 
131
                                   ; WINDOW LABEL
132
    mov  eax,4                     ; function 4 : write text to window
133
    mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
134
    mov  ecx,0x00ffffff            ; color of text RRGGBB
135
    mov  edx,labeltext             ; pointer to text beginning
136
    mov  esi,lte-labeltext         ; text length
137
    int  0x40
138
 
139
    mov  eax,8                     ; SEND MESSAGE
140
    mov  ebx,50*65536+145
141
    mov  ecx,47*65536+13
142
    mov  edx,2
143
    mov  esi,0x667788
144
    int  0x40
145
 
146
    cld
147
    mov  ebx,25*65536+50           ; draw info text with function 4
148
    mov  ecx,0x000000
149
    mov  edx,text
150
    mov  esi,40
151
  newline:
152
    mov  eax,4
153
    int  0x40
154
    add  ebx,16
155
    add  edx,40
156
    cmp  [edx],byte 'x'
157
    jnz  newline
158
 
159
    mov  eax,12                    ; function 12:tell os about windowdraw
160
    mov  ebx,2                     ; 2, end of draw
161
    int  0x40
162
 
163
    ret
164
 
165
 
166
; DATA AREA
167
 
168
 
169
text:
170
    db '        Послать сообщение               '
171
    db '                                        '
172
    db ' Локальный адрес : 192.168.0.1          '
173
    db ' Удалённый адрес : 192.168.0.2          '
174
    db 'Текст и адрес в конце исходника         '
175
    db 'x <- END MARKER, DONT DELETE            '
176
 
177
 
178
labeltext:  db  'NetSend(Client)'  ;
179
lte:
180
 
181
socketNum   dd  0x0
182
 
183
remote_ip  db  192,168,1,2
184
 
185
picture_position dd 0x0
186
 
187
send_data   db  'Привет,это тест!Hello,this is a test!'
188
end_message:
189
 
190
 
191
I_END:
192