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