25 |
{ |
{ |
26 |
HCONN conn; |
HCONN conn; |
27 |
RDP_ACTIVE_PDU active; |
RDP_ACTIVE_PDU active; |
|
RDP_DATA_HEADER hdr; |
|
|
RDP_UPDATE_PDU update; |
|
|
RDP_ORDER_STATE os; |
|
28 |
uint8 type; |
uint8 type; |
29 |
|
|
|
memset(&os, 0, sizeof(os)); |
|
|
|
|
30 |
if ((conn = mcs_connect(server)) == NULL) |
if ((conn = mcs_connect(server)) == NULL) |
31 |
return NULL; |
return NULL; |
32 |
|
|
35 |
rdp_send_cert(conn); |
rdp_send_cert(conn); |
36 |
mcs_recv(conn, False); |
mcs_recv(conn, False); |
37 |
|
|
38 |
if (rdp_recv_pdu(conn, &type) && (type != RDP_PDU_DEMAND_ACTIVE)) |
if (!rdp_recv_pdu(conn, &type) || (type != RDP_PDU_DEMAND_ACTIVE)) |
39 |
{ |
{ |
40 |
fprintf(stderr, "RDP error, expected Demand Active\n"); |
fprintf(stderr, "RDP error, expected Demand Active\n"); |
41 |
mcs_disconnect(conn); |
mcs_disconnect(conn); |
54 |
rdp_send_fonts(conn, 1); |
rdp_send_fonts(conn, 1); |
55 |
rdp_send_fonts(conn, 2); |
rdp_send_fonts(conn, 2); |
56 |
rdp_recv_pdu(conn, &type); // RDP_PDU_UNKNOWN 0x28 |
rdp_recv_pdu(conn, &type); // RDP_PDU_UNKNOWN 0x28 |
57 |
|
|
58 |
|
return conn; |
59 |
|
} |
60 |
|
|
61 |
|
void rdp_main_loop(HCONN conn) |
62 |
|
{ |
63 |
|
RDP_DATA_HEADER hdr; |
64 |
|
RDP_UPDATE_PDU update; |
65 |
|
RDP_ORDER_STATE os; |
66 |
|
uint8 type; |
67 |
|
|
68 |
|
memset(&os, 0, sizeof(os)); |
69 |
|
|
70 |
while (rdp_recv_pdu(conn, &type)) |
while (rdp_recv_pdu(conn, &type)) |
71 |
{ |
{ |
72 |
if (type != RDP_PDU_DATA) |
if (type != RDP_PDU_DATA) |
86 |
break; |
break; |
87 |
} |
} |
88 |
} |
} |
|
|
|
|
return conn; |
|
89 |
} |
} |
90 |
|
|
91 |
void prs_io_coord(STREAM s, uint16 *coord, BOOL delta) |
void prs_io_coord(STREAM s, uint16 *coord, BOOL delta) |
126 |
fprintf(stderr, "Opaque rectangle at %d, %d\n", os->opaque_rect.x, os->opaque_rect.y); |
fprintf(stderr, "Opaque rectangle at %d, %d\n", os->opaque_rect.x, os->opaque_rect.y); |
127 |
} |
} |
128 |
|
|
129 |
|
void process_bmpcache(HCONN conn) |
130 |
|
{ |
131 |
|
|
132 |
|
RDP_BITMAP_HEADER rbh; |
133 |
|
char *bmpdata; |
134 |
|
HBITMAP bmp; |
135 |
|
static int x = 0; |
136 |
|
|
137 |
|
rdp_io_bitmap_header(&conn->in, &rbh); |
138 |
|
fprintf(stderr, "Decompressing bitmap %d x %d, final size %d\n", rbh.width, rbh.height, rbh.final_size); |
139 |
|
|
140 |
|
bmpdata = malloc(rbh.width * rbh.height); |
141 |
|
bitmap_decompress(conn->in.data |
142 |
|
+ conn->in.offset, rbh.size, |
143 |
|
bmpdata, rbh.width); |
144 |
|
conn->in.offset += rbh.size; |
145 |
|
|
146 |
|
bmp = ui_create_bitmap(conn->wnd, rbh.width, rbh.height, bmpdata); |
147 |
|
ui_paint_bitmap(conn->wnd, bmp, x, 0); |
148 |
|
ui_destroy_bitmap(bmp); |
149 |
|
|
150 |
|
x += rbh.width; |
151 |
|
} |
152 |
|
|
153 |
void process_orders(HCONN conn, RDP_ORDER_STATE *os) |
void process_orders(HCONN conn, RDP_ORDER_STATE *os) |
154 |
{ |
{ |
155 |
uint16 num_orders; |
uint16 num_orders; |
181 |
switch (rso.type) |
switch (rso.type) |
182 |
{ |
{ |
183 |
case RDP_ORDER_BMPCACHE: |
case RDP_ORDER_BMPCACHE: |
184 |
{ |
process_bmpcache(conn); |
|
RDP_BITMAP_HEADER rbh; |
|
|
char output[8192]; |
|
|
|
|
|
rdp_io_bitmap_header(&conn->in, &rbh); |
|
|
fprintf(stderr, "Decompressing bitmap %d x %d, final size %d\n", rbh.width, rbh.height, rbh.final_size); |
|
|
bitmap_decompress(conn->in.data |
|
|
+ conn->in.offset, rbh.size, |
|
|
output, rbh.width); |
|
|
conn->in.offset += rbh.size; |
|
185 |
break; |
break; |
|
} |
|
186 |
default: |
default: |
187 |
fprintf(stderr, "Unknown secondary order %d\n", |
fprintf(stderr, "Unknown secondary order %d\n", |
188 |
rso.type); |
rso.type); |