Merge pull request #955 from awakecoding/master

Messaging Cleanup + Licensing Fix
This commit is contained in:
Marc-André Moreau 2013-02-05 07:04:31 -08:00
commit df0d258097
19 changed files with 843 additions and 487 deletions

View File

@ -1021,23 +1021,25 @@ int xfreerdp_run(freerdp* instance)
int rcount;
int wcount;
int ret = 0;
BOOL status;
void* rfds[32];
void* wfds[32];
fd_set rfds_set;
fd_set wfds_set;
int fd_msg_event;
HANDLE msg_event;
int fd_evt_event;
HANDLE evt_event;
int fd_update_event;
HANDLE update_event;
int fd_input_event;
HANDLE input_event;
int select_status;
rdpChannels* channels;
struct timeval timeout;
memset(rfds, 0, sizeof(rfds));
memset(wfds, 0, sizeof(wfds));
memset(&timeout, 0, sizeof(struct timeval));
ZeroMemory(rfds, sizeof(rfds));
ZeroMemory(wfds, sizeof(wfds));
ZeroMemory(&timeout, sizeof(struct timeval));
status = freerdp_connect(instance);
BOOL status = freerdp_connect(instance);
/* Connection succeeded. --authonly ? */
if (instance->settings->AuthenticationOnly)
{
@ -1055,17 +1057,17 @@ int xfreerdp_run(freerdp* instance)
xfi = ((xfContext*) instance->context)->xfi;
channels = instance->context->channels;
fd_msg_event = -1;
msg_event = freerdp_get_message_queue_event_handle(instance);
fd_update_event = -1;
update_event = freerdp_get_message_queue_event_handle(instance, FREERDP_UPDATE_MESSAGE_QUEUE);
if (msg_event)
fd_msg_event = GetEventFileDescriptor(msg_event);
if (update_event)
fd_update_event = GetEventFileDescriptor(update_event);
fd_evt_event = -1;
evt_event = freerdp_get_input_queue_event_handle(instance);
fd_input_event = -1;
input_event = freerdp_get_message_queue_event_handle(instance, FREERDP_INPUT_MESSAGE_QUEUE);
if (evt_event)
fd_evt_event = GetEventFileDescriptor(evt_event);
if (input_event)
fd_input_event = GetEventFileDescriptor(input_event);
while (!xfi->disconnect && !freerdp_shall_disconnect(instance))
{
@ -1091,11 +1093,11 @@ int xfreerdp_run(freerdp* instance)
break;
}
if (fd_msg_event > 0)
rfds[rcount++] = (void*) (long) fd_msg_event;
if (fd_update_event > 0)
rfds[rcount++] = (void*) (long) fd_update_event;
if (fd_evt_event > 0)
rfds[rcount++] = (void*) (long) fd_evt_event;
if (fd_input_event > 0)
rfds[rcount++] = (void*) (long) fd_input_event;
max_fds = 0;
FD_ZERO(&rfds_set);
@ -1153,11 +1155,11 @@ int xfreerdp_run(freerdp* instance)
}
xf_process_channel_event(channels, instance);
if (fd_msg_event > 0)
freerdp_process_messages(instance);
if (fd_update_event > 0)
freerdp_message_queue_process_pending_messages(instance, FREERDP_UPDATE_MESSAGE_QUEUE);
if (fd_evt_event > 0)
freerdp_process_input(instance);
if (fd_input_event > 0)
freerdp_message_queue_process_pending_messages(instance, FREERDP_INPUT_MESSAGE_QUEUE);
}
FILE *fin = fopen("/tmp/tsmf.tid", "rt");

View File

@ -316,8 +316,8 @@ void test_license(void)
STREAM _s, *s;
s = &_s;
memcpy(license->client_random, client_random, sizeof(client_random));
memcpy(license->premaster_secret, premaster_secret, sizeof(premaster_secret));
memcpy(license->ClientRandom, client_random, sizeof(client_random));
memcpy(license->PremasterSecret, premaster_secret, sizeof(premaster_secret));
s->data = server_license_request;
s->p = s->data + LICENSE_PREAMBLE_LENGTH;
@ -327,31 +327,31 @@ void test_license(void)
printf("\n");
printf("client random:\n");
winpr_HexDump(license->client_random, 32);
winpr_HexDump(license->ClientRandom, 32);
printf("\n");
printf("server random:\n");
winpr_HexDump(license->server_random, 32);
winpr_HexDump(license->ServerRandom, 32);
printf("\n");
printf("premaster secret:\n");
winpr_HexDump(license->premaster_secret, 48);
winpr_HexDump(license->PremasterSecret, 48);
printf("\n");
printf("master secret:\n");
winpr_HexDump(license->master_secret, 48);
winpr_HexDump(license->MasterSecret, 48);
printf("\n");
printf("session key blob:\n");
winpr_HexDump(license->session_key_blob, 48);
winpr_HexDump(license->SessionKeyBlob, 48);
printf("\n");
printf("licensing encryption key:\n");
winpr_HexDump(license->licensing_encryption_key, 16);
winpr_HexDump(license->LicensingEncryptionKey, 16);
printf("\n");
printf("mac salt key:\n");
winpr_HexDump(license->mac_salt_key, 16);
winpr_HexDump(license->MacSaltKey, 16);
printf("\n");
printf("modulus:\n");
@ -364,8 +364,8 @@ void test_license(void)
printf("\n");
printf("encrypted premaster secret:\n");
winpr_HexDump(license->encrypted_premaster_secret->data,
license->encrypted_premaster_secret->length);
winpr_HexDump(license->EncryptedPremasterSecret->data,
license->EncryptedPremasterSecret->length);
printf("\n");
#endif
@ -422,9 +422,9 @@ void test_license_generate_keys(void)
STREAM _s, *s;
s = &_s;
memcpy(license->client_random, client_random, sizeof(client_random));
memcpy(license->server_random, test_server_random, sizeof(test_server_random));
memcpy(license->premaster_secret, premaster_secret, sizeof(premaster_secret));
memcpy(license->ClientRandom, client_random, sizeof(client_random));
memcpy(license->ServerRandom, test_server_random, sizeof(test_server_random));
memcpy(license->PremasterSecret, premaster_secret, sizeof(premaster_secret));
memcpy(license->certificate->cert_info.exponent, test_exponent, sizeof(test_exponent));
memcpy(license->certificate->cert_info.Modulus, test_modulus, sizeof(test_modulus));
license->certificate->cert_info.ModulusLength = sizeof(test_modulus);
@ -432,23 +432,23 @@ void test_license_generate_keys(void)
license_generate_keys(license);
license_encrypt_premaster_secret(license);
s->data = license->master_secret;
s->data = license->MasterSecret;
s->p = s->data + sizeof(test_master_secret);
ASSERT_STREAM(s, test_master_secret, sizeof(test_master_secret));
s->data = license->session_key_blob;
s->data = license->SessionKeyBlob;
s->p = s->data + sizeof(test_session_key_blob);
ASSERT_STREAM(s, test_session_key_blob, sizeof(test_session_key_blob));
s->data = license->mac_salt_key;
s->data = license->MacSaltKey;
s->p = s->data + sizeof(test_mac_salt_key);
ASSERT_STREAM(s, test_mac_salt_key, sizeof(test_mac_salt_key));
s->data = license->licensing_encryption_key;
s->data = license->LicensingEncryptionKey;
s->p = s->data + sizeof(test_licensing_encryption_key);
ASSERT_STREAM(s, test_licensing_encryption_key, sizeof(test_licensing_encryption_key));
s->data = license->encrypted_premaster_secret->data;
s->data = license->EncryptedPremasterSecret->data;
s->p = s->data + sizeof(test_encrypted_premaster_secret);
ASSERT_STREAM(s, test_encrypted_premaster_secret, sizeof(test_encrypted_premaster_secret));
}
@ -458,12 +458,12 @@ void test_license_encrypt_premaster_secret(void)
STREAM _s, *s;
s = &_s;
memcpy(license->premaster_secret, premaster_secret, sizeof(premaster_secret));
memcpy(license->PremasterSecret, premaster_secret, sizeof(premaster_secret));
memcpy(license->certificate->cert_info.exponent, test_exponent, sizeof(test_exponent));
memcpy(license->certificate->cert_info.Modulus, test_modulus, sizeof(test_modulus));
license->certificate->cert_info.ModulusLength = sizeof(test_modulus);
s->data = license->encrypted_premaster_secret->data;
s->data = license->EncryptedPremasterSecret->data;
s->p = s->data + sizeof(test_encrypted_premaster_secret);
ASSERT_STREAM(s, test_encrypted_premaster_secret, sizeof(test_encrypted_premaster_secret));
}
@ -479,20 +479,20 @@ void test_license_decrypt_platform_challenge(void)
STREAM _s, *s;
s = &_s;
memcpy(license->licensing_encryption_key, test_licensing_encryption_key,
memcpy(license->LicensingEncryptionKey, test_licensing_encryption_key,
sizeof(test_licensing_encryption_key));
license->encrypted_platform_challenge->data =
license->EncryptedPlatformChallenge->data =
(BYTE*) malloc(sizeof(test_encrypted_platform_challenge));
license->encrypted_platform_challenge->length =
license->EncryptedPlatformChallenge->length =
sizeof(test_encrypted_platform_challenge);
memcpy(license->encrypted_platform_challenge->data, test_encrypted_platform_challenge,
memcpy(license->EncryptedPlatformChallenge->data, test_encrypted_platform_challenge,
sizeof(test_encrypted_platform_challenge));
license_decrypt_platform_challenge(license);
s->data = license->platform_challenge->data;
s->data = license->PlatformChallenge->data;
s->p = s->data + sizeof(test_platform_challenge);
ASSERT_STREAM(s, test_platform_challenge, sizeof(test_platform_challenge));

View File

@ -40,7 +40,6 @@
#endif
#define EXPONENT_MAX_SIZE 4
#define MODULUS_MAX_SIZE 256
#include <freerdp/api.h>
#include <freerdp/freerdp.h>

View File

@ -40,6 +40,7 @@ typedef struct rdp_freerdp_peer freerdp_peer;
#include <freerdp/input.h>
#include <freerdp/update.h>
#include <freerdp/message.h>
#ifdef __cplusplus
extern "C" {
@ -196,11 +197,10 @@ FREERDP_API BOOL freerdp_disconnect(freerdp* instance);
FREERDP_API BOOL freerdp_get_fds(freerdp* instance, void** rfds, int* rcount, void** wfds, int* wcount);
FREERDP_API BOOL freerdp_check_fds(freerdp* instance);
FREERDP_API int freerdp_process_messages(freerdp* instance);
FREERDP_API HANDLE freerdp_get_message_queue_event_handle(freerdp* instance);
FREERDP_API HANDLE freerdp_get_input_queue_event_handle(freerdp* instance);
FREERDP_API int freerdp_process_input(freerdp* instance);
FREERDP_API wMessageQueue* freerdp_get_message_queue(freerdp* instance, DWORD id);
FREERDP_API HANDLE freerdp_get_message_queue_event_handle(freerdp* instance, DWORD id);
FREERDP_API int freerdp_message_queue_process_message(freerdp* instance, DWORD id, wMessage* message);
FREERDP_API int freerdp_message_queue_process_pending_messages(freerdp* instance, DWORD id);
FREERDP_API UINT32 freerdp_error_info(freerdp* instance);

238
include/freerdp/message.h Normal file
View File

@ -0,0 +1,238 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* Asynchronous Message Interface
*
* Copyright 2012 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 FREERDP_CORE_MESSAGE_H
#define FREERDP_CORE_MESSAGE_H
#define GetMessageType(_id) (_id & 0xFF)
#define GetMessageClass(_id) ((_id >> 16) & 0xFF)
#define MakeMessageId(_class, _type) \
(((_class ##_Class) << 16) | (_class ## _ ## _type))
/**
* Update Message Queue
*/
#define FREERDP_UPDATE_MESSAGE_QUEUE 1
#define Update_Base 0
/* Update */
#define Update_Class (Update_Base + 1)
#define Update_BeginPaint 1
#define Update_EndPaint 2
#define Update_SetBounds 3
#define Update_Synchronize 4
#define Update_DesktopResize 5
#define Update_BitmapUpdate 6
#define Update_Palette 7
#define Update_PlaySound 8
#define Update_RefreshRect 9
#define Update_SuppressOutput 10
#define Update_SurfaceCommand 11
#define Update_SurfaceBits 12
#define Update_SurfaceFrameMarker 13
#define Update_SurfaceFrameAcknowledge 14
#define FREERDP_UPDATE_BEGIN_PAINT MakeMessageId(Update, BeginPaint)
#define FREERDP_UPDATE_ END_PAINT MakeMessageId(Update, EndPaint)
#define FREERDP_UPDATE_SET_BOUNDS MakeMessageId(Update, SetBounds)
#define FREERDP_UPDATE_SYNCHRONIZE MakeMessageId(Update, Synchronize)
#define FREERDP_UPDATE_DESKTOP_RESIZE MakeMessageId(Update, DesktopResize)
#define FREERDP_UPDATE_BITMAP_UPDATE MakeMessageId(Update, BitmapUpdate)
#define FREERDP_UPDATE_PALETTE MakeMessageId(Update, Palette)
#define FREERDP_UPDATE_PLAY_SOUND MakeMessageId(Update, PlaySound)
#define FREERDP_UPDATE_REFRESH_RECT MakeMessageId(Update, RefreshRect)
#define FREERDP_UPDATE_SUPPRESS_OUTPUT MakeMessageId(Update, SuppressOutput)
#define FREERDP_UPDATE_SURFACE_COMMAND MakeMessageId(Update, SurfaceCommand)
#define FREERDP_UPDATE_SURFACE_BITS MakeMessageId(Update, SurfaceBits)
#define FREERDP_UPDATE_SURFACE_FRAME_MARKER MakeMessageId(Update, SurfaceFrameMarker)
#define FREERDP_UPDATE_SURFACE_FRAME_ACKNOWLEDGE MakeMessageId(Update, SurfaceFrameAcknowledge)
/* Primary Update */
#define PrimaryUpdate_Class (Update_Base + 2)
#define PrimaryUpdate_DstBlt 1
#define PrimaryUpdate_PatBlt 2
#define PrimaryUpdate_ScrBlt 3
#define PrimaryUpdate_OpaqueRect 4
#define PrimaryUpdate_DrawNineGrid 5
#define PrimaryUpdate_MultiDstBlt 6
#define PrimaryUpdate_MultiPatBlt 7
#define PrimaryUpdate_MultiScrBlt 8
#define PrimaryUpdate_MultiOpaqueRect 9
#define PrimaryUpdate_MultiDrawNineGrid 10
#define PrimaryUpdate_LineTo 11
#define PrimaryUpdate_Polyline 12
#define PrimaryUpdate_MemBlt 13
#define PrimaryUpdate_Mem3Blt 14
#define PrimaryUpdate_SaveBitmap 15
#define PrimaryUpdate_GlyphIndex 16
#define PrimaryUpdate_FastIndex 17
#define PrimaryUpdate_FastGlyph 18
#define PrimaryUpdate_PolygonSC 19
#define PrimaryUpdate_PolygonCB 20
#define PrimaryUpdate_EllipseSC 21
#define PrimaryUpdate_EllipseCB 22
#define FREERDP_PRIMARY_UPDATE_DSTBLT MakeMessageId(PrimaryUpdate, DstBlt)
#define FREERDP_PRIMARY_UPDATE_PATBLT MakeMessageId(PrimaryUpdate, PatBlt)
#define FREERDP_PRIMARY_UPDATE_SCRBLT MakeMessageId(PrimaryUpdate, ScrBlt)
#define FREERDP_PRIMARY_UPDATE_OPAQUE_RECT MakeMessageId(PrimaryUpdate, OpaqueRect)
#define FREERDP_PRIMARY_UPDATE_DRAW_NINE_GRID MakeMessageId(PrimaryUpdate, DrawNineGrid)
#define FREERDP_PRIMARY_UPDATE_MULTI_DSTBLT MakeMessageId(PrimaryUpdate, MultiDstBlt)
#define FREERDP_PRIMARY_UPDATE_MULTI_PATBLT MakeMessageId(PrimaryUpdate, MultiPatBlt)
#define FREERDP_PRIMARY_UPDATE_MULTI_SCRBLT MakeMessageId(PrimaryUpdate, MultiScrBlt)
#define FREERDP_PRIMARY_UPDATE_MULTI_OPAQUE_RECT MakeMessageId(PrimaryUpdate, MultiOpaqueRect)
#define FREERDP_PRIMARY_UPDATE_MULTI_DRAW_NINE_GRID MakeMessageId(PrimaryUpdate, MultiDrawNineGrid)
#define FREERDP_PRIMARY_UPDATE_LINE_TO MakeMessageId(PrimaryUpdate, LineTo)
#define FREERDP_PRIMARY_UPDATE_POLYLINE MakeMessageId(PrimaryUpdate, Polyline)
#define FREERDP_PRIMARY_UPDATE_MEMBLT MakeMessageId(PrimaryUpdate, MemBlt)
#define FREERDP_PRIMARY_UPDATE_MEM3BLT MakeMessageId(PrimaryUpdate, Mem3Blt)
#define FREERDP_PRIMARY_UPDATE_SAVE_BITMAP MakeMessageId(PrimaryUpdate, SaveBitmap)
#define FREERDP_PRIMARY_UPDATE_GLYPH_INDEX MakeMessageId(PrimaryUpdate, GlyphIndex)
#define FREERDP_PRIMARY_UPDATE_FAST_INDEX MakeMessageId(PrimaryUpdate, FastIndex)
#define FREERDP_PRIMARY_UPDATE_FAST_GLYPH MakeMessageId(PrimaryUpdate, FastGlyph)
#define FREERDP_PRIMARY_UPDATE_POLYGON_SC MakeMessageId(PrimaryUpdate, PolygonSC)
#define FREERDP_PRIMARY_UPDATE_POLYGON_CB MakeMessageId(PrimaryUpdate, PolygonCB)
#define FREERDP_PRIMARY_UPDATE_ELLIPSE_SC MakeMessageId(PrimaryUpdate, EllipseSC)
#define FREERDP_PRIMARY_UPDATE_ELLIPSE_CB MakeMessageId(PrimaryUpdate, EllipseCB)
/* Secondary Update */
#define SecondaryUpdate_Class (Update_Base + 3)
#define SecondaryUpdate_CacheBitmap 1
#define SecondaryUpdate_CacheBitmapV2 2
#define SecondaryUpdate_CacheBitmapV3 3
#define SecondaryUpdate_CacheColorTable 4
#define SecondaryUpdate_CacheGlyph 5
#define SecondaryUpdate_CacheGlyphV2 6
#define SecondaryUpdate_CacheBrush 7
#define FREERDP_SECONDARY_UPDATE_CACHE_BITMAP MakeMessageId(SecondaryUpdate, CacheBitmap)
#define FREERDP_SECONDARY_UPDATE_CACHE_BITMAP_V2 MakeMessageId(SecondaryUpdate, CacheBitmapV2)
#define FREERDP_SECONDARY_UPDATE_CACHE_BITMAP_V3 MakeMessageId(SecondaryUpdate, CacheBitmapV3)
#define FREERDP_SECONDARY_UPDATE_CACHE_COLOR_TABLE MakeMessageId(SecondaryUpdate, CacheColorTable)
#define FREERDP_SECONDARY_UPDATE_CACHE_GLYPH MakeMessageId(SecondaryUpdate, CacheGlyph)
#define FREERDP_SECONDARY_UPDATE_CACHE_GLYPH_V2 MakeMessageId(SecondaryUpdate, CacheGlyphV2)
#define FREERDP_SECONDARY_UPDATE_CACHE_BRUSH MakeMessageId(SecondaryUpdate, CacheBrush)
/* Alternate Secondary Update */
#define AltSecUpdate_Class (Update_Base + 4)
#define AltSecUpdate_CreateOffscreenBitmap 1
#define AltSecUpdate_SwitchSurface 2
#define AltSecUpdate_CreateNineGridBitmap 3
#define AltSecUpdate_FrameMarker 4
#define AltSecUpdate_StreamBitmapFirst 5
#define AltSecUpdate_StreamBitmapNext 6
#define AltSecUpdate_DrawGdiPlusFirst 7
#define AltSecUpdate_DrawGdiPlusNext 8
#define AltSecUpdate_DrawGdiPlusEnd 9
#define AltSecUpdate_DrawGdiPlusCacheFirst 10
#define AltSecUpdate_DrawGdiPlusCacheNext 11
#define AltSecUpdate_DrawGdiPlusCacheEnd 12
#define FREERDP_ALTSEC_UPDATE_CREATE_OFFSCREEN_BITMAP MakeMessageId(AltSecUpdate, CreateOffscreenBitmap)
#define FREERDP_ALTSEC_UPDATE_SWITCH_SURFACE MakeMessageId(AltSecUpdate, SwitchSurface)
#define FREERDP_ALTSEC_UPDATE_CREATE_NINE_GRID_BITMAP MakeMessageId(AltSecUpdate, CreateNineGridBitmap)
#define FREERDP_ALTSEC_UPDATE_FRAME_MARKER MakeMessageId(AltSecUpdate, FrameMarker)
#define FREERDP_ALTSEC_UPDATE_STREAM_BITMAP_FIRST MakeMessageId(AltSecUpdate, StreamBitmapFirst)
#define FREERDP_ALTSEC_UPDATE_STREAM_BITMAP_NEXT MakeMessageId(AltSecUpdate, StreamBitmapNext)
#define FREERDP_ALTSEC_UPDATE_DRAW_GDI_PLUS_FIRST MakeMessageId(AltSecUpdate, DrawGdiPlusFirst)
#define FREERDP_ALTSEC_UPDATE_DRAW_GDI_PLUS_NEXT MakeMessageId(AltSecUpdate, DrawGdiPlusNext)
#define FREERDP_ALTSEC_UPDATE_DRAW_GDI_PLUS_END MakeMessageId(AltSecUpdate, DrawGdiPlusEnd)
#define FREERDP_ALTSEC_UPDATE_DRAW_GDI_PLUS_CACHE_FIRST MakeMessageId(AltSecUpdate, DrawGdiPlusCacheFirst)
#define FREERDP_ALTSEC_UPDATE_DRAW_GDI_PLUS_CACHE_NEXT MakeMessageId(AltSecUpdate, DrawGdiPlusCacheNext)
#define FREERDP_ALTSEC_UPDATE_DRAW_GDI_PLUS_CACHE_END MakeMessageId(AltSecUpdate, DrawGdiPlusCacheEnd)
/* Window Update */
#define WindowUpdate_Class (Update_Base + 5)
#define WindowUpdate_WindowCreate 1
#define WindowUpdate_WindowUpdate 2
#define WindowUpdate_WindowIcon 3
#define WindowUpdate_WindowCachedIcon 4
#define WindowUpdate_WindowDelete 5
#define WindowUpdate_NotifyIconCreate 6
#define WindowUpdate_NotifyIconUpdate 7
#define WindowUpdate_NotifyIconDelete 8
#define WindowUpdate_MonitoredDesktop 9
#define WindowUpdate_NonMonitoredDesktop 10
#define FREERDP_WINDOW_UPDATE_WINDOW_CREATE MakeMessageId(WindowUpdate, WindowCreate)
#define FREERDP_WINDOW_UPDATE_WINDOW_UPDATE MakeMessageId(WindowUpdate, WindowUpdate)
#define FREERDP_WINDOW_UPDATE_WINDOW_ICON MakeMessageId(WindowUpdate, WindowIcon)
#define FREERDP_WINDOW_UPDATE_WINDOW_CACHED_ICON MakeMessageId(WindowUpdate, WindowCachedIcon)
#define FREERDP_WINDOW_UPDATE_WINDOW_DELETE MakeMessageId(WindowUpdate, WindowDelete)
#define FREERDP_WINDOW_UPDATE_NOTIFY_ICON_CREATE MakeMessageId(WindowUpdate, NotifyIconCreate)
#define FREERDP_WINDOW_UPDATE_NOTIFY_ICON_UPDATE MakeMessageId(WindowUpdate, NotifyIconUpdate)
#define FREERDP_WINDOW_UPDATE_NOTIFY_ICON_DELETE MakeMessageId(WindowUpdate, NotifyIconDelete)
#define FREERDP_WINDOW_UPDATE_MONITORED_DESKTOP MakeMessageId(WindowUpdate, MonitoredDesktop)
#define FREERDP_WINDOW_UPDATE_NON_MONITORED_DESKTOP MakeMessageId(WindowUpdate, NonMonitoredDesktop)
/* Pointer Update */
#define PointerUpdate_Class (Update_Base + 6)
#define PointerUpdate_PointerPosition 1
#define PointerUpdate_PointerSystem 2
#define PointerUpdate_PointerColor 3
#define PointerUpdate_PointerNew 4
#define PointerUpdate_PointerCached 5
#define FREERDP_POINTER_UPDATE_ POINTER_POSITION MakeMessageId(PointerUpdate, PointerPosition)
#define FREERDP_POINTER_UPDATE_POINTER_SYSTEM MakeMessageId(PointerUpdate, PointerSystem)
#define FREERDP_POINTER_UPDATE_POINTER_COLOR MakeMessageId(PointerUpdate, PointerColor)
#define FREERDP_POINTER_UPDATE_POINTER_NEW MakeMessageId(PointerUpdate, PointerNew)
#define FREERDP_POINTER_UPDATE_POINTER_CACHED MakeMessageId(PointerUpdate, PointerCached)
/**
* Input Message Queue
*/
#define FREERDP_INPUT_MESSAGE_QUEUE 2
#define Input_Base 16
/* Input */
#define Input_Class (Input_Base + 1)
#define Input_SynchronizeEvent 1
#define Input_KeyboardEvent 2
#define Input_UnicodeKeyboardEvent 3
#define Input_MouseEvent 4
#define Input_ExtendedMouseEvent 5
#define FREERDP_INPUT_SYNCHRONIZE_EVENT MakeMessageId(Input, SynchronizeEvent)
#define FREERDP_INPUT_KEYBOARD_EVENT MakeMessageId(Input, KeyboardEvent)
#define FREERDP_INPUT_UNICODE_KEYBOARD_EVENT MakeMessageId(Input, UnicodeKeyboardEvent)
#define FREERDP_INPUT_MOUSE_EVENT MakeMessageId(Input, MouseEvent)
#define FREERDP_INPUT_EXTENDED_MOUSE_EVENT MakeMessageId(Input, ExtendedMouseEvent)
#endif /* FREERDP_CORE_MESSAGE_H */

View File

@ -28,6 +28,7 @@
#include "transport.h"
#include "connection.h"
#include "extension.h"
#include "message.h"
#include <winpr/crt.h>
@ -184,34 +185,71 @@ BOOL freerdp_check_fds(freerdp* instance)
return TRUE;
}
HANDLE freerdp_get_message_queue_event_handle(freerdp* instance)
wMessageQueue* freerdp_get_message_queue(freerdp* instance, DWORD id)
{
wMessageQueue* queue = NULL;
switch (id)
{
case FREERDP_UPDATE_MESSAGE_QUEUE:
queue = instance->update->queue;
break;
case FREERDP_INPUT_MESSAGE_QUEUE:
queue = instance->input->queue;
break;
}
return queue;
}
HANDLE freerdp_get_message_queue_event_handle(freerdp* instance, DWORD id)
{
HANDLE event = NULL;
wMessageQueue* queue = NULL;
if (instance->update->queue)
event = MessageQueue_Event(instance->update->queue);
queue = freerdp_get_message_queue(instance, id);
if (queue)
event = MessageQueue_Event(queue);
return event;
}
int freerdp_process_messages(freerdp* instance)
int freerdp_message_queue_process_message(freerdp* instance, DWORD id, wMessage* message)
{
return update_process_messages(instance->update);
int status = -1;
switch (id)
{
case FREERDP_UPDATE_MESSAGE_QUEUE:
status = update_message_queue_process_message(instance->update, message);
break;
case FREERDP_INPUT_MESSAGE_QUEUE:
status = input_message_queue_process_message(instance->input, message);
break;
}
HANDLE freerdp_get_input_queue_event_handle(freerdp* instance)
{
HANDLE event = NULL;
if (instance->input->queue)
event = MessageQueue_Event(instance->input->queue);
return event;
return status;
}
int freerdp_process_input(freerdp* instance)
int freerdp_message_queue_process_pending_messages(freerdp* instance, DWORD id)
{
return input_process_events(instance->input);
int status = -1;
switch (id)
{
case FREERDP_UPDATE_MESSAGE_QUEUE:
status = update_message_queue_process_pending_messages(instance->update);
break;
case FREERDP_INPUT_MESSAGE_QUEUE:
status = input_message_queue_process_pending_messages(instance->input);
break;
}
return status;
}
static int freerdp_send_channel_data(freerdp* instance, int channel_id, BYTE* data, int size)

View File

@ -432,7 +432,7 @@ void freerdp_input_send_extended_mouse_event(rdpInput* input, UINT16 flags, UINT
int input_process_events(rdpInput* input)
{
return input_message_process_pending_input(input);
return input_message_queue_process_pending_messages(input);
}
rdpInput* input_new(rdpRdp* rdp)

View File

@ -2,7 +2,7 @@
* FreeRDP: A Remote Desktop Protocol Implementation
* RDP Licensing
*
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2011-2013 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.
@ -28,7 +28,11 @@
#include "license.h"
//#define LICENSE_NULL_CLIENT_RANDOM 1
#define LICENSE_NULL_PREMASTER_SECRET 1
#ifdef WITH_DEBUG_LICENSE
static const char* const LICENSE_MESSAGE_STRINGS[] =
{
"",
@ -72,6 +76,41 @@ static const char* const state_transitions[] =
"ST_RESET_PHASE_TO_START",
"ST_RESEND_LAST_MESSAGE"
};
void license_print_product_info(PRODUCT_INFO* productInfo)
{
char* CompanyName = NULL;
char* ProductId = NULL;
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) productInfo->pbCompanyName,
productInfo->cbCompanyName / 2, &CompanyName, 0, NULL, NULL);
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) productInfo->pbProductId,
productInfo->cbProductId / 2, &ProductId, 0, NULL, NULL);
printf("ProductInfo:\n");
printf("\tdwVersion: 0x%08X\n", productInfo->dwVersion);
printf("\tCompanyName: %s\n", CompanyName);
printf("\tProductId: %s\n", ProductId);
free(CompanyName);
free(ProductId);
}
void license_print_scope_list(SCOPE_LIST* scopeList)
{
int index;
LICENSE_BLOB* scope;
printf("ScopeList (%d):\n", scopeList->count);
for (index = 0; index < scopeList->count; index++)
{
scope = &scopeList->array[index];
printf("\t%s\n", (char*) scope->data);
}
}
#endif
/**
@ -89,9 +128,11 @@ BOOL license_read_preamble(STREAM* s, BYTE* bMsgType, BYTE* flags, UINT16* wMsgS
/* preamble (4 bytes) */
if (stream_get_left(s) < 4)
return FALSE;
stream_read_BYTE(s, *bMsgType); /* bMsgType (1 byte) */
stream_read_BYTE(s, *flags); /* flags (1 byte) */
stream_read_UINT16(s, *wMsgSize); /* wMsgSize (2 bytes) */
return TRUE;
}
@ -121,8 +162,10 @@ void license_write_preamble(STREAM* s, BYTE bMsgType, BYTE flags, UINT16 wMsgSiz
STREAM* license_send_stream_init(rdpLicense* license)
{
STREAM* s;
s = transport_send_stream_init(license->rdp->transport, 4096);
stream_seek(s, LICENSE_PACKET_HEADER_MAX_LENGTH);
return s;
}
@ -147,6 +190,7 @@ BOOL license_send(rdpLicense* license, STREAM* s, BYTE type)
sec_flags = SEC_LICENSE_PKT;
wMsgSize = length - LICENSE_PACKET_HEADER_MAX_LENGTH + 4;
/**
* Using EXTENDED_ERROR_MSG_SUPPORTED here would cause mstsc to crash when
* running in server mode! This flag seems to be incorrectly documented.
@ -163,6 +207,7 @@ BOOL license_send(rdpLicense* license, STREAM* s, BYTE type)
#endif
stream_set_pos(s, length);
if (transport_write(license->rdp->transport, s) < 0)
return FALSE;
@ -179,12 +224,12 @@ BOOL license_send(rdpLicense* license, STREAM* s, BYTE type)
BOOL license_recv(rdpLicense* license, STREAM* s)
{
UINT16 length;
UINT16 channelId;
UINT16 sec_flags;
BYTE flags;
BYTE bMsgType;
UINT16 wMsgSize;
UINT16 length;
UINT16 channelId;
UINT16 securityFlags;
if (!rdp_read_header(license->rdp, s, &length, &channelId))
{
@ -192,17 +237,29 @@ BOOL license_recv(rdpLicense* license, STREAM* s)
return FALSE;
}
if (!rdp_read_security_header(s, &sec_flags))
if (!rdp_read_security_header(s, &securityFlags))
return FALSE;
if (!(sec_flags & SEC_LICENSE_PKT))
if (securityFlags & SEC_ENCRYPT)
{
if (!rdp_decrypt(license->rdp, s, length - 4, securityFlags))
{
printf("rdp_decrypt failed\n");
return FALSE;
}
}
if (!(securityFlags & SEC_LICENSE_PKT))
{
if (!(securityFlags & SEC_ENCRYPT))
stream_rewind(s, RDP_SECURITY_HEADER_LENGTH);
if (rdp_recv_out_of_sequence_pdu(license->rdp, s) != TRUE)
{
printf("Unexpected license packet.\n");
return FALSE;
}
return TRUE;
}
@ -248,12 +305,15 @@ BOOL license_recv(rdpLicense* license, STREAM* s)
void license_generate_randoms(rdpLicense* license)
{
#if 0
crypto_nonce(license->client_random, CLIENT_RANDOM_LENGTH); /* ClientRandom */
crypto_nonce(license->premaster_secret, PREMASTER_SECRET_LENGTH); /* PremasterSecret */
#else
memset(license->client_random, 0, CLIENT_RANDOM_LENGTH); /* ClientRandom */
memset(license->premaster_secret, 0, PREMASTER_SECRET_LENGTH); /* PremasterSecret */
ZeroMemory(license->ClientRandom, CLIENT_RANDOM_LENGTH); /* ClientRandom */
ZeroMemory(license->PremasterSecret, PREMASTER_SECRET_LENGTH); /* PremasterSecret */
#ifndef LICENSE_NULL_CLIENT_RANDOM
crypto_nonce(license->ClientRandom, CLIENT_RANDOM_LENGTH); /* ClientRandom */
#endif
#ifndef LICENSE_NULL_PREMASTER_SECRET
crypto_nonce(license->PremasterSecret, PREMASTER_SECRET_LENGTH); /* PremasterSecret */
#endif
}
@ -264,39 +324,46 @@ void license_generate_randoms(rdpLicense* license)
void license_generate_keys(rdpLicense* license)
{
security_master_secret(license->premaster_secret, license->client_random,
license->server_random, license->master_secret); /* MasterSecret */
security_master_secret(license->PremasterSecret, license->ClientRandom,
license->ServerRandom, license->MasterSecret); /* MasterSecret */
security_session_key_blob(license->master_secret, license->client_random,
license->server_random, license->session_key_blob); /* SessionKeyBlob */
security_session_key_blob(license->MasterSecret, license->ClientRandom,
license->ServerRandom, license->SessionKeyBlob); /* SessionKeyBlob */
security_mac_salt_key(license->session_key_blob, license->client_random,
license->server_random, license->mac_salt_key); /* MacSaltKey */
security_mac_salt_key(license->SessionKeyBlob, license->ClientRandom,
license->ServerRandom, license->MacSaltKey); /* MacSaltKey */
security_licensing_encryption_key(license->session_key_blob, license->client_random,
license->server_random, license->licensing_encryption_key); /* LicensingEncryptionKey */
security_licensing_encryption_key(license->SessionKeyBlob, license->ClientRandom,
license->ServerRandom, license->LicensingEncryptionKey); /* LicensingEncryptionKey */
#ifdef WITH_DEBUG_LICENSE
printf("ClientRandom:\n");
winpr_HexDump(license->client_random, CLIENT_RANDOM_LENGTH);
winpr_HexDump(license->ClientRandom, CLIENT_RANDOM_LENGTH);
printf("\n");
printf("ServerRandom:\n");
winpr_HexDump(license->server_random, SERVER_RANDOM_LENGTH);
winpr_HexDump(license->ServerRandom, SERVER_RANDOM_LENGTH);
printf("\n");
printf("PremasterSecret:\n");
winpr_HexDump(license->premaster_secret, PREMASTER_SECRET_LENGTH);
winpr_HexDump(license->PremasterSecret, PREMASTER_SECRET_LENGTH);
printf("\n");
printf("MasterSecret:\n");
winpr_HexDump(license->master_secret, MASTER_SECRET_LENGTH);
winpr_HexDump(license->MasterSecret, MASTER_SECRET_LENGTH);
printf("\n");
printf("SessionKeyBlob:\n");
winpr_HexDump(license->session_key_blob, SESSION_KEY_BLOB_LENGTH);
winpr_HexDump(license->SessionKeyBlob, SESSION_KEY_BLOB_LENGTH);
printf("\n");
printf("MacSaltKey:\n");
winpr_HexDump(license->mac_salt_key, MAC_SALT_KEY_LENGTH);
winpr_HexDump(license->MacSaltKey, MAC_SALT_KEY_LENGTH);
printf("\n");
printf("LicensingEncryptionKey:\n");
winpr_HexDump(license->licensing_encryption_key, LICENSING_ENCRYPTION_KEY_LENGTH);
winpr_HexDump(license->LicensingEncryptionKey, LICENSING_ENCRYPTION_KEY_LENGTH);
printf("\n");
#endif
}
@ -310,82 +377,79 @@ void license_generate_hwid(rdpLicense* license)
CryptoMd5 md5;
BYTE* mac_address;
memset(license->hwid, 0, HWID_LENGTH);
ZeroMemory(license->HardwareId, HWID_LENGTH);
mac_address = license->rdp->transport->TcpIn->mac_address;
md5 = crypto_md5_init();
crypto_md5_update(md5, mac_address, 6);
crypto_md5_final(md5, &license->hwid[HWID_PLATFORM_ID_LENGTH]);
crypto_md5_final(md5, &license->HardwareId[HWID_PLATFORM_ID_LENGTH]);
}
void license_get_server_rsa_public_key(rdpLicense* license)
{
BYTE* Exponent;
BYTE* Modulus;
int ModulusLength;
if (license->ServerCertificate->length < 1)
{
certificate_read_server_certificate(license->certificate,
license->rdp->settings->ServerCertificate,
license->rdp->settings->ServerCertificateLength);
}
Exponent = license->certificate->cert_info.exponent;
Modulus = license->certificate->cert_info.Modulus;
ModulusLength = license->certificate->cert_info.ModulusLength;
CopyMemory(license->Exponent, Exponent, 4);
license->ModulusLength = ModulusLength;
license->Modulus = (BYTE*) malloc(ModulusLength);
ZeroMemory(license->Modulus, ModulusLength);
}
void license_encrypt_premaster_secret(rdpLicense* license)
{
BYTE* encrypted_premaster_secret;
#if 0
int key_length;
BYTE* modulus;
BYTE* exponent;
rdpCertificate *certificate;
BYTE* EncryptedPremasterSecret;
if (license->server_certificate->length)
certificate = license->certificate;
else
certificate = license->rdp->settings->server_cert;
exponent = certificate->cert_info.exponent;
modulus = certificate->cert_info.modulus.data;
key_length = certificate->cert_info.modulus.length;
license_get_server_rsa_public_key(license);
#ifdef WITH_DEBUG_LICENSE
printf("modulus (%d bits):\n", key_length * 8);
winpr_HexDump(modulus, key_length);
printf("Modulus (%d bits):\n", license->ModulusLength * 8);
winpr_HexDump(license->Modulus, license->ModulusLength);
printf("\n");
printf("exponent:\n");
winpr_HexDump(exponent, 4);
printf("Exponent:\n");
winpr_HexDump(license->Exponent, 4);
printf("\n");
#endif
encrypted_premaster_secret = (BYTE*) malloc(MODULUS_MAX_SIZE);
memset(encrypted_premaster_secret, 0, MODULUS_MAX_SIZE);
EncryptedPremasterSecret = (BYTE*) malloc(license->ModulusLength);
ZeroMemory(EncryptedPremasterSecret, license->ModulusLength);
crypto_rsa_public_encrypt(license->premaster_secret, PREMASTER_SECRET_LENGTH,
key_length, modulus, exponent, encrypted_premaster_secret);
license->encrypted_premaster_secret->type = BB_RANDOM_BLOB;
license->encrypted_premaster_secret->length = PREMASTER_SECRET_LENGTH;
license->encrypted_premaster_secret->data = encrypted_premaster_secret;
#else
encrypted_premaster_secret = (BYTE*) malloc(MODULUS_MAX_SIZE);
memset(encrypted_premaster_secret, 0, MODULUS_MAX_SIZE);
license->encrypted_premaster_secret->type = BB_RANDOM_BLOB;
license->encrypted_premaster_secret->length = PREMASTER_SECRET_LENGTH;
license->encrypted_premaster_secret->data = encrypted_premaster_secret;
#ifndef LICENSE_NULL_PREMASTER_SECRET
crypto_rsa_public_encrypt(license->PremasterSecret, PREMASTER_SECRET_LENGTH,
license->ModulusLength, license->Modulus, license->Exponent, EncryptedPremasterSecret);
#endif
license->EncryptedPremasterSecret->type = BB_RANDOM_BLOB;
license->EncryptedPremasterSecret->length = PREMASTER_SECRET_LENGTH;
license->EncryptedPremasterSecret->data = EncryptedPremasterSecret;
}
void license_decrypt_platform_challenge(rdpLicense* license)
{
CryptoRc4 rc4;
license->platform_challenge->data =
(BYTE*) malloc(license->encrypted_platform_challenge->length);
license->platform_challenge->length =
license->encrypted_platform_challenge->length;
license->PlatformChallenge->data = (BYTE*) malloc(license->EncryptedPlatformChallenge->length);
license->PlatformChallenge->length = license->EncryptedPlatformChallenge->length;
rc4 = crypto_rc4_init(license->licensing_encryption_key, LICENSING_ENCRYPTION_KEY_LENGTH);
rc4 = crypto_rc4_init(license->LicensingEncryptionKey, LICENSING_ENCRYPTION_KEY_LENGTH);
crypto_rc4(rc4, license->encrypted_platform_challenge->length,
license->encrypted_platform_challenge->data,
license->platform_challenge->data);
#ifdef WITH_DEBUG_LICENSE
printf("encrypted_platform challenge:\n");
winpr_HexDump(license->encrypted_platform_challenge->data,
license->encrypted_platform_challenge->length);
printf("platform challenge:\n");
winpr_HexDump(license->platform_challenge->data, license->platform_challenge->length);
#endif
crypto_rc4(rc4, license->EncryptedPlatformChallenge->length,
license->EncryptedPlatformChallenge->data,
license->PlatformChallenge->data);
crypto_rc4_free(rc4);
}
@ -401,9 +465,11 @@ BOOL license_read_product_info(STREAM* s, PRODUCT_INFO* productInfo)
{
if (stream_get_left(s) < 8)
return FALSE;
stream_read_UINT32(s, productInfo->dwVersion); /* dwVersion (4 bytes) */
stream_read_UINT32(s, productInfo->cbCompanyName); /* cbCompanyName (4 bytes) */
if (stream_get_left(s) < productInfo->cbCompanyName + 4)
return FALSE;
@ -411,6 +477,7 @@ BOOL license_read_product_info(STREAM* s, PRODUCT_INFO* productInfo)
stream_read(s, productInfo->pbCompanyName, productInfo->cbCompanyName);
stream_read_UINT32(s, productInfo->cbProductId); /* cbProductId (4 bytes) */
if (stream_get_left(s) < productInfo->cbProductId)
{
free(productInfo->pbCompanyName);
@ -420,6 +487,7 @@ BOOL license_read_product_info(STREAM* s, PRODUCT_INFO* productInfo)
productInfo->pbProductId = (BYTE*) malloc(productInfo->cbProductId);
stream_read(s, productInfo->pbProductId, productInfo->cbProductId);
return TRUE;
}
@ -474,6 +542,7 @@ BOOL license_read_binary_blob(STREAM* s, LICENSE_BLOB* blob)
if (stream_get_left(s) < 4)
return FALSE;
stream_read_UINT16(s, wBlobType); /* wBlobType (2 bytes) */
stream_read_UINT16(s, blob->length); /* wBlobLen (2 bytes) */
@ -481,13 +550,13 @@ BOOL license_read_binary_blob(STREAM* s, LICENSE_BLOB* blob)
return FALSE;
/*
* Server can choose to not send data by setting len to 0.
* Server can choose to not send data by setting length to 0.
* If so, it may not bother to set the type, so shortcut the warning
*/
if (blob->type != BB_ANY_BLOB && blob->length == 0)
if ((blob->type != BB_ANY_BLOB) && (blob->length == 0))
return TRUE;
if (blob->type != wBlobType && blob->type != BB_ANY_BLOB)
if ((blob->type != wBlobType) && (blob->type != BB_ANY_BLOB))
{
printf("license binary blob type (%x) does not match expected type (%x).\n", wBlobType, blob->type);
}
@ -515,18 +584,25 @@ void license_write_binary_blob(STREAM* s, LICENSE_BLOB* blob)
stream_write(s, blob->data, blob->length); /* blobData */
}
void license_write_padded_binary_blob(STREAM* s, LICENSE_BLOB* blob)
void license_write_encrypted_premaster_secret_blob(STREAM* s, LICENSE_BLOB* blob, UINT32 ModulusLength)
{
UINT16 pad_len;
UINT32 length;
length = ModulusLength + 8;
if (blob->length > ModulusLength)
{
printf("license_write_encrypted_premaster_secret_blob: invalid blob\n");
return;
}
pad_len = 72 % blob->length;
stream_write_UINT16(s, blob->type); /* wBlobType (2 bytes) */
stream_write_UINT16(s, blob->length + pad_len); /* wBlobLen (2 bytes) */
stream_write_UINT16(s, length); /* wBlobLen (2 bytes) */
if (blob->length > 0)
stream_write(s, blob->data, blob->length); /* blobData */
stream_write_zero(s, pad_len);
stream_write_zero(s, length - blob->length);
}
/**
@ -575,6 +651,7 @@ BOOL license_read_scope_list(STREAM* s, SCOPE_LIST* scopeList)
if (stream_get_left(s) < 4)
return FALSE;
stream_read_UINT32(s, scopeCount); /* ScopeCount (4 bytes) */
scopeList->count = scopeCount;
@ -584,9 +661,11 @@ BOOL license_read_scope_list(STREAM* s, SCOPE_LIST* scopeList)
for (i = 0; i < scopeCount; i++)
{
scopeList->array[i].type = BB_SCOPE_BLOB;
if (!license_read_binary_blob(s, &scopeList->array[i]))
return FALSE;
}
return TRUE;
}
@ -646,33 +725,45 @@ BOOL license_read_license_request_packet(rdpLicense* license, STREAM* s)
if (stream_get_left(s) < 32)
return FALSE;
stream_read(s, license->server_random, 32);
stream_read(s, license->ServerRandom, 32);
/* ProductInfo */
if (!license_read_product_info(s, license->product_info))
if (!license_read_product_info(s, license->ProductInfo))
return FALSE;
/* KeyExchangeList */
if (!license_read_binary_blob(s, license->key_exchange_list))
if (!license_read_binary_blob(s, license->KeyExchangeList))
return FALSE;
/* ServerCertificate */
if (!license_read_binary_blob(s, license->server_certificate))
if (!license_read_binary_blob(s, license->ServerCertificate))
return FALSE;
/* ScopeList */
if (!license_read_scope_list(s, license->scope_list))
if (!license_read_scope_list(s, license->ScopeList))
return FALSE;
/* Parse Server Certificate */
if (!certificate_read_server_certificate(license->certificate,
license->server_certificate->data, license->server_certificate->length) < 0)
license->ServerCertificate->data, license->ServerCertificate->length) < 0)
return FALSE;
license_generate_keys(license);
license_generate_hwid(license);
license_encrypt_premaster_secret(license);
#ifdef WITH_DEBUG_LICENSE
printf("ServerRandom:\n");
winpr_HexDump(license->ServerRandom, 32);
printf("\n");
license_print_product_info(license->ProductInfo);
printf("\n");
license_print_scope_list(license->ScopeList);
printf("\n");
#endif
return TRUE;
}
@ -685,21 +776,45 @@ BOOL license_read_license_request_packet(rdpLicense* license, STREAM* s)
BOOL license_read_platform_challenge_packet(rdpLicense* license, STREAM* s)
{
BYTE MacData[16];
UINT32 ConnectFlags = 0;
DEBUG_LICENSE("Receiving Platform Challenge Packet");
if (stream_get_left(s) < 4)
return FALSE;
stream_seek(s, 4); /* ConnectFlags, Reserved (4 bytes) */
stream_read_UINT32(s, ConnectFlags); /* ConnectFlags, Reserved (4 bytes) */
/* EncryptedPlatformChallenge */
license->encrypted_platform_challenge->type = BB_ANY_BLOB;
license_read_binary_blob(s, license->encrypted_platform_challenge);
license->encrypted_platform_challenge->type = BB_ENCRYPTED_DATA_BLOB;
license->EncryptedPlatformChallenge->type = BB_ANY_BLOB;
license_read_binary_blob(s, license->EncryptedPlatformChallenge);
license->EncryptedPlatformChallenge->type = BB_ENCRYPTED_DATA_BLOB;
/* MACData (16 bytes) */
if(!stream_skip(s, 16))
if (stream_get_left(s) < 16)
return FALSE;
stream_read(s, MacData, 16); /* MACData (16 bytes) */
license_decrypt_platform_challenge(license);
#ifdef WITH_DEBUG_LICENSE
printf("ConnectFlags: 0x%08X\n", ConnectFlags);
printf("\n");
printf("EncryptedPlatformChallenge:\n");
winpr_HexDump(license->EncryptedPlatformChallenge->data, license->EncryptedPlatformChallenge->length);
printf("\n");
printf("PlatformChallenge:\n");
winpr_HexDump(license->PlatformChallenge->data, license->PlatformChallenge->length);
printf("\n");
printf("MacData:\n");
winpr_HexDump(MacData, 16);
printf("\n");
#endif
return TRUE;
}
@ -743,9 +858,11 @@ BOOL license_read_error_alert_packet(rdpLicense* license, STREAM* s)
if (stream_get_left(s) < 8)
return FALSE;
stream_read_UINT32(s, dwErrorCode); /* dwErrorCode (4 bytes) */
stream_read_UINT32(s, dwStateTransition); /* dwStateTransition (4 bytes) */
if(!license_read_binary_blob(s, license->error_info)) /* bbErrorInfo */
if (!license_read_binary_blob(s, license->ErrorInfo)) /* bbErrorInfo */
return FALSE;
#ifdef WITH_DEBUG_LICENSE
@ -779,23 +896,10 @@ BOOL license_read_error_alert_packet(rdpLicense* license, STREAM* s)
default:
break;
}
return TRUE;
}
/**
* Write Platform ID.\n
* @msdn{cc241918}
* @param license license module
* @param s stream
*/
void license_write_platform_id(rdpLicense* license, STREAM* s)
{
stream_write_BYTE(s, 0); /* Client Operating System Version */
stream_write_BYTE(s, 0); /* Independent Software Vendor (ISV) */
stream_write_UINT16(s, 0); /* Client Software Build */
}
/**
* Write a NEW_LICENSE_REQUEST packet.\n
* @msdn{cc241918}
@ -805,12 +909,36 @@ void license_write_platform_id(rdpLicense* license, STREAM* s)
void license_write_new_license_request_packet(rdpLicense* license, STREAM* s)
{
stream_write_UINT32(s, KEY_EXCHANGE_ALG_RSA); /* PreferredKeyExchangeAlg (4 bytes) */
license_write_platform_id(license, s); /* PlatformId (4 bytes) */
stream_write(s, license->client_random, 32); /* ClientRandom (32 bytes) */
license_write_padded_binary_blob(s, license->encrypted_premaster_secret); /* EncryptedPremasterSecret */
license_write_binary_blob(s, license->client_user_name); /* ClientUserName */
license_write_binary_blob(s, license->client_machine_name); /* ClientMachineName */
UINT32 PlatformId;
UINT32 PreferredKeyExchangeAlg = KEY_EXCHANGE_ALG_RSA;
PlatformId = CLIENT_OS_ID_WINNT_POST_52 | CLIENT_IMAGE_ID_MICROSOFT;
stream_write_UINT32(s, PreferredKeyExchangeAlg); /* PreferredKeyExchangeAlg (4 bytes) */
stream_write_UINT32(s, PlatformId); /* PlatformId (4 bytes) */
stream_write(s, license->ClientRandom, 32); /* ClientRandom (32 bytes) */
license_write_encrypted_premaster_secret_blob(s, license->EncryptedPremasterSecret, license->ModulusLength); /* EncryptedPremasterSecret */
license_write_binary_blob(s, license->ClientUserName); /* ClientUserName */
license_write_binary_blob(s, license->ClientMachineName); /* ClientMachineName */
#ifdef WITH_DEBUG_LICENSE
printf("PreferredKeyExchangeAlg: 0x%08X\n", PreferredKeyExchangeAlg);
printf("\n");
printf("ClientRandom:\n");
winpr_HexDump(license->ClientRandom, 32);
printf("\n");
printf("EncryptedPremasterSecret\n");
winpr_HexDump(license->EncryptedPremasterSecret->data, license->EncryptedPremasterSecret->length);
printf("\n");
printf("ClientUserName (%d): %s\n", license->ClientUserName->length, (char*) license->ClientUserName->data);
printf("\n");
printf("ClientMachineName (%d): %s\n", license->ClientMachineName->length, (char*) license->ClientMachineName->data);
printf("\n");
#endif
}
/**
@ -824,6 +952,8 @@ void license_send_new_license_request_packet(rdpLicense* license)
STREAM* s;
char* username;
DEBUG_LICENSE("Sending New License Packet");
s = license_send_stream_init(license);
if (license->rdp->settings->Username != NULL)
@ -831,21 +961,21 @@ void license_send_new_license_request_packet(rdpLicense* license)
else
username = "username";
license->client_user_name->data = (BYTE*) username;
license->client_user_name->length = strlen(username) + 1;
license->ClientUserName->data = (BYTE*) username;
license->ClientUserName->length = strlen(username) + 1;
license->client_machine_name->data = (BYTE*) license->rdp->settings->ClientHostname;
license->client_machine_name->length = strlen(license->rdp->settings->ClientHostname) + 1;
license->ClientMachineName->data = (BYTE*) license->rdp->settings->ClientHostname;
license->ClientMachineName->length = strlen(license->rdp->settings->ClientHostname) + 1;
license_write_new_license_request_packet(license, s);
license_send(license, s, NEW_LICENSE_REQUEST);
license->client_user_name->data = NULL;
license->client_user_name->length = 0;
license->ClientUserName->data = NULL;
license->ClientUserName->length = 0;
license->client_machine_name->data = NULL;
license->client_machine_name->length = 0;
license->ClientMachineName->data = NULL;
license->ClientMachineName->length = 0;
}
/**
@ -856,16 +986,11 @@ void license_send_new_license_request_packet(rdpLicense* license)
* @param mac_data signature
*/
void license_write_platform_challenge_response_packet(rdpLicense* license, STREAM* s, BYTE* mac_data)
void license_write_platform_challenge_response_packet(rdpLicense* license, STREAM* s, BYTE* macData)
{
/* EncryptedPlatformChallengeResponse */
license_write_binary_blob(s, license->encrypted_platform_challenge);
/* EncryptedHWID */
license_write_binary_blob(s, license->encrypted_hwid);
/* MACData */
stream_write(s, mac_data, 16);
license_write_binary_blob(s, license->EncryptedPlatformChallenge); /* EncryptedPlatformChallengeResponse */
license_write_binary_blob(s, license->EncryptedHardwareId); /* EncryptedHWID */
stream_write(s, macData, 16); /* MACData */
}
/**
@ -882,37 +1007,42 @@ void license_send_platform_challenge_response_packet(rdpLicense* license)
CryptoRc4 rc4;
BYTE mac_data[16];
s = license_send_stream_init(license);
DEBUG_LICENSE("Sending Platform Challenge Response Packet");
license->encrypted_platform_challenge->type = BB_DATA_BLOB;
length = license->platform_challenge->length + HWID_LENGTH;
s = license_send_stream_init(license);
license->EncryptedPlatformChallenge->type = BB_DATA_BLOB;
length = license->PlatformChallenge->length + HWID_LENGTH;
buffer = (BYTE*) malloc(length);
memcpy(buffer, license->platform_challenge->data, license->platform_challenge->length);
memcpy(&buffer[license->platform_challenge->length], license->hwid, HWID_LENGTH);
security_mac_data(license->mac_salt_key, buffer, length, mac_data);
CopyMemory(buffer, license->PlatformChallenge->data, license->PlatformChallenge->length);
CopyMemory(&buffer[license->PlatformChallenge->length], license->HardwareId, HWID_LENGTH);
security_mac_data(license->MacSaltKey, buffer, length, mac_data);
free(buffer);
buffer = (BYTE*) malloc(HWID_LENGTH);
rc4 = crypto_rc4_init(license->licensing_encryption_key, LICENSING_ENCRYPTION_KEY_LENGTH);
crypto_rc4(rc4, HWID_LENGTH, license->hwid, buffer);
rc4 = crypto_rc4_init(license->LicensingEncryptionKey, LICENSING_ENCRYPTION_KEY_LENGTH);
crypto_rc4(rc4, HWID_LENGTH, license->HardwareId, buffer);
crypto_rc4_free(rc4);
license->EncryptedHardwareId->type = BB_DATA_BLOB;
license->EncryptedHardwareId->data = buffer;
license->EncryptedHardwareId->length = HWID_LENGTH;
#ifdef WITH_DEBUG_LICENSE
printf("LicensingEncryptionKey:\n");
winpr_HexDump(license->licensing_encryption_key, 16);
winpr_HexDump(license->LicensingEncryptionKey, 16);
printf("\n");
printf("HardwareID:\n");
winpr_HexDump(license->hwid, 20);
printf("HardwareId:\n");
winpr_HexDump(license->HardwareId, 20);
printf("\n");
printf("Encrypted HardwareID:\n");
winpr_HexDump(buffer, 20);
printf("EncryptedHardwareId:\n");
winpr_HexDump(license->EncryptedHardwareId->data, 20);
printf("\n");
#endif
license->encrypted_hwid->type = BB_DATA_BLOB;
license->encrypted_hwid->data = buffer;
license->encrypted_hwid->length = HWID_LENGTH;
license_write_platform_challenge_response_packet(license, s, mac_data);
license_send(license, s, PLATFORM_CHALLENGE_RESPONSE);
@ -930,10 +1060,12 @@ BOOL license_send_valid_client_error_packet(rdpLicense* license)
s = license_send_stream_init(license);
DEBUG_LICENSE("Sending Error Alert Packet");
stream_write_UINT32(s, STATUS_VALID_CLIENT); /* dwErrorCode */
stream_write_UINT32(s, ST_NO_TRANSITION); /* dwStateTransition */
license_write_binary_blob(s, license->error_info);
license_write_binary_blob(s, license->ErrorInfo);
return license_send(license, s, ERROR_ALERT);
}
@ -956,19 +1088,18 @@ rdpLicense* license_new(rdpRdp* rdp)
license->rdp = rdp;
license->state = LICENSE_STATE_AWAIT;
//license->certificate = certificate_new(rdp);
license->certificate = certificate_new();
license->product_info = license_new_product_info();
license->error_info = license_new_binary_blob(BB_ERROR_BLOB);
license->key_exchange_list = license_new_binary_blob(BB_KEY_EXCHG_ALG_BLOB);
license->server_certificate = license_new_binary_blob(BB_CERTIFICATE_BLOB);
license->client_user_name = license_new_binary_blob(BB_CLIENT_USER_NAME_BLOB);
license->client_machine_name = license_new_binary_blob(BB_CLIENT_MACHINE_NAME_BLOB);
license->platform_challenge = license_new_binary_blob(BB_ANY_BLOB);
license->encrypted_platform_challenge = license_new_binary_blob(BB_ANY_BLOB);
license->encrypted_premaster_secret = license_new_binary_blob(BB_ANY_BLOB);
license->encrypted_hwid = license_new_binary_blob(BB_ENCRYPTED_DATA_BLOB);
license->scope_list = license_new_scope_list();
license->ProductInfo = license_new_product_info();
license->ErrorInfo = license_new_binary_blob(BB_ERROR_BLOB);
license->KeyExchangeList = license_new_binary_blob(BB_KEY_EXCHG_ALG_BLOB);
license->ServerCertificate = license_new_binary_blob(BB_CERTIFICATE_BLOB);
license->ClientUserName = license_new_binary_blob(BB_CLIENT_USER_NAME_BLOB);
license->ClientMachineName = license_new_binary_blob(BB_CLIENT_MACHINE_NAME_BLOB);
license->PlatformChallenge = license_new_binary_blob(BB_ANY_BLOB);
license->EncryptedPlatformChallenge = license_new_binary_blob(BB_ANY_BLOB);
license->EncryptedPremasterSecret = license_new_binary_blob(BB_ANY_BLOB);
license->EncryptedHardwareId = license_new_binary_blob(BB_ENCRYPTED_DATA_BLOB);
license->ScopeList = license_new_scope_list();
license_generate_randoms(license);
}
@ -982,21 +1113,21 @@ rdpLicense* license_new(rdpRdp* rdp)
void license_free(rdpLicense* license)
{
if (license != NULL)
if (license)
{
free(license->Modulus);
certificate_free(license->certificate);
license_free_product_info(license->product_info);
license_free_binary_blob(license->error_info);
license_free_binary_blob(license->key_exchange_list);
license_free_binary_blob(license->server_certificate);
license_free_binary_blob(license->client_user_name);
license_free_binary_blob(license->client_machine_name);
license_free_binary_blob(license->platform_challenge);
license_free_binary_blob(license->encrypted_platform_challenge);
license_free_binary_blob(license->encrypted_premaster_secret);
license_free_binary_blob(license->encrypted_hwid);
license_free_scope_list(license->scope_list);
license_free_product_info(license->ProductInfo);
license_free_binary_blob(license->ErrorInfo);
license_free_binary_blob(license->KeyExchangeList);
license_free_binary_blob(license->ServerCertificate);
license_free_binary_blob(license->ClientUserName);
license_free_binary_blob(license->ClientMachineName);
license_free_binary_blob(license->PlatformChallenge);
license_free_binary_blob(license->EncryptedPlatformChallenge);
license_free_binary_blob(license->EncryptedPremasterSecret);
license_free_binary_blob(license->EncryptedHardwareId);
license_free_scope_list(license->ScopeList);
free(license);
}
}

View File

@ -31,6 +31,7 @@ typedef struct rdp_license rdpLicense;
#include <freerdp/utils/stream.h>
/* Licensing Packet Types */
#define LICENSE_REQUEST 0x01
#define PLATFORM_CHALLENGE 0x02
#define NEW_LICENSE 0x03
@ -48,6 +49,7 @@ typedef struct rdp_license rdpLicense;
#define LICENSE_PACKET_HEADER_MAX_LENGTH (RDP_PACKET_HEADER_MAX_LENGTH + RDP_SECURITY_HEADER_LENGTH + LICENSE_PREAMBLE_LENGTH)
/* Cryptographic Lengths */
#define CLIENT_RANDOM_LENGTH 32
#define SERVER_RANDOM_LENGTH 32
#define MASTER_SECRET_LENGTH 48
@ -60,13 +62,15 @@ typedef struct rdp_license rdpLicense;
#define HWID_LENGTH 20
#define LICENSING_PADDING_SIZE 8
/* Licensing Preamble Flags */
/* Preamble Flags */
#define PREAMBLE_VERSION_2_0 0x02
#define PREAMBLE_VERSION_3_0 0x03
#define LicenseProtocolVersionMask 0x0F
#define EXTENDED_ERROR_MSG_SUPPORTED 0x80
/* Licensing Binary Blob Types */
/* Binary Blob Types */
#define BB_ANY_BLOB 0x0000
#define BB_DATA_BLOB 0x0001
#define BB_RANDOM_BLOB 0x0002
@ -78,10 +82,12 @@ typedef struct rdp_license rdpLicense;
#define BB_CLIENT_USER_NAME_BLOB 0x000F
#define BB_CLIENT_MACHINE_NAME_BLOB 0x0010
/* Key Exchange Algorithms */
/* License Key Exchange Algorithms */
#define KEY_EXCHANGE_ALG_RSA 0x00000001
/* Licensing Error Codes */
/* License Error Codes */
#define ERR_INVALID_SERVER_CERTIFICATE 0x00000001
#define ERR_NO_LICENSE 0x00000002
#define ERR_INVALID_MAC 0x00000003
@ -92,12 +98,47 @@ typedef struct rdp_license rdpLicense;
#define ERR_INVALID_PRODUCT_ID 0x0000000B
#define ERR_INVALID_MESSAGE_LENGTH 0x0000000C
/* Licensing State Transition Codes */
/* State Transition Codes */
#define ST_TOTAL_ABORT 0x00000001
#define ST_NO_TRANSITION 0x00000002
#define ST_RESET_PHASE_TO_START 0x00000003
#define ST_RESEND_LAST_MESSAGE 0x00000004
/* Platform Challenge Types */
#define WIN32_PLATFORM_CHALLENGE_TYPE 0x0100
#define WIN16_PLATFORM_CHALLENGE_TYPE 0x0200
#define WINCE_PLATFORM_CHALLENGE_TYPE 0x0300
#define OTHER_PLATFORM_CHALLENGE_TYPE 0xFF00
/* License Detail Levels */
#define LICENSE_DETAIL_SIMPLE 0x0001
#define LICENSE_DETAIL_MODERATE 0x0002
#define LICENSE_DETAIL_DETAIL 0x0003
/*
* PlatformId:
*
* The most significant byte of the PlatformId field contains the operating system version of the client.
* The second most significant byte of the PlatformId field identifies the ISV that provided the client image.
* The remaining two bytes in the PlatformId field are used by the ISV to identify the build number of the operating system.
*
* 0x04010000:
*
* CLIENT_OS_ID_WINNT_POST_52 (0x04000000)
* CLIENT_IMAGE_ID_MICROSOFT (0x00010000)
*/
#define CLIENT_OS_ID_WINNT_351 0x01000000
#define CLIENT_OS_ID_WINNT_40 0x02000000
#define CLIENT_OS_ID_WINNT_50 0x03000000
#define CLIENT_OS_ID_WINNT_POST_52 0x04000000
#define CLIENT_IMAGE_ID_MICROSOFT 0x00010000
#define CLIENT_IMAGE_ID_CITRIX 0x00020000
typedef struct
{
UINT32 dwVersion;
@ -131,29 +172,30 @@ typedef enum
struct rdp_license
{
LICENSE_STATE state;
struct rdp_rdp* rdp;
struct rdp_certificate* certificate;
BYTE hwid[HWID_LENGTH];
BYTE modulus[MODULUS_MAX_SIZE];
BYTE exponent[EXPONENT_MAX_SIZE];
BYTE client_random[CLIENT_RANDOM_LENGTH];
BYTE server_random[SERVER_RANDOM_LENGTH];
BYTE master_secret[MASTER_SECRET_LENGTH];
BYTE premaster_secret[PREMASTER_SECRET_LENGTH];
BYTE session_key_blob[SESSION_KEY_BLOB_LENGTH];
BYTE mac_salt_key[MAC_SALT_KEY_LENGTH];
BYTE licensing_encryption_key[LICENSING_ENCRYPTION_KEY_LENGTH];
PRODUCT_INFO* product_info;
LICENSE_BLOB* error_info;
LICENSE_BLOB* key_exchange_list;
LICENSE_BLOB* server_certificate;
LICENSE_BLOB* client_user_name;
LICENSE_BLOB* client_machine_name;
LICENSE_BLOB* platform_challenge;
LICENSE_BLOB* encrypted_premaster_secret;
LICENSE_BLOB* encrypted_platform_challenge;
LICENSE_BLOB* encrypted_hwid;
SCOPE_LIST* scope_list;
rdpRdp* rdp;
rdpCertificate* certificate;
BYTE* Modulus;
UINT32 ModulusLength;
BYTE Exponent[4];
BYTE HardwareId[HWID_LENGTH];
BYTE ClientRandom[CLIENT_RANDOM_LENGTH];
BYTE ServerRandom[SERVER_RANDOM_LENGTH];
BYTE MasterSecret[MASTER_SECRET_LENGTH];
BYTE PremasterSecret[PREMASTER_SECRET_LENGTH];
BYTE SessionKeyBlob[SESSION_KEY_BLOB_LENGTH];
BYTE MacSaltKey[MAC_SALT_KEY_LENGTH];
BYTE LicensingEncryptionKey[LICENSING_ENCRYPTION_KEY_LENGTH];
PRODUCT_INFO* ProductInfo;
LICENSE_BLOB* ErrorInfo;
LICENSE_BLOB* KeyExchangeList;
LICENSE_BLOB* ServerCertificate;
LICENSE_BLOB* ClientUserName;
LICENSE_BLOB* ClientMachineName;
LICENSE_BLOB* PlatformChallenge;
LICENSE_BLOB* EncryptedPremasterSecret;
LICENSE_BLOB* EncryptedPlatformChallenge;
LICENSE_BLOB* EncryptedHardwareId;
SCOPE_LIST* ScopeList;
};
BOOL license_recv(rdpLicense* license, STREAM* s);

View File

@ -1482,11 +1482,29 @@ int update_message_process_class(rdpUpdateProxy* proxy, wMessage* msg, int msgCl
return status;
}
int update_message_process_pending_updates(rdpUpdate* update)
int update_message_queue_process_message(rdpUpdate* update, wMessage* message)
{
int status;
int msgClass;
int msgType;
if (message->id == WMQ_QUIT)
return 0;
msgClass = GetMessageClass(message->id);
msgType = GetMessageType(message->id);
status = update_message_process_class(update->proxy, message, msgClass, msgType);
if (status < 0)
return -1;
return 1;
}
int update_message_queue_process_pending_messages(rdpUpdate* update)
{
int status;
wMessage message;
wMessageQueue* queue;
@ -1499,16 +1517,13 @@ int update_message_process_pending_updates(rdpUpdate* update)
if (!status)
break;
if (message.type == WMQ_QUIT)
status = update_message_queue_process_message(update, &message);
if (!status)
break;
msgClass = GetMessageClass(message.type);
msgType = GetMessageType(message.type);
status = update_message_process_class(update->proxy, &message, msgClass, msgType);
}
return 0;
return status;
}
void update_message_register_interface(rdpUpdateProxy* message, rdpUpdate* update)
@ -1807,7 +1822,6 @@ int input_message_process_input_class(rdpInputProxy* proxy, wMessage* msg, int t
return status;
}
int input_message_process_class(rdpInputProxy* proxy, wMessage* msg, int msgClass, int msgType)
{
int status = 0;
@ -1829,11 +1843,29 @@ int input_message_process_class(rdpInputProxy* proxy, wMessage* msg, int msgClas
return status;
}
int input_message_process_pending_input(rdpInput* input)
int input_message_queue_process_message(rdpInput* input, wMessage* message)
{
int status;
int msgClass;
int msgType;
if (message->id == WMQ_QUIT)
return 0;
msgClass = GetMessageClass(message->id);
msgType = GetMessageType(message->id);
status = input_message_process_class(input->proxy, message, msgClass, msgType);
if (status < 0)
return -1;
return 1;
}
int input_message_queue_process_pending_messages(rdpInput* input)
{
int status;
wMessage message;
wMessageQueue* queue;
@ -1846,13 +1878,10 @@ int input_message_process_pending_input(rdpInput* input)
if (!status)
break;
if (message.type == WMQ_QUIT)
status = input_message_queue_process_message(input, &message);
if (!status)
break;
msgClass = GetMessageClass(message.type);
msgType = GetMessageType(message.type);
status = input_message_process_class(input->proxy, &message, msgClass, msgType);
}
return 0;

View File

@ -21,117 +21,12 @@
#define FREERDP_CORE_MESSAGE_PRIVATE_H
#include <freerdp/freerdp.h>
#define GetMessageType(_id) (_id & 0xFF)
#define GetMessageClass(_id) ((_id >> 16) & 0xFF)
#define MakeMessageId(_class, _type) \
(((_class ##_Class) << 16) | (_class ## _ ## _type))
#include <freerdp/message.h>
/**
* Update Message Queue
*/
/* Update */
#define Update_Class 1
#define Update_BeginPaint 1
#define Update_EndPaint 2
#define Update_SetBounds 3
#define Update_Synchronize 4
#define Update_DesktopResize 5
#define Update_BitmapUpdate 6
#define Update_Palette 7
#define Update_PlaySound 8
#define Update_RefreshRect 9
#define Update_SuppressOutput 10
#define Update_SurfaceCommand 11
#define Update_SurfaceBits 12
#define Update_SurfaceFrameMarker 13
#define Update_SurfaceFrameAcknowledge 14
/* Primary Update */
#define PrimaryUpdate_Class 2
#define PrimaryUpdate_DstBlt 1
#define PrimaryUpdate_PatBlt 2
#define PrimaryUpdate_ScrBlt 3
#define PrimaryUpdate_OpaqueRect 4
#define PrimaryUpdate_DrawNineGrid 5
#define PrimaryUpdate_MultiDstBlt 6
#define PrimaryUpdate_MultiPatBlt 7
#define PrimaryUpdate_MultiScrBlt 8
#define PrimaryUpdate_MultiOpaqueRect 9
#define PrimaryUpdate_MultiDrawNineGrid 10
#define PrimaryUpdate_LineTo 11
#define PrimaryUpdate_Polyline 12
#define PrimaryUpdate_MemBlt 13
#define PrimaryUpdate_Mem3Blt 14
#define PrimaryUpdate_SaveBitmap 15
#define PrimaryUpdate_GlyphIndex 16
#define PrimaryUpdate_FastIndex 17
#define PrimaryUpdate_FastGlyph 18
#define PrimaryUpdate_PolygonSC 19
#define PrimaryUpdate_PolygonCB 20
#define PrimaryUpdate_EllipseSC 21
#define PrimaryUpdate_EllipseCB 22
/* Secondary Update */
#define SecondaryUpdate_Class 3
#define SecondaryUpdate_CacheBitmap 1
#define SecondaryUpdate_CacheBitmapV2 2
#define SecondaryUpdate_CacheBitmapV3 3
#define SecondaryUpdate_CacheColorTable 4
#define SecondaryUpdate_CacheGlyph 5
#define SecondaryUpdate_CacheGlyphV2 6
#define SecondaryUpdate_CacheBrush 7
/* Alternate Secondary Update */
#define AltSecUpdate_Class 4
#define AltSecUpdate_CreateOffscreenBitmap 1
#define AltSecUpdate_SwitchSurface 2
#define AltSecUpdate_CreateNineGridBitmap 3
#define AltSecUpdate_FrameMarker 4
#define AltSecUpdate_StreamBitmapFirst 5
#define AltSecUpdate_StreamBitmapNext 6
#define AltSecUpdate_DrawGdiPlusFirst 7
#define AltSecUpdate_DrawGdiPlusNext 8
#define AltSecUpdate_DrawGdiPlusEnd 9
#define AltSecUpdate_DrawGdiPlusCacheFirst 10
#define AltSecUpdate_DrawGdiPlusCacheNext 11
#define AltSecUpdate_DrawGdiPlusCacheEnd 12
/* Window Update */
#define WindowUpdate_Class 5
#define WindowUpdate_WindowCreate 1
#define WindowUpdate_WindowUpdate 2
#define WindowUpdate_WindowIcon 3
#define WindowUpdate_WindowCachedIcon 4
#define WindowUpdate_WindowDelete 5
#define WindowUpdate_NotifyIconCreate 6
#define WindowUpdate_NotifyIconUpdate 7
#define WindowUpdate_NotifyIconDelete 8
#define WindowUpdate_MonitoredDesktop 9
#define WindowUpdate_NonMonitoredDesktop 10
/* Pointer Update */
#define PointerUpdate_Class 6
#define PointerUpdate_PointerPosition 1
#define PointerUpdate_PointerSystem 2
#define PointerUpdate_PointerColor 3
#define PointerUpdate_PointerNew 4
#define PointerUpdate_PointerCached 5
/* Update Proxy Interface */
struct rdp_update_proxy
@ -227,7 +122,8 @@ struct rdp_update_proxy
pPointerCached PointerCached;
};
int update_message_process_pending_updates(rdpUpdate* update);
int update_message_queue_process_message(rdpUpdate* update, wMessage* message);
int update_message_queue_process_pending_messages(rdpUpdate* update);
rdpUpdateProxy* update_message_proxy_new(rdpUpdate* update);
void update_message_proxy_free(rdpUpdateProxy* message);
@ -236,16 +132,6 @@ void update_message_proxy_free(rdpUpdateProxy* message);
* Input Message Queue
*/
/* Input */
#define Input_Class 1
#define Input_SynchronizeEvent 1
#define Input_KeyboardEvent 2
#define Input_UnicodeKeyboardEvent 3
#define Input_MouseEvent 4
#define Input_ExtendedMouseEvent 5
/* Input Proxy Interface */
struct rdp_input_proxy
@ -261,7 +147,8 @@ struct rdp_input_proxy
pExtendedMouseEvent ExtendedMouseEvent;
};
int input_message_process_pending_input(rdpInput* input);
int input_message_queue_process_message(rdpInput* input, wMessage* message);
int input_message_queue_process_pending_messages(rdpInput* input);
rdpInputProxy* input_message_proxy_new(rdpInput* input);
void input_message_proxy_free(rdpInputProxy* proxy);

View File

@ -117,8 +117,8 @@ BOOL rdp_read_share_control_header(STREAM* s, UINT16* length, UINT16* type, UINT
if (*length > 4)
stream_read_UINT16(s, *channel_id); /* pduSource */
else /* Windows XP can send such short DEACTIVATE_ALL PDUs. */
*channel_id = 0;
else
*channel_id = 0; /* Windows XP can send such short DEACTIVATE_ALL PDUs. */
return TRUE;
}

View File

@ -735,7 +735,7 @@ void update_register_client_callbacks(rdpUpdate* update)
int update_process_messages(rdpUpdate* update)
{
return update_message_process_pending_updates(update);
return update_message_queue_process_pending_messages(update);
}
rdpUpdate* update_new(rdpRdp* rdp)

View File

@ -146,6 +146,7 @@ void crypto_hmac_free(CryptoHmac hmac)
{
if (hmac == NULL)
return;
HMAC_CTX_cleanup(&hmac->hmac_ctx);
free(hmac);
}
@ -258,37 +259,31 @@ static void crypto_rsa_public(const BYTE* input, int length, UINT32 key_length,
static void crypto_rsa_private(const BYTE* input, int length, UINT32 key_length, const BYTE* modulus, const BYTE* private_exponent, BYTE* output)
{
crypto_rsa_common(input, length, key_length, modulus, private_exponent, key_length, output);
}
void crypto_rsa_public_encrypt(const BYTE* input, int length, UINT32 key_length, const BYTE* modulus, const BYTE* exponent, BYTE* output)
{
crypto_rsa_public(input, length, key_length, modulus, exponent, output);
}
void crypto_rsa_public_decrypt(const BYTE* input, int length, UINT32 key_length, const BYTE* modulus, const BYTE* exponent, BYTE* output)
{
crypto_rsa_public(input, length, key_length, modulus, exponent, output);
}
void crypto_rsa_private_encrypt(const BYTE* input, int length, UINT32 key_length, const BYTE* modulus, const BYTE* private_exponent, BYTE* output)
{
crypto_rsa_private(input, length, key_length, modulus, private_exponent, output);
}
void crypto_rsa_private_decrypt(const BYTE* input, int length, UINT32 key_length, const BYTE* modulus, const BYTE* private_exponent, BYTE* output)
{
crypto_rsa_private(input, length, key_length, modulus, private_exponent, output);
}
void crypto_rsa_decrypt(const BYTE* input, int length, UINT32 key_length, const BYTE* modulus, const BYTE* private_exponent, BYTE* output)
{
crypto_rsa_common(input, length, key_length, modulus, private_exponent, key_length, output);
}

View File

@ -254,7 +254,7 @@ WINPR_API void BufferPool_Free(wBufferPool* pool);
struct _wMessage
{
UINT32 type;
UINT32 id;
void* context;
void* wParam;
void* lParam;

View File

@ -28,15 +28,10 @@
#ifndef _WIN32
#define CopyMemory RtlCopyMemory
#define MoveMemory RtlMoveMemory
#define FillMemory RtlFillMemory
#define ZeroMemory RtlZeroMemory
#define RtlCopyMemory(Destination, Source, Length) memcpy((Destination), (Source), (Length))
#define RtlMoveMemory(Destination, Source, Length) memmove((Destination), (Source), (Length))
#define RtlFillMemory(Destination, Length, Fill) memset((Destination), (Fill), (Length))
#define RtlZeroMemory(Destination, Length) memset((Destination), 0, (Length))
#define CopyMemory(Destination, Source, Length) memcpy((Destination), (Source), (Length))
#define MoveMemory(Destination, Source, Length) memmove((Destination), (Source), (Length))
#define FillMemory(Destination, Length, Fill) memset((Destination), (Fill), (Length))
#define ZeroMemory(Destination, Length) memset((Destination), 0, (Length))
#endif

View File

@ -94,7 +94,7 @@ void MessageQueue_Post(wMessageQueue* queue, void* context, UINT32 type, void* w
wMessage message;
message.context = context;
message.type = type;
message.id = type;
message.wParam = wParam;
message.lParam = lParam;
@ -122,7 +122,7 @@ int MessageQueue_Get(wMessageQueue* queue, wMessage* message)
queue->head = (queue->head + 1) % queue->capacity;
queue->size--;
status = (message->type != WMQ_QUIT) ? 1 : 0;
status = (message->id != WMQ_QUIT) ? 1 : 0;
}
if (queue->size < 1)

View File

@ -14,10 +14,10 @@ static void* message_queue_consumer_thread(void* arg)
{
if (MessageQueue_Peek(queue, &message, TRUE))
{
if (message.type == WMQ_QUIT)
if (message.id == WMQ_QUIT)
break;
printf("Message.Type: %d\n", message.type);
printf("Message.Type: %d\n", message.id);
}
}