Rev 109 | 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(Server) |
||
3 | ; |
||
4 | ; Автор: Hex |
||
5 | ; Сайт: www.mestack.narod.ru |
||
6 | ; |
||
7 | ; Описание: |
||
8 | ; Программа для обмена сообщениями в сети.Серверная часть. |
||
9 | ; |
||
10 | ; Compile with FASM for Menuet |
||
11 | ; Компилируется FASM'ом для Менуэт ОС |
||
12 | ; |
||
13 | |||
14 | use32 |
||
15 | |||
16 | org 0x0 |
||
17 | |||
18 | db 'MENUET00' ; 8 byte id |
||
19 | dd 38 ; required os |
||
20 | dd START ; program start |
||
21 | dd I_END ; program image size |
||
22 | dd 0x100000 ; required amount of memory |
||
23 | dd 0x00000000 ; reserved=no extended header |
||
24 | |||
25 | include 'lang.inc' |
||
26 | include 'macros.inc' |
||
27 | remote_ip db 192,168,0,1 |
||
28 | |||
29 | |||
30 | START: ; start of execution |
||
31 | |||
32 | mov eax, 53 ; open receiver socket |
||
33 | mov ebx, 0 |
||
34 | mov ecx, 0x5000 ; local port |
||
35 | mov edx, 0xffff ; remote port |
||
36 | mov esi, dword [remote_ip] ; remote IP |
||
37 | int 0x40 |
||
38 | mov [socketNum],eax |
||
39 | mov [0],eax ; save for remote code |
||
40 | |||
41 | call draw_window ; at first, draw the window |
||
42 | |||
43 | still: |
||
44 | |||
45 | mov eax,23 ; wait here for event |
||
46 | mov ebx,1 |
||
47 | int 0x40 |
||
48 | |||
49 | cmp eax,1 ; redraw request ? |
||
50 | jz red |
||
51 | cmp eax,2 ; key in buffer ? |
||
52 | jz key |
||
53 | cmp eax,3 ; button in buffer ? |
||
54 | jz button |
||
55 | |||
56 | mov eax,53 ; data from cluster terminal ? |
||
57 | mov ebx,2 |
||
58 | mov ecx,[socketNum] |
||
59 | int 0x40 |
||
60 | |||
61 | cmp eax,0 |
||
62 | jne data_arrived |
||
63 | |||
64 | jmp still |
||
65 | |||
66 | red: |
||
67 | call draw_window |
||
68 | jmp still |
||
69 | |||
70 | key: |
||
71 | mov eax,2 |
||
72 | int 0x40 |
||
73 | jmp still |
||
74 | |||
75 | button: |
||
76 | |||
77 | mov eax,53 |
||
78 | mov ebx,1 |
||
79 | mov ecx,[socketNum] |
||
80 | int 0x40 |
||
81 | mov eax,-1 |
||
82 | int 0x40 |
||
83 | |||
84 | |||
85 | data_arrived: |
||
86 | |||
87 | mov eax,5 ; wait a second for everything to arrive |
||
88 | mov ebx,10 |
||
89 | int 0x40 |
||
90 | |||
91 | mov edi,I_END |
||
92 | |||
93 | get_data: |
||
94 | |||
95 | mov eax,53 |
||
96 | mov ebx,3 |
||
97 | mov ecx,[socketNum] |
||
98 | int 0x40 |
||
99 | |||
100 | mov [edi],bl |
||
101 | inc edi |
||
102 | |||
103 | mov eax,53 |
||
104 | mov ebx,2 |
||
105 | mov ecx,[socketNum] |
||
106 | int 0x40 |
||
107 | |||
108 | cmp eax,0 |
||
109 | jne get_data |
||
110 | |||
111 | mov eax,4 |
||
112 | mov ebx,10*65536+60 |
||
113 | add ebx,[y] |
||
114 | mov ecx,0x000000 |
||
115 | mov edx,I_END |
||
116 | mov esi,100 |
||
117 | int 0x40 |
||
118 | |||
119 | add [y],10 |
||
120 | |||
121 | jmp still |
||
122 | |||
123 | y dd 0x10 |
||
124 | |||
125 | |||
126 | |||
127 | ; ********************************************* |
||
128 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
||
129 | ; ********************************************* |
||
130 | |||
131 | |||
132 | draw_window: |
||
133 | |||
134 | mov eax,12 ; function 12:tell os about windowdraw |
||
135 | mov ebx,1 ; 1, start of draw |
||
136 | int 0x40 |
||
137 | |||
138 | ; DRAW WINDOW |
||
139 | mov eax,0 ; function 0 : define and draw window |
||
140 | mov ebx,100*65536+300 ; [x start] *65536 + [x size] |
||
141 | mov ecx,100*65536+330 ; [y start] *65536 + [y size] |
||
142 | mov edx,0x03ffffff ; color of work area RRGGBB |
||
143 | mov esi,0x80aabbcc ; color of grab bar RRGGBB,8->color gl |
||
144 | mov edi,0x00aabbcc ; color of frames RRGGBB |
||
145 | int 0x40 |
||
146 | |||
147 | mov eax,8 |
||
148 | mov ebx,(286-19)*65536+12 |
||
149 | mov ecx,4*65536+12 |
||
150 | mov edx,1 |
||
151 | mov esi,0xaabbcc |
||
152 | ; int 0x40 |
||
153 | |||
154 | ; WINDOW LABEL |
||
155 | mov eax,4 ; function 4 : write text to window |
||
156 | mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
||
157 | mov ecx,0x00ffffff ; color of text RRGGBB |
||
158 | mov edx,labeltext ; pointer to text beginning |
||
159 | mov esi,lte-labeltext ; text length |
||
160 | int 0x40 |
||
161 | |||
162 | ; Re-draw the screen text |
||
163 | cld |
||
164 | mov ebx,10*65536+30 ; draw info text with function 4 |
||
165 | mov ecx,0x000000 |
||
166 | mov edx,text |
||
167 | mov esi,40 |
||
168 | newline: |
||
169 | mov eax,4 |
||
170 | int 0x40 |
||
171 | add ebx,16 |
||
172 | add edx,40 |
||
173 | cmp [edx],byte 'x' |
||
174 | jnz newline |
||
175 | |||
176 | |||
177 | mov eax,12 ; function 12:tell os about windowdraw |
||
178 | mov ebx,2 ; 2, end of draw |
||
179 | int 0x40 |
||
180 | |||
181 | ret |
||
182 | |||
183 | |||
184 | ; DATA AREA |
||
185 | |||
131 | diamond | 186 | if lang eq ru |
31 | halyavin | 187 | text: |
188 | db 'Данный адрес : 192.168.0.2 ' |
||
189 | db 'Прослушиваемый порт : 0x5000 ' |
||
190 | db 'Присланные сообщения: ' |
||
131 | diamond | 191 | db 'x' ; <- END MARKER, DONT DELETE |
192 | else |
||
193 | text: |
||
194 | db 'This address : 192.168.0.2 ' |
||
195 | db 'Used port : 0x5000 ' |
||
196 | db 'Received messages: ' |
||
197 | db 'x' ; <- END MARKER, DONT DELETE |
||
198 | end if |
||
31 | halyavin | 199 | |
200 | labeltext: db 'NetSend(Server)' |
||
201 | lte: |
||
202 | |||
203 | socketNum dd 0x0 |
||
204 | |||
205 | |||
206 | I_END:->-> |