mirror of https://github.com/FreeRDP/FreeRDP
Merge pull request #869 from llyzs/windows
Various fixes mainly for Windows
This commit is contained in:
commit
d51905ec21
|
@ -416,6 +416,7 @@ void wf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits
|
|||
int tx, ty;
|
||||
char* tile_bitmap;
|
||||
RFX_MESSAGE* message;
|
||||
BITMAPINFO bitmap_info;
|
||||
wfInfo* wfi = ((wfContext*) context)->wfi;
|
||||
|
||||
RFX_CONTEXT* rfx_context = (RFX_CONTEXT*) wfi->rfx_context;
|
||||
|
@ -463,46 +464,33 @@ void wf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits
|
|||
{
|
||||
nsc_process_message(nsc_context, surface_bits_command->bpp, surface_bits_command->width, surface_bits_command->height,
|
||||
surface_bits_command->bitmapData, surface_bits_command->bitmapDataLength);
|
||||
wfi->image->_bitmap.width = surface_bits_command->width;
|
||||
wfi->image->_bitmap.height = surface_bits_command->height;
|
||||
wfi->image->_bitmap.bpp = surface_bits_command->bpp;
|
||||
wfi->image->_bitmap.data = (BYTE*) realloc(wfi->image->_bitmap.data, wfi->image->_bitmap.width * wfi->image->_bitmap.height * 4);
|
||||
freerdp_image_flip(nsc_context->bmpdata, wfi->image->_bitmap.data, wfi->image->_bitmap.width, wfi->image->_bitmap.height, 32);
|
||||
BitBlt(wfi->primary->hdc, surface_bits_command->destLeft, surface_bits_command->destTop, surface_bits_command->width, surface_bits_command->height, wfi->image->hdc, 0, 0, GDI_SRCCOPY);
|
||||
ZeroMemory(&bitmap_info, sizeof(bitmap_info));
|
||||
bitmap_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bitmap_info.bmiHeader.biWidth = surface_bits_command->width;
|
||||
bitmap_info.bmiHeader.biHeight = surface_bits_command->height;
|
||||
bitmap_info.bmiHeader.biPlanes = 1;
|
||||
bitmap_info.bmiHeader.biBitCount = surface_bits_command->bpp;
|
||||
bitmap_info.bmiHeader.biCompression = BI_RGB;
|
||||
SetDIBitsToDevice(wfi->primary->hdc, surface_bits_command->destLeft, surface_bits_command->destTop,
|
||||
surface_bits_command->width, surface_bits_command->height, 0, 0, 0, surface_bits_command->height,
|
||||
nsc_context->bmpdata, &bitmap_info, DIB_RGB_COLORS);
|
||||
wf_invalidate_region(wfi, surface_bits_command->destLeft, surface_bits_command->destTop,
|
||||
surface_bits_command->width, surface_bits_command->height);
|
||||
}
|
||||
else if (surface_bits_command->codecID == CODEC_ID_NONE)
|
||||
{
|
||||
wfi->image->_bitmap.width = surface_bits_command->width;
|
||||
wfi->image->_bitmap.height = surface_bits_command->height;
|
||||
wfi->image->_bitmap.bpp = surface_bits_command->bpp;
|
||||
|
||||
wfi->image->_bitmap.data = (BYTE*) realloc(wfi->image->_bitmap.data,
|
||||
wfi->image->_bitmap.width * wfi->image->_bitmap.height * 4);
|
||||
|
||||
if ((surface_bits_command->bpp != 32) || (wfi->clrconv->alpha == TRUE))
|
||||
{
|
||||
BYTE* temp_image;
|
||||
|
||||
freerdp_image_convert(surface_bits_command->bitmapData, wfi->image->_bitmap.data,
|
||||
wfi->image->_bitmap.width, wfi->image->_bitmap.height,
|
||||
wfi->image->_bitmap.bpp, 32, wfi->clrconv);
|
||||
|
||||
surface_bits_command->bpp = 32;
|
||||
surface_bits_command->bitmapData = wfi->image->_bitmap.data;
|
||||
|
||||
temp_image = (BYTE*) malloc(wfi->image->_bitmap.width * wfi->image->_bitmap.height * 4);
|
||||
freerdp_image_flip(wfi->image->_bitmap.data, temp_image, wfi->image->_bitmap.width, wfi->image->_bitmap.height, 32);
|
||||
free(wfi->image->_bitmap.data);
|
||||
wfi->image->_bitmap.data = temp_image;
|
||||
}
|
||||
else
|
||||
{
|
||||
freerdp_image_flip(surface_bits_command->bitmapData, wfi->image->_bitmap.data,
|
||||
wfi->image->_bitmap.width, wfi->image->_bitmap.height, 32);
|
||||
}
|
||||
|
||||
BitBlt(wfi->primary->hdc, surface_bits_command->destLeft, surface_bits_command->destTop,
|
||||
surface_bits_command->width, surface_bits_command->height, wfi->image->hdc, 0, 0, SRCCOPY);
|
||||
ZeroMemory(&bitmap_info, sizeof(bitmap_info));
|
||||
bitmap_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bitmap_info.bmiHeader.biWidth = surface_bits_command->width;
|
||||
bitmap_info.bmiHeader.biHeight = surface_bits_command->height;
|
||||
bitmap_info.bmiHeader.biPlanes = 1;
|
||||
bitmap_info.bmiHeader.biBitCount = surface_bits_command->bpp;
|
||||
bitmap_info.bmiHeader.biCompression = BI_RGB;
|
||||
SetDIBitsToDevice(wfi->primary->hdc, surface_bits_command->destLeft, surface_bits_command->destTop,
|
||||
surface_bits_command->width, surface_bits_command->height, 0, 0, 0, surface_bits_command->height,
|
||||
surface_bits_command->bitmapData, &bitmap_info, DIB_RGB_COLORS);
|
||||
wf_invalidate_region(wfi, surface_bits_command->destLeft, surface_bits_command->destTop,
|
||||
surface_bits_command->width, surface_bits_command->height);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -191,40 +191,38 @@ void wf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL primary)
|
|||
void wf_Pointer_New(rdpContext* context, rdpPointer* pointer)
|
||||
{
|
||||
HCURSOR hCur;
|
||||
unsigned char am[32 * 4];
|
||||
unsigned char xm[32 * 4];
|
||||
int i, j, ii;
|
||||
int width, height, bpp;
|
||||
ICONINFO info;
|
||||
BYTE *data;
|
||||
|
||||
width = pointer->width;
|
||||
height = pointer->height;
|
||||
bpp = pointer->xorBpp;
|
||||
|
||||
if ((bpp != 1 && bpp != 8 && bpp != 15 && bpp != 16 && bpp != 24 && bpp != 32) ||
|
||||
width > 32 || height > 32)
|
||||
info.fIcon = FALSE;
|
||||
info.xHotspot = pointer->xPos;
|
||||
info.yHotspot = pointer->yPos;
|
||||
if (pointer->xorBpp == 1)
|
||||
{
|
||||
printf("wf_Pointer_New: Unsupported Cursor width = %u, height = %u, xorBpp = %u\n", width, height, bpp);
|
||||
return;
|
||||
data = (BYTE*) malloc(pointer->lengthAndMask + pointer->lengthXorMask);
|
||||
CopyMemory(data, pointer->andMaskData, pointer->lengthAndMask);
|
||||
CopyMemory(data + pointer->lengthAndMask, pointer->xorMaskData, pointer->lengthXorMask);
|
||||
info.hbmMask = CreateBitmap(pointer->width, pointer->height * 2, 1, 1, data);
|
||||
free(data);
|
||||
info.hbmColor = NULL;
|
||||
}
|
||||
memset(am, 0, 32 * 4);
|
||||
memset(xm, 0, 32 * 4);
|
||||
for (i = 0; i < height; i++)
|
||||
else
|
||||
{
|
||||
ii = (bpp == 1) ? i : (height - 1) - i;
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
if (freerdp_get_pixel(pointer->andMaskData, j, i, width, height, 1))
|
||||
{
|
||||
freerdp_set_pixel(am, j, ii, width, height, 1, 1);
|
||||
}
|
||||
if (freerdp_get_pixel(pointer->xorMaskData, j, i, width, height, bpp))
|
||||
{
|
||||
freerdp_set_pixel(xm, j, ii, width, height, 1, 1);
|
||||
}
|
||||
}
|
||||
data = (BYTE*) malloc(pointer->lengthAndMask);
|
||||
freerdp_bitmap_flip(pointer->andMaskData, data, (pointer->width + 7) / 8, pointer->height);
|
||||
info.hbmMask = CreateBitmap(pointer->width, pointer->height, 1, 1, data);
|
||||
free(data);
|
||||
data = (BYTE*) malloc(pointer->lengthXorMask);
|
||||
freerdp_image_flip(pointer->xorMaskData, data, pointer->width, pointer->height, pointer->xorBpp);
|
||||
info.hbmColor = CreateBitmap(pointer->width, pointer->height, 1, pointer->xorBpp, data);
|
||||
free(data);
|
||||
}
|
||||
hCur = CreateCursor(g_hInstance, pointer->xPos, pointer->yPos, pointer->width, pointer->height, am, xm);
|
||||
hCur = CreateIconIndirect(&info);
|
||||
((wfPointer*) pointer)->cursor = hCur;
|
||||
if (info.hbmMask)
|
||||
DeleteObject(info.hbmMask);
|
||||
if (info.hbmColor)
|
||||
DeleteObject(info.hbmColor);
|
||||
}
|
||||
|
||||
void wf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
|
||||
|
@ -233,7 +231,7 @@ void wf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
|
|||
|
||||
hCur = ((wfPointer*) pointer)->cursor;
|
||||
if (hCur != 0)
|
||||
DestroyCursor(hCur);
|
||||
DestroyIcon(hCur);
|
||||
}
|
||||
|
||||
void wf_Pointer_Set(rdpContext* context, rdpPointer* pointer)
|
||||
|
|
|
@ -332,9 +332,6 @@ BOOL wf_post_connect(freerdp* instance)
|
|||
wfi->hdc->hwnd->cinvalid = (HGDI_RGN) malloc(sizeof(GDI_RGN) * wfi->hdc->hwnd->count);
|
||||
wfi->hdc->hwnd->ninvalid = 0;
|
||||
|
||||
wfi->image = wf_image_new(wfi, 64, 64, 32, NULL);
|
||||
wfi->image->_bitmap.data = NULL;
|
||||
|
||||
if (settings->RemoteFxCodec)
|
||||
{
|
||||
wfi->tile = wf_image_new(wfi, 64, 64, 32, NULL);
|
||||
|
|
|
@ -85,7 +85,6 @@ struct wf_info
|
|||
RECT update_rect;
|
||||
|
||||
wfBitmap* tile;
|
||||
wfBitmap* image;
|
||||
RFX_CONTEXT* rfx_context;
|
||||
NSC_CONTEXT* nsc_context;
|
||||
|
||||
|
|
|
@ -53,6 +53,9 @@ FREERDP_API int tls_write(rdpTls* tls, BYTE* data, int length);
|
|||
FREERDP_API int tls_read_all(rdpTls* tls, BYTE* data, int length);
|
||||
FREERDP_API int tls_write_all(rdpTls* tls, BYTE* data, int length);
|
||||
|
||||
FREERDP_API int tls_wait_read(rdpTls* tls);
|
||||
FREERDP_API int tls_wait_write(rdpTls* tls);
|
||||
|
||||
FREERDP_API BOOL tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname);
|
||||
FREERDP_API void tls_print_certificate_error(char* hostname, char* fingerprint);
|
||||
FREERDP_API void tls_print_certificate_name_mismatch_error(char* hostname, char* common_name, char** alt_names, int alt_names_count);
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
FREERDP_API int freerdp_tcp_connect(const char* hostname, int port);
|
||||
FREERDP_API int freerdp_tcp_read(int sockfd, BYTE* data, int length);
|
||||
FREERDP_API int freerdp_tcp_write(int sockfd, BYTE* data, int length);
|
||||
FREERDP_API int freerdp_tcp_wait_read(int sockfd);
|
||||
FREERDP_API int freerdp_tcp_wait_write(int sockfd);
|
||||
FREERDP_API int freerdp_tcp_disconnect(int sockfd);
|
||||
|
||||
FREERDP_API int freerdp_tcp_set_no_delay(int sockfd, BOOL no_delay);
|
||||
|
|
|
@ -168,6 +168,16 @@ int tcp_write(rdpTcp* tcp, BYTE* data, int length)
|
|||
return freerdp_tcp_write(tcp->sockfd, data, length);
|
||||
}
|
||||
|
||||
int tcp_wait_read(rdpTcp* tcp)
|
||||
{
|
||||
return freerdp_tcp_wait_read(tcp->sockfd);
|
||||
}
|
||||
|
||||
int tcp_wait_write(rdpTcp* tcp)
|
||||
{
|
||||
return freerdp_tcp_wait_write(tcp->sockfd);
|
||||
}
|
||||
|
||||
BOOL tcp_disconnect(rdpTcp* tcp)
|
||||
{
|
||||
freerdp_tcp_disconnect(tcp->sockfd);
|
||||
|
|
|
@ -48,6 +48,8 @@ BOOL tcp_connect(rdpTcp* tcp, const char* hostname, UINT16 port);
|
|||
BOOL tcp_disconnect(rdpTcp* tcp);
|
||||
int tcp_read(rdpTcp* tcp, BYTE* data, int length);
|
||||
int tcp_write(rdpTcp* tcp, BYTE* data, int length);
|
||||
int tcp_wait_read(rdpTcp* tcp);
|
||||
int tcp_wait_write(rdpTcp* tcp);
|
||||
BOOL tcp_set_blocking_mode(rdpTcp* tcp, BOOL blocking);
|
||||
BOOL tcp_set_keep_alive_mode(rdpTcp* tcp);
|
||||
|
||||
|
|
|
@ -423,7 +423,12 @@ int transport_read(rdpTransport* transport, STREAM* s)
|
|||
|
||||
if ((status == 0) && (transport->blocking))
|
||||
{
|
||||
USleep(transport->usleep_interval);
|
||||
if (transport->layer == TRANSPORT_LAYER_TLS)
|
||||
tls_wait_read(transport->TlsIn);
|
||||
else if (transport->layer == TRANSPORT_LAYER_TCP)
|
||||
tcp_wait_read(transport->TcpIn);
|
||||
else
|
||||
USleep(transport->usleep_interval);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -488,9 +493,6 @@ int transport_write(rdpTransport* transport, STREAM* s)
|
|||
|
||||
if (status == 0)
|
||||
{
|
||||
/* blocking while sending */
|
||||
USleep(transport->usleep_interval);
|
||||
|
||||
/* when sending is blocked in nonblocking mode, the receiving buffer should be checked */
|
||||
if (!transport->blocking)
|
||||
{
|
||||
|
@ -498,6 +500,13 @@ int transport_write(rdpTransport* transport, STREAM* s)
|
|||
if (transport_read_nonblocking(transport) > 0)
|
||||
SetEvent(transport->recv_event);
|
||||
}
|
||||
|
||||
if (transport->layer == TRANSPORT_LAYER_TLS)
|
||||
tls_wait_write(transport->TlsOut);
|
||||
else if (transport->layer == TRANSPORT_LAYER_TCP)
|
||||
tcp_wait_write(transport->TcpOut);
|
||||
else
|
||||
USleep(transport->usleep_interval);
|
||||
}
|
||||
|
||||
length -= status;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <winpr/crt.h>
|
||||
|
||||
#include <freerdp/utils/stream.h>
|
||||
#include <freerdp/utils/tcp.h>
|
||||
|
||||
#include <freerdp/crypto/tls.h>
|
||||
|
||||
|
@ -331,6 +332,8 @@ int tls_read_all(rdpTls* tls, BYTE* data, int length)
|
|||
do
|
||||
{
|
||||
status = tls_read(tls, data, length);
|
||||
if (status == 0)
|
||||
tls_wait_read(tls);
|
||||
}
|
||||
while (status == 0);
|
||||
|
||||
|
@ -382,6 +385,8 @@ int tls_write_all(rdpTls* tls, BYTE* data, int length)
|
|||
|
||||
if (status > 0)
|
||||
sent += status;
|
||||
else if (status == 0)
|
||||
tls_wait_write(tls);
|
||||
|
||||
if (sent >= length)
|
||||
break;
|
||||
|
@ -394,6 +399,16 @@ int tls_write_all(rdpTls* tls, BYTE* data, int length)
|
|||
return status;
|
||||
}
|
||||
|
||||
int tls_wait_read(rdpTls* tls)
|
||||
{
|
||||
return freerdp_tcp_wait_read(tls->sockfd);
|
||||
}
|
||||
|
||||
int tls_wait_write(rdpTls* tls)
|
||||
{
|
||||
return freerdp_tcp_wait_write(tls->sockfd);
|
||||
}
|
||||
|
||||
static void tls_errors(const char *prefix)
|
||||
{
|
||||
unsigned long error;
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/select.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <net/if.h>
|
||||
|
@ -178,6 +179,28 @@ int freerdp_tcp_write(int sockfd, BYTE* data, int length)
|
|||
return status;
|
||||
}
|
||||
|
||||
int freerdp_tcp_wait_read(int sockfd)
|
||||
{
|
||||
fd_set fds;
|
||||
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(sockfd, &fds);
|
||||
select(1, &fds, NULL, NULL, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_tcp_wait_write(int sockfd)
|
||||
{
|
||||
fd_set fds;
|
||||
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(sockfd, &fds);
|
||||
select(1, NULL, &fds, NULL, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_tcp_disconnect(int sockfd)
|
||||
{
|
||||
if (sockfd != -1)
|
||||
|
|
|
@ -79,7 +79,7 @@ void freerdp_thread_stop(freerdp_thread* thread)
|
|||
while ((thread->status > 0) && (i < 1000))
|
||||
{
|
||||
i++;
|
||||
USleep(100000);
|
||||
Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue