void AsyncHashTable_Add(AsyncHashTable* self, uint8* key, uint32 keyLength, void* value, uint32 valueLength) { assert(self != NULL); SAL_Mutex_Acquire(self->Lock); HashTable_Add(self->BaseTable, key, keyLength, value, valueLength); SAL_Mutex_Release(self->Lock); }
int StringChunk_Add(StringChunk *dl, const char *Str, const char *AdditionalData, int LengthOfAdditionalData /* The length will not be stored. */ ) { EntryForString NewEntry; if( AdditionalData != NULL && LengthOfAdditionalData > 0 ) { _32BIT_INT OffsetOfStoredTo; char *DataStoredTo = ExtendableBuffer_Expand(&(dl -> AdditionalDataChunk), LengthOfAdditionalData, &OffsetOfStoredTo ); if( DataStoredTo == NULL ) { return -1; } NewEntry.OffsetOfData = OffsetOfStoredTo; memcpy(DataStoredTo, AdditionalData, LengthOfAdditionalData); } else { NewEntry.OffsetOfData = -1; } if( ContainWildCard(Str) ) { NewEntry.OffsetOfString = StringList_Add(&(dl -> List_W), Str, ','); if( NewEntry.OffsetOfString >= 0 ) { Array_PushBack(&(dl -> List_W_Pos), &NewEntry, NULL); } else { return -1; } } else { NewEntry.OffsetOfString = StringList_Add(&(dl -> List), Str, ','); if( NewEntry.OffsetOfString >= 0 ) { HashTable_Add(&(dl -> List_Pos), Str, 0, &NewEntry, NULL); } else { return -2; } } return 0; }
int rdpgfx_set_surface_data(RdpgfxClientContext* context, UINT16 surfaceId, void* pData) { ULONG_PTR key; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) context->handle; key = ((ULONG_PTR) surfaceId) + 1; if (pData) HashTable_Add(gfx->SurfaceTable, (void*) key, pData); else HashTable_Remove(gfx->SurfaceTable, (void*) key); return 1; }
HANDLE WINAPI FreeRDP_WTSOpenServerA(LPSTR pServerName) { rdpContext* context; freerdp_peer* client; WTSVirtualChannelManager* vcm; HANDLE hServer = INVALID_HANDLE_VALUE; context = (rdpContext*) pServerName; if (!context) return INVALID_HANDLE_VALUE; client = context->peer; if (!client) return INVALID_HANDLE_VALUE; vcm = (WTSVirtualChannelManager*) calloc(1, sizeof(WTSVirtualChannelManager)); if (vcm) { vcm->client = client; vcm->rdp = context->rdp; vcm->SessionId = g_SessionId++; if (!g_ServerHandles) g_ServerHandles = HashTable_New(TRUE); HashTable_Add(g_ServerHandles, (void*) (UINT_PTR) vcm->SessionId, (void*) vcm); vcm->queue = MessageQueue_New(NULL); vcm->dvc_channel_id_seq = 1; vcm->dynamicVirtualChannels = ArrayList_New(TRUE); client->ReceiveChannelData = WTSReceiveChannelData; hServer = (HANDLE) vcm; } return hServer; }
static void wf_rail_window_common(rdpContext* context, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* windowState) { wfRailWindow* railWindow = NULL; wfContext* wfc = (wfContext*) context; RailClientContext* rail = wfc->rail; UINT32 fieldFlags = orderInfo->fieldFlags; PrintRailWindowState(orderInfo, windowState); if (fieldFlags & WINDOW_ORDER_STATE_NEW) { HANDLE hInstance; WCHAR* titleW = NULL; WNDCLASSEX wndClassEx; railWindow = (wfRailWindow*) calloc(1, sizeof(wfRailWindow)); if (!railWindow) return; railWindow->wfc = wfc; railWindow->dwStyle = windowState->style; railWindow->dwStyle &= ~RAIL_DISABLED_WINDOW_STYLES; railWindow->dwExStyle = windowState->extendedStyle; railWindow->dwExStyle &= ~RAIL_DISABLED_EXTENDED_WINDOW_STYLES; railWindow->x = windowState->windowOffsetX; railWindow->y = windowState->windowOffsetY; railWindow->width = windowState->windowWidth; railWindow->height = windowState->windowHeight; if (fieldFlags & WINDOW_ORDER_FIELD_TITLE) { char* title = NULL; ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) windowState->titleInfo.string, windowState->titleInfo.length / 2, &title, 0, NULL, NULL); railWindow->title = title; } else { railWindow->title = _strdup("RdpRailWindow"); } ConvertToUnicode(CP_UTF8, 0, railWindow->title, -1, &titleW, 0); hInstance = GetModuleHandle(NULL); ZeroMemory(&wndClassEx, sizeof(WNDCLASSEX)); wndClassEx.cbSize = sizeof(WNDCLASSEX); wndClassEx.style = 0; wndClassEx.lpfnWndProc = wf_RailWndProc; wndClassEx.cbClsExtra = 0; wndClassEx.cbWndExtra = 0; wndClassEx.hIcon = NULL; wndClassEx.hCursor = NULL; wndClassEx.hbrBackground = NULL; wndClassEx.lpszMenuName = NULL; wndClassEx.lpszClassName = _T("RdpRailWindow"); wndClassEx.hInstance = hInstance; wndClassEx.hIconSm = NULL; RegisterClassEx(&wndClassEx); railWindow->hWnd = CreateWindowExW( railWindow->dwExStyle, /* dwExStyle */ _T("RdpRailWindow"), /* lpClassName */ titleW, /* lpWindowName */ railWindow->dwStyle, /* dwStyle */ railWindow->x, /* x */ railWindow->y, /* y */ railWindow->width, /* nWidth */ railWindow->height, /* nHeight */ NULL, /* hWndParent */ NULL, /* hMenu */ hInstance, /* hInstance */ NULL /* lpParam */ ); SetWindowLongPtr(railWindow->hWnd, GWLP_USERDATA, (LONG_PTR) railWindow); HashTable_Add(wfc->railWindows, (void*) (UINT_PTR) orderInfo->windowId, (void*) railWindow); free(titleW); UpdateWindow(railWindow->hWnd); return; } else { railWindow = (wfRailWindow*) HashTable_GetItemValue(wfc->railWindows, (void*) (UINT_PTR) orderInfo->windowId); } if (!railWindow) return; if ((fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) || (fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE)) { if (fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) { railWindow->x = windowState->windowOffsetX; railWindow->y = windowState->windowOffsetY; } if (fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE) { railWindow->width = windowState->windowWidth; railWindow->height = windowState->windowHeight; } SetWindowPos(railWindow->hWnd, NULL, railWindow->x, railWindow->y, railWindow->width, railWindow->height, 0); } if (fieldFlags & WINDOW_ORDER_FIELD_OWNER) { } if (fieldFlags & WINDOW_ORDER_FIELD_STYLE) { railWindow->dwStyle = windowState->style; railWindow->dwStyle &= ~RAIL_DISABLED_WINDOW_STYLES; railWindow->dwExStyle = windowState->extendedStyle; railWindow->dwExStyle &= ~RAIL_DISABLED_EXTENDED_WINDOW_STYLES; SetWindowLongPtr(railWindow->hWnd, GWL_STYLE, (LONG) railWindow->dwStyle); SetWindowLongPtr(railWindow->hWnd, GWL_EXSTYLE, (LONG) railWindow->dwExStyle); } if (fieldFlags & WINDOW_ORDER_FIELD_SHOW) { ShowWindow(railWindow->hWnd, windowState->showState); } if (fieldFlags & WINDOW_ORDER_FIELD_TITLE) { char* title = NULL; WCHAR* titleW = NULL; ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) windowState->titleInfo.string, windowState->titleInfo.length / 2, &title, 0, NULL, NULL); free(railWindow->title); railWindow->title = title; ConvertToUnicode(CP_UTF8, 0, railWindow->title, -1, &titleW, 0); SetWindowTextW(railWindow->hWnd, titleW); free(titleW); } if (fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET) { } if (fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE) { } if (fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA) { } if (fieldFlags & WINDOW_ORDER_FIELD_RP_CONTENT) { } if (fieldFlags & WINDOW_ORDER_FIELD_ROOT_PARENT) { } if (fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS) { UINT32 index; HRGN hWndRect; HRGN hWndRects; RECTANGLE_16* rect; if (windowState->numWindowRects > 0) { rect = &(windowState->windowRects[0]); hWndRects = CreateRectRgn(rect->left, rect->top, rect->right, rect->bottom); for (index = 1; index < windowState->numWindowRects; index++) { rect = &(windowState->windowRects[index]); hWndRect = CreateRectRgn(rect->left, rect->top, rect->right, rect->bottom); CombineRgn(hWndRects, hWndRects, hWndRect, RGN_OR); DeleteObject(hWndRect); } SetWindowRgn(railWindow->hWnd, hWndRects, TRUE); DeleteObject(hWndRects); } } if (fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET) { } if (fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY) { } UpdateWindow(railWindow->hWnd); }
static BOOL xf_rail_window_common(rdpContext* context, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* windowState) { xfAppWindow* appWindow = NULL; xfContext* xfc = (xfContext*) context; UINT32 fieldFlags = orderInfo->fieldFlags; if (fieldFlags & WINDOW_ORDER_STATE_NEW) { appWindow = (xfAppWindow*) calloc(1, sizeof(xfAppWindow)); if (!appWindow) return FALSE; appWindow->xfc = xfc; appWindow->windowId = orderInfo->windowId; appWindow->dwStyle = windowState->style; appWindow->dwExStyle = windowState->extendedStyle; appWindow->x = appWindow->windowOffsetX = windowState->windowOffsetX; appWindow->y = appWindow->windowOffsetY = windowState->windowOffsetY; appWindow->width = appWindow->windowWidth = windowState->windowWidth; appWindow->height = appWindow->windowHeight = windowState->windowHeight; appWindow->localWindowOffsetCorrX = 0; appWindow->localWindowOffsetCorrY = 0; if (fieldFlags & WINDOW_ORDER_FIELD_TITLE) { char* title = NULL; ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) windowState->titleInfo.string, windowState->titleInfo.length / 2, &title, 0, NULL, NULL); appWindow->title = title; } else { appWindow->title = _strdup("RdpRailWindow"); } if (!appWindow->title) { free(appWindow); return FALSE; } HashTable_Add(xfc->railWindows, (void*) (UINT_PTR) orderInfo->windowId, (void*) appWindow); xf_AppWindowInit(xfc, appWindow); return TRUE; } else { appWindow = (xfAppWindow*) HashTable_GetItemValue(xfc->railWindows, (void*) (UINT_PTR) orderInfo->windowId); } if (!appWindow) return FALSE; /* Update Parameters */ if ((fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) || (fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE)) { if (fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) { appWindow->windowOffsetX = windowState->windowOffsetX; appWindow->windowOffsetY = windowState->windowOffsetY; /* * The rail server can give negative window coordinates when updating windowOffsetX and windowOffsetY, * but we can only send unsigned integers to the rail server. Therefore, we maintain a local offset. */ if (appWindow->windowOffsetX < 0) appWindow->localWindowOffsetCorrX = 0 - appWindow->windowOffsetX; else appWindow->localWindowOffsetCorrX = 0; if (appWindow->windowOffsetY < 0) appWindow->localWindowOffsetCorrY = 0 - appWindow->windowOffsetY; else appWindow->localWindowOffsetCorrY = 0; } if (fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE) { appWindow->windowWidth = windowState->windowWidth; appWindow->windowHeight = windowState->windowHeight; } } if (fieldFlags & WINDOW_ORDER_FIELD_OWNER) { appWindow->ownerWindowId = windowState->ownerWindowId; } if (fieldFlags & WINDOW_ORDER_FIELD_STYLE) { appWindow->dwStyle = windowState->style; appWindow->dwExStyle = windowState->extendedStyle; } if (fieldFlags & WINDOW_ORDER_FIELD_SHOW) { appWindow->showState = windowState->showState; } if (fieldFlags & WINDOW_ORDER_FIELD_TITLE) { char* title = NULL; ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) windowState->titleInfo.string, windowState->titleInfo.length / 2, &title, 0, NULL, NULL); free(appWindow->title); appWindow->title = title; } if (fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET) { appWindow->clientOffsetX = windowState->clientOffsetX; appWindow->clientOffsetY = windowState->clientOffsetY; } if (fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE) { appWindow->clientAreaWidth = windowState->clientAreaWidth; appWindow->clientAreaHeight = windowState->clientAreaHeight; } if (fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA) { appWindow->windowClientDeltaX = windowState->windowClientDeltaX; appWindow->windowClientDeltaY = windowState->windowClientDeltaY; } if (fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS) { if (appWindow->windowRects) { free(appWindow->windowRects); appWindow->windowRects = NULL; } appWindow->numWindowRects = windowState->numWindowRects; if (appWindow->numWindowRects) { appWindow->windowRects = (RECTANGLE_16*) calloc(appWindow->numWindowRects, sizeof(RECTANGLE_16)); if (!appWindow->windowRects) return FALSE; CopyMemory(appWindow->windowRects, windowState->windowRects, appWindow->numWindowRects * sizeof(RECTANGLE_16)); } } if (fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET) { appWindow->visibleOffsetX = windowState->visibleOffsetX; appWindow->visibleOffsetY = windowState->visibleOffsetY; } if (fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY) { if (appWindow->visibilityRects) { free(appWindow->visibilityRects); appWindow->visibilityRects = NULL; } appWindow->numVisibilityRects = windowState->numVisibilityRects; if (appWindow->numVisibilityRects) { appWindow->visibilityRects = (RECTANGLE_16*) calloc(appWindow->numVisibilityRects, sizeof(RECTANGLE_16)); if (!appWindow->visibilityRects) return FALSE; CopyMemory(appWindow->visibilityRects, windowState->visibilityRects, appWindow->numVisibilityRects * sizeof(RECTANGLE_16)); } } /* Update Window */ if (fieldFlags & WINDOW_ORDER_FIELD_STYLE) { } if (fieldFlags & WINDOW_ORDER_FIELD_SHOW) { xf_ShowWindow(xfc, appWindow, appWindow->showState); } if (fieldFlags & WINDOW_ORDER_FIELD_TITLE) { if (appWindow->title) xf_SetWindowText(xfc, appWindow, appWindow->title); } if ((fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) || (fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE)) { /* * The rail server like to set the window to a small size when it is minimized even though it is hidden * in some cases this can cause the window not to restore back to its original size. Therefore we don't * update our local window when that rail window state is minimized */ if (appWindow->rail_state == WINDOW_SHOW_MINIMIZED) return TRUE; /* Do nothing if window is already in the correct position */ if (appWindow->x == (appWindow->windowOffsetX - appWindow->localWindowOffsetCorrX) && appWindow->y == (appWindow->windowOffsetY - appWindow->localWindowOffsetCorrY) && appWindow->width == appWindow->windowWidth && appWindow->height == appWindow->windowHeight) { xf_UpdateWindowArea(xfc, appWindow, 0, 0, appWindow->windowWidth, appWindow->windowHeight); return TRUE; } xf_MoveWindow(xfc, appWindow, appWindow->windowOffsetX - appWindow->localWindowOffsetCorrX, appWindow->windowOffsetY - appWindow->localWindowOffsetCorrY, appWindow->windowWidth, appWindow->windowHeight); } if (fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS) { xf_SetWindowRects(xfc, appWindow, appWindow->windowRects, appWindow->numWindowRects); } if (fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY) { xf_SetWindowVisibilityRects(xfc, appWindow, appWindow->visibilityRects, appWindow->numVisibilityRects); } return TRUE; }
UINT VCAPITYPE FreeRDP_VirtualChannelInit(LPVOID* ppInitHandle, PCHANNEL_DEF pChannel, INT channelCount, ULONG versionRequested, PCHANNEL_INIT_EVENT_FN pChannelInitEventProc) { int index; void* pInterface; DWORD OpenHandle; CHANNEL_DEF* channel; rdpChannels* channels; rdpSettings* settings; PCHANNEL_DEF pChannelDef; CHANNEL_INIT_DATA* pChannelInitData; CHANNEL_OPEN_DATA* pChannelOpenData; CHANNEL_CLIENT_DATA* pChannelClientData; if (!ppInitHandle) return CHANNEL_RC_BAD_INIT_HANDLE; channels = g_ChannelInitData.channels; pInterface = g_pInterface; pChannelInitData = &(channels->initDataList[channels->initDataCount]); *ppInitHandle = pChannelInitData; channels->initDataCount++; pChannelInitData->channels = channels; pChannelInitData->pInterface = pInterface; if (!channels->can_call_init) return CHANNEL_RC_NOT_IN_VIRTUALCHANNELENTRY; if (channels->openDataCount + channelCount >= CHANNEL_MAX_COUNT) return CHANNEL_RC_TOO_MANY_CHANNELS; if (!pChannel) return CHANNEL_RC_BAD_CHANNEL; if (channels->connected) return CHANNEL_RC_ALREADY_CONNECTED; if (versionRequested != VIRTUAL_CHANNEL_VERSION_WIN2000) { } for (index = 0; index < channelCount; index++) { pChannelDef = &pChannel[index]; if (freerdp_channels_find_channel_open_data_by_name(channels, pChannelDef->name) != 0) { return CHANNEL_RC_BAD_CHANNEL; } } pChannelClientData = &channels->clientDataList[channels->clientDataCount]; pChannelClientData->pChannelInitEventProc = pChannelInitEventProc; pChannelClientData->pInitHandle = *ppInitHandle; channels->clientDataCount++; settings = channels->settings; for (index = 0; index < channelCount; index++) { pChannelDef = &pChannel[index]; pChannelOpenData = &channels->openDataList[channels->openDataCount]; OpenHandle = g_open_handle_sequence++; pChannelOpenData->OpenHandle = OpenHandle; pChannelOpenData->channels = channels; HashTable_Add(g_OpenHandles, (void*) (UINT_PTR) OpenHandle, (void*) pChannelOpenData); pChannelOpenData->flags = 1; /* init */ strncpy(pChannelOpenData->name, pChannelDef->name, CHANNEL_NAME_LEN); pChannelOpenData->options = pChannelDef->options; if (settings->ChannelCount < CHANNEL_MAX_COUNT) { channel = &settings->ChannelDefArray[settings->ChannelCount]; strncpy(channel->name, pChannelDef->name, 7); channel->options = pChannelDef->options; channels->settings->ChannelCount++; } channels->openDataCount++; } return CHANNEL_RC_OK; }
static BOOL xf_rail_window_common(rdpContext* context, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* windowState) { xfAppWindow* appWindow = NULL; xfContext* xfc = (xfContext*) context; UINT32 fieldFlags = orderInfo->fieldFlags; BOOL position_or_size_updated = FALSE; if (fieldFlags & WINDOW_ORDER_STATE_NEW) { appWindow = (xfAppWindow*) calloc(1, sizeof(xfAppWindow)); if (!appWindow) return FALSE; appWindow->xfc = xfc; appWindow->windowId = orderInfo->windowId; appWindow->dwStyle = windowState->style; appWindow->dwExStyle = windowState->extendedStyle; appWindow->x = appWindow->windowOffsetX = windowState->windowOffsetX; appWindow->y = appWindow->windowOffsetY = windowState->windowOffsetY; appWindow->width = appWindow->windowWidth = windowState->windowWidth; appWindow->height = appWindow->windowHeight = windowState->windowHeight; /* Ensure window always gets a window title */ if (fieldFlags & WINDOW_ORDER_FIELD_TITLE) { char* title = NULL; if (windowState->titleInfo.length == 0) { if (!(title = _strdup(""))) { WLog_ERR(TAG, "failed to duplicate empty window title string"); /* error handled below */ } } else if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) windowState->titleInfo.string, windowState->titleInfo.length / 2, &title, 0, NULL, NULL) < 1) { WLog_ERR(TAG, "failed to convert window title"); /* error handled below */ } appWindow->title = title; } else { if (!(appWindow->title = _strdup("RdpRailWindow"))) WLog_ERR(TAG, "failed to duplicate default window title string"); } if (!appWindow->title) { free(appWindow); return FALSE; } HashTable_Add(xfc->railWindows, (void*)(UINT_PTR) orderInfo->windowId, (void*) appWindow); xf_AppWindowInit(xfc, appWindow); } else { appWindow = (xfAppWindow*) HashTable_GetItemValue(xfc->railWindows, (void*)(UINT_PTR) orderInfo->windowId); } if (!appWindow) return FALSE; /* Keep track of any position/size update so that we can force a refresh of the window */ if ((fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) || (fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE) || (fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET) || (fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE) || (fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA) || (fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET) || (fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)) { position_or_size_updated = TRUE; } /* Update Parameters */ if (fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET) { appWindow->windowOffsetX = windowState->windowOffsetX; appWindow->windowOffsetY = windowState->windowOffsetY; } if (fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE) { appWindow->windowWidth = windowState->windowWidth; appWindow->windowHeight = windowState->windowHeight; } if (fieldFlags & WINDOW_ORDER_FIELD_OWNER) { appWindow->ownerWindowId = windowState->ownerWindowId; } if (fieldFlags & WINDOW_ORDER_FIELD_STYLE) { appWindow->dwStyle = windowState->style; appWindow->dwExStyle = windowState->extendedStyle; } if (fieldFlags & WINDOW_ORDER_FIELD_SHOW) { appWindow->showState = windowState->showState; } if (fieldFlags & WINDOW_ORDER_FIELD_TITLE) { char* title = NULL; if (windowState->titleInfo.length == 0) { if (!(title = _strdup(""))) { WLog_ERR(TAG, "failed to duplicate empty window title string"); return FALSE; } } else if (ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) windowState->titleInfo.string, windowState->titleInfo.length / 2, &title, 0, NULL, NULL) < 1) { WLog_ERR(TAG, "failed to convert window title"); return FALSE; } free(appWindow->title); appWindow->title = title; } if (fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET) { appWindow->clientOffsetX = windowState->clientOffsetX; appWindow->clientOffsetY = windowState->clientOffsetY; } if (fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE) { appWindow->clientAreaWidth = windowState->clientAreaWidth; appWindow->clientAreaHeight = windowState->clientAreaHeight; } if (fieldFlags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA) { appWindow->windowClientDeltaX = windowState->windowClientDeltaX; appWindow->windowClientDeltaY = windowState->windowClientDeltaY; } if (fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS) { if (appWindow->windowRects) { free(appWindow->windowRects); appWindow->windowRects = NULL; } appWindow->numWindowRects = windowState->numWindowRects; if (appWindow->numWindowRects) { appWindow->windowRects = (RECTANGLE_16*) calloc(appWindow->numWindowRects, sizeof(RECTANGLE_16)); if (!appWindow->windowRects) return FALSE; CopyMemory(appWindow->windowRects, windowState->windowRects, appWindow->numWindowRects * sizeof(RECTANGLE_16)); } } if (fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET) { appWindow->visibleOffsetX = windowState->visibleOffsetX; appWindow->visibleOffsetY = windowState->visibleOffsetY; } if (fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY) { if (appWindow->visibilityRects) { free(appWindow->visibilityRects); appWindow->visibilityRects = NULL; } appWindow->numVisibilityRects = windowState->numVisibilityRects; if (appWindow->numVisibilityRects) { appWindow->visibilityRects = (RECTANGLE_16*) calloc( appWindow->numVisibilityRects, sizeof(RECTANGLE_16)); if (!appWindow->visibilityRects) return FALSE; CopyMemory(appWindow->visibilityRects, windowState->visibilityRects, appWindow->numVisibilityRects * sizeof(RECTANGLE_16)); } } /* Update Window */ if (fieldFlags & WINDOW_ORDER_FIELD_STYLE) { } if (fieldFlags & WINDOW_ORDER_FIELD_SHOW) { xf_ShowWindow(xfc, appWindow, appWindow->showState); } if (fieldFlags & WINDOW_ORDER_FIELD_TITLE) { if (appWindow->title) xf_SetWindowText(xfc, appWindow, appWindow->title); } if (position_or_size_updated) { UINT32 visibilityRectsOffsetX = (appWindow->visibleOffsetX - (appWindow->clientOffsetX - appWindow->windowClientDeltaX)); UINT32 visibilityRectsOffsetY = (appWindow->visibleOffsetY - (appWindow->clientOffsetY - appWindow->windowClientDeltaY)); /* * The rail server like to set the window to a small size when it is minimized even though it is hidden * in some cases this can cause the window not to restore back to its original size. Therefore we don't * update our local window when that rail window state is minimized */ if (appWindow->rail_state != WINDOW_SHOW_MINIMIZED) { /* Redraw window area if already in the correct position */ if (appWindow->x == appWindow->windowOffsetX && appWindow->y == appWindow->windowOffsetY && appWindow->width == appWindow->windowWidth && appWindow->height == appWindow->windowHeight) { xf_UpdateWindowArea(xfc, appWindow, 0, 0, appWindow->windowWidth, appWindow->windowHeight); } else { xf_MoveWindow(xfc, appWindow, appWindow->windowOffsetX, appWindow->windowOffsetY, appWindow->windowWidth, appWindow->windowHeight); } xf_SetWindowVisibilityRects(xfc, appWindow, visibilityRectsOffsetX, visibilityRectsOffsetY, appWindow->visibilityRects, appWindow->numVisibilityRects); } } /* We should only be using the visibility rects for shaping the window */ /*if (fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS) { xf_SetWindowRects(xfc, appWindow, appWindow->windowRects, appWindow->numWindowRects); }*/ return TRUE; }
static UINT VCAPITYPE FreeRDP_VirtualChannelInitEx(LPVOID lpUserParam, LPVOID clientContext, LPVOID pInitHandle, PCHANNEL_DEF pChannel, INT channelCount, ULONG versionRequested, PCHANNEL_INIT_EVENT_EX_FN pChannelInitEventProcEx) { INT index; CHANNEL_DEF* channel; rdpSettings* settings; PCHANNEL_DEF pChannelDef; CHANNEL_INIT_DATA* pChannelInitData; CHANNEL_OPEN_DATA* pChannelOpenData; CHANNEL_CLIENT_DATA* pChannelClientData; rdpChannels* channels = (rdpChannels*) pInitHandle; if (!pInitHandle) return CHANNEL_RC_BAD_INIT_HANDLE; if (!pChannel || (channelCount <= 0) || !pChannelInitEventProcEx) return CHANNEL_RC_INITIALIZATION_ERROR; pChannelInitData = (CHANNEL_INIT_DATA*) pInitHandle; channels = pChannelInitData->channels; pChannelInitData->pInterface = clientContext; if (!channels->can_call_init) return CHANNEL_RC_NOT_IN_VIRTUALCHANNELENTRY; if ((channels->openDataCount + channelCount) >= CHANNEL_MAX_COUNT) return CHANNEL_RC_TOO_MANY_CHANNELS; if (!pChannel) return CHANNEL_RC_BAD_CHANNEL; if (channels->connected) return CHANNEL_RC_ALREADY_CONNECTED; if (versionRequested != VIRTUAL_CHANNEL_VERSION_WIN2000) { } for (index = 0; index < channelCount; index++) { pChannelDef = &pChannel[index]; if (freerdp_channels_find_channel_open_data_by_name(channels, pChannelDef->name) != 0) { return CHANNEL_RC_BAD_CHANNEL; } } pChannelClientData = &channels->clientDataList[channels->clientDataCount]; pChannelClientData->pChannelInitEventProcEx = pChannelInitEventProcEx; pChannelClientData->pInitHandle = pInitHandle; pChannelClientData->lpUserParam = lpUserParam; channels->clientDataCount++; settings = channels->instance->context->settings; for (index = 0; index < channelCount; index++) { pChannelDef = &pChannel[index]; pChannelOpenData = &channels->openDataList[channels->openDataCount]; pChannelOpenData->OpenHandle = InterlockedIncrement(&g_OpenHandleSeq); pChannelOpenData->channels = channels; pChannelOpenData->lpUserParam = lpUserParam; HashTable_Add(channels->openHandles, (void*)(UINT_PTR) pChannelOpenData->OpenHandle, (void*) pChannelOpenData); pChannelOpenData->flags = 1; /* init */ strncpy(pChannelOpenData->name, pChannelDef->name, CHANNEL_NAME_LEN); pChannelOpenData->options = pChannelDef->options; if (settings->ChannelCount < CHANNEL_MAX_COUNT) { channel = &settings->ChannelDefArray[settings->ChannelCount]; strncpy(channel->name, pChannelDef->name, 7); channel->options = pChannelDef->options; settings->ChannelCount++; } channels->openDataCount++; } return CHANNEL_RC_OK; }
HANDLE WINAPI FreeRDP_WTSOpenServerA(LPSTR pServerName) { rdpContext* context; freerdp_peer* client; WTSVirtualChannelManager* vcm; HANDLE hServer = INVALID_HANDLE_VALUE; context = (rdpContext*) pServerName; if (!context) return INVALID_HANDLE_VALUE; client = context->peer; if (!client) { SetLastError(ERROR_INVALID_DATA); return INVALID_HANDLE_VALUE; } vcm = (WTSVirtualChannelManager*) calloc(1, sizeof(WTSVirtualChannelManager)); if (!vcm) goto error_vcm_alloc; vcm->client = client; vcm->rdp = context->rdp; vcm->SessionId = g_SessionId++; if (!g_ServerHandles) { g_ServerHandles = HashTable_New(TRUE); if (!g_ServerHandles) goto error_free; } if (HashTable_Add(g_ServerHandles, (void*) (UINT_PTR) vcm->SessionId, (void*) vcm) < 0) goto error_free; vcm->queue = MessageQueue_New(NULL); if (!vcm->queue) goto error_queue; vcm->dvc_channel_id_seq = 0; vcm->dynamicVirtualChannels = ArrayList_New(TRUE); if (!vcm->dynamicVirtualChannels) goto error_dynamicVirtualChannels; client->ReceiveChannelData = WTSReceiveChannelData; hServer = (HANDLE) vcm; return hServer; error_dynamicVirtualChannels: MessageQueue_Free(vcm->queue); error_queue: HashTable_Remove(g_ServerHandles, (void*) (UINT_PTR) vcm->SessionId); error_free: free(vcm); error_vcm_alloc: SetLastError(ERROR_NOT_ENOUGH_MEMORY); return INVALID_HANDLE_VALUE; }
int test_hash_table_string() { int count; char* value; wHashTable* table; table = HashTable_New(TRUE); if (!table) return -1; table->hash = HashTable_StringHash; table->keyCompare = HashTable_StringCompare; table->valueCompare = HashTable_StringCompare; table->keyClone = HashTable_StringClone; table->valueClone = HashTable_StringClone; table->keyFree = HashTable_StringFree; table->valueFree = HashTable_StringFree; HashTable_Add(table, key1, val1); HashTable_Add(table, key2, val2); HashTable_Add(table, key3, val3); count = HashTable_Count(table); if (count != 3) { printf("HashTable_Count: Expected : %d, Actual: %d\n", 3, count); return -1; } HashTable_Remove(table, key2); count = HashTable_Count(table); if (count != 2) { printf("HashTable_Count: Expected : %d, Actual: %d\n", 2, count); return -1; } HashTable_Remove(table, key3); count = HashTable_Count(table); if (count != 1) { printf("HashTable_Count: Expected : %d, Actual: %d\n", 1, count); return -1; } HashTable_Remove(table, key1); count = HashTable_Count(table); if (count != 0) { printf("HashTable_Count: Expected : %d, Actual: %d\n", 0, count); return -1; } HashTable_Add(table, key1, val1); HashTable_Add(table, key2, val2); HashTable_Add(table, key3, val3); count = HashTable_Count(table); if (count != 3) { printf("HashTable_Count: Expected : %d, Actual: %d\n", 3, count); return -1; } value = (char*) HashTable_GetItemValue(table, key1); if (strcmp(value, val1) != 0) { printf("HashTable_GetItemValue: Expected : %s, Actual: %s\n", val1, value); return -1; } value = (char*) HashTable_GetItemValue(table, key2); if (strcmp(value, val2) != 0) { printf("HashTable_GetItemValue: Expected : %s, Actual: %s\n", val2, value); return -1; } value = (char*) HashTable_GetItemValue(table, key3); if (strcmp(value, val3) != 0) { printf("HashTable_GetItemValue: Expected : %s, Actual: %s\n", val3, value); return -1; } HashTable_SetItemValue(table, key2, "apple"); value = (char*) HashTable_GetItemValue(table, key2); if (strcmp(value, "apple") != 0) { printf("HashTable_GetItemValue: Expected : %s, Actual: %s\n", "apple", value); return -1; } if (!HashTable_Contains(table, key2)) { printf("HashTable_Contains: Expected : %d, Actual: %d\n", TRUE, FALSE); return -1; } if (!HashTable_Remove(table, key2)) { printf("HashTable_Remove: Expected : %d, Actual: %d\n", TRUE, FALSE); return -1; } if (HashTable_Remove(table, key2)) { printf("HashTable_Remove: Expected : %d, Actual: %d\n", FALSE, TRUE); return -1; } HashTable_Clear(table); count = HashTable_Count(table); if (count != 0) { printf("HashTable_Count: Expected : %d, Actual: %d\n", 0, count); return -1; } HashTable_Free(table); return 1; }