void rdp_write_general_capability_set(STREAM* s, rdpSettings* settings) { uint8* header; uint16 extraFlags; header = rdp_capability_set_start(s); extraFlags = LONG_CREDENTIALS_SUPPORTED | NO_BITMAP_COMPRESSION_HDR; if (settings->auto_reconnection) extraFlags |= AUTORECONNECT_SUPPORTED; if (settings->fast_path_input) extraFlags |= FASTPATH_OUTPUT_SUPPORTED; stream_write_uint16(s, 0); /* osMajorType (2 bytes) */ stream_write_uint16(s, 0); /* osMinorType (2 bytes) */ stream_write_uint16(s, CAPS_PROTOCOL_VERSION); /* protocolVersion (2 bytes) */ stream_write_uint16(s, 0); /* pad2OctetsA (2 bytes) */ stream_write_uint16(s, 0); /* generalCompressionTypes (2 bytes) */ stream_write_uint16(s, 0); /* extraFlags (2 bytes) */ stream_write_uint16(s, 0); /* updateCapabilityFlag (2 bytes) */ stream_write_uint16(s, 0); /* remoteUnshareFlag (2 bytes) */ stream_write_uint16(s, 0); /* generalCompressionLevel (2 bytes) */ stream_write_uint8(s, settings->refresh_rect); /* refreshRectSupport (1 byte) */ stream_write_uint8(s, settings->suppress_output); /* suppressOutputSupport (1 byte) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_GENERAL); }
void tpkt_write_header(STREAM* s, int length) { stream_write_uint8(s, 3); /* version */ stream_write_uint8(s, 0); /* reserved */ stream_write_uint16_be(s, length); /* length */ }
void rdp_write_bitmap_capability_set(STREAM* s, rdpSettings* settings) { uint8* header; uint8 drawingFlags; uint16 preferredBitsPerPixel; header = rdp_capability_set_start(s); drawingFlags = 0; if (settings->rdp_version > 5) preferredBitsPerPixel = settings->color_depth; else preferredBitsPerPixel = 8; stream_write_uint16(s, preferredBitsPerPixel); /* preferredBitsPerPixel (2 bytes) */ stream_write_uint16(s, 1); /* receive1BitPerPixel (2 bytes) */ stream_write_uint16(s, 1); /* receive4BitsPerPixel (2 bytes) */ stream_write_uint16(s, 1); /* receive8BitsPerPixel (2 bytes) */ stream_write_uint16(s, settings->width); /* desktopWidth (2 bytes) */ stream_write_uint16(s, settings->height); /* desktopHeight (2 bytes) */ stream_write_uint16(s, 0); /* pad2Octets (2 bytes) */ stream_write_uint16(s, settings->desktop_resize); /* desktopResizeFlag (2 bytes) */ stream_write_uint16(s, 1); /* bitmapCompressionFlag (2 bytes) */ stream_write_uint8(s, 0); /* highColorFlags (1 byte) */ stream_write_uint8(s, drawingFlags); /* drawingFlags (1 byte) */ stream_write_uint16(s, 1); /* multipleRectangleSupport (2 bytes) */ stream_write_uint16(s, 0); /* pad2OctetsB (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_BITMAP); }
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_uint8(s, 1); /* CodecChannelT.codecId */ stream_write_uint8(s, 0); /* CodecChannelT.channelId */ stream_write_uint8(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 license_write_preamble(STREAM* s, uint8 bMsgType, uint8 flags, uint16 wMsgSize) { /* preamble (4 bytes) */ stream_write_uint8(s, bMsgType); /* bMsgType (1 byte) */ stream_write_uint8(s, flags); /* flags (1 byte) */ stream_write_uint16(s, wMsgSize); /* wMsgSize (2 bytes) */ }
tbool rpch_in_send_ping(rdpRpch* rpch) { STREAM* pdu = stream_new(20); uint8 rpc_vers = 0x05; uint8 rpc_vers_minor = 0x00; uint8 ptype = PTYPE_RTS; uint8 pfc_flags = PFC_FIRST_FRAG | PFC_LAST_FRAG; uint32 packet_drep = 0x00000010; uint16 frag_length = 56; uint16 auth_length = 0; uint32 call_id = 0x00000000; uint16 flags = 0x0001; uint16 num_commands = 0x0000; stream_write_uint8(pdu, rpc_vers); stream_write_uint8(pdu, rpc_vers_minor); stream_write_uint8(pdu, ptype); stream_write_uint8(pdu, pfc_flags); stream_write_uint32(pdu, packet_drep); stream_write_uint16(pdu, frag_length); stream_write_uint16(pdu, auth_length); stream_write_uint32(pdu, call_id); stream_write_uint16(pdu, flags); stream_write_uint16(pdu, num_commands); rpch_in_write(rpch, pdu->data, pdu->p - pdu->data); stream_free(pdu); return true; }
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_uint8(s, 1); /* CodecChannelT.codecId */ stream_write_uint8(s, 0); /* CodecChannelT.channelId */ stream_write_uint8(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 */ }
static boolean rdpsnd_server_send_formats(rdpsnd_server* rdpsnd, STREAM* s) { uint16 i; RDPSND_PDU_INIT(s, SNDC_FORMATS); stream_write_uint32(s, 0); /* dwFlags */ stream_write_uint32(s, 0); /* dwVolume */ stream_write_uint32(s, 0); /* dwPitch */ stream_write_uint16(s, 0); /* wDGramPort */ stream_write_uint16(s, rdpsnd->context.num_server_formats); /* wNumberOfFormats */ stream_write_uint8(s, rdpsnd->context.block_no); /* cLastBlockConfirmed */ stream_write_uint16(s, 0x06); /* wVersion */ stream_write_uint8(s, 0); /* bPad */ for (i = 0; i < rdpsnd->context.num_server_formats; i++) { stream_write_uint16(s, rdpsnd->context.server_formats[i].wFormatTag); /* wFormatTag (WAVE_FORMAT_PCM) */ stream_write_uint16(s, rdpsnd->context.server_formats[i].nChannels); /* nChannels */ stream_write_uint32(s, rdpsnd->context.server_formats[i].nSamplesPerSec); /* nSamplesPerSec */ stream_write_uint32(s, rdpsnd->context.server_formats[i].nSamplesPerSec * rdpsnd->context.server_formats[i].nChannels * rdpsnd->context.server_formats[i].wBitsPerSample / 8); /* nAvgBytesPerSec */ stream_write_uint16(s, rdpsnd->context.server_formats[i].nBlockAlign); /* nBlockAlign */ stream_write_uint16(s, rdpsnd->context.server_formats[i].wBitsPerSample); /* wBitsPerSample */ stream_write_uint16(s, rdpsnd->context.server_formats[i].cbSize); /* cbSize */ if (rdpsnd->context.server_formats[i].cbSize > 0) { stream_write(s, rdpsnd->context.server_formats[i].data, rdpsnd->context.server_formats[i].cbSize); } } RDPSND_PDU_FINISH(s); }
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_uint8(s, 1); /* numCodecs */ stream_write_uint8(s, 1); /* codecs.codecId */ stream_write_uint16(s, WF_VERSION_1_0); /* codecs.version */ }
static void rfx_compose_message_frame_end(RFX_CONTEXT* context, STREAM* s) { stream_check_size(s, 8); stream_write_uint16(s, WBT_FRAME_END); /* CodecChannelT.blockType */ stream_write_uint32(s, 8); /* CodecChannelT.blockLen */ stream_write_uint8(s, 1); /* CodecChannelT.codecId */ stream_write_uint8(s, 0); /* CodecChannelT.channelId */ }
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_uint8(s, 1); /* numChannels */ stream_write_uint8(s, 0); /* Channel.channelId */ stream_write_uint16(s, context->width); /* Channel.width */ stream_write_uint16(s, context->height); /* Channel.height */ }
static uint32 rdp_security_stream_out(rdpRdp* rdp, STREAM* s, int length) { uint32 ml; uint8* mk; uint8* data; uint32 sec_flags; uint32 pad = 0; sec_flags = rdp->sec_flags; if (sec_flags != 0) { rdp_write_security_header(s, sec_flags); if (sec_flags & SEC_ENCRYPT) { if (rdp->settings->encryption_method == ENCRYPTION_METHOD_FIPS) { data = s->p + 12; length = length - (data - s->data); stream_write_uint16(s, 0x10); /* length */ stream_write_uint8(s, 0x1); /* TSFIPS_VERSION 1*/ /* handle padding */ pad = 8 - (length % 8); if (pad == 8) pad = 0; if (pad) memset(data+length, 0, pad); stream_write_uint8(s, pad); security_hmac_signature(data, length, s->p, rdp); stream_seek(s, 8); security_fips_encrypt(data, length + pad, rdp); } else { data = s->p + 8; length = length - (data - s->data); mk = rdp->sign_key; ml = rdp->rc4_key_len; security_mac_signature(mk, ml, data, length, s->p); stream_seek(s, 8); security_encrypt(s->p, length, rdp); } } rdp->sec_flags = 0; } return pad; }
void rdp_write_share_data_header(STREAM* s, uint16 length, uint8 type, uint32 share_id) { /* Share Data Header */ stream_write_uint32(s, share_id); /* shareId (4 bytes) */ stream_write_uint8(s, 0); /* pad1 (1 byte) */ stream_write_uint8(s, STREAM_LOW); /* streamId (1 byte) */ stream_write_uint16(s, length); /* uncompressedLength (2 bytes) */ stream_write_uint8(s, type); /* pduType2, Data PDU Type (1 byte) */ stream_write_uint8(s, 0); /* compressedType (1 byte) */ stream_write_uint16(s, 0); /* compressedLength (2 bytes) */ }
void rdp_write_bitmap_cache_host_support_capability_set(STREAM* s, rdpSettings* settings) { uint8* header; header = rdp_capability_set_start(s); stream_write_uint8(s, BITMAP_CACHE_V2); /* cacheVersion (1 byte) */ stream_write_uint8(s, 0); /* pad1 (1 byte) */ stream_write_uint16(s, 0); /* pad2 (2 bytes) */ rdp_capability_set_finish(s, header, CAPSET_TYPE_BITMAP_CACHE_HOST_SUPPORT); }
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_uint8(s, 1); /* CodecChannelT.codecId */ stream_write_uint8(s, 0); /* CodecChannelT.channelId */ stream_write_uint32(s, context->frame_idx); /* frameIdx */ stream_write_uint16(s, 1); /* numRegions */ context->frame_idx++; }
static uint32 rdp_security_stream_out(rdpRdp* rdp, STREAM* s, int length) { uint8* data; uint32 sec_flags; uint32 pad = 0; sec_flags = rdp->sec_flags; if (sec_flags != 0) { rdp_write_security_header(s, sec_flags); if (sec_flags & SEC_ENCRYPT) { if (rdp->settings->encryption_method == ENCRYPTION_METHOD_FIPS) { data = s->p + 12; length = length - (data - s->data); stream_write_uint16(s, 0x10); /* length */ stream_write_uint8(s, 0x1); /* TSFIPS_VERSION 1*/ /* handle padding */ pad = (8 - (length % 8)) & 7; memset(data+length, 0, pad); stream_write_uint8(s, pad); security_hmac_signature(data, length, s->p, rdp); stream_seek(s, 8); security_fips_encrypt(data, length + pad, rdp); } else { data = s->p + 8; length = length - (data - s->data); if (sec_flags & SEC_SECURE_CHECKSUM) security_salted_mac_signature(rdp, data, length, true, s->p); else security_mac_signature(rdp, data, length, s->p); stream_seek(s, 8); security_encrypt(s->p, length, rdp); } } rdp->sec_flags = 0; } return pad; }
int ber_write_length(STREAM* s, int length) { if (length > 0x7F) { stream_write_uint8(s, 0x82); stream_write_uint16_be(s, length); return 3; } else { stream_write_uint8(s, length); return 1; } }
boolean disk_file_query_information(DISK_FILE* file, uint32 FsInformationClass, STREAM* output) { struct stat st; if (stat(file->fullpath, &st) != 0) { stream_write_uint32(output, 0); /* Length */ return false; } switch (FsInformationClass) { case FileBasicInformation: /* http://msdn.microsoft.com/en-us/library/cc232094.aspx */ stream_write_uint32(output, 36); /* Length */ stream_check_size(output, 36); stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */ stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_atime)); /* LastAccessTime */ stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* LastWriteTime */ stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* ChangeTime */ stream_write_uint32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */ /* Reserved(4), MUST NOT be added! */ break; case FileStandardInformation: /* http://msdn.microsoft.com/en-us/library/cc232088.aspx */ stream_write_uint32(output, 22); /* Length */ stream_check_size(output, 22); stream_write_uint64(output, st.st_size); /* AllocationSize */ stream_write_uint64(output, st.st_size); /* EndOfFile */ stream_write_uint32(output, st.st_nlink); /* NumberOfLinks */ stream_write_uint8(output, file->delete_pending ? 1 : 0); /* DeletePending */ stream_write_uint8(output, file->is_dir ? 1 : 0); /* Directory */ /* Reserved(2), MUST NOT be added! */ break; case FileAttributeTagInformation: /* http://msdn.microsoft.com/en-us/library/cc232093.aspx */ stream_write_uint32(output, 8); /* Length */ stream_check_size(output, 8); stream_write_uint32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */ stream_write_uint32(output, 0); /* ReparseTag */ break; default: stream_write_uint32(output, 0); /* Length */ DEBUG_WARN("invalid FsInformationClass %d", FsInformationClass); return false; } return true; }
static void update_send_pointer_system(rdpUpdate* update, POINTER_SYSTEM_UPDATE* pointer_system) { rdpRdp* rdp = (rdpRdp*)update->rdp; STREAM* s; s = fastpath_update_pdu_init(rdp->fastpath); /* updateHeader (1 byte) */ if (pointer_system->type == SYSPTR_NULL) stream_write_uint8(s, FASTPATH_UPDATETYPE_PTR_NULL); else stream_write_uint8(s, FASTPATH_UPDATETYPE_PTR_DEFAULT); stream_write_uint16(s, 0); /* size (2 bytes) */ fastpath_send_update_pdu(rdp->fastpath, s); }
void ber_write_application_tag(STREAM* s, uint8 tag, int length) { if (tag > 30) { stream_write_uint8(s, (BER_CLASS_APPL | BER_CONSTRUCT) | BER_TAG_MASK); stream_write_uint8(s, tag); ber_write_length(s, length); } else { stream_write_uint8(s, (BER_CLASS_APPL | BER_CONSTRUCT) | (BER_TAG_MASK & tag)); ber_write_length(s, length); } }
boolean nego_send_negotiation_request(rdpNego* nego) { STREAM* s; int length; uint8 *bm, *em; s = transport_send_stream_init(nego->transport, 256); length = TPDU_CONNECTION_REQUEST_LENGTH; stream_get_mark(s, bm); stream_seek(s, length); if (nego->routing_token != NULL) { stream_write(s, nego->routing_token->data, nego->routing_token->length); length += nego->routing_token->length; } else if (nego->cookie != NULL) { int cookie_length = strlen(nego->cookie); stream_write(s, "Cookie: mstshash=", 17); stream_write(s, (uint8*) nego->cookie, cookie_length); stream_write_uint8(s, 0x0D); /* CR */ stream_write_uint8(s, 0x0A); /* LF */ length += cookie_length + 19; } DEBUG_NEGO("requested_protocols: %d", nego->requested_protocols); if (nego->requested_protocols > PROTOCOL_RDP) { /* RDP_NEG_DATA must be present for TLS and NLA */ stream_write_uint8(s, TYPE_RDP_NEG_REQ); stream_write_uint8(s, 0); /* flags, must be set to zero */ stream_write_uint16(s, 8); /* RDP_NEG_DATA length (8) */ stream_write_uint32(s, nego->requested_protocols); /* requestedProtocols */ length += 8; } stream_get_mark(s, em); stream_set_mark(s, bm); tpkt_write_header(s, length); tpdu_write_connection_request(s, length - 5); stream_set_mark(s, em); if (transport_write(nego->transport, s) < 0) return false; return true; }
void rdp_write_share_data_header(STREAM* s, uint16 length, uint8 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_uint8(s, 0); /* pad1 (1 byte) */ stream_write_uint8(s, STREAM_LOW); /* streamId (1 byte) */ stream_write_uint16(s, length); /* uncompressedLength (2 bytes) */ stream_write_uint8(s, type); /* pduType2, Data PDU Type (1 byte) */ stream_write_uint8(s, 0); /* compressedType (1 byte) */ stream_write_uint16(s, 0); /* compressedLength (2 bytes) */ }
void rdp_write_header(rdpRdp* rdp, STREAM* s, uint16 length, uint16 channel_id) { int body_length; enum DomainMCSPDU MCSPDU; MCSPDU = (rdp->settings->server_mode) ? DomainMCSPDU_SendDataIndication : DomainMCSPDU_SendDataRequest; if ((rdp->sec_flags & SEC_ENCRYPT) && (rdp->settings->encryption_method == ENCRYPTION_METHOD_FIPS)) { int pad; body_length = length - RDP_PACKET_HEADER_MAX_LENGTH - 16; pad = 8 - (body_length % 8); if (pad != 8) length += pad; } mcs_write_domain_mcspdu_header(s, MCSPDU, length, 0); per_write_integer16(s, rdp->mcs->user_id, MCS_BASE_CHANNEL_ID); /* initiator */ per_write_integer16(s, channel_id, 0); /* channelId */ stream_write_uint8(s, 0x70); /* dataPriority + segmentation */ /* * We always encode length in two bytes, eventhough we could use * only one byte if length <= 0x7F. It is just easier that way, * because we can leave room for fixed-length header, store all * the data first and then store the header. */ length = (length - RDP_PACKET_HEADER_MAX_LENGTH) | 0x8000; stream_write_uint16_be(s, length); /* userData (OCTET_STRING) */ }
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_uint8(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 void audin_server_send_formats(audin_server* audin, STREAM* s) { int i; uint32 nAvgBytesPerSec; stream_set_pos(s, 0); stream_write_uint8(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); }
static void printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp) { rdpPrintJob* printjob = NULL; uint32 Length; uint64 Offset; stream_read_uint32(irp->input, Length); stream_read_uint64(irp->input, Offset); (void) Offset; stream_seek(irp->input, 20); /* Padding */ if (printer_dev->printer != NULL) printjob = printer_dev->printer->FindPrintJob(printer_dev->printer, irp->FileId); if (printjob == NULL) { irp->IoStatus = STATUS_UNSUCCESSFUL; Length = 0; log_warning("printjob id %d not found.", irp->FileId); } else { printjob->Write(printjob, stream_get_tail(irp->input), Length); log_debug("printjob id %d written %d bytes.", irp->FileId, Length); } stream_write_uint32(irp->output, Length); stream_write_uint8(irp->output, 0); /* Padding */ irp->Complete(irp); }
void rdp_write_header(rdpRdp* rdp, STREAM* s, uint16 length, uint16 channel_id) { int body_length; enum DomainMCSPDU MCSPDU; MCSPDU = (rdp->settings->server_mode) ? DomainMCSPDU_SendDataIndication : DomainMCSPDU_SendDataRequest; if ((rdp->sec_flags & SEC_ENCRYPT) && (rdp->settings->encryption_method == ENCRYPTION_METHOD_FIPS)) { int pad; body_length = length - RDP_PACKET_HEADER_LENGTH - 16; pad = 8 - (body_length % 8); if (pad != 8) length += pad; } mcs_write_domain_mcspdu_header(s, MCSPDU, length, 0); per_write_integer16(s, rdp->mcs->user_id, MCS_BASE_CHANNEL_ID); /* initiator */ per_write_integer16(s, channel_id, 0); /* channelId */ stream_write_uint8(s, 0x70); /* dataPriority + segmentation */ length = (length - RDP_PACKET_HEADER_LENGTH) | 0x8000; stream_write_uint16_be(s, length); /* userData (OCTET_STRING) */ }
void test_stream(void) { STREAM * stream; int pos; uint32 n; uint64 n64; stream = stream_new(1); pos = stream_get_pos(stream); stream_write_uint8(stream, 0xFE); stream_check_size(stream, 14); stream_write_uint16(stream, 0x0102); stream_write_uint32(stream, 0x03040506); stream_write_uint64(stream, 0x0708091011121314LL); /* freerdp_hexdump(stream->buffer, 15); */ stream_set_pos(stream, pos); stream_seek(stream, 3); stream_read_uint32(stream, n); stream_read_uint64(stream, n64); CU_ASSERT(n == 0x03040506); CU_ASSERT(n64 == 0x0708091011121314LL); stream_free(stream); }
int ber_write_integer(STREAM* s, uint32 value) { ber_write_universal_tag(s, BER_TAG_INTEGER, false); if (value <= 0xFF) { ber_write_length(s, 1); stream_write_uint8(s, value); return 2; } else if (value <= 0xFFFF) { ber_write_length(s, 2); stream_write_uint16_be(s, value); return 3; } else if (value <= 0xFFFFFFFF) { ber_write_length(s, 4); stream_write_uint32_be(s, value); return 5; } return 0; }
void rdp_write_header(rdpRdp* rdp, STREAM* s, int length) { mcs_write_domain_mcspdu_header(s, DomainMCSPDU_SendDataRequest, length); per_write_integer16(s, rdp->mcs->user_id, MCS_BASE_CHANNEL_ID); /* initiator */ per_write_integer16(s, MCS_GLOBAL_CHANNEL_ID, 0); /* channelId */ stream_write_uint8(s, 0x70); /* dataPriority + segmentation */ per_write_length(s, length - RDP_PACKET_HEADER_LENGTH); /* userData (OCTET_STRING) */ }