Rev 485 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
264 | hidnplayr | 1 | ; |
2 | ; |
||
3 | ; VNC Client for kolibrios by hidnplayr |
||
4 | ; |
||
5 | ; |
||
6 | ; WORK IN PROGRESS... |
||
7 | ; |
||
8 | ; FEEL FREE TO CONTRIBUTE ! |
||
9 | ; |
||
10 | ; hidnplayr@gmail.com |
||
11 | ; |
||
12 | |||
13 | use32 |
||
14 | |||
15 | org 0x0 |
||
16 | |||
17 | db 'MENUET01' ; 8 byte id |
||
18 | dd 0x01 ; header version |
||
19 | dd START ; start of code |
||
20 | dd I_END ; size of image |
||
21 | dd IM_END ; memory for app |
||
22 | dd IM_END ; esp |
||
23 | dd 0x0 , 0x0 ; I_Param , I_Icon |
||
24 | |||
25 | __DEBUG__ equ 1 |
||
26 | __DEBUG_LEVEL__ equ 1 |
||
27 | |||
28 | STRLEN = 64 ; password and server max length |
||
29 | xpos = 4 ; coordinates of image |
||
30 | ypos = 22 ; |
||
31 | |||
32 | TIMEOUT = 60 ; timeout in seconds |
||
33 | BUFFER = 1500 ; Buffer size for DNS |
||
34 | |||
485 | heavyiron | 35 | include '..\..\macros.inc' |
264 | hidnplayr | 36 | include 'fdo.inc' |
37 | include 'ETH.INC' |
||
38 | include 'logon.inc' |
||
39 | include 'raw.inc' |
||
40 | include 'copyrect.inc' |
||
41 | include 'thread.inc' |
||
42 | |||
43 | START: ; start of execution |
||
44 | |||
45 | call red_logon |
||
46 | |||
47 | mov eax,40 ; Report events |
||
48 | mov ebx,00000000b ; Only Stack |
||
485 | heavyiron | 49 | mcall |
264 | hidnplayr | 50 | |
51 | mov eax,67 ; resize the window (hide it) |
||
52 | xor ebx,ebx |
||
53 | mov ecx,ebx |
||
54 | mov edx,ebx |
||
55 | mov esi,ebx |
||
485 | heavyiron | 56 | mcall |
264 | hidnplayr | 57 | |
58 | mov eax,51 |
||
59 | mov ebx,1 |
||
60 | mov ecx,thread_start |
||
61 | mov edx,thread_stack |
||
485 | heavyiron | 62 | mcall |
264 | hidnplayr | 63 | |
64 | DEBUGF 1,'Thread created: %u\n',eax |
||
65 | |||
66 | @@: |
||
67 | mov eax,5 |
||
68 | mov ebx,10 |
||
485 | heavyiron | 69 | mcall |
264 | hidnplayr | 70 | |
71 | cmp byte[thread_ready],0 |
||
72 | je @r |
||
73 | |||
74 | mov eax,40 ; report events |
||
75 | mov ebx,100111b ; mouse, button, key, redraw |
||
485 | heavyiron | 76 | mcall |
264 | hidnplayr | 77 | |
78 | mov eax,67 ; resize the window |
||
79 | mov ebx,10 |
||
80 | mov ecx,10 |
||
81 | mov edx,dword[framebuffer] |
||
82 | bswap edx |
||
83 | movzx esi,dx |
||
84 | shr edx,16 |
||
85 | add edx,2*xpos |
||
86 | add esi,ypos+xpos |
||
485 | heavyiron | 87 | mcall |
264 | hidnplayr | 88 | |
89 | mainloop: |
||
90 | eth.socket_status [socket],eax |
||
91 | cmp al,TCB_CLOSE_WAIT |
||
92 | je close |
||
93 | |||
94 | mov eax,23 ; wait for event with timeout |
||
95 | mov ebx,50 ; 0,5 s |
||
485 | heavyiron | 96 | mcall |
264 | hidnplayr | 97 | |
98 | cmp eax,1 |
||
99 | je redraw |
||
100 | cmp eax,2 ; key |
||
101 | je key |
||
102 | cmp eax,3 ; button |
||
103 | je button |
||
104 | cmp eax,6 ; mouse |
||
105 | je mouse |
||
106 | |||
107 | call drawbuffer |
||
108 | |||
109 | jmp mainloop |
||
110 | |||
111 | key: |
||
112 | DEBUGF 1,'Sending key event\n' |
||
113 | |||
114 | mov eax,2 |
||
485 | heavyiron | 115 | mcall |
264 | hidnplayr | 116 | mov byte[keyevent.key+3],ah |
117 | |||
118 | eth.write_tcp [socket],8,keyevent |
||
119 | |||
120 | jmp mainloop |
||
121 | |||
122 | mouse: |
||
123 | DEBUGF 1,'Sending mouse event\n' |
||
124 | |||
125 | mov eax,37 |
||
126 | mov ebx,1 |
||
485 | heavyiron | 127 | mcall |
264 | hidnplayr | 128 | |
129 | sub eax,xpos*65536+ypos |
||
130 | bswap eax |
||
131 | mov word[pointerevent.x],ax |
||
132 | shr eax,16 |
||
133 | mov word[pointerevent.y],ax |
||
134 | |||
135 | mov eax,37 |
||
136 | mov ebx,2 |
||
485 | heavyiron | 137 | mcall |
264 | hidnplayr | 138 | |
139 | test al,00000010b ; test if right button was pressed (bit 1 in kolibri) |
||
140 | jz @f |
||
141 | add al,00000010b ; in RFB protocol it is bit 2, so if we add bit 2 again, we'll get bit 3 and bit 1 will remain the same |
||
142 | @@: |
||
143 | |||
144 | mov byte[pointerevent.mask],al |
||
145 | |||
146 | eth.write_tcp [socket],6,pointerevent |
||
147 | |||
148 | jmp mainloop |
||
149 | |||
150 | redraw: |
||
151 | |||
152 | DEBUGF 1,'Drawing window\n' |
||
153 | |||
2196 | leency | 154 | mcall 12, 1 |
264 | hidnplayr | 155 | |
156 | mov eax,0 ; draw window |
||
157 | mov ebx,dword[framebuffer] |
||
158 | bswap ebx |
||
159 | movzx ecx,bx |
||
160 | shr ebx,16 |
||
161 | add ebx,2*xpos |
||
162 | add ecx,ypos+xpos |
||
2196 | leency | 163 | mov edx,0xffffff |
485 | heavyiron | 164 | mcall |
264 | hidnplayr | 165 | |
166 | mov eax,4 ; label |
||
167 | mov ebx,9*65536+8 |
||
168 | mov ecx,0x10ffffff |
||
169 | mov edx,name |
||
170 | mov esi,[name_length] |
||
171 | bswap esi |
||
485 | heavyiron | 172 | mcall |
264 | hidnplayr | 173 | |
174 | call drawbuffer |
||
175 | |||
2196 | leency | 176 | mcall 12, 2 |
264 | hidnplayr | 177 | |
178 | jmp mainloop |
||
179 | |||
180 | drawbuffer: |
||
181 | |||
182 | mov eax,7 |
||
183 | mov ebx,framebuffer_data |
||
184 | mov ecx,dword[screen] |
||
185 | mov edx,xpos*65536+ypos |
||
485 | heavyiron | 186 | mcall |
264 | hidnplayr | 187 | |
188 | ret |
||
189 | |||
190 | |||
191 | button: ; button |
||
192 | mov eax,17 ; get id |
||
485 | heavyiron | 193 | mcall |
264 | hidnplayr | 194 | |
195 | close: |
||
196 | call read_data |
||
197 | ; eth.close_tcp [socket] ; We're done, close the socket ;;; BUG WHEN CLOSING SOCKET !! |
||
198 | DEBUGF 1,'Socket closed\n' |
||
199 | |||
200 | mov eax,-1 |
||
485 | heavyiron | 201 | mcall |
264 | hidnplayr | 202 | |
203 | no_rfb: |
||
204 | DEBUGF 1,'This is no vnc server!\n' |
||
205 | jmp close |
||
206 | |||
207 | invalid_security: |
||
208 | DEBUGF 1,'Security error: %s\n',receive_buffer+5 |
||
209 | jmp close |
||
210 | |||
211 | |||
212 | ; DATA AREA |
||
213 | |||
214 | include_debug_strings ; ALWAYS present in data section |
||
215 | |||
216 | handshake db 'RFB 003.003',0x0a |
||
217 | shared db 0 |
||
218 | beep db 0x85,0x25,0x85,0x40,0 |
||
219 | |||
220 | pixel_format32 db 0 ; setPixelformat |
||
221 | rb 3 ; padding |
||
222 | .bpp db 32 ; bits per pixel |
||
223 | .depth db 32 ; depth |
||
224 | .big_endian db 0 ; big-endian flag |
||
225 | .true_color db 1 ; true-colour flag |
||
226 | .red_max db 0,255 ; red-max |
||
227 | .green_max db 0,255 ; green-max |
||
228 | .blue_max db 0,255 ; blue-max |
||
229 | .red_shif db 0 ; red-shift |
||
230 | .green_shift db 8 ; green-shift |
||
231 | .blue_shift db 16 ; blue-shift |
||
232 | rb 3 ; padding |
||
233 | |||
234 | pixel_format16 db 0 ; setPixelformat |
||
235 | rb 3 ; padding |
||
236 | .bpp db 16 ; bits per pixel |
||
237 | .depth db 15 ; depth |
||
238 | .big_endian db 0 ; big-endian flag |
||
239 | .true_color db 1 ; true-colour flag |
||
240 | .red_max db 0,31 ; red-max |
||
241 | .green_max db 0,31 ; green-max |
||
242 | .blue_max db 0,31 ; blue-max |
||
243 | .red_shif db 0 ; red-shift |
||
244 | .green_shift db 5 ; green-shift |
||
245 | .blue_shift db 10 ; blue-shift |
||
246 | rb 3 ; padding |
||
247 | |||
248 | pixel_format8 db 0 ; setPixelformat |
||
249 | rb 3 ; padding |
||
250 | .bpp db 8 ; bits per pixel |
||
251 | .depth db 6 ; depth |
||
252 | .big_endian db 0 ; big-endian flag |
||
253 | .true_color db 1 ; true-colour flag |
||
254 | .red_max db 0,3 ; red-max |
||
255 | .green_max db 0,3 ; green-max |
||
256 | .blue_max db 0,3 ; blue-max |
||
257 | .red_shif db 0 ; red-shift |
||
258 | .green_shift db 2 ; green-shift |
||
259 | .blue_shift db 4 ; blue-shift |
||
260 | rb 3 ; padding |
||
261 | |||
262 | encodings db 2 ; setEncodings |
||
263 | rb 1 ; padding |
||
264 | db 1,0 ; number of encodings |
||
265 | db 0,0,0,0 ; raw encoding (DWORD, Big endian order) |
||
266 | db 1,0,0,0 ; Copyrect encoding |
||
267 | |||
268 | fbur db 3 ; frame buffer update request |
||
269 | .inc db 0 ; incremental |
||
270 | .x dw 0 |
||
271 | .y dw 0 |
||
272 | .width dw 0 |
||
273 | .height dw 0 |
||
274 | |||
275 | keyevent db 4 ; keyevent |
||
276 | .down db 0 ; down-flag |
||
277 | dw 0 ; padding |
||
278 | .key dd 0 ; key |
||
279 | |||
280 | pointerevent db 5 ; pointerevent |
||
281 | .mask db 0 ; button-mask |
||
282 | .x dw 0 ; x-position |
||
283 | .y dw 0 ; y-position |
||
284 | |||
285 | I_END: |
||
286 | |||
287 | framebuffer: |
||
288 | .width dw ? |
||
289 | .height dw ? |
||
290 | pixelformat: |
||
291 | .bpp db ? |
||
292 | .depth db ? |
||
293 | .big_endian db ? |
||
294 | .true_color db ? |
||
295 | .red_max dw ? |
||
296 | .green_max dw ? |
||
297 | .blue_max dw ? |
||
298 | .red_shift db ? |
||
299 | .green_shift db ? |
||
300 | .blue_shift db ? |
||
301 | .padding rb 3 |
||
302 | name_length dd ? |
||
303 | name rb 256 |
||
304 | |||
305 | server_ip dd 0 |
||
306 | server_port dd 0 |
||
307 | socket dd 0 |
||
308 | datapointer dd 0 |
||
309 | |||
310 | frame: |
||
311 | .width dw 0 |
||
312 | .height dw 0 |
||
313 | .x dw 0 |
||
314 | .y dw 0 |
||
315 | |||
316 | screen: |
||
317 | .height dw 0 |
||
318 | .width dw 0 |
||
319 | |||
320 | thread_ready db 0 |
||
321 | |||
322 | dnsMsg: |
||
323 | receive_buffer rb 5*1024*1024 ; 5 mb buffer for received data (incoming frbupdate etc) |
||
324 | framebuffer_data rb 1024*768*3 ; framebuffer |
||
325 | |||
326 | thread_stack rb 0x1000 |
||
327 | |||
328 | IM_END: |
||
329 |