void test_nsc_encode(void) { int i; uint8* rgb_data; STREAM* enc_stream; NSC_CONTEXT* context; rgb_data = (uint8 *) malloc(64 * 64 * 3); for (i = 0; i < 64; i++) memcpy(rgb_data + i * 64 * 3, rgb_scanline_data, 64 * 3); context = nsc_context_new(); nsc_context_set_cpu_opt(context, CPU_SSE2); nsc_context_set_pixel_format(context, RDP_PIXEL_FORMAT_R8G8B8); enc_stream = stream_new(65536); stream_clear(enc_stream); for (i = 0; i < 30000; i++) { stream_set_pos(enc_stream, 0); nsc_compose_message(context, enc_stream, rgb_data, 64, 64, 64 * 3); } /*freerdp_hexdump(stream_get_head(enc_stream), stream_get_length(enc_stream));*/ nsc_process_message(context, 32, 64, 64, stream_get_head(enc_stream), stream_get_length(enc_stream)); /*freerdp_hexdump(context->bmpdata, 64 * 64 * 4);*/ stream_free(enc_stream); nsc_context_free(context); }
void test_nsc_encode(void) { int i; BYTE* rgb_data; wStream* enc_stream; NSC_CONTEXT* context; rgb_data = (BYTE *) malloc(64 * 64 * 3); for (i = 0; i < 64; i++) memcpy(rgb_data + i * 64 * 3, rgb_scanline_data, 64 * 3); context = nsc_context_new(); nsc_context_set_pixel_format(context, RDP_PIXEL_FORMAT_R8G8B8); enc_stream = stream_new(65536); stream_clear(enc_stream); for (i = 0; i < 30000; i++) { Stream_SetPosition(enc_stream, 0); nsc_compose_message(context, enc_stream, rgb_data, 64, 64, 64 * 3); } /*winpr_HexDump(Stream_Buffer(enc_stream), Stream_GetPosition(enc_stream));*/ nsc_process_message(context, 32, 64, 64, Stream_Buffer(enc_stream), Stream_GetPosition(enc_stream)); /*winpr_HexDump(context->bmpdata, 64 * 64 * 4);*/ stream_free(enc_stream); nsc_context_free(context); }
void test_message(void) { RFX_CONTEXT* context; STREAM* s; int i, j; RFX_RECT rect = {0, 0, 100, 80}; RFX_MESSAGE * message; rgb_data = (BYTE *) malloc(100 * 80 * 3); for (i = 0; i < 80; i++) memcpy(rgb_data + i * 100 * 3, rgb_scanline_data, 100 * 3); s = stream_new(65536); stream_clear(s); context = rfx_context_new(); context->mode = RLGR3; context->width = 800; context->height = 600; rfx_context_set_pixel_format(context, RDP_PIXEL_FORMAT_R8G8B8); for (i = 0; i < 1000; i++) { s = stream_new(65536); stream_clear(s); rfx_compose_message(context, s, &rect, 1, rgb_data, 100, 80, 100 * 3); stream_seal(s); /*hexdump(buffer, size);*/ stream_set_pos(s, 0); message = rfx_process_message(context, s->p, s->size); if (i == 0) { for (j = 0; j < message->num_tiles; j++) { dump_ppm_image(message->tiles[j]->data); } } rfx_message_free(context, message); stream_free(s); } rfx_context_free(context); free(rgb_data); }
static void crt_image_exit(imgtool_image *img) { crt_image *image=(crt_image*)img; if (image->modified) { stream_clear(image->file_handle); stream_write(image->file_handle, image->data, image->size); } stream_close(image->file_handle); free(image->data); free(image); }
static void ti85_file_exit(imgtool_image * img) { ti85_file *file=(ti85_file*)img; if (file->modified) { stream_clear(file->file_handle); stream_write(file->file_handle, file->data, file->size); } stream_close(file->file_handle); free(file->entries); free(file->data); free(file); }
void test_encode(void) { RFX_CONTEXT* context; STREAM* enc_stream; int y_size, cb_size, cr_size; int i; BYTE decode_buffer[4096 * 3]; rgb_data = (BYTE *) malloc(64 * 64 * 3); for (i = 0; i < 64; i++) memcpy(rgb_data + i * 64 * 3, rgb_scanline_data, 64 * 3); //freerdp_hexdump(rgb_data, 64 * 64 * 3); enc_stream = stream_new(65536); stream_clear(enc_stream); context = rfx_context_new(); context->mode = RLGR3; rfx_context_set_pixel_format(context, RDP_PIXEL_FORMAT_R8G8B8); rfx_encode_rgb(context, rgb_data, 64, 64, 64 * 3, test_quantization_values, test_quantization_values, test_quantization_values, enc_stream, &y_size, &cb_size, &cr_size); //dump_buffer(context->priv->cb_g_buffer, 4096); /*printf("*** Y ***\n"); freerdp_hexdump(stream_get_head(enc_stream), y_size); printf("*** Cb ***\n"); freerdp_hexdump(stream_get_head(enc_stream) + y_size, cb_size); printf("*** Cr ***\n"); freerdp_hexdump(stream_get_head(enc_stream) + y_size + cb_size, cr_size);*/ stream_set_pos(enc_stream, 0); rfx_decode_rgb(context, enc_stream, y_size, test_quantization_values, cb_size, test_quantization_values, cr_size, test_quantization_values, decode_buffer); dump_ppm_image(decode_buffer); rfx_context_free(context); stream_free(enc_stream); free(rgb_data); }
void wf_update_encode(wfInfo* wfi) { RFX_RECT rect; long height, width; BYTE* pDataBits = NULL; int stride; SURFACE_BITS_COMMAND* cmd; wf_info_find_invalid_region(wfi); cmd = &wfi->cmd; stream_set_pos(wfi->s, 0); wf_info_getScreenData(wfi, &width, &height, &pDataBits, &stride); rect.x = 0; rect.y = 0; rect.width = (UINT16) width; rect.height = (UINT16) height; //printf("x:%d y:%d w:%d h:%d\n", wfi->invalid.left, wfi->invalid.top, width, height); stream_clear(wfi->s); rfx_compose_message(wfi->rfx_context, wfi->s, &rect, 1, pDataBits, width, height, stride); wfi->frame_idx = wfi->rfx_context->frame_idx; cmd->destLeft = wfi->invalid.left; cmd->destTop = wfi->invalid.top; cmd->destRight = wfi->invalid.left + width; cmd->destBottom = wfi->invalid.top + height; cmd->bpp = 32; cmd->codecID = 3; cmd->width = width; cmd->height = height; cmd->bitmapDataLength = stream_get_length(wfi->s); cmd->bitmapData = stream_get_head(wfi->s); }
void wf_update_encode(wfInfo* wfi) { long offset; RFX_RECT rect; long height, width; GETCHANGESBUF* changes; SURFACE_BITS_COMMAND* cmd; wf_info_find_invalid_region(wfi); cmd = &wfi->cmd; changes = (GETCHANGESBUF*) wfi->changeBuffer; width = (wfi->invalid.right - wfi->invalid.left) + 1; height = (wfi->invalid.bottom - wfi->invalid.top) + 1; stream_clear(wfi->s); stream_set_pos(wfi->s, 0); rect.x = 0; rect.y = 0; rect.width = (uint16) width; rect.height = (uint16) height; offset = (4 * wfi->invalid.left) + (wfi->invalid.top * wfi->width * 4); rfx_compose_message(wfi->rfx_context, wfi->s, &rect, 1, ((uint8*) (changes->Userbuffer)) + offset, width, height, wfi->width * 4); cmd->destLeft = wfi->invalid.left; cmd->destTop = wfi->invalid.top; cmd->destRight = wfi->invalid.left + width; cmd->destBottom = wfi->invalid.top + height; cmd->bpp = 32; cmd->codecID = 3; cmd->width = width; cmd->height = height; cmd->bitmapDataLength = stream_get_length(wfi->s); cmd->bitmapData = stream_get_head(wfi->s); }
static STREAM* test_peer_stream_init(testPeerContext* context) { stream_clear(context->s); stream_set_pos(context->s, 0); return context->s; }
void mf_peer_rfx_update(freerdp_peer* client) { //check mfInfo* mfi = mf_info_get_instance(); mf_info_find_invalid_region(mfi); if (mf_info_have_invalid_region(mfi) == false) { return; } long width; long height; int pitch; BYTE* dataBits = NULL; mf_info_getScreenData(mfi, &width, &height, &dataBits, &pitch); mf_info_clear_invalid_region(mfi); //encode wStream* s; RFX_RECT rect; rdpUpdate* update; mfPeerContext* mfp; SURFACE_BITS_COMMAND* cmd; update = client->update; mfp = (mfPeerContext*) client->context; cmd = &update->surface_bits_command; s = mfp->s; stream_clear(s); stream_set_pos(s, 0); UINT32 x = mfi->invalid.x / mfi->scale; UINT32 y = mfi->invalid.y / mfi->scale; rect.x = 0; rect.y = 0; rect.width = width; rect.height = height; mfp->rfx_context->width = mfi->servscreen_width; mfp->rfx_context->height = mfi->servscreen_height; rfx_compose_message(mfp->rfx_context, s, &rect, 1, (BYTE*) dataBits, rect.width, rect.height, pitch); cmd->destLeft = x; cmd->destTop = y; cmd->destRight = x + rect.width; cmd->destBottom = y + rect.height; cmd->bpp = 32; cmd->codecID = 3; cmd->width = rect.width; cmd->height = rect.height; cmd->bitmapDataLength = stream_get_length(s); cmd->bitmapData = stream_get_head(s); //send update->SurfaceBits(update->context, cmd); //clean up... maybe? }
void mf_peer_rfx_update(freerdp_peer* client) { //check mfInfo* mfi = mf_info_get_instance(); mf_info_find_invalid_region(mfi); if (mf_info_have_invalid_region(mfi) == false) { return; } long width; long height; int pitch; BYTE* dataBits = NULL; mf_info_getScreenData(mfi, &width, &height, &dataBits, &pitch); mf_info_clear_invalid_region(mfi); //encode STREAM* s; RFX_RECT rect; rdpUpdate* update; mfPeerContext* mfp; SURFACE_BITS_COMMAND* cmd; update = client->update; mfp = (mfPeerContext*) client->context; cmd = &update->surface_bits_command; s = mfp->s; stream_clear(s); stream_set_pos(s, 0); UINT32 x = mfi->invalid.x / mfi->scale; UINT32 y = mfi->invalid.y / mfi->scale; rect.x = 0; rect.y = 0; rect.width = width; rect.height = height; mfp->rfx_context->width = mfi->servscreen_width; mfp->rfx_context->height = mfi->servscreen_height; rfx_compose_message(mfp->rfx_context, s, &rect, 1, (BYTE*) dataBits, rect.width, rect.height, pitch); cmd->destLeft = x; cmd->destTop = y; cmd->destRight = x + rect.width; cmd->destBottom = y + rect.height; cmd->bpp = 32; cmd->codecID = 3; cmd->width = rect.width; cmd->height = rect.height; cmd->bitmapDataLength = stream_get_length(s); cmd->bitmapData = stream_get_head(s); //send update->SurfaceBits(update->context, cmd); //clean up // note: need to stop getting new dirty rects until here /* CGColorSpaceRelease(rgbColorSpace); CGImageRelease(image); CGContextRelease(context); CVPixelBufferUnlockBaseAddress(pxbuffer, 0); CVPixelBufferRelease(pxbuffer); */ }
tbool rpch_in_connect_http(rdpRpch* rpch) { rdpTls* tls_in = rpch->tls_in; rdpSettings* settings = rpch->settings; rdpRpchHTTP* http_in = rpch->http_in; NTLMSSP* http_in_ntlmssp = http_in->ntht; STREAM* ntlmssp_stream; STREAM* http_stream; int decoded_ntht_length; int encoded_ntht_length = 0; int bytes; uint8* decoded_ntht_data; uint8* encoded_ntht_data = NULL; char* ntlm_text; LLOGLN(10, ("rpch_in_connect_http:")); ntlmssp_stream = stream_new(0xFFFF); http_stream = stream_new(0xFFFF); ntlmssp_set_username(http_in_ntlmssp, settings->tsg_username); ntlmssp_set_password(http_in_ntlmssp, settings->tsg_password); ntlmssp_set_domain(http_in_ntlmssp, settings->tsg_domain); ntlmssp_set_workstation(http_in_ntlmssp, "WORKSTATION"); /* TODO insert proper w.name */ LLOGLN(10, ("rpch_in_connect_http: tsg_username %s tsg_password %s tsg_domain %s", settings->tsg_username, settings->tsg_password, settings->tsg_domain)); ntlmssp_send(http_in_ntlmssp, ntlmssp_stream); decoded_ntht_length = (int) (ntlmssp_stream->p - ntlmssp_stream->data); decoded_ntht_data = (uint8*) xmalloc(decoded_ntht_length); ntlmssp_stream->p = ntlmssp_stream->data; stream_read(ntlmssp_stream, decoded_ntht_data, decoded_ntht_length); stream_clear(ntlmssp_stream); ntlmssp_stream->p = ntlmssp_stream->data; crypto_base64_encode(decoded_ntht_data, decoded_ntht_length, &encoded_ntht_data, &encoded_ntht_length); stream_write(http_stream, "RPC_IN_DATA /rpc/rpcproxy.dll?localhost:3388 HTTP/1.1\n", 54); stream_write(http_stream, "Accept: application/rpc\n", 24); stream_write(http_stream, "Cache-Control: no-cache\n", 24); stream_write(http_stream, "Connection: Keep-Alive\n", 23); stream_write(http_stream, "Content-Length: 0\n", 18); stream_write(http_stream, "User-Agent: MSRPC\n", 18); stream_write(http_stream, "Host: ", 6); stream_write(http_stream, settings->tsg_server, strlen(settings->tsg_server)); stream_write(http_stream, "\n", 1); stream_write(http_stream, "Pragma: ResourceTypeUuid=44e265dd-7daf-42cd-8560-3cdb6e7a2729, SessionId=33ad20ac-7469-4f63-946d-113eac21a23c\n", 110); stream_write(http_stream, "Authorization: NTLM ", 20); stream_write(http_stream, encoded_ntht_data, encoded_ntht_length); stream_write(http_stream, "\n\n", 2); LLOGLN(10, ("rpch_in_connect_http: sending\n%s", http_stream->data)); DEBUG_RPCH("\nSend:\n%s\n", http_stream->data); bytes = (int) (http_stream->p - http_stream->data); tls_write(tls_in, http_stream->data, bytes); stream_clear(http_stream); http_stream->p = http_stream->data; xfree(decoded_ntht_data); encoded_ntht_length = -1; xfree(encoded_ntht_data); encoded_ntht_data = NULL; http_in->contentLength = 0; LLOGLN(10, ("rpch_in_connect_http: 1")); stream_free(http_stream); http_stream = read_http(tls_in, NULL, true); if (http_stream == NULL) { LLOGLN(0, ("rpch_in_connect_http: error http_stream is nil")); return false; } ntlm_text = strstr((char*)(http_stream->data), "NTLM "); if (ntlm_text != NULL) { encoded_ntht_data = (uint8*)(ntlm_text + 5); encoded_ntht_length = 0; while (encoded_ntht_data[encoded_ntht_length] != '\r' && encoded_ntht_data[encoded_ntht_length] != '\n') { encoded_ntht_length++; } } LLOGLN(0, ("rpch_in_connect_http: encoded_ntht_length %d encoded_ntht_data %s", encoded_ntht_length, encoded_ntht_data)); if (encoded_ntht_length < 1) /* No NTLM data was found */ { LLOGLN(0, ("rpch_in_connect_http: error encoded_ntht_length < 1")); return false; } http_stream->p = http_stream->data; crypto_base64_decode(encoded_ntht_data, encoded_ntht_length, &decoded_ntht_data, &decoded_ntht_length); stream_write(ntlmssp_stream, decoded_ntht_data, decoded_ntht_length); ntlmssp_stream->p = ntlmssp_stream->data; xfree(decoded_ntht_data); ntlmssp_recv(http_in_ntlmssp, ntlmssp_stream); stream_clear(ntlmssp_stream); ntlmssp_stream->p = ntlmssp_stream->data; ntlmssp_send(http_in_ntlmssp, ntlmssp_stream); decoded_ntht_length = (int) (ntlmssp_stream->p - ntlmssp_stream->data); decoded_ntht_data = (uint8*) xmalloc(decoded_ntht_length); ntlmssp_stream->p = ntlmssp_stream->data; stream_read(ntlmssp_stream, decoded_ntht_data, decoded_ntht_length); stream_clear(ntlmssp_stream); ntlmssp_stream->p = ntlmssp_stream->data; crypto_base64_encode(decoded_ntht_data, decoded_ntht_length, &encoded_ntht_data, &encoded_ntht_length); stream_write(http_stream, "RPC_IN_DATA /rpc/rpcproxy.dll?localhost:3388 HTTP/1.1\n", 54); stream_write(http_stream, "Accept: application/rpc\n", 24); stream_write(http_stream, "Cache-Control: no-cache\n", 24); stream_write(http_stream, "Connection: Keep-Alive\n", 23); stream_write(http_stream, "Content-Length: 1073741824\n", 27); stream_write(http_stream, "User-Agent: MSRPC\n", 18); stream_write(http_stream, "Host: ", 6); stream_write(http_stream, settings->tsg_server, strlen(settings->tsg_server)); stream_write(http_stream, "\n", 1); stream_write(http_stream, "Pragma: ResourceTypeUuid=44e265dd-7daf-42cd-8560-3cdb6e7a2729, SessionId=33ad20ac-7469-4f63-946d-113eac21a23c\n", 110); stream_write(http_stream, "Authorization: NTLM ", 20); stream_write(http_stream, encoded_ntht_data, encoded_ntht_length); stream_write(http_stream, "\n\n", 2); http_in->contentLength = 1073741824; http_in->remContentLength = 1073741824; DEBUG_RPCH("\nSend:\n%s\n", http_stream->data); tls_write(tls_in, http_stream->data, http_stream->p - http_stream->data); stream_clear(http_stream); http_stream->p = http_stream->data; xfree(decoded_ntht_data); xfree(encoded_ntht_data); /* At this point IN connection is ready to send CONN/B1 and start with sending data */ http_in->state = RPCH_HTTP_SENDING; LLOGLN(10, ("rpch_in_connect_http: out")); return true; }