Rev 5663 | Rev 5668 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3618 | hidnplayr | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
5663 | hidnplayr | 3 | ;; Copyright (C) KolibriOS team 2010-2015. All rights reserved. ;; |
3618 | hidnplayr | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;; vncc.asm - VNC client for KolibriOS ;; |
||
7 | ;; ;; |
||
8 | ;; Written by hidnplayr@kolibrios.org ;; |
||
9 | ;; ;; |
||
10 | ;; GNU GENERAL PUBLIC LICENSE ;; |
||
11 | ;; Version 2, June 1991 ;; |
||
12 | ;; ;; |
||
13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
3545 | hidnplayr | 14 | |
15 | format binary as "" |
||
16 | |||
3618 | hidnplayr | 17 | __DEBUG__ = 1 |
18 | __DEBUG_LEVEL__ = 1 |
||
19 | |||
20 | xpos = 4 ; coordinates of image |
||
21 | ypos = 22 ; |
||
22 | |||
23 | TIMEOUT = 5 ; timeout in seconds |
||
24 | |||
3545 | hidnplayr | 25 | use32 |
26 | |||
27 | org 0x0 |
||
28 | |||
5663 | hidnplayr | 29 | db "MENUET01" ; 8 byte id |
3618 | hidnplayr | 30 | dd 0x01 ; header version |
31 | dd START ; start of code |
||
32 | dd I_END ; size of image |
||
33 | dd IM_END ; memory for app |
||
34 | dd IM_END ; esp |
||
35 | dd 0x0 , 0x0 ; I_Param , I_Path |
||
3545 | hidnplayr | 36 | |
37 | |||
5663 | hidnplayr | 38 | include "../../macros.inc" |
39 | include "../../debug-fdo.inc" |
||
40 | include "../../proc32.inc" |
||
41 | include "../../dll.inc" |
||
42 | include "../../struct.inc" |
||
43 | include "../../develop/libraries/box_lib/trunk/box_lib.mac" |
||
44 | include "../../network.inc" |
||
3545 | hidnplayr | 45 | |
5663 | hidnplayr | 46 | struct pixel_format |
47 | bpp db ? |
||
48 | depth db ? |
||
49 | big_endian db ? |
||
50 | true_color db ? |
||
51 | red_max dw ? |
||
52 | green_max dw ? |
||
53 | blue_max dw ? |
||
54 | red_shift db ? |
||
55 | green_shift db ? |
||
56 | blue_shift db ? |
||
57 | padding rb 3 |
||
58 | ends |
||
3545 | hidnplayr | 59 | |
5663 | hidnplayr | 60 | struct framebuffer |
61 | width dw ? |
||
62 | height dw ? |
||
63 | pixelformat pixel_format |
||
64 | name_length dd ? |
||
65 | name rb 256 |
||
66 | ends |
||
67 | |||
68 | include "logon.inc" |
||
69 | include "raw.inc" |
||
5666 | hidnplayr | 70 | include "copyrect.inc" |
5663 | hidnplayr | 71 | include "thread.inc" |
72 | |||
3545 | hidnplayr | 73 | START: |
74 | |||
75 | mcall 68, 11 ; init heap |
||
76 | |||
77 | ; load libraries |
||
78 | stdcall dll.Load, @IMPORT |
||
79 | test eax, eax |
||
80 | jnz exit |
||
81 | |||
5663 | hidnplayr | 82 | call logon |
3545 | hidnplayr | 83 | |
5663 | hidnplayr | 84 | mcall 40, 0 ; disable all events |
3545 | hidnplayr | 85 | mcall 67, 0, 0, 0, 0 ; resize the window (hide it) |
86 | mcall 51, 1, thread_start, thread_stack |
||
87 | |||
5663 | hidnplayr | 88 | DEBUGF 1,"Thread created: %u\n", eax |
3545 | hidnplayr | 89 | |
90 | @@: |
||
91 | mcall 5, 10 |
||
5663 | hidnplayr | 92 | cmp byte[thread_ready], 0 |
3545 | hidnplayr | 93 | je @r |
94 | |||
5663 | hidnplayr | 95 | mcall 40, EVM_MOUSE + EVM_MOUSE_FILTER + EVM_KEY + EVM_REDRAW + EVM_BUTTON |
3545 | hidnplayr | 96 | |
5663 | hidnplayr | 97 | mov edx, dword[screen] |
3545 | hidnplayr | 98 | movzx esi, dx |
99 | shr edx, 16 |
||
100 | add edx, 2*xpos |
||
101 | add esi, ypos+xpos |
||
102 | mcall 67, 10, 10 ; resize the window |
||
103 | |||
104 | mainloop: |
||
5663 | hidnplayr | 105 | mcall 10 ; wait for event |
3545 | hidnplayr | 106 | |
107 | dec eax |
||
108 | jz redraw |
||
109 | dec eax |
||
110 | jz key |
||
111 | dec eax |
||
112 | jz button |
||
113 | sub eax, 3 |
||
114 | jz mouse |
||
115 | jmp mainloop |
||
116 | |||
117 | key: |
||
118 | |||
5663 | hidnplayr | 119 | ; DEBUGF 1,"Sending key event\n" |
3545 | hidnplayr | 120 | |
121 | mcall 2 |
||
5663 | hidnplayr | 122 | mov byte[keyevent.key+3], ah |
3545 | hidnplayr | 123 | |
124 | mcall send, [socketnum], keyevent, 8, 0 |
||
125 | jmp mainloop |
||
126 | |||
127 | mouse: |
||
128 | |||
5663 | hidnplayr | 129 | ; DEBUGF 1,"Sending mouse event\n" |
3545 | hidnplayr | 130 | |
131 | mcall 37, 1 ; get mouse pos |
||
132 | sub eax, xpos shl 16 + ypos |
||
133 | bswap eax |
||
134 | mov [pointerevent.x], ax |
||
135 | shr eax, 16 |
||
136 | mov [pointerevent.y], ax |
||
137 | |||
138 | mcall 37, 2 ; get mouse buttons |
||
139 | test al, 00000010b ; test if right button was pressed (bit 1 in kolibri) |
||
140 | jz @f |
||
5663 | hidnplayr | 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 |
3545 | hidnplayr | 142 | @@: |
143 | mov [pointerevent.mask],al |
||
144 | |||
145 | mcall send, [socketnum], pointerevent, 6, 0 |
||
146 | jmp mainloop |
||
147 | |||
148 | redraw: |
||
149 | |||
5663 | hidnplayr | 150 | ; DEBUGF 1,"Drawing window\n" |
3545 | hidnplayr | 151 | |
152 | mcall 12, 1 |
||
153 | |||
154 | mov ebx, dword[screen] |
||
155 | movzx ecx, bx |
||
156 | shr ebx, 16 |
||
157 | mov edx, 0x74ffffff |
||
158 | mov edi, name |
||
159 | mcall 0 ; draw window |
||
160 | |||
161 | call drawbuffer |
||
162 | |||
163 | mcall 12, 2 |
||
164 | |||
165 | jmp mainloop |
||
166 | |||
167 | drawbuffer: |
||
168 | mcall 7, framebuffer_data, dword[screen], 0 |
||
169 | ret |
||
170 | |||
171 | button: |
||
172 | mcall 17 ; get id |
||
173 | |||
174 | exit: |
||
5663 | hidnplayr | 175 | DEBUGF 1, "Closing time!\n" |
3545 | hidnplayr | 176 | mcall close, [socketnum] |
177 | mcall -1 |
||
178 | |||
179 | no_rfb: |
||
5663 | hidnplayr | 180 | DEBUGF 1, "This is no vnc server!\n" |
3545 | hidnplayr | 181 | jmp exit |
182 | |||
183 | invalid_security: |
||
5663 | hidnplayr | 184 | DEBUGF 1, "Security error: %s\n", receive_buffer+5 |
3545 | hidnplayr | 185 | jmp exit |
186 | |||
187 | |||
188 | ; DATA AREA |
||
189 | |||
190 | include_debug_strings ; ALWAYS present in data section |
||
191 | |||
5663 | hidnplayr | 192 | handshake db "RFB 003.003", 10 |
193 | ClientInit db 0 ; not shared |
||
194 | beep db 0x85, 0x25, 0x85, 0x40, 0 |
||
3545 | hidnplayr | 195 | |
5663 | hidnplayr | 196 | pixel_format32 db 0 ; setPixelformat |
197 | db 0, 0, 0 ; padding |
||
198 | .bpp db 32 ; bits per pixel |
||
199 | .depth db 32 ; depth |
||
200 | .big_endian db 0 ; big-endian flag |
||
201 | .true_color db 1 ; true-colour flag |
||
202 | .red_max db 0, 255 ; red-max |
||
203 | .green_max db 0, 255 ; green-max |
||
204 | .blue_max db 0, 255 ; blue-max |
||
205 | .red_shif db 0 ; red-shift |
||
206 | .green_shift db 8 ; green-shift |
||
207 | .blue_shift db 16 ; blue-shift |
||
208 | db 0, 0, 0 ; padding |
||
3545 | hidnplayr | 209 | |
5663 | hidnplayr | 210 | pixel_format16 db 0 ; setPixelformat |
211 | db 0, 0, 0 ; padding |
||
212 | .bpp db 16 ; bits per pixel |
||
213 | .depth db 15 ; depth |
||
214 | .big_endian db 0 ; big-endian flag |
||
215 | .true_color db 1 ; true-colour flag |
||
216 | .red_max db 0, 31 ; red-max |
||
217 | .green_max db 0, 31 ; green-max |
||
218 | .blue_max db 0, 31 ; blue-max |
||
219 | .red_shif db 0 ; red-shift |
||
220 | .green_shift db 5 ; green-shift |
||
221 | .blue_shift db 10 ; blue-shift |
||
222 | db 0, 0, 0 ; padding |
||
3545 | hidnplayr | 223 | |
5663 | hidnplayr | 224 | pixel_format8 db 0 ; setPixelformat |
225 | db 0, 0, 0 ; padding |
||
226 | .bpp db 8 ; bits per pixel |
||
227 | .depth db 6 ; depth |
||
228 | .big_endian db 0 ; big-endian flag |
||
229 | .true_color db 1 ; true-colour flag |
||
230 | .red_max db 0, 3 ; red-max |
||
231 | .green_max db 0, 3 ; green-max |
||
232 | .blue_max db 0, 3 ; blue-max |
||
233 | .red_shif db 0 ; red-shift |
||
234 | .green_shift db 2 ; green-shift |
||
235 | .blue_shift db 4 ; blue-shift |
||
236 | db 0, 0, 0 ; padding |
||
3545 | hidnplayr | 237 | |
5663 | hidnplayr | 238 | encodings db 2 ; setEncodings |
239 | db 0 ; padding |
||
5666 | hidnplayr | 240 | db 0, 2 ; number of encodings |
241 | db 0, 0, 0, 0 ; raw encoding (DWORD, Big endian order) |
||
242 | db 0, 0, 0, 1 ; Copyrect encoding |
||
243 | ; db 0, 0, 0, 2 ; RRE |
||
244 | ; db 0, 0, 0, 5 ; HexTile |
||
245 | ; db 0, 0, 0, 15 ; TRLE |
||
246 | ; db 0, 0, 0, 16 ; ZRLE |
||
3545 | hidnplayr | 247 | |
5663 | hidnplayr | 248 | fbur db 3 ; frame buffer update request |
249 | .inc db 0 ; incremental |
||
3545 | hidnplayr | 250 | .x dw 0 |
251 | .y dw 0 |
||
252 | .width dw 0 |
||
253 | .height dw 0 |
||
254 | |||
5663 | hidnplayr | 255 | keyevent db 4 ; keyevent |
256 | .down db 0 ; down-flag |
||
257 | dw 0 ; padding |
||
258 | .key dd 0 ; key |
||
3545 | hidnplayr | 259 | |
5663 | hidnplayr | 260 | pointerevent db 5 ; pointerevent |
261 | .mask db 0 ; button-mask |
||
262 | .x dw 0 ; x-position |
||
263 | .y dw 0 ; y-position |
||
3545 | hidnplayr | 264 | |
265 | |||
266 | sockaddr1: |
||
267 | dw AF_INET4 |
||
5663 | hidnplayr | 268 | .port dw 0x0c17 ; 5900 |
3545 | hidnplayr | 269 | .ip dd 0 |
270 | rb 10 |
||
271 | |||
272 | thread_ready db 0 |
||
5663 | hidnplayr | 273 | mouse_dd dd ? |
274 | |||
275 | URLbox edit_box 200, 25, 16, 0xffffff, 0x6f9480, 0, 0, 0, 65535, serveraddr, mouse_dd, ed_focus, 0, 0 |
||
276 | |||
3545 | hidnplayr | 277 | ; import |
278 | align 4 |
||
279 | @IMPORT: |
||
280 | |||
5663 | hidnplayr | 281 | library network, "network.obj",\ |
282 | box_lib, "box_lib.obj",\ |
||
283 | archiver, "archiver.obj" |
||
3545 | hidnplayr | 284 | |
5663 | hidnplayr | 285 | import network,\ |
286 | getaddrinfo, "getaddrinfo", \ |
||
287 | freeaddrinfo, "freeaddrinfo", \ |
||
288 | inet_ntoa, "inet_ntoa" |
||
3545 | hidnplayr | 289 | |
5663 | hidnplayr | 290 | import box_lib,\ |
291 | edit_box_draw, "edit_box",\ |
||
292 | edit_box_key, "edit_box_key",\ |
||
293 | edit_box_mouse, "edit_box_mouse",\ |
||
294 | scrollbar_v_draw, "scrollbar_v_draw",\ |
||
295 | scrollbar_v_mouse, "scrollbar_v_mouse",\ |
||
296 | scrollbar_h_draw, "scrollbar_h_draw",\ |
||
297 | scrollbar_h_mouse, "scrollbar_h_mouse" |
||
298 | |||
299 | import archiver,\ |
||
300 | deflate_unpack, "deflate_unpack" |
||
301 | |||
302 | name db "VNC client " |
||
303 | name.dash db 0, " " |
||
304 | |||
3545 | hidnplayr | 305 | I_END: |
306 | |||
5663 | hidnplayr | 307 | servername rb 64+1 |
3545 | hidnplayr | 308 | |
5663 | hidnplayr | 309 | socketnum dd ? |
310 | datapointer dd ? |
||
311 | rectangles dw ? |
||
3545 | hidnplayr | 312 | |
5663 | hidnplayr | 313 | rectangle: |
314 | .width dw ? |
||
315 | .height dw ? |
||
316 | .x dw ? |
||
317 | .y dw ? |
||
3545 | hidnplayr | 318 | |
5663 | hidnplayr | 319 | screen: ; Remote screen resolution |
320 | .height dw ? |
||
321 | .width dw ? |
||
3545 | hidnplayr | 322 | |
5663 | hidnplayr | 323 | serveraddr rb 65536 |
324 | receive_buffer rb 5*1024*1024 ; 5 mb buffer for received data (incoming frbupdate etc) |
||
325 | framebuffer_data rb 1024*1024*3 ; framebuffer |
||
3545 | hidnplayr | 326 | |
5663 | hidnplayr | 327 | rb 0x1000 |
3545 | hidnplayr | 328 | thread_stack: |
329 | |||
5663 | hidnplayr | 330 | rb 0x1000 |
331 | |||
3545 | hidnplayr | 332 | IM_END: |
333 |