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(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' |
||
31 | halyavin | 28 | include 'macros.inc' |
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 |
||
37 | int 0x40 |
||
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 |
31 | halyavin | 47 | int 0x40 |
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 |
31 | halyavin | 56 | int 0x40 |
57 | jmp still |
||
58 | |||
59 | button: |
||
131 | diamond | 60 | mov al,17 |
31 | halyavin | 61 | int 0x40 |
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] |
||
68 | int 0x40 |
||
69 | mov eax,-1 |
||
70 | int 0x40 |
||
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 |
31 | halyavin | 87 | int 0x40 |
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 |
||
101 | int 0x40 |
||
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] |
||
107 | mov edx,0x03ffffff ; color of work area RRGGBB |
||
108 | int 0x40 |
||
109 | |||
110 | ; WINDOW LABEL |
||
111 | mov eax,4 ; function 4 : write text to window |
||
112 | mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
||
113 | mov ecx,0x00ffffff ; color of text RRGGBB |
||
114 | mov edx,labeltext ; pointer to text beginning |
||
115 | mov esi,lte-labeltext ; text length |
||
116 | int 0x40 |
||
117 | |||
118 | mov eax,8 ; SEND MESSAGE |
||
119 | mov ebx,50*65536+145 |
||
120 | mov ecx,47*65536+13 |
||
121 | mov edx,2 |
||
122 | mov esi,0x667788 |
||
123 | int 0x40 |
||
124 | |||
125 | mov ebx,25*65536+50 ; draw info text with function 4 |
||
126 | mov ecx,0x000000 |
||
127 | mov edx,text |
||
128 | mov esi,40 |
||
129 | newline: |
||
130 | mov eax,4 |
||
131 | int 0x40 |
||
132 | add ebx,16 |
||
131 | diamond | 133 | add edx,esi |
31 | halyavin | 134 | cmp [edx],byte 'x' |
135 | jnz newline |
||
136 | |||
137 | mov eax,12 ; function 12:tell os about windowdraw |
||
138 | mov ebx,2 ; 2, end of draw |
||
139 | int 0x40 |
||
140 | |||
141 | ret |
||
142 | |||
143 | |||
144 | ; DATA AREA |
||
145 | |||
131 | diamond | 146 | if lang eq ru |
31 | halyavin | 147 | text: |
148 | db ' Послать сообщение ' |
||
149 | db ' ' |
||
150 | db ' Локальный адрес : 192.168.0.1 ' |
||
151 | db ' Удалённый адрес : 192.168.0.2 ' |
||
152 | db 'Текст и адрес в конце исходника ' |
||
131 | diamond | 153 | db 'x' ; <- END MARKER, DONT DELETE |
154 | else |
||
155 | text: |
||
156 | db ' Send message ' |
||
157 | db ' ' |
||
158 | db ' Local address : 192.168.0.1 ' |
||
159 | db ' Remote address : 192.168.0.2 ' |
||
160 | db 'Text and address in end of source ' |
||
161 | db 'x' ; <- END MARKER, DONT DELETE |
||
162 | end if |
||
31 | halyavin | 163 | |
164 | labeltext: db 'NetSend(Client)' ; |
||
165 | lte: |
||
166 | |||
167 | remote_ip db 192,168,1,2 |
||
168 | |||
169 | send_data db 'Привет,это тест!Hello,this is a test!' |
||
170 | end_message: |
||
171 | |||
172 | |||
173 | I_END: |
||
131 | diamond | 174 | align 4 |
175 | socketNum dd ? |
||
176 | |||
177 | rb 32 ; this is for stack |
||
178 | |||
179 | mem:->-> |
||
180 |