Rev 264 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
264 | hidnplayr | 1 | thread_start: |
2 | DEBUGF 1,'I am the thread!\n' |
||
3 | |||
4 | mov eax,40 ; Report events |
||
5 | mov ebx,10000000b ; Only Stack |
||
485 | heavyiron | 6 | mcall |
264 | hidnplayr | 7 | |
8 | resolve first,[server_ip] ; the input window putted the server @ 'first', resolve it into a real ip |
||
9 | mov [server_port],5900 ; no port input for now, only standard port 5900 |
||
10 | |||
11 | DEBUGF 1,'connecting to %u.%u.%u.%u:%u\n',1[server_ip],1[server_ip+1],1[server_ip+2],1[server_ip+3],4[server_port] |
||
12 | eth.search_port 1000,edx ; Find a free port starting from 1001 and store in edx |
||
13 | eth.open_tcp edx,[server_port],[server_ip],1,[socket] ; open socket |
||
14 | DEBUGF 1,'Socket opened: %u (port %u)\n',[socket],ecx |
||
15 | |||
16 | call read_data |
||
17 | cmp dword[receive_buffer+1],'RFB ' |
||
18 | jne no_rfb |
||
19 | eth.write_tcp [socket],12,handshake |
||
20 | DEBUGF 1,'Sending handshake: protocol version\n' |
||
21 | |||
22 | call read_data |
||
23 | mov eax,receive_buffer+1 |
||
24 | mov eax,[eax] |
||
25 | bswap eax |
||
26 | cmp eax,0 |
||
27 | je invalid_security |
||
28 | cmp eax,1 |
||
29 | je no_security |
||
30 | cmp eax,2 |
||
31 | je vnc_security |
||
32 | |||
33 | jmp close |
||
34 | |||
35 | vnc_security: |
||
36 | mov byte[mode],1 |
||
37 | call red_logon |
||
38 | |||
39 | no_security: |
||
40 | eth.write_tcp [socket],1,shared |
||
41 | DEBUGF 1,'Sending handshake: shared session?\n' |
||
42 | |||
43 | eth.wait_for_data [socket],TIMEOUT*10,close |
||
44 | eth.read_data [socket],framebuffer,[datapointer],IM_END-receive_buffer ; now the server should send init message |
||
45 | DEBUGF 1,'Serverinit: bpp:%u depth:%u bigendian:%u truecolor:%u\n',1[pixelformat.bpp],1[pixelformat.depth],1[pixelformat.big_endian],1[pixelformat.true_color] |
||
46 | mov eax,dword[framebuffer] |
||
47 | bswap eax |
||
48 | mov dword[screen],eax |
||
49 | |||
50 | eth.write_tcp [socket],20,pixel_format8 |
||
51 | DEBUGF 1,'Sending pixel format\n' |
||
52 | call read_data |
||
53 | |||
54 | ; eth.write_tcp [socket],8,encodings |
||
55 | ; DEBUGF 1,'Sending encoding info\n' |
||
56 | ; call read_data |
||
57 | |||
58 | mov eax,dword[framebuffer.width] |
||
59 | mov dword[fbur.width],eax |
||
60 | |||
61 | mov byte[thread_ready],1 |
||
62 | |||
63 | request_rfb: |
||
64 | mov byte[fbur.inc],2 ;;;;;;;; |
||
65 | eth.write_tcp [socket],10,fbur ;;;;;;;;; |
||
66 | |||
67 | thread_loop: |
||
68 | eth.wait_for_data [socket],1000,thread_loop |
||
69 | |||
70 | call read_data ; Read the data into the buffer |
||
71 | |||
72 | mov eax,[datapointer] ; at least 2 bytes should be received |
||
73 | sub eax,receive_buffer |
||
74 | cmp eax,1 |
||
75 | jle mainloop |
||
76 | |||
77 | DEBUGF 1,'Data received, %u bytes\n',eax |
||
78 | |||
79 | cmp byte[receive_buffer],0 |
||
80 | je framebufferupdate |
||
81 | |||
82 | cmp byte[receive_buffer],1 |
||
83 | je setcolourmapentries |
||
84 | |||
85 | cmp byte[receive_buffer],2 |
||
86 | je bell |
||
87 | |||
88 | cmp byte[receive_buffer],3 |
||
89 | je servercuttext |
||
90 | |||
91 | jmp thread_loop |
||
92 | |||
93 | |||
94 | framebufferupdate: |
||
95 | mov ax,word[receive_buffer+2] |
||
96 | xchg al,ah |
||
97 | mov di,ax |
||
98 | DEBUGF 1,'Framebufferupdate: %u frames\n',di |
||
99 | mov esi,receive_buffer+4 |
||
100 | jmp rectangle_loop |
||
101 | |||
102 | next_rectangle: |
||
103 | call drawbuffer |
||
104 | |||
105 | dec di |
||
106 | test di,di |
||
107 | jz request_rfb |
||
108 | |||
109 | rectangle_loop: |
||
110 | mov edx,[esi] |
||
111 | bswap edx |
||
112 | mov ebx,edx |
||
113 | shr edx,16 |
||
114 | mov [frame.x],dx |
||
115 | mov [frame.y],bx |
||
116 | add esi,4 |
||
117 | mov ecx,[esi] |
||
118 | bswap ecx |
||
119 | mov eax,ecx |
||
120 | shr ecx,16 |
||
121 | mov [frame.width],cx |
||
122 | mov [frame.height],ax |
||
123 | add esi,4 |
||
124 | mov eax,[esi] |
||
125 | add esi,4 |
||
126 | |||
127 | mov ebx,esi |
||
128 | sub ebx,receive_buffer+12 |
||
129 | DEBUGF 1,'frame: width=%u height=%u x=%u y=%u offset:%u encoding:',2[frame.width],2[frame.height],2[frame.x],2[frame.y],ebx |
||
130 | |||
131 | cmp eax,0 |
||
132 | je encoding_raw |
||
133 | cmp eax,1 |
||
134 | je encoding_copyrect |
||
135 | cmp eax,2 |
||
136 | je encoding_RRE |
||
137 | cmp eax,5 |
||
138 | je encoding_hextile |
||
139 | cmp eax,16 |
||
140 | je encoding_ZRLE |
||
141 | |||
142 | mov ebx,esi |
||
143 | sub ebx,receive_buffer+8 |
||
144 | DEBUGF 1,'\nunknown encoding: %u (offset %u)\n',eax,ebx |
||
145 | jmp bell |
||
146 | jmp thread_loop |
||
147 | |||
148 | encoding_RRE: |
||
149 | DEBUGF 1,'RRE\n' |
||
150 | |||
151 | jmp next_rectangle |
||
152 | |||
153 | encoding_hextile: |
||
154 | DEBUGF 1,'hextile\n' |
||
155 | |||
156 | jmp next_rectangle |
||
157 | |||
158 | encoding_ZRLE: |
||
159 | DEBUGF 1,'ZRLE\n' |
||
160 | |||
161 | jmp next_rectangle |
||
162 | |||
163 | |||
164 | setcolourmapentries: |
||
165 | DEBUGF 1,'Server sended SetColourMapEntries message\n' |
||
166 | |||
167 | jmp thread_loop |
||
168 | |||
169 | |||
170 | bell: |
||
171 | mov eax,55 |
||
172 | mov ebx,eax |
||
173 | mov esi,beep |
||
485 | heavyiron | 174 | mcall |
264 | hidnplayr | 175 | |
176 | jmp thread_loop |
||
177 | |||
178 | |||
179 | servercuttext: |
||
180 | DEBUGF 1,'Server cut text\n' |
||
181 | |||
182 | jmp thread_loop |
||
183 | |||
184 | |||
185 | |||
186 | read_data: |
||
187 | eth.read_data [socket],receive_buffer,[datapointer],IM_END-receive_buffer |
||
188 | ret |