static void rfx_compose_message_context(RFX_CONTEXT* context, STREAM* s) { UINT16 properties; stream_write_UINT16(s, WBT_CONTEXT); /* CodecChannelT.blockType */ stream_write_UINT32(s, 13); /* CodecChannelT.blockLen */ stream_write_BYTE(s, 1); /* CodecChannelT.codecId */ stream_write_BYTE(s, 0); /* CodecChannelT.channelId */ stream_write_BYTE(s, 0); /* ctxId */ stream_write_UINT16(s, CT_TILE_64x64); /* tileSize */ /* properties */ properties = context->flags; /* flags */ properties |= (COL_CONV_ICT << 3); /* cct */ properties |= (CLW_XFORM_DWT_53_A << 5); /* xft */ properties |= ((context->mode == RLGR1 ? CLW_ENTROPY_RLGR1 : CLW_ENTROPY_RLGR3) << 9); /* et */ properties |= (SCALAR_QUANTIZATION << 13); /* qt */ stream_write_UINT16(s, properties); /* properties in tilesets: note that this has different format from the one in TS_RFX_CONTEXT */ properties = 1; /* lt */ properties |= (context->flags << 1); /* flags */ properties |= (COL_CONV_ICT << 4); /* cct */ properties |= (CLW_XFORM_DWT_53_A << 6); /* xft */ properties |= ((context->mode == RLGR1 ? CLW_ENTROPY_RLGR1 : CLW_ENTROPY_RLGR3) << 10); /* et */ properties |= (SCALAR_QUANTIZATION << 14); /* qt */ context->properties = properties; }
void rdp_write_client_font_list_pdu(STREAM* s, UINT16 flags) { stream_write_UINT16(s, 0); /* numberFonts (2 bytes) */ stream_write_UINT16(s, 0); /* totalNumFonts (2 bytes) */ stream_write_UINT16(s, flags); /* listFlags (2 bytes) */ stream_write_UINT16(s, 50); /* entrySize (2 bytes) */ }
static void rfx_compose_message_sync(RFX_CONTEXT* context, STREAM* s) { stream_write_UINT16(s, WBT_SYNC); /* BlockT.blockType */ stream_write_UINT32(s, 12); /* BlockT.blockLen */ stream_write_UINT32(s, WF_MAGIC); /* magic */ stream_write_UINT16(s, WF_VERSION_1_0); /* version */ }
static void rdpdr_send_client_name_request(rdpdrPlugin* rdpdr) { STREAM* data_out; WCHAR* computerNameW = NULL; size_t computerNameLenW; if (!rdpdr->computerName[0]) gethostname(rdpdr->computerName, sizeof(rdpdr->computerName) - 1); computerNameLenW = ConvertToUnicode(CP_UTF8, 0, rdpdr->computerName, -1, &computerNameW, 0) * 2; data_out = stream_new(16 + computerNameLenW + 2); stream_write_UINT16(data_out, RDPDR_CTYP_CORE); stream_write_UINT16(data_out, PAKID_CORE_CLIENT_NAME); stream_write_UINT32(data_out, 1); /* unicodeFlag, 0 for ASCII and 1 for Unicode */ stream_write_UINT32(data_out, 0); /* codePage, must be set to zero */ stream_write_UINT32(data_out, computerNameLenW + 2); /* computerNameLen, including null terminator */ stream_write(data_out, computerNameW, computerNameLenW); stream_write_UINT16(data_out, 0); /* null terminator */ free(computerNameW); svc_plugin_send((rdpSvcPlugin*) rdpdr, data_out); }
static void audin_server_send_open(audin_server* audin, STREAM* s) { if (audin->context.selected_client_format < 0) return; audin->opened = TRUE; stream_set_pos(s, 0); stream_write_BYTE(s, MSG_SNDIN_OPEN); stream_write_UINT32(s, audin->context.frames_per_packet); /* FramesPerPacket (4 bytes) */ stream_write_UINT32(s, audin->context.selected_client_format); /* initialFormat (4 bytes) */ /* * [MS-RDPEAI] 3.2.5.1.6 * The second format specify the format that SHOULD be used to capture data from * the actual audio input device. */ stream_write_UINT16(s, 1); /* wFormatTag = PCM */ stream_write_UINT16(s, 2); /* nChannels */ stream_write_UINT32(s, 44100); /* nSamplesPerSec */ stream_write_UINT32(s, 44100 * 2 * 2); /* nAvgBytesPerSec */ stream_write_UINT16(s, 4); /* nBlockAlign */ stream_write_UINT16(s, 16); /* wBitsPerSample */ stream_write_UINT16(s, 0); /* cbSize */ WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), stream_get_length(s), NULL); }
static int drdynvc_process_capability_request(drdynvcPlugin* drdynvc, int Sp, int cbChId, STREAM* s) { STREAM* data_out; int error; DEBUG_DVC("Sp=%d cbChId=%d", Sp, cbChId); stream_seek(s, 1); /* pad */ stream_read_UINT16(s, drdynvc->version); if (drdynvc->version == 2) { stream_read_UINT16(s, drdynvc->PriorityCharge0); stream_read_UINT16(s, drdynvc->PriorityCharge1); stream_read_UINT16(s, drdynvc->PriorityCharge2); stream_read_UINT16(s, drdynvc->PriorityCharge3); } data_out = stream_new(4); stream_write_UINT16(data_out, 0x0050); /* Cmd+Sp+cbChId+Pad. Note: MSTSC sends 0x005c */ stream_write_UINT16(data_out, drdynvc->version); error = svc_plugin_send((rdpSvcPlugin*) drdynvc, data_out); if (error != CHANNEL_RC_OK) { DEBUG_WARN("VirtualChannelWrite failed %d", error); return 1; } drdynvc->channel_error = error; return 0; }
static void audin_server_send_formats(audin_server* audin, STREAM* s) { int i; UINT32 nAvgBytesPerSec; stream_set_pos(s, 0); stream_write_BYTE(s, MSG_SNDIN_FORMATS); stream_write_UINT32(s, audin->context.num_server_formats); /* NumFormats (4 bytes) */ stream_write_UINT32(s, 0); /* cbSizeFormatsPacket (4 bytes), client-to-server only */ for (i = 0; i < audin->context.num_server_formats; i++) { nAvgBytesPerSec = audin->context.server_formats[i].nSamplesPerSec * audin->context.server_formats[i].nChannels * audin->context.server_formats[i].wBitsPerSample / 8; stream_check_size(s, 18); stream_write_UINT16(s, audin->context.server_formats[i].wFormatTag); stream_write_UINT16(s, audin->context.server_formats[i].nChannels); stream_write_UINT32(s, audin->context.server_formats[i].nSamplesPerSec); stream_write_UINT32(s, nAvgBytesPerSec); stream_write_UINT16(s, audin->context.server_formats[i].nBlockAlign); stream_write_UINT16(s, audin->context.server_formats[i].wBitsPerSample); stream_write_UINT16(s, audin->context.server_formats[i].cbSize); if (audin->context.server_formats[i].cbSize) { stream_check_size(s, audin->context.server_formats[i].cbSize); stream_write(s, audin->context.server_formats[i].data, audin->context.server_formats[i].cbSize); } } WTSVirtualChannelWrite(audin->audin_channel, stream_get_head(s), stream_get_length(s), NULL); }
void rail_write_rectangle_16(wStream* s, RECTANGLE_16* rectangle_16) { stream_write_UINT16(s, rectangle_16->left); /* left (2 bytes) */ stream_write_UINT16(s, rectangle_16->top); /* top (2 bytes) */ stream_write_UINT16(s, rectangle_16->right); /* right (2 bytes) */ stream_write_UINT16(s, rectangle_16->bottom); /* bottom (2 bytes) */ }
void license_write_binary_blob(STREAM* s, LICENSE_BLOB* blob) { stream_write_UINT16(s, blob->type); /* wBlobType (2 bytes) */ stream_write_UINT16(s, blob->length); /* wBlobLen (2 bytes) */ if (blob->length > 0) stream_write(s, blob->data, blob->length); /* blobData */ }
void rail_write_client_window_move_order(STREAM* s, RAIL_WINDOW_MOVE_ORDER* window_move) { stream_write_UINT32(s, window_move->windowId); /* windowId (4 bytes) */ stream_write_UINT16(s, window_move->left); /* left (2 bytes) */ stream_write_UINT16(s, window_move->top); /* top (2 bytes) */ stream_write_UINT16(s, window_move->right); /* right (2 bytes) */ stream_write_UINT16(s, window_move->bottom); /* bottom (2 bytes) */ }
static void rfx_compose_message_codec_versions(RFX_CONTEXT* context, STREAM* s) { stream_write_UINT16(s, WBT_CODEC_VERSIONS); /* BlockT.blockType */ stream_write_UINT32(s, 10); /* BlockT.blockLen */ stream_write_BYTE(s, 1); /* numCodecs */ stream_write_BYTE(s, 1); /* codecs.codecId */ stream_write_UINT16(s, WF_VERSION_1_0); /* codecs.version */ }
static void rfx_compose_message_channels(RFX_CONTEXT* context, STREAM* s) { stream_write_UINT16(s, WBT_CHANNELS); /* BlockT.blockType */ stream_write_UINT32(s, 12); /* BlockT.blockLen */ stream_write_BYTE(s, 1); /* numChannels */ stream_write_BYTE(s, 0); /* Channel.channelId */ stream_write_UINT16(s, context->width); /* Channel.width */ stream_write_UINT16(s, context->height); /* Channel.height */ }
void rdp_write_share_control_header(STREAM* s, UINT16 length, UINT16 type, UINT16 channel_id) { length -= RDP_PACKET_HEADER_MAX_LENGTH; /* Share Control Header */ stream_write_UINT16(s, length); /* totalLength */ stream_write_UINT16(s, type | 0x10); /* pduType */ stream_write_UINT16(s, channel_id); /* pduSource */ }
void update_write_surfcmd_frame_marker(STREAM* s, UINT16 frameAction, UINT32 frameId) { stream_check_size(s, SURFCMD_FRAME_MARKER_LENGTH); stream_write_UINT16(s, CMDTYPE_FRAME_MARKER); stream_write_UINT16(s, frameAction); stream_write_UINT32(s, frameId); }
void rail_write_client_exec_order(STREAM* s, RAIL_EXEC_ORDER* exec) { stream_write_UINT16(s, exec->flags); /* flags (2 bytes) */ stream_write_UINT16(s, exec->exeOrFile.length); /* exeOrFileLength (2 bytes) */ stream_write_UINT16(s, exec->workingDir.length); /* workingDirLength (2 bytes) */ stream_write_UINT16(s, exec->arguments.length); /* argumentsLength (2 bytes) */ rail_write_unicode_string_value(s, &exec->exeOrFile); /* exeOrFile */ rail_write_unicode_string_value(s, &exec->workingDir); /* workingDir */ rail_write_unicode_string_value(s, &exec->arguments); /* arguments */ }
static BOOL rdpsnd_server_set_volume(rdpsnd_server_context* context, int left, int right) { rdpsnd_server* rdpsnd = (rdpsnd_server*) context; STREAM* s = rdpsnd->rdpsnd_pdu; RDPSND_PDU_INIT(s, SNDC_SETVOLUME); stream_write_UINT16(s, left); stream_write_UINT16(s, right); RDPSND_PDU_FINISH(s); }
wStream* cliprdr_packet_new(UINT16 msgType, UINT16 msgFlags, UINT32 dataLen) { wStream* s; s = stream_new(dataLen + 8); stream_write_UINT16(s, msgType); stream_write_UINT16(s, msgFlags); /* Write actual length after the entire packet has been constructed. */ stream_seek(s, 4); return s; }
BOOL rdp_send_server_font_map_pdu(rdpRdp* rdp) { STREAM* s; s = rdp_data_pdu_init(rdp); stream_write_UINT16(s, 0); /* numberEntries (2 bytes) */ stream_write_UINT16(s, 0); /* totalNumEntries (2 bytes) */ stream_write_UINT16(s, FONTLIST_FIRST | FONTLIST_LAST); /* mapFlags (2 bytes) */ stream_write_UINT16(s, 4); /* entrySize (2 bytes) */ return rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_FONT_MAP, rdp->mcs->user_id); }
void license_write_padded_binary_blob(STREAM* s, LICENSE_BLOB* blob) { UINT16 pad_len; pad_len = 72 % blob->length; stream_write_UINT16(s, blob->type); /* wBlobType (2 bytes) */ stream_write_UINT16(s, blob->length + pad_len); /* wBlobLen (2 bytes) */ if (blob->length > 0) stream_write(s, blob->data, blob->length); /* blobData */ stream_write_zero(s, pad_len); }
static void rfx_compose_message_frame_begin(RFX_CONTEXT* context, STREAM* s) { stream_check_size(s, 14); stream_write_UINT16(s, WBT_FRAME_BEGIN); /* CodecChannelT.blockType */ stream_write_UINT32(s, 14); /* CodecChannelT.blockLen */ stream_write_BYTE(s, 1); /* CodecChannelT.codecId */ stream_write_BYTE(s, 0); /* CodecChannelT.channelId */ stream_write_UINT32(s, context->frame_idx); /* frameIdx */ stream_write_UINT16(s, 1); /* numRegions */ context->frame_idx++; }
static void update_write_suppress_output(STREAM* s, BYTE allow, RECTANGLE_16* area) { stream_write_BYTE(s, allow); /* allowDisplayUpdates (1 byte) */ stream_seek(s, 3); /* pad3Octets (3 bytes) */ if (allow > 0) { stream_write_UINT16(s, area->left); /* left (2 bytes) */ stream_write_UINT16(s, area->top); /* top (2 bytes) */ stream_write_UINT16(s, area->right); /* right (2 bytes) */ stream_write_UINT16(s, area->bottom); /* bottom (2 bytes) */ } }
static void rfx_compose_message_region(RFX_CONTEXT* context, STREAM* s, const RFX_RECT* rects, int num_rects) { int size; int i; size = 15 + num_rects * 8; stream_check_size(s, size); stream_write_UINT16(s, WBT_REGION); /* CodecChannelT.blockType */ stream_write_UINT32(s, size); /* set CodecChannelT.blockLen later */ stream_write_BYTE(s, 1); /* CodecChannelT.codecId */ stream_write_BYTE(s, 0); /* CodecChannelT.channelId */ stream_write_BYTE(s, 1); /* regionFlags */ stream_write_UINT16(s, num_rects); /* numRects */ for (i = 0; i < num_rects; i++) { stream_write_UINT16(s, rects[i].x); stream_write_UINT16(s, rects[i].y); stream_write_UINT16(s, rects[i].width); stream_write_UINT16(s, rects[i].height); } stream_write_UINT16(s, CBT_REGION); /* regionType */ stream_write_UINT16(s, 1); /* numTilesets */ }
BOOL rdp_send_server_control_granted_pdu(rdpRdp* rdp) { STREAM* s; s = rdp_data_pdu_init(rdp); stream_write_UINT16(s, CTRLACTION_GRANTED_CONTROL); /* action (2 bytes) */ stream_write_UINT16(s, rdp->mcs->user_id); /* grantId (2 bytes) */ stream_write_UINT32(s, 0x03EA); /* controlId (4 bytes) */ rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_CONTROL, rdp->mcs->user_id); return TRUE; }
void rdp_write_share_data_header(STREAM* s, UINT16 length, BYTE type, UINT32 share_id) { length -= RDP_PACKET_HEADER_MAX_LENGTH; length -= RDP_SHARE_CONTROL_HEADER_LENGTH; length -= RDP_SHARE_DATA_HEADER_LENGTH; /* Share Data Header */ stream_write_UINT32(s, share_id); /* shareId (4 bytes) */ stream_write_BYTE(s, 0); /* pad1 (1 byte) */ stream_write_BYTE(s, STREAM_LOW); /* streamId (1 byte) */ stream_write_UINT16(s, length); /* uncompressedLength (2 bytes) */ stream_write_BYTE(s, type); /* pduType2, Data PDU Type (1 byte) */ stream_write_BYTE(s, 0); /* compressedType (1 byte) */ stream_write_UINT16(s, 0); /* compressedLength (2 bytes) */ }
static void update_write_refresh_rect(STREAM* s, BYTE count, RECTANGLE_16* areas) { int i; stream_write_BYTE(s, count); /* numberOfAreas (1 byte) */ stream_seek(s, 3); /* pad3Octets (3 bytes) */ for (i = 0; i < count; i++) { stream_write_UINT16(s, areas[i].left); /* left (2 bytes) */ stream_write_UINT16(s, areas[i].top); /* top (2 bytes) */ stream_write_UINT16(s, areas[i].right); /* right (2 bytes) */ stream_write_UINT16(s, areas[i].bottom); /* bottom (2 bytes) */ } }
static void rdpdr_send_client_announce_reply(rdpdrPlugin* rdpdr) { STREAM* data_out; data_out = stream_new(12); stream_write_UINT16(data_out, RDPDR_CTYP_CORE); stream_write_UINT16(data_out, PAKID_CORE_CLIENTID_CONFIRM); stream_write_UINT16(data_out, rdpdr->versionMajor); stream_write_UINT16(data_out, rdpdr->versionMinor); stream_write_UINT32(data_out, (UINT32) rdpdr->clientID); svc_plugin_send((rdpSvcPlugin*) rdpdr, data_out); }
void rts_pdu_header_write(STREAM* s, RTS_PDU_HEADER* header) { stream_write_BYTE(s, header->rpc_vers); /* rpc_vers (1 byte) */ stream_write_BYTE(s, header->rpc_vers_minor); /* rpc_vers_minor (1 byte) */ stream_write_BYTE(s, header->ptype); /* PTYPE (1 byte) */ stream_write_BYTE(s, header->pfc_flags); /* pfc_flags (1 byte) */ stream_write_BYTE(s, header->packed_drep[0]); /* packet_drep[0] (1 byte) */ stream_write_BYTE(s, header->packed_drep[1]); /* packet_drep[1] (1 byte) */ stream_write_BYTE(s, header->packed_drep[2]); /* packet_drep[2] (1 byte) */ stream_write_BYTE(s, header->packed_drep[3]); /* packet_drep[3] (1 byte) */ stream_write_UINT16(s, header->frag_length); /* frag_length (2 bytes) */ stream_write_UINT16(s, header->auth_length); /* auth_length (2 bytes) */ stream_write_UINT32(s, header->call_id); /* call_id (4 bytes) */ stream_write_UINT16(s, header->flags); /* flags (2 bytes) */ stream_write_UINT16(s, header->numberOfCommands); /* numberOfCommands (2 bytes) */ }
void tpdu_write_header(STREAM* s, UINT16 length, BYTE code) { stream_write_BYTE(s, length); /* LI */ stream_write_BYTE(s, code); /* code */ if (code == X224_TPDU_DATA) { stream_write_BYTE(s, 0x80); /* EOT */ } else { stream_write_UINT16(s, 0); /* DST-REF */ stream_write_UINT16(s, 0); /* SRC-REF */ stream_write_BYTE(s, 0); /* Class 0 */ } }
void license_write_preamble(STREAM* s, BYTE bMsgType, BYTE flags, UINT16 wMsgSize) { /* preamble (4 bytes) */ stream_write_BYTE(s, bMsgType); /* bMsgType (1 byte) */ stream_write_BYTE(s, flags); /* flags (1 byte) */ stream_write_UINT16(s, wMsgSize); /* wMsgSize (2 bytes) */ }
void gcc_write_server_network_data(STREAM* s, rdpSettings* settings) { int i; gcc_write_user_data_header(s, SC_NET, 8 + settings->ChannelCount * 2 + (settings->ChannelCount % 2 == 1 ? 2 : 0)); stream_write_UINT16(s, MCS_GLOBAL_CHANNEL_ID); /* MCSChannelId */ stream_write_UINT16(s, settings->ChannelCount); /* channelCount */ for (i = 0; i < settings->ChannelCount; i++) { stream_write_UINT16(s, settings->ChannelDefArray[i].ChannelId); } if (settings->ChannelCount % 2 == 1) stream_write_UINT16(s, 0); }