Rev 3618 | Rev 5666 | 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" |
||
70 | include "thread.inc" |
||
71 | |||
3545 | hidnplayr | 72 | START: |
73 | |||
74 | mcall 68, 11 ; init heap |
||
75 | |||
76 | ; load libraries |
||
77 | stdcall dll.Load, @IMPORT |
||
78 | test eax, eax |
||
79 | jnz exit |
||
80 | |||
5663 | hidnplayr | 81 | call logon |
3545 | hidnplayr | 82 | |
5663 | hidnplayr | 83 | mcall 40, 0 ; disable all events |
3545 | hidnplayr | 84 | mcall 67, 0, 0, 0, 0 ; resize the window (hide it) |
85 | mcall 51, 1, thread_start, thread_stack |
||
86 | |||
5663 | hidnplayr | 87 | DEBUGF 1,"Thread created: %u\n", eax |
3545 | hidnplayr | 88 | |
89 | @@: |
||
90 | mcall 5, 10 |
||
5663 | hidnplayr | 91 | cmp byte[thread_ready], 0 |
3545 | hidnplayr | 92 | je @r |
93 | |||
5663 | hidnplayr | 94 | mcall 40, EVM_MOUSE + EVM_MOUSE_FILTER + EVM_KEY + EVM_REDRAW + EVM_BUTTON |
3545 | hidnplayr | 95 | |
5663 | hidnplayr | 96 | mov edx, dword[screen] |
3545 | hidnplayr | 97 | movzx esi, dx |
98 | shr edx, 16 |
||
99 | add edx, 2*xpos |
||
100 | add esi, ypos+xpos |
||
101 | mcall 67, 10, 10 ; resize the window |
||
102 | |||
103 | mainloop: |
||
5663 | hidnplayr | 104 | mcall 10 ; wait for event |
3545 | hidnplayr | 105 | |
106 | dec eax |
||
107 | jz redraw |
||
108 | dec eax |
||
109 | jz key |
||
110 | dec eax |
||
111 | jz button |
||
112 | sub eax, 3 |
||
113 | jz mouse |
||
114 | jmp mainloop |
||
115 | |||
116 | key: |
||
117 | |||
5663 | hidnplayr | 118 | ; DEBUGF 1,"Sending key event\n" |
3545 | hidnplayr | 119 | |
120 | mcall 2 |
||
5663 | hidnplayr | 121 | mov byte[keyevent.key+3], ah |
3545 | hidnplayr | 122 | |
123 | mcall send, [socketnum], keyevent, 8, 0 |
||
124 | jmp mainloop |
||
125 | |||
126 | mouse: |
||
127 | |||
5663 | hidnplayr | 128 | ; DEBUGF 1,"Sending mouse event\n" |
3545 | hidnplayr | 129 | |
130 | mcall 37, 1 ; get mouse pos |
||
131 | sub eax, xpos shl 16 + ypos |
||
132 | bswap eax |
||
133 | mov [pointerevent.x], ax |
||
134 | shr eax, 16 |
||
135 | mov [pointerevent.y], ax |
||
136 | |||
137 | mcall 37, 2 ; get mouse buttons |
||
138 | test al, 00000010b ; test if right button was pressed (bit 1 in kolibri) |
||
139 | jz @f |
||
5663 | hidnplayr | 140 | 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 | 141 | @@: |
142 | mov [pointerevent.mask],al |
||
143 | |||
144 | mcall send, [socketnum], pointerevent, 6, 0 |
||
145 | jmp mainloop |
||
146 | |||
147 | redraw: |
||
148 | |||
5663 | hidnplayr | 149 | ; DEBUGF 1,"Drawing window\n" |
3545 | hidnplayr | 150 | |
151 | mcall 12, 1 |
||
152 | |||
153 | mov ebx, dword[screen] |
||
154 | movzx ecx, bx |
||
155 | shr ebx, 16 |
||
156 | mov edx, 0x74ffffff |
||
157 | mov edi, name |
||
158 | mcall 0 ; draw window |
||
159 | |||
160 | call drawbuffer |
||
161 | |||
162 | mcall 12, 2 |
||
163 | |||
164 | jmp mainloop |
||
165 | |||
166 | drawbuffer: |
||
167 | mcall 7, framebuffer_data, dword[screen], 0 |
||
168 | ret |
||
169 | |||
170 | button: |
||
171 | mcall 17 ; get id |
||
172 | |||
173 | exit: |
||
5663 | hidnplayr | 174 | DEBUGF 1, "Closing time!\n" |
3545 | hidnplayr | 175 | mcall close, [socketnum] |
176 | mcall -1 |
||
177 | |||
178 | no_rfb: |
||
5663 | hidnplayr | 179 | DEBUGF 1, "This is no vnc server!\n" |
3545 | hidnplayr | 180 | jmp exit |
181 | |||
182 | invalid_security: |
||
5663 | hidnplayr | 183 | DEBUGF 1, "Security error: %s\n", receive_buffer+5 |
3545 | hidnplayr | 184 | jmp exit |
185 | |||
186 | |||
187 | ; DATA AREA |
||
188 | |||
189 | include_debug_strings ; ALWAYS present in data section |
||
190 | |||
5663 | hidnplayr | 191 | handshake db "RFB 003.003", 10 |
192 | ClientInit db 0 ; not shared |
||
193 | beep db 0x85, 0x25, 0x85, 0x40, 0 |
||
3545 | hidnplayr | 194 | |
5663 | hidnplayr | 195 | pixel_format32 db 0 ; setPixelformat |
196 | db 0, 0, 0 ; padding |
||
197 | .bpp db 32 ; bits per pixel |
||
198 | .depth db 32 ; depth |
||
199 | .big_endian db 0 ; big-endian flag |
||
200 | .true_color db 1 ; true-colour flag |
||
201 | .red_max db 0, 255 ; red-max |
||
202 | .green_max db 0, 255 ; green-max |
||
203 | .blue_max db 0, 255 ; blue-max |
||
204 | .red_shif db 0 ; red-shift |
||
205 | .green_shift db 8 ; green-shift |
||
206 | .blue_shift db 16 ; blue-shift |
||
207 | db 0, 0, 0 ; padding |
||
3545 | hidnplayr | 208 | |
5663 | hidnplayr | 209 | pixel_format16 db 0 ; setPixelformat |
210 | db 0, 0, 0 ; padding |
||
211 | .bpp db 16 ; bits per pixel |
||
212 | .depth db 15 ; depth |
||
213 | .big_endian db 0 ; big-endian flag |
||
214 | .true_color db 1 ; true-colour flag |
||
215 | .red_max db 0, 31 ; red-max |
||
216 | .green_max db 0, 31 ; green-max |
||
217 | .blue_max db 0, 31 ; blue-max |
||
218 | .red_shif db 0 ; red-shift |
||
219 | .green_shift db 5 ; green-shift |
||
220 | .blue_shift db 10 ; blue-shift |
||
221 | db 0, 0, 0 ; padding |
||
3545 | hidnplayr | 222 | |
5663 | hidnplayr | 223 | pixel_format8 db 0 ; setPixelformat |
224 | db 0, 0, 0 ; padding |
||
225 | .bpp db 8 ; bits per pixel |
||
226 | .depth db 6 ; depth |
||
227 | .big_endian db 0 ; big-endian flag |
||
228 | .true_color db 1 ; true-colour flag |
||
229 | .red_max db 0, 3 ; red-max |
||
230 | .green_max db 0, 3 ; green-max |
||
231 | .blue_max db 0, 3 ; blue-max |
||
232 | .red_shif db 0 ; red-shift |
||
233 | .green_shift db 2 ; green-shift |
||
234 | .blue_shift db 4 ; blue-shift |
||
235 | db 0, 0, 0 ; padding |
||
3545 | hidnplayr | 236 | |
5663 | hidnplayr | 237 | encodings db 2 ; setEncodings |
238 | db 0 ; padding |
||
239 | db 0, 1 ; number of encodings |
||
240 | db 0, 0, 0 ,0 ; raw encoding (DWORD, Big endian order) |
||
241 | ; db 1, 0, 0, 0 ; Copyrect encoding |
||
242 | ; db |
||
3545 | hidnplayr | 243 | |
5663 | hidnplayr | 244 | fbur db 3 ; frame buffer update request |
245 | .inc db 0 ; incremental |
||
3545 | hidnplayr | 246 | .x dw 0 |
247 | .y dw 0 |
||
248 | .width dw 0 |
||
249 | .height dw 0 |
||
250 | |||
5663 | hidnplayr | 251 | keyevent db 4 ; keyevent |
252 | .down db 0 ; down-flag |
||
253 | dw 0 ; padding |
||
254 | .key dd 0 ; key |
||
3545 | hidnplayr | 255 | |
5663 | hidnplayr | 256 | pointerevent db 5 ; pointerevent |
257 | .mask db 0 ; button-mask |
||
258 | .x dw 0 ; x-position |
||
259 | .y dw 0 ; y-position |
||
3545 | hidnplayr | 260 | |
261 | |||
262 | sockaddr1: |
||
263 | dw AF_INET4 |
||
5663 | hidnplayr | 264 | .port dw 0x0c17 ; 5900 |
3545 | hidnplayr | 265 | .ip dd 0 |
266 | rb 10 |
||
267 | |||
268 | thread_ready db 0 |
||
5663 | hidnplayr | 269 | mouse_dd dd ? |
270 | |||
271 | URLbox edit_box 200, 25, 16, 0xffffff, 0x6f9480, 0, 0, 0, 65535, serveraddr, mouse_dd, ed_focus, 0, 0 |
||
272 | |||
3545 | hidnplayr | 273 | ; import |
274 | align 4 |
||
275 | @IMPORT: |
||
276 | |||
5663 | hidnplayr | 277 | library network, "network.obj",\ |
278 | box_lib, "box_lib.obj",\ |
||
279 | archiver, "archiver.obj" |
||
3545 | hidnplayr | 280 | |
5663 | hidnplayr | 281 | import network,\ |
282 | getaddrinfo, "getaddrinfo", \ |
||
283 | freeaddrinfo, "freeaddrinfo", \ |
||
284 | inet_ntoa, "inet_ntoa" |
||
3545 | hidnplayr | 285 | |
5663 | hidnplayr | 286 | import box_lib,\ |
287 | edit_box_draw, "edit_box",\ |
||
288 | edit_box_key, "edit_box_key",\ |
||
289 | edit_box_mouse, "edit_box_mouse",\ |
||
290 | scrollbar_v_draw, "scrollbar_v_draw",\ |
||
291 | scrollbar_v_mouse, "scrollbar_v_mouse",\ |
||
292 | scrollbar_h_draw, "scrollbar_h_draw",\ |
||
293 | scrollbar_h_mouse, "scrollbar_h_mouse" |
||
294 | |||
295 | import archiver,\ |
||
296 | deflate_unpack, "deflate_unpack" |
||
297 | |||
298 | name db "VNC client " |
||
299 | name.dash db 0, " " |
||
300 | |||
3545 | hidnplayr | 301 | I_END: |
302 | |||
5663 | hidnplayr | 303 | servername rb 64+1 |
3545 | hidnplayr | 304 | |
5663 | hidnplayr | 305 | socketnum dd ? |
306 | datapointer dd ? |
||
307 | rectangles dw ? |
||
3545 | hidnplayr | 308 | |
5663 | hidnplayr | 309 | rectangle: |
310 | .width dw ? |
||
311 | .height dw ? |
||
312 | .x dw ? |
||
313 | .y dw ? |
||
3545 | hidnplayr | 314 | |
5663 | hidnplayr | 315 | screen: ; Remote screen resolution |
316 | .height dw ? |
||
317 | .width dw ? |
||
3545 | hidnplayr | 318 | |
5663 | hidnplayr | 319 | serveraddr rb 65536 |
320 | receive_buffer rb 5*1024*1024 ; 5 mb buffer for received data (incoming frbupdate etc) |
||
321 | framebuffer_data rb 1024*1024*3 ; framebuffer |
||
3545 | hidnplayr | 322 | |
5663 | hidnplayr | 323 | rb 0x1000 |
3545 | hidnplayr | 324 | thread_stack: |
325 | |||
5663 | hidnplayr | 326 | rb 0x1000 |
327 | |||
3545 | hidnplayr | 328 | IM_END: |
329 |