Merge remote-tracking branch 'upstream/master' into rail

This commit is contained in:
roman-b 2011-08-22 19:14:11 +03:00
commit 8ae5b05c86
40 changed files with 1124 additions and 364 deletions

View File

@ -265,7 +265,8 @@ int dfreerdp_run(freerdp* instance)
memset(rfds, 0, sizeof(rfds));
memset(wfds, 0, sizeof(wfds));
instance->Connect(instance);
if (!instance->Connect(instance))
return 0;
dfi = GET_DFI(instance);
chanman = GET_CHANMAN(instance);

View File

@ -20,6 +20,8 @@
#include <freerdp/kbd/kbd.h>
#include <freerdp/kbd/vkcodes.h>
#include "xf_rail.h"
#include "xf_event.h"
uint8 X11_EVENT_STRINGS[][20] =
@ -418,6 +420,24 @@ boolean xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, boolean app)
return True;
}
boolean xf_event_MapNotify(xfInfo* xfi, XEvent* event, boolean app)
{
rdpWindow* window;
if (app != True)
return True;
window = window_list_get_by_extra_id(xfi->rail->list, (void*) event->xany.window);
if (window != NULL)
{
/* local restore event */
xf_rail_send_client_system_command(xfi, window->windowId, SC_RESTORE);
}
return True;
}
boolean xf_event_process(freerdp* instance, XEvent* event)
{
boolean app = False;
@ -434,7 +454,7 @@ boolean xf_event_process(freerdp* instance, XEvent* event)
app = True;
}
#if 0
#if 1
if (event->type != MotionNotify)
printf("X11 %s Event\n", X11_EVENT_STRINGS[event->type]);
#endif
@ -496,6 +516,7 @@ boolean xf_event_process(freerdp* instance, XEvent* event)
break;
case MapNotify:
status = xf_event_MapNotify(xfi, event, app);
break;
case ReparentNotify:

View File

@ -22,7 +22,6 @@
#include <freerdp/utils/rail.h>
#include <freerdp/rail/rail.h>
#include "xf_window.h"
#include "xf_rail.h"
@ -82,7 +81,10 @@ void xf_rail_CreateWindow(rdpRail* rail, rdpWindow* window)
xfw = xf_CreateWindow((xfInfo*) rail->extra,
window->windowOffsetX + xfi->workArea.x,
window->windowOffsetY + xfi->workArea.y,
window->windowWidth, window->windowHeight, window->title);
window->windowWidth, window->windowHeight,
window->windowId);
XStoreName(xfi->display, xfw->handle, window->title);
window->extra = (void*) xfw;
window->extraId = (void*) xfw->handle;
@ -102,6 +104,17 @@ void xf_rail_MoveWindow(rdpRail* rail, rdpWindow* window)
window->windowWidth, window->windowHeight);
}
void xf_rail_ShowWindow(rdpRail* rail, rdpWindow* window, uint8 state)
{
xfInfo* xfi;
xfWindow* xfw;
xfi = (xfInfo*) rail->extra;
xfw = (xfWindow*) window->extra;
xf_ShowWindow((xfInfo*) rail->extra, xfw, state);
}
void xf_rail_SetWindowText(rdpRail* rail, rdpWindow* window)
{
xfInfo* xfi;
@ -113,6 +126,20 @@ void xf_rail_SetWindowText(rdpRail* rail, rdpWindow* window)
XStoreName(xfi->display, xfw->handle, window->title);
}
void xf_rail_SetWindowIcon(rdpRail* rail, rdpWindow* window, rdpIcon* icon)
{
xfInfo* xfi;
xfWindow* xfw;
xfi = (xfInfo*) rail->extra;
xfw = (xfWindow*) window->extra;
icon->extra = gdi_icon_convert(icon->entry->bitsColor, NULL, icon->entry->bitsMask,
icon->entry->width, icon->entry->height, icon->entry->bpp, rail->clrconv);
xf_SetWindowIcon(xfi, xfw, icon);
}
void xf_rail_DestroyWindow(rdpRail* rail, rdpWindow* window)
{
xfWindow* xfw;
@ -125,7 +152,9 @@ void xf_rail_register_callbacks(xfInfo* xfi, rdpRail* rail)
rail->extra = (void*) xfi;
rail->CreateWindow = xf_rail_CreateWindow;
rail->MoveWindow = xf_rail_MoveWindow;
rail->ShowWindow = xf_rail_ShowWindow;
rail->SetWindowText = xf_rail_SetWindowText;
rail->SetWindowIcon = xf_rail_SetWindowIcon;
rail->DestroyWindow = xf_rail_DestroyWindow;
}
@ -151,6 +180,19 @@ static void xf_send_rail_client_event(rdpChanMan* chanman, uint16 event_type, vo
}
}
void xf_rail_send_client_system_command(xfInfo* xfi, uint32 windowId, uint16 command)
{
rdpChanMan* chanman;
RAIL_SYSCOMMAND_ORDER syscommand;
chanman = GET_CHANMAN(xfi->instance);
syscommand.windowId = windowId;
syscommand.command = command;
xf_send_rail_client_event(chanman, RDP_EVENT_TYPE_RAIL_CLIENT_SYSCOMMAND, &syscommand);
}
void xf_process_rail_get_sysparams_event(xfInfo* xfi, rdpChanMan* chanman, RDP_EVENT* event)
{
RAIL_SYSPARAM_ORDER* sysparam;
@ -205,12 +247,15 @@ void xf_process_rail_server_sysparam_event(xfInfo* xfi, rdpChanMan* chanman, RDP
switch (sysparam->param)
{
case SPI_SET_SCREEN_SAVE_ACTIVE:
printf("xf_process_rail_server_sysparam_event: Server System Param PDU: setScreenSaveActive=%d\n", sysparam->setScreenSaveActive);
break;
case SPI_SET_SCREEN_SAVE_SECURE:
printf("xf_process_rail_server_sysparam_event: Server System Param PDU: setScreenSaveSecure=%d\n", sysparam->setScreenSaveSecure);
break;
case SPI_SET_SCREEN_SAVE_ACTIVE:
printf("xf_process_rail_server_sysparam_event: Server System Param PDU: setScreenSaveActive=%d\n",
sysparam->setScreenSaveActive);
break;
case SPI_SET_SCREEN_SAVE_SECURE:
printf("xf_process_rail_server_sysparam_event: Server System Param PDU: setScreenSaveSecure=%d\n",
sysparam->setScreenSaveSecure);
break;
}
}
@ -221,23 +266,14 @@ void xf_process_rail_server_minmaxinfo_event(xfInfo* xfi, rdpChanMan* chanman, R
printf("Server Min Max Info PDU: windowId=0x%X "
"maxWidth=%d maxHeight=%d maxPosX=%d maxPosY=%d "
"minTrackWidth=%d minTrackHeight=%d maxTrackWidth=%d maxTrackHeight=%d\n",
minmax->windowId,
minmax->maxWidth,
minmax->maxHeight,
minmax->maxPosX,
minmax->maxPosY,
minmax->minTrackWidth,
minmax->minTrackHeight,
minmax->maxTrackWidth,
minmax->maxTrackHeight
);
minmax->windowId, minmax->maxWidth, minmax->maxHeight,
minmax->maxPosX, minmax->maxPosY,
minmax->minTrackWidth, minmax->minTrackHeight,
minmax->maxTrackWidth, minmax->maxTrackHeight);
}
void xf_process_rail_server_localmovesize_event(xfInfo* xfi, rdpChanMan* chanman, RDP_EVENT* event)
const char* movetype_names[] =
{
RAIL_LOCALMOVESIZE_ORDER* movesize = (RAIL_LOCALMOVESIZE_ORDER*)event->user_data;
const char* movetype_names[] =
{
"(invalid)",
"RAIL_WMSZ_LEFT",
"RAIL_WMSZ_RIGHT",
@ -249,17 +285,17 @@ void xf_process_rail_server_localmovesize_event(xfInfo* xfi, rdpChanMan* chanman
"RAIL_WMSZ_BOTTOMRIGHT",
"RAIL_WMSZ_MOVE",
"RAIL_WMSZ_KEYMOVE",
"RAIL_WMSZ_KEYSIZE",
};
"RAIL_WMSZ_KEYSIZE"
};
void xf_process_rail_server_localmovesize_event(xfInfo* xfi, rdpChanMan* chanman, RDP_EVENT* event)
{
RAIL_LOCALMOVESIZE_ORDER* movesize = (RAIL_LOCALMOVESIZE_ORDER*) event->user_data;
printf("Server Local MoveSize PDU: windowId=0x%X "
"isMoveSizeStart=%d moveSizeType=%s PosX=%d PosY=%d\n",
movesize->windowId,
movesize->isMoveSizeStart,
movetype_names[movesize->moveSizeType],
movesize->posX,
movesize->posY
);
movesize->windowId, movesize->isMoveSizeStart,
movetype_names[movesize->moveSizeType], movesize->posX, movesize->posY);
}
void xf_process_rail_appid_resp_event(xfInfo* xfi, rdpChanMan* chanman, RDP_EVENT* event)
@ -269,20 +305,18 @@ void xf_process_rail_appid_resp_event(xfInfo* xfi, rdpChanMan* chanman, RDP_EVEN
printf("Server Application ID Response PDU: windowId=0x%X "
"applicationId=(length=%d dump)\n",
appid_resp->windowId,
appid_resp->applicationId.length
);
appid_resp->windowId, appid_resp->applicationId.length);
freerdp_hexdump(appid_resp->applicationId.string, appid_resp->applicationId.length);
}
void xf_process_rail_langbarinfo_event(xfInfo* xfi, rdpChanMan* chanman, RDP_EVENT* event)
{
RAIL_LANGBAR_INFO_ORDER* langbar =
(RAIL_LANGBAR_INFO_ORDER*)event->user_data;
(RAIL_LANGBAR_INFO_ORDER*) event->user_data;
printf("Language Bar Information PDU: languageBarStatus=0x%X\n",
langbar->languageBarStatus
);
langbar->languageBarStatus);
}
void xf_process_rail_event(xfInfo* xfi, rdpChanMan* chanman, RDP_EVENT* event)

View File

