X-Git-Url: https://git.sesse.net/?p=rdpsrv;a=blobdiff_plain;f=rdp.c;h=56a0f7c90e09ac84cb2993563c869f725a073f62;hp=1663dfdc7bbcf85f52c01c01a58c5fde6a29a5c9;hb=f6cb05500f5c71cbb069daeb26edd5879fd17a99;hpb=f7c77f1d801d69794ea81a97060f260a0af51e51 diff --git a/rdp.c b/rdp.c index 1663dfd..56a0f7c 100644 --- a/rdp.c +++ b/rdp.c @@ -71,8 +71,8 @@ rdp_recv(uint8 * type) *type = pdu_type & 0xf; #if WITH_DEBUG - DEBUG(("RDP packet #%d, (type %x)\n", ++g_packetno, *type)); - hexdump(g_next_packet, length); + DEBUG(("RDP packet #%d, (type %x, length %u)\n", ++g_packetno, *type, length)); + //hexdump(g_next_packet, length); #endif /* */ g_next_packet += length; @@ -80,7 +80,7 @@ rdp_recv(uint8 * type) } /* Initialise an RDP data packet */ -static STREAM +STREAM rdp_init_data(int maxlen) { STREAM s; @@ -92,7 +92,7 @@ rdp_init_data(int maxlen) } /* Send an RDP data packet */ -static void +void rdp_send_data(STREAM s, uint8 data_pdu_type) { uint16 length; @@ -132,6 +132,81 @@ rdp_out_unistr(STREAM s, char *string, int len) s->p += len; } +/* Input a string in Unicode (uuuuuuugly, use iconv later) */ +void +rdp_in_unistr(STREAM s, char *string, int len) +{ + int i = 0, j = 0; + len += 2; + + while (i < len) + { + string[j++] = s->p[i]; + i += 2; + } + + s->p += len; +} + +void rdp_send_bitmap_update(unsigned x, unsigned y, unsigned width, unsigned height, unsigned char *data) +{ + STREAM s; + + s = rdp_init_data(11*2 + width*height*3); + out_uint16_le(s, RDP_UPDATE_BITMAP); + out_uint16_le(s, 1); // one update + out_uint16_le(s, x); // left, top, right, bottom + out_uint16_le(s, y); + out_uint16_le(s, x+width); + out_uint16_le(s, y+height); + out_uint16_le(s, width); // width, height + out_uint16_le(s, height); + out_uint16_le(s, 24); // bpp + out_uint16_le(s, 0); // no compression + out_uint16_le(s, width*height*3); // bufsize + + out_uint8p(s, data, width*height*3); + + s_mark_end(s); + rdp_send_data(s, RDP_DATA_PDU_UPDATE); +} + + +void +rdp_get_logon_info(STREAM s) +{ + uint32 flags; + int len_domain, len_user, len_password, len_program, len_directory; + char domain[256], user[256], password[256], program[256], directory[256]; // FIXME + + in_uint32_le(s, flags); // unknown + in_uint32_le(s, flags); + + if (flags & RDP_LOGON_BLOB) + error("got RDP5-style logon packet, can't handle this yet"); + + printf("logon flags: %x\n", flags); + + in_uint16_le(s, len_domain); + in_uint16_le(s, len_user); + in_uint16_le(s, len_password); + in_uint16_le(s, len_program); + in_uint16_le(s, len_directory); + rdp_in_unistr(s, domain, len_domain); + rdp_in_unistr(s, user, len_user); + rdp_in_unistr(s, password, len_password); + rdp_in_unistr(s, program, len_program); + rdp_in_unistr(s, directory, len_directory); + + printf("domain='%s'\n", domain); + printf("user='%s'\n", user); + printf("password='%s'\n", password); + printf("program='%s'\n", program); + printf("directory='%s'\n", directory); + + if (!s_check_end(s)) + error("Unknown data at end of logon packet!"); +} /* Send a control PDU */ static void @@ -164,25 +239,15 @@ rdp_send_synchronise(void) rdp_send_data(s, RDP_DATA_PDU_SYNCHRONISE); } -/* Send a single input event */ +/* Receive a single input event */ void -rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags, uint16 param1, uint16 param2) +rdp_recv_input(STREAM s, uint32 *time, uint16 *message_type, uint16 *device_flags, uint16 *param1, uint16 *param2) { - STREAM s; - - s = rdp_init_data(16); - - out_uint16_le(s, 1); /* number of events */ - out_uint16(s, 0); /* pad */ - - out_uint32_le(s, time); - out_uint16_le(s, message_type); - out_uint16_le(s, device_flags); - out_uint16_le(s, param1); - out_uint16_le(s, param2); - - s_mark_end(s); - rdp_send_data(s, RDP_DATA_PDU_INPUT); + in_uint32_le(s, *time); + in_uint16_le(s, *message_type); + in_uint16_le(s, *device_flags); + in_uint16_le(s, *param1); + in_uint16_le(s, *param2); } /* Disconnect from the RDP layer */