Rev 5666 | Rev 5670 | 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 | ;; ;; |
||
5668 | hidnplayr | 6 | ;; VNC client for KolibriOS ;; |
3618 | hidnplayr | 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 | |||
3545 | hidnplayr | 20 | use32 |
21 | |||
22 | org 0x0 |
||
23 | |||
5663 | hidnplayr | 24 | db "MENUET01" ; 8 byte id |
3618 | hidnplayr | 25 | dd 0x01 ; header version |
26 | dd START ; start of code |
||
27 | dd I_END ; size of image |
||
28 | dd IM_END ; memory for app |
||
29 | dd IM_END ; esp |
||
5668 | hidnplayr | 30 | dd 0x0, 0x0 ; I_Param , I_Path |
3545 | hidnplayr | 31 | |
5663 | hidnplayr | 32 | include "../../macros.inc" |
33 | include "../../debug-fdo.inc" |
||
34 | include "../../proc32.inc" |
||
35 | include "../../dll.inc" |
||
36 | include "../../struct.inc" |
||
37 | include "../../develop/libraries/box_lib/trunk/box_lib.mac" |
||
38 | include "../../network.inc" |
||
3545 | hidnplayr | 39 | |
5663 | hidnplayr | 40 | struct pixel_format |
41 | bpp db ? |
||
42 | depth db ? |
||
43 | big_endian db ? |
||
44 | true_color db ? |
||
45 | red_max dw ? |
||
46 | green_max dw ? |
||
47 | blue_max dw ? |
||
48 | red_shift db ? |
||
49 | green_shift db ? |
||
50 | blue_shift db ? |
||
51 | padding rb 3 |
||
52 | ends |
||
3545 | hidnplayr | 53 | |
5663 | hidnplayr | 54 | struct framebuffer |
55 | width dw ? |
||
56 | height dw ? |
||
57 | pixelformat pixel_format |
||
58 | name_length dd ? |
||
59 | name rb 256 |
||
60 | ends |
||
61 | |||
5668 | hidnplayr | 62 | xpos = 4 |
63 | ypos = 22 |
||
64 | |||
65 | TIMEOUT = 5 ; timeout in seconds |
||
66 | |||
67 | RECEIVE_BUFFER_SIZE = 8*1024*1024 ; 8 Mib |
||
68 | |||
69 | STATUS_INITIAL = 0 |
||
70 | STATUS_CONNECTING = 1 |
||
71 | STATUS_LOGIN = 2 |
||
72 | STATUS_CONNECTED = 3 |
||
73 | |||
74 | STATUS_DISCONNECTED = 10 |
||
75 | STATUS_DNS_ERR = 11 |
||
76 | STATUS_SOCK_ERR = 12 |
||
77 | STATUS_CONNECT_ERR = 13 |
||
78 | STATUS_PROTO_ERR = 14 |
||
79 | STATUS_SECURITY_ERR = 15 |
||
80 | STATUS_LIB_ERR = 16 |
||
81 | STATUS_THREAD_ERR = 17 |
||
82 | |||
83 | include "gui.inc" |
||
84 | include "network.inc" |
||
5663 | hidnplayr | 85 | include "raw.inc" |
5666 | hidnplayr | 86 | include "copyrect.inc" |
5668 | hidnplayr | 87 | include "rre.inc" |
5663 | hidnplayr | 88 | |
3545 | hidnplayr | 89 | START: |
90 | |||
91 | mcall 68, 11 ; init heap |
||
92 | |||
5668 | hidnplayr | 93 | ; Load libraries |
3545 | hidnplayr | 94 | stdcall dll.Load, @IMPORT |
95 | test eax, eax |
||
5668 | hidnplayr | 96 | jz @f |
97 | mov [status], STATUS_LIB_ERR |
||
98 | @@: |
||
3545 | hidnplayr | 99 | |
5668 | hidnplayr | 100 | ; Present the user with the GUI and wait for network connection |
101 | call draw_gui |
||
3545 | hidnplayr | 102 | |
5668 | hidnplayr | 103 | ; Create main window |
104 | mcall 71, 1, name ; reset window caption (add server name) |
||
3545 | hidnplayr | 105 | |
5663 | hidnplayr | 106 | mov edx, dword[screen] |
3545 | hidnplayr | 107 | movzx esi, dx |
108 | shr edx, 16 |
||
109 | add edx, 2*xpos |
||
110 | add esi, ypos+xpos |
||
111 | mcall 67, 10, 10 ; resize the window |
||
112 | |||
5668 | hidnplayr | 113 | mcall 40, EVM_MOUSE + EVM_MOUSE_FILTER + EVM_KEY + EVM_REDRAW + EVM_BUTTON |
114 | |||
115 | redraw: |
||
116 | mcall 12, 1 |
||
117 | |||
118 | mov ebx, dword[screen] |
||
119 | movzx ecx, bx |
||
120 | shr ebx, 16 |
||
121 | mov edx, 0x74ffffff |
||
122 | mov edi, name |
||
123 | mcall 0 ; draw window |
||
124 | |||
125 | call drawbuffer |
||
126 | |||
127 | mcall 12, 2 |
||
128 | |||
3545 | hidnplayr | 129 | mainloop: |
5668 | hidnplayr | 130 | cmp [status], STATUS_CONNECTED |
131 | jne draw_gui |
||
3545 | hidnplayr | 132 | |
5668 | hidnplayr | 133 | mcall 23, 100 ; Check for event with 1s timeout |
134 | |||
3545 | hidnplayr | 135 | dec eax |
136 | jz redraw |
||
137 | dec eax |
||
138 | jz key |
||
139 | dec eax |
||
140 | jz button |
||
141 | sub eax, 3 |
||
142 | jz mouse |
||
143 | jmp mainloop |
||
144 | |||
5668 | hidnplayr | 145 | drawbuffer: |
146 | mcall 7, framebuffer_data, dword[screen], 0 |
||
147 | ret |
||
148 | |||
3545 | hidnplayr | 149 | key: |
5668 | hidnplayr | 150 | ; DEBUGF 1, "Sending key event\n" |
3545 | hidnplayr | 151 | |
152 | mcall 2 |
||
5668 | hidnplayr | 153 | mov byte[KeyEvent.key+3], ah |
3545 | hidnplayr | 154 | |
5668 | hidnplayr | 155 | mcall send, [socketnum], KeyEvent, 8, 0 |
3545 | hidnplayr | 156 | jmp mainloop |
157 | |||
158 | mouse: |
||
5668 | hidnplayr | 159 | ; DEBUGF 1, "Sending mouse event\n" |
3545 | hidnplayr | 160 | |
161 | mcall 37, 1 ; get mouse pos |
||
162 | sub eax, xpos shl 16 + ypos |
||
163 | bswap eax |
||
5668 | hidnplayr | 164 | mov [PointerEvent.x], ax |
3545 | hidnplayr | 165 | shr eax, 16 |
5668 | hidnplayr | 166 | mov [PointerEvent.y], ax |
3545 | hidnplayr | 167 | |
168 | mcall 37, 2 ; get mouse buttons |
||
169 | test al, 00000010b ; test if right button was pressed (bit 1 in kolibri) |
||
170 | jz @f |
||
5663 | hidnplayr | 171 | 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 | 172 | @@: |
5668 | hidnplayr | 173 | mov [PointerEvent.mask], al |
3545 | hidnplayr | 174 | |
5668 | hidnplayr | 175 | mcall send, [socketnum], PointerEvent, 6, 0 |
3545 | hidnplayr | 176 | jmp mainloop |
177 | |||
178 | button: |
||
179 | mcall 17 ; get id |
||
180 | mcall -1 |
||
181 | |||
182 | |||
5668 | hidnplayr | 183 | ; DATA AREA |
3545 | hidnplayr | 184 | |
5668 | hidnplayr | 185 | include_debug_strings |
3545 | hidnplayr | 186 | |
5668 | hidnplayr | 187 | HandShake db "RFB 003.003", 10 |
3545 | hidnplayr | 188 | |
5668 | hidnplayr | 189 | ClientInit db 0 ; not shared |
3545 | hidnplayr | 190 | |
5668 | hidnplayr | 191 | SetPixelFormat32 db 0 ; setPixelformat |
192 | db 0, 0, 0 ; padding |
||
193 | .bpp db 32 ; bits per pixel |
||
194 | .depth db 32 ; depth |
||
195 | .big_endian db 0 ; big-endian flag |
||
196 | .true_color db 1 ; true-colour flag |
||
197 | .red_max db 0, 255 ; red-max |
||
198 | .green_max db 0, 255 ; green-max |
||
199 | .blue_max db 0, 255 ; blue-max |
||
200 | .red_shif db 0 ; red-shift |
||
201 | .green_shift db 8 ; green-shift |
||
202 | .blue_shift db 16 ; blue-shift |
||
203 | db 0, 0, 0 ; padding |
||
3545 | hidnplayr | 204 | |
5668 | hidnplayr | 205 | SetPixelFormat16 db 0 ; setPixelformat |
206 | db 0, 0, 0 ; padding |
||
207 | .bpp db 16 ; bits per pixel |
||
208 | .depth db 15 ; depth |
||
209 | .big_endian db 0 ; big-endian flag |
||
210 | .true_color db 1 ; true-colour flag |
||
211 | .red_max db 0, 31 ; red-max |
||
212 | .green_max db 0, 31 ; green-max |
||
213 | .blue_max db 0, 31 ; blue-max |
||
214 | .red_shif db 0 ; red-shift |
||
215 | .green_shift db 5 ; green-shift |
||
216 | .blue_shift db 10 ; blue-shift |
||
217 | db 0, 0, 0 ; padding |
||
3545 | hidnplayr | 218 | |
5668 | hidnplayr | 219 | SetPixelFormat8 db 0 ; setPixelformat |
220 | db 0, 0, 0 ; padding |
||
221 | .bpp db 8 ; bits per pixel |
||
222 | .depth db 6 ; depth |
||
223 | .big_endian db 0 ; big-endian flag |
||
224 | .true_color db 1 ; true-colour flag |
||
225 | .red_max db 0, 3 ; red-max |
||
226 | .green_max db 0, 3 ; green-max |
||
227 | .blue_max db 0, 3 ; blue-max |
||
228 | .red_shif db 0 ; red-shift |
||
229 | .green_shift db 2 ; green-shift |
||
230 | .blue_shift db 4 ; blue-shift |
||
231 | db 0, 0, 0 ; padding |
||
3545 | hidnplayr | 232 | |
5668 | hidnplayr | 233 | SetEncodings db 2 ; setEncodings |
234 | db 0 ; padding |
||
235 | db 0, 2 ; number of encodings |
||
236 | db 0, 0, 0, 0 ; raw encoding (DWORD, Big endian order) |
||
237 | db 0, 0, 0, 1 ; Copyrect encoding |
||
238 | ; db 0, 0, 0, 2 ; RRE |
||
239 | ; db 0, 0, 0, 5 ; HexTile |
||
240 | ; db 0, 0, 0, 15 ; TRLE |
||
241 | ; db 0, 0, 0, 16 ; ZRLE |
||
3545 | hidnplayr | 242 | |
5668 | hidnplayr | 243 | FramebufferUpdateRequest db 3 |
244 | .inc db 0 ; incremental |
||
245 | .x dw 0 |
||
246 | .y dw 0 |
||
247 | .width dw 0 |
||
248 | .height dw 0 |
||
3545 | hidnplayr | 249 | |
5668 | hidnplayr | 250 | KeyEvent db 4 ; keyevent |
251 | .down db 0 ; down-flag |
||
252 | dw 0 ; padding |
||
253 | .key dd 0 ; key |
||
3545 | hidnplayr | 254 | |
5668 | hidnplayr | 255 | PointerEvent db 5 ; pointerevent |
256 | .mask db 0 ; button-mask |
||
257 | .x dw 0 ; x-position |
||
258 | .y dw 0 ; y-position |
||
3545 | hidnplayr | 259 | |
260 | |||
261 | sockaddr1: |
||
5668 | hidnplayr | 262 | dw AF_INET4 |
263 | .port dw 0x0c17 ; 5900 |
||
264 | .ip dd 0 |
||
265 | rb 10 |
||
3545 | hidnplayr | 266 | |
5668 | hidnplayr | 267 | beep db 0x85, 0x25, 0x85, 0x40, 0 |
5663 | hidnplayr | 268 | |
5668 | hidnplayr | 269 | status dd STATUS_INITIAL |
270 | update_gui dd 0 |
||
271 | mouse_dd dd 0 |
||
272 | |||
5663 | hidnplayr | 273 | URLbox edit_box 200, 25, 16, 0xffffff, 0x6f9480, 0, 0, 0, 65535, serveraddr, mouse_dd, ed_focus, 0, 0 |
274 | |||
5668 | hidnplayr | 275 | serverstr db "server:" |
276 | userstr db "username:" |
||
277 | passstr db "password:" |
||
278 | connectstr db "connect" |
||
279 | loginstr db "login" |
||
280 | loginstr_e: |
||
281 | |||
282 | sz_err_disconnected db "Server closed connection unexpectedly.", 0 |
||
283 | sz_err_dns db "Could not resolve hostname.", 0 |
||
284 | sz_err_sock db "Could not open socket.", 0 |
||
285 | sz_err_connect db "Could not connect to the server.", 0 |
||
286 | sz_err_proto db "A protocol error has occured.", 0 |
||
287 | sz_err_security db "Server requested an unsupported security type.", 0 |
||
288 | sz_err_library db "Could not load needed libraries.", 0 |
||
289 | sz_err_thread db "Could not create thread.", 0 |
||
290 | |||
291 | err_msg dd sz_err_disconnected |
||
292 | dd sz_err_dns |
||
293 | dd sz_err_sock |
||
294 | dd sz_err_connect |
||
295 | dd sz_err_proto |
||
296 | dd sz_err_security |
||
297 | dd sz_err_library |
||
298 | dd sz_err_thread |
||
299 | |||
3545 | hidnplayr | 300 | ; import |
301 | align 4 |
||
302 | @IMPORT: |
||
303 | |||
5663 | hidnplayr | 304 | library network, "network.obj",\ |
305 | box_lib, "box_lib.obj",\ |
||
306 | archiver, "archiver.obj" |
||
3545 | hidnplayr | 307 | |
5663 | hidnplayr | 308 | import network,\ |
309 | getaddrinfo, "getaddrinfo", \ |
||
310 | freeaddrinfo, "freeaddrinfo", \ |
||
311 | inet_ntoa, "inet_ntoa" |
||
3545 | hidnplayr | 312 | |
5663 | hidnplayr | 313 | import box_lib,\ |
314 | edit_box_draw, "edit_box",\ |
||
315 | edit_box_key, "edit_box_key",\ |
||
316 | edit_box_mouse, "edit_box_mouse",\ |
||
317 | scrollbar_v_draw, "scrollbar_v_draw",\ |
||
318 | scrollbar_v_mouse, "scrollbar_v_mouse",\ |
||
319 | scrollbar_h_draw, "scrollbar_h_draw",\ |
||
320 | scrollbar_h_mouse, "scrollbar_h_mouse" |
||
321 | |||
322 | import archiver,\ |
||
323 | deflate_unpack, "deflate_unpack" |
||
324 | |||
5668 | hidnplayr | 325 | name db "VNC viewer " |
326 | .dash db 0, " " |
||
5663 | hidnplayr | 327 | |
3545 | hidnplayr | 328 | I_END: |
329 | |||
5663 | hidnplayr | 330 | servername rb 64+1 |
3545 | hidnplayr | 331 | |
5663 | hidnplayr | 332 | socketnum dd ? |
333 | datapointer dd ? |
||
5668 | hidnplayr | 334 | |
5663 | hidnplayr | 335 | rectangles dw ? |
3545 | hidnplayr | 336 | |
5663 | hidnplayr | 337 | rectangle: |
5668 | hidnplayr | 338 | .x dd ? |
339 | .y dd ? |
||
340 | .width dd ? |
||
341 | .height dd ? |
||
3545 | hidnplayr | 342 | |
5668 | hidnplayr | 343 | subrectangles dd ? |
344 | |||
345 | subrectangle: |
||
346 | .x dd ? |
||
347 | .y dd ? |
||
348 | .width dd ? |
||
349 | .height dd ? |
||
350 | |||
5663 | hidnplayr | 351 | screen: ; Remote screen resolution |
352 | .height dw ? |
||
353 | .width dw ? |
||
3545 | hidnplayr | 354 | |
5663 | hidnplayr | 355 | serveraddr rb 65536 |
5668 | hidnplayr | 356 | receive_buffer rb RECEIVE_BUFFER_SIZE |
5663 | hidnplayr | 357 | framebuffer_data rb 1024*1024*3 ; framebuffer |
3545 | hidnplayr | 358 | |
5663 | hidnplayr | 359 | rb 0x1000 |
3545 | hidnplayr | 360 | thread_stack: |
5663 | hidnplayr | 361 | rb 0x1000 |
3545 | hidnplayr | 362 | IM_END: |
363 |