Rev 3545 | 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 | ;; ;; |
||
3 | ;; Copyright (C) KolibriOS team 2010-2013. All rights reserved. ;; |
||
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 | STRLEN = 64 ; password and server max length |
||
21 | xpos = 4 ; coordinates of image |
||
22 | ypos = 22 ; |
||
23 | |||
24 | TIMEOUT = 5 ; timeout in seconds |
||
25 | |||
3545 | hidnplayr | 26 | use32 |
27 | |||
28 | org 0x0 |
||
29 | |||
3618 | hidnplayr | 30 | db 'MENUET01' ; 8 byte id |
31 | dd 0x01 ; header version |
||
32 | dd START ; start of code |
||
33 | dd I_END ; size of image |
||
34 | dd IM_END ; memory for app |
||
35 | dd IM_END ; esp |
||
36 | dd 0x0 , 0x0 ; I_Param , I_Path |
||
3545 | hidnplayr | 37 | |
38 | |||
3618 | hidnplayr | 39 | include '../../macros.inc' |
40 | include '../../debug-fdo.inc' |
||
41 | include '../../proc32.inc' |
||
42 | include '../../dll.inc' |
||
43 | include '../../struct.inc' |
||
44 | include '../../network.inc' |
||
3545 | hidnplayr | 45 | |
46 | include 'structs.inc' |
||
47 | include 'logon.inc' |
||
48 | include 'raw.inc' |
||
49 | include 'thread.inc' |
||
50 | |||
51 | START: |
||
52 | |||
53 | mcall 68, 11 ; init heap |
||
54 | |||
55 | ; load libraries |
||
56 | stdcall dll.Load, @IMPORT |
||
57 | test eax, eax |
||
58 | jnz exit |
||
59 | |||
60 | call red_logon |
||
61 | |||
62 | mcall 40, 0 ; no events |
||
63 | mcall 67, 0, 0, 0, 0 ; resize the window (hide it) |
||
64 | mcall 51, 1, thread_start, thread_stack |
||
65 | |||
66 | DEBUGF 1,'Thread created: %u\n', eax |
||
67 | |||
68 | @@: |
||
69 | mcall 5, 10 |
||
70 | cmp byte [thread_ready], 0 |
||
71 | je @r |
||
72 | |||
73 | mcall 40, 100111b ; mouse, button, key, redraw |
||
74 | |||
75 | |||
76 | mov edx, dword [screen] |
||
77 | movzx esi, dx |
||
78 | shr edx, 16 |
||
79 | add edx, 2*xpos |
||
80 | add esi, ypos+xpos |
||
81 | mcall 67, 10, 10 ; resize the window |
||
82 | |||
83 | mainloop: |
||
84 | mcall 23, 50 ; wait for event, 0,5s timeout |
||
85 | |||
86 | dec eax |
||
87 | jz redraw |
||
88 | |||
89 | dec eax |
||
90 | jz key |
||
91 | |||
92 | dec eax |
||
93 | jz button |
||
94 | |||
95 | sub eax, 3 |
||
96 | jz mouse |
||
97 | |||
98 | jmp mainloop |
||
99 | |||
100 | key: |
||
101 | |||
102 | DEBUGF 1,'Sending key event\n' |
||
103 | |||
104 | mcall 2 |
||
105 | mov byte [keyevent.key+3], ah |
||
106 | |||
107 | mcall send, [socketnum], keyevent, 8, 0 |
||
108 | jmp mainloop |
||
109 | |||
110 | mouse: |
||
111 | |||
112 | DEBUGF 1,'Sending mouse event\n' |
||
113 | |||
114 | mcall 37, 1 ; get mouse pos |
||
115 | sub eax, xpos shl 16 + ypos |
||
116 | bswap eax |
||
117 | mov [pointerevent.x], ax |
||
118 | shr eax, 16 |
||
119 | mov [pointerevent.y], ax |
||
120 | |||
121 | mcall 37, 2 ; get mouse buttons |
||
122 | test al, 00000010b ; test if right button was pressed (bit 1 in kolibri) |
||
123 | jz @f |
||
124 | 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 |
||
125 | @@: |
||
126 | mov [pointerevent.mask],al |
||
127 | |||
128 | mcall send, [socketnum], pointerevent, 6, 0 |
||
129 | jmp mainloop |
||
130 | |||
131 | redraw: |
||
132 | |||
133 | DEBUGF 1,'Drawing window\n' |
||
134 | |||
135 | mcall 12, 1 |
||
136 | |||
137 | mov ebx, dword[screen] |
||
138 | movzx ecx, bx |
||
139 | shr ebx, 16 |
||
140 | mov edx, 0x74ffffff |
||
141 | mov edi, name |
||
142 | mcall 0 ; draw window |
||
143 | |||
144 | call drawbuffer |
||
145 | |||
146 | mcall 12, 2 |
||
147 | |||
148 | jmp mainloop |
||
149 | |||
150 | drawbuffer: |
||
151 | |||
152 | mcall 7, framebuffer_data, dword[screen], 0 |
||
153 | ret |
||
154 | |||
155 | |||
156 | button: |
||
157 | mcall 17 ; get id |
||
158 | |||
159 | exit: |
||
160 | DEBUGF 1, 'Closing time!\n' |
||
161 | mcall close, [socketnum] |
||
162 | mcall -1 |
||
163 | |||
164 | no_rfb: |
||
165 | DEBUGF 1, 'This is no vnc server!\n' |
||
166 | jmp exit |
||
167 | |||
168 | invalid_security: |
||
169 | DEBUGF 1, 'Security error: %s\n', receive_buffer+5 |
||
170 | jmp exit |
||
171 | |||
172 | |||
173 | ; DATA AREA |
||
174 | |||
175 | include_debug_strings ; ALWAYS present in data section |
||
176 | |||
177 | handshake db 'RFB 003.003', 10 |
||
178 | shared db 0 |
||
179 | beep db 0x85,0x25,0x85,0x40,0 |
||
180 | |||
181 | pixel_format32 db 0 ; setPixelformat |
||
182 | rb 3 ; padding |
||
183 | .bpp db 32 ; bits per pixel |
||
184 | .depth db 32 ; depth |
||
185 | .big_endian db 0 ; big-endian flag |
||
186 | .true_color db 1 ; true-colour flag |
||
187 | .red_max db 0,255 ; red-max |
||
188 | .green_max db 0,255 ; green-max |
||
189 | .blue_max db 0,255 ; blue-max |
||
190 | .red_shif db 0 ; red-shift |
||
191 | .green_shift db 8 ; green-shift |
||
192 | .blue_shift db 16 ; blue-shift |
||
193 | rb 3 ; padding |
||
194 | |||
195 | pixel_format16 db 0 ; setPixelformat |
||
196 | rb 3 ; padding |
||
197 | .bpp db 16 ; bits per pixel |
||
198 | .depth db 15 ; depth |
||
199 | .big_endian db 0 ; big-endian flag |
||
200 | .true_color db 1 ; true-colour flag |
||
201 | .red_max db 0,31 ; red-max |
||
202 | .green_max db 0,31 ; green-max |
||
203 | .blue_max db 0,31 ; blue-max |
||
204 | .red_shif db 0 ; red-shift |
||
205 | .green_shift db 5 ; green-shift |
||
206 | .blue_shift db 10 ; blue-shift |
||
207 | rb 3 ; padding |
||
208 | |||
209 | pixel_format8 db 0 ; setPixelformat |
||
210 | rb 3 ; padding |
||
211 | .bpp db 8 ; bits per pixel |
||
212 | .depth db 6 ; depth |
||
213 | .big_endian db 0 ; big-endian flag |
||
214 | .true_color db 1 ; true-colour flag |
||
215 | .red_max db 0,3 ; red-max |
||
216 | .green_max db 0,3 ; green-max |
||
217 | .blue_max db 0,3 ; blue-max |
||
218 | .red_shif db 0 ; red-shift |
||
219 | .green_shift db 2 ; green-shift |
||
220 | .blue_shift db 4 ; blue-shift |
||
221 | rb 3 ; padding |
||
222 | |||
223 | encodings db 2 ; setEncodings |
||
224 | rb 1 ; padding |
||
225 | db 1,0 ; number of encodings |
||
226 | db 0,0,0,0 ; raw encoding (DWORD, Big endian order) |
||
227 | db 1,0,0,0 ; Copyrect encoding |
||
228 | |||
229 | fbur db 3 ; frame buffer update request |
||
230 | .inc db 0 ; incremental |
||
231 | .x dw 0 |
||
232 | .y dw 0 |
||
233 | .width dw 0 |
||
234 | .height dw 0 |
||
235 | |||
236 | keyevent db 4 ; keyevent |
||
237 | .down db 0 ; down-flag |
||
238 | dw 0 ; padding |
||
239 | .key dd 0 ; key |
||
240 | |||
241 | pointerevent db 5 ; pointerevent |
||
242 | .mask db 0 ; button-mask |
||
243 | .x dw 0 ; x-position |
||
244 | .y dw 0 ; y-position |
||
245 | |||
246 | |||
247 | sockaddr1: |
||
248 | dw AF_INET4 |
||
249 | .port dw 0x0c17 ; 5900 |
||
250 | .ip dd 0 |
||
251 | rb 10 |
||
252 | |||
253 | thread_ready db 0 |
||
254 | ; import |
||
255 | align 4 |
||
256 | @IMPORT: |
||
257 | |||
258 | library network, 'network.obj' |
||
259 | import network, \ |
||
260 | getaddrinfo, 'getaddrinfo', \ |
||
261 | freeaddrinfo, 'freeaddrinfo', \ |
||
262 | inet_ntoa, 'inet_ntoa' |
||
263 | |||
264 | name db 'VNC client', 0 |
||
265 | |||
266 | I_END: |
||
267 | |||
268 | socketnum dd ? |
||
269 | datapointer dd ? |
||
270 | |||
271 | frame: |
||
272 | .width dw ? |
||
273 | .height dw ? |
||
274 | .x dw ? |
||
275 | .y dw ? |
||
276 | |||
277 | screen: |
||
278 | .height dw ? |
||
279 | .width dw ? |
||
280 | |||
281 | receive_buffer rb 5*1024*1024 ; 5 mb buffer for received data (incoming frbupdate etc) |
||
282 | framebuffer_data rb 1024*768*3 ; framebuffer |
||
283 | |||
284 | |||
285 | rb 0x1000 |
||
286 | thread_stack: |
||
287 | |||
288 | rb 0x1000 |
||
289 | IM_END: |
||
290 |