Rev 5720 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5720 | Rev 5722 | ||
---|---|---|---|
Line 69... | Line 69... | ||
69 | mcall connect, [socketnum], sockaddr1, 18 |
69 | mcall connect, [socketnum], sockaddr1, 18 |
70 | cmp eax, -1 |
70 | cmp eax, -1 |
71 | je err_connect |
71 | je err_connect |
Line 72... | Line 72... | ||
72 | 72 | ||
73 | ; Verify handshake from server |
73 | ; Verify handshake from server |
- | 74 | call read_data |
|
- | 75 | cmp eax, 12 |
|
74 | call wait_for_data |
76 | jb err_proto |
75 | cmp dword[receive_buffer], "RFB " |
77 | cmp dword[esi], "RFB " |
76 | jne err_proto |
78 | jne err_proto |
Line 77... | Line 79... | ||
77 | add esi, 12 |
79 | add esi, 12 |
78 | 80 | ||
Line 87... | Line 89... | ||
87 | ; Reply to handshake |
89 | ; Reply to handshake |
88 | DEBUGF 1, "Sending handshake\n" |
90 | DEBUGF 1, "Sending handshake\n" |
89 | mcall send, [socketnum], HandShake, 12, 0 |
91 | mcall send, [socketnum], HandShake, 12, 0 |
Line 90... | Line 92... | ||
90 | 92 | ||
91 | ; VNC 3.3 protocol: server decides security type |
93 | ; VNC 3.3 protocol: server decides security type |
- | 94 | call read_data |
|
- | 95 | cmp eax, 4 |
|
92 | call wait_for_data |
96 | jb err_proto |
93 | lodsd |
97 | lodsd |
94 | cmp eax, 0x00000000 |
98 | cmp eax, 0x00000000 |
95 | je err_handshake |
99 | je err_handshake |
96 | cmp eax, 0x01000000 ; no security |
100 | cmp eax, 0x01000000 ; no security |
Line 99... | Line 103... | ||
99 | je vnc_security |
103 | je vnc_security |
100 | jmp err_proto |
104 | jmp err_proto |
Line 101... | Line 105... | ||
101 | 105 | ||
Line -... | Line 106... | ||
- | 106 | vnc_security: |
|
- | 107 | ||
- | 108 | lea eax, [esi+8] |
|
- | 109 | cmp [datapointer], eax |
|
102 | vnc_security: |
110 | jb err_proto |
Line 103... | Line 111... | ||
103 | 111 | ||
104 | push esi ; pointer to message |
112 | push esi ; pointer to message |
Line 194... | Line 202... | ||
194 | pop edx |
202 | pop edx |
195 | mcall send, [socketnum], , 16, 0 |
203 | mcall send, [socketnum], , 16, 0 |
Line 196... | Line 204... | ||
196 | 204 | ||
197 | securityresult: |
205 | securityresult: |
198 | ; Wait for SecurityResult from server |
206 | ; Wait for SecurityResult from server |
- | 207 | call read_data |
|
- | 208 | cmp eax, 4 |
|
199 | call wait_for_data |
209 | jb err_proto |
200 | cmp dword[receive_buffer], 0 ; OK |
210 | cmp dword[esi], 0 ; OK |
Line 201... | Line 211... | ||
201 | jne err_login |
211 | jne err_login |
202 | 212 | ||
203 | initialize: |
213 | initialize: |
Line 204... | Line 214... | ||
204 | DEBUGF 1, "Sending ClientInit\n" |
214 | DEBUGF 1, "Sending ClientInit\n" |
- | 215 | mcall send, [socketnum], ClientInit, 1, 0 |
|
- | 216 | ||
205 | mcall send, [socketnum], ClientInit, 1, 0 |
217 | call read_data ; now the server should send init message |
206 | 218 | cmp eax, ServerInit.name |
|
207 | call wait_for_data ; now the server should send init message |
219 | jb err_proto |
208 | 220 | ||
209 | DEBUGF 1, "Serverinit: bpp: %u depth: %u bigendian: %u truecolor: %u\n", \ |
221 | DEBUGF 2, "Serverinit: bpp: %u depth: %u bigendian: %u truecolor: %u\n", \ |
210 | [receive_buffer+framebuffer.pixelformat.bpp]:1, \ |
222 | [esi+ServerInit.pixelformat.bpp]:1, \ |
Line 211... | Line 223... | ||
211 | [receive_buffer+framebuffer.pixelformat.depth]:1, \ |
223 | [esi+ServerInit.pixelformat.depth]:1, \ |
212 | [receive_buffer+framebuffer.pixelformat.big_endian]:1, \ |
224 | [esi+ServerInit.pixelformat.big_endian]:1, \ |
213 | [receive_buffer+framebuffer.pixelformat.true_color]:1 |
225 | [esi+ServerInit.pixelformat.true_color]:1 |
214 | 226 | ||
215 | mov eax, dword[receive_buffer+framebuffer.width] |
227 | mov eax, dword[esi+ServerInit.width] |
Line -... | Line 228... | ||
- | 228 | mov dword[FramebufferUpdateRequest.width], eax |
|
- | 229 | bswap eax |
|
- | 230 | mov dword[screen], eax |
|
- | 231 | DEBUGF 1, "Screen width=%u, height=%u\n", [screen.width]:2, [screen.height]:2 |
|
- | 232 | ||
- | 233 | ; Set main window caption to servername |
|
- | 234 | mov ecx, dword[esi+ServerInit.name_length] |
|
- | 235 | bswap ecx |
|
- | 236 | add esi, ServerInit.name |
|
- | 237 | lea eax, [esi+ecx] |
|
- | 238 | cmp [datapointer], eax |
|
- | 239 | jb err_proto |
|
- | 240 | cmp ecx, 64 ; Limit name length to 64 chars |
|
- | 241 | jbe @f |
|
- | 242 | mov ecx, 64 |
|
- | 243 | @@: |
|
216 | mov dword[FramebufferUpdateRequest.width], eax |
244 | mov edi, servername |
217 | bswap eax |
245 | rep movsb |
218 | mov dword[screen], eax |
246 | mov byte[edi], 0 |
219 | DEBUGF 1, "Screen width=%u, height=%u\n", [screen.width]:2, [screen.height]:2 |
247 | mov [name.dash], "-" |
220 | 248 | ||
221 | DEBUGF 1, "Sending pixel format\n" |
249 | DEBUGF 1, "Sending pixel format\n" |
222 | if BITS_PER_PIXEL = 8 |
250 | if BITS_PER_PIXEL = 8 |
- | 251 | mcall send, [socketnum], SetPixelFormat8, 20, 0 |
|
- | 252 | else if BITS_PER_PIXEL = 16 |
|
223 | mcall send, [socketnum], SetPixelFormat8, 20, 0 |
253 | mcall send, [socketnum], SetPixelFormat16, 20, 0 |
Line 224... | Line 254... | ||
224 | else if BITS_PER_PIXEL = 16 |
254 | else if BITS_PER_PIXEL = 24 |
225 | mcall send, [socketnum], SetPixelFormat16, 20, 0 |
255 | mcall send, [socketnum], SetPixelFormat24, 20, 0 |
Line 226... | Line -... | ||
226 | else |
- | |
227 | mcall send, [socketnum], SetPixelFormat24, 20, 0 |
- | |
228 | end if |
- | |
229 | - | ||
230 | DEBUGF 1, "Sending encoding info\n" |
- | |
231 | mcall send, [socketnum], SetEncodings, SetEncodings.length, 0 |
- | |
232 | - | ||
233 | ; Set main window caption to servername |
- | |
234 | mov ecx, dword[receive_buffer+framebuffer.name_length] |
- | |
235 | bswap ecx |
- | |
236 | cmp ecx, 64 |
- | |
237 | jbe @f |
- | |
238 | mov ecx, 64 |
- | |
239 | @@: |
256 | else |
240 | lea esi, [receive_buffer+framebuffer.name] |
257 | mcall send, [socketnum], SetPixelFormat32, 20, 0 |
Line 241... | Line 258... | ||
241 | mov edi, servername |
258 | end if |
242 | rep movsb |
259 | |
Line 441... | Line 458... | ||
441 | mov [datapointer], edi ; new end of data |
458 | mov [datapointer], edi ; new end of data |
442 | mov esi, receive_buffer ; new start of data |
459 | mov esi, receive_buffer ; new start of data |
443 | jmp .more |
460 | jmp .more |
Line 444... | Line -... | ||
444 | - | ||
445 | - | ||
446 | - | ||
447 | wait_for_data: ; FIXME: add timeout |
- | |
448 | mcall recv, [socketnum], receive_buffer, 4096, 0 ; MSG_DONTWAIT |
- | |
449 | cmp eax, -1 |
- | |
450 | je err_sock |
- | |
451 | test eax, eax |
- | |
452 | jz err_disconnected |
- | |
453 | mov esi, receive_buffer |
- | |
454 | ret |
- | |
455 | 461 | ||
456 | 462 | ||
457 | err_disconnected: |
463 | err_disconnected: |
458 | mov [status], STATUS_DISCONNECTED |
464 | mov [status], STATUS_DISCONNECTED |
Line 463... | Line 469... | ||
463 | mov [status], STATUS_DNS_ERR |
469 | mov [status], STATUS_DNS_ERR |
464 | inc [update_gui] |
470 | inc [update_gui] |
465 | mcall -1 |
471 | mcall -1 |
Line 466... | Line 472... | ||
466 | 472 | ||
- | 473 | err_sock: |
|
- | 474 | ; TODO: distinguish between different socket errors! |
|
467 | err_sock: |
475 | DEBUGF 2, "Socket error: %u\n", ebx |
468 | mov [status], STATUS_SOCK_ERR |
476 | mov [status], STATUS_SOCK_ERR |
469 | inc [update_gui] |
477 | inc [update_gui] |
Line 470... | Line 478... | ||
470 | mcall -1 |
478 | mcall -1 |