@ -26,6 +26,8 @@ void xf_rail_paint(xfInfo* xfi, rdpRail* rail, uint32 ileft, uint32 itop, uint32
void xf_rail_register_callbacks(xfInfo* xfi, rdpRail* rail);
void xf_rail_send_client_system_command(xfInfo* xfi, uint32 windowId, uint16 command);
void xf_process_rail_event(xfInfo* xfi, rdpChanMan* chanman, RDP_EVENT* event);
#endif /* __XF_RAIL_H */

View File

@ -23,6 +23,10 @@
/* Extended Window Manager Hints: http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html */
#ifndef XA_CARDINAL
#define XA_CARDINAL 6
#endif
#define MWM_HINTS_DECORATIONS (1L << 1)
#define PROP_MOTIF_WM_HINTS_ELEMENTS 5
@ -201,7 +205,9 @@ xfWindow* desktop_create(xfInfo* xfi, char* name)
return window;
}
xfWindow* xf_CreateWindow(xfInfo* xfi, int x, int y, int width, int height, char* name)
char rail_window_class[] = "RAIL:00000000";
xfWindow* xf_CreateWindow(xfInfo* xfi, int x, int y, int width, int height, uint32 id)
{
xfWindow* window;
@ -231,10 +237,14 @@ xfWindow* xf_CreateWindow(xfInfo* xfi, int x, int y, int width, int height, char
if (class_hints != NULL)
{
class_hints->res_name = "rail";
class_hints->res_class = "freerdp";
char* class;
class = xmalloc(sizeof(rail_window_class));
snprintf(class, sizeof(rail_window_class), "RAIL:%08X", id);
class_hints->res_name = "RAIL";
class_hints->res_class = class;
XSetClassHint(xfi->display, window->handle, class_hints);
XFree(class_hints);
xfree(class);
}
size_hints = XAllocSizeHints();
@ -260,8 +270,6 @@ xfWindow* xf_CreateWindow(xfInfo* xfi, int x, int y, int width, int height, char
window->gc = XCreateGC(xfi->display, window->handle, GCGraphicsExposures, &gcv);
window->surface = XCreatePixmap(xfi->display, window->handle, window->width, window->height, xfi->depth);
XStoreName(xfi->display, window->handle, name);
xf_MoveWindow(xfi, window, x, y, width, height);
}
@ -305,11 +313,88 @@ void xf_MoveWindow(xfInfo* xfi, xfWindow* window, int x, int y, int width, int h
window->height = height;
}
void xf_ShowWindow(xfInfo* xfi, xfWindow* window, uint8 state)
{
//printf("xf_ShowWindow:%d\n", state);
switch (state)
{
case WINDOW_HIDE:
//XIconifyWindow(xfi->display, window->handle, xfi->screen_number);
break;
case WINDOW_SHOW_MINIMIZED:
XIconifyWindow(xfi->display, window->handle, xfi->screen_number);
break;
case WINDOW_SHOW_MAXIMIZED:
XRaiseWindow(xfi->display, window->handle);
break;
case WINDOW_SHOW:
XRaiseWindow(xfi->display, window->handle);
break;
}
XFlush(xfi->display);
}
void xf_SetWindowIcon(xfInfo* xfi, xfWindow* window, rdpIcon* icon)
{
Atom atom;
int x, y;
int pixels;
int propsize;
long* propdata;
long* dstp;
uint32* srcp;
if (icon->big != True)
return;
pixels = icon->entry->width * icon->entry->height;
propsize = 2 + pixels;
propdata = xmalloc(propsize * sizeof(long));
propdata[0] = icon->entry->width;
propdata[1] = icon->entry->height;
dstp = &(propdata[2]);
srcp = (uint32*) icon->extra;
for (y = 0; y < icon->entry->height; y++)
{
for (x = 0; x < icon->entry->width; x++)
{
*dstp++ = *srcp++;
}
}
atom = XInternAtom(xfi->display, "_NET_WM_ICON", False);
if (!atom)
{
printf("xf_SetWindowIcon: failed to obtain atom _NET_WM_ICON\n");
return;
}
else
{
XChangeProperty(xfi->display, window->handle, atom, XA_CARDINAL, 32,
PropModeReplace, (uint8*) propdata, propsize);
XFlush(xfi->display);
}
}
void xf_DestroyWindow(xfInfo* xfi, xfWindow* window)
{
XFreeGC(xfi->display, window->gc);
XFreePixmap(xfi->display, window->surface);
XUnmapWindow(xfi->display, window->handle);
XDestroyWindow(xfi->display, window->handle);
if (window->gc)
XFreeGC(xfi->display, window->gc);
if (window->surface)
XFreePixmap(xfi->display, window->surface);
if (window->handle)
{
XUnmapWindow(xfi->display, window->handle);
XDestroyWindow(xfi->display, window->handle);
}
xfree(window);
}

View File

@ -49,8 +49,10 @@ void window_show_decorations(xfInfo* xfi, xfWindow* window, boolean show);
xfWindow* desktop_create(xfInfo* xfi, char* name);
xfWindow* xf_CreateWindow(xfInfo* xfi, int x, int y, int width, int height, char* name);
xfWindow* xf_CreateWindow(xfInfo* xfi, int x, int y, int width, int height, uint32 id);
void xf_MoveWindow(xfInfo* xfi, xfWindow* window, int x, int y, int width, int height);
void xf_ShowWindow(xfInfo* xfi, xfWindow* window, uint8 state);
void xf_SetWindowIcon(xfInfo* xfi, xfWindow* window, rdpIcon* icon);
void xf_DestroyWindow(xfInfo* xfi, xfWindow* window);
#endif /* __XF_WINDOW_H */

View File

@ -376,7 +376,7 @@ boolean xf_post_connect(freerdp* instance)
instance->update->BeginPaint = xf_begin_paint;
instance->update->EndPaint = xf_end_paint;
xfi->rail = rail_new();
xfi->rail = rail_new(instance->settings);
instance->update->rail = (void*) xfi->rail;
rail_register_update_callbacks(xfi->rail, instance->update);
xf_rail_register_callbacks(xfi, xfi->rail);
@ -489,7 +489,8 @@ int xfreerdp_run(freerdp* instance)
memset(rfds, 0, sizeof(rfds));
memset(wfds, 0, sizeof(wfds));
instance->Connect(instance);
if (!instance->Connect(instance))
return 0;
xfi = GET_XFI(instance);
chanman = GET_CHANMAN(instance);

View File

@ -239,6 +239,8 @@ typedef uint8* (*p_gdi_image_convert)(uint8* srcData, uint8* dstData, int width,
FREERDP_API uint32 gdi_color_convert(uint32 srcColor, int srcBpp, int dstBpp, HCLRCONV clrconv);
FREERDP_API uint8* gdi_image_convert(uint8* srcData, uint8 *dstData, int width, int height, int srcBpp, int dstBpp, HCLRCONV clrconv);
FREERDP_API uint8* gdi_glyph_convert(int width, int height, uint8* data);
FREERDP_API uint8* gdi_image_invert(uint8* srcData, uint8* dstData, int width, int height, int bpp);
FREERDP_API uint8* gdi_icon_convert(uint8* srcData, uint8* dstData, uint8* mask, int width, int height, int bpp, HCLRCONV clrconv);
FREERDP_API uint8* gdi_mono_image_convert(uint8* srcData, int width, int height, int srcBpp, int dstBpp, uint32 bgcolor, uint32 fgcolor, HCLRCONV clrconv);
#ifdef __cplusplus

View File

@ -0,0 +1,61 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Window Icon Cache
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __RAIL_ICON_CACHE_H
#define __RAIL_ICON_CACHE_H
#include <freerdp/api.h>
#include <freerdp/rail.h>
#include <freerdp/types.h>
#include <freerdp/update.h>
#include <freerdp/utils/stream.h>
typedef struct rdp_icon rdpIcon;
typedef struct rdp_icon_cache rdpIconCache;
#include <freerdp/rail/rail.h>
struct rdp_icon
{
ICON_INFO* entry;
boolean big;
void* extra;
};
struct _WINDOW_ICON_CACHE
{
rdpIcon* entries;
};
typedef struct _WINDOW_ICON_CACHE WINDOW_ICON_CACHE;
struct rdp_icon_cache
{
rdpRail* rail;
uint8 numCaches;
uint16 numCacheEntries;
WINDOW_ICON_CACHE* caches;
};
ICON_INFO* icon_cache_get(rdpIconCache* cache, uint8 id, uint16 index, void** extra);
void icon_cache_put(rdpIconCache* cache, uint8 id, uint16 index, ICON_INFO* entry, void* extra);
rdpIconCache* icon_cache_new(rdpRail* rail);
void icon_cache_free(rdpIconCache* cache);
#endif /* __RAIL_ICON_H */

View File

@ -24,32 +24,41 @@
#include <freerdp/rail.h>
#include <freerdp/types.h>
#include <freerdp/update.h>
#include <freerdp/gdi/color.h>
#include <freerdp/utils/stream.h>
typedef struct rdp_rail rdpRail;
#include <freerdp/rail/icon.h>
#include <freerdp/rail/window.h>
#include <freerdp/rail/window_list.h>
typedef void (*railCreateWindow)(rdpRail* rail, rdpWindow* window);
typedef void (*railDestroyWindow)(rdpRail* rail, rdpWindow* window);
typedef void (*railMoveWindow)(rdpRail* rail, rdpWindow* window);
typedef void (*railShowWindow)(rdpRail* rail, rdpWindow* window, uint8 state);
typedef void (*railSetWindowText)(rdpRail* rail, rdpWindow* window);
typedef void (*railSetWindowIcon)(rdpRail* rail, rdpWindow* window, rdpIcon* icon);
struct rdp_rail
{
void* extra;
UNICONV* uniconv;
CLRCONV* clrconv;
rdpIconCache* cache;
rdpWindowList* list;
rdpSettings* settings;
railCreateWindow CreateWindow;
railDestroyWindow DestroyWindow;
railMoveWindow MoveWindow;
railShowWindow ShowWindow;
railSetWindowText SetWindowText;
railSetWindowIcon SetWindowIcon;
};
FREERDP_API void rail_register_update_callbacks(rdpRail* rail, rdpUpdate* update);
FREERDP_API rdpRail* rail_new();
FREERDP_API rdpRail* rail_new(rdpSettings* settings);
FREERDP_API void rail_free(rdpRail* rail);
#endif /* __RAIL_H */

View File

@ -17,8 +17,8 @@
* limitations under the License.
*/
#ifndef __WINDOW_H
#define __WINDOW_H
#ifndef __RAIL_WINDOW_H
#define __RAIL_WINDOW_H
#include <freerdp/api.h>
#include <freerdp/rail.h>
@ -29,12 +29,15 @@
typedef struct rdp_window rdpWindow;
#include <freerdp/rail/rail.h>
#include <freerdp/rail/icon.h>
struct rdp_window
{
void* extra;
void* extraId;
char* title;
rdpIcon* bigIcon;
rdpIcon* smallIcon;
uint32 fieldFlags;
rdpWindow* prev;
rdpWindow* next;
@ -70,4 +73,4 @@ FREERDP_API void rail_CreateWindow(rdpRail* rail, rdpWindow* window);
FREERDP_API void rail_UpdateWindow(rdpRail* rail, rdpWindow* window);
FREERDP_API void rail_DestroyWindow(rdpRail* rail, rdpWindow* window);
#endif /* __WINDOW_H */
#endif /* __RAIL_WINDOW_H */

View File

@ -17,8 +17,8 @@
* limitations under the License.
*/
#ifndef __WINDOW_LIST_H
#define __WINDOW_LIST_H
#ifndef __RAIL_WINDOW_LIST_H
#define __RAIL_WINDOW_LIST_H
#include <freerdp/api.h>
#include <freerdp/types.h>
@ -42,7 +42,8 @@ FREERDP_API void window_list_rewind(rdpWindowList* list);
FREERDP_API boolean window_list_has_next(rdpWindowList* list);
FREERDP_API rdpWindow* window_list_get_next(rdpWindowList* list);
rdpWindow* window_list_get_by_extra_id(rdpWindowList* list, void* extraId);
FREERDP_API rdpWindow* window_list_get_by_id(rdpWindowList* list, uint32 windowId);
FREERDP_API rdpWindow* window_list_get_by_extra_id(rdpWindowList* list, void* extraId);
FREERDP_API void window_list_create(rdpWindowList* list, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* window_state);
FREERDP_API void window_list_update(rdpWindowList* list, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* window_state);
@ -51,4 +52,4 @@ FREERDP_API void window_list_delete(rdpWindowList* list, WINDOW_ORDER_INFO* orde
FREERDP_API rdpWindowList* window_list_new(rdpRail* rail);
FREERDP_API void window_list_free(rdpWindowList* list);
#endif /* __WINDOW_LIST_H */
#endif /* __RAIL_WINDOW_LIST_H */

View File

@ -748,7 +748,7 @@ typedef struct _WINDOW_STATE_ORDER WINDOW_STATE_ORDER;
struct _WINDOW_ICON_ORDER
{
ICON_INFO iconInfo;
ICON_INFO* iconInfo;
};
typedef struct _WINDOW_ICON_ORDER WINDOW_ICON_ORDER;
@ -867,6 +867,70 @@ typedef struct _SURFACE_BITS_COMMAND SURFACE_BITS_COMMAND;
#define WINDOW_ORDER_FIELD_DESKTOP_ZORDER 0x00000010
#define WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND 0x00000020
/* Window Show States */
#define WINDOW_HIDE 0x00
#define WINDOW_SHOW_MINIMIZED 0x02
#define WINDOW_SHOW_MAXIMIZED 0x03
#define WINDOW_SHOW 0x05
/* Window Styles */
#ifndef _WIN32
#define WS_BORDER 0x00800000
#define WS_CAPTION 0x00C00000
#define WS_CHILD 0x40000000
#define WS_CLIPCHILDREN 0x02000000
#define WS_CLIPSIBLINGS 0x04000000
#define WS_DISABLED 0x08000000
#define WS_DLGFRAME 0x00400000
#define WS_GROUP 0x00020000
#define WS_HSCROLL 0x00100000
#define WS_ICONIC 0x20000000
#define WS_MAXIMIZE 0x01000000
#define WS_MAXIMIZEBOX 0x00010000
#define WS_MINIMIZE 0x20000000
#define WS_MINIMIZEBOX 0x00020000
#define WS_OVERLAPPED 0x00000000
#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
#define WS_POPUP 0x80000000
#define WS_POPUPWINDOW (WS_POPUP | WS_BORDER | WS_SYSMENU)
#define WS_SIZEBOX 0x00040000
#define WS_SYSMENU 0x00080000
#define WS_TABSTOP 0x00010000
#define WS_THICKFRAME 0x00040000
#define WS_VISIBLE 0x10000000
#define WS_VSCROLL 0x00200000
#endif
/* Extended Window Styles */
#ifndef _WIN32
#define WS_EX_ACCEPTFILES 0x00000010
#define WS_EX_APPWINDOW 0x00040000
#define WS_EX_CLIENTEDGE 0x00000200
#define WS_EX_COMPOSITED 0x02000000
#define WS_EX_CONTEXTHELP 0x00000400
#define WS_EX_CONTROLPARENT 0x00010000
#define WS_EX_DLGMODALFRAME 0x00000001
#define WS_EX_LAYERED 0x00080000
#define WS_EX_LAYOUTRTL 0x00400000
#define WS_EX_LEFT 0x00000000
#define WS_EX_LEFTSCROLLBAR 0x00004000
#define WS_EX_LTRREADING 0x00000000
#define WS_EX_MDICHILD 0x00000040
#define WS_EX_NOACTIVATE 0x08000000
#define WS_EX_NOINHERITLAYOUT 0x00100000
#define WS_EX_NOPARENTNOTIFY 0x00000004
#define WS_EX_OVERLAPPEDWINDOW (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE)
#define WS_EX_PALETTEWINDOW (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST)
#define WS_EX_RIGHT 0x00001000
#define WS_EX_RIGHTSCROLLBAR 0x00000000
#define WS_EX_RTLREADING 0x00002000
#define WS_EX_STATICEDGE 0x00020000
#define WS_EX_TOOLWINDOW 0x00000080
#define WS_EX_TOPMOST 0x00000008
#define WS_EX_TRANSPARENT 0x00000020
#define WS_EX_WINDOWEDGE 0x00000100
#endif
/* Update Interface */
typedef struct rdp_update rdpUpdate;

View File

@ -28,27 +28,15 @@ uint8 CTRLACTION_STRINGS[][32] =
"CTRLACTION_COOPERATE"
};
boolean rdp_client_activate(rdpRdp* rdp)
{
while (rdp->activated != True)
{
rdp_recv(rdp);
}
printf("client is activated\n");
return True;
}
void rdp_write_synchronize_pdu(STREAM* s, rdpSettings* settings)
{
stream_write_uint16(s, SYNCMSGTYPE_SYNC); /* messageType (2 bytes) */
stream_write_uint16(s, settings->pdu_source); /* targetUser (2 bytes) */
}
void rdp_recv_server_synchronize_pdu(rdpRdp* rdp, STREAM* s, rdpSettings* settings)
boolean rdp_read_server_synchronize_pdu(rdpRdp* rdp, STREAM* s)
{
rdp_send_client_control_pdu(rdp, CTRLACTION_COOPERATE);
return True;
}
boolean rdp_send_server_synchronize_pdu(rdpRdp* rdp)
@ -87,9 +75,7 @@ boolean rdp_send_client_synchronize_pdu(rdpRdp* rdp)
rdp_write_synchronize_pdu(s, rdp->settings);
rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_SYNCHRONIZE, rdp->mcs->user_id);
return True;
return rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_SYNCHRONIZE, rdp->mcs->user_id);
}
boolean rdp_read_control_pdu(STREAM* s, uint16* action)
@ -111,29 +97,13 @@ void rdp_write_client_control_pdu(STREAM* s, uint16 action)
stream_write_uint32(s, 0); /* controlId (4 bytes) */
}
void rdp_recv_server_control_pdu(rdpRdp* rdp, STREAM* s, rdpSettings* settings)
boolean rdp_read_server_control_pdu(rdpRdp* rdp, STREAM* s)
{
uint16 action;
rdp_read_control_pdu(s, &action);
if (action == CTRLACTION_COOPERATE)
{
rdp_send_client_control_pdu(rdp, CTRLACTION_REQUEST_CONTROL);
}
else if (action == CTRLACTION_GRANTED_CONTROL)
{
if (rdp->settings->rdp_version >= 5)
{
//rdp_send_client_persistent_key_list_pdu(rdp);
rdp_send_client_font_list_pdu(rdp, FONTLIST_FIRST | FONTLIST_LAST);
}
else
{
rdp_send_client_font_list_pdu(rdp, FONTLIST_FIRST);
rdp_send_client_font_list_pdu(rdp, FONTLIST_LAST);
}
}
return True;
}
boolean rdp_send_server_control_cooperate_pdu(rdpRdp* rdp)
@ -166,7 +136,7 @@ boolean rdp_send_server_control_granted_pdu(rdpRdp* rdp)
return True;
}
void rdp_send_client_control_pdu(rdpRdp* rdp, uint16 action)
boolean rdp_send_client_control_pdu(rdpRdp* rdp, uint16 action)
{
STREAM* s;
@ -174,7 +144,7 @@ void rdp_send_client_control_pdu(rdpRdp* rdp, uint16 action)
rdp_write_client_control_pdu(s, action);
rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_CONTROL, rdp->mcs->user_id);
return rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_CONTROL, rdp->mcs->user_id);
}
void rdp_write_persistent_list_entry(STREAM* s, uint32 key1, uint32 key2)
@ -202,7 +172,7 @@ void rdp_write_client_persistent_key_list_pdu(STREAM* s, rdpSettings* settings)
/* entries */
}
void rdp_send_client_persistent_key_list_pdu(rdpRdp* rdp)
boolean rdp_send_client_persistent_key_list_pdu(rdpRdp* rdp)
{
STREAM* s;
@ -210,7 +180,7 @@ void rdp_send_client_persistent_key_list_pdu(rdpRdp* rdp)
rdp_write_client_persistent_key_list_pdu(s, rdp->settings);
rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_BITMAP_CACHE_PERSISTENT_LIST, rdp->mcs->user_id);
return rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_BITMAP_CACHE_PERSISTENT_LIST, rdp->mcs->user_id);
}
boolean rdp_read_client_font_list_pdu(STREAM* s)
@ -229,7 +199,7 @@ void rdp_write_client_font_list_pdu(STREAM* s, uint16 flags)
stream_write_uint16(s, 50); /* entrySize (2 bytes) */
}
void rdp_send_client_font_list_pdu(rdpRdp* rdp, uint16 flags)
boolean rdp_send_client_font_list_pdu(rdpRdp* rdp, uint16 flags)
{
STREAM* s;
@ -237,15 +207,12 @@ void rdp_send_client_font_list_pdu(rdpRdp* rdp, uint16 flags)
rdp_write_client_font_list_pdu(s, flags);
rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_FONT_LIST, rdp->mcs->user_id);
return rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_FONT_LIST, rdp->mcs->user_id);
}
void rdp_recv_server_font_map_pdu(rdpRdp* rdp, STREAM* s, rdpSettings* settings)
boolean rdp_read_server_font_map_pdu(rdpRdp* rdp, STREAM* s)
{
rdp->activated = True;
update_reset_state(rdp->update);
rdp->update->switch_surface.bitmapId = SCREEN_BITMAP_SURFACE;
IFCALL(rdp->update->SwitchSurface, rdp->update, &(rdp->update->switch_surface));
return True;
}
boolean rdp_send_server_font_map_pdu(rdpRdp* rdp)
@ -264,7 +231,7 @@ boolean rdp_send_server_font_map_pdu(rdpRdp* rdp)
return True;
}
void rdp_recv_deactivate_all(rdpRdp* rdp, STREAM* s)
boolean rdp_read_deactivate_all(rdpRdp* rdp, STREAM* s)
{
uint16 lengthSourceDescriptor;
@ -274,7 +241,9 @@ void rdp_recv_deactivate_all(rdpRdp* rdp, STREAM* s)
stream_read_uint16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */
stream_seek(s, lengthSourceDescriptor); /* sourceDescriptor (should be 0x00) */
rdp->activated = False;
rdp->state = CONNECTION_STATE_CAPABILITY;
return True;
}
boolean rdp_server_accept_client_control_pdu(rdpRdp* rdp, STREAM* s)

View File

@ -38,22 +38,21 @@
#define FONTLIST_FIRST 0x0001
#define FONTLIST_LAST 0x0002
boolean rdp_client_activate(rdpRdp* rdp);
void rdp_recv_deactivate_all(rdpRdp* rdp, STREAM* s);
boolean rdp_read_deactivate_all(rdpRdp* rdp, STREAM* s);
void rdp_recv_server_synchronize_pdu(rdpRdp* rdp, STREAM* s, rdpSettings* settings);
boolean rdp_read_server_synchronize_pdu(rdpRdp* rdp, STREAM* s);
boolean rdp_send_server_synchronize_pdu(rdpRdp* rdp);
boolean rdp_read_client_synchronize_pdu(STREAM* s);
boolean rdp_send_client_synchronize_pdu(rdpRdp* rdp);
boolean rdp_read_control_pdu(STREAM* s, uint16* action);
void rdp_recv_server_control_pdu(rdpRdp* rdp, STREAM* s, rdpSettings* settings);
boolean rdp_read_server_control_pdu(rdpRdp* rdp, STREAM* s);
boolean rdp_send_server_control_cooperate_pdu(rdpRdp* rdp);
boolean rdp_send_server_control_granted_pdu(rdpRdp* rdp);
void rdp_send_client_control_pdu(rdpRdp* rdp, uint16 action);
void rdp_send_client_persistent_key_list_pdu(rdpRdp* rdp);
boolean rdp_send_client_control_pdu(rdpRdp* rdp, uint16 action);
boolean rdp_send_client_persistent_key_list_pdu(rdpRdp* rdp);
boolean rdp_read_client_font_list_pdu(STREAM* s);
void rdp_send_client_font_list_pdu(rdpRdp* rdp, uint16 flags);
void rdp_recv_server_font_map_pdu(rdpRdp* rdp, STREAM* s, rdpSettings* settings);
boolean rdp_send_client_font_list_pdu(rdpRdp* rdp, uint16 flags);
boolean rdp_read_server_font_map_pdu(rdpRdp* rdp, STREAM* s);
boolean rdp_send_server_font_map_pdu(rdpRdp* rdp);
boolean rdp_server_accept_client_control_pdu(rdpRdp* rdp, STREAM* s);

View File

@ -1576,15 +1576,29 @@ boolean rdp_read_capability_sets(STREAM* s, rdpSettings* settings, uint16 number
return True;
}
void rdp_read_demand_active(STREAM* s, rdpSettings* settings)
boolean rdp_read_demand_active(rdpRdp* rdp, STREAM* s)
{
uint16 length;
uint16 channelId;
uint16 pduType;
uint16 pduLength;
uint16 numberCapabilities;
uint16 lengthSourceDescriptor;
uint16 lengthCombinedCapabilities;
if (!rdp_read_header(rdp, s, &length, &channelId))
return False;
if (channelId != MCS_GLOBAL_CHANNEL_ID)
return False;
if (!rdp_read_share_control_header(s, &pduLength, &pduType, &rdp->settings->pdu_source))
return False;
if (pduType != PDU_TYPE_DEMAND_ACTIVE)
return False;
//printf("Demand Active PDU\n");
stream_read_uint32(s, settings->share_id); /* shareId (4 bytes) */
stream_read_uint32(s, rdp->settings->share_id); /* shareId (4 bytes) */
stream_read_uint16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */
stream_read_uint16(s, lengthCombinedCapabilities); /* lengthCombinedCapabilities (2 bytes) */
stream_seek(s, lengthSourceDescriptor); /* sourceDescriptor */
@ -1592,18 +1606,12 @@ void rdp_read_demand_active(STREAM* s, rdpSettings* settings)
stream_seek(s, 2); /* pad2Octets (2 bytes) */
/* capabilitySets */
rdp_read_capability_sets(s, settings, numberCapabilities);
}
if (!rdp_read_capability_sets(s, rdp->settings, numberCapabilities))
return False;
void rdp_recv_demand_active(rdpRdp* rdp, STREAM* s, rdpSettings* settings)
{
rdp_read_demand_active(s, settings);
rdp->update->glyph_v2 = (rdp->settings->glyphSupportLevel > GLYPH_SUPPORT_FULL) ? True : False;
rdp->update->glyph_v2 = (settings->glyphSupportLevel > GLYPH_SUPPORT_FULL) ? True : False;
rdp_send_confirm_active(rdp);
rdp_send_client_synchronize_pdu(rdp);
return True;
}
void rdp_write_demand_active(STREAM* s, rdpSettings* settings)
@ -1803,7 +1811,7 @@ void rdp_write_confirm_active(STREAM* s, rdpSettings* settings)
stream_set_mark(s, em);
}
void rdp_send_confirm_active(rdpRdp* rdp)
boolean rdp_send_confirm_active(rdpRdp* rdp)
{
STREAM* s;
@ -1811,6 +1819,6 @@ void rdp_send_confirm_active(rdpRdp* rdp)
rdp_write_confirm_active(s, rdp->settings);
rdp_send_pdu(rdp, s, PDU_TYPE_CONFIRM_ACTIVE, rdp->mcs->user_id);
return rdp_send_pdu(rdp, s, PDU_TYPE_CONFIRM_ACTIVE, rdp->mcs->user_id);
}

View File

@ -163,12 +163,11 @@
#define CLW_ENTROPY_RLGR1 0x01
#define CLW_ENTROPY_RLGR3 0x04
void rdp_read_demand_active(STREAM* s, rdpSettings* settings);
void rdp_recv_demand_active(rdpRdp* rdp, STREAM* s, rdpSettings* settings);
boolean rdp_read_demand_active(rdpRdp* rdp, STREAM* s);
void rdp_write_demand_active(STREAM* s, rdpSettings* settings);
boolean rdp_send_demand_active(rdpRdp* rdp);
boolean rdp_read_confirm_active(rdpRdp* rdp, STREAM* s);
void rdp_write_confirm_active(STREAM* s, rdpSettings* settings);
void rdp_send_confirm_active(rdpRdp* rdp);
boolean rdp_send_confirm_active(rdpRdp* rdp);
#endif /* __CAPABILITIES_H */

View File

@ -86,24 +86,168 @@ boolean rdp_client_connect(rdpRdp* rdp)
if (!ret)
return False;
if (mcs_connect(rdp->mcs) != True)
{
printf("Error: Multipoint Connection Service (MCS) connection failure\n");
return False;
}
rdp_send_client_info(rdp);
if (license_connect(rdp->license) != True)
{
printf("Error: license connection sequence failure\n");
return False;
}
rdp->licensed = True;
rdp_client_activate(rdp);
rdp_set_blocking_mode(rdp, False);
rdp->state = CONNECTION_STATE_NEGO;
if (!mcs_send_connect_initial(rdp->mcs))
{
printf("Error: unable to send MCS Connect Initial\n");
return False;
}
while (rdp->state != CONNECTION_STATE_ACTIVE)
{
if (rdp_check_fds(rdp) < 0)
return False;
}
return True;
}
boolean rdp_client_connect_mcs_connect_response(rdpRdp* rdp, STREAM* s)
{
if (!mcs_read_connect_response(rdp->mcs, s))
return False;
if (!mcs_send_erect_domain_request(rdp->mcs))
return False;
if (!mcs_send_attach_user_request(rdp->mcs))
return False;
rdp->state = CONNECTION_STATE_MCS_ATTACH_USER;
return True;
}
boolean rdp_client_connect_mcs_attach_user_confirm(rdpRdp* rdp, STREAM* s)
{
if (!mcs_read_attach_user_confirm(rdp->mcs, s))
return False;
if (!mcs_send_channel_join_request(rdp->mcs, rdp->mcs->user_id))
return False;
rdp->state = CONNECTION_STATE_MCS_CHANNEL_JOIN;
return True;
}
boolean rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, STREAM* s)
{
int i;
uint16 channel_id;
boolean all_joined = True;
if (!mcs_read_channel_join_confirm(rdp->mcs, s, &channel_id))
return False;
if (!rdp->mcs->user_channel_joined)
{
if (channel_id != rdp->mcs->user_id)
return False;
rdp->mcs->user_channel_joined = True;
if (!mcs_send_channel_join_request(rdp->mcs, MCS_GLOBAL_CHANNEL_ID))
return False;
}
else if (!rdp->mcs->global_channel_joined)
{
if (channel_id != MCS_GLOBAL_CHANNEL_ID)
return False;
rdp->mcs->global_channel_joined = True;
if (rdp->settings->num_channels > 0)
{
if (!mcs_send_channel_join_request(rdp->mcs, rdp->settings->channels[0].chan_id))
return False;
all_joined = False;
}
}
else
{
for (i = 0; i < rdp->settings->num_channels; i++)
{
if (rdp->settings->channels[i].joined)
continue;
if (rdp->settings->channels[i].chan_id != channel_id)
return False;
rdp->settings->channels[i].joined = True;
break;
}
if (i + 1 < rdp->settings->num_channels)
{
if (!mcs_send_channel_join_request(rdp->mcs, rdp->settings->channels[i + 1].chan_id))
return False;
all_joined = False;
}
}
if (rdp->mcs->user_channel_joined && rdp->mcs->global_channel_joined && all_joined)
{
if (!rdp_send_client_info(rdp))
return False;
rdp->state = CONNECTION_STATE_LICENSE;
}
return True;
}
boolean rdp_client_connect_license(rdpRdp* rdp, STREAM* s)
{
if (!license_read(rdp->license, s))
return False;
if (rdp->license->state == LICENSE_STATE_ABORTED)
{
printf("license connection sequence aborted.\n");
return False;
}
if (rdp->license->state == LICENSE_STATE_COMPLETED)
{
printf("license connection sequence completed.\n");
rdp->state = CONNECTION_STATE_CAPABILITY;
}
return True;
}
boolean rdp_client_connect_demand_active(rdpRdp* rdp, STREAM* s)
{
if (!rdp_read_demand_active(rdp, s))
return False;
if (!rdp_send_confirm_active(rdp))
return False;
/**
* [MS-RDPBCGR] 1.3.1.1 - 8.
* The client-to-server PDUs sent during this phase have no dependencies on any of the server-to-
* client PDUs; they may be sent as a single batch, provided that sequencing is maintained.
*/
if (!rdp_send_client_synchronize_pdu(rdp))
return False;
if (!rdp_send_client_control_pdu(rdp, CTRLACTION_COOPERATE))
return False;
if (!rdp_send_client_control_pdu(rdp, CTRLACTION_REQUEST_CONTROL))
return False;
if (!rdp_send_client_persistent_key_list_pdu(rdp))
return False;
if (!rdp_send_client_font_list_pdu(rdp, FONTLIST_FIRST | FONTLIST_LAST))
return False;
rdp->state = CONNECTION_STATE_ACTIVE;
update_reset_state(rdp->update);
rdp->update->switch_surface.bitmapId = SCREEN_BITMAP_SURFACE;
IFCALL(rdp->update->SwitchSurface, rdp->update, &(rdp->update->switch_surface));
printf("client is activated\n");
return True;
}
@ -114,7 +258,7 @@ boolean rdp_server_accept_nego(rdpRdp* rdp, STREAM* s)
transport_set_blocking_mode(rdp->transport, True);
if (!nego_recv_request(rdp->nego, s))
if (!nego_read_request(rdp->nego, s))
return False;
if (rdp->nego->requested_protocols == PROTOCOL_RDP)
{
@ -240,7 +384,7 @@ boolean rdp_server_accept_mcs_channel_join_request(rdpRdp* rdp, STREAM* s)
}
if (rdp->mcs->user_channel_joined && rdp->mcs->global_channel_joined && all_joined)
rdp->state = CONNECTION_STATE_CHANNEL_JOIN;
rdp->state = CONNECTION_STATE_MCS_CHANNEL_JOIN;
return True;
}

View File

@ -38,12 +38,18 @@ enum CONNECTION_STATE
CONNECTION_STATE_MCS_CONNECT,
CONNECTION_STATE_MCS_ERECT_DOMAIN,
CONNECTION_STATE_MCS_ATTACH_USER,
CONNECTION_STATE_CHANNEL_JOIN,
CONNECTION_STATE_MCS_CHANNEL_JOIN,
CONNECTION_STATE_LICENSE,
CONNECTION_STATE_CAPABILITY,
CONNECTION_STATE_ACTIVE
};
boolean rdp_client_connect(rdpRdp* rdp);
boolean rdp_client_connect_mcs_connect_response(rdpRdp* rdp, STREAM* s);
boolean rdp_client_connect_mcs_attach_user_confirm(rdpRdp* rdp, STREAM* s);
boolean rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, STREAM* s);
boolean rdp_client_connect_license(rdpRdp* rdp, STREAM* s);
boolean rdp_client_connect_demand_active(rdpRdp* rdp, STREAM* s);
boolean rdp_server_accept_nego(rdpRdp* rdp, STREAM* s);
boolean rdp_server_accept_mcs_connect_initial(rdpRdp* rdp, STREAM* s);

View File

@ -35,7 +35,8 @@ boolean freerdp_connect(freerdp* instance)
IFCALL(instance->PreConnect, instance);
status = rdp_client_connect((rdpRdp*) instance->rdp);
IFCALL(instance->PostConnect, instance);
if (status)
IFCALL(instance->PostConnect, instance);
return status;
}

View File

@ -215,7 +215,7 @@ void gcc_write_conference_create_request(STREAM* s, STREAM* user_data)
per_write_octet_string(s, user_data->data, stream_get_length(user_data), 0); /* array of client data blocks */
}
void gcc_read_conference_create_response(STREAM* s, rdpSettings* settings)
boolean gcc_read_conference_create_response(STREAM* s, rdpSettings* settings)
{
uint16 length;
uint32 tag;
@ -254,7 +254,10 @@ void gcc_read_conference_create_response(STREAM* s, rdpSettings* settings)
/* userData (OCTET_STRING) */
per_read_length(s, &length);
gcc_read_server_data_blocks(s, settings, length);
if (!gcc_read_server_data_blocks(s, settings, length))
return False;
return True;
}
void gcc_write_conference_create_response(STREAM* s, STREAM* user_data)
@ -349,7 +352,7 @@ void gcc_write_client_data_blocks(STREAM* s, rdpSettings *settings)
gcc_write_client_monitor_data(s, settings);
}
void gcc_read_server_data_blocks(STREAM* s, rdpSettings *settings, int length)
boolean gcc_read_server_data_blocks(STREAM* s, rdpSettings *settings, int length)
{
uint16 type;
uint16 offset = 0;
@ -357,20 +360,24 @@ void gcc_read_server_data_blocks(STREAM* s, rdpSettings *settings, int length)
while (offset < length)
{
gcc_read_user_data_header(s, &type, &blockLength);
if (!gcc_read_user_data_header(s, &type, &blockLength))
return False;
switch (type)
{
case SC_CORE:
gcc_read_server_core_data(s, settings);
if (!gcc_read_server_core_data(s, settings))
return False;
break;
case SC_SECURITY:
gcc_read_server_security_data(s, settings);
if (!gcc_read_server_security_data(s, settings))
return False;
break;
case SC_NET:
gcc_read_server_network_data(s, settings);
if (!gcc_read_server_network_data(s, settings))
return False;
break;
default:
@ -379,6 +386,8 @@ void gcc_read_server_data_blocks(STREAM* s, rdpSettings *settings, int length)
offset += blockLength;
}
return True;
}
void gcc_write_server_data_blocks(STREAM* s, rdpSettings *settings)
@ -388,10 +397,15 @@ void gcc_write_server_data_blocks(STREAM* s, rdpSettings *settings)
gcc_write_server_security_data(s, settings);
}
void gcc_read_user_data_header(STREAM* s, uint16* type, uint16* length)
boolean gcc_read_user_data_header(STREAM* s, uint16* type, uint16* length)
{
stream_read_uint16(s, *type); /* type */
stream_read_uint16(s, *length); /* length */
if (stream_get_left(s) < *length - 4)
return False;
return True;
}
/**
@ -661,7 +675,7 @@ void gcc_write_client_core_data(STREAM* s, rdpSettings *settings)
stream_write_uint32(s, settings->selected_protocol); /* serverSelectedProtocol */
}
void gcc_read_server_core_data(STREAM* s, rdpSettings *settings)
boolean gcc_read_server_core_data(STREAM* s, rdpSettings *settings)
{
uint32 version;
uint32 clientRequestedProtocols;
@ -673,6 +687,8 @@ void gcc_read_server_core_data(STREAM* s, rdpSettings *settings)
settings->rdp_version = 4;
else if (version == RDP_VERSION_5_PLUS && settings->rdp_version < 5)
settings->rdp_version = 7;
return True;
}
void gcc_write_server_core_data(STREAM* s, rdpSettings *settings)
@ -726,7 +742,7 @@ void gcc_write_client_security_data(STREAM* s, rdpSettings *settings)
}
}
void gcc_read_server_security_data(STREAM* s, rdpSettings *settings)
boolean gcc_read_server_security_data(STREAM* s, rdpSettings *settings)
{
uint32 encryptionMethod;
uint32 encryptionLevel;
@ -735,15 +751,16 @@ void gcc_read_server_security_data(STREAM* s, rdpSettings *settings)
stream_read_uint32(s, encryptionMethod); /* encryptionMethod */
stream_read_uint32(s, encryptionLevel); /* encryptionLevel */
stream_read_uint32(s, serverRandomLen); /* serverRandomLen */
stream_read_uint32(s, serverCertLen); /* serverCertLen */
if (encryptionMethod == 0 && encryptionLevel == 0)
{
/* serverRandom and serverRandom must not be present */
return;
return True;
}
stream_read_uint32(s, serverRandomLen); /* serverRandomLen */
stream_read_uint32(s, serverCertLen); /* serverCertLen */
if (serverRandomLen > 0)
{
/* serverRandom */
@ -759,6 +776,8 @@ void gcc_read_server_security_data(STREAM* s, rdpSettings *settings)
memcpy(settings->server_certificate.data, s->p, serverCertLen);
stream_seek(s, serverCertLen);
}
return True;
}
void gcc_write_server_security_data(STREAM* s, rdpSettings *settings)
@ -834,7 +853,7 @@ void gcc_write_client_network_data(STREAM* s, rdpSettings *settings)
}
}
void gcc_read_server_network_data(STREAM* s, rdpSettings *settings)
boolean gcc_read_server_network_data(STREAM* s, rdpSettings *settings)
{
int i;
uint16 MCSChannelId;
@ -858,6 +877,8 @@ void gcc_read_server_network_data(STREAM* s, rdpSettings *settings)
if (channelCount % 2 == 1)
stream_seek(s, 2); /* padding */
return True;
}
void gcc_write_server_network_data(STREAM* s, rdpSettings *settings)

View File

@ -102,25 +102,25 @@
boolean gcc_read_conference_create_request(STREAM* s, rdpSettings* settings);
void gcc_write_conference_create_request(STREAM* s, STREAM* user_data);
void gcc_read_conference_create_response(STREAM* s, rdpSettings* settings);
boolean gcc_read_conference_create_response(STREAM* s, rdpSettings* settings);
void gcc_write_conference_create_response(STREAM* s, STREAM* user_data);
boolean gcc_read_client_data_blocks(STREAM* s, rdpSettings *settings, int length);
void gcc_write_client_data_blocks(STREAM* s, rdpSettings *settings);
void gcc_read_server_data_blocks(STREAM* s, rdpSettings *settings, int length);
boolean gcc_read_server_data_blocks(STREAM* s, rdpSettings *settings, int length);
void gcc_write_server_data_blocks(STREAM* s, rdpSettings *settings);
void gcc_read_user_data_header(STREAM* s, uint16* type, uint16* length);
boolean gcc_read_user_data_header(STREAM* s, uint16* type, uint16* length);
void gcc_write_user_data_header(STREAM* s, uint16 type, uint16 length);
boolean gcc_read_client_core_data(STREAM* s, rdpSettings *settings, uint16 blockLength);
void gcc_write_client_core_data(STREAM* s, rdpSettings *settings);
void gcc_read_server_core_data(STREAM* s, rdpSettings *settings);
boolean gcc_read_server_core_data(STREAM* s, rdpSettings *settings);
void gcc_write_server_core_data(STREAM* s, rdpSettings *settings);
boolean gcc_read_client_security_data(STREAM* s, rdpSettings *settings, uint16 blockLength);
void gcc_write_client_security_data(STREAM* s, rdpSettings *settings);
void gcc_read_server_security_data(STREAM* s, rdpSettings *settings);
boolean gcc_read_server_security_data(STREAM* s, rdpSettings *settings);
void gcc_write_server_security_data(STREAM* s, rdpSettings *settings);
boolean gcc_read_client_network_data(STREAM* s, rdpSettings *settings, uint16 blockLength);
void gcc_write_client_network_data(STREAM* s, rdpSettings *settings);
void gcc_read_server_network_data(STREAM* s, rdpSettings *settings);
boolean gcc_read_server_network_data(STREAM* s, rdpSettings *settings);
void gcc_write_server_network_data(STREAM* s, rdpSettings *settings);
boolean gcc_read_client_cluster_data(STREAM* s, rdpSettings *settings, uint16 blockLength);
void gcc_write_client_cluster_data(STREAM* s, rdpSettings *settings);

View File

@ -578,7 +578,7 @@ boolean rdp_read_client_info(rdpRdp* rdp, STREAM* s)
* @param rdp RDP module
*/
void rdp_send_client_info(rdpRdp* rdp)
boolean rdp_send_client_info(rdpRdp* rdp)
{
STREAM* s;
@ -587,7 +587,7 @@ void rdp_send_client_info(rdpRdp* rdp)
rdp_write_security_header(s, SEC_INFO_PKT);
rdp_write_info_packet(s, rdp->settings);
rdp_send(rdp, s, MCS_GLOBAL_CHANNEL_ID);
return rdp_send(rdp, s, MCS_GLOBAL_CHANNEL_ID);
}
void rdp_recv_logon_info_v1(rdpRdp* rdp, STREAM* s)
@ -654,7 +654,7 @@ void rdp_recv_logon_info_extended(rdpRdp* rdp, STREAM* s)
stream_seek(s, 570); /* pad */
}
void rdp_recv_save_session_info(rdpRdp* rdp, STREAM* s)
boolean rdp_read_save_session_info(rdpRdp* rdp, STREAM* s)
{
uint32 infoType;
@ -683,5 +683,7 @@ void rdp_recv_save_session_info(rdpRdp* rdp, STREAM* s)
default:
break;
}
return True;
}

View File

@ -84,7 +84,7 @@ void rdp_write_extended_info_packet(STREAM* s, rdpSettings* settings);
boolean rdp_read_info_packet(STREAM* s, rdpSettings* settings);
void rdp_write_info_packet(STREAM* s, rdpSettings* settings);
boolean rdp_read_client_info(rdpRdp* rdp, STREAM* s);
void rdp_send_client_info(rdpRdp* rdp);
void rdp_recv_save_session_info(rdpRdp* rdp, STREAM* s);
boolean rdp_send_client_info(rdpRdp* rdp);
boolean rdp_read_save_session_info(rdpRdp* rdp, STREAM* s);
#endif /* __INFO_H */

View File

@ -63,33 +63,6 @@ uint8 state_transitions[][32] =
"ST_RESEND_LAST_MESSAGE"
};
/**
* Perform licensing phase of connection sequence.\n
* @param license license module
* @return
*/
boolean license_connect(rdpLicense* license)
{
while (1)
{
rdp_recv(license->rdp);
if (license->state == LICENSE_STATE_COMPLETED)
{
printf("license connection sequence completed.\n");
return True;
}
else if (license->state == LICENSE_STATE_ABORTED)
{
printf("license connection sequence aborted.\n");
return False;
}
}
return False;
}
/**
* Read a licensing preamble.\n
* @msdn{cc240480}
@ -145,7 +118,7 @@ STREAM* license_send_stream_init(rdpLicense* license)
* @param s stream
*/
void license_send(rdpLicense* license, STREAM* s, uint8 type)
boolean license_send(rdpLicense* license, STREAM* s, uint8 type)
{
int length;
uint8 flags;
@ -175,7 +148,10 @@ void license_send(rdpLicense* license, STREAM* s, uint8 type)
#endif
stream_set_pos(s, length);
transport_write(license->rdp->transport, s);
if (transport_write(license->rdp->transport, s) < 0)
return False;
return True;
}
/**
@ -185,12 +161,28 @@ void license_send(rdpLicense* license, STREAM* s, uint8 type)
* @param s stream
*/
void license_recv(rdpLicense* license, STREAM* s)
boolean license_read(rdpLicense* license, STREAM* s)
{
uint16 length;
uint16 channelId;
uint16 sec_flags;
uint8 flags;
uint8 bMsgType;
uint16 wMsgSize;
if (!rdp_read_header(license->rdp, s, &length, &channelId))
{
printf("Incorrect RDP header.\n");
return False;
}
rdp_read_security_header(s, &sec_flags);
if (!(sec_flags & SEC_LICENSE_PKT))
{
printf("Unexpected license packet.\n");
return False;
}
license_read_preamble(s, &bMsgType, &flags, &wMsgSize); /* preamble (4 bytes) */
DEBUG_LICENSE("Receiving %s Packet", LICENSE_MESSAGE_STRINGS[bMsgType & 0x1F]);
@ -221,8 +213,10 @@ void license_recv(rdpLicense* license, STREAM* s)
default:
printf("invalid bMsgType:%d\n", bMsgType);
break;
return False;
}
return True;
}
void license_generate_randoms(rdpLicense* license)

View File

@ -156,10 +156,8 @@ struct rdp_license
SCOPE_LIST* scope_list;
};
boolean license_connect(rdpLicense* license);
void license_send(rdpLicense* license, STREAM* s, uint8 type);
void license_recv(rdpLicense* license, STREAM* s);
boolean license_read(rdpLicense* license, STREAM* s);
boolean license_send(rdpLicense* license, STREAM* s, uint8 type);
STREAM* license_send_stream_init(rdpLicense* license);
void license_generate_randoms(rdpLicense* license);

View File

@ -175,43 +175,6 @@ uint8 mcs_result_enumerated[16][32] =
"rt-user-rejected"
};
/**
* MCS Connection Sequence.
* @param mcs mcs module
* @return
*/
boolean mcs_connect(rdpMcs* mcs)
{
int i;
uint16 channelId;
rdpSettings* settings;
settings = mcs->transport->settings;
mcs_send_connect_initial(mcs);
mcs_recv_connect_response(mcs);
mcs_send_erect_domain_request(mcs);
mcs_send_attach_user_request(mcs);
mcs_recv_attach_user_confirm(mcs);
mcs_send_channel_join_request(mcs, mcs->user_id);
mcs_recv_channel_join_confirm(mcs);
mcs_send_channel_join_request(mcs, MCS_GLOBAL_CHANNEL_ID);
mcs_recv_channel_join_confirm(mcs);
for (i = 0; i < settings->num_channels; i++)
{
channelId = settings->channels[i].chan_id;
mcs_send_channel_join_request(mcs, channelId);
mcs_recv_channel_join_confirm(mcs);
}
return True;
}
/**
* Read a DomainMCSPDU header.
* @param s stream
@ -283,7 +246,7 @@ static void mcs_init_domain_parameters(DomainParameters* domainParameters,
* @param domainParameters domain parameters
*/
void mcs_read_domain_parameters(STREAM* s, DomainParameters* domainParameters)
boolean mcs_read_domain_parameters(STREAM* s, DomainParameters* domainParameters)
{
int length;
ber_read_sequence_tag(s, &length);
@ -295,6 +258,8 @@ void mcs_read_domain_parameters(STREAM* s, DomainParameters* domainParameters)
ber_read_integer(s, &(domainParameters->maxHeight));
ber_read_integer(s, &(domainParameters->maxMCSPDUsize));
ber_read_integer(s, &(domainParameters->protocolVersion));
return True;
}
/**
@ -488,13 +453,14 @@ void mcs_write_connect_response(STREAM* s, rdpMcs* mcs, STREAM* user_data)
* @param mcs mcs module
*/
void mcs_send_connect_initial(rdpMcs* mcs)
boolean mcs_send_connect_initial(rdpMcs* mcs)
{
STREAM* s;
int length;
uint8 *bm, *em;
STREAM* gcc_CCrq;
STREAM* client_data;
int status;
client_data = stream_new(512);
gcc_write_client_data_blocks(client_data, mcs->transport->settings);
@ -516,42 +482,44 @@ void mcs_send_connect_initial(rdpMcs* mcs)
tpdu_write_data(s);
stream_set_mark(s, em);
transport_write(mcs->transport, s);
status = transport_write(mcs->transport, s);
stream_free(gcc_CCrq);
stream_free(client_data);
return (status < 0 ? False : True);
}
/**
* Receive MCS Connect Response.\n
* Read MCS Connect Response.\n
* @msdn{cc240501}
* @param mcs mcs module
*/
void mcs_recv_connect_response(rdpMcs* mcs)
boolean mcs_read_connect_response(rdpMcs* mcs, STREAM* s)
{
STREAM* s;
int length;
uint8 result;
uint32 calledConnectId;
s = transport_recv_stream_init(mcs->transport, 1024);
transport_read(mcs->transport, s);
tpkt_read_header(s);
if (tpdu_read_data(s) == 0)
return;
return False;
ber_read_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, &length);
ber_read_enumerated(s, &result, MCS_Result_enum_length);
ber_read_integer(s, &calledConnectId);
mcs_read_domain_parameters(s, &(mcs->domainParameters));
if (!mcs_read_domain_parameters(s, &(mcs->domainParameters)))
return False;
ber_read_octet_string(s, &length);
gcc_read_conference_create_response(s, mcs->transport->settings);
if (!gcc_read_conference_create_response(s, mcs->transport->settings))
return False;
return True;
}
/**
@ -621,7 +589,7 @@ boolean mcs_read_erect_domain_request(rdpMcs* mcs, STREAM* s)
* @param mcs
*/
void mcs_send_erect_domain_request(rdpMcs* mcs)
boolean mcs_send_erect_domain_request(rdpMcs* mcs)
{
STREAM* s;
uint16 length = 12;
@ -632,7 +600,10 @@ void mcs_send_erect_domain_request(rdpMcs* mcs)
per_write_integer(s, 0); /* subHeight (INTEGER) */
per_write_integer(s, 0); /* subInterval (INTEGER) */
transport_write(mcs->transport, s);
if (transport_write(mcs->transport, s) < 0)
return False;
return True;
}
/**
@ -660,7 +631,7 @@ boolean mcs_read_attach_user_request(rdpMcs* mcs, STREAM* s)
* @param mcs mcs module
*/
void mcs_send_attach_user_request(rdpMcs* mcs)
boolean mcs_send_attach_user_request(rdpMcs* mcs)
{
STREAM* s;
uint16 length = 8;
@ -668,30 +639,32 @@ void mcs_send_attach_user_request(rdpMcs* mcs)
mcs_write_domain_mcspdu_header(s, DomainMCSPDU_AttachUserRequest, length, 0);
transport_write(mcs->transport, s);
if (transport_write(mcs->transport, s) < 0)
return False;
return True;
}
/**
* Receive MCS Attach User Confirm.\n
* Read MCS Attach User Confirm.\n
* @msdn{cc240525}
* @param mcs mcs module
*/
void mcs_recv_attach_user_confirm(rdpMcs* mcs)
boolean mcs_read_attach_user_confirm(rdpMcs* mcs, STREAM* s)
{
STREAM* s;
uint16 length;
uint8 result;
enum DomainMCSPDU MCSPDU;
s = transport_recv_stream_init(mcs->transport, 32);
transport_read(mcs->transport, s);
MCSPDU = DomainMCSPDU_AttachUserConfirm;
mcs_read_domain_mcspdu_header(s, &MCSPDU, &length);
if (!mcs_read_domain_mcspdu_header(s, &MCSPDU, &length))
return False;
per_read_enumerated(s, &result, MCS_Result_enum_length); /* result */
per_read_integer16(s, &(mcs->user_id), MCS_BASE_CHANNEL_ID); /* initiator (UserId) */
return True;
}
/**
@ -752,7 +725,7 @@ boolean mcs_read_channel_join_request(rdpMcs* mcs, STREAM* s, uint16* channel_id
* @param channel_id channel id
*/
void mcs_send_channel_join_request(rdpMcs* mcs, uint16 channel_id)
boolean mcs_send_channel_join_request(rdpMcs* mcs, uint16 channel_id)
{
STREAM* s;
uint16 length = 12;
@ -763,35 +736,36 @@ void mcs_send_channel_join_request(rdpMcs* mcs, uint16 channel_id)
per_write_integer16(s, mcs->user_id, MCS_BASE_CHANNEL_ID);
per_write_integer16(s, channel_id, 0);
transport_write(mcs->transport, s);
if (transport_write(mcs->transport, s) < 0)
return False;
return True;
}
/**
* Receive MCS Channel Join Confirm.\n
* Read MCS Channel Join Confirm.\n
* @msdn{cc240527}
* @param mcs mcs module
*/
void mcs_recv_channel_join_confirm(rdpMcs* mcs)
boolean mcs_read_channel_join_confirm(rdpMcs* mcs, STREAM* s, uint16* channel_id)
{
STREAM* s;
uint16 length;
uint8 result;
uint16 initiator;
uint16 requested;
uint16 channelId;
enum DomainMCSPDU MCSPDU;
s = transport_recv_stream_init(mcs->transport, 32);
transport_read(mcs->transport, s);
MCSPDU = DomainMCSPDU_ChannelJoinConfirm;
mcs_read_domain_mcspdu_header(s, &MCSPDU, &length);
if (!mcs_read_domain_mcspdu_header(s, &MCSPDU, &length))
return False;
per_read_enumerated(s, &result, MCS_Result_enum_length); /* result */
per_read_integer16(s, &initiator, MCS_BASE_CHANNEL_ID); /* initiator (UserId) */
per_read_integer16(s, &requested, 0); /* requested (ChannelId) */
per_read_integer16(s, &channelId, 0); /* channelId */
per_read_integer16(s, channel_id, 0); /* channelId */
return True;
}
/**

View File

@ -129,24 +129,22 @@ typedef struct rdp_mcs rdpMcs;
#define MCS_TYPE_CONNECT_INITIAL 0x65
#define MCS_TYPE_CONNECT_RESPONSE 0x66
boolean mcs_connect(rdpMcs* mcs);
void mcs_write_connect_initial(STREAM* s, rdpMcs* mcs, STREAM* user_data);
void mcs_write_connect_response(STREAM* s, rdpMcs* mcs, STREAM* user_data);
boolean mcs_read_connect_initial(rdpMcs* mcs, STREAM* s);
void mcs_send_connect_initial(rdpMcs* mcs);
void mcs_recv_connect_response(rdpMcs* mcs);
boolean mcs_send_connect_initial(rdpMcs* mcs);
boolean mcs_read_connect_response(rdpMcs* mcs, STREAM* s);
boolean mcs_send_connect_response(rdpMcs* mcs);
boolean mcs_read_erect_domain_request(rdpMcs* mcs, STREAM* s);
void mcs_send_erect_domain_request(rdpMcs* mcs);
boolean mcs_send_erect_domain_request(rdpMcs* mcs);
boolean mcs_read_attach_user_request(rdpMcs* mcs, STREAM* s);
void mcs_send_attach_user_request(rdpMcs* mcs);
void mcs_recv_attach_user_confirm(rdpMcs* mcs);
boolean mcs_send_attach_user_request(rdpMcs* mcs);
boolean mcs_read_attach_user_confirm(rdpMcs* mcs, STREAM* s);
boolean mcs_send_attach_user_confirm(rdpMcs* mcs);
boolean mcs_read_channel_join_request(rdpMcs* mcs, STREAM* s, uint16* channel_id);
void mcs_send_channel_join_request(rdpMcs* mcs, uint16 channel_id);
void mcs_recv_channel_join_confirm(rdpMcs* mcs);
boolean mcs_send_channel_join_request(rdpMcs* mcs, uint16 channel_id);
boolean mcs_read_channel_join_confirm(rdpMcs* mcs, STREAM* s, uint16* channel_id);
boolean mcs_send_channel_join_confirm(rdpMcs* mcs, uint16 channel_id);
boolean mcs_read_domain_mcspdu_header(STREAM* s, enum DomainMCSPDU* domainMCSPDU, uint16* length);
void mcs_write_domain_mcspdu_header(STREAM* s, enum DomainMCSPDU domainMCSPDU, uint16 length, uint8 options);

View File

@ -271,12 +271,12 @@ int nego_recv(rdpTransport* transport, STREAM* s, void* extra)
}
/**
* Receive protocol security negotiation request message.\n
* Read protocol security negotiation request message.\n
* @param nego
* @param s stream
*/
boolean nego_recv_request(rdpNego* nego, STREAM* s)
boolean nego_read_request(rdpNego* nego, STREAM* s)
{
uint8 li;
uint8 c;

View File

@ -94,7 +94,7 @@ void nego_attempt_rdp(rdpNego* nego);
void nego_send(rdpNego* nego);
int nego_recv(rdpTransport* transport, STREAM* s, void* extra);
void nego_recv_response(rdpNego* nego);
boolean nego_recv_request(rdpNego* nego, STREAM* s);
boolean nego_read_request(rdpNego* nego, STREAM* s);
void nego_send_negotiation_request(rdpNego* nego);
void nego_process_negotiation_request(rdpNego* nego, STREAM* s);

View File

@ -243,6 +243,6 @@ void update_read_draw_gdiplus_cache_first_order(STREAM* s, DRAW_GDIPLUS_CACHE_FI
void update_read_draw_gdiplus_cache_next_order(STREAM* s, DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next);
void update_read_draw_gdiplus_cache_end_order(STREAM* s, DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end);
#define WITH_DEBUG_ORDERS 1
//#define WITH_DEBUG_ORDERS 1
#endif /* __ORDERS_H */

View File

@ -175,7 +175,7 @@ static int peer_recv_callback(rdpTransport* transport, STREAM* s, void* extra)
return -1;
break;
case CONNECTION_STATE_CHANNEL_JOIN:
case CONNECTION_STATE_MCS_CHANNEL_JOIN:
if (!rdp_server_accept_client_info(peer->rdp, s))
return -1;
break;

View File

@ -235,7 +235,7 @@ void rdp_write_header(rdpRdp* rdp, STREAM* s, uint16 length, uint16 channel_id)
* @param channel_id channel id
*/
void rdp_send(rdpRdp* rdp, STREAM* s, uint16 channel_id)
boolean rdp_send(rdpRdp* rdp, STREAM* s, uint16 channel_id)
{
uint16 length;
@ -245,10 +245,13 @@ void rdp_send(rdpRdp* rdp, STREAM* s, uint16 channel_id)
rdp_write_header(rdp, s, length, channel_id);
stream_set_pos(s, length);
transport_write(rdp->transport, s);
if (transport_write(rdp->transport, s) < 0)
return False;
return True;
}
void rdp_send_pdu(rdpRdp* rdp, STREAM* s, uint16 type, uint16 channel_id)
boolean rdp_send_pdu(rdpRdp* rdp, STREAM* s, uint16 type, uint16 channel_id)
{
uint16 length;
@ -259,10 +262,13 @@ void rdp_send_pdu(rdpRdp* rdp, STREAM* s, uint16 type, uint16 channel_id)
rdp_write_share_control_header(s, length, type, channel_id);
stream_set_pos(s, length);
transport_write(rdp->transport, s);
if (transport_write(rdp->transport, s) < 0)
return False;
return True;
}
void rdp_send_data_pdu(rdpRdp* rdp, STREAM* s, uint8 type, uint16 channel_id)
boolean rdp_send_data_pdu(rdpRdp* rdp, STREAM* s, uint8 type, uint16 channel_id)
{
uint16 length;
@ -276,7 +282,10 @@ void rdp_send_data_pdu(rdpRdp* rdp, STREAM* s, uint8 type, uint16 channel_id)
//printf("send %s Data PDU (0x%02X), length:%d\n", DATA_PDU_TYPE_STRINGS[type], type, length);
stream_set_pos(s, length);
transport_write(rdp->transport, s);
if (transport_write(rdp->transport, s) < 0)
return False;
return True;
}
void rdp_read_set_error_info_data_pdu(STREAM* s)
@ -307,7 +316,7 @@ void rdp_read_data_pdu(rdpRdp* rdp, STREAM* s)
break;
case DATA_PDU_TYPE_CONTROL:
rdp_recv_server_control_pdu(rdp, s, rdp->settings);
rdp_read_server_control_pdu(rdp, s);
break;
case DATA_PDU_TYPE_POINTER:
@ -317,7 +326,7 @@ void rdp_read_data_pdu(rdpRdp* rdp, STREAM* s)
break;
case DATA_PDU_TYPE_SYNCHRONIZE:
rdp_recv_server_synchronize_pdu(rdp, s, rdp->settings);
rdp_read_server_synchronize_pdu(rdp, s);
break;
case DATA_PDU_TYPE_REFRESH_RECT:
@ -336,14 +345,14 @@ void rdp_read_data_pdu(rdpRdp* rdp, STREAM* s)
break;
case DATA_PDU_TYPE_SAVE_SESSION_INFO:
rdp_recv_save_session_info(rdp, s);
rdp_read_save_session_info(rdp, s);
break;
case DATA_PDU_TYPE_FONT_LIST:
break;
case DATA_PDU_TYPE_FONT_MAP:
rdp_recv_server_font_map_pdu(rdp, s, rdp->settings);
rdp_read_server_font_map_pdu(rdp, s);
break;
case DATA_PDU_TYPE_SET_KEYBOARD_INDICATORS:
@ -391,49 +400,17 @@ void rdp_read_data_pdu(rdpRdp* rdp, STREAM* s)
* @param s stream
*/
static void rdp_read_tpkt_pdu(rdpRdp* rdp, STREAM* s)
static boolean rdp_read_tpkt_pdu(rdpRdp* rdp, STREAM* s)
{
uint16 length;
uint16 pduType;
uint16 pduLength;
uint16 channelId;
uint16 sec_flags;
boolean processed;
if (!rdp_read_header(rdp, s, &length, &channelId))
{
printf("Incorrect RDP header.\n");
return;
}
if (rdp->licensed != True)
{
processed = False;
rdp_read_security_header(s, &sec_flags);
if (sec_flags & SEC_PKT_MASK)
{
switch (sec_flags & SEC_PKT_MASK)
{
case SEC_LICENSE_PKT:
processed = True;
license_recv(rdp->license, s);
break;
case SEC_REDIRECTION_PKT:
processed = True;
rdp_read_redirection_packet(rdp, s);
break;
default:
break;
}
}
if (processed)
return;
else
stream_rewind(s, 4);
return False;
}
if (channelId != MCS_GLOBAL_CHANNEL_ID)
@ -450,12 +427,9 @@ static void rdp_read_tpkt_pdu(rdpRdp* rdp, STREAM* s)
rdp_read_data_pdu(rdp, s);
break;
case PDU_TYPE_DEMAND_ACTIVE:
rdp_recv_demand_active(rdp, s, rdp->settings);
break;
case PDU_TYPE_DEACTIVATE_ALL:
rdp_recv_deactivate_all(rdp, s);
if (!rdp_read_deactivate_all(rdp, s))
return False;
break;
case PDU_TYPE_SERVER_REDIRECTION:
@ -467,9 +441,11 @@ static void rdp_read_tpkt_pdu(rdpRdp* rdp, STREAM* s)
break;
}
}
return True;
}
static void rdp_read_fastpath_pdu(rdpRdp* rdp, STREAM* s)
static boolean rdp_read_fastpath_pdu(rdpRdp* rdp, STREAM* s)
{
uint16 length;
@ -477,7 +453,7 @@ static void rdp_read_fastpath_pdu(rdpRdp* rdp, STREAM* s)
if (length > stream_get_size(s))
{
printf("incorrect FastPath PDU header length %d\n", length);
return;
return False;
}
/* TODO: fipsInformation */
@ -488,14 +464,16 @@ static void rdp_read_fastpath_pdu(rdpRdp* rdp, STREAM* s)
}
fastpath_recv_updates(rdp->fastpath, s);
return True;
}
static void rdp_read_pdu(rdpRdp* rdp, STREAM* s)
static boolean rdp_read_pdu(rdpRdp* rdp, STREAM* s)
{
if (tpkt_verify_header(s))
rdp_read_tpkt_pdu(rdp, s);
return rdp_read_tpkt_pdu(rdp, s);
else
rdp_read_fastpath_pdu(rdp, s);
return rdp_read_fastpath_pdu(rdp, s);
}
/**
@ -517,7 +495,42 @@ static int rdp_recv_callback(rdpTransport* transport, STREAM* s, void* extra)
{
rdpRdp* rdp = (rdpRdp*) extra;
rdp_read_pdu(rdp, s);
switch (rdp->state)
{
case CONNECTION_STATE_NEGO:
if (!rdp_client_connect_mcs_connect_response(rdp, s))
return -1;
break;
case CONNECTION_STATE_MCS_ATTACH_USER:
if (!rdp_client_connect_mcs_attach_user_confirm(rdp, s))
return -1;
break;
case CONNECTION_STATE_MCS_CHANNEL_JOIN:
if (!rdp_client_connect_mcs_channel_join_confirm(rdp, s))
return -1;
break;
case CONNECTION_STATE_LICENSE:
if (!rdp_client_connect_license(rdp, s))
return -1;
break;
case CONNECTION_STATE_CAPABILITY:
if (!rdp_client_connect_demand_active(rdp, s))
return -1;
break;
case CONNECTION_STATE_ACTIVE:
if (!rdp_read_pdu(rdp, s))
return -1;
break;
default:
printf("Invalid state %d\n", rdp->state);
return -1;
}
return 1;
}
@ -557,7 +570,6 @@ rdpRdp* rdp_new(freerdp* instance)
if (rdp != NULL)
{
rdp->licensed = False;
rdp->settings = settings_new();
rdp->transport = transport_new(rdp->settings);
rdp->license = license_new(rdp);

View File

@ -113,8 +113,6 @@ typedef struct rdp_rdp rdpRdp;
struct rdp_rdp
{
boolean licensed;
boolean activated;
int state;
struct rdp_mcs* mcs;
struct rdp_nego* nego;
@ -142,12 +140,12 @@ boolean rdp_read_header(rdpRdp* rdp, STREAM* s, uint16* length, uint16* channel_
void rdp_write_header(rdpRdp* rdp, STREAM* s, uint16 length, uint16 channel_id);
STREAM* rdp_pdu_init(rdpRdp* rdp);
void rdp_send_pdu(rdpRdp* rdp, STREAM* s, uint16 type, uint16 channel_id);
boolean rdp_send_pdu(rdpRdp* rdp, STREAM* s, uint16 type, uint16 channel_id);
STREAM* rdp_data_pdu_init(rdpRdp* rdp);
void rdp_send_data_pdu(rdpRdp* rdp, STREAM* s, uint8 type, uint16 channel_id);
boolean rdp_send_data_pdu(rdpRdp* rdp, STREAM* s, uint8 type, uint16 channel_id);
void rdp_send(rdpRdp* rdp, STREAM* s, uint16 channel_id);
boolean rdp_send(rdpRdp* rdp, STREAM* s, uint16 channel_id);
void rdp_recv(rdpRdp* rdp);
int rdp_send_channel_data(rdpRdp* rdp, int channel_id, uint8* data, int size);

View File

@ -177,7 +177,8 @@ void update_read_window_state_order(STREAM* s, WINDOW_ORDER_INFO* orderInfo, WIN
void update_read_window_icon_order(STREAM* s, WINDOW_ORDER_INFO* orderInfo, WINDOW_ICON_ORDER* window_icon)
{
update_read_icon_info(s, &window_icon->iconInfo); /* iconInfo (ICON_INFO) */
window_icon->iconInfo = (ICON_INFO*) xzalloc(sizeof(ICON_INFO));
update_read_icon_info(s, window_icon->iconInfo); /* iconInfo (ICON_INFO) */
}
void update_read_window_cached_icon_order(STREAM* s, WINDOW_ORDER_INFO* orderInfo, WINDOW_CACHED_ICON_ORDER* window_cached_icon)

View File

@ -575,8 +575,74 @@ uint8* gdi_image_convert(uint8* srcData, uint8* dstData, int width, int height,
return 0;
}
uint8*
gdi_glyph_convert(int width, int height, uint8* data)
uint8* gdi_image_invert(uint8* srcData, uint8* dstData, int width, int height, int bpp)
{
int y;
uint8* srcp;
uint8* dstp;
int scanline;
scanline = width * (bpp / 8);
if (dstData == NULL)
dstData = (uint8*) malloc(width * height * (bpp / 8));
dstp = dstData;
srcp = &srcData[scanline * (height - 1)];
for (y = height - 1; y >= 0; y--)
{
memcpy(dstp, srcp, scanline);
dstp += scanline;
srcp -= scanline;
}
return dstData;
}
uint8* gdi_icon_convert(uint8* srcData, uint8* dstData, uint8* mask, int width, int height, int bpp, HCLRCONV clrconv)
{
int x, y;
int pixel;
uint8* data;
uint8 bmask;
uint32 pmask;
uint32* icon;
pixel = 0;
data = gdi_image_invert(srcData, dstData, width, height, bpp);
dstData = gdi_image_convert(data, NULL, width, height, bpp, 32, clrconv);
free(data);
bmask = mask[pixel];
icon = (uint32*) dstData;
if (bpp < 32)
{
for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++)
{
if (pixel % 8 == 0)
bmask = mask[pixel / 8];
else
bmask <<= 1;
pmask = (bmask & 0x80) ? 0x00000000 : 0xFF000000;
*icon++ |= pmask;
pixel++;
}
}
}
free(mask);
return dstData;
}
uint8* gdi_glyph_convert(int width, int height, uint8* data)
{
int x, y;
uint8 *srcp;

View File

@ -20,6 +20,7 @@
set(FREERDP_RAIL_SRCS
window_list.c
window.c
icon.c
rail.c)
add_library(freerdp-rail SHARED ${FREERDP_RAIL_SRCS})

112
libfreerdp-rail/icon.c Normal file
View File

@ -0,0 +1,112 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Window Icon Cache
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <freerdp/utils/stream.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/hexdump.h>
#include <freerdp/utils/unicode.h>
#include <freerdp/rail/icon.h>
ICON_INFO* icon_cache_get(rdpIconCache* cache, uint8 id, uint16 index, void** extra)
{
ICON_INFO* entry;
if (id >= cache->numCaches)
{
printf("invalid window icon cache id:%d\n", id);
return (ICON_INFO*) NULL;
}
if (index >= cache->numCacheEntries)
{
printf("invalid window icon cache index:%d in cache id:%d\n", index, id);
return (ICON_INFO*) NULL;
}
entry = cache->caches[id].entries[index].entry;
if (extra != NULL)
*extra = cache->caches[id].entries[index].extra;
return entry;
}
void icon_cache_put(rdpIconCache* cache, uint8 id, uint16 index, ICON_INFO* entry, void* extra)
{
if (id >= cache->numCaches)
{
printf("invalid window icon cache id:%d\n", id);
return;
}
if (index >= cache->numCacheEntries)
{
printf("invalid window icon cache index:%d in cache id:%d\n", index, id);
return;
}
cache->caches[id].entries[index].entry = entry;
if (extra != NULL)
cache->caches[id].entries[index].extra = extra;
}
rdpIconCache* icon_cache_new(rdpRail* rail)
{
rdpIconCache* cache;
cache = (rdpIconCache*) xzalloc(sizeof(rdpIconCache));
if (cache != NULL)
{
int i;
cache->rail = rail;
cache->numCaches = rail->settings->num_icon_cache_entries;
cache->numCacheEntries = rail->settings->num_icon_cache_entries;
cache->caches = xzalloc(cache->numCaches * sizeof(WINDOW_ICON_CACHE));
for (i = 0; i < cache->numCaches; i++)
{
cache->caches[i].entries = xzalloc(cache->numCacheEntries * sizeof(rdpIconCache));
}
}
return cache;
}
void icon_cache_free(rdpIconCache* cache)
{
if (cache != NULL)
{
int i;
for (i = 0; i < cache->numCaches; i++)
{
xfree(cache->caches[i].entries);
}
xfree(cache->caches);
xfree(cache);
}
}

View File

@ -21,6 +21,7 @@
#include <freerdp/utils/memory.h>
#include <freerdp/rail/rail.h>
#include <freerdp/rail/window_list.h>
static void rail_WindowCreate(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* window_state)
{
@ -43,14 +44,54 @@ static void rail_WindowDelete(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo)
window_list_delete(rail->list, orderInfo);
}
static void rail_WindowIcon(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo, WINDOW_ICON_ORDER* window_icon)
{
rdpRail* rail;
rdpIcon* icon;
rdpWindow* window;
rail = (rdpRail*) update->rail;
if (window_icon->iconInfo->cacheEntry != 0xFFFF)
{
/* cache icon */
}
window = window_list_get_by_id(rail->list, orderInfo->windowId);
icon = (rdpIcon*) xzalloc(sizeof(rdpIcon));
icon->entry = window_icon->iconInfo;
icon->big = (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_ICON_BIG) ? True : False;
printf("Window Icon: %dx%d@%dbpp cbBitsColor:%d cbBitsMask:%d cbColorTable:%d\n",
window_icon->iconInfo->width, window_icon->iconInfo->height, window_icon->iconInfo->bpp,
window_icon->iconInfo->cbBitsColor, window_icon->iconInfo->cbBitsMask, window_icon->iconInfo->cbColorTable);
if (icon->big)
window->bigIcon = icon;
else
window->smallIcon = icon;
IFCALL(rail->SetWindowIcon, rail, window, icon);
}
static void rail_WindowCachedIcon(rdpUpdate* update, WINDOW_ORDER_INFO* orderInfo, WINDOW_CACHED_ICON_ORDER* window_cached_icon)
{
rdpRail* rail;
rail = (rdpRail*) update->rail;
printf("rail_WindowCachedIcon\n");
}
void rail_register_update_callbacks(rdpRail* rail, rdpUpdate* update)
{
update->WindowCreate = rail_WindowCreate;
update->WindowUpdate = rail_WindowUpdate;
update->WindowDelete = rail_WindowDelete;
update->WindowIcon = rail_WindowIcon;
update->WindowCachedIcon = rail_WindowCachedIcon;
}
rdpRail* rail_new()
rdpRail* rail_new(rdpSettings* settings)
{
rdpRail* rail;
@ -58,8 +99,11 @@ rdpRail* rail_new()
if (rail != NULL)
{
rail->settings = settings;
rail->cache = icon_cache_new(rail);
rail->list = window_list_new(rail);
rail->uniconv = freerdp_uniconv_new();
rail->clrconv = (CLRCONV*) xzalloc(sizeof(CLRCONV));
}
return rail;
@ -69,6 +113,7 @@ void rail_free(rdpRail* rail)
{
if (rail != NULL)
{
icon_cache_free(rail->cache);
window_list_free(rail->list);
freerdp_uniconv_free(rail->uniconv);
xfree(rail);

View File

@ -24,6 +24,113 @@
#include <freerdp/rail/window.h>
struct _WINDOW_STYLE
{
uint32 style;
char* name;
boolean multi;
};
typedef struct _WINDOW_STYLE WINDOW_STYLE;
WINDOW_STYLE WINDOW_STYLES[] =
{
{ WS_BORDER, "WS_BORDER", False },
{ WS_CAPTION, "WS_CAPTION", False },
{ WS_CHILD, "WS_CHILD", False },
{ WS_CLIPCHILDREN, "WS_CLIPCHILDREN", False },
{ WS_CLIPSIBLINGS, "WS_CLIPSIBLINGS", False },
{ WS_DISABLED, "WS_DISABLED", False },
{ WS_DLGFRAME, "WS_DLGFRAME", False },
{ WS_GROUP, "WS_GROUP", False },
{ WS_HSCROLL, "WS_HSCROLL", False },
{ WS_ICONIC, "WS_ICONIC", False },
{ WS_MAXIMIZE, "WS_MAXIMIZE", False },
{ WS_MAXIMIZEBOX, "WS_MAXIMIZEBOX", False },
{ WS_MINIMIZE, "WS_MINIMIZE", False },
{ WS_MINIMIZEBOX, "WS_MINIMIZEBOX", False },
{ WS_OVERLAPPED, "WS_OVERLAPPED", False },
{ WS_OVERLAPPEDWINDOW, "WS_OVERLAPPEDWINDOW", True },
{ WS_POPUP, "WS_POPUP", False },
{ WS_POPUPWINDOW, "WS_POPUPWINDOW", True },
{ WS_SIZEBOX, "WS_SIZEBOX", False },
{ WS_SYSMENU, "WS_SYSMENU", False },
{ WS_TABSTOP, "WS_TABSTOP", False },
{ WS_THICKFRAME, "WS_THICKFRAME", False },
{ WS_VISIBLE, "WS_VISIBLE", False }
};
WINDOW_STYLE EXTENDED_WINDOW_STYLES[] =
{
{ WS_EX_ACCEPTFILES, "WS_EX_ACCEPTFILES", False },
{ WS_EX_APPWINDOW, "WS_EX_APPWINDOW", False },
{ WS_EX_CLIENTEDGE, "WS_EX_CLIENTEDGE", False },
{ WS_EX_COMPOSITED, "WS_EX_COMPOSITED", False },
{ WS_EX_CONTEXTHELP, "WS_EX_CONTEXTHELP", False },
{ WS_EX_CONTROLPARENT, "WS_EX_CONTROLPARENT", False },
{ WS_EX_DLGMODALFRAME, "WS_EX_DLGMODALFRAME", False },
{ WS_EX_LAYERED, "WS_EX_LAYERED", False },
{ WS_EX_LAYOUTRTL, "WS_EX_LAYOUTRTL", False },
{ WS_EX_LEFT, "WS_EX_LEFT", False },
{ WS_EX_LEFTSCROLLBAR, "WS_EX_LEFTSCROLLBAR", False },
{ WS_EX_LTRREADING, "WS_EX_LTRREADING", False },
{ WS_EX_MDICHILD, "WS_EX_MDICHILD", False },
{ WS_EX_NOACTIVATE, "WS_EX_NOACTIVATE", False },
{ WS_EX_NOINHERITLAYOUT, "WS_EX_NOINHERITLAYOUT", False },
{ WS_EX_NOPARENTNOTIFY, "WS_EX_NOPARENTNOTIFY", False },
{ WS_EX_OVERLAPPEDWINDOW, "WS_EX_OVERLAPPEDWINDOW", True },
{ WS_EX_PALETTEWINDOW, "WS_EX_PALETTEWINDOW", True },
{ WS_EX_RIGHT, "WS_EX_RIGHT", False },
{ WS_EX_RIGHTSCROLLBAR, "WS_EX_RIGHTSCROLLBAR", False },
{ WS_EX_RTLREADING, "WS_EX_RTLREADING", False },
{ WS_EX_STATICEDGE, "WS_EX_STATICEDGE", False },
{ WS_EX_TOOLWINDOW, "WS_EX_TOOLWINDOW", False },
{ WS_EX_TOPMOST, "WS_EX_TOPMOST", False },
{ WS_EX_TRANSPARENT, "WS_EX_TRANSPARENT", False },
{ WS_EX_WINDOWEDGE, "WS_EX_WINDOWEDGE", False }
};
void print_window_styles(uint32 style)
{
int i;
printf("Window Styles:\n{\n");
for (i = 0; i < sizeof(WINDOW_STYLES) / sizeof(WINDOW_STYLE); i++)
{
if (style & WINDOW_STYLES[i].style)
{
if (WINDOW_STYLES[i].multi)
{
if ((style & WINDOW_STYLES[i].style) != WINDOW_STYLES[i].style)
continue;
}
printf("\t%s\n", WINDOW_STYLES[i].name);
}
}
printf("}\n");
}
void print_extended_window_styles(uint32 style)
{
int i;
printf("Extended Window Styles:\n{\n");
for (i = 0; i < sizeof(EXTENDED_WINDOW_STYLES) / sizeof(WINDOW_STYLE); i++)
{
if (style & EXTENDED_WINDOW_STYLES[i].style)
{
if (EXTENDED_WINDOW_STYLES[i].multi)
{
if ((style & EXTENDED_WINDOW_STYLES[i].style) != EXTENDED_WINDOW_STYLES[i].style)
continue;
}
printf("\t%s\n", EXTENDED_WINDOW_STYLES[i].name);
}
}
printf("}\n");
}
void window_state_update(rdpWindow* window, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* window_state)
{
window->fieldFlags = orderInfo->fieldFlags;
@ -31,12 +138,17 @@ void window_state_update(rdpWindow* window, WINDOW_ORDER_INFO* orderInfo, WINDOW
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_OWNER)
{
window->ownerWindowId = window_state->ownerWindowId;
printf("ownerWindowId:0x%08X\n", window->ownerWindowId);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_STYLE)
{
window->style = window_state->style;
window->extendedStyle = window_state->extendedStyle;
//printf("Style:%d, ExtendedStyle:%d\n", window->style, window->extendedStyle);
print_window_styles(window->style);
print_extended_window_styles(window->extendedStyle);
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_SHOW)
@ -110,7 +222,14 @@ void window_state_update(rdpWindow* window, WINDOW_ORDER_INFO* orderInfo, WINDOW
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS)
{
int i;
for (i = 0; i < window_state->numWindowRects; i++)
{
printf("Window Rect #%d: left:%d top:%d right:%d bottom:%d\n", i,
window_state->windowRects->left, window_state->windowRects->top,
window_state->windowRects->right, window_state->windowRects->bottom);
}
}
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET)
@ -124,7 +243,14 @@ void window_state_update(rdpWindow* window, WINDOW_ORDER_INFO* orderInfo, WINDOW
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)
{
int i;
for (i = 0; i < window_state->numVisibilityRects; i++)
{
printf("Visibility Rect #%d: left:%d top:%d right:%d bottom:%d\n", i,
window_state->visibilityRects->left, window_state->visibilityRects->top,
window_state->visibilityRects->right, window_state->visibilityRects->bottom);
}
}
}
@ -157,7 +283,7 @@ void rail_UpdateWindow(rdpRail* rail, rdpWindow* window)
if (window->fieldFlags & WINDOW_ORDER_FIELD_SHOW)
{
IFCALL(rail->ShowWindow, rail, window, window->showState);
}
if (window->fieldFlags & WINDOW_ORDER_FIELD_TITLE)