Merge pull request #12385 from akallabeth/c23-nullptr-server

[c23,server] replace NULL with nullptr
This commit is contained in:
akallabeth
2026-02-26 15:00:24 +01:00
committed by GitHub
58 changed files with 919 additions and 906 deletions

View File

@@ -53,7 +53,7 @@ BOOL mf_peer_audin_init(mfPeerContext* context)
context->audin->Data = mf_peer_audin_data; context->audin->Data = mf_peer_audin_data;
return audin_server_set_formats(context->audin, -1, NULL); return audin_server_set_formats(context->audin, -1, nullptr);
} }
void mf_peer_audin_uninit(mfPeerContext* context) void mf_peer_audin_uninit(mfPeerContext* context)
@@ -61,5 +61,5 @@ void mf_peer_audin_uninit(mfPeerContext* context)
WINPR_ASSERT(context); WINPR_ASSERT(context);
audin_server_context_free(context->audin); audin_server_context_free(context->audin);
context->audin = NULL; context->audin = nullptr;
} }

View File

@@ -112,7 +112,7 @@ mfEvent* mf_event_peek(mfEventQueue* event_queue)
pthread_mutex_lock(&(event_queue->mutex)); pthread_mutex_lock(&(event_queue->mutex));
if (event_queue->count < 1) if (event_queue->count < 1)
event = NULL; event = nullptr;
else else
event = event_queue->events[0]; event = event_queue->events[0];
@@ -128,7 +128,7 @@ mfEvent* mf_event_pop(mfEventQueue* event_queue)
pthread_mutex_lock(&(event_queue->mutex)); pthread_mutex_lock(&(event_queue->mutex));
if (event_queue->count < 1) if (event_queue->count < 1)
return NULL; return nullptr;
/* remove event signal */ /* remove event signal */
mf_clear_event(event_queue); mf_clear_event(event_queue);
@@ -147,7 +147,7 @@ mfEventRegion* mf_event_region_new(int x, int y, int width, int height)
{ {
mfEventRegion* event_region = malloc(sizeof(mfEventRegion)); mfEventRegion* event_region = malloc(sizeof(mfEventRegion));
if (event_region != NULL) if (event_region != nullptr)
{ {
event_region->x = x; event_region->x = x;
event_region->y = y; event_region->y = y;
@@ -167,7 +167,7 @@ mfEvent* mf_event_new(int type)
{ {
mfEvent* event = malloc(sizeof(mfEvent)); mfEvent* event = malloc(sizeof(mfEvent));
if (!event) if (!event)
return NULL; return nullptr;
event->type = type; event->type = type;
return event; return event;
} }
@@ -181,7 +181,7 @@ mfEventQueue* mf_event_queue_new()
{ {
mfEventQueue* event_queue = malloc(sizeof(mfEventQueue)); mfEventQueue* event_queue = malloc(sizeof(mfEventQueue));
if (event_queue != NULL) if (event_queue != nullptr)
{ {
event_queue->pipe_fd[0] = -1; event_queue->pipe_fd[0] = -1;
event_queue->pipe_fd[1] = -1; event_queue->pipe_fd[1] = -1;
@@ -193,10 +193,10 @@ mfEventQueue* mf_event_queue_new()
if (pipe(event_queue->pipe_fd) < 0) if (pipe(event_queue->pipe_fd) < 0)
{ {
free(event_queue); free(event_queue);
return NULL; return nullptr;
} }
pthread_mutex_init(&(event_queue->mutex), NULL); pthread_mutex_init(&(event_queue->mutex), nullptr);
} }
return event_queue; return event_queue;

View File

@@ -28,7 +28,7 @@
#define MF_INFO_DEFAULT_FPS 30 #define MF_INFO_DEFAULT_FPS 30
#define MF_INFO_MAXPEERS 32 #define MF_INFO_MAXPEERS 32
static mfInfo* mfInfoInstance = NULL; static mfInfo* mfInfoInstance = nullptr;
int mf_info_lock(mfInfo* mfi) int mf_info_lock(mfInfo* mfi)
{ {
@@ -93,15 +93,15 @@ static mfInfo* mf_info_init(void)
{ {
mfInfo* mfi = (mfInfo*)calloc(1, sizeof(mfInfo)); mfInfo* mfi = (mfInfo*)calloc(1, sizeof(mfInfo));
if (mfi != NULL) if (mfi != nullptr)
{ {
pthread_mutex_init(&mfi->mutex, NULL); pthread_mutex_init(&mfi->mutex, nullptr);
mfi->peers = (freerdp_peer**)calloc(MF_INFO_MAXPEERS, sizeof(freerdp_peer*)); mfi->peers = (freerdp_peer**)calloc(MF_INFO_MAXPEERS, sizeof(freerdp_peer*));
if (!mfi->peers) if (!mfi->peers)
{ {
free(mfi); free(mfi);
return NULL; return nullptr;
} }
mfi->framesPerSecond = MF_INFO_DEFAULT_FPS; mfi->framesPerSecond = MF_INFO_DEFAULT_FPS;
@@ -113,7 +113,7 @@ static mfInfo* mf_info_init(void)
mfInfo* mf_info_get_instance(void) mfInfo* mf_info_get_instance(void)
{ {
if (mfInfoInstance == NULL) if (mfInfoInstance == nullptr)
mfInfoInstance = mf_info_init(); mfInfoInstance = mf_info_init();
return mfInfoInstance; return mfInfoInstance;
@@ -145,7 +145,7 @@ void mf_info_peer_register(mfInfo* mfi, mfPeerContext* context)
for (int i = 0; i < MF_INFO_MAXPEERS; ++i) for (int i = 0; i < MF_INFO_MAXPEERS; ++i)
{ {
// empty index will be our peer id // empty index will be our peer id
if (mfi->peers[i] == NULL) if (mfi->peers[i] == nullptr)
{ {
peerId = i; peerId = i;
break; break;
@@ -167,7 +167,7 @@ void mf_info_peer_unregister(mfInfo* mfi, mfPeerContext* context)
int peerId; int peerId;
peerId = ((rdpContext*)context)->peer->pId; peerId = ((rdpContext*)context)->peer->pId;
mfi->peers[peerId] = NULL; mfi->peers[peerId] = nullptr;
mfi->peerCount--; mfi->peerCount--;
if (mfi->peerCount == 0) if (mfi->peerCount == 0)

View File

@@ -30,9 +30,9 @@ dispatch_semaphore_t data_sem;
dispatch_queue_t screen_update_q; dispatch_queue_t screen_update_q;
CGDisplayStreamRef stream; CGDisplayStreamRef stream;
CGDisplayStreamUpdateRef lastUpdate = NULL; CGDisplayStreamUpdateRef lastUpdate = nullptr;
BYTE* localBuf = NULL; BYTE* localBuf = nullptr;
BOOL ready = FALSE; BOOL ready = FALSE;
@@ -57,7 +57,7 @@ void (^streamHandler)(CGDisplayStreamFrameStatus, uint64_t, IOSurfaceRef,
mf_mlion_peek_dirty_region(&rect); mf_mlion_peek_dirty_region(&rect);
// lock surface // lock surface
IOSurfaceLock(frameSurface, kIOSurfaceLockReadOnly, NULL); IOSurfaceLock(frameSurface, kIOSurfaceLockReadOnly, nullptr);
// get pointer // get pointer
void* baseAddress = IOSurfaceGetBaseAddress(frameSurface); void* baseAddress = IOSurfaceGetBaseAddress(frameSurface);
// copy region // copy region
@@ -71,7 +71,7 @@ void (^streamHandler)(CGDisplayStreamFrameStatus, uint64_t, IOSurfaceRef,
} }
// unlock surface // unlock surface
IOSurfaceUnlock(frameSurface, kIOSurfaceLockReadOnly, NULL); IOSurfaceUnlock(frameSurface, kIOSurfaceLockReadOnly, nullptr);
ready = FALSE; ready = FALSE;
dispatch_semaphore_signal(data_sem); dispatch_semaphore_signal(data_sem);
@@ -94,7 +94,7 @@ void (^streamHandler)(CGDisplayStreamFrameStatus, uint64_t, IOSurfaceRef,
break; break;
} }
} }
else if (lastUpdate == NULL) else if (lastUpdate == nullptr)
{ {
CFRetain(updateRef); CFRetain(updateRef);
lastUpdate = updateRef; lastUpdate = updateRef;
@@ -139,7 +139,7 @@ int mf_mlion_screen_updates_init()
display_id = CGMainDisplayID(); display_id = CGMainDisplayID();
screen_update_q = dispatch_queue_create("mfreerdp.server.screenUpdate", NULL); screen_update_q = dispatch_queue_create("mfreerdp.server.screenUpdate", nullptr);
region_sem = dispatch_semaphore_create(1); region_sem = dispatch_semaphore_create(1);
data_sem = dispatch_semaphore_create(1); data_sem = dispatch_semaphore_create(1);
@@ -163,7 +163,7 @@ int mf_mlion_screen_updates_init()
values[0] = (void*)kCFBooleanFalse; values[0] = (void*)kCFBooleanFalse;
opts = CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)values, 1, opts = CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)values, 1,
NULL, NULL); nullptr, nullptr);
stream = CGDisplayStreamCreateWithDispatchQueue(display_id, pixelWidth, pixelHeight, 'BGRA', stream = CGDisplayStreamCreateWithDispatchQueue(display_id, pixelWidth, pixelHeight, 'BGRA',
opts, screen_update_q, streamHandler); opts, screen_update_q, streamHandler);
@@ -204,7 +204,7 @@ int mf_mlion_get_dirty_region(RFX_RECT* invalid)
{ {
dispatch_semaphore_wait(region_sem, DISPATCH_TIME_FOREVER); dispatch_semaphore_wait(region_sem, DISPATCH_TIME_FOREVER);
if (lastUpdate != NULL) if (lastUpdate != nullptr)
{ {
mf_mlion_peek_dirty_region(invalid); mf_mlion_peek_dirty_region(invalid);
} }
@@ -246,7 +246,7 @@ int mf_mlion_clear_dirty_region()
dispatch_semaphore_wait(region_sem, DISPATCH_TIME_FOREVER); dispatch_semaphore_wait(region_sem, DISPATCH_TIME_FOREVER);
CFRelease(lastUpdate); CFRelease(lastUpdate);
lastUpdate = NULL; lastUpdate = nullptr;
dispatch_semaphore_signal(region_sem); dispatch_semaphore_signal(region_sem);

View File

@@ -87,7 +87,7 @@ static void mf_peer_rfx_update(freerdp_peer* client)
long width; long width;
long height; long height;
int pitch; int pitch;
BYTE* dataBits = NULL; BYTE* dataBits = nullptr;
mf_info_getScreenData(mfi, &width, &height, &dataBits, &pitch); mf_info_getScreenData(mfi, &width, &height, &dataBits, &pitch);
mf_info_clear_invalid_region(mfi); mf_info_clear_invalid_region(mfi);
// encode // encode
@@ -151,7 +151,7 @@ static BOOL mf_peer_check_fds(freerdp_peer* client)
event = mf_event_peek(info_event_queue); event = mf_event_peek(info_event_queue);
if (event != NULL) if (event != nullptr)
{ {
if (event->type == FREERDP_SERVER_MAC_EVENT_TYPE_REGION) if (event->type == FREERDP_SERVER_MAC_EVENT_TYPE_REGION)
{ {
@@ -193,7 +193,7 @@ static BOOL mf_peer_context_new(freerdp_peer* client, rdpContext* context)
rfx_context_set_mode(peer->rfx_context, RLGR3); rfx_context_set_mode(peer->rfx_context, RLGR3);
rfx_context_set_pixel_format(peer->rfx_context, PIXEL_FORMAT_BGRA32); rfx_context_set_pixel_format(peer->rfx_context, PIXEL_FORMAT_BGRA32);
if (!(peer->s = Stream_New(NULL, 0xFFFF))) if (!(peer->s = Stream_New(nullptr, 0xFFFF)))
goto fail; goto fail;
peer->vcm = WTSOpenServerA((LPSTR)client->context); peer->vcm = WTSOpenServerA((LPSTR)client->context);
@@ -387,7 +387,7 @@ static void* mf_peer_main_loop(void* arg)
WINPR_ASSERT(settings); WINPR_ASSERT(settings);
/* Initialize the real server settings here */ /* Initialize the real server settings here */
rdpPrivateKey* key = freerdp_key_new_from_file_enc(info->key, NULL); rdpPrivateKey* key = freerdp_key_new_from_file_enc(info->key, nullptr);
if (!key) if (!key)
goto fail; goto fail;
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerRsaKey, key, 1)) if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerRsaKey, key, 1))
@@ -475,7 +475,7 @@ static void* mf_peer_main_loop(void* arg)
freerdp_peer_context_free(client); freerdp_peer_context_free(client);
fail: fail:
freerdp_peer_free(client); freerdp_peer_free(client);
return NULL; return nullptr;
} }
BOOL mf_peer_accepted(freerdp_listener* instance, freerdp_peer* client) BOOL mf_peer_accepted(freerdp_listener* instance, freerdp_peer* client)

View File

@@ -38,7 +38,7 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context)
{ {
OSStatus status; OSStatus status;
BOOL formatAgreed = FALSE; BOOL formatAgreed = FALSE;
AUDIO_FORMAT* agreedFormat = NULL; AUDIO_FORMAT* agreedFormat = nullptr;
// we should actually loop through the list of client formats here // we should actually loop through the list of client formats here
// and see if we can send the client something that it supports... // and see if we can send the client something that it supports...
WLog_DBG(TAG, "Client supports the following %d formats: ", context->num_client_formats); WLog_DBG(TAG, "Client supports the following %d formats: ", context->num_client_formats);
@@ -100,7 +100,7 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context)
recorderState.snd_context = context; recorderState.snd_context = context;
status = status =
AudioQueueNewInput(&recorderState.dataFormat, mf_peer_rdpsnd_input_callback, &recorderState, AudioQueueNewInput(&recorderState.dataFormat, mf_peer_rdpsnd_input_callback, &recorderState,
NULL, kCFRunLoopCommonModes, 0, &recorderState.queue); nullptr, kCFRunLoopCommonModes, 0, &recorderState.queue);
if (status != noErr) if (status != noErr)
{ {
@@ -117,12 +117,12 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context)
{ {
AudioQueueAllocateBuffer(recorderState.queue, recorderState.bufferByteSize, AudioQueueAllocateBuffer(recorderState.queue, recorderState.bufferByteSize,
&recorderState.buffers[x]); &recorderState.buffers[x]);
AudioQueueEnqueueBuffer(recorderState.queue, recorderState.buffers[x], 0, NULL); AudioQueueEnqueueBuffer(recorderState.queue, recorderState.buffers[x], 0, nullptr);
} }
recorderState.currentPacket = 0; recorderState.currentPacket = 0;
recorderState.isRunning = true; recorderState.isRunning = true;
AudioQueueStart(recorderState.queue, NULL); AudioQueueStart(recorderState.queue, nullptr);
} }
BOOL mf_peer_rdpsnd_init(mfPeerContext* context) BOOL mf_peer_rdpsnd_init(mfPeerContext* context)
@@ -171,7 +171,7 @@ void mf_peer_rdpsnd_input_callback(void* inUserData, AudioQueueRef inAQ,
rState->snd_context->SendSamples(rState->snd_context, inBuffer->mAudioData, rState->snd_context->SendSamples(rState->snd_context, inBuffer->mAudioData,
inBuffer->mAudioDataByteSize / 4, inBuffer->mAudioDataByteSize / 4,
(UINT16)(GetTickCount() & 0xffff)); (UINT16)(GetTickCount() & 0xffff));
status = AudioQueueEnqueueBuffer(rState->queue, inBuffer, 0, NULL); status = AudioQueueEnqueueBuffer(rState->queue, inBuffer, 0, nullptr);
if (status != noErr) if (status != noErr)
{ {

View File

@@ -97,7 +97,7 @@ int main(int argc, char* argv[])
instance->info = &info; instance->info = &info;
instance->PeerAccepted = mf_peer_accepted; instance->PeerAccepted = mf_peer_accepted;
if (instance->Open(instance, NULL, 3389)) if (instance->Open(instance, nullptr, 3389))
{ {
mf_server_main_loop(instance); mf_server_main_loop(instance);
} }

View File

@@ -61,7 +61,7 @@ BOOL sf_peer_audin_init(testPeerContext* context)
context->audin->Data = sf_peer_audin_data; context->audin->Data = sf_peer_audin_data;
return audin_server_set_formats(context->audin, -1, NULL); return audin_server_set_formats(context->audin, -1, nullptr);
#else #else
return TRUE; return TRUE;
#endif #endif
@@ -109,6 +109,6 @@ void sf_peer_audin_uninit(testPeerContext* context)
#if defined(CHANNEL_AUDIN_SERVER) #if defined(CHANNEL_AUDIN_SERVER)
audin_server_context_free(context->audin); audin_server_context_free(context->audin);
context->audin = NULL; context->audin = nullptr;
#endif #endif
} }

View File

@@ -138,7 +138,7 @@ static BOOL test_peer_context_new(freerdp_peer* client, rdpContext* ctx)
if (!(context->nsc_context = nsc_context_new())) if (!(context->nsc_context = nsc_context_new()))
goto fail; goto fail;
if (!(context->s = Stream_New(NULL, 65536))) if (!(context->s = Stream_New(nullptr, 65536)))
goto fail; goto fail;
context->icon_x = UINT32_MAX; context->icon_x = UINT32_MAX;
@@ -178,9 +178,9 @@ static wStream* test_peer_stream_init(testPeerContext* context)
static void test_peer_begin_frame(freerdp_peer* client) static void test_peer_begin_frame(freerdp_peer* client)
{ {
rdpUpdate* update = NULL; rdpUpdate* update = nullptr;
SURFACE_FRAME_MARKER fm = WINPR_C_ARRAY_INIT; SURFACE_FRAME_MARKER fm = WINPR_C_ARRAY_INIT;
testPeerContext* context = NULL; testPeerContext* context = nullptr;
WINPR_ASSERT(client); WINPR_ASSERT(client);
WINPR_ASSERT(client->context); WINPR_ASSERT(client->context);
@@ -200,9 +200,9 @@ static void test_peer_begin_frame(freerdp_peer* client)
static void test_peer_end_frame(freerdp_peer* client) static void test_peer_end_frame(freerdp_peer* client)
{ {
rdpUpdate* update = NULL; rdpUpdate* update = nullptr;
SURFACE_FRAME_MARKER fm = WINPR_C_ARRAY_INIT; SURFACE_FRAME_MARKER fm = WINPR_C_ARRAY_INIT;
testPeerContext* context = NULL; testPeerContext* context = nullptr;
WINPR_ASSERT(client); WINPR_ASSERT(client);
@@ -350,8 +350,8 @@ static int open_icon(wImage* img)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL test_peer_load_icon(freerdp_peer* client) static BOOL test_peer_load_icon(freerdp_peer* client)
{ {
testPeerContext* context = NULL; testPeerContext* context = nullptr;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
WINPR_ASSERT(client); WINPR_ASSERT(client);
@@ -379,7 +379,7 @@ static BOOL test_peer_load_icon(freerdp_peer* client)
memset(context->bg_data, 0xA0, 3ULL * context->image->height * context->image->width); memset(context->bg_data, 0xA0, 3ULL * context->image->height * context->image->width);
return TRUE; return TRUE;
out_fail: out_fail:
context->bg_data = NULL; context->bg_data = nullptr;
return FALSE; return FALSE;
} }
@@ -546,11 +546,11 @@ static BOOL test_sleep_tsdiff(UINT32* old_sec, UINT32* old_usec, UINT32 new_sec,
static BOOL tf_peer_dump_rfx(freerdp_peer* client) static BOOL tf_peer_dump_rfx(freerdp_peer* client)
{ {
BOOL rc = FALSE; BOOL rc = FALSE;
wStream* s = NULL; wStream* s = nullptr;
UINT32 prev_seconds = 0; UINT32 prev_seconds = 0;
UINT32 prev_useconds = 0; UINT32 prev_useconds = 0;
rdpUpdate* update = NULL; rdpUpdate* update = nullptr;
rdpPcap* pcap_rfx = NULL; rdpPcap* pcap_rfx = nullptr;
pcap_record record = WINPR_C_ARRAY_INIT; pcap_record record = WINPR_C_ARRAY_INIT;
WINPR_ASSERT(client); WINPR_ASSERT(client);
@@ -559,7 +559,7 @@ static BOOL tf_peer_dump_rfx(freerdp_peer* client)
struct server_info* info = client->ContextExtra; struct server_info* info = client->ContextExtra;
WINPR_ASSERT(info); WINPR_ASSERT(info);
s = Stream_New(NULL, 512); s = Stream_New(nullptr, 512);
if (!s) if (!s)
return FALSE; return FALSE;
@@ -610,8 +610,8 @@ fail:
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static DWORD WINAPI tf_debug_channel_thread_func(LPVOID arg) static DWORD WINAPI tf_debug_channel_thread_func(LPVOID arg)
{ {
void* fd = NULL; void* fd = nullptr;
void* buffer = NULL; void* buffer = nullptr;
DWORD BytesReturned = 0; DWORD BytesReturned = 0;
ULONG written = 0; ULONG written = 0;
testPeerContext* context = (testPeerContext*)arg; testPeerContext* context = (testPeerContext*)arg;
@@ -623,11 +623,11 @@ static DWORD WINAPI tf_debug_channel_thread_func(LPVOID arg)
fd = *((void**)buffer); fd = *((void**)buffer);
WTSFreeMemory(buffer); WTSFreeMemory(buffer);
if (!(context->event = CreateWaitObjectEvent(NULL, TRUE, FALSE, fd))) if (!(context->event = CreateWaitObjectEvent(nullptr, TRUE, FALSE, fd)))
return 0; return 0;
} }
wStream* s = Stream_New(NULL, 4096); wStream* s = Stream_New(nullptr, 4096);
if (!s) if (!s)
goto fail; goto fail;
@@ -682,8 +682,8 @@ fail:
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL tf_peer_post_connect(freerdp_peer* client) static BOOL tf_peer_post_connect(freerdp_peer* client)
{ {
testPeerContext* context = NULL; testPeerContext* context = nullptr;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
WINPR_ASSERT(client); WINPR_ASSERT(client);
@@ -748,22 +748,22 @@ static BOOL tf_peer_post_connect(freerdp_peer* client)
{ {
context->debug_channel = WTSVirtualChannelOpen(context->vcm, WTS_CURRENT_SESSION, "rdpdbg"); context->debug_channel = WTSVirtualChannelOpen(context->vcm, WTS_CURRENT_SESSION, "rdpdbg");
if (context->debug_channel != NULL) if (context->debug_channel != nullptr)
{ {
WLog_DBG(TAG, "Open channel rdpdbg."); WLog_DBG(TAG, "Open channel rdpdbg.");
if (!(context->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) if (!(context->stopEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
{ {
WLog_ERR(TAG, "Failed to create stop event"); WLog_ERR(TAG, "Failed to create stop event");
return FALSE; return FALSE;
} }
if (!(context->debug_channel_thread = if (!(context->debug_channel_thread = CreateThread(
CreateThread(NULL, 0, tf_debug_channel_thread_func, (void*)context, 0, NULL))) nullptr, 0, tf_debug_channel_thread_func, (void*)context, 0, nullptr)))
{ {
WLog_ERR(TAG, "Failed to create debug channel thread"); WLog_ERR(TAG, "Failed to create debug channel thread");
(void)CloseHandle(context->stopEvent); (void)CloseHandle(context->stopEvent);
context->stopEvent = NULL; context->stopEvent = nullptr;
return FALSE; return FALSE;
} }
} }
@@ -815,7 +815,7 @@ static BOOL tf_peer_activate(freerdp_peer* client)
if (!freerdp_settings_set_uint32(settings, FreeRDP_CompressionLevel, PACKET_COMPR_TYPE_RDP8)) if (!freerdp_settings_set_uint32(settings, FreeRDP_CompressionLevel, PACKET_COMPR_TYPE_RDP8))
return FALSE; return FALSE;
if (info->test_pcap_file != NULL) if (info->test_pcap_file != nullptr)
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_DumpRemoteFx, TRUE)) if (!freerdp_settings_set_bool(settings, FreeRDP_DumpRemoteFx, TRUE))
return FALSE; return FALSE;
@@ -851,11 +851,11 @@ static BOOL tf_peer_synchronize_event(rdpInput* input, UINT32 flags)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL tf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT8 code) static BOOL tf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT8 code)
{ {
freerdp_peer* client = NULL; freerdp_peer* client = nullptr;
rdpUpdate* update = NULL; rdpUpdate* update = nullptr;
rdpContext* context = NULL; rdpContext* context = nullptr;
testPeerContext* tcontext = NULL; testPeerContext* tcontext = nullptr;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
WINPR_ASSERT(input); WINPR_ASSERT(input);
@@ -1056,7 +1056,7 @@ WINPR_ATTR_NODISCARD
static int hook_peer_write_pdu(rdpTransport* transport, wStream* s) static int hook_peer_write_pdu(rdpTransport* transport, wStream* s)
{ {
UINT64 ts = 0; UINT64 ts = 0;
wStream* ls = NULL; wStream* ls = nullptr;
UINT64 last_ts = 0; UINT64 last_ts = 0;
size_t offset = 0; size_t offset = 0;
UINT32 flags = 0; UINT32 flags = 0;
@@ -1083,7 +1083,7 @@ static int hook_peer_write_pdu(rdpTransport* transport, wStream* s)
if (state < CONNECTION_STATE_NEGO) if (state < CONNECTION_STATE_NEGO)
return peerCtx->io.WritePdu(transport, s); return peerCtx->io.WritePdu(transport, s);
ls = Stream_New(NULL, 4096); ls = Stream_New(nullptr, 4096);
if (!ls) if (!ls)
goto fail; goto fail;
@@ -1124,10 +1124,10 @@ static DWORD WINAPI test_peer_mainloop(LPVOID arg)
HANDLE handles[MAXIMUM_WAIT_OBJECTS] = WINPR_C_ARRAY_INIT; HANDLE handles[MAXIMUM_WAIT_OBJECTS] = WINPR_C_ARRAY_INIT;
DWORD count = 0; DWORD count = 0;
DWORD status = 0; DWORD status = 0;
testPeerContext* context = NULL; testPeerContext* context = nullptr;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
rdpInput* input = NULL; rdpInput* input = nullptr;
rdpUpdate* update = NULL; rdpUpdate* update = nullptr;
freerdp_peer* client = (freerdp_peer*)arg; freerdp_peer* client = (freerdp_peer*)arg;
WINPR_ASSERT(client); WINPR_ASSERT(client);
@@ -1153,7 +1153,7 @@ static DWORD WINAPI test_peer_mainloop(LPVOID arg)
} }
{ {
rdpPrivateKey* key = freerdp_key_new_from_file_enc(info->key, NULL); rdpPrivateKey* key = freerdp_key_new_from_file_enc(info->key, nullptr);
if (!key) if (!key)
goto fail; goto fail;
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerRsaKey, key, 1)) if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerRsaKey, key, 1))
@@ -1325,7 +1325,7 @@ fail:
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL test_peer_accepted(freerdp_listener* instance, freerdp_peer* client) static BOOL test_peer_accepted(freerdp_listener* instance, freerdp_peer* client)
{ {
HANDLE hThread = NULL; HANDLE hThread = nullptr;
WINPR_UNUSED(instance); WINPR_UNUSED(instance);
@@ -1335,7 +1335,7 @@ static BOOL test_peer_accepted(freerdp_listener* instance, freerdp_peer* client)
struct server_info* info = instance->info; struct server_info* info = instance->info;
client->ContextExtra = info; client->ContextExtra = info;
if (!(hThread = CreateThread(NULL, 0, test_peer_mainloop, (void*)client, 0, NULL))) if (!(hThread = CreateThread(nullptr, 0, test_peer_mainloop, (void*)client, 0, nullptr)))
return FALSE; return FALSE;
(void)CloseHandle(hThread); (void)CloseHandle(hThread);
@@ -1428,8 +1428,8 @@ int main(int argc, char* argv[])
int rc = -1; int rc = -1;
BOOL started = FALSE; BOOL started = FALSE;
WSADATA wsaData = WINPR_C_ARRAY_INIT; WSADATA wsaData = WINPR_C_ARRAY_INIT;
freerdp_listener* instance = NULL; freerdp_listener* instance = nullptr;
char* file = NULL; char* file = nullptr;
char name[MAX_PATH] = WINPR_C_ARRAY_INIT; char name[MAX_PATH] = WINPR_C_ARRAY_INIT;
long port = 3389; long port = 3389;
BOOL localOnly = FALSE; BOOL localOnly = FALSE;
@@ -1449,7 +1449,7 @@ int main(int argc, char* argv[])
else if (strncmp(arg, options.sport, sizeof(options.sport)) == 0) else if (strncmp(arg, options.sport, sizeof(options.sport)) == 0)
{ {
const char* sport = &arg[sizeof(options.sport)]; const char* sport = &arg[sizeof(options.sport)];
port = strtol(sport, NULL, 10); port = strtol(sport, nullptr, 10);
if ((port < 1) || (port > UINT16_MAX) || (errno != 0)) if ((port < 1) || (port > UINT16_MAX) || (errno != 0))
return usage(app, arg); return usage(app, arg);
@@ -1511,7 +1511,7 @@ int main(int argc, char* argv[])
else else
{ {
WINPR_ASSERT(instance->Open); WINPR_ASSERT(instance->Open);
started = instance->Open(instance, NULL, (UINT16)port); started = instance->Open(instance, nullptr, (UINT16)port);
} }
if (started) if (started)

View File

@@ -91,7 +91,7 @@ int main(int argc, char* argv[])
vscreen_w = GetSystemMetrics(SM_CXVIRTUALSCREEN); vscreen_w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
vscreen_h = GetSystemMetrics(SM_CYVIRTUALSCREEN); vscreen_h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
WLog_INFO(TAG, ""); WLog_INFO(TAG, "");
EnumDisplayMonitors(NULL, NULL, moncb, 0); EnumDisplayMonitors(nullptr, nullptr, moncb, 0);
IDcount = 0; IDcount = 0;
WLog_INFO(TAG, "Virtual Screen = %dx%d", vscreen_w, vscreen_h); WLog_INFO(TAG, "Virtual Screen = %dx%d", vscreen_w, vscreen_h);
} }
@@ -111,7 +111,7 @@ int main(int argc, char* argv[])
return 0; return 0;
} }
val = strtoul(argv[index], NULL, 0); val = strtoul(argv[index], nullptr, 0);
if ((errno != 0) || (val > UINT32_MAX)) if ((errno != 0) || (val > UINT32_MAX))
return -1; return -1;
@@ -122,7 +122,7 @@ int main(int argc, char* argv[])
if (index == argc - 1) if (index == argc - 1)
{ {
UINT32 val = strtoul(argv[index], NULL, 0); UINT32 val = strtoul(argv[index], nullptr, 0);
if ((errno != 0) || (val > UINT32_MAX)) if ((errno != 0) || (val > UINT32_MAX))
return -1; return -1;

View File

@@ -43,7 +43,7 @@ int wf_directsound_activate(RdpsndServerContext* context)
return 1; return 1;
} }
WLog_DBG(TAG, "RDPSND (direct sound) Activated"); WLog_DBG(TAG, "RDPSND (direct sound) Activated");
hr = DirectSoundCaptureCreate8(NULL, &cap, NULL); hr = DirectSoundCaptureCreate8(nullptr, &cap, nullptr);
if (FAILED(hr)) if (FAILED(hr))
{ {
@@ -58,9 +58,9 @@ int wf_directsound_activate(RdpsndServerContext* context)
dscbd.dwReserved = 0; dscbd.dwReserved = 0;
dscbd.lpwfxFormat = wfi->agreed_format; dscbd.lpwfxFormat = wfi->agreed_format;
dscbd.dwFXCount = 0; dscbd.dwFXCount = 0;
dscbd.lpDSCFXDesc = NULL; dscbd.lpDSCFXDesc = nullptr;
hr = cap->lpVtbl->CreateCaptureBuffer(cap, &dscbd, &pDSCB, NULL); hr = cap->lpVtbl->CreateCaptureBuffer(cap, &dscbd, &pDSCB, nullptr);
if (FAILED(hr)) if (FAILED(hr))
{ {
@@ -77,7 +77,7 @@ int wf_directsound_activate(RdpsndServerContext* context)
pDSCB->lpVtbl->Release(pDSCB); pDSCB->lpVtbl->Release(pDSCB);
lastPos = 0; lastPos = 0;
if (!(hThread = CreateThread(NULL, 0, wf_rdpsnd_directsound_thread, latestPeer, 0, NULL))) if (!(hThread = CreateThread(nullptr, 0, wf_rdpsnd_directsound_thread, latestPeer, 0, nullptr)))
{ {
WLog_ERR(TAG, "Failed to create direct sound thread"); WLog_ERR(TAG, "Failed to create direct sound thread");
return 1; return 1;
@@ -96,11 +96,11 @@ static DWORD WINAPI wf_rdpsnd_directsound_thread(LPVOID lpParam)
wfPeerContext* context; wfPeerContext* context;
wfInfo* wfi; wfInfo* wfi;
VOID* pbCaptureData = NULL; VOID* pbCaptureData = nullptr;
DWORD dwCaptureLength = 0; DWORD dwCaptureLength = 0;
VOID* pbCaptureData2 = NULL; VOID* pbCaptureData2 = nullptr;
DWORD dwCaptureLength2 = 0; DWORD dwCaptureLength2 = 0;
VOID* pbPlayData = NULL; VOID* pbPlayData = nullptr;
DWORD dwReadPos = 0; DWORD dwReadPos = 0;
LONG lLockSize = 0; LONG lLockSize = 0;
@@ -143,7 +143,7 @@ static DWORD WINAPI wf_rdpsnd_directsound_thread(LPVOID lpParam)
break; break;
} }
hr = capBuf->lpVtbl->GetCurrentPosition(capBuf, NULL, &dwReadPos); hr = capBuf->lpVtbl->GetCurrentPosition(capBuf, nullptr, &dwReadPos);
if (FAILED(hr)) if (FAILED(hr))
{ {
WLog_ERR(TAG, "Failed to get read pos"); WLog_ERR(TAG, "Failed to get read pos");

View File

@@ -50,10 +50,10 @@ UINT NumFeatureLevels = ARRAYSIZE(FeatureLevels);
D3D_FEATURE_LEVEL FeatureLevel; D3D_FEATURE_LEVEL FeatureLevel;
ID3D11Device* gDevice = NULL; ID3D11Device* gDevice = nullptr;
ID3D11DeviceContext* gContext = NULL; ID3D11DeviceContext* gContext = nullptr;
IDXGIOutputDuplication* gOutputDuplication = NULL; IDXGIOutputDuplication* gOutputDuplication = nullptr;
ID3D11Texture2D* gAcquiredDesktopImage = NULL; ID3D11Texture2D* gAcquiredDesktopImage = nullptr;
IDXGISurface* surf; IDXGISurface* surf;
ID3D11Texture2D* sStage; ID3D11Texture2D* sStage;
@@ -62,7 +62,7 @@ DXGI_OUTDUPL_FRAME_INFO FrameInfo;
int wf_dxgi_init(wfInfo* wfi) int wf_dxgi_init(wfInfo* wfi)
{ {
gAcquiredDesktopImage = NULL; gAcquiredDesktopImage = nullptr;
if (wf_dxgi_createDevice(wfi) != 0) if (wf_dxgi_createDevice(wfi) != 0)
{ {
@@ -84,7 +84,7 @@ int wf_dxgi_createDevice(wfInfo* wfi)
for (DriverTypeIndex = 0; DriverTypeIndex < NumDriverTypes; ++DriverTypeIndex) for (DriverTypeIndex = 0; DriverTypeIndex < NumDriverTypes; ++DriverTypeIndex)
{ {
status = D3D11CreateDevice(NULL, DriverTypes[DriverTypeIndex], NULL, 0, FeatureLevels, status = D3D11CreateDevice(nullptr, DriverTypes[DriverTypeIndex], nullptr, 0, FeatureLevels,
NumFeatureLevels, D3D11_SDK_VERSION, &gDevice, &FeatureLevel, NumFeatureLevels, D3D11_SDK_VERSION, &gDevice, &FeatureLevel,
&gContext); &gContext);
if (SUCCEEDED(status)) if (SUCCEEDED(status))
@@ -109,10 +109,10 @@ int wf_dxgi_getDuplication(wfInfo* wfi)
UINT dTop, i = 0; UINT dTop, i = 0;
DXGI_OUTPUT_DESC desc = WINPR_C_ARRAY_INIT; DXGI_OUTPUT_DESC desc = WINPR_C_ARRAY_INIT;
IDXGIOutput* pOutput; IDXGIOutput* pOutput;
IDXGIDevice* DxgiDevice = NULL; IDXGIDevice* DxgiDevice = nullptr;
IDXGIAdapter* DxgiAdapter = NULL; IDXGIAdapter* DxgiAdapter = nullptr;
IDXGIOutput* DxgiOutput = NULL; IDXGIOutput* DxgiOutput = nullptr;
IDXGIOutput1* DxgiOutput1 = NULL; IDXGIOutput1* DxgiOutput1 = nullptr;
status = gDevice->lpVtbl->QueryInterface(gDevice, &IID_IDXGIDevice, (void**)&DxgiDevice); status = gDevice->lpVtbl->QueryInterface(gDevice, &IID_IDXGIDevice, (void**)&DxgiDevice);
@@ -124,7 +124,7 @@ int wf_dxgi_getDuplication(wfInfo* wfi)
status = DxgiDevice->lpVtbl->GetParent(DxgiDevice, &IID_IDXGIAdapter, (void**)&DxgiAdapter); status = DxgiDevice->lpVtbl->GetParent(DxgiDevice, &IID_IDXGIAdapter, (void**)&DxgiAdapter);
DxgiDevice->lpVtbl->Release(DxgiDevice); DxgiDevice->lpVtbl->Release(DxgiDevice);
DxgiDevice = NULL; DxgiDevice = nullptr;
if (FAILED(status)) if (FAILED(status))
{ {
@@ -132,7 +132,7 @@ int wf_dxgi_getDuplication(wfInfo* wfi)
return 1; return 1;
} }
pOutput = NULL; pOutput = nullptr;
while (DxgiAdapter->lpVtbl->EnumOutputs(DxgiAdapter, i, &pOutput) != DXGI_ERROR_NOT_FOUND) while (DxgiAdapter->lpVtbl->EnumOutputs(DxgiAdapter, i, &pOutput) != DXGI_ERROR_NOT_FOUND)
{ {
@@ -159,7 +159,7 @@ int wf_dxgi_getDuplication(wfInfo* wfi)
status = DxgiAdapter->lpVtbl->EnumOutputs(DxgiAdapter, dTop, &DxgiOutput); status = DxgiAdapter->lpVtbl->EnumOutputs(DxgiAdapter, dTop, &DxgiOutput);
DxgiAdapter->lpVtbl->Release(DxgiAdapter); DxgiAdapter->lpVtbl->Release(DxgiAdapter);
DxgiAdapter = NULL; DxgiAdapter = nullptr;
if (FAILED(status)) if (FAILED(status))
{ {
@@ -170,7 +170,7 @@ int wf_dxgi_getDuplication(wfInfo* wfi)
status = status =
DxgiOutput->lpVtbl->QueryInterface(DxgiOutput, &IID_IDXGIOutput1, (void**)&DxgiOutput1); DxgiOutput->lpVtbl->QueryInterface(DxgiOutput, &IID_IDXGIOutput1, (void**)&DxgiOutput1);
DxgiOutput->lpVtbl->Release(DxgiOutput); DxgiOutput->lpVtbl->Release(DxgiOutput);
DxgiOutput = NULL; DxgiOutput = nullptr;
if (FAILED(status)) if (FAILED(status))
{ {
@@ -181,7 +181,7 @@ int wf_dxgi_getDuplication(wfInfo* wfi)
status = status =
DxgiOutput1->lpVtbl->DuplicateOutput(DxgiOutput1, (IUnknown*)gDevice, &gOutputDuplication); DxgiOutput1->lpVtbl->DuplicateOutput(DxgiOutput1, (IUnknown*)gDevice, &gOutputDuplication);
DxgiOutput1->lpVtbl->Release(DxgiOutput1); DxgiOutput1->lpVtbl->Release(DxgiOutput1);
DxgiOutput1 = NULL; DxgiOutput1 = nullptr;
if (FAILED(status)) if (FAILED(status))
{ {
@@ -211,25 +211,25 @@ int wf_dxgi_cleanup(wfInfo* wfi)
if (gAcquiredDesktopImage) if (gAcquiredDesktopImage)
{ {
gAcquiredDesktopImage->lpVtbl->Release(gAcquiredDesktopImage); gAcquiredDesktopImage->lpVtbl->Release(gAcquiredDesktopImage);
gAcquiredDesktopImage = NULL; gAcquiredDesktopImage = nullptr;
} }
if (gOutputDuplication) if (gOutputDuplication)
{ {
gOutputDuplication->lpVtbl->Release(gOutputDuplication); gOutputDuplication->lpVtbl->Release(gOutputDuplication);
gOutputDuplication = NULL; gOutputDuplication = nullptr;
} }
if (gContext) if (gContext)
{ {
gContext->lpVtbl->Release(gContext); gContext->lpVtbl->Release(gContext);
gContext = NULL; gContext = nullptr;
} }
if (gDevice) if (gDevice)
{ {
gDevice->lpVtbl->Release(gDevice); gDevice->lpVtbl->Release(gDevice);
gDevice = NULL; gDevice = nullptr;
} }
return 0; return 0;
@@ -240,8 +240,8 @@ int wf_dxgi_nextFrame(wfInfo* wfi, UINT timeout)
HRESULT status = 0; HRESULT status = 0;
UINT i = 0; UINT i = 0;
UINT DataBufferSize = 0; UINT DataBufferSize = 0;
BYTE* DataBuffer = NULL; BYTE* DataBuffer = nullptr;
IDXGIResource* DesktopResource = NULL; IDXGIResource* DesktopResource = nullptr;
if (wfi->framesWaiting > 0) if (wfi->framesWaiting > 0)
{ {
@@ -251,7 +251,7 @@ int wf_dxgi_nextFrame(wfInfo* wfi, UINT timeout)
if (gAcquiredDesktopImage) if (gAcquiredDesktopImage)
{ {
gAcquiredDesktopImage->lpVtbl->Release(gAcquiredDesktopImage); gAcquiredDesktopImage->lpVtbl->Release(gAcquiredDesktopImage);
gAcquiredDesktopImage = NULL; gAcquiredDesktopImage = nullptr;
} }
status = gOutputDuplication->lpVtbl->AcquireNextFrame(gOutputDuplication, timeout, &FrameInfo, status = gOutputDuplication->lpVtbl->AcquireNextFrame(gOutputDuplication, timeout, &FrameInfo,
@@ -272,13 +272,13 @@ int wf_dxgi_nextFrame(wfInfo* wfi, UINT timeout)
if (gAcquiredDesktopImage) if (gAcquiredDesktopImage)
{ {
gAcquiredDesktopImage->lpVtbl->Release(gAcquiredDesktopImage); gAcquiredDesktopImage->lpVtbl->Release(gAcquiredDesktopImage);
gAcquiredDesktopImage = NULL; gAcquiredDesktopImage = nullptr;
} }
if (gOutputDuplication) if (gOutputDuplication)
{ {
gOutputDuplication->lpVtbl->Release(gOutputDuplication); gOutputDuplication->lpVtbl->Release(gOutputDuplication);
gOutputDuplication = NULL; gOutputDuplication = nullptr;
} }
wf_dxgi_getDuplication(wfi); wf_dxgi_getDuplication(wfi);
@@ -302,7 +302,7 @@ int wf_dxgi_nextFrame(wfInfo* wfi, UINT timeout)
status = DesktopResource->lpVtbl->QueryInterface(DesktopResource, &IID_ID3D11Texture2D, status = DesktopResource->lpVtbl->QueryInterface(DesktopResource, &IID_ID3D11Texture2D,
(void**)&gAcquiredDesktopImage); (void**)&gAcquiredDesktopImage);
DesktopResource->lpVtbl->Release(DesktopResource); DesktopResource->lpVtbl->Release(DesktopResource);
DesktopResource = NULL; DesktopResource = nullptr;
if (FAILED(status)) if (FAILED(status))
{ {
@@ -350,7 +350,7 @@ int wf_dxgi_getPixelData(wfInfo* wfi, BYTE** data, int* pitch, RECT* invalid)
Box.front = 0; Box.front = 0;
Box.back = 1; Box.back = 1;
status = gDevice->lpVtbl->CreateTexture2D(gDevice, &tDesc, NULL, &sStage); status = gDevice->lpVtbl->CreateTexture2D(gDevice, &tDesc, nullptr, &sStage);
if (FAILED(status)) if (FAILED(status))
{ {
@@ -392,9 +392,9 @@ int wf_dxgi_releasePixelData(wfInfo* wfi)
surf->lpVtbl->Unmap(surf); surf->lpVtbl->Unmap(surf);
surf->lpVtbl->Release(surf); surf->lpVtbl->Release(surf);
surf = NULL; surf = nullptr;
sStage->lpVtbl->Release(sStage); sStage->lpVtbl->Release(sStage);
sStage = NULL; sStage = nullptr;
status = gOutputDuplication->lpVtbl->ReleaseFrame(gOutputDuplication); status = gOutputDuplication->lpVtbl->ReleaseFrame(gOutputDuplication);
@@ -417,7 +417,7 @@ int wf_dxgi_getInvalidRegion(RECT* invalid)
RECT* pRect; RECT* pRect;
BYTE* DirtyRects; BYTE* DirtyRects;
UINT DataBufferSize = 0; UINT DataBufferSize = 0;
BYTE* DataBuffer = NULL; BYTE* DataBuffer = nullptr;
if (FrameInfo.AccumulatedFrames == 0) if (FrameInfo.AccumulatedFrames == 0)
{ {
@@ -432,7 +432,7 @@ int wf_dxgi_getInvalidRegion(RECT* invalid)
if (DataBuffer) if (DataBuffer)
{ {
free(DataBuffer); free(DataBuffer);
DataBuffer = NULL; DataBuffer = nullptr;
} }
DataBuffer = (BYTE*)malloc(FrameInfo.TotalMetadataBufferSize); DataBuffer = (BYTE*)malloc(FrameInfo.TotalMetadataBufferSize);

View File

@@ -36,7 +36,7 @@
#define SERVER_KEY "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING "\\Server" #define SERVER_KEY "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING "\\Server"
static wfInfo* wfInfoInstance = NULL; static wfInfo* wfInfoInstance = nullptr;
static int _IDcount = 0; static int _IDcount = 0;
BOOL wf_info_lock(wfInfo* wfi) BOOL wf_info_lock(wfInfo* wfi)
@@ -99,33 +99,34 @@ wfInfo* wf_info_init()
wfInfo* wfi; wfInfo* wfi;
wfi = (wfInfo*)calloc(1, sizeof(wfInfo)); wfi = (wfInfo*)calloc(1, sizeof(wfInfo));
if (wfi != NULL) if (wfi != nullptr)
{ {
HKEY hKey; HKEY hKey;
LONG status; LONG status;
DWORD dwType; DWORD dwType;
DWORD dwSize; DWORD dwSize;
DWORD dwValue; DWORD dwValue;
wfi->mutex = CreateMutex(NULL, FALSE, NULL); wfi->mutex = CreateMutex(nullptr, FALSE, nullptr);
if (wfi->mutex == NULL) if (wfi->mutex == nullptr)
{ {
WLog_ERR(TAG, "CreateMutex error: %lu", GetLastError()); WLog_ERR(TAG, "CreateMutex error: %lu", GetLastError());
free(wfi); free(wfi);
return NULL; return nullptr;
} }
wfi->updateSemaphore = CreateSemaphore(NULL, 0, 32, NULL); wfi->updateSemaphore = CreateSemaphore(nullptr, 0, 32, nullptr);
if (!wfi->updateSemaphore) if (!wfi->updateSemaphore)
{ {
WLog_ERR(TAG, "CreateSemaphore error: %lu", GetLastError()); WLog_ERR(TAG, "CreateSemaphore error: %lu", GetLastError());
(void)CloseHandle(wfi->mutex); (void)CloseHandle(wfi->mutex);
free(wfi); free(wfi);
return NULL; return nullptr;
} }
wfi->updateThread = CreateThread(NULL, 0, wf_update_thread, wfi, CREATE_SUSPENDED, NULL); wfi->updateThread =
CreateThread(nullptr, 0, wf_update_thread, wfi, CREATE_SUSPENDED, nullptr);
if (!wfi->updateThread) if (!wfi->updateThread)
{ {
@@ -133,7 +134,7 @@ wfInfo* wf_info_init()
(void)CloseHandle(wfi->mutex); (void)CloseHandle(wfi->mutex);
(void)CloseHandle(wfi->updateSemaphore); (void)CloseHandle(wfi->updateSemaphore);
free(wfi); free(wfi);
return NULL; return nullptr;
} }
wfi->peers = wfi->peers =
@@ -146,7 +147,7 @@ wfInfo* wf_info_init()
(void)CloseHandle(wfi->updateSemaphore); (void)CloseHandle(wfi->updateSemaphore);
(void)CloseHandle(wfi->updateThread); (void)CloseHandle(wfi->updateThread);
free(wfi); free(wfi);
return NULL; return nullptr;
} }
// Set FPS // Set FPS
@@ -156,7 +157,7 @@ wfInfo* wf_info_init()
if (status == ERROR_SUCCESS) if (status == ERROR_SUCCESS)
{ {
if (RegQueryValueEx(hKey, _T("FramesPerSecond"), NULL, &dwType, (BYTE*)&dwValue, if (RegQueryValueEx(hKey, _T("FramesPerSecond"), nullptr, &dwType, (BYTE*)&dwValue,
&dwSize) == ERROR_SUCCESS) &dwSize) == ERROR_SUCCESS)
wfi->framesPerSecond = dwValue; wfi->framesPerSecond = dwValue;
} }
@@ -169,7 +170,7 @@ wfInfo* wf_info_init()
if (status == ERROR_SUCCESS) if (status == ERROR_SUCCESS)
{ {
if (RegQueryValueEx(hKey, _T("DisableInput"), NULL, &dwType, (BYTE*)&dwValue, if (RegQueryValueEx(hKey, _T("DisableInput"), nullptr, &dwType, (BYTE*)&dwValue,
&dwSize) == ERROR_SUCCESS) &dwSize) == ERROR_SUCCESS)
{ {
if (dwValue != 0) if (dwValue != 0)
@@ -185,7 +186,7 @@ wfInfo* wf_info_init()
wfInfo* wf_info_get_instance() wfInfo* wf_info_get_instance()
{ {
if (wfInfoInstance == NULL) if (wfInfoInstance == nullptr)
wfInfoInstance = wf_info_init(); wfInfoInstance = wf_info_init();
return wfInfoInstance; return wfInfoInstance;
@@ -206,11 +207,11 @@ BOOL wf_info_peer_register(wfInfo* wfi, wfPeerContext* context)
context->info = wfi; context->info = wfi;
if (!(context->updateEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) if (!(context->updateEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
goto fail_update_event; goto fail_update_event;
// get the offset of the top left corner of selected screen // get the offset of the top left corner of selected screen
EnumDisplayMonitors(NULL, NULL, wf_info_monEnumCB, 0); EnumDisplayMonitors(nullptr, nullptr, wf_info_monEnumCB, 0);
_IDcount = 0; _IDcount = 0;
#ifdef WITH_DXGI_1_2 #ifdef WITH_DXGI_1_2
@@ -229,7 +230,7 @@ BOOL wf_info_peer_register(wfInfo* wfi, wfPeerContext* context)
for (int i = 0; i < FREERDP_SERVER_WIN_INFO_MAXPEERS; ++i) for (int i = 0; i < FREERDP_SERVER_WIN_INFO_MAXPEERS; ++i)
{ {
// empty index will be our peer id // empty index will be our peer id
if (wfi->peers[i] == NULL) if (wfi->peers[i] == nullptr)
{ {
peerId = i; peerId = i;
break; break;
@@ -245,7 +246,7 @@ BOOL wf_info_peer_register(wfInfo* wfi, wfPeerContext* context)
return TRUE; return TRUE;
fail_driver_init: fail_driver_init:
(void)CloseHandle(context->updateEvent); (void)CloseHandle(context->updateEvent);
context->updateEvent = NULL; context->updateEvent = nullptr;
fail_update_event: fail_update_event:
fail_peer_count: fail_peer_count:
context->socketClose = TRUE; context->socketClose = TRUE;
@@ -259,7 +260,7 @@ void wf_info_peer_unregister(wfInfo* wfi, wfPeerContext* context)
{ {
int peerId; int peerId;
peerId = ((rdpContext*)context)->peer->pId; peerId = ((rdpContext*)context)->peer->pId;
wfi->peers[peerId] = NULL; wfi->peers[peerId] = nullptr;
wfi->peerCount--; wfi->peerCount--;
(void)CloseHandle(context->updateEvent); (void)CloseHandle(context->updateEvent);
WLog_INFO(TAG, "Unregistering Peer: id=%d, #=%d", peerId, wfi->peerCount); WLog_INFO(TAG, "Unregistering Peer: id=%d, #=%d", peerId, wfi->peerCount);

View File

@@ -43,7 +43,7 @@
#define SERVER_KEY "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING "\\Server" #define SERVER_KEY "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING "\\Server"
static cbCallback cbEvent = NULL; static cbCallback cbEvent = nullptr;
int get_screen_info(int id, _TCHAR* name, size_t length, int* width, int* height, int* bpp) int get_screen_info(int id, _TCHAR* name, size_t length, int* width, int* height, int* bpp)
{ {
@@ -51,18 +51,18 @@ int get_screen_info(int id, _TCHAR* name, size_t length, int* width, int* height
dd.cb = sizeof(DISPLAY_DEVICE); dd.cb = sizeof(DISPLAY_DEVICE);
if (EnumDisplayDevices(NULL, id, &dd, 0) != 0) if (EnumDisplayDevices(nullptr, id, &dd, 0) != 0)
{ {
HDC dc; HDC dc;
if (name != NULL) if (name != nullptr)
_stprintf_s(name, length, _T("%s (%s)"), dd.DeviceName, dd.DeviceString); _stprintf_s(name, length, _T("%s (%s)"), dd.DeviceName, dd.DeviceString);
dc = CreateDC(dd.DeviceName, NULL, NULL, NULL); dc = CreateDC(dd.DeviceName, nullptr, nullptr, nullptr);
*width = GetDeviceCaps(dc, HORZRES); *width = GetDeviceCaps(dc, HORZRES);
*height = GetDeviceCaps(dc, VERTRES); *height = GetDeviceCaps(dc, VERTRES);
*bpp = GetDeviceCaps(dc, BITSPIXEL); *bpp = GetDeviceCaps(dc, BITSPIXEL);
// ReleaseDC(NULL, dc); // ReleaseDC(nullptr, dc);
DeleteDC(dc); DeleteDC(dc);
} }
else else
@@ -146,10 +146,11 @@ BOOL wfreerdp_server_start(wfServer* server)
wf_settings_read_dword(HKEY_LOCAL_MACHINE, SERVER_KEY, _T("DefaultPort"), &server->port); wf_settings_read_dword(HKEY_LOCAL_MACHINE, SERVER_KEY, _T("DefaultPort"), &server->port);
if (!instance->Open(instance, NULL, (UINT16)server->port)) if (!instance->Open(instance, nullptr, (UINT16)server->port))
return FALSE; return FALSE;
if (!(server->thread = CreateThread(NULL, 0, wf_server_main_loop, (void*)instance, 0, NULL))) if (!(server->thread =
CreateThread(nullptr, 0, wf_server_main_loop, (void*)instance, 0, nullptr)))
return FALSE; return FALSE;
return TRUE; return TRUE;
@@ -174,7 +175,7 @@ wfServer* wfreerdp_server_new()
wfServer* server; wfServer* server;
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
return NULL; return nullptr;
server = (wfServer*)calloc(1, sizeof(wfServer)); server = (wfServer*)calloc(1, sizeof(wfServer));
@@ -185,7 +186,7 @@ wfServer* wfreerdp_server_new()
WTSRegisterWtsApiFunctionTable(FreeRDP_InitWtsApi()); WTSRegisterWtsApiFunctionTable(FreeRDP_InitWtsApi());
cbEvent = NULL; cbEvent = nullptr;
return server; return server;
} }

View File

@@ -43,7 +43,7 @@ BOOL wf_mirror_driver_find_display_device(wfInfo* wfi)
deviceNumber = 0; deviceNumber = 0;
deviceInfo.cb = sizeof(deviceInfo); deviceInfo.cb = sizeof(deviceInfo);
while (result = EnumDisplayDevices(NULL, deviceNumber, &deviceInfo, 0)) while (result = EnumDisplayDevices(nullptr, deviceNumber, &deviceInfo, 0))
{ {
if (_tcscmp(deviceInfo.DeviceString, _T("Mirage Driver")) == 0) if (_tcscmp(deviceInfo.DeviceString, _T("Mirage Driver")) == 0)
{ {
@@ -104,7 +104,8 @@ BOOL wf_mirror_driver_display_device_attach(wfInfo* wfi, DWORD mode)
} }
dwSize = sizeof(DWORD); dwSize = sizeof(DWORD);
status = RegQueryValueEx(hKey, _T("Attach.ToDesktop"), NULL, &dwType, (BYTE*)&dwValue, &dwSize); status =
RegQueryValueEx(hKey, _T("Attach.ToDesktop"), nullptr, &dwType, (BYTE*)&dwValue, &dwSize);
if (status != ERROR_SUCCESS) if (status != ERROR_SUCCESS)
{ {
@@ -236,7 +237,7 @@ BOOL wf_mirror_driver_update(wfInfo* wfi, int mode)
deviceMode->dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION; deviceMode->dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION;
_tcsncpy_s(deviceMode->dmDeviceName, 32, wfi->deviceName, _tcslen(wfi->deviceName)); _tcsncpy_s(deviceMode->dmDeviceName, 32, wfi->deviceName, _tcslen(wfi->deviceName));
disp_change_status = disp_change_status =
ChangeDisplaySettingsEx(wfi->deviceName, deviceMode, NULL, CDS_UPDATEREGISTRY, NULL); ChangeDisplaySettingsEx(wfi->deviceName, deviceMode, nullptr, CDS_UPDATEREGISTRY, nullptr);
status = (disp_change_status == DISP_CHANGE_SUCCESSFUL) ? TRUE : FALSE; status = (disp_change_status == DISP_CHANGE_SUCCESSFUL) ? TRUE : FALSE;
if (!status) if (!status)
@@ -248,9 +249,9 @@ BOOL wf_mirror_driver_update(wfInfo* wfi, int mode)
BOOL wf_mirror_driver_map_memory(wfInfo* wfi) BOOL wf_mirror_driver_map_memory(wfInfo* wfi)
{ {
int status; int status;
wfi->driverDC = CreateDC(wfi->deviceName, NULL, NULL, NULL); wfi->driverDC = CreateDC(wfi->deviceName, nullptr, nullptr, nullptr);
if (wfi->driverDC == NULL) if (wfi->driverDC == nullptr)
{ {
WLog_ERR(TAG, "Could not create device driver context!"); WLog_ERR(TAG, "Could not create device driver context!");
{ {
@@ -258,8 +259,8 @@ BOOL wf_mirror_driver_map_memory(wfInfo* wfi)
DWORD dw = GetLastError(); DWORD dw = GetLastError();
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, nullptr, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf,
NULL); 0, nullptr);
// Display the error message and exit the process // Display the error message and exit the process
WLog_ERR(TAG, "CreateDC failed on device [%s] with error %lu: %s", wfi->deviceName, dw, WLog_ERR(TAG, "CreateDC failed on device [%s] with error %lu: %s", wfi->deviceName, dw,
lpMsgBuf); lpMsgBuf);
@@ -298,7 +299,7 @@ BOOL wf_mirror_driver_cleanup(wfInfo* wfi)
WLog_ERR(TAG, "Failed to unmap shared memory from the driver! code %d", status); WLog_ERR(TAG, "Failed to unmap shared memory from the driver! code %d", status);
} }
if (wfi->driverDC != NULL) if (wfi->driverDC != nullptr)
{ {
status = DeleteDC(wfi->driverDC); status = DeleteDC(wfi->driverDC);

View File

@@ -63,7 +63,7 @@ static BOOL wf_peer_context_new(freerdp_peer* client, rdpContext* ctx)
if (!wf_info_peer_register(context->info, context)) if (!wf_info_peer_register(context->info, context))
{ {
WTSCloseServer(context->vcm); WTSCloseServer(context->vcm);
context->vcm = NULL; context->vcm = nullptr;
return FALSE; return FALSE;
} }
@@ -113,7 +113,7 @@ static BOOL wf_peer_post_connect(freerdp_peer* client)
settings = client->context->settings; settings = client->context->settings;
WINPR_ASSERT(settings); WINPR_ASSERT(settings);
if ((get_screen_info(wfi->screenID, NULL, 0, &wfi->servscreen_width, &wfi->servscreen_height, if ((get_screen_info(wfi->screenID, nullptr, 0, &wfi->servscreen_width, &wfi->servscreen_height,
&wfi->bitsPerPixel) == 0) || &wfi->bitsPerPixel) == 0) ||
(wfi->servscreen_width == 0) || (wfi->servscreen_height == 0) || (wfi->bitsPerPixel == 0)) (wfi->servscreen_width == 0) || (wfi->servscreen_height == 0) || (wfi->bitsPerPixel == 0))
{ {
@@ -179,7 +179,7 @@ BOOL wf_peer_accepted(freerdp_listener* instance, freerdp_peer* client)
{ {
HANDLE hThread; HANDLE hThread;
if (!(hThread = CreateThread(NULL, 0, wf_peer_main_loop, client, 0, NULL))) if (!(hThread = CreateThread(nullptr, 0, wf_peer_main_loop, client, 0, nullptr)))
return FALSE; return FALSE;
(void)CloseHandle(hThread); (void)CloseHandle(hThread);
@@ -237,7 +237,7 @@ static BOOL wf_peer_read_settings(freerdp_peer* client)
settings = client->context->settings; settings = client->context->settings;
WINPR_ASSERT(settings); WINPR_ASSERT(settings);
char* CertificateFile = NULL; char* CertificateFile = nullptr;
if (!wf_settings_read_string_ascii(HKEY_LOCAL_MACHINE, SERVER_KEY, _T("CertificateFile"), if (!wf_settings_read_string_ascii(HKEY_LOCAL_MACHINE, SERVER_KEY, _T("CertificateFile"),
&(CertificateFile))) &(CertificateFile)))
CertificateFile = _strdup("server.crt"); CertificateFile = _strdup("server.crt");
@@ -250,12 +250,12 @@ static BOOL wf_peer_read_settings(freerdp_peer* client)
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerCertificate, cert, 1)) if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerCertificate, cert, 1))
return FALSE; return FALSE;
char* PrivateKeyFile = NULL; char* PrivateKeyFile = nullptr;
if (!wf_settings_read_string_ascii(HKEY_LOCAL_MACHINE, SERVER_KEY, _T("PrivateKeyFile"), if (!wf_settings_read_string_ascii(HKEY_LOCAL_MACHINE, SERVER_KEY, _T("PrivateKeyFile"),
&(PrivateKeyFile))) &(PrivateKeyFile)))
PrivateKeyFile = _strdup("server.key"); PrivateKeyFile = _strdup("server.key");
rdpPrivateKey* key = freerdp_key_new_from_file_enc(PrivateKeyFile, NULL); rdpPrivateKey* key = freerdp_key_new_from_file_enc(PrivateKeyFile, nullptr);
free(PrivateKeyFile); free(PrivateKeyFile);
if (!key) if (!key)
@@ -328,13 +328,14 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam)
client->context->input->ExtendedMouseEvent = wf_peer_extended_mouse_event_dummy; client->context->input->ExtendedMouseEvent = wf_peer_extended_mouse_event_dummy;
} }
if (!(context->socketEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) if (!(context->socketEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
goto fail_socket_event; goto fail_socket_event;
if (!(context->socketSemaphore = CreateSemaphore(NULL, 0, 1, NULL))) if (!(context->socketSemaphore = CreateSemaphore(nullptr, 0, 1, nullptr)))
goto fail_socket_semaphore; goto fail_socket_semaphore;
if (!(context->socketThread = CreateThread(NULL, 0, wf_peer_socket_listener, client, 0, NULL))) if (!(context->socketThread =
CreateThread(nullptr, 0, wf_peer_socket_listener, client, 0, nullptr)))
goto fail_socket_thread; goto fail_socket_thread;
WLog_INFO(TAG, "We've got a client %s", client->local ? "(local)" : client->hostname); WLog_INFO(TAG, "We've got a client %s", client->local ? "(local)" : client->hostname);
@@ -358,7 +359,7 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam)
wf_update_peer_send(wfi, context); wf_update_peer_send(wfi, context);
(void)ResetEvent(context->updateEvent); (void)ResetEvent(context->updateEvent);
ReleaseSemaphore(wfi->updateSemaphore, 1, NULL); ReleaseSemaphore(wfi->updateSemaphore, 1, nullptr);
} }
if (WaitForSingleObject(context->socketEvent, 0) == 0) if (WaitForSingleObject(context->socketEvent, 0) == 0)
@@ -370,7 +371,7 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam)
} }
(void)ResetEvent(context->socketEvent); (void)ResetEvent(context->socketEvent);
ReleaseSemaphore(context->socketSemaphore, 1, NULL); ReleaseSemaphore(context->socketSemaphore, 1, nullptr);
if (context->socketClose) if (context->socketClose)
break; break;
@@ -393,17 +394,17 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam)
if (WaitForSingleObject(context->updateEvent, 0) == 0) if (WaitForSingleObject(context->updateEvent, 0) == 0)
{ {
(void)ResetEvent(context->updateEvent); (void)ResetEvent(context->updateEvent);
ReleaseSemaphore(wfi->updateSemaphore, 1, NULL); ReleaseSemaphore(wfi->updateSemaphore, 1, nullptr);
} }
wf_update_peer_deactivate(wfi, context); wf_update_peer_deactivate(wfi, context);
client->Disconnect(client); client->Disconnect(client);
fail_socket_thread: fail_socket_thread:
(void)CloseHandle(context->socketSemaphore); (void)CloseHandle(context->socketSemaphore);
context->socketSemaphore = NULL; context->socketSemaphore = nullptr;
fail_socket_semaphore: fail_socket_semaphore:
(void)CloseHandle(context->socketEvent); (void)CloseHandle(context->socketEvent);
context->socketEvent = NULL; context->socketEvent = nullptr;
fail_socket_event: fail_socket_event:
fail_socked_closed: fail_socked_closed:
fail_client_initialize: fail_client_initialize:

View File

@@ -46,7 +46,7 @@ static void wf_peer_rdpsnd_activated(RdpsndServerContext* context)
{ {
wfInfo* wfi; wfInfo* wfi;
wfi = wf_info_get_instance(); wfi = wf_info_get_instance();
wfi->agreed_format = NULL; wfi->agreed_format = nullptr;
WLog_DBG(TAG, "Client supports the following %d formats:", context->num_client_formats); WLog_DBG(TAG, "Client supports the following %d formats:", context->num_client_formats);
size_t i = 0; size_t i = 0;
@@ -66,11 +66,11 @@ static void wf_peer_rdpsnd_activated(RdpsndServerContext* context)
} }
} }
if (wfi->agreed_format != NULL) if (wfi->agreed_format != nullptr)
break; break;
} }
if (wfi->agreed_format == NULL) if (wfi->agreed_format == nullptr)
{ {
WLog_ERR(TAG, "Could not agree on a audio format with the server"); WLog_ERR(TAG, "Could not agree on a audio format with the server");
return; return;
@@ -133,7 +133,7 @@ BOOL wf_peer_rdpsnd_init(wfPeerContext* context)
if (!wfi) if (!wfi)
return FALSE; return FALSE;
if (!(wfi->snd_mutex = CreateMutex(NULL, FALSE, NULL))) if (!(wfi->snd_mutex = CreateMutex(nullptr, FALSE, nullptr)))
return FALSE; return FALSE;
context->rdpsnd = rdpsnd_server_context_new(context->vcm); context->rdpsnd = rdpsnd_server_context_new(context->vcm);

View File

@@ -38,7 +38,7 @@ BOOL wf_settings_read_dword(HKEY key, LPCSTR subkey, LPTSTR name, DWORD* value)
{ {
dwSize = sizeof(DWORD); dwSize = sizeof(DWORD);
status = RegQueryValueEx(hKey, name, NULL, &dwType, (BYTE*)&dwValue, &dwSize); status = RegQueryValueEx(hKey, name, nullptr, &dwType, (BYTE*)&dwValue, &dwSize);
if (status == ERROR_SUCCESS) if (status == ERROR_SUCCESS)
*value = dwValue; *value = dwValue;
@@ -59,21 +59,21 @@ BOOL wf_settings_read_string_ascii(HKEY key, LPCSTR subkey, LPTSTR name, char**
DWORD dwType; DWORD dwType;
DWORD dwSize; DWORD dwSize;
char* strA; char* strA;
TCHAR* strX = NULL; TCHAR* strX = nullptr;
status = RegOpenKeyExA(key, subkey, 0, KEY_READ | KEY_WOW64_64KEY, &hKey); status = RegOpenKeyExA(key, subkey, 0, KEY_READ | KEY_WOW64_64KEY, &hKey);
if (status != ERROR_SUCCESS) if (status != ERROR_SUCCESS)
return FALSE; return FALSE;
status = RegQueryValueEx(hKey, name, NULL, &dwType, NULL, &dwSize); status = RegQueryValueEx(hKey, name, nullptr, &dwType, nullptr, &dwSize);
if (status == ERROR_SUCCESS) if (status == ERROR_SUCCESS)
{ {
strX = (LPTSTR)malloc(dwSize + sizeof(TCHAR)); strX = (LPTSTR)malloc(dwSize + sizeof(TCHAR));
if (!strX) if (!strX)
return FALSE; return FALSE;
status = RegQueryValueEx(hKey, name, NULL, &dwType, (BYTE*)strX, &dwSize); status = RegQueryValueEx(hKey, name, nullptr, &dwType, (BYTE*)strX, &dwSize);
if (status != ERROR_SUCCESS) if (status != ERROR_SUCCESS)
{ {
@@ -86,9 +86,10 @@ BOOL wf_settings_read_string_ascii(HKEY key, LPCSTR subkey, LPTSTR name, char**
if (strX) if (strX)
{ {
#ifdef UNICODE #ifdef UNICODE
length = WideCharToMultiByte(CP_UTF8, 0, strX, lstrlenW(strX), NULL, 0, NULL, NULL); length =
WideCharToMultiByte(CP_UTF8, 0, strX, lstrlenW(strX), nullptr, 0, nullptr, nullptr);
strA = (char*)malloc(length + 1); strA = (char*)malloc(length + 1);
WideCharToMultiByte(CP_UTF8, 0, strX, lstrlenW(strX), strA, length, NULL, NULL); WideCharToMultiByte(CP_UTF8, 0, strX, lstrlenW(strX), strA, length, nullptr, nullptr);
strA[length] = '\0'; strA[length] = '\0';
free(strX); free(strX);
#else #else

View File

@@ -108,7 +108,7 @@ void wf_update_encode(wfInfo* wfi)
{ {
RFX_RECT rect; RFX_RECT rect;
long height, width; long height, width;
BYTE* pDataBits = NULL; BYTE* pDataBits = nullptr;
int stride; int stride;
SURFACE_BITS_COMMAND* cmd; SURFACE_BITS_COMMAND* cmd;
wf_info_find_invalid_region(wfi); wf_info_find_invalid_region(wfi);
@@ -202,7 +202,7 @@ void wf_update_encoder_reset(wfInfo* wfi)
rfx_context_set_mode(wfi->rfx_context, RLGR3); rfx_context_set_mode(wfi->rfx_context, RLGR3);
rfx_context_reset(wfi->rfx_context, wfi->servscreen_width, wfi->servscreen_height); rfx_context_reset(wfi->rfx_context, wfi->servscreen_width, wfi->servscreen_height);
rfx_context_set_pixel_format(wfi->rfx_context, PIXEL_FORMAT_BGRA32); rfx_context_set_pixel_format(wfi->rfx_context, PIXEL_FORMAT_BGRA32);
wfi->s = Stream_New(NULL, 0xFFFF); wfi->s = Stream_New(nullptr, 0xFFFF);
} }
wf_info_invalidate_full_screen(wfi); wf_info_invalidate_full_screen(wfi);

View File

@@ -30,8 +30,8 @@ DEFINE_GUID(IID_IAudioCaptureClient, 0xc8adbd64, 0xe71e, 0x48a0, 0xa4, 0xde, 0x1
0xd3, 0x17); 0xd3, 0x17);
#endif #endif
LPWSTR devStr = NULL; LPWSTR devStr = nullptr;
wfPeerContext* latestPeer = NULL; wfPeerContext* latestPeer = nullptr;
int wf_rdpsnd_set_latest_peer(wfPeerContext* peer) int wf_rdpsnd_set_latest_peer(wfPeerContext* peer)
{ {
@@ -46,14 +46,14 @@ int wf_wasapi_activate(RdpsndServerContext* context)
wf_wasapi_get_device_string(pattern, &devStr); wf_wasapi_get_device_string(pattern, &devStr);
if (devStr == NULL) if (devStr == nullptr)
{ {
WLog_ERR(TAG, "Failed to match for output device! Disabling rdpsnd."); WLog_ERR(TAG, "Failed to match for output device! Disabling rdpsnd.");
return 1; return 1;
} }
WLog_DBG(TAG, "RDPSND (WASAPI) Activated"); WLog_DBG(TAG, "RDPSND (WASAPI) Activated");
if (!(hThread = CreateThread(NULL, 0, wf_rdpsnd_wasapi_thread, latestPeer, 0, NULL))) if (!(hThread = CreateThread(nullptr, 0, wf_rdpsnd_wasapi_thread, latestPeer, 0, nullptr)))
{ {
WLog_ERR(TAG, "CreateThread failed"); WLog_ERR(TAG, "CreateThread failed");
return 1; return 1;
@@ -66,15 +66,15 @@ int wf_wasapi_activate(RdpsndServerContext* context)
int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR* deviceStr) int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR* deviceStr)
{ {
HRESULT hr; HRESULT hr;
IMMDeviceEnumerator* pEnumerator = NULL; IMMDeviceEnumerator* pEnumerator = nullptr;
IMMDeviceCollection* pCollection = NULL; IMMDeviceCollection* pCollection = nullptr;
IMMDevice* pEndpoint = NULL; IMMDevice* pEndpoint = nullptr;
IPropertyStore* pProps = NULL; IPropertyStore* pProps = nullptr;
LPWSTR pwszID = NULL; LPWSTR pwszID = nullptr;
unsigned int count; unsigned int count;
CoInitialize(NULL); CoInitialize(nullptr);
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &IID_IMMDeviceEnumerator, hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, &IID_IMMDeviceEnumerator,
(void**)&pEnumerator); (void**)&pEnumerator);
if (FAILED(hr)) if (FAILED(hr))
{ {
@@ -145,21 +145,21 @@ int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR* deviceStr)
wcscpy_s(*deviceStr, devStrLen + 1, pwszID); wcscpy_s(*deviceStr, devStrLen + 1, pwszID);
} }
CoTaskMemFree(pwszID); CoTaskMemFree(pwszID);
pwszID = NULL; pwszID = nullptr;
PropVariantClear(&nameVar); PropVariantClear(&nameVar);
pProps->lpVtbl->Release(pProps); pProps->lpVtbl->Release(pProps);
pProps = NULL; pProps = nullptr;
pEndpoint->lpVtbl->Release(pEndpoint); pEndpoint->lpVtbl->Release(pEndpoint);
pEndpoint = NULL; pEndpoint = nullptr;
} }
pCollection->lpVtbl->Release(pCollection); pCollection->lpVtbl->Release(pCollection);
pCollection = NULL; pCollection = nullptr;
pEnumerator->lpVtbl->Release(pEnumerator); pEnumerator->lpVtbl->Release(pEnumerator);
pEnumerator = NULL; pEnumerator = nullptr;
CoUninitialize(); CoUninitialize();
return 0; return 0;
@@ -167,11 +167,11 @@ int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR* deviceStr)
DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam) DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
{ {
IMMDeviceEnumerator* pEnumerator = NULL; IMMDeviceEnumerator* pEnumerator = nullptr;
IMMDevice* pDevice = NULL; IMMDevice* pDevice = nullptr;
IAudioClient* pAudioClient = NULL; IAudioClient* pAudioClient = nullptr;
IAudioCaptureClient* pCaptureClient = NULL; IAudioCaptureClient* pCaptureClient = nullptr;
WAVEFORMATEX* pwfx = NULL; WAVEFORMATEX* pwfx = nullptr;
HRESULT hr; HRESULT hr;
REFERENCE_TIME hnsRequestedDuration = REFTIMES_PER_SEC; REFERENCE_TIME hnsRequestedDuration = REFTIMES_PER_SEC;
REFERENCE_TIME hnsActualDuration; REFERENCE_TIME hnsActualDuration;
@@ -187,8 +187,8 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
wfi = wf_info_get_instance(); wfi = wf_info_get_instance();
context = (wfPeerContext*)lpParam; context = (wfPeerContext*)lpParam;
CoInitialize(NULL); CoInitialize(nullptr);
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &IID_IMMDeviceEnumerator, hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, &IID_IMMDeviceEnumerator,
(void**)&pEnumerator); (void**)&pEnumerator);
if (FAILED(hr)) if (FAILED(hr))
{ {
@@ -203,7 +203,7 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
exit(1); exit(1);
} }
hr = pDevice->lpVtbl->Activate(pDevice, &IID_IAudioClient, CLSCTX_ALL, NULL, hr = pDevice->lpVtbl->Activate(pDevice, &IID_IAudioClient, CLSCTX_ALL, nullptr,
(void**)&pAudioClient); (void**)&pAudioClient);
if (FAILED(hr)) if (FAILED(hr))
{ {
@@ -227,7 +227,7 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
pwfx->cbSize = wfi->agreed_format->cbSize; pwfx->cbSize = wfi->agreed_format->cbSize;
hr = pAudioClient->lpVtbl->Initialize(pAudioClient, AUDCLNT_SHAREMODE_SHARED, 0, hr = pAudioClient->lpVtbl->Initialize(pAudioClient, AUDCLNT_SHAREMODE_SHARED, 0,
hnsRequestedDuration, 0, pwfx, NULL); hnsRequestedDuration, 0, pwfx, nullptr);
if (FAILED(hr)) if (FAILED(hr))
{ {
@@ -277,7 +277,7 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
while (packetLength != 0) while (packetLength != 0)
{ {
hr = pCaptureClient->lpVtbl->GetBuffer(pCaptureClient, &pData, &numFramesAvailable, hr = pCaptureClient->lpVtbl->GetBuffer(pCaptureClient, &pData, &numFramesAvailable,
&flags, NULL, NULL); &flags, nullptr, nullptr);
if (FAILED(hr)) if (FAILED(hr))
{ {
WLog_ERR(TAG, "Failed to get buffer"); WLog_ERR(TAG, "Failed to get buffer");
@@ -315,16 +315,16 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam)
CoTaskMemFree(pwfx); CoTaskMemFree(pwfx);
if (pEnumerator != NULL) if (pEnumerator != nullptr)
pEnumerator->lpVtbl->Release(pEnumerator); pEnumerator->lpVtbl->Release(pEnumerator);
if (pDevice != NULL) if (pDevice != nullptr)
pDevice->lpVtbl->Release(pDevice); pDevice->lpVtbl->Release(pDevice);
if (pAudioClient != NULL) if (pAudioClient != nullptr)
pAudioClient->lpVtbl->Release(pAudioClient); pAudioClient->lpVtbl->Release(pAudioClient);
if (pCaptureClient != NULL) if (pCaptureClient != nullptr)
pCaptureClient->lpVtbl->Release(pCaptureClient); pCaptureClient->lpVtbl->Release(pCaptureClient);
CoUninitialize(); CoUninitialize();

View File

@@ -46,14 +46,14 @@ size_t server_audin_get_formats(AUDIO_FORMAT** dst_formats)
BYTE gsm610_data[] = { 0x40, 0x01 }; BYTE gsm610_data[] = { 0x40, 0x01 };
const AUDIO_FORMAT default_supported_audio_formats[] = { const AUDIO_FORMAT default_supported_audio_formats[] = {
/* Formats sent by windows 10 server */ /* Formats sent by windows 10 server */
{ WAVE_FORMAT_AAC_MS, 2, 44100, 24000, 4, 16, 0, NULL }, { WAVE_FORMAT_AAC_MS, 2, 44100, 24000, 4, 16, 0, nullptr },
{ WAVE_FORMAT_AAC_MS, 2, 44100, 20000, 4, 16, 0, NULL }, { WAVE_FORMAT_AAC_MS, 2, 44100, 20000, 4, 16, 0, nullptr },
{ WAVE_FORMAT_AAC_MS, 2, 44100, 16000, 4, 16, 0, NULL }, { WAVE_FORMAT_AAC_MS, 2, 44100, 16000, 4, 16, 0, nullptr },
{ WAVE_FORMAT_AAC_MS, 2, 44100, 12000, 4, 16, 0, NULL }, { WAVE_FORMAT_AAC_MS, 2, 44100, 12000, 4, 16, 0, nullptr },
{ WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, NULL }, { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, nullptr },
{ WAVE_FORMAT_ADPCM, 2, 44100, 44359, 2048, 4, 32, adpcm_data_7 }, { WAVE_FORMAT_ADPCM, 2, 44100, 44359, 2048, 4, 32, adpcm_data_7 },
{ WAVE_FORMAT_DVI_ADPCM, 2, 44100, 44251, 2048, 4, 2, adpcm_dvi_data_7 }, { WAVE_FORMAT_DVI_ADPCM, 2, 44100, 44251, 2048, 4, 2, adpcm_dvi_data_7 },
{ WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, NULL }, { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, nullptr },
{ WAVE_FORMAT_ADPCM, 2, 22050, 22311, 1024, 4, 32, adpcm_data_3 }, { WAVE_FORMAT_ADPCM, 2, 22050, 22311, 1024, 4, 32, adpcm_data_3 },
{ WAVE_FORMAT_DVI_ADPCM, 2, 22050, 22201, 1024, 4, 2, adpcm_dvi_data_3 }, { WAVE_FORMAT_DVI_ADPCM, 2, 22050, 22201, 1024, 4, 2, adpcm_dvi_data_3 },
{ WAVE_FORMAT_ADPCM, 1, 44100, 22179, 1024, 4, 32, adpcm_data_7 }, { WAVE_FORMAT_ADPCM, 1, 44100, 22179, 1024, 4, 32, adpcm_data_7 },
@@ -74,22 +74,22 @@ size_t server_audin_get_formats(AUDIO_FORMAT** dst_formats)
{ WAVE_FORMAT_GSM610, 1, 8000, 1625, 65, 0, 2, gsm610_data }, { WAVE_FORMAT_GSM610, 1, 8000, 1625, 65, 0, 2, gsm610_data },
/* Formats added for others */ /* Formats added for others */
{ WAVE_FORMAT_MSG723, 2, 44100, 0, 4, 16, 0, NULL }, { WAVE_FORMAT_MSG723, 2, 44100, 0, 4, 16, 0, nullptr },
{ WAVE_FORMAT_MSG723, 2, 22050, 0, 4, 16, 0, NULL }, { WAVE_FORMAT_MSG723, 2, 22050, 0, 4, 16, 0, nullptr },
{ WAVE_FORMAT_MSG723, 1, 44100, 0, 4, 16, 0, NULL }, { WAVE_FORMAT_MSG723, 1, 44100, 0, 4, 16, 0, nullptr },
{ WAVE_FORMAT_MSG723, 1, 22050, 0, 4, 16, 0, NULL }, { WAVE_FORMAT_MSG723, 1, 22050, 0, 4, 16, 0, nullptr },
{ WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, NULL }, { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, nullptr },
{ WAVE_FORMAT_PCM, 2, 22050, 88200, 4, 16, 0, NULL }, { WAVE_FORMAT_PCM, 2, 22050, 88200, 4, 16, 0, nullptr },
{ WAVE_FORMAT_PCM, 1, 44100, 88200, 4, 16, 0, NULL }, { WAVE_FORMAT_PCM, 1, 44100, 88200, 4, 16, 0, nullptr },
{ WAVE_FORMAT_PCM, 1, 22050, 44100, 4, 16, 0, NULL }, { WAVE_FORMAT_PCM, 1, 22050, 44100, 4, 16, 0, nullptr },
{ WAVE_FORMAT_MULAW, 2, 44100, 88200, 4, 16, 0, NULL }, { WAVE_FORMAT_MULAW, 2, 44100, 88200, 4, 16, 0, nullptr },
{ WAVE_FORMAT_MULAW, 2, 22050, 44100, 4, 16, 0, NULL }, { WAVE_FORMAT_MULAW, 2, 22050, 44100, 4, 16, 0, nullptr },
{ WAVE_FORMAT_MULAW, 1, 44100, 44100, 4, 16, 0, NULL }, { WAVE_FORMAT_MULAW, 1, 44100, 44100, 4, 16, 0, nullptr },
{ WAVE_FORMAT_MULAW, 1, 22050, 22050, 4, 16, 0, NULL }, { WAVE_FORMAT_MULAW, 1, 22050, 22050, 4, 16, 0, nullptr },
{ WAVE_FORMAT_ALAW, 2, 44100, 88200, 2, 8, 0, NULL }, { WAVE_FORMAT_ALAW, 2, 44100, 88200, 2, 8, 0, nullptr },
{ WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, NULL }, { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, nullptr },
{ WAVE_FORMAT_ALAW, 1, 44100, 44100, 2, 8, 0, NULL }, { WAVE_FORMAT_ALAW, 1, 44100, 44100, 2, 8, 0, nullptr },
{ WAVE_FORMAT_ALAW, 1, 22050, 22050, 2, 8, 0, NULL } { WAVE_FORMAT_ALAW, 1, 22050, 22050, 2, 8, 0, nullptr }
}; };
const size_t nrDefaultFormatsMax = ARRAYSIZE(default_supported_audio_formats); const size_t nrDefaultFormatsMax = ARRAYSIZE(default_supported_audio_formats);
size_t nr_formats = 0; size_t nr_formats = 0;
@@ -98,7 +98,7 @@ size_t server_audin_get_formats(AUDIO_FORMAT** dst_formats)
if (!dst_formats) if (!dst_formats)
goto fail; goto fail;
*dst_formats = NULL; *dst_formats = nullptr;
if (!formats) if (!formats)
goto fail; goto fail;
@@ -127,14 +127,14 @@ size_t server_rdpsnd_get_formats(AUDIO_FORMAT** dst_formats)
{ {
/* Default supported audio formats */ /* Default supported audio formats */
static const AUDIO_FORMAT default_supported_audio_formats[] = { static const AUDIO_FORMAT default_supported_audio_formats[] = {
{ WAVE_FORMAT_AAC_MS, 2, 44100, 176400, 4, 16, 0, NULL }, { WAVE_FORMAT_AAC_MS, 2, 44100, 176400, 4, 16, 0, nullptr },
{ WAVE_FORMAT_MPEGLAYER3, 2, 44100, 176400, 4, 16, 0, NULL }, { WAVE_FORMAT_MPEGLAYER3, 2, 44100, 176400, 4, 16, 0, nullptr },
{ WAVE_FORMAT_MSG723, 2, 44100, 176400, 4, 16, 0, NULL }, { WAVE_FORMAT_MSG723, 2, 44100, 176400, 4, 16, 0, nullptr },
{ WAVE_FORMAT_GSM610, 2, 44100, 176400, 4, 16, 0, NULL }, { WAVE_FORMAT_GSM610, 2, 44100, 176400, 4, 16, 0, nullptr },
{ WAVE_FORMAT_ADPCM, 2, 44100, 176400, 4, 16, 0, NULL }, { WAVE_FORMAT_ADPCM, 2, 44100, 176400, 4, 16, 0, nullptr },
{ WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, NULL }, { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, nullptr },
{ WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, NULL }, { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, nullptr },
{ WAVE_FORMAT_MULAW, 2, 22050, 44100, 2, 8, 0, NULL }, { WAVE_FORMAT_MULAW, 2, 22050, 44100, 2, 8, 0, nullptr },
}; };
AUDIO_FORMAT* supported_audio_formats = AUDIO_FORMAT* supported_audio_formats =
audio_formats_new(ARRAYSIZE(default_supported_audio_formats)); audio_formats_new(ARRAYSIZE(default_supported_audio_formats));
@@ -160,7 +160,7 @@ fail:
audio_formats_free(supported_audio_formats, ARRAYSIZE(default_supported_audio_formats)); audio_formats_free(supported_audio_formats, ARRAYSIZE(default_supported_audio_formats));
if (dst_formats) if (dst_formats)
*dst_formats = NULL; *dst_formats = nullptr;
return 0; return 0;
} }

View File

@@ -125,13 +125,13 @@ static void dyn_log_(wLog* log, DWORD level, const pServerDynamicChannelContext*
if (!WLog_IsLevelActive(log, level)) if (!WLog_IsLevelActive(log, level))
return; return;
char* prefix = NULL; char* prefix = nullptr;
char* msg = NULL; char* msg = nullptr;
size_t prefixlen = 0; size_t prefixlen = 0;
size_t msglen = 0; size_t msglen = 0;
uint32_t channelId = dynChannel ? dynChannel->channelId : UINT32_MAX; uint32_t channelId = dynChannel ? dynChannel->channelId : UINT32_MAX;
const char* channelName = dynChannel ? dynChannel->channelName : "<NULL>"; const char* channelName = dynChannel ? dynChannel->channelName : "<nullptr>";
(void)winpr_asprintf(&prefix, &prefixlen, "DynvcTracker[%s](%s [%s:%" PRIu32 "])", (void)winpr_asprintf(&prefix, &prefixlen, "DynvcTracker[%s](%s [%s:%" PRIu32 "])",
getDirection(isBackData), channelName, drdynvc_get_packet_type(cmd), getDirection(isBackData), channelName, drdynvc_get_packet_type(cmd),
channelId); channelId);
@@ -206,7 +206,7 @@ static pServerDynamicChannelContext* DynamicChannelContext_new(wLog* log, pServe
if (!ret) if (!ret)
{ {
WLog_Print(log, WLOG_ERROR, "error allocating dynamic channel context '%s'", name); WLog_Print(log, WLOG_ERROR, "error allocating dynamic channel context '%s'", name);
return NULL; return nullptr;
} }
ret->channelId = id; ret->channelId = id;
@@ -215,7 +215,7 @@ static pServerDynamicChannelContext* DynamicChannelContext_new(wLog* log, pServe
{ {
WLog_Print(log, WLOG_ERROR, "error allocating name in dynamic channel context '%s'", name); WLog_Print(log, WLOG_ERROR, "error allocating name in dynamic channel context '%s'", name);
free(ret); free(ret);
return NULL; return nullptr;
} }
ret->frontTracker.dataCallback = data_cb; ret->frontTracker.dataCallback = data_cb;
@@ -389,7 +389,7 @@ static PfChannelResult DynvcTrackerHandleCreateBack(ChannelStateTracker* tracker
DynvcTrackerLog(dynChannelContext->log, WLOG_ERROR, dynChannel, cmd, isBackData, DynvcTrackerLog(dynChannelContext->log, WLOG_ERROR, dynChannel, cmd, isBackData,
"channel id %" PRIu64 ", name=%s [%" PRIuz "|%" PRIuz "], status=%s", "channel id %" PRIu64 ", name=%s [%" PRIuz "|%" PRIuz "], status=%s",
dynChannelId, namebuffer, len, nameLen, dynChannelId, namebuffer, len, nameLen,
dynChannel ? openstatus2str(dynChannel->openStatus) : "NULL"); dynChannel ? openstatus2str(dynChannel->openStatus) : "nullptr");
return PF_CHANNEL_RESULT_ERROR; return PF_CHANNEL_RESULT_ERROR;
} }
@@ -518,7 +518,7 @@ static PfChannelResult DynvcTrackerHandleCmdDATA(ChannelStateTracker* tracker,
if (!dynChannel) if (!dynChannel)
{ {
DynvcTrackerLog(dynChannelContext->log, WLOG_WARN, dynChannel, cmd, isBackData, DynvcTrackerLog(dynChannelContext->log, WLOG_WARN, dynChannel, cmd, isBackData,
"channel is NULL, dropping packet"); "channel is nullptr, dropping packet");
return PF_CHANNEL_RESULT_DROP; return PF_CHANNEL_RESULT_DROP;
} }
@@ -573,7 +573,7 @@ static PfChannelResult DynvcTrackerHandleCmdDATA(ChannelStateTracker* tracker,
{ {
if (!trackerState->currentPacket) if (!trackerState->currentPacket)
{ {
trackerState->currentPacket = Stream_New(NULL, 1024); trackerState->currentPacket = Stream_New(nullptr, 1024);
if (!trackerState->currentPacket) if (!trackerState->currentPacket)
{ {
DynvcTrackerLog(dynChannelContext->log, WLOG_ERROR, dynChannel, cmd, DynvcTrackerLog(dynChannelContext->log, WLOG_ERROR, dynChannel, cmd,
@@ -702,13 +702,13 @@ WINPR_ATTR_NODISCARD
static PfChannelResult DynvcTrackerPeekFn(ChannelStateTracker* tracker, BOOL firstPacket, static PfChannelResult DynvcTrackerPeekFn(ChannelStateTracker* tracker, BOOL firstPacket,
BOOL lastPacket) BOOL lastPacket)
{ {
wStream* s = NULL; wStream* s = nullptr;
wStream sbuffer; wStream sbuffer;
BOOL haveChannelId = 0; BOOL haveChannelId = 0;
BOOL haveLength = 0; BOOL haveLength = 0;
UINT64 dynChannelId = 0; UINT64 dynChannelId = 0;
UINT64 Length = 0; UINT64 Length = 0;
pServerDynamicChannelContext* dynChannel = NULL; pServerDynamicChannelContext* dynChannel = nullptr;
WINPR_ASSERT(tracker); WINPR_ASSERT(tracker);
@@ -836,7 +836,7 @@ static DynChannelContext* DynChannelContext_new(proxyData* pdata,
{ {
DynChannelContext* dyn = calloc(1, sizeof(DynChannelContext)); DynChannelContext* dyn = calloc(1, sizeof(DynChannelContext));
if (!dyn) if (!dyn)
return NULL; return nullptr;
dyn->log = WLog_Get(DTAG); dyn->log = WLog_Get(DTAG);
WINPR_ASSERT(dyn->log); WINPR_ASSERT(dyn->log);
@@ -877,7 +877,7 @@ static DynChannelContext* DynChannelContext_new(proxyData* pdata,
fail: fail:
DynChannelContext_free(dyn); DynChannelContext_free(dyn);
return NULL; return nullptr;
} }
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD

View File

@@ -200,9 +200,9 @@ static wStream* rdpdr_get_send_buffer(pf_channel_common_context* rdpdr, UINT16 c
WINPR_ASSERT(rdpdr); WINPR_ASSERT(rdpdr);
WINPR_ASSERT(rdpdr->s); WINPR_ASSERT(rdpdr->s);
if (!Stream_SetPosition(rdpdr->s, 0)) if (!Stream_SetPosition(rdpdr->s, 0))
return NULL; return nullptr;
if (!Stream_EnsureCapacity(rdpdr->s, capacity + 4)) if (!Stream_EnsureCapacity(rdpdr->s, capacity + 4))
return NULL; return nullptr;
Stream_Write_UINT16(rdpdr->s, component); Stream_Write_UINT16(rdpdr->s, component);
Stream_Write_UINT16(rdpdr->s, PacketID); Stream_Write_UINT16(rdpdr->s, PacketID);
return rdpdr->s; return rdpdr->s;
@@ -271,7 +271,7 @@ static UINT rdpdr_seal_send_free_request(pf_channel_server_context* context, wSt
WINPR_ASSERT(len <= UINT32_MAX); WINPR_ASSERT(len <= UINT32_MAX);
rdpdr_dump_send_packet(context->log, WLOG_TRACE, s, proxy_client_tx); rdpdr_dump_send_packet(context->log, WLOG_TRACE, s, proxy_client_tx);
status = WTSVirtualChannelWrite(context->handle, Stream_BufferAs(s, char), (ULONG)len, NULL); status = WTSVirtualChannelWrite(context->handle, Stream_BufferAs(s, char), (ULONG)len, nullptr);
return (status) ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR; return (status) ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR;
} }
@@ -507,7 +507,7 @@ static UINT rdpdr_process_client_name_request(pf_channel_server_context* rdpdr,
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static UINT rdpdr_send_client_name_request(pClientContext* pc, pf_channel_client_context* rdpdr) static UINT rdpdr_send_client_name_request(pClientContext* pc, pf_channel_client_context* rdpdr)
{ {
wStream* s = NULL; wStream* s = nullptr;
WINPR_ASSERT(rdpdr); WINPR_ASSERT(rdpdr);
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
@@ -826,7 +826,7 @@ WINPR_ATTR_NODISCARD
static UINT rdpdr_send_client_capability_response(pClientContext* pc, static UINT rdpdr_send_client_capability_response(pClientContext* pc,
pf_channel_client_context* rdpdr) pf_channel_client_context* rdpdr)
{ {
wStream* s = NULL; wStream* s = nullptr;
WINPR_ASSERT(rdpdr); WINPR_ASSERT(rdpdr);
s = rdpdr_client_get_send_buffer(rdpdr, RDPDR_CTYP_CORE, PAKID_CORE_CLIENT_CAPABILITY, 4); s = rdpdr_client_get_send_buffer(rdpdr, RDPDR_CTYP_CORE, PAKID_CORE_CLIENT_CAPABILITY, 4);
@@ -851,7 +851,7 @@ static UINT rdpdr_send_client_capability_response(pClientContext* pc,
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static UINT rdpdr_send_server_clientid_confirm(pf_channel_server_context* rdpdr) static UINT rdpdr_send_server_clientid_confirm(pf_channel_server_context* rdpdr)
{ {
wStream* s = NULL; wStream* s = nullptr;
s = rdpdr_server_get_send_buffer(rdpdr, RDPDR_CTYP_CORE, PAKID_CORE_CLIENTID_CONFIRM, 8); s = rdpdr_server_get_send_buffer(rdpdr, RDPDR_CTYP_CORE, PAKID_CORE_CLIENTID_CONFIRM, 8);
if (!s) if (!s)
@@ -973,7 +973,7 @@ WINPR_ATTR_NODISCARD
static UINT rdpdr_send_emulated_scard_device_list_announce_request(pClientContext* pc, static UINT rdpdr_send_emulated_scard_device_list_announce_request(pClientContext* pc,
pf_channel_client_context* rdpdr) pf_channel_client_context* rdpdr)
{ {
wStream* s = NULL; wStream* s = nullptr;
s = rdpdr_client_get_send_buffer(rdpdr, RDPDR_CTYP_CORE, PAKID_CORE_DEVICELIST_ANNOUNCE, 24); s = rdpdr_client_get_send_buffer(rdpdr, RDPDR_CTYP_CORE, PAKID_CORE_DEVICELIST_ANNOUNCE, 24);
if (!s) if (!s)
@@ -994,7 +994,7 @@ WINPR_ATTR_NODISCARD
static UINT rdpdr_send_emulated_scard_device_remove(pClientContext* pc, static UINT rdpdr_send_emulated_scard_device_remove(pClientContext* pc,
pf_channel_client_context* rdpdr) pf_channel_client_context* rdpdr)
{ {
wStream* s = NULL; wStream* s = nullptr;
s = rdpdr_client_get_send_buffer(rdpdr, RDPDR_CTYP_CORE, PAKID_CORE_DEVICELIST_REMOVE, 24); s = rdpdr_client_get_send_buffer(rdpdr, RDPDR_CTYP_CORE, PAKID_CORE_DEVICELIST_REMOVE, 24);
if (!s) if (!s)
@@ -1059,7 +1059,7 @@ static BOOL pf_channel_rdpdr_rewrite_device_list_to(wStream* s, UINT32 fromVersi
return TRUE; return TRUE;
const size_t cap = Stream_GetRemainingLength(s); const size_t cap = Stream_GetRemainingLength(s);
wStream* clone = Stream_New(NULL, cap); wStream* clone = Stream_New(nullptr, cap);
if (!clone) if (!clone)
goto fail; goto fail;
@@ -1356,9 +1356,9 @@ static BOOL rdpdr_handle_server_announce_request(pClientContext* pc,
BOOL pf_channel_rdpdr_client_handle(pClientContext* pc, UINT16 channelId, const char* channel_name, BOOL pf_channel_rdpdr_client_handle(pClientContext* pc, UINT16 channelId, const char* channel_name,
const BYTE* xdata, size_t xsize, UINT32 flags, size_t totalSize) const BYTE* xdata, size_t xsize, UINT32 flags, size_t totalSize)
{ {
pf_channel_client_context* rdpdr = NULL; pf_channel_client_context* rdpdr = nullptr;
pServerContext* ps = NULL; pServerContext* ps = nullptr;
wStream* s = NULL; wStream* s = nullptr;
#if defined(WITH_PROXY_EMULATE_SMARTCARD) #if defined(WITH_PROXY_EMULATE_SMARTCARD)
UINT16 packetid = 0; UINT16 packetid = 0;
#endif #endif
@@ -1529,14 +1529,14 @@ static BOOL pf_channel_rdpdr_common_context_new(pf_channel_common_context* commo
if (!common) if (!common)
return FALSE; return FALSE;
common->base.free = fkt; common->base.free = fkt;
common->s = Stream_New(NULL, 1024); common->s = Stream_New(nullptr, 1024);
if (!common->s) if (!common->s)
return FALSE; return FALSE;
common->buffer = Stream_New(NULL, 1024); common->buffer = Stream_New(nullptr, 1024);
if (!common->buffer) if (!common->buffer)
return FALSE; return FALSE;
common->computerNameUnicode = 1; common->computerNameUnicode = 1;
common->computerName.v = NULL; common->computerName.v = nullptr;
common->versionMajor = RDPDR_VERSION_MAJOR; common->versionMajor = RDPDR_VERSION_MAJOR;
common->versionMinor = RDPDR_VERSION_MINOR_RDP10X; common->versionMinor = RDPDR_VERSION_MINOR_RDP10X;
common->clientID = SCARD_DEVICE_ID; common->clientID = SCARD_DEVICE_ID;
@@ -1557,7 +1557,7 @@ static BOOL pf_channel_rdpdr_client_pass_message(pServerContext* ps, pClientCont
WINPR_ATTR_UNUSED UINT16 channelId, WINPR_ATTR_UNUSED UINT16 channelId,
const char* channel_name, wStream* s) const char* channel_name, wStream* s)
{ {
pf_channel_client_context* rdpdr = NULL; pf_channel_client_context* rdpdr = nullptr;
WINPR_ASSERT(ps); WINPR_ASSERT(ps);
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
@@ -1739,9 +1739,9 @@ WINPR_ATTR_NODISCARD
static void* stream_copy(const void* obj) static void* stream_copy(const void* obj)
{ {
const wStream* src = obj; const wStream* src = obj;
wStream* dst = Stream_New(NULL, Stream_Capacity(src)); wStream* dst = Stream_New(nullptr, Stream_Capacity(src));
if (!dst) if (!dst)
return NULL; return nullptr;
memcpy(Stream_Buffer(dst), Stream_ConstBuffer(src), Stream_Capacity(dst)); memcpy(Stream_Buffer(dst), Stream_ConstBuffer(src), Stream_Capacity(dst));
Stream_SetLength(dst, Stream_Length(src)); Stream_SetLength(dst, Stream_Length(src));
Stream_SetPosition(dst, Stream_GetPosition(src)); Stream_SetPosition(dst, Stream_GetPosition(src));
@@ -1767,8 +1767,8 @@ static const char* pf_channel_rdpdr_client_context(void* arg)
BOOL pf_channel_rdpdr_client_new(pClientContext* pc) BOOL pf_channel_rdpdr_client_new(pClientContext* pc)
{ {
wObject* obj = NULL; wObject* obj = nullptr;
pf_channel_client_context* rdpdr = NULL; pf_channel_client_context* rdpdr = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
WINPR_ASSERT(pc->interceptContextMap); WINPR_ASSERT(pc->interceptContextMap);
@@ -1835,8 +1835,8 @@ static const char* pf_channel_rdpdr_server_context(void* arg)
BOOL pf_channel_rdpdr_server_new(pServerContext* ps) BOOL pf_channel_rdpdr_server_new(pServerContext* ps)
{ {
pf_channel_server_context* rdpdr = NULL; pf_channel_server_context* rdpdr = nullptr;
PULONG pSessionId = NULL; PULONG pSessionId = nullptr;
DWORD BytesReturned = 0; DWORD BytesReturned = 0;
WINPR_ASSERT(ps); WINPR_ASSERT(ps);
@@ -1866,7 +1866,7 @@ BOOL pf_channel_rdpdr_server_new(pServerContext* ps)
} }
rdpdr->handle = WTSVirtualChannelOpenEx(rdpdr->SessionId, RDPDR_SVC_CHANNEL_NAME, 0); rdpdr->handle = WTSVirtualChannelOpenEx(rdpdr->SessionId, RDPDR_SVC_CHANNEL_NAME, 0);
if (rdpdr->handle == 0) if (rdpdr->handle == nullptr)
goto fail; goto fail;
if (!HashTable_Insert(ps->interceptContextMap, RDPDR_SVC_CHANNEL_NAME, rdpdr)) if (!HashTable_Insert(ps->interceptContextMap, RDPDR_SVC_CHANNEL_NAME, rdpdr))
goto fail; goto fail;
@@ -1888,7 +1888,7 @@ void pf_channel_rdpdr_server_free(pServerContext* ps)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static pf_channel_server_context* get_channel(pServerContext* ps, BOOL send) static pf_channel_server_context* get_channel(pServerContext* ps, BOOL send)
{ {
pf_channel_server_context* rdpdr = NULL; pf_channel_server_context* rdpdr = nullptr;
WINPR_ASSERT(ps); WINPR_ASSERT(ps);
WINPR_ASSERT(ps->interceptContextMap); WINPR_ASSERT(ps->interceptContextMap);
@@ -1898,7 +1898,7 @@ static pf_channel_server_context* get_channel(pServerContext* ps, BOOL send)
SERVER_RXTX_LOG(send, WLog_Get(RTAG), WLOG_ERROR, SERVER_RXTX_LOG(send, WLog_Get(RTAG), WLOG_ERROR,
"Channel %s missing context in interceptContextMap", "Channel %s missing context in interceptContextMap",
RDPDR_SVC_CHANNEL_NAME); RDPDR_SVC_CHANNEL_NAME);
return NULL; return nullptr;
} }
return rdpdr; return rdpdr;
@@ -1907,8 +1907,8 @@ static pf_channel_server_context* get_channel(pServerContext* ps, BOOL send)
BOOL pf_channel_rdpdr_server_handle(pServerContext* ps, UINT16 channelId, const char* channel_name, BOOL pf_channel_rdpdr_server_handle(pServerContext* ps, UINT16 channelId, const char* channel_name,
const BYTE* xdata, size_t xsize, UINT32 flags, size_t totalSize) const BYTE* xdata, size_t xsize, UINT32 flags, size_t totalSize)
{ {
wStream* s = NULL; wStream* s = nullptr;
pClientContext* pc = NULL; pClientContext* pc = nullptr;
pf_channel_server_context* rdpdr = get_channel(ps, FALSE); pf_channel_server_context* rdpdr = get_channel(ps, FALSE);
if (!rdpdr) if (!rdpdr)
return FALSE; return FALSE;
@@ -2002,7 +2002,7 @@ BOOL pf_channel_rdpdr_server_announce(pServerContext* ps)
BOOL pf_channel_rdpdr_client_reset(pClientContext* pc) BOOL pf_channel_rdpdr_client_reset(pClientContext* pc)
{ {
pf_channel_client_context* rdpdr = NULL; pf_channel_client_context* rdpdr = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
WINPR_ASSERT(pc->pdata); WINPR_ASSERT(pc->pdata);

View File

@@ -59,7 +59,7 @@ typedef struct
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static pf_channel_client_context* scard_get_client_context(pClientContext* pc) static pf_channel_client_context* scard_get_client_context(pClientContext* pc)
{ {
pf_channel_client_context* scard = NULL; pf_channel_client_context* scard = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
WINPR_ASSERT(pc->interceptContextMap); WINPR_ASSERT(pc->interceptContextMap);
@@ -140,7 +140,7 @@ WINPR_ATTR_NODISCARD
static BOOL start_irp_thread(pf_channel_client_context* scard, static BOOL start_irp_thread(pf_channel_client_context* scard,
const pf_channel_client_queue_element* e) const pf_channel_client_queue_element* e)
{ {
PTP_WORK work = NULL; PTP_WORK work = nullptr;
struct thread_arg* arg = calloc(1, sizeof(struct thread_arg)); struct thread_arg* arg = calloc(1, sizeof(struct thread_arg));
if (!arg) if (!arg)
return FALSE; return FALSE;
@@ -149,7 +149,7 @@ static BOOL start_irp_thread(pf_channel_client_context* scard,
if (!arg->e) if (!arg->e)
goto fail; goto fail;
work = CreateThreadpoolWork(irp_thread, arg, NULL); work = CreateThreadpoolWork(irp_thread, arg, nullptr);
if (!work) if (!work)
goto fail; goto fail;
ArrayList_Append(scard->workObjects, work); ArrayList_Append(scard->workObjects, work);
@@ -315,22 +315,22 @@ WINPR_ATTR_NODISCARD
static void* queue_copy(const void* obj) static void* queue_copy(const void* obj)
{ {
const pf_channel_client_queue_element* other = obj; const pf_channel_client_queue_element* other = obj;
pf_channel_client_queue_element* copy = NULL; pf_channel_client_queue_element* copy = nullptr;
if (!other) if (!other)
return NULL; return nullptr;
copy = calloc(1, sizeof(pf_channel_client_queue_element)); copy = calloc(1, sizeof(pf_channel_client_queue_element));
if (!copy) if (!copy)
return NULL; return nullptr;
*copy = *other; *copy = *other;
copy->out = Stream_New(NULL, Stream_Capacity(other->out)); copy->out = Stream_New(nullptr, Stream_Capacity(other->out));
if (!copy->out) if (!copy->out)
goto fail; goto fail;
Stream_Write(copy->out, Stream_Buffer(other->out), Stream_GetPosition(other->out)); Stream_Write(copy->out, Stream_Buffer(other->out), Stream_GetPosition(other->out));
return copy; return copy;
fail: fail:
queue_free(copy); queue_free(copy);
return NULL; return nullptr;
} }
static void work_object_free(void* arg) static void work_object_free(void* arg)
@@ -341,8 +341,8 @@ static void work_object_free(void* arg)
BOOL pf_channel_smartcard_client_new(pClientContext* pc) BOOL pf_channel_smartcard_client_new(pClientContext* pc)
{ {
pf_channel_client_context* scard = NULL; pf_channel_client_context* scard = nullptr;
wObject* obj = NULL; wObject* obj = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
WINPR_ASSERT(pc->interceptContextMap); WINPR_ASSERT(pc->interceptContextMap);

View File

@@ -32,7 +32,7 @@
#define TAG PROXY_TAG("server") #define TAG PROXY_TAG("server")
static proxyServer* server = NULL; static proxyServer* server = nullptr;
#if defined(_WIN32) #if defined(_WIN32)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD

View File

@@ -57,7 +57,7 @@ static BOOL channelTracker_resetCurrentPacket(ChannelStateTracker* tracker)
} }
if (create) if (create)
tracker->currentPacket = Stream_New(NULL, 10ULL * 1024ULL); tracker->currentPacket = Stream_New(nullptr, 10ULL * 1024ULL);
if (!tracker->currentPacket) if (!tracker->currentPacket)
return FALSE; return FALSE;
Stream_SetPosition(tracker->currentPacket, 0); Stream_SetPosition(tracker->currentPacket, 0);
@@ -89,7 +89,7 @@ fail:
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
channelTracker_free(ret); channelTracker_free(ret);
WINPR_PRAGMA_DIAG_POP WINPR_PRAGMA_DIAG_POP
return NULL; return nullptr;
} }
PfChannelResult channelTracker_update(ChannelStateTracker* tracker, const BYTE* xdata, size_t xsize, PfChannelResult channelTracker_update(ChannelStateTracker* tracker, const BYTE* xdata, size_t xsize,
@@ -177,9 +177,9 @@ void channelTracker_free(ChannelStateTracker* t)
PfChannelResult channelTracker_flushCurrent(ChannelStateTracker* t, BOOL first, BOOL last, PfChannelResult channelTracker_flushCurrent(ChannelStateTracker* t, BOOL first, BOOL last,
BOOL toBack) BOOL toBack)
{ {
proxyData* pdata = NULL; proxyData* pdata = nullptr;
pServerContext* ps = NULL; pServerContext* ps = nullptr;
pServerStaticChannelContext* channel = NULL; pServerStaticChannelContext* channel = nullptr;
UINT32 flags = CHANNEL_FLAG_FIRST; UINT32 flags = CHANNEL_FLAG_FIRST;
BOOL r = 0; BOOL r = 0;
const char* direction = toBack ? "F->B" : "B->F"; const char* direction = toBack ? "F->B" : "B->F";

View File

@@ -73,7 +73,7 @@ static BOOL proxy_server_reactivate(rdpContext* ps, const rdpContext* pc)
static void pf_client_on_error_info(void* ctx, const ErrorInfoEventArgs* e) static void pf_client_on_error_info(void* ctx, const ErrorInfoEventArgs* e)
{ {
pClientContext* pc = (pClientContext*)ctx; pClientContext* pc = (pClientContext*)ctx;
pServerContext* ps = NULL; pServerContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
WINPR_ASSERT(pc->pdata); WINPR_ASSERT(pc->pdata);
@@ -99,8 +99,8 @@ static void pf_client_on_error_info(void* ctx, const ErrorInfoEventArgs* e)
static void pf_client_on_activated(void* ctx, WINPR_ATTR_UNUSED const ActivatedEventArgs* e) static void pf_client_on_activated(void* ctx, WINPR_ATTR_UNUSED const ActivatedEventArgs* e)
{ {
pClientContext* pc = (pClientContext*)ctx; pClientContext* pc = (pClientContext*)ctx;
pServerContext* ps = NULL; pServerContext* ps = nullptr;
freerdp_peer* peer = NULL; freerdp_peer* peer = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
WINPR_ASSERT(pc->pdata); WINPR_ASSERT(pc->pdata);
@@ -144,10 +144,10 @@ static BOOL pf_client_load_rdpsnd(pClientContext* pc)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_client_use_peer_load_balance_info(pClientContext* pc) static BOOL pf_client_use_peer_load_balance_info(pClientContext* pc)
{ {
pServerContext* ps = NULL; pServerContext* ps = nullptr;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
DWORD lb_info_len = 0; DWORD lb_info_len = 0;
const char* lb_info = NULL; const char* lb_info = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
WINPR_ASSERT(pc->pdata); WINPR_ASSERT(pc->pdata);
@@ -196,10 +196,10 @@ static BOOL pf_client_use_proxy_smartcard_auth(const rdpSettings* settings)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_client_pre_connect(freerdp* instance) static BOOL pf_client_pre_connect(freerdp* instance)
{ {
pClientContext* pc = NULL; pClientContext* pc = nullptr;
pServerContext* ps = NULL; pServerContext* ps = nullptr;
const proxyConfig* config = NULL; const proxyConfig* config = nullptr;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
WINPR_ASSERT(instance); WINPR_ASSERT(instance);
pc = (pClientContext*)instance->context; pc = (pClientContext*)instance->context;
@@ -333,10 +333,10 @@ static BOOL pf_client_update_back_id(pServerContext* ps, const char* name, UINT3
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_client_load_channels(freerdp* instance) static BOOL pf_client_load_channels(freerdp* instance)
{ {
pClientContext* pc = NULL; pClientContext* pc = nullptr;
pServerContext* ps = NULL; pServerContext* ps = nullptr;
const proxyConfig* config = NULL; const proxyConfig* config = nullptr;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
WINPR_ASSERT(instance); WINPR_ASSERT(instance);
pc = (pClientContext*)instance->context; pc = (pClientContext*)instance->context;
@@ -431,10 +431,10 @@ static BOOL pf_client_receive_channel_data_hook(freerdp* instance, UINT16 channe
const BYTE* xdata, size_t xsize, UINT32 flags, const BYTE* xdata, size_t xsize, UINT32 flags,
size_t totalSize) size_t totalSize)
{ {
pClientContext* pc = NULL; pClientContext* pc = nullptr;
pServerContext* ps = NULL; pServerContext* ps = nullptr;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
pServerStaticChannelContext* channel = NULL; pServerStaticChannelContext* channel = nullptr;
UINT64 channelId64 = channelId; UINT64 channelId64 = channelId;
WINPR_ASSERT(instance); WINPR_ASSERT(instance);
@@ -478,8 +478,8 @@ static BOOL pf_client_receive_channel_data_hook(freerdp* instance, UINT16 channe
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_client_on_server_heartbeat(freerdp* instance, BYTE period, BYTE count1, BYTE count2) static BOOL pf_client_on_server_heartbeat(freerdp* instance, BYTE period, BYTE count1, BYTE count2)
{ {
pClientContext* pc = NULL; pClientContext* pc = nullptr;
pServerContext* ps = NULL; pServerContext* ps = nullptr;
WINPR_ASSERT(instance); WINPR_ASSERT(instance);
pc = (pClientContext*)instance->context; pc = (pClientContext*)instance->context;
@@ -509,7 +509,7 @@ static BOOL sendQueuedChannelData(pClientContext* pc)
if (pc->connected) if (pc->connected)
{ {
proxyChannelDataEventInfo* ev = NULL; proxyChannelDataEventInfo* ev = nullptr;
Queue_Lock(pc->cached_server_channel_data); Queue_Lock(pc->cached_server_channel_data);
while (rc && (ev = Queue_Dequeue(pc->cached_server_channel_data))) while (rc && (ev = Queue_Dequeue(pc->cached_server_channel_data)))
@@ -595,8 +595,8 @@ static BOOL pf_client_post_connect(freerdp* instance)
*/ */
static void pf_client_post_disconnect(freerdp* instance) static void pf_client_post_disconnect(freerdp* instance)
{ {
pClientContext* pc = NULL; pClientContext* pc = nullptr;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
if (!instance) if (!instance)
return; return;
@@ -655,8 +655,8 @@ static BOOL pf_client_redirect(freerdp* instance)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_client_should_retry_without_nla(pClientContext* pc) static BOOL pf_client_should_retry_without_nla(pClientContext* pc)
{ {
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
const proxyConfig* config = NULL; const proxyConfig* config = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
WINPR_ASSERT(pc->pdata); WINPR_ASSERT(pc->pdata);
@@ -696,9 +696,9 @@ static BOOL pf_client_set_security_settings(pClientContext* pc)
return FALSE; return FALSE;
/* Reset username/domain, we will get that info later from the sc cert */ /* Reset username/domain, we will get that info later from the sc cert */
if (!freerdp_settings_set_string(settings, FreeRDP_Username, NULL)) if (!freerdp_settings_set_string(settings, FreeRDP_Username, nullptr))
return FALSE; return FALSE;
if (!freerdp_settings_set_string(settings, FreeRDP_Domain, NULL)) if (!freerdp_settings_set_string(settings, FreeRDP_Domain, nullptr))
return FALSE; return FALSE;
} }
@@ -708,8 +708,8 @@ static BOOL pf_client_set_security_settings(pClientContext* pc)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_client_connect_without_nla(pClientContext* pc) static BOOL pf_client_connect_without_nla(pClientContext* pc)
{ {
freerdp* instance = NULL; freerdp* instance = nullptr;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
instance = pc->context.instance; instance = pc->context.instance;
@@ -737,8 +737,8 @@ static BOOL pf_client_connect_without_nla(pClientContext* pc)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_client_connect(freerdp* instance) static BOOL pf_client_connect(freerdp* instance)
{ {
pClientContext* pc = NULL; pClientContext* pc = nullptr;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
BOOL rc = FALSE; BOOL rc = FALSE;
BOOL retry = FALSE; BOOL retry = FALSE;
@@ -793,8 +793,8 @@ out:
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static DWORD WINAPI pf_client_thread_proc(pClientContext* pc) static DWORD WINAPI pf_client_thread_proc(pClientContext* pc)
{ {
freerdp* instance = NULL; freerdp* instance = nullptr;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
DWORD nCount = 0; DWORD nCount = 0;
DWORD status = 0; DWORD status = 0;
HANDLE handles[MAXIMUM_WAIT_OBJECTS] = WINPR_C_ARRAY_INIT; HANDLE handles[MAXIMUM_WAIT_OBJECTS] = WINPR_C_ARRAY_INIT;
@@ -897,7 +897,7 @@ static void pf_client_context_free(freerdp* instance, rdpContext* context)
if (!pc) if (!pc)
return; return;
pc->sendChannelData = NULL; pc->sendChannelData = nullptr;
Queue_Free(pc->cached_server_channel_data); Queue_Free(pc->cached_server_channel_data);
Stream_Free(pc->remote_pem, TRUE); Stream_Free(pc->remote_pem, TRUE);
free(pc->remote_hostname); free(pc->remote_hostname);
@@ -909,7 +909,7 @@ WINPR_ATTR_NODISCARD
static int pf_client_verify_X509_certificate(freerdp* instance, const BYTE* data, size_t length, static int pf_client_verify_X509_certificate(freerdp* instance, const BYTE* data, size_t length,
const char* hostname, UINT16 port, DWORD flags) const char* hostname, UINT16 port, DWORD flags)
{ {
pClientContext* pc = NULL; pClientContext* pc = nullptr;
WINPR_ASSERT(instance); WINPR_ASSERT(instance);
WINPR_ASSERT(data); WINPR_ASSERT(data);
@@ -924,7 +924,7 @@ static int pf_client_verify_X509_certificate(freerdp* instance, const BYTE* data
Stream_SetPosition(pc->remote_pem, 0); Stream_SetPosition(pc->remote_pem, 0);
free(pc->remote_hostname); free(pc->remote_hostname);
pc->remote_hostname = NULL; pc->remote_hostname = nullptr;
if (length > 0) if (length > 0)
Stream_Write(pc->remote_pem, data, length); Stream_Write(pc->remote_pem, data, length);
@@ -969,7 +969,7 @@ static void* channel_data_copy(const void* obj)
void* pv; void* pv;
} cnv; } cnv;
const proxyChannelDataEventInfo* src = obj; const proxyChannelDataEventInfo* src = obj;
proxyChannelDataEventInfo* dst = NULL; proxyChannelDataEventInfo* dst = nullptr;
WINPR_ASSERT(src); WINPR_ASSERT(src);
@@ -994,13 +994,13 @@ static void* channel_data_copy(const void* obj)
fail: fail:
channel_data_free(dst); channel_data_free(dst);
return NULL; return nullptr;
} }
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_client_client_new(freerdp* instance, rdpContext* context) static BOOL pf_client_client_new(freerdp* instance, rdpContext* context)
{ {
wObject* obj = NULL; wObject* obj = nullptr;
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
if (!instance || !context) if (!instance || !context)
@@ -1014,7 +1014,7 @@ static BOOL pf_client_client_new(freerdp* instance, rdpContext* context)
instance->LogonErrorInfo = pf_logon_error_info; instance->LogonErrorInfo = pf_logon_error_info;
instance->VerifyX509Certificate = pf_client_verify_X509_certificate; instance->VerifyX509Certificate = pf_client_verify_X509_certificate;
pc->remote_pem = Stream_New(NULL, 4096); pc->remote_pem = Stream_New(nullptr, 4096);
if (!pc->remote_pem) if (!pc->remote_pem)
return FALSE; return FALSE;
@@ -1045,7 +1045,7 @@ WINPR_ATTR_NODISCARD
static int pf_client_client_stop(rdpContext* context) static int pf_client_client_stop(rdpContext* context)
{ {
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;

View File

@@ -52,7 +52,7 @@
#define CONFIG_PRINT_SECTION_KEY(section, key) WLog_INFO(TAG, "\t%s/%s:", section, key) #define CONFIG_PRINT_SECTION_KEY(section, key) WLog_INFO(TAG, "\t%s/%s:", section, key)
#define CONFIG_PRINT_STR(config, key) WLog_INFO(TAG, "\t\t%s: %s", #key, (config)->key) #define CONFIG_PRINT_STR(config, key) WLog_INFO(TAG, "\t\t%s: %s", #key, (config)->key)
#define CONFIG_PRINT_STR_CONTENT(config, key) \ #define CONFIG_PRINT_STR_CONTENT(config, key) \
WLog_INFO(TAG, "\t\t%s: %s", #key, (config)->key ? "set" : NULL) WLog_INFO(TAG, "\t\t%s: %s", #key, (config)->key ? "set" : nullptr)
#define CONFIG_PRINT_BOOL(config, key) WLog_INFO(TAG, "\t\t%s: %s", #key, boolstr((config)->key)) #define CONFIG_PRINT_BOOL(config, key) WLog_INFO(TAG, "\t\t%s: %s", #key, boolstr((config)->key))
#define CONFIG_PRINT_UINT16(config, key) WLog_INFO(TAG, "\t\t%s: %" PRIu16 "", #key, (config)->key) #define CONFIG_PRINT_UINT16(config, key) WLog_INFO(TAG, "\t\t%s: %" PRIu16 "", #key, (config)->key)
#define CONFIG_PRINT_UINT32(config, key) WLog_INFO(TAG, "\t\t%s: %" PRIu32 "", #key, (config)->key) #define CONFIG_PRINT_UINT32(config, key) WLog_INFO(TAG, "\t\t%s: %" PRIu32 "", #key, (config)->key)
@@ -120,12 +120,12 @@ WINPR_ATTR_NODISCARD
static char** pf_config_parse_comma_separated_list(const char* list, size_t* count) static char** pf_config_parse_comma_separated_list(const char* list, size_t* count)
{ {
if (!list || !count) if (!list || !count)
return NULL; return nullptr;
if (strlen(list) == 0) if (strlen(list) == 0)
{ {
*count = 0; *count = 0;
return NULL; return nullptr;
} }
return CommandLineParseCommaSeparatedValues(list, count); return CommandLineParseCommaSeparatedValues(list, count);
@@ -136,7 +136,7 @@ static BOOL pf_config_get_uint16(wIniFile* ini, const char* section, const char*
UINT16* result, BOOL required) UINT16* result, BOOL required)
{ {
int val = 0; int val = 0;
const char* strval = NULL; const char* strval = nullptr;
WINPR_ASSERT(result); WINPR_ASSERT(result);
@@ -186,7 +186,7 @@ WINPR_ATTR_NODISCARD
static BOOL pf_config_get_bool(wIniFile* ini, const char* section, const char* key, BOOL fallback) static BOOL pf_config_get_bool(wIniFile* ini, const char* section, const char* key, BOOL fallback)
{ {
int num_value = 0; int num_value = 0;
const char* str_value = NULL; const char* str_value = nullptr;
str_value = IniFile_GetKeyValueString(ini, section, key); str_value = IniFile_GetKeyValueString(ini, section, key);
if (!str_value) if (!str_value)
@@ -210,7 +210,7 @@ WINPR_ATTR_NODISCARD
static const char* pf_config_get_str(wIniFile* ini, const char* section, const char* key, static const char* pf_config_get_str(wIniFile* ini, const char* section, const char* key,
BOOL required) BOOL required)
{ {
const char* value = NULL; const char* value = nullptr;
value = IniFile_GetKeyValueString(ini, section, key); value = IniFile_GetKeyValueString(ini, section, key);
@@ -218,7 +218,7 @@ static const char* pf_config_get_str(wIniFile* ini, const char* section, const c
{ {
if (required) if (required)
WLog_ERR(TAG, "key '%s.%s' not found.", section, key); WLog_ERR(TAG, "key '%s.%s' not found.", section, key);
return NULL; return nullptr;
} }
return value; return value;
@@ -248,7 +248,7 @@ static BOOL pf_config_load_server(wIniFile* ini, proxyConfig* config)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_config_load_target(wIniFile* ini, proxyConfig* config) static BOOL pf_config_load_target(wIniFile* ini, proxyConfig* config)
{ {
const char* target_value = NULL; const char* target_value = nullptr;
WINPR_ASSERT(config); WINPR_ASSERT(config);
config->FixedTarget = pf_config_get_bool(ini, section_target, key_target_fixed, FALSE); config->FixedTarget = pf_config_get_bool(ini, section_target, key_target_fixed, FALSE);
@@ -364,8 +364,8 @@ static BOOL pf_config_load_security(wIniFile* ini, proxyConfig* config)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_config_load_modules(wIniFile* ini, proxyConfig* config) static BOOL pf_config_load_modules(wIniFile* ini, proxyConfig* config)
{ {
const char* modules_to_load = NULL; const char* modules_to_load = nullptr;
const char* required_modules = NULL; const char* required_modules = nullptr;
modules_to_load = pf_config_get_str(ini, section_plugins, key_plugins_modules, FALSE); modules_to_load = pf_config_get_str(ini, section_plugins, key_plugins_modules, FALSE);
required_modules = pf_config_get_str(ini, section_plugins, key_plugins_required, FALSE); required_modules = pf_config_get_str(ini, section_plugins, key_plugins_required, FALSE);
@@ -386,11 +386,11 @@ static char* pf_config_decode_base64(const char* data, const char* name, size_t*
"-----BEGIN RSA PRIVATE KEY-----" }; "-----BEGIN RSA PRIVATE KEY-----" };
size_t decoded_length = 0; size_t decoded_length = 0;
char* decoded = NULL; char* decoded = nullptr;
if (!data) if (!data)
{ {
WLog_ERR(TAG, "Invalid base64 data [NULL] for %s", name); WLog_ERR(TAG, "Invalid base64 data [nullptr] for %s", name);
return NULL; return nullptr;
} }
WINPR_ASSERT(name); WINPR_ASSERT(name);
@@ -442,7 +442,7 @@ static char* pf_config_decode_base64(const char* data, const char* name, size_t*
{ {
WLog_ERR(TAG, "Failed to decode base64 data of length %" PRIuz " for %s", length, name); WLog_ERR(TAG, "Failed to decode base64 data of length %" PRIuz " for %s", length, name);
free(decoded); free(decoded);
return NULL; return nullptr;
} }
*pLength = strnlen(decoded, decoded_length) + 1; *pLength = strnlen(decoded, decoded_length) + 1;
@@ -452,8 +452,8 @@ static char* pf_config_decode_base64(const char* data, const char* name, size_t*
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_config_load_certificates(wIniFile* ini, proxyConfig* config) static BOOL pf_config_load_certificates(wIniFile* ini, proxyConfig* config)
{ {
const char* tmp1 = NULL; const char* tmp1 = nullptr;
const char* tmp2 = NULL; const char* tmp2 = nullptr;
WINPR_ASSERT(ini); WINPR_ASSERT(ini);
WINPR_ASSERT(config); WINPR_ASSERT(config);
@@ -561,7 +561,7 @@ static BOOL pf_config_load_certificates(wIniFile* ini, proxyConfig* config)
proxyConfig* server_config_load_ini(wIniFile* ini) proxyConfig* server_config_load_ini(wIniFile* ini)
{ {
proxyConfig* config = NULL; proxyConfig* config = nullptr;
WINPR_ASSERT(ini); WINPR_ASSERT(ini);
@@ -603,7 +603,7 @@ out:
pf_server_config_free(config); pf_server_config_free(config);
WINPR_PRAGMA_DIAG_POP WINPR_PRAGMA_DIAG_POP
return NULL; return nullptr;
} }
BOOL pf_server_config_dump(const char* file) BOOL pf_server_config_dump(const char* file)
@@ -724,15 +724,15 @@ fail:
proxyConfig* pf_server_config_load_buffer(const char* buffer) proxyConfig* pf_server_config_load_buffer(const char* buffer)
{ {
proxyConfig* config = NULL; proxyConfig* config = nullptr;
wIniFile* ini = NULL; wIniFile* ini = nullptr;
ini = IniFile_New(); ini = IniFile_New();
if (!ini) if (!ini)
{ {
WLog_ERR(TAG, "IniFile_New() failed!"); WLog_ERR(TAG, "IniFile_New() failed!");
return NULL; return nullptr;
} }
if (IniFile_ReadBuffer(ini, buffer) < 0) if (IniFile_ReadBuffer(ini, buffer) < 0)
@@ -749,13 +749,13 @@ out:
proxyConfig* pf_server_config_load_file(const char* path) proxyConfig* pf_server_config_load_file(const char* path)
{ {
proxyConfig* config = NULL; proxyConfig* config = nullptr;
wIniFile* ini = IniFile_New(); wIniFile* ini = IniFile_New();
if (!ini) if (!ini)
{ {
WLog_ERR(TAG, "IniFile_New() failed!"); WLog_ERR(TAG, "IniFile_New() failed!");
return NULL; return nullptr;
} }
if (IniFile_ReadFile(ini, path) < 0) if (IniFile_ReadFile(ini, path) < 0)
@@ -873,7 +873,7 @@ static void znfree(char* str, size_t len)
void pf_server_config_free(proxyConfig* config) void pf_server_config_free(proxyConfig* config)
{ {
if (config == NULL) if (config == nullptr)
return; return;
free(config->Host); free(config->Host);
@@ -907,7 +907,7 @@ const char* pf_config_required_plugin(const proxyConfig* config, size_t index)
{ {
WINPR_ASSERT(config); WINPR_ASSERT(config);
if (index >= config->RequiredPluginsCount) if (index >= config->RequiredPluginsCount)
return NULL; return nullptr;
return config->RequiredPlugins[index]; return config->RequiredPlugins[index];
} }
@@ -935,7 +935,7 @@ const char** pf_config_modules(const proxyConfig* config)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_config_copy_string(char** dst, const char* src) static BOOL pf_config_copy_string(char** dst, const char* src)
{ {
*dst = NULL; *dst = nullptr;
if (src) if (src)
*dst = _strdup(src); *dst = _strdup(src);
return TRUE; return TRUE;
@@ -944,7 +944,7 @@ static BOOL pf_config_copy_string(char** dst, const char* src)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_config_copy_string_n(char** dst, const char* src, size_t size) static BOOL pf_config_copy_string_n(char** dst, const char* src, size_t size)
{ {
*dst = NULL; *dst = nullptr;
if (src && (size > 0)) if (src && (size > 0))
{ {
@@ -965,7 +965,7 @@ static BOOL pf_config_copy_string_list(char*** dst, size_t* size, char** src, si
WINPR_ASSERT(size); WINPR_ASSERT(size);
WINPR_ASSERT(src || (srcSize == 0)); WINPR_ASSERT(src || (srcSize == 0));
*dst = NULL; *dst = nullptr;
*size = 0; *size = 0;
if (srcSize > INT32_MAX) if (srcSize > INT32_MAX)
return FALSE; return FALSE;
@@ -1063,7 +1063,7 @@ static BOOL config_plugin_unload(proxyPlugin* plugin)
if (plugin) if (plugin)
{ {
free(plugin->custom); free(plugin->custom);
plugin->custom = NULL; plugin->custom = nullptr;
} }
return TRUE; return TRUE;
@@ -1074,8 +1074,8 @@ static BOOL config_plugin_keyboard_event(proxyPlugin* plugin, WINPR_ATTR_UNUSED
void* param) void* param)
{ {
BOOL rc = 0; BOOL rc = 0;
const struct config_plugin_data* custom = NULL; const struct config_plugin_data* custom = nullptr;
const proxyConfig* cfg = NULL; const proxyConfig* cfg = nullptr;
const proxyKeyboardEventInfo* event_data = (const proxyKeyboardEventInfo*)(param); const proxyKeyboardEventInfo* event_data = (const proxyKeyboardEventInfo*)(param);
WINPR_ASSERT(plugin); WINPR_ASSERT(plugin);
@@ -1100,8 +1100,8 @@ static BOOL config_plugin_unicode_event(proxyPlugin* plugin, WINPR_ATTR_UNUSED p
void* param) void* param)
{ {
BOOL rc = 0; BOOL rc = 0;
const struct config_plugin_data* custom = NULL; const struct config_plugin_data* custom = nullptr;
const proxyConfig* cfg = NULL; const proxyConfig* cfg = nullptr;
const proxyUnicodeEventInfo* event_data = (const proxyUnicodeEventInfo*)(param); const proxyUnicodeEventInfo* event_data = (const proxyUnicodeEventInfo*)(param);
WINPR_ASSERT(plugin); WINPR_ASSERT(plugin);
@@ -1126,8 +1126,8 @@ static BOOL config_plugin_mouse_event(proxyPlugin* plugin, WINPR_ATTR_UNUSED pro
void* param) void* param)
{ {
BOOL rc = 0; BOOL rc = 0;
const struct config_plugin_data* custom = NULL; const struct config_plugin_data* custom = nullptr;
const proxyConfig* cfg = NULL; const proxyConfig* cfg = nullptr;
const proxyMouseEventInfo* event_data = (const proxyMouseEventInfo*)(param); const proxyMouseEventInfo* event_data = (const proxyMouseEventInfo*)(param);
WINPR_ASSERT(plugin); WINPR_ASSERT(plugin);
@@ -1151,8 +1151,8 @@ static BOOL config_plugin_mouse_ex_event(proxyPlugin* plugin, WINPR_ATTR_UNUSED
void* param) void* param)
{ {
BOOL rc = 0; BOOL rc = 0;
const struct config_plugin_data* custom = NULL; const struct config_plugin_data* custom = nullptr;
const proxyConfig* cfg = NULL; const proxyConfig* cfg = nullptr;
const proxyMouseExEventInfo* event_data = (const proxyMouseExEventInfo*)(param); const proxyMouseExEventInfo* event_data = (const proxyMouseExEventInfo*)(param);
WINPR_ASSERT(plugin); WINPR_ASSERT(plugin);
@@ -1322,7 +1322,7 @@ static BOOL config_plugin_channel_create(proxyPlugin* plugin, WINPR_ATTR_UNUSED
BOOL pf_config_plugin(proxyPluginsManager* plugins_manager, void* userdata) BOOL pf_config_plugin(proxyPluginsManager* plugins_manager, void* userdata)
{ {
struct config_plugin_data* custom = NULL; struct config_plugin_data* custom = nullptr;
proxyPlugin plugin = WINPR_C_ARRAY_INIT; proxyPlugin plugin = WINPR_C_ARRAY_INIT;
plugin.name = config_plugin_name; plugin.name = config_plugin_name;

View File

@@ -88,7 +88,7 @@ pServerStaticChannelContext* StaticChannelContext_new(pServerContext* ps, const
if (!ret) if (!ret)
{ {
PROXY_LOG_ERR(TAG, ps, "error allocating channel context for '%s'", name); PROXY_LOG_ERR(TAG, ps, "error allocating channel context for '%s'", name);
return NULL; return nullptr;
} }
ret->front_channel_id = id; ret->front_channel_id = id;
@@ -97,7 +97,7 @@ pServerStaticChannelContext* StaticChannelContext_new(pServerContext* ps, const
{ {
PROXY_LOG_ERR(TAG, ps, "error allocating name in channel context for '%s'", name); PROXY_LOG_ERR(TAG, ps, "error allocating name in channel context for '%s'", name);
free(ret); free(ret);
return NULL; return nullptr;
} }
proxyChannelToInterceptData channel = { .name = name, .channelId = id, .intercept = FALSE }; proxyChannelToInterceptData channel = { .name = name, .channelId = id, .intercept = FALSE };
@@ -136,20 +136,20 @@ static void client_to_proxy_context_free(freerdp_peer* client, rdpContext* ctx);
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL client_to_proxy_context_new(freerdp_peer* client, rdpContext* ctx) static BOOL client_to_proxy_context_new(freerdp_peer* client, rdpContext* ctx)
{ {
wObject* obj = NULL; wObject* obj = nullptr;
pServerContext* context = (pServerContext*)ctx; pServerContext* context = (pServerContext*)ctx;
WINPR_ASSERT(client); WINPR_ASSERT(client);
WINPR_ASSERT(context); WINPR_ASSERT(context);
context->dynvcReady = NULL; context->dynvcReady = nullptr;
context->vcm = WTSOpenServerA((LPSTR)client->context); context->vcm = WTSOpenServerA((LPSTR)client->context);
if (!context->vcm || context->vcm == INVALID_HANDLE_VALUE) if (!context->vcm || context->vcm == INVALID_HANDLE_VALUE)
goto error; goto error;
if (!(context->dynvcReady = CreateEvent(NULL, TRUE, FALSE, NULL))) if (!(context->dynvcReady = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
goto error; goto error;
context->interceptContextMap = HashTable_New(FALSE); context->interceptContextMap = HashTable_New(FALSE);
@@ -204,7 +204,7 @@ void client_to_proxy_context_free(freerdp_peer* client, rdpContext* ctx)
if (context->dynvcReady) if (context->dynvcReady)
{ {
(void)CloseHandle(context->dynvcReady); (void)CloseHandle(context->dynvcReady);
context->dynvcReady = NULL; context->dynvcReady = nullptr;
} }
HashTable_Free(context->interceptContextMap); HashTable_Free(context->interceptContextMap);
@@ -213,7 +213,7 @@ void client_to_proxy_context_free(freerdp_peer* client, rdpContext* ctx)
if (context->vcm && (context->vcm != INVALID_HANDLE_VALUE)) if (context->vcm && (context->vcm != INVALID_HANDLE_VALUE))
WTSCloseServer(context->vcm); WTSCloseServer(context->vcm);
context->vcm = NULL; context->vcm = nullptr;
} }
BOOL pf_context_init_server_context(freerdp_peer* client) BOOL pf_context_init_server_context(freerdp_peer* client)
@@ -259,7 +259,7 @@ void intercept_context_entry_free(void* obj)
BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src) BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src)
{ {
BOOL rc = FALSE; BOOL rc = FALSE;
rdpSettings* before_copy = NULL; rdpSettings* before_copy = nullptr;
const FreeRDP_Settings_Keys_String to_revert[] = { FreeRDP_ConfigPath, const FreeRDP_Settings_Keys_String to_revert[] = { FreeRDP_ConfigPath,
FreeRDP_CertificateName }; FreeRDP_CertificateName };
@@ -288,11 +288,11 @@ BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src)
goto out_fail; goto out_fail;
/* /*
* RdpServerRsaKey must be set to NULL if `dst` is client's context * RdpServerRsaKey must be set to nullptr if `dst` is client's context
* it must be freed before setting it to NULL to avoid a memory leak! * it must be freed before setting it to nullptr to avoid a memory leak!
*/ */
if (!freerdp_settings_set_pointer_len(dst, FreeRDP_RdpServerRsaKey, NULL, 1)) if (!freerdp_settings_set_pointer_len(dst, FreeRDP_RdpServerRsaKey, nullptr, 1))
goto out_fail; goto out_fail;
} }
@@ -314,7 +314,7 @@ pClientContext* pf_context_create_client_context(const rdpSettings* clientSettin
rdpContext* context = freerdp_client_context_new(&clientEntryPoints); rdpContext* context = freerdp_client_context_new(&clientEntryPoints);
if (!context) if (!context)
return NULL; return nullptr;
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
@@ -324,23 +324,23 @@ pClientContext* pf_context_create_client_context(const rdpSettings* clientSettin
return pc; return pc;
error: error:
freerdp_client_context_free(context); freerdp_client_context_free(context);
return NULL; return nullptr;
} }
proxyData* proxy_data_new(void) proxyData* proxy_data_new(void)
{ {
BYTE temp[16]; BYTE temp[16];
char* hex = NULL; char* hex = nullptr;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
pdata = calloc(1, sizeof(proxyData)); pdata = calloc(1, sizeof(proxyData));
if (!pdata) if (!pdata)
return NULL; return nullptr;
if (!(pdata->abort_event = CreateEvent(NULL, TRUE, FALSE, NULL))) if (!(pdata->abort_event = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
goto error; goto error;
if (!(pdata->gfx_server_ready = CreateEvent(NULL, TRUE, FALSE, NULL))) if (!(pdata->gfx_server_ready = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
goto error; goto error;
winpr_RAND(&temp, 16); winpr_RAND(&temp, 16);
@@ -365,7 +365,7 @@ error:
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
proxy_data_free(pdata); proxy_data_free(pdata);
WINPR_PRAGMA_DIAG_POP WINPR_PRAGMA_DIAG_POP
return NULL; return nullptr;
} }
/* updates circular pointers between proxyData and pClientContext instances */ /* updates circular pointers between proxyData and pClientContext instances */

View File

@@ -48,8 +48,8 @@ static BOOL pf_server_check_and_sync_input_state(pClientContext* pc)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_server_synchronize_event(rdpInput* input, UINT32 flags) static BOOL pf_server_synchronize_event(rdpInput* input, UINT32 flags)
{ {
pServerContext* ps = NULL; pServerContext* ps = nullptr;
pClientContext* pc = NULL; pClientContext* pc = nullptr;
WINPR_ASSERT(input); WINPR_ASSERT(input);
ps = (pServerContext*)input->context; ps = (pServerContext*)input->context;
@@ -68,10 +68,10 @@ static BOOL pf_server_synchronize_event(rdpInput* input, UINT32 flags)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_server_keyboard_event(rdpInput* input, UINT16 flags, UINT8 code) static BOOL pf_server_keyboard_event(rdpInput* input, UINT16 flags, UINT8 code)
{ {
const proxyConfig* config = NULL; const proxyConfig* config = nullptr;
proxyKeyboardEventInfo event = WINPR_C_ARRAY_INIT; proxyKeyboardEventInfo event = WINPR_C_ARRAY_INIT;
pServerContext* ps = NULL; pServerContext* ps = nullptr;
pClientContext* pc = NULL; pClientContext* pc = nullptr;
WINPR_ASSERT(input); WINPR_ASSERT(input);
ps = (pServerContext*)input->context; ps = (pServerContext*)input->context;
@@ -102,10 +102,10 @@ static BOOL pf_server_keyboard_event(rdpInput* input, UINT16 flags, UINT8 code)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_server_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) static BOOL pf_server_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
{ {
const proxyConfig* config = NULL; const proxyConfig* config = nullptr;
proxyUnicodeEventInfo event = WINPR_C_ARRAY_INIT; proxyUnicodeEventInfo event = WINPR_C_ARRAY_INIT;
pServerContext* ps = NULL; pServerContext* ps = nullptr;
pClientContext* pc = NULL; pClientContext* pc = nullptr;
WINPR_ASSERT(input); WINPR_ASSERT(input);
ps = (pServerContext*)input->context; ps = (pServerContext*)input->context;
@@ -135,9 +135,9 @@ WINPR_ATTR_NODISCARD
static BOOL pf_server_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) static BOOL pf_server_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
{ {
proxyMouseEventInfo event = WINPR_C_ARRAY_INIT; proxyMouseEventInfo event = WINPR_C_ARRAY_INIT;
const proxyConfig* config = NULL; const proxyConfig* config = nullptr;
pServerContext* ps = NULL; pServerContext* ps = nullptr;
pClientContext* pc = NULL; pClientContext* pc = nullptr;
WINPR_ASSERT(input); WINPR_ASSERT(input);
ps = (pServerContext*)input->context; ps = (pServerContext*)input->context;
@@ -169,10 +169,10 @@ static BOOL pf_server_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT1
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_server_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) static BOOL pf_server_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
{ {
const proxyConfig* config = NULL; const proxyConfig* config = nullptr;
proxyMouseExEventInfo event = WINPR_C_ARRAY_INIT; proxyMouseExEventInfo event = WINPR_C_ARRAY_INIT;
pServerContext* ps = NULL; pServerContext* ps = nullptr;
pClientContext* pc = NULL; pClientContext* pc = nullptr;
WINPR_ASSERT(input); WINPR_ASSERT(input);
ps = (pServerContext*)input->context; ps = (pServerContext*)input->context;

View File

@@ -357,7 +357,7 @@ static BOOL pf_modules_set_plugin_data(WINPR_ATTR_UNUSED proxyPluginsManager* mg
WINPR_ASSERT(plugin_name); WINPR_ASSERT(plugin_name);
ccharconv.ccp = plugin_name; ccharconv.ccp = plugin_name;
if (data == NULL) /* no need to store anything */ if (data == nullptr) /* no need to store anything */
return FALSE; return FALSE;
if (!HashTable_Insert(pdata->modules_info, ccharconv.cp, data)) if (!HashTable_Insert(pdata->modules_info, ccharconv.cp, data))
@@ -373,7 +373,7 @@ static BOOL pf_modules_set_plugin_data(WINPR_ATTR_UNUSED proxyPluginsManager* mg
* returns per-session data needed a plugin. * returns per-session data needed a plugin.
* *
* @context: current session server's rdpContext instance. * @context: current session server's rdpContext instance.
* if there's no data related to `plugin_name` in `context` (current session), a NULL will be * if there's no data related to `plugin_name` in `context` (current session), a nullptr will be
* returned. * returned.
*/ */
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
@@ -504,9 +504,9 @@ static BOOL pf_modules_load_static_module(const char* module_name, proxyModule*
{ {
WINPR_ASSERT(module); WINPR_ASSERT(module);
HANDLE handle = GetModuleHandleA(NULL); HANDLE handle = GetModuleHandleA(nullptr);
if (handle == NULL) if (handle == nullptr)
{ {
WLog_DBG(TAG, "failed loading static library: %s", module_name); WLog_DBG(TAG, "failed loading static library: %s", module_name);
return FALSE; return FALSE;
@@ -550,7 +550,7 @@ static BOOL pf_modules_load_dynamic_module(const char* module_path, proxyModule*
HANDLE handle = LoadLibraryX(module_path); HANDLE handle = LoadLibraryX(module_path);
if (handle == NULL) if (handle == nullptr)
{ {
WLog_DBG(TAG, "failed loading external library: %s", module_path); WLog_DBG(TAG, "failed loading external library: %s", module_path);
return FALSE; return FALSE;
@@ -649,18 +649,18 @@ static void* new_plugin(const void* obj)
const proxyPlugin* src = obj; const proxyPlugin* src = obj;
proxyPlugin* proxy = calloc(1, sizeof(proxyPlugin)); proxyPlugin* proxy = calloc(1, sizeof(proxyPlugin));
if (!proxy) if (!proxy)
return NULL; return nullptr;
*proxy = *src; *proxy = *src;
return proxy; return proxy;
} }
proxyModule* pf_modules_new(const char* root_dir, const char** modules, size_t count) proxyModule* pf_modules_new(const char* root_dir, const char** modules, size_t count)
{ {
wObject* obj = NULL; wObject* obj = nullptr;
char* path = NULL; char* path = nullptr;
proxyModule* module = calloc(1, sizeof(proxyModule)); proxyModule* module = calloc(1, sizeof(proxyModule));
if (!module) if (!module)
return NULL; return nullptr;
module->mgr.RegisterPlugin = pf_modules_register_plugin; module->mgr.RegisterPlugin = pf_modules_register_plugin;
module->mgr.SetPluginData = pf_modules_set_plugin_data; module->mgr.SetPluginData = pf_modules_set_plugin_data;
@@ -668,7 +668,7 @@ proxyModule* pf_modules_new(const char* root_dir, const char** modules, size_t c
module->mgr.AbortConnect = pf_modules_abort_connect; module->mgr.AbortConnect = pf_modules_abort_connect;
module->plugins = ArrayList_New(FALSE); module->plugins = ArrayList_New(FALSE);
if (module->plugins == NULL) if (module->plugins == nullptr)
{ {
WLog_ERR(TAG, "ArrayList_New failed!"); WLog_ERR(TAG, "ArrayList_New failed!");
goto error; goto error;
@@ -680,7 +680,7 @@ proxyModule* pf_modules_new(const char* root_dir, const char** modules, size_t c
obj->fnObjectNew = new_plugin; obj->fnObjectNew = new_plugin;
module->handles = ArrayList_New(FALSE); module->handles = ArrayList_New(FALSE);
if (module->handles == NULL) if (module->handles == nullptr)
{ {
WLog_ERR(TAG, "ArrayList_New failed!"); WLog_ERR(TAG, "ArrayList_New failed!");
@@ -698,7 +698,7 @@ proxyModule* pf_modules_new(const char* root_dir, const char** modules, size_t c
if (!winpr_PathFileExists(path)) if (!winpr_PathFileExists(path))
{ {
if (!winpr_PathMakePath(path, NULL)) if (!winpr_PathMakePath(path, nullptr))
{ {
WLog_ERR(TAG, "error occurred while creating modules directory: %s", root_dir); WLog_ERR(TAG, "error occurred while creating modules directory: %s", root_dir);
} }
@@ -710,7 +710,7 @@ proxyModule* pf_modules_new(const char* root_dir, const char** modules, size_t c
for (size_t i = 0; i < count; i++) for (size_t i = 0; i < count; i++)
{ {
const char* module_name = modules[i]; const char* module_name = modules[i];
if (!pf_modules_load_module(path, module_name, module, NULL)) if (!pf_modules_load_module(path, module_name, module, nullptr))
WLog_WARN(TAG, "Failed to load proxy module '%s'", module_name); WLog_WARN(TAG, "Failed to load proxy module '%s'", module_name);
else else
WLog_INFO(TAG, "Successfully loaded proxy module '%s'", module_name); WLog_INFO(TAG, "Successfully loaded proxy module '%s'", module_name);
@@ -723,7 +723,7 @@ proxyModule* pf_modules_new(const char* root_dir, const char** modules, size_t c
error: error:
free(path); free(path);
pf_modules_free(module); pf_modules_free(module);
return NULL; return nullptr;
} }
void pf_modules_free(proxyModule* module) void pf_modules_free(proxyModule* module)

View File

@@ -70,7 +70,7 @@ static BOOL pf_server_parse_target_from_routing_token(rdpContext* context, rdpSe
{ {
#define TARGET_MAX (100) #define TARGET_MAX (100)
#define ROUTING_TOKEN_PREFIX "Cookie: msts=" #define ROUTING_TOKEN_PREFIX "Cookie: msts="
char* colon = NULL; char* colon = nullptr;
size_t len = 0; size_t len = 0;
DWORD routing_token_length = 0; DWORD routing_token_length = 0;
const size_t prefix_len = strnlen(ROUTING_TOKEN_PREFIX, sizeof(ROUTING_TOKEN_PREFIX)); const size_t prefix_len = strnlen(ROUTING_TOKEN_PREFIX, sizeof(ROUTING_TOKEN_PREFIX));
@@ -97,7 +97,7 @@ static BOOL pf_server_parse_target_from_routing_token(rdpContext* context, rdpSe
if (colon) if (colon)
{ {
/* port is specified */ /* port is specified */
unsigned long p = strtoul(colon + 1, NULL, 10); unsigned long p = strtoul(colon + 1, nullptr, 10);
if (p > USHRT_MAX) if (p > USHRT_MAX)
return FALSE; return FALSE;
@@ -184,8 +184,9 @@ static BOOL pf_server_get_target_info(rdpContext* context, rdpSettings* settings
{ {
if (!ev.target_address) if (!ev.target_address)
{ {
PROXY_LOG_ERR(TAG, ps, PROXY_LOG_ERR(
"router: using CUSTOM_ADDR fetch method, but target_address == NULL"); TAG, ps,
"router: using CUSTOM_ADDR fetch method, but target_address == nullptr");
return FALSE; return FALSE;
} }
@@ -210,7 +211,7 @@ WINPR_ATTR_NODISCARD
static BOOL pf_server_setup_channels(freerdp_peer* peer) static BOOL pf_server_setup_channels(freerdp_peer* peer)
{ {
BOOL rc = FALSE; BOOL rc = FALSE;
char** accepted_channels = NULL; char** accepted_channels = nullptr;
size_t accepted_channels_count = 0; size_t accepted_channels_count = 0;
pServerContext* ps = (pServerContext*)peer->context; pServerContext* ps = (pServerContext*)peer->context;
@@ -220,7 +221,7 @@ static BOOL pf_server_setup_channels(freerdp_peer* peer)
for (size_t i = 0; i < accepted_channels_count; i++) for (size_t i = 0; i < accepted_channels_count; i++)
{ {
pServerStaticChannelContext* channelContext = NULL; pServerStaticChannelContext* channelContext = nullptr;
const char* cname = accepted_channels[i]; const char* cname = accepted_channels[i];
UINT16 channelId = WTSChannelGetId(peer, cname); UINT16 channelId = WTSChannelGetId(peer, cname);
@@ -289,11 +290,11 @@ fail:
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_server_post_connect(freerdp_peer* peer) static BOOL pf_server_post_connect(freerdp_peer* peer)
{ {
pServerContext* ps = NULL; pServerContext* ps = nullptr;
pClientContext* pc = NULL; pClientContext* pc = nullptr;
rdpSettings* client_settings = NULL; rdpSettings* client_settings = nullptr;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpSettings* frontSettings = NULL; rdpSettings* frontSettings = nullptr;
WINPR_ASSERT(peer); WINPR_ASSERT(peer);
@@ -315,7 +316,7 @@ static BOOL pf_server_post_connect(freerdp_peer* peer)
} }
pc = pf_context_create_client_context(frontSettings); pc = pf_context_create_client_context(frontSettings);
if (pc == NULL) if (pc == nullptr)
{ {
PROXY_LOG_ERR(TAG, ps, "failed to create client context!"); PROXY_LOG_ERR(TAG, ps, "failed to create client context!");
return FALSE; return FALSE;
@@ -340,7 +341,7 @@ static BOOL pf_server_post_connect(freerdp_peer* peer)
return FALSE; return FALSE;
/* Start a proxy's client in it's own thread */ /* Start a proxy's client in it's own thread */
if (!(pdata->client_thread = CreateThread(NULL, 0, pf_client_start, pc, 0, NULL))) if (!(pdata->client_thread = CreateThread(nullptr, 0, pf_client_start, pc, 0, nullptr)))
{ {
PROXY_LOG_ERR(TAG, ps, "failed to create client thread"); PROXY_LOG_ERR(TAG, ps, "failed to create client thread");
return FALSE; return FALSE;
@@ -352,9 +353,9 @@ static BOOL pf_server_post_connect(freerdp_peer* peer)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_server_activate(freerdp_peer* peer) static BOOL pf_server_activate(freerdp_peer* peer)
{ {
pServerContext* ps = NULL; pServerContext* ps = nullptr;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
WINPR_ASSERT(peer); WINPR_ASSERT(peer);
@@ -378,8 +379,8 @@ WINPR_ATTR_NODISCARD
static BOOL pf_server_logon(freerdp_peer* peer, const SEC_WINNT_AUTH_IDENTITY* identity, static BOOL pf_server_logon(freerdp_peer* peer, const SEC_WINNT_AUTH_IDENTITY* identity,
BOOL automatic) BOOL automatic)
{ {
pServerContext* ps = NULL; pServerContext* ps = nullptr;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
proxyServerPeerLogon info = WINPR_C_ARRAY_INIT; proxyServerPeerLogon info = WINPR_C_ARRAY_INIT;
WINPR_ASSERT(peer); WINPR_ASSERT(peer);
@@ -489,7 +490,7 @@ static BOOL pf_server_initialize_peer_connection(freerdp_peer* peer)
pdata->module = server->module; pdata->module = server->module;
const proxyConfig* config = pdata->config = server->config; const proxyConfig* config = pdata->config = server->config;
rdpPrivateKey* key = freerdp_key_new_from_pem_enc(config->PrivateKeyPEM, NULL); rdpPrivateKey* key = freerdp_key_new_from_pem_enc(config->PrivateKeyPEM, nullptr);
if (!key) if (!key)
return FALSE; return FALSE;
@@ -581,8 +582,8 @@ WINPR_ATTR_NODISCARD
static DWORD WINAPI pf_server_handle_peer(LPVOID arg) static DWORD WINAPI pf_server_handle_peer(LPVOID arg)
{ {
HANDLE eventHandles[MAXIMUM_WAIT_OBJECTS] = WINPR_C_ARRAY_INIT; HANDLE eventHandles[MAXIMUM_WAIT_OBJECTS] = WINPR_C_ARRAY_INIT;
pServerContext* ps = NULL; pServerContext* ps = nullptr;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
peer_thread_args* args = arg; peer_thread_args* args = arg;
WINPR_ASSERT(args); WINPR_ASSERT(args);
@@ -761,8 +762,8 @@ out_free_peer:
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_server_start_peer(freerdp_peer* client) static BOOL pf_server_start_peer(freerdp_peer* client)
{ {
HANDLE hThread = NULL; HANDLE hThread = nullptr;
proxyServer* server = NULL; proxyServer* server = nullptr;
peer_thread_args* args = calloc(1, sizeof(peer_thread_args)); peer_thread_args* args = calloc(1, sizeof(peer_thread_args));
if (!args) if (!args)
return FALSE; return FALSE;
@@ -773,7 +774,7 @@ static BOOL pf_server_start_peer(freerdp_peer* client)
server = (proxyServer*)client->ContextExtra; server = (proxyServer*)client->ContextExtra;
WINPR_ASSERT(server); WINPR_ASSERT(server);
hThread = CreateThread(NULL, 0, pf_server_handle_peer, args, CREATE_SUSPENDED, NULL); hThread = CreateThread(nullptr, 0, pf_server_handle_peer, args, CREATE_SUSPENDED, nullptr);
if (!hThread) if (!hThread)
{ {
free(args); free(args);
@@ -888,7 +889,7 @@ BOOL pf_server_start_with_peer_socket(proxyServer* server, int socket)
{ {
struct sockaddr_storage peer_addr; struct sockaddr_storage peer_addr;
socklen_t len = sizeof(peer_addr); socklen_t len = sizeof(peer_addr);
freerdp_peer* client = NULL; freerdp_peer* client = nullptr;
WINPR_ASSERT(server); WINPR_ASSERT(server);
@@ -943,14 +944,14 @@ static void peer_free(void* obj)
proxyServer* pf_server_new(const proxyConfig* config) proxyServer* pf_server_new(const proxyConfig* config)
{ {
wObject* obj = NULL; wObject* obj = nullptr;
proxyServer* server = NULL; proxyServer* server = nullptr;
WINPR_ASSERT(config); WINPR_ASSERT(config);
server = calloc(1, sizeof(proxyServer)); server = calloc(1, sizeof(proxyServer));
if (!server) if (!server)
return NULL; return nullptr;
if (!pf_config_clone(&server->config, config)) if (!pf_config_clone(&server->config, config))
goto out; goto out;
@@ -967,7 +968,7 @@ proxyServer* pf_server_new(const proxyConfig* config)
if (!are_all_required_modules_loaded(server->module, server->config)) if (!are_all_required_modules_loaded(server->module, server->config))
goto out; goto out;
server->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL); server->stopEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
if (!server->stopEvent) if (!server->stopEvent)
goto out; goto out;
@@ -997,7 +998,7 @@ out:
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
pf_server_free(server); pf_server_free(server);
WINPR_PRAGMA_DIAG_POP WINPR_PRAGMA_DIAG_POP
return NULL; return nullptr;
} }
BOOL pf_server_run(proxyServer* server) BOOL pf_server_run(proxyServer* server)
@@ -1006,7 +1007,7 @@ BOOL pf_server_run(proxyServer* server)
HANDLE eventHandles[MAXIMUM_WAIT_OBJECTS] = WINPR_C_ARRAY_INIT; HANDLE eventHandles[MAXIMUM_WAIT_OBJECTS] = WINPR_C_ARRAY_INIT;
DWORD eventCount = 0; DWORD eventCount = 0;
DWORD status = 0; DWORD status = 0;
freerdp_listener* listener = NULL; freerdp_listener* listener = nullptr;
WINPR_ASSERT(server); WINPR_ASSERT(server);

View File

@@ -39,7 +39,7 @@ WINPR_ATTR_NODISCARD
static BOOL pf_server_refresh_rect(rdpContext* context, BYTE count, const RECTANGLE_16* areas) static BOOL pf_server_refresh_rect(rdpContext* context, BYTE count, const RECTANGLE_16* areas)
{ {
pServerContext* ps = (pServerContext*)context; pServerContext* ps = (pServerContext*)context;
rdpContext* pc = NULL; rdpContext* pc = nullptr;
WINPR_ASSERT(ps); WINPR_ASSERT(ps);
WINPR_ASSERT(ps->pdata); WINPR_ASSERT(ps->pdata);
pc = (rdpContext*)ps->pdata->pc; pc = (rdpContext*)ps->pdata->pc;
@@ -53,7 +53,7 @@ WINPR_ATTR_NODISCARD
static BOOL pf_server_suppress_output(rdpContext* context, BYTE allow, const RECTANGLE_16* area) static BOOL pf_server_suppress_output(rdpContext* context, BYTE allow, const RECTANGLE_16* area)
{ {
pServerContext* ps = (pServerContext*)context; pServerContext* ps = (pServerContext*)context;
rdpContext* pc = NULL; rdpContext* pc = nullptr;
WINPR_ASSERT(ps); WINPR_ASSERT(ps);
WINPR_ASSERT(ps->pdata); WINPR_ASSERT(ps->pdata);
pc = (rdpContext*)ps->pdata->pc; pc = (rdpContext*)ps->pdata->pc;
@@ -73,8 +73,8 @@ WINPR_ATTR_NODISCARD
static BOOL pf_client_begin_paint(rdpContext* context) static BOOL pf_client_begin_paint(rdpContext* context)
{ {
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -95,8 +95,8 @@ WINPR_ATTR_NODISCARD
static BOOL pf_client_end_paint(rdpContext* context) static BOOL pf_client_end_paint(rdpContext* context)
{ {
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -121,8 +121,8 @@ WINPR_ATTR_NODISCARD
static BOOL pf_client_bitmap_update(rdpContext* context, const BITMAP_UPDATE* bitmap) static BOOL pf_client_bitmap_update(rdpContext* context, const BITMAP_UPDATE* bitmap)
{ {
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -138,8 +138,8 @@ WINPR_ATTR_NODISCARD
static BOOL pf_client_desktop_resize(rdpContext* context) static BOOL pf_client_desktop_resize(rdpContext* context)
{ {
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -162,8 +162,8 @@ static BOOL pf_client_remote_monitors(rdpContext* context, UINT32 count,
const MONITOR_DEF* monitors) const MONITOR_DEF* monitors)
{ {
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -178,8 +178,8 @@ static BOOL pf_client_send_pointer_system(rdpContext* context,
const POINTER_SYSTEM_UPDATE* pointer_system) const POINTER_SYSTEM_UPDATE* pointer_system)
{ {
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -197,8 +197,8 @@ static BOOL pf_client_send_pointer_position(rdpContext* context,
const POINTER_POSITION_UPDATE* pointerPosition) const POINTER_POSITION_UPDATE* pointerPosition)
{ {
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -216,8 +216,8 @@ static BOOL pf_client_send_pointer_color(rdpContext* context,
const POINTER_COLOR_UPDATE* pointer_color) const POINTER_COLOR_UPDATE* pointer_color)
{ {
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -235,8 +235,8 @@ static BOOL pf_client_send_pointer_large(rdpContext* context,
const POINTER_LARGE_UPDATE* pointer_large) const POINTER_LARGE_UPDATE* pointer_large)
{ {
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -253,8 +253,8 @@ WINPR_ATTR_NODISCARD
static BOOL pf_client_send_pointer_new(rdpContext* context, const POINTER_NEW_UPDATE* pointer_new) static BOOL pf_client_send_pointer_new(rdpContext* context, const POINTER_NEW_UPDATE* pointer_new)
{ {
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -272,8 +272,8 @@ static BOOL pf_client_send_pointer_cached(rdpContext* context,
const POINTER_CACHED_UPDATE* pointer_cached) const POINTER_CACHED_UPDATE* pointer_cached)
{ {
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -289,10 +289,10 @@ static BOOL pf_client_send_pointer_cached(rdpContext* context,
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL pf_client_save_session_info(rdpContext* context, UINT32 type, void* data) static BOOL pf_client_save_session_info(rdpContext* context, UINT32 type, void* data)
{ {
logon_info* logonInfo = NULL; logon_info* logonInfo = nullptr;
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -325,8 +325,8 @@ WINPR_ATTR_NODISCARD
static BOOL pf_client_server_status_info(rdpContext* context, UINT32 status) static BOOL pf_client_server_status_info(rdpContext* context, UINT32 status)
{ {
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -343,8 +343,8 @@ WINPR_ATTR_NODISCARD
static BOOL pf_client_set_keyboard_indicators(rdpContext* context, UINT16 led_flags) static BOOL pf_client_set_keyboard_indicators(rdpContext* context, UINT16 led_flags)
{ {
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -362,8 +362,8 @@ static BOOL pf_client_set_keyboard_ime_status(rdpContext* context, UINT16 imeId,
UINT32 imeConvMode) UINT32 imeConvMode)
{ {
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -382,8 +382,8 @@ static BOOL pf_client_window_create(rdpContext* context, const WINDOW_ORDER_INFO
{ {
BOOL rc = 0; BOOL rc = 0;
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -406,8 +406,8 @@ static BOOL pf_client_window_update(rdpContext* context, const WINDOW_ORDER_INFO
{ {
BOOL rc = 0; BOOL rc = 0;
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -430,8 +430,8 @@ static BOOL pf_client_window_icon(rdpContext* context, const WINDOW_ORDER_INFO*
{ {
BOOL rc = 0; BOOL rc = 0;
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -454,8 +454,8 @@ static BOOL pf_client_window_cached_icon(rdpContext* context, const WINDOW_ORDER
{ {
BOOL rc = 0; BOOL rc = 0;
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -477,8 +477,8 @@ static BOOL pf_client_window_delete(rdpContext* context, const WINDOW_ORDER_INFO
{ {
BOOL rc = 0; BOOL rc = 0;
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -501,8 +501,8 @@ static BOOL pf_client_notify_icon_create(rdpContext* context, const WINDOW_ORDER
{ {
BOOL rc = 0; BOOL rc = 0;
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -525,8 +525,8 @@ static BOOL pf_client_notify_icon_update(rdpContext* context, const WINDOW_ORDER
{ {
BOOL rc = 0; BOOL rc = 0;
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -549,8 +549,8 @@ static BOOL pf_client_notify_icon_delete(rdpContext* context, const WINDOW_ORDER
BOOL rc = 0; BOOL rc = 0;
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -573,8 +573,8 @@ static BOOL pf_client_monitored_desktop(rdpContext* context, const WINDOW_ORDER_
{ {
BOOL rc = 0; BOOL rc = 0;
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);
@@ -596,8 +596,8 @@ static BOOL pf_client_non_monitored_desktop(rdpContext* context, const WINDOW_OR
{ {
BOOL rc = 0; BOOL rc = 0;
pClientContext* pc = (pClientContext*)context; pClientContext* pc = (pClientContext*)context;
proxyData* pdata = NULL; proxyData* pdata = nullptr;
rdpContext* ps = NULL; rdpContext* ps = nullptr;
WINPR_ASSERT(pc); WINPR_ASSERT(pc);
pdata = pc->pdata; pdata = pc->pdata;
WINPR_ASSERT(pdata); WINPR_ASSERT(pdata);

View File

@@ -28,8 +28,8 @@
* @brief pf_utils_channel_is_passthrough Checks of a channel identified by 'name' * @brief pf_utils_channel_is_passthrough Checks of a channel identified by 'name'
* should be handled as passthrough. * should be handled as passthrough.
* *
* @param config The proxy configuration to check against. Must NOT be NULL. * @param config The proxy configuration to check against. Must NOT be nullptr.
* @param name The name of the channel. Must NOT be NULL. * @param name The name of the channel. Must NOT be nullptr.
* @return -1 if the channel is not handled, 0 if the channel should be ignored, * @return -1 if the channel is not handled, 0 if the channel should be ignored,
* 1 if the channel should be passed, 2 the channel will be intercepted * 1 if the channel should be passed, 2 the channel will be intercepted
* e.g. proxy client and server are termination points and data passed * e.g. proxy client and server are termination points and data passed

View File

@@ -82,7 +82,7 @@ extern "C"
/** /**
* @brief pf_modules_add Registers a new plugin * @brief pf_modules_add Registers a new plugin
* @param ep A module entry point function, must NOT be NULL * @param ep A module entry point function, must NOT be nullptr
* @return TRUE for success, FALSE otherwise * @return TRUE for success, FALSE otherwise
*/ */
WINPR_ATTR_NODISCARD BOOL pf_modules_add(proxyModule* module, proxyModuleEntryPoint ep, WINPR_ATTR_NODISCARD BOOL pf_modules_add(proxyModule* module, proxyModuleEntryPoint ep,

View File

@@ -30,7 +30,7 @@
#define TAG SERVER_TAG("shadow.mac") #define TAG SERVER_TAG("shadow.mac")
static macShadowSubsystem* g_Subsystem = NULL; static macShadowSubsystem* g_Subsystem = nullptr;
static BOOL mac_shadow_input_synchronize_event(rdpShadowSubsystem* subsystem, static BOOL mac_shadow_input_synchronize_event(rdpShadowSubsystem* subsystem,
rdpShadowClient* client, UINT32 flags) rdpShadowClient* client, UINT32 flags)
@@ -394,7 +394,7 @@ static void (^mac_capture_stream_handler)(
y = extents->top; y = extents->top;
width = extents->right - extents->left; width = extents->right - extents->left;
height = extents->bottom - extents->top; height = extents->bottom - extents->top;
IOSurfaceLock(frameSurface, kIOSurfaceLockReadOnly, NULL); IOSurfaceLock(frameSurface, kIOSurfaceLockReadOnly, nullptr);
pSrcData = (BYTE*)IOSurfaceGetBaseAddress(frameSurface); pSrcData = (BYTE*)IOSurfaceGetBaseAddress(frameSurface);
nSrcStep = (int)IOSurfaceGetBytesPerRow(frameSurface); nSrcStep = (int)IOSurfaceGetBytesPerRow(frameSurface);
@@ -407,11 +407,11 @@ static void (^mac_capture_stream_handler)(
{ {
freerdp_image_copy_no_overlap(surface->data, surface->format, surface->scanline, x, y, freerdp_image_copy_no_overlap(surface->data, surface->format, surface->scanline, x, y,
width, height, pSrcData, PIXEL_FORMAT_BGRX32, nSrcStep, x, width, height, pSrcData, PIXEL_FORMAT_BGRX32, nSrcStep, x,
y, NULL, FREERDP_FLIP_NONE); y, nullptr, FREERDP_FLIP_NONE);
} }
LeaveCriticalSection(&(surface->lock)); LeaveCriticalSection(&(surface->lock));
IOSurfaceUnlock(frameSurface, kIOSurfaceLockReadOnly, NULL); IOSurfaceUnlock(frameSurface, kIOSurfaceLockReadOnly, nullptr);
ArrayList_Lock(server->clients); ArrayList_Lock(server->clients);
count = ArrayList_Count(server->clients); count = ArrayList_Count(server->clients);
shadow_subsystem_frame_update(&subsystem->common); shadow_subsystem_frame_update(&subsystem->common);
@@ -470,11 +470,11 @@ static int mac_shadow_capture_init(macShadowSubsystem* subsystem)
CFDictionaryRef opts; CFDictionaryRef opts;
CGDirectDisplayID displayId; CGDirectDisplayID displayId;
displayId = CGMainDisplayID(); displayId = CGMainDisplayID();
subsystem->captureQueue = dispatch_queue_create("mac.shadow.capture", NULL); subsystem->captureQueue = dispatch_queue_create("mac.shadow.capture", nullptr);
keys[0] = (void*)kCGDisplayStreamShowCursor; keys[0] = (void*)kCGDisplayStreamShowCursor;
values[0] = (void*)kCFBooleanFalse; values[0] = (void*)kCFBooleanFalse;
opts = CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)values, 1, opts = CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)values, 1,
NULL, NULL); nullptr, nullptr);
subsystem->stream = CGDisplayStreamCreateWithDispatchQueue( subsystem->stream = CGDisplayStreamCreateWithDispatchQueue(
displayId, subsystem->pixelWidth, subsystem->pixelHeight, 'BGRA', opts, displayId, subsystem->pixelWidth, subsystem->pixelHeight, 'BGRA', opts,
subsystem->captureQueue, mac_capture_stream_handler); subsystem->captureQueue, mac_capture_stream_handler);
@@ -601,7 +601,7 @@ static int mac_shadow_subsystem_uninit(rdpShadowSubsystem* rdpsubsystem)
if (subsystem->lastUpdate) if (subsystem->lastUpdate)
{ {
CFRelease(subsystem->lastUpdate); CFRelease(subsystem->lastUpdate);
subsystem->lastUpdate = NULL; subsystem->lastUpdate = nullptr;
} }
return 1; return 1;
@@ -617,7 +617,8 @@ static int mac_shadow_subsystem_start(rdpShadowSubsystem* rdpsubsystem)
mac_shadow_capture_start(subsystem); mac_shadow_capture_start(subsystem);
if (!(thread = CreateThread(NULL, 0, mac_shadow_subsystem_thread, (void*)subsystem, 0, NULL))) if (!(thread =
CreateThread(nullptr, 0, mac_shadow_subsystem_thread, (void*)subsystem, 0, nullptr)))
{ {
WLog_ERR(TAG, "Failed to create thread"); WLog_ERR(TAG, "Failed to create thread");
return -1; return -1;
@@ -648,7 +649,7 @@ static rdpShadowSubsystem* mac_shadow_subsystem_new(void)
macShadowSubsystem* subsystem = calloc(1, sizeof(macShadowSubsystem)); macShadowSubsystem* subsystem = calloc(1, sizeof(macShadowSubsystem));
if (!subsystem) if (!subsystem)
return NULL; return nullptr;
subsystem->common.SynchronizeEvent = mac_shadow_input_synchronize_event; subsystem->common.SynchronizeEvent = mac_shadow_input_synchronize_event;
subsystem->common.KeyboardEvent = mac_shadow_input_keyboard_event; subsystem->common.KeyboardEvent = mac_shadow_input_keyboard_event;

View File

@@ -161,7 +161,7 @@ static rdpShadowSubsystem* sample_shadow_subsystem_new(void)
(sampleShadowSubsystem*)calloc(1, sizeof(sampleShadowSubsystem)); (sampleShadowSubsystem*)calloc(1, sizeof(sampleShadowSubsystem));
if (!subsystem) if (!subsystem)
return NULL; return nullptr;
subsystem->base.SynchronizeEvent = sample_shadow_input_synchronize_event; subsystem->base.SynchronizeEvent = sample_shadow_input_synchronize_event;
subsystem->base.KeyboardEvent = sample_shadow_input_keyboard_event; subsystem->base.KeyboardEvent = sample_shadow_input_keyboard_event;

View File

@@ -42,7 +42,7 @@ static D3D_FEATURE_LEVEL FeatureLevels[] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE
static UINT NumFeatureLevels = ARRAYSIZE(FeatureLevels); static UINT NumFeatureLevels = ARRAYSIZE(FeatureLevels);
static HMODULE d3d11_module = NULL; static HMODULE d3d11_module = nullptr;
typedef HRESULT(WINAPI* fnD3D11CreateDevice)(IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType, typedef HRESULT(WINAPI* fnD3D11CreateDevice)(IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType,
HMODULE Software, UINT Flags, HMODULE Software, UINT Flags,
@@ -52,7 +52,7 @@ typedef HRESULT(WINAPI* fnD3D11CreateDevice)(IDXGIAdapter* pAdapter, D3D_DRIVER_
D3D_FEATURE_LEVEL* pFeatureLevel, D3D_FEATURE_LEVEL* pFeatureLevel,
ID3D11DeviceContext** ppImmediateContext); ID3D11DeviceContext** ppImmediateContext);
static fnD3D11CreateDevice pfnD3D11CreateDevice = NULL; static fnD3D11CreateDevice pfnD3D11CreateDevice = nullptr;
#undef DEFINE_GUID #undef DEFINE_GUID
#define INITGUID #define INITGUID
@@ -300,10 +300,10 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem)
DXGI_OUTPUT_DESC outputDesc = WINPR_C_ARRAY_INIT; DXGI_OUTPUT_DESC outputDesc = WINPR_C_ARRAY_INIT;
DXGI_OUTPUT_DESC* pOutputDesc; DXGI_OUTPUT_DESC* pOutputDesc;
D3D11_TEXTURE2D_DESC textureDesc; D3D11_TEXTURE2D_DESC textureDesc;
IDXGIDevice* dxgiDevice = NULL; IDXGIDevice* dxgiDevice = nullptr;
IDXGIAdapter* dxgiAdapter = NULL; IDXGIAdapter* dxgiAdapter = nullptr;
IDXGIOutput* dxgiOutput = NULL; IDXGIOutput* dxgiOutput = nullptr;
IDXGIOutput1* dxgiOutput1 = NULL; IDXGIOutput1* dxgiOutput1 = nullptr;
hr = subsystem->dxgiDevice->lpVtbl->QueryInterface(subsystem->dxgiDevice, &IID_IDXGIDevice, hr = subsystem->dxgiDevice->lpVtbl->QueryInterface(subsystem->dxgiDevice, &IID_IDXGIDevice,
(void**)&dxgiDevice); (void**)&dxgiDevice);
@@ -320,7 +320,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem)
if (dxgiDevice) if (dxgiDevice)
{ {
dxgiDevice->lpVtbl->Release(dxgiDevice); dxgiDevice->lpVtbl->Release(dxgiDevice);
dxgiDevice = NULL; dxgiDevice = nullptr;
} }
if (FAILED(hr)) if (FAILED(hr))
@@ -330,7 +330,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem)
return -1; return -1;
} }
pOutput = NULL; pOutput = nullptr;
while (dxgiAdapter->lpVtbl->EnumOutputs(dxgiAdapter, i, &pOutput) != DXGI_ERROR_NOT_FOUND) while (dxgiAdapter->lpVtbl->EnumOutputs(dxgiAdapter, i, &pOutput) != DXGI_ERROR_NOT_FOUND)
{ {
@@ -358,7 +358,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem)
if (dxgiAdapter) if (dxgiAdapter)
{ {
dxgiAdapter->lpVtbl->Release(dxgiAdapter); dxgiAdapter->lpVtbl->Release(dxgiAdapter);
dxgiAdapter = NULL; dxgiAdapter = nullptr;
} }
if (FAILED(hr)) if (FAILED(hr))
@@ -373,7 +373,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem)
if (dxgiOutput) if (dxgiOutput)
{ {
dxgiOutput->lpVtbl->Release(dxgiOutput); dxgiOutput->lpVtbl->Release(dxgiOutput);
dxgiOutput = NULL; dxgiOutput = nullptr;
} }
if (FAILED(hr)) if (FAILED(hr))
@@ -389,7 +389,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem)
if (dxgiOutput1) if (dxgiOutput1)
{ {
dxgiOutput1->lpVtbl->Release(dxgiOutput1); dxgiOutput1->lpVtbl->Release(dxgiOutput1);
dxgiOutput1 = NULL; dxgiOutput1 = nullptr;
} }
if (FAILED(hr)) if (FAILED(hr))
@@ -411,8 +411,8 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem)
textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
textureDesc.MiscFlags = 0; textureDesc.MiscFlags = 0;
hr = subsystem->dxgiDevice->lpVtbl->CreateTexture2D(subsystem->dxgiDevice, &textureDesc, NULL, hr = subsystem->dxgiDevice->lpVtbl->CreateTexture2D(subsystem->dxgiDevice, &textureDesc,
&(subsystem->dxgiStage)); nullptr, &(subsystem->dxgiStage));
if (FAILED(hr)) if (FAILED(hr))
{ {
@@ -430,10 +430,10 @@ int win_shadow_dxgi_init(winShadowSubsystem* subsystem)
HRESULT hr; HRESULT hr;
int status; int status;
UINT DriverTypeIndex; UINT DriverTypeIndex;
IDXGIDevice* DxgiDevice = NULL; IDXGIDevice* DxgiDevice = nullptr;
IDXGIAdapter* DxgiAdapter = NULL; IDXGIAdapter* DxgiAdapter = nullptr;
IDXGIOutput* DxgiOutput = NULL; IDXGIOutput* DxgiOutput = nullptr;
IDXGIOutput1* DxgiOutput1 = NULL; IDXGIOutput1* DxgiOutput1 = nullptr;
win_shadow_d3d11_module_init(); win_shadow_d3d11_module_init();
@@ -442,7 +442,7 @@ int win_shadow_dxgi_init(winShadowSubsystem* subsystem)
for (DriverTypeIndex = 0; DriverTypeIndex < NumDriverTypes; ++DriverTypeIndex) for (DriverTypeIndex = 0; DriverTypeIndex < NumDriverTypes; ++DriverTypeIndex)
{ {
hr = pfnD3D11CreateDevice(NULL, DriverTypes[DriverTypeIndex], NULL, 0, FeatureLevels, hr = pfnD3D11CreateDevice(nullptr, DriverTypes[DriverTypeIndex], nullptr, 0, FeatureLevels,
NumFeatureLevels, D3D11_SDK_VERSION, &(subsystem->dxgiDevice), NumFeatureLevels, D3D11_SDK_VERSION, &(subsystem->dxgiDevice),
&(subsystem->featureLevel), &(subsystem->dxgiDeviceContext)); &(subsystem->featureLevel), &(subsystem->dxgiDeviceContext));
@@ -466,31 +466,31 @@ int win_shadow_dxgi_uninit(winShadowSubsystem* subsystem)
if (subsystem->dxgiStage) if (subsystem->dxgiStage)
{ {
subsystem->dxgiStage->lpVtbl->Release(subsystem->dxgiStage); subsystem->dxgiStage->lpVtbl->Release(subsystem->dxgiStage);
subsystem->dxgiStage = NULL; subsystem->dxgiStage = nullptr;
} }
if (subsystem->dxgiDesktopImage) if (subsystem->dxgiDesktopImage)
{ {
subsystem->dxgiDesktopImage->lpVtbl->Release(subsystem->dxgiDesktopImage); subsystem->dxgiDesktopImage->lpVtbl->Release(subsystem->dxgiDesktopImage);
subsystem->dxgiDesktopImage = NULL; subsystem->dxgiDesktopImage = nullptr;
} }
if (subsystem->dxgiOutputDuplication) if (subsystem->dxgiOutputDuplication)
{ {
subsystem->dxgiOutputDuplication->lpVtbl->Release(subsystem->dxgiOutputDuplication); subsystem->dxgiOutputDuplication->lpVtbl->Release(subsystem->dxgiOutputDuplication);
subsystem->dxgiOutputDuplication = NULL; subsystem->dxgiOutputDuplication = nullptr;
} }
if (subsystem->dxgiDeviceContext) if (subsystem->dxgiDeviceContext)
{ {
subsystem->dxgiDeviceContext->lpVtbl->Release(subsystem->dxgiDeviceContext); subsystem->dxgiDeviceContext->lpVtbl->Release(subsystem->dxgiDeviceContext);
subsystem->dxgiDeviceContext = NULL; subsystem->dxgiDeviceContext = nullptr;
} }
if (subsystem->dxgiDevice) if (subsystem->dxgiDevice)
{ {
subsystem->dxgiDevice->lpVtbl->Release(subsystem->dxgiDevice); subsystem->dxgiDevice->lpVtbl->Release(subsystem->dxgiDevice);
subsystem->dxgiDevice = NULL; subsystem->dxgiDevice = nullptr;
} }
return 1; return 1;
@@ -568,7 +568,7 @@ int win_shadow_dxgi_release_frame_data(winShadowSubsystem* subsystem)
} }
subsystem->dxgiSurface->lpVtbl->Release(subsystem->dxgiSurface); subsystem->dxgiSurface->lpVtbl->Release(subsystem->dxgiSurface);
subsystem->dxgiSurface = NULL; subsystem->dxgiSurface = nullptr;
} }
if (subsystem->dxgiOutputDuplication) if (subsystem->dxgiOutputDuplication)
@@ -593,7 +593,7 @@ int win_shadow_dxgi_get_next_frame(winShadowSubsystem* subsystem)
HRESULT hr = 0; HRESULT hr = 0;
UINT timeout = 15; UINT timeout = 15;
UINT DataBufferSize = 0; UINT DataBufferSize = 0;
BYTE* DataBuffer = NULL; BYTE* DataBuffer = nullptr;
if (subsystem->dxgiFrameAcquired) if (subsystem->dxgiFrameAcquired)
{ {
@@ -603,7 +603,7 @@ int win_shadow_dxgi_get_next_frame(winShadowSubsystem* subsystem)
if (subsystem->dxgiDesktopImage) if (subsystem->dxgiDesktopImage)
{ {
subsystem->dxgiDesktopImage->lpVtbl->Release(subsystem->dxgiDesktopImage); subsystem->dxgiDesktopImage->lpVtbl->Release(subsystem->dxgiDesktopImage);
subsystem->dxgiDesktopImage = NULL; subsystem->dxgiDesktopImage = nullptr;
} }
hr = subsystem->dxgiOutputDuplication->lpVtbl->AcquireNextFrame( hr = subsystem->dxgiOutputDuplication->lpVtbl->AcquireNextFrame(
@@ -631,13 +631,13 @@ int win_shadow_dxgi_get_next_frame(winShadowSubsystem* subsystem)
if (subsystem->dxgiDesktopImage) if (subsystem->dxgiDesktopImage)
{ {
subsystem->dxgiDesktopImage->lpVtbl->Release(subsystem->dxgiDesktopImage); subsystem->dxgiDesktopImage->lpVtbl->Release(subsystem->dxgiDesktopImage);
subsystem->dxgiDesktopImage = NULL; subsystem->dxgiDesktopImage = nullptr;
} }
if (subsystem->dxgiOutputDuplication) if (subsystem->dxgiOutputDuplication)
{ {
subsystem->dxgiOutputDuplication->lpVtbl->Release(subsystem->dxgiOutputDuplication); subsystem->dxgiOutputDuplication->lpVtbl->Release(subsystem->dxgiOutputDuplication);
subsystem->dxgiOutputDuplication = NULL; subsystem->dxgiOutputDuplication = nullptr;
} }
status = win_shadow_dxgi_init_duplication(subsystem); status = win_shadow_dxgi_init_duplication(subsystem);
@@ -668,7 +668,7 @@ int win_shadow_dxgi_get_next_frame(winShadowSubsystem* subsystem)
if (subsystem->dxgiResource) if (subsystem->dxgiResource)
{ {
subsystem->dxgiResource->lpVtbl->Release(subsystem->dxgiResource); subsystem->dxgiResource->lpVtbl->Release(subsystem->dxgiResource);
subsystem->dxgiResource = NULL; subsystem->dxgiResource = nullptr;
} }
if (FAILED(hr)) if (FAILED(hr))

View File

@@ -249,7 +249,7 @@ static int shw_freerdp_client_start(rdpContext* context)
freerdp* instance = context->instance; freerdp* instance = context->instance;
shw = (shwContext*)context; shw = (shwContext*)context;
if (!(shw->common.thread = CreateThread(NULL, 0, shw_client_thread, instance, 0, NULL))) if (!(shw->common.thread = CreateThread(nullptr, 0, shw_client_thread, instance, 0, nullptr)))
{ {
WLog_ERR(TAG, "Failed to create thread"); WLog_ERR(TAG, "Failed to create thread");
return -1; return -1;
@@ -276,7 +276,7 @@ static BOOL shw_freerdp_client_new(freerdp* instance, rdpContext* context)
shw = (shwContext*)instance->context; shw = (shwContext*)instance->context;
WINPR_ASSERT(shw); WINPR_ASSERT(shw);
if (!(shw->StopEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) if (!(shw->StopEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
return FALSE; return FALSE;
instance->LoadChannels = freerdp_client_load_channels; instance->LoadChannels = freerdp_client_load_channels;
@@ -374,7 +374,7 @@ int shw_RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
{ {
pEntryPoints->Version = 1; pEntryPoints->Version = 1;
pEntryPoints->Size = sizeof(RDP_CLIENT_ENTRY_POINTS_V1); pEntryPoints->Size = sizeof(RDP_CLIENT_ENTRY_POINTS_V1);
pEntryPoints->settings = NULL; pEntryPoints->settings = nullptr;
pEntryPoints->ContextSize = sizeof(shwContext); pEntryPoints->ContextSize = sizeof(shwContext);
pEntryPoints->GlobalInit = shw_freerdp_client_global_init; pEntryPoints->GlobalInit = shw_freerdp_client_global_init;
pEntryPoints->GlobalUninit = shw_freerdp_client_global_uninit; pEntryPoints->GlobalUninit = shw_freerdp_client_global_uninit;
@@ -394,10 +394,10 @@ int win_shadow_rdp_init(winShadowSubsystem* subsystem)
clientEntryPoints.Version = RDP_CLIENT_INTERFACE_VERSION; clientEntryPoints.Version = RDP_CLIENT_INTERFACE_VERSION;
shw_RdpClientEntry(&clientEntryPoints); shw_RdpClientEntry(&clientEntryPoints);
if (!(subsystem->RdpUpdateEnterEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) if (!(subsystem->RdpUpdateEnterEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
goto fail_enter_event; goto fail_enter_event;
if (!(subsystem->RdpUpdateLeaveEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) if (!(subsystem->RdpUpdateLeaveEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
goto fail_leave_event; goto fail_leave_event;
if (!(context = freerdp_client_context_new(&clientEntryPoints))) if (!(context = freerdp_client_context_new(&clientEntryPoints)))

View File

@@ -247,7 +247,7 @@ static int win_shadow_surface_copy(winShadowSubsystem* subsystem)
int status = 1; int status = 1;
int nDstStep = 0; int nDstStep = 0;
DWORD DstFormat; DWORD DstFormat;
BYTE* pDstData = NULL; BYTE* pDstData = nullptr;
rdpShadowServer* server; rdpShadowServer* server;
rdpShadowSurface* surface; rdpShadowSurface* surface;
RECTANGLE_16 surfaceRect; RECTANGLE_16 surfaceRect;
@@ -315,7 +315,7 @@ static int win_shadow_surface_copy(winShadowSubsystem* subsystem)
return status; return status;
if (!freerdp_image_copy_no_overlap(surface->data, surface->format, surface->scanline, x, y, if (!freerdp_image_copy_no_overlap(surface->data, surface->format, surface->scanline, x, y,
width, height, pDstData, DstFormat, nDstStep, x, y, NULL, width, height, pDstData, DstFormat, nDstStep, x, y, nullptr,
FREERDP_FLIP_NONE)) FREERDP_FLIP_NONE))
return ERROR_INTERNAL_ERROR; return ERROR_INTERNAL_ERROR;
@@ -430,9 +430,9 @@ static UINT32 win_shadow_enum_monitors(MONITOR_DEF* monitors, UINT32 maxMonitors
displayDevice.cb = sizeof(DISPLAY_DEVICE); displayDevice.cb = sizeof(DISPLAY_DEVICE);
if (EnumDisplayDevices(NULL, iDevNum, &displayDevice, 0)) if (EnumDisplayDevices(nullptr, iDevNum, &displayDevice, 0))
{ {
hdc = CreateDC(displayDevice.DeviceName, NULL, NULL, NULL); hdc = CreateDC(displayDevice.DeviceName, nullptr, nullptr, nullptr);
desktopWidth = GetDeviceCaps(hdc, HORZRES); desktopWidth = GetDeviceCaps(hdc, HORZRES);
desktopHeight = GetDeviceCaps(hdc, VERTRES); desktopHeight = GetDeviceCaps(hdc, VERTRES);
index = 0; index = 0;
@@ -493,7 +493,8 @@ static int win_shadow_subsystem_start(rdpShadowSubsystem* arg)
if (!subsystem) if (!subsystem)
return -1; return -1;
if (!(thread = CreateThread(NULL, 0, win_shadow_subsystem_thread, (void*)subsystem, 0, NULL))) if (!(thread =
CreateThread(nullptr, 0, win_shadow_subsystem_thread, (void*)subsystem, 0, nullptr)))
{ {
WLog_ERR(TAG, "Failed to create thread"); WLog_ERR(TAG, "Failed to create thread");
return -1; return -1;
@@ -529,7 +530,7 @@ static rdpShadowSubsystem* win_shadow_subsystem_new(void)
subsystem = (winShadowSubsystem*)calloc(1, sizeof(winShadowSubsystem)); subsystem = (winShadowSubsystem*)calloc(1, sizeof(winShadowSubsystem));
if (!subsystem) if (!subsystem)
return NULL; return nullptr;
subsystem->base.SynchronizeEvent = win_shadow_input_synchronize_event; subsystem->base.SynchronizeEvent = win_shadow_input_synchronize_event;
subsystem->base.KeyboardEvent = win_shadow_input_keyboard_event; subsystem->base.KeyboardEvent = win_shadow_input_keyboard_event;

View File

@@ -186,7 +186,7 @@ Shadow_IRDPSessionEvents_QueryInterface(__RPC__in _IRDPSessionEvents* This,
/* [annotation][iid_is][out] */ /* [annotation][iid_is][out] */
_COM_Outptr_ void** ppvObject) _COM_Outptr_ void** ppvObject)
{ {
*ppvObject = NULL; *ppvObject = nullptr;
if (IsEqualIID(riid, &DIID__IRDPSessionEvents) || IsEqualIID(riid, &IID_IDispatch) || if (IsEqualIID(riid, &DIID__IRDPSessionEvents) || IsEqualIID(riid, &IID_IDispatch) ||
IsEqualIID(riid, &IID_IUnknown)) IsEqualIID(riid, &IID_IUnknown))
@@ -278,7 +278,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke(_IRDPSessionEve
IDispatch* pDispatch; IDispatch* pDispatch;
IRDPSRAPIAttendee* pAttendee; IRDPSRAPIAttendee* pAttendee;
vr.vt = VT_DISPATCH; vr.vt = VT_DISPATCH;
vr.pdispVal = NULL; vr.pdispVal = nullptr;
hr = DispGetParam(pDispParams, 0, VT_DISPATCH, &vr, &uArgErr); hr = DispGetParam(pDispParams, 0, VT_DISPATCH, &vr, &uArgErr);
if (FAILED(hr)) if (FAILED(hr))
@@ -341,7 +341,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke(_IRDPSessionEve
IDispatch* pDispatch; IDispatch* pDispatch;
IRDPSRAPIAttendee* pAttendee; IRDPSRAPIAttendee* pAttendee;
vr.vt = VT_INT; vr.vt = VT_INT;
vr.pdispVal = NULL; vr.pdispVal = nullptr;
hr = DispGetParam(pDispParams, 1, VT_INT, &vr, &uArgErr); hr = DispGetParam(pDispParams, 1, VT_INT, &vr, &uArgErr);
if (FAILED(hr)) if (FAILED(hr))
@@ -353,7 +353,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke(_IRDPSessionEve
level = vr.intVal; level = vr.intVal;
vr.vt = VT_DISPATCH; vr.vt = VT_DISPATCH;
vr.pdispVal = NULL; vr.pdispVal = nullptr;
hr = DispGetParam(pDispParams, 0, VT_DISPATCH, &vr, &uArgErr); hr = DispGetParam(pDispParams, 0, VT_DISPATCH, &vr, &uArgErr);
if (FAILED(hr)) if (FAILED(hr))
@@ -479,7 +479,7 @@ int win_shadow_wds_wnd_init(winShadowSubsystem* subsystem)
HMODULE hModule; HMODULE hModule;
HINSTANCE hInstance; HINSTANCE hInstance;
WNDCLASSEX wndClassEx = WINPR_C_ARRAY_INIT; WNDCLASSEX wndClassEx = WINPR_C_ARRAY_INIT;
hModule = GetModuleHandle(NULL); hModule = GetModuleHandle(nullptr);
wndClassEx.cbSize = sizeof(WNDCLASSEX); wndClassEx.cbSize = sizeof(WNDCLASSEX);
wndClassEx.style = 0; wndClassEx.style = 0;
@@ -487,12 +487,12 @@ int win_shadow_wds_wnd_init(winShadowSubsystem* subsystem)
wndClassEx.cbClsExtra = 0; wndClassEx.cbClsExtra = 0;
wndClassEx.cbWndExtra = 0; wndClassEx.cbWndExtra = 0;
wndClassEx.hInstance = hModule; wndClassEx.hInstance = hModule;
wndClassEx.hIcon = NULL; wndClassEx.hIcon = nullptr;
wndClassEx.hCursor = NULL; wndClassEx.hCursor = nullptr;
wndClassEx.hbrBackground = NULL; wndClassEx.hbrBackground = nullptr;
wndClassEx.lpszMenuName = _T("ShadowWndMenu"); wndClassEx.lpszMenuName = _T("ShadowWndMenu");
wndClassEx.lpszClassName = _T("ShadowWndClass"); wndClassEx.lpszClassName = _T("ShadowWndClass");
wndClassEx.hIconSm = NULL; wndClassEx.hIconSm = nullptr;
if (!RegisterClassEx(&wndClassEx)) if (!RegisterClassEx(&wndClassEx))
{ {
@@ -502,7 +502,7 @@ int win_shadow_wds_wnd_init(winShadowSubsystem* subsystem)
hInstance = wndClassEx.hInstance; hInstance = wndClassEx.hInstance;
subsystem->hWnd = CreateWindowEx(0, wndClassEx.lpszClassName, 0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, subsystem->hWnd = CreateWindowEx(0, wndClassEx.lpszClassName, 0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0,
hInstance, NULL); hInstance, nullptr);
if (!subsystem->hWnd) if (!subsystem->hWnd)
{ {
@@ -521,17 +521,17 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem)
long top = 0; long top = 0;
long right = 0; long right = 0;
long bottom = 0; long bottom = 0;
BSTR bstrAuthString = NULL; BSTR bstrAuthString = nullptr;
BSTR bstrGroupName = NULL; BSTR bstrGroupName = nullptr;
BSTR bstrPassword = NULL; BSTR bstrPassword = nullptr;
BSTR bstrPropertyName = NULL; BSTR bstrPropertyName = nullptr;
VARIANT varPropertyValue; VARIANT varPropertyValue;
rdpAssistanceFile* file = NULL; rdpAssistanceFile* file = nullptr;
IConnectionPoint* pCP = NULL; IConnectionPoint* pCP = nullptr;
IConnectionPointContainer* pCPC = NULL; IConnectionPointContainer* pCPC = nullptr;
win_shadow_wds_wnd_init(subsystem); win_shadow_wds_wnd_init(subsystem);
HRESULT hr = OleInitialize(NULL); HRESULT hr = OleInitialize(nullptr);
if (FAILED(hr)) if (FAILED(hr))
{ {
@@ -539,7 +539,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem)
return -1; return -1;
} }
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
if (FAILED(hr)) if (FAILED(hr))
{ {
@@ -547,7 +547,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem)
return -1; return -1;
} }
hr = CoCreateInstance(&CLSID_RDPSession, NULL, CLSCTX_ALL, &IID_IRDPSRAPISharingSession, hr = CoCreateInstance(&CLSID_RDPSession, nullptr, CLSCTX_ALL, &IID_IRDPSRAPISharingSession,
(void**)&(subsystem->pSharingSession)); (void**)&(subsystem->pSharingSession));
if (FAILED(hr)) if (FAILED(hr))
@@ -743,7 +743,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem)
return -1; return -1;
} }
ConnectionString2 = ConvertWCharToUtf8Alloc(bstrConnectionString, NULL); ConnectionString2 = ConvertWCharToUtf8Alloc(bstrConnectionString, nullptr);
SysFreeString(bstrConnectionString); SysFreeString(bstrConnectionString);
status2 = freerdp_assistance_set_connection_string2(file, ConnectionString2, "Shadow123!"); status2 = freerdp_assistance_set_connection_string2(file, ConnectionString2, "Shadow123!");
free(ConnectionString2); free(ConnectionString2);
@@ -794,61 +794,61 @@ int win_shadow_wds_uninit(winShadowSubsystem* subsystem)
{ {
subsystem->pSharingSession->lpVtbl->Close(subsystem->pSharingSession); subsystem->pSharingSession->lpVtbl->Close(subsystem->pSharingSession);
subsystem->pSharingSession->lpVtbl->Release(subsystem->pSharingSession); subsystem->pSharingSession->lpVtbl->Release(subsystem->pSharingSession);
subsystem->pSharingSession = NULL; subsystem->pSharingSession = nullptr;
} }
if (subsystem->pVirtualChannelMgr) if (subsystem->pVirtualChannelMgr)
{ {
subsystem->pVirtualChannelMgr->lpVtbl->Release(subsystem->pVirtualChannelMgr); subsystem->pVirtualChannelMgr->lpVtbl->Release(subsystem->pVirtualChannelMgr);
subsystem->pVirtualChannelMgr = NULL; subsystem->pVirtualChannelMgr = nullptr;
} }
if (subsystem->pApplicationFilter) if (subsystem->pApplicationFilter)
{ {
subsystem->pApplicationFilter->lpVtbl->Release(subsystem->pApplicationFilter); subsystem->pApplicationFilter->lpVtbl->Release(subsystem->pApplicationFilter);
subsystem->pApplicationFilter = NULL; subsystem->pApplicationFilter = nullptr;
} }
if (subsystem->pAttendeeMgr) if (subsystem->pAttendeeMgr)
{ {
subsystem->pAttendeeMgr->lpVtbl->Release(subsystem->pAttendeeMgr); subsystem->pAttendeeMgr->lpVtbl->Release(subsystem->pAttendeeMgr);
subsystem->pAttendeeMgr = NULL; subsystem->pAttendeeMgr = nullptr;
} }
if (subsystem->pSessionProperties) if (subsystem->pSessionProperties)
{ {
subsystem->pSessionProperties->lpVtbl->Release(subsystem->pSessionProperties); subsystem->pSessionProperties->lpVtbl->Release(subsystem->pSessionProperties);
subsystem->pSessionProperties = NULL; subsystem->pSessionProperties = nullptr;
} }
if (subsystem->pInvitationMgr) if (subsystem->pInvitationMgr)
{ {
subsystem->pInvitationMgr->lpVtbl->Release(subsystem->pInvitationMgr); subsystem->pInvitationMgr->lpVtbl->Release(subsystem->pInvitationMgr);
subsystem->pInvitationMgr = NULL; subsystem->pInvitationMgr = nullptr;
} }
if (subsystem->pInvitation) if (subsystem->pInvitation)
{ {
subsystem->pInvitation->lpVtbl->Release(subsystem->pInvitation); subsystem->pInvitation->lpVtbl->Release(subsystem->pInvitation);
subsystem->pInvitation = NULL; subsystem->pInvitation = nullptr;
} }
if (subsystem->pAssistanceFile) if (subsystem->pAssistanceFile)
{ {
freerdp_assistance_file_free(subsystem->pAssistanceFile); freerdp_assistance_file_free(subsystem->pAssistanceFile);
subsystem->pAssistanceFile = NULL; subsystem->pAssistanceFile = nullptr;
} }
if (subsystem->hWnd) if (subsystem->hWnd)
{ {
DestroyWindow(subsystem->hWnd); DestroyWindow(subsystem->hWnd);
subsystem->hWnd = NULL; subsystem->hWnd = nullptr;
} }
if (subsystem->shw) if (subsystem->shw)
{ {
win_shadow_rdp_uninit(subsystem); win_shadow_rdp_uninit(subsystem);
subsystem->shw = NULL; subsystem->shw = nullptr;
} }
return 1; return 1;

View File

@@ -76,8 +76,8 @@ static int x11_shadow_pam_conv(int num_msg, const struct pam_message** msg,
struct pam_response** resp, void* appdata_ptr) struct pam_response** resp, void* appdata_ptr)
{ {
int pam_status = PAM_CONV_ERR; int pam_status = PAM_CONV_ERR;
SHADOW_PAM_AUTH_DATA* appdata = NULL; SHADOW_PAM_AUTH_DATA* appdata = nullptr;
struct pam_response* response = NULL; struct pam_response* response = nullptr;
WINPR_ASSERT(num_msg >= 0); WINPR_ASSERT(num_msg >= 0);
appdata = (SHADOW_PAM_AUTH_DATA*)appdata_ptr; appdata = (SHADOW_PAM_AUTH_DATA*)appdata_ptr;
WINPR_ASSERT(appdata); WINPR_ASSERT(appdata);
@@ -128,7 +128,7 @@ out_fail:
memset(response, 0, sizeof(struct pam_response) * (size_t)num_msg); memset(response, 0, sizeof(struct pam_response) * (size_t)num_msg);
free(response); free(response);
*resp = NULL; *resp = nullptr;
return pam_status; return pam_status;
} }
@@ -148,7 +148,7 @@ static BOOL x11_shadow_pam_get_service_name(SHADOW_PAM_AUTH_INFO* info)
{ {
info->service_name = _strdup(hint); info->service_name = _strdup(hint);
return info->service_name != NULL; return info->service_name != nullptr;
} }
} }
WLog_WARN(TAG, "Could not determine PAM service name"); WLog_WARN(TAG, "Could not determine PAM service name");
@@ -172,7 +172,7 @@ static int x11_shadow_pam_authenticate(rdpShadowSubsystem* subsystem, rdpShadowC
info.appdata.password = password; info.appdata.password = password;
info.pamc.conv = &x11_shadow_pam_conv; info.pamc.conv = &x11_shadow_pam_conv;
info.pamc.appdata_ptr = &info.appdata; info.pamc.appdata_ptr = &info.appdata;
pam_status = pam_start(info.service_name, 0, &info.pamc, &info.handle); pam_status = pam_start(info.service_name, nullptr, &info.pamc, &info.handle);
if (pam_status != PAM_SUCCESS) if (pam_status != PAM_SUCCESS)
{ {
@@ -278,8 +278,8 @@ static BOOL x11_shadow_input_mouse_event(rdpShadowSubsystem* subsystem, rdpShado
x11ShadowSubsystem* x11 = (x11ShadowSubsystem*)subsystem; x11ShadowSubsystem* x11 = (x11ShadowSubsystem*)subsystem;
unsigned int button = 0; unsigned int button = 0;
BOOL down = FALSE; BOOL down = FALSE;
rdpShadowServer* server = NULL; rdpShadowServer* server = nullptr;
rdpShadowSurface* surface = NULL; rdpShadowSurface* surface = nullptr;
if (!subsystem || !client) if (!subsystem || !client)
return FALSE; return FALSE;
@@ -417,8 +417,8 @@ static BOOL x11_shadow_input_extended_mouse_event(rdpShadowSubsystem* subsystem,
x11ShadowSubsystem* x11 = (x11ShadowSubsystem*)subsystem; x11ShadowSubsystem* x11 = (x11ShadowSubsystem*)subsystem;
UINT button = 0; UINT button = 0;
BOOL down = FALSE; BOOL down = FALSE;
rdpShadowServer* server = NULL; rdpShadowServer* server = nullptr;
rdpShadowSurface* surface = NULL; rdpShadowSurface* surface = nullptr;
if (!subsystem || !client) if (!subsystem || !client)
return FALSE; return FALSE;
@@ -485,7 +485,7 @@ WINPR_ATTR_NODISCARD
static int x11_shadow_pointer_position_update(x11ShadowSubsystem* subsystem) static int x11_shadow_pointer_position_update(x11ShadowSubsystem* subsystem)
{ {
UINT32 msgId = SHADOW_MSG_OUT_POINTER_POSITION_UPDATE_ID; UINT32 msgId = SHADOW_MSG_OUT_POINTER_POSITION_UPDATE_ID;
rdpShadowServer* server = NULL; rdpShadowServer* server = nullptr;
SHADOW_MSG_OUT_POINTER_POSITION_UPDATE templateMsg = WINPR_C_ARRAY_INIT; SHADOW_MSG_OUT_POINTER_POSITION_UPDATE templateMsg = WINPR_C_ARRAY_INIT;
int count = 0; int count = 0;
@@ -500,7 +500,7 @@ static int x11_shadow_pointer_position_update(x11ShadowSubsystem* subsystem)
for (size_t index = 0; index < ArrayList_Count(server->clients); index++) for (size_t index = 0; index < ArrayList_Count(server->clients); index++)
{ {
SHADOW_MSG_OUT_POINTER_POSITION_UPDATE* msg = NULL; SHADOW_MSG_OUT_POINTER_POSITION_UPDATE* msg = nullptr;
rdpShadowClient* client = (rdpShadowClient*)ArrayList_GetItem(server->clients, index); rdpShadowClient* client = (rdpShadowClient*)ArrayList_GetItem(server->clients, index);
/* Skip the client which send us the latest mouse event */ /* Skip the client which send us the latest mouse event */
@@ -517,7 +517,7 @@ static int x11_shadow_pointer_position_update(x11ShadowSubsystem* subsystem)
memcpy(msg, &templateMsg, sizeof(templateMsg)); memcpy(msg, &templateMsg, sizeof(templateMsg));
if (shadow_client_post_msg(client, NULL, msgId, (SHADOW_MSG_OUT*)msg, NULL)) if (shadow_client_post_msg(client, nullptr, msgId, (SHADOW_MSG_OUT*)msg, nullptr))
count++; count++;
} }
@@ -548,8 +548,8 @@ static int x11_shadow_pointer_alpha_update(x11ShadowSubsystem* subsystem)
} }
msg->common.Free = x11_shadow_message_free; msg->common.Free = x11_shadow_message_free;
const int count = shadow_client_boardcast_msg(subsystem->common.server, NULL, msgId, const int count = shadow_client_boardcast_msg(subsystem->common.server, nullptr, msgId,
(SHADOW_MSG_OUT*)msg, NULL); (SHADOW_MSG_OUT*)msg, nullptr);
if (count < 0) if (count < 0)
return -1; return -1;
return 1; return 1;
@@ -561,16 +561,16 @@ static int x11_shadow_query_cursor(x11ShadowSubsystem* subsystem, BOOL getImage)
int x = 0; int x = 0;
int y = 0; int y = 0;
int n = 0; int n = 0;
rdpShadowServer* server = NULL; rdpShadowServer* server = nullptr;
rdpShadowSurface* surface = NULL; rdpShadowSurface* surface = nullptr;
server = subsystem->common.server; server = subsystem->common.server;
surface = server->surface; surface = server->surface;
if (getImage) if (getImage)
{ {
#ifdef WITH_XFIXES #ifdef WITH_XFIXES
UINT32* pDstPixel = NULL; UINT32* pDstPixel = nullptr;
XFixesCursorImage* ci = NULL; XFixesCursorImage* ci = nullptr;
XLockDisplay(subsystem->display); XLockDisplay(subsystem->display);
ci = XFixesGetCursorImage(subsystem->display); ci = XFixesGetCursorImage(subsystem->display);
XUnlockDisplay(subsystem->display); XUnlockDisplay(subsystem->display);
@@ -904,7 +904,7 @@ static BOOL x11_shadow_surface_update_contents(rdpShadowSurface* surface, UINT32
WINPR_ASSERTING_INT_CAST(uint32_t, y), WINPR_ASSERTING_INT_CAST(uint32_t, width), WINPR_ASSERTING_INT_CAST(uint32_t, y), WINPR_ASSERTING_INT_CAST(uint32_t, width),
WINPR_ASSERTING_INT_CAST(uint32_t, height), (BYTE*)image->data, format, WINPR_ASSERTING_INT_CAST(uint32_t, height), (BYTE*)image->data, format,
WINPR_ASSERTING_INT_CAST(uint32_t, image->bytes_per_line), WINPR_ASSERTING_INT_CAST(uint32_t, image->bytes_per_line),
WINPR_ASSERTING_INT_CAST(UINT32, x), WINPR_ASSERTING_INT_CAST(UINT32, y), NULL, WINPR_ASSERTING_INT_CAST(UINT32, x), WINPR_ASSERTING_INT_CAST(UINT32, y), nullptr,
FREERDP_FLIP_NONE); FREERDP_FLIP_NONE);
LeaveCriticalSection(&surface->lock); LeaveCriticalSection(&surface->lock);
return success; return success;
@@ -936,7 +936,7 @@ static int x11_shadow_screen_grab(x11ShadowSubsystem* subsystem)
LeaveCriticalSection(&surface->lock); LeaveCriticalSection(&surface->lock);
} }
XImage* image = NULL; XImage* image = nullptr;
RECTANGLE_16 invalidRect = WINPR_C_ARRAY_INIT; RECTANGLE_16 invalidRect = WINPR_C_ARRAY_INIT;
int status = -1; int status = -1;
{ {
@@ -952,7 +952,7 @@ static int x11_shadow_screen_grab(x11ShadowSubsystem* subsystem)
goto fail_capture; goto fail_capture;
/* Restore the default error handler */ /* Restore the default error handler */
XSetErrorHandler(NULL); XSetErrorHandler(nullptr);
XSync(subsystem->display, False); XSync(subsystem->display, False);
XUnlockDisplay(subsystem->display); XUnlockDisplay(subsystem->display);
} }
@@ -977,7 +977,7 @@ static int x11_shadow_screen_grab(x11ShadowSubsystem* subsystem)
if (count == 1) if (count == 1)
{ {
rdpShadowClient* client = NULL; rdpShadowClient* client = nullptr;
client = (rdpShadowClient*)ArrayList_GetItem(server->clients, 0); client = (rdpShadowClient*)ArrayList_GetItem(server->clients, 0);
if (client) if (client)
@@ -1032,7 +1032,7 @@ static DWORD WINAPI x11_shadow_subsystem_thread(LPVOID arg)
UINT64 frameTime = 0; UINT64 frameTime = 0;
HANDLE events[32]; HANDLE events[32];
wMessage message; wMessage message;
wMessagePipe* MsgPipe = NULL; wMessagePipe* MsgPipe = nullptr;
MsgPipe = subsystem->common.MsgPipe; MsgPipe = subsystem->common.MsgPipe;
nCount = 0; nCount = 0;
events[nCount++] = subsystem->common.event; events[nCount++] = subsystem->common.event;
@@ -1113,11 +1113,11 @@ static int x11_shadow_subsystem_base_init(x11ShadowSubsystem* subsystem)
if (!XInitThreads()) if (!XInitThreads())
return -1; return -1;
subsystem->display = XOpenDisplay(NULL); subsystem->display = XOpenDisplay(nullptr);
if (!subsystem->display) if (!subsystem->display)
{ {
WLog_ERR(TAG, "failed to open display: %s", XDisplayName(NULL)); WLog_ERR(TAG, "failed to open display: %s", XDisplayName(nullptr));
return -1; return -1;
} }
@@ -1214,7 +1214,7 @@ static int x11_shadow_xdamage_init(x11ShadowSubsystem* subsystem)
return -1; return -1;
#ifdef WITH_XFIXES #ifdef WITH_XFIXES
subsystem->xdamage_region = XFixesCreateRegion(subsystem->display, NULL, 0); subsystem->xdamage_region = XFixesCreateRegion(subsystem->display, nullptr, 0);
if (!subsystem->xdamage_region) if (!subsystem->xdamage_region)
return -1; return -1;
@@ -1247,7 +1247,7 @@ static int x11_shadow_xshm_init(x11ShadowSubsystem* subsystem)
subsystem->fb_shm_info.shmaddr = (char*)-1; subsystem->fb_shm_info.shmaddr = (char*)-1;
subsystem->fb_shm_info.readOnly = False; subsystem->fb_shm_info.readOnly = False;
subsystem->fb_image = subsystem->fb_image =
XShmCreateImage(subsystem->display, subsystem->visual, subsystem->depth, ZPixmap, NULL, XShmCreateImage(subsystem->display, subsystem->visual, subsystem->depth, ZPixmap, nullptr,
&(subsystem->fb_shm_info), subsystem->width, subsystem->height); &(subsystem->fb_shm_info), subsystem->width, subsystem->height);
if (!subsystem->fb_image) if (!subsystem->fb_image)
@@ -1268,7 +1268,7 @@ static int x11_shadow_xshm_init(x11ShadowSubsystem* subsystem)
return -1; return -1;
} }
subsystem->fb_shm_info.shmaddr = shmat(subsystem->fb_shm_info.shmid, 0, 0); subsystem->fb_shm_info.shmaddr = shmat(subsystem->fb_shm_info.shmid, nullptr, 0);
subsystem->fb_image->data = subsystem->fb_shm_info.shmaddr; subsystem->fb_image->data = subsystem->fb_shm_info.shmaddr;
if (subsystem->fb_shm_info.shmaddr == ((char*)-1)) if (subsystem->fb_shm_info.shmaddr == ((char*)-1))
@@ -1281,7 +1281,7 @@ static int x11_shadow_xshm_init(x11ShadowSubsystem* subsystem)
return -1; return -1;
XSync(subsystem->display, False); XSync(subsystem->display, False);
shmctl(subsystem->fb_shm_info.shmid, IPC_RMID, 0); shmctl(subsystem->fb_shm_info.shmid, IPC_RMID, nullptr);
subsystem->fb_pixmap = XShmCreatePixmap( subsystem->fb_pixmap = XShmCreatePixmap(
subsystem->display, subsystem->root_window, subsystem->fb_image->data, subsystem->display, subsystem->root_window, subsystem->fb_image->data,
&(subsystem->fb_shm_info), WINPR_ASSERTING_INT_CAST(uint32_t, subsystem->fb_image->width), &(subsystem->fb_shm_info), WINPR_ASSERTING_INT_CAST(uint32_t, subsystem->fb_image->width),
@@ -1305,7 +1305,7 @@ static int x11_shadow_xshm_init(x11ShadowSubsystem* subsystem)
UINT32 x11_shadow_enum_monitors(MONITOR_DEF* monitors, UINT32 maxMonitors) UINT32 x11_shadow_enum_monitors(MONITOR_DEF* monitors, UINT32 maxMonitors)
{ {
Display* display = NULL; Display* display = nullptr;
int displayWidth = 0; int displayWidth = 0;
int displayHeight = 0; int displayHeight = 0;
int numMonitors = 0; int numMonitors = 0;
@@ -1317,11 +1317,11 @@ UINT32 x11_shadow_enum_monitors(MONITOR_DEF* monitors, UINT32 maxMonitors)
setenv("DISPLAY", ":0", 1); setenv("DISPLAY", ":0", 1);
} }
display = XOpenDisplay(NULL); display = XOpenDisplay(nullptr);
if (!display) if (!display)
{ {
WLog_ERR(TAG, "failed to open display: %s", XDisplayName(NULL)); WLog_ERR(TAG, "failed to open display: %s", XDisplayName(nullptr));
return 0; return 0;
} }
@@ -1335,7 +1335,7 @@ UINT32 x11_shadow_enum_monitors(MONITOR_DEF* monitors, UINT32 maxMonitors)
#endif #endif
int xinerama_event = 0; int xinerama_event = 0;
int xinerama_error = 0; int xinerama_error = 0;
XineramaScreenInfo* screens = NULL; XineramaScreenInfo* screens = nullptr;
const Bool xinerama = XineramaQueryExtension(display, &xinerama_event, &xinerama_error); const Bool xinerama = XineramaQueryExtension(display, &xinerama_event, &xinerama_error);
const Bool damage = const Bool damage =
@@ -1396,7 +1396,7 @@ static int x11_shadow_subsystem_init(rdpShadowSubsystem* sub)
int vi_count = 0; int vi_count = 0;
int nextensions = 0; int nextensions = 0;
XVisualInfo xtemplate = WINPR_C_ARRAY_INIT; XVisualInfo xtemplate = WINPR_C_ARRAY_INIT;
XPixmapFormatValues* pf = NULL; XPixmapFormatValues* pf = nullptr;
x11ShadowSubsystem* subsystem = (x11ShadowSubsystem*)sub; x11ShadowSubsystem* subsystem = (x11ShadowSubsystem*)sub;
@@ -1524,7 +1524,7 @@ static int x11_shadow_subsystem_init(rdpShadowSubsystem* sub)
} }
if (!(subsystem->common.event = if (!(subsystem->common.event =
CreateFileDescriptorEvent(NULL, FALSE, FALSE, subsystem->xfds, WINPR_FD_READ))) CreateFileDescriptorEvent(nullptr, FALSE, FALSE, subsystem->xfds, WINPR_FD_READ)))
return -1; return -1;
{ {
@@ -1556,19 +1556,19 @@ static int x11_shadow_subsystem_uninit(rdpShadowSubsystem* sub)
if (subsystem->display) if (subsystem->display)
{ {
XCloseDisplay(subsystem->display); XCloseDisplay(subsystem->display);
subsystem->display = NULL; subsystem->display = nullptr;
} }
if (subsystem->common.event) if (subsystem->common.event)
{ {
(void)CloseHandle(subsystem->common.event); (void)CloseHandle(subsystem->common.event);
subsystem->common.event = NULL; subsystem->common.event = nullptr;
} }
if (subsystem->cursorPixels) if (subsystem->cursorPixels)
{ {
winpr_aligned_free(subsystem->cursorPixels); winpr_aligned_free(subsystem->cursorPixels);
subsystem->cursorPixels = NULL; subsystem->cursorPixels = nullptr;
} }
return 1; return 1;
@@ -1583,7 +1583,7 @@ static int x11_shadow_subsystem_start(rdpShadowSubsystem* sub)
return -1; return -1;
if (!(subsystem->thread = if (!(subsystem->thread =
CreateThread(NULL, 0, x11_shadow_subsystem_thread, (void*)subsystem, 0, NULL))) CreateThread(nullptr, 0, x11_shadow_subsystem_thread, (void*)subsystem, 0, nullptr)))
{ {
WLog_ERR(TAG, "Failed to create thread"); WLog_ERR(TAG, "Failed to create thread");
return -1; return -1;
@@ -1606,7 +1606,7 @@ static int x11_shadow_subsystem_stop(rdpShadowSubsystem* sub)
(void)WaitForSingleObject(subsystem->thread, INFINITE); (void)WaitForSingleObject(subsystem->thread, INFINITE);
(void)CloseHandle(subsystem->thread); (void)CloseHandle(subsystem->thread);
subsystem->thread = NULL; subsystem->thread = nullptr;
} }
return 1; return 1;
@@ -1618,7 +1618,7 @@ static rdpShadowSubsystem* x11_shadow_subsystem_new(void)
x11ShadowSubsystem* subsystem = (x11ShadowSubsystem*)calloc(1, sizeof(x11ShadowSubsystem)); x11ShadowSubsystem* subsystem = (x11ShadowSubsystem*)calloc(1, sizeof(x11ShadowSubsystem));
if (!subsystem) if (!subsystem)
return NULL; return nullptr;
#ifdef WITH_PAM #ifdef WITH_PAM
subsystem->common.Authenticate = x11_shadow_pam_authenticate; subsystem->common.Authenticate = x11_shadow_pam_authenticate;

View File

@@ -37,84 +37,86 @@ int main(int argc, char** argv)
int status = 0; int status = 0;
DWORD dwExitCode = 0; DWORD dwExitCode = 0;
COMMAND_LINE_ARGUMENT_A shadow_args[] = { COMMAND_LINE_ARGUMENT_A shadow_args[] = {
{ "log-filters", COMMAND_LINE_VALUE_REQUIRED, "<tag>:<level>[,<tag>:<level>[,...]]", NULL, { "log-filters", COMMAND_LINE_VALUE_REQUIRED, "<tag>:<level>[,<tag>:<level>[,...]]",
NULL, -1, NULL, "Set logger filters, see wLog(7) for details" }, nullptr, nullptr, -1, nullptr, "Set logger filters, see wLog(7) for details" },
{ "log-level", COMMAND_LINE_VALUE_REQUIRED, "[OFF|FATAL|ERROR|WARN|INFO|DEBUG|TRACE]", NULL, { "log-level", COMMAND_LINE_VALUE_REQUIRED, "[OFF|FATAL|ERROR|WARN|INFO|DEBUG|TRACE]",
NULL, -1, NULL, "Set the default log level, see wLog(7) for details" }, nullptr, nullptr, -1, nullptr, "Set the default log level, see wLog(7) for details" },
{ "port", COMMAND_LINE_VALUE_REQUIRED, "<number>", NULL, NULL, -1, NULL, "Server port" }, { "port", COMMAND_LINE_VALUE_REQUIRED, "<number>", nullptr, nullptr, -1, nullptr,
{ "ipc-socket", COMMAND_LINE_VALUE_REQUIRED, "<ipc-socket>", NULL, NULL, -1, NULL, "Server port" },
{ "ipc-socket", COMMAND_LINE_VALUE_REQUIRED, "<ipc-socket>", nullptr, nullptr, -1, nullptr,
"Server IPC socket" }, "Server IPC socket" },
{ "bind-address", COMMAND_LINE_VALUE_REQUIRED, "<bind-address>[,<another address>, ...]", { "bind-address", COMMAND_LINE_VALUE_REQUIRED, "<bind-address>[,<another address>, ...]",
NULL, NULL, -1, NULL, nullptr, nullptr, -1, nullptr,
"An address to bind to. Use '[<ipv6>]' for IPv6 addresses, e.g. '[::1]' for " "An address to bind to. Use '[<ipv6>]' for IPv6 addresses, e.g. '[::1]' for "
"localhost" }, "localhost" },
{ "server-side-cursor", COMMAND_LINE_VALUE_BOOL, NULL, NULL, NULL, -1, NULL, { "server-side-cursor", COMMAND_LINE_VALUE_BOOL, nullptr, nullptr, nullptr, -1, nullptr,
"hide mouse cursor in RDP client." }, "hide mouse cursor in RDP client." },
{ "monitors", COMMAND_LINE_VALUE_OPTIONAL, "<0,1,2...>", NULL, NULL, -1, NULL, { "monitors", COMMAND_LINE_VALUE_OPTIONAL, "<0,1,2...>", nullptr, nullptr, -1, nullptr,
"Select or list monitors" }, "Select or list monitors" },
{ "max-connections", COMMAND_LINE_VALUE_REQUIRED, "<number>", 0, NULL, -1, NULL, { "max-connections", COMMAND_LINE_VALUE_REQUIRED, "<number>", nullptr, nullptr, -1, nullptr,
"maximum connections allowed to server, 0 to deactivate" }, "maximum connections allowed to server, 0 to deactivate" },
{ "mouse-relative", COMMAND_LINE_VALUE_BOOL, NULL, NULL, NULL, -1, NULL, { "mouse-relative", COMMAND_LINE_VALUE_BOOL, nullptr, nullptr, nullptr, -1, nullptr,
"enable support for relative mouse events" }, "enable support for relative mouse events" },
{ "rect", COMMAND_LINE_VALUE_REQUIRED, "<x,y,w,h>", NULL, NULL, -1, NULL, { "rect", COMMAND_LINE_VALUE_REQUIRED, "<x,y,w,h>", nullptr, nullptr, -1, nullptr,
"Select rectangle within monitor to share" }, "Select rectangle within monitor to share" },
{ "auth", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, { "auth", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"Clients must authenticate" }, "Clients must authenticate" },
{ "remote-guard", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, { "remote-guard", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueFalse, nullptr, -1, nullptr,
"Remote credential guard" }, "Remote credential guard" },
{ "restricted-admin", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, { "restricted-admin", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"Restricted Admin" }, "Restricted Admin" },
{ "vmconnect", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, { "vmconnect", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueFalse,
NULL, -1, NULL, "Hyper-V console server (bind on vsock://1)" }, nullptr, -1, nullptr, "Hyper-V console server (bind on vsock://1)" },
{ "may-view", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, { "may-view", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"Clients may view without prompt" }, "Clients may view without prompt" },
{ "may-interact", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, { "may-interact", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"Clients may interact without prompt" }, "Clients may interact without prompt" },
{ "sec", COMMAND_LINE_VALUE_REQUIRED, "<rdp|tls|nla|ext>", NULL, NULL, -1, NULL, { "sec", COMMAND_LINE_VALUE_REQUIRED, "<rdp|tls|nla|ext>", nullptr, nullptr, -1, nullptr,
"force specific protocol security" }, "force specific protocol security" },
{ "sec-rdp", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, { "sec-rdp", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"rdp protocol security" }, "rdp protocol security" },
{ "sec-tls", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, { "sec-tls", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"tls protocol security" }, "tls protocol security" },
{ "sec-nla", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, { "sec-nla", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"nla protocol security" }, "nla protocol security" },
{ "sec-ext", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, { "sec-ext", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueFalse, nullptr, -1, nullptr,
"nla extended protocol security" }, "nla extended protocol security" },
{ "sam-file", COMMAND_LINE_VALUE_REQUIRED, "<file>", NULL, NULL, -1, NULL, { "sam-file", COMMAND_LINE_VALUE_REQUIRED, "<file>", nullptr, nullptr, -1, nullptr,
"NTLM SAM file for NLA authentication" }, "NTLM SAM file for NLA authentication" },
{ "keytab", COMMAND_LINE_VALUE_REQUIRED, "<file>", NULL, NULL, -1, NULL, { "keytab", COMMAND_LINE_VALUE_REQUIRED, "<file>", nullptr, nullptr, -1, nullptr,
"Kerberos keytab file for NLA authentication" }, "Kerberos keytab file for NLA authentication" },
{ "ccache", COMMAND_LINE_VALUE_REQUIRED, "<file>", NULL, NULL, -1, NULL, { "ccache", COMMAND_LINE_VALUE_REQUIRED, "<file>", nullptr, nullptr, -1, nullptr,
"Kerberos host ccache file for NLA authentication" }, "Kerberos host ccache file for NLA authentication" },
{ "tls-secrets-file", COMMAND_LINE_VALUE_REQUIRED, "<file>", NULL, NULL, -1, NULL, { "tls-secrets-file", COMMAND_LINE_VALUE_REQUIRED, "<file>", nullptr, nullptr, -1, nullptr,
"file where tls secrets shall be stored" }, "file where tls secrets shall be stored" },
{ "nsc", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "Allow NSC codec" }, { "nsc", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
{ "rfx", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "Allow NSC codec" },
{ "rfx", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"Allow RFX surface bits" }, "Allow RFX surface bits" },
{ "gfx", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, { "gfx", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"Allow GFX pipeline" }, "Allow GFX pipeline" },
{ "gfx-progressive", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, { "gfx-progressive", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"Allow GFX progressive codec" }, "Allow GFX progressive codec" },
{ "gfx-rfx", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, { "gfx-rfx", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"Allow GFX RFX codec" }, "Allow GFX RFX codec" },
{ "gfx-planar", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, { "gfx-planar", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"Allow GFX planar codec" }, "Allow GFX planar codec" },
{ "gfx-avc420", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, { "gfx-avc420", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"Allow GFX AVC420 codec" }, "Allow GFX AVC420 codec" },
{ "gfx-avc444", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, { "gfx-avc444", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"Allow GFX AVC444 codec" }, "Allow GFX AVC444 codec" },
{ "bitmap-compat", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, { "bitmap-compat", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueFalse, nullptr, -1, nullptr,
"Limit BitmapUpdate to 1 rectangle (fixes broken windows 11 24H2 clients)" }, "Limit BitmapUpdate to 1 rectangle (fixes broken windows 11 24H2 clients)" },
{ "version", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_VERSION, NULL, NULL, NULL, -1, { "version", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_VERSION, nullptr, nullptr,
NULL, "Print version" }, nullptr, -1, nullptr, "Print version" },
{ "buildconfig", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_BUILDCONFIG, NULL, NULL, NULL, { "buildconfig", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_BUILDCONFIG, nullptr, nullptr,
-1, NULL, "Print the build configuration" }, nullptr, -1, nullptr, "Print the build configuration" },
{ "help", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, NULL, NULL, NULL, -1, "?", { "help", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, nullptr, nullptr, nullptr, -1,
"Print help" }, "?", "Print help" },
{ NULL, 0, NULL, NULL, NULL, -1, NULL, NULL } { nullptr, 0, nullptr, nullptr, nullptr, -1, nullptr, nullptr }
}; };
shadow_subsystem_set_entry_builtin(NULL); shadow_subsystem_set_entry_builtin(nullptr);
rdpShadowServer* server = shadow_server_new(); rdpShadowServer* server = shadow_server_new();

View File

@@ -34,8 +34,8 @@
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static UINT AudinServerData(audin_server_context* audin, const SNDIN_DATA* data) static UINT AudinServerData(audin_server_context* audin, const SNDIN_DATA* data)
{ {
rdpShadowClient* client = NULL; rdpShadowClient* client = nullptr;
rdpShadowSubsystem* subsystem = NULL; rdpShadowSubsystem* subsystem = nullptr;
WINPR_ASSERT(audin); WINPR_ASSERT(audin);
WINPR_ASSERT(data); WINPR_ASSERT(data);
@@ -83,14 +83,14 @@ BOOL shadow_client_audin_init(rdpShadowClient* client)
} }
else else
{ {
if (!audin_server_set_formats(client->audin, -1, NULL)) if (!audin_server_set_formats(client->audin, -1, nullptr))
goto fail; goto fail;
} }
return TRUE; return TRUE;
fail: fail:
audin_server_context_free(audin); audin_server_context_free(audin);
client->audin = NULL; client->audin = nullptr;
#endif #endif
return FALSE; return FALSE;
} }
@@ -101,6 +101,6 @@ void shadow_client_audin_uninit(rdpShadowClient* client)
#if defined(CHANNEL_AUDIN_SERVER) #if defined(CHANNEL_AUDIN_SERVER)
audin_server_context_free(client->audin); audin_server_context_free(client->audin);
client->audin = NULL; client->audin = nullptr;
#endif #endif
} }

View File

@@ -97,8 +97,8 @@ static BOOL color_equal(UINT32 colorA, UINT32 formatA, UINT32 colorB, UINT32 for
BYTE bg = 0; BYTE bg = 0;
BYTE bb = 0; BYTE bb = 0;
BYTE ba = 0; BYTE ba = 0;
FreeRDPSplitColor(colorA, formatA, &ar, &ag, &ab, &aa, NULL); FreeRDPSplitColor(colorA, formatA, &ar, &ag, &ab, &aa, nullptr);
FreeRDPSplitColor(colorB, formatB, &br, &bg, &bb, &ba, NULL); FreeRDPSplitColor(colorB, formatB, &br, &bg, &bb, &ba, nullptr);
if (ar != br) if (ar != br)
return FALSE; return FALSE;
@@ -138,8 +138,8 @@ static BOOL color_equal_no_alpha(UINT32 colorA, UINT32 formatA, UINT32 colorB, U
BYTE br = 0; BYTE br = 0;
BYTE bg = 0; BYTE bg = 0;
BYTE bb = 0; BYTE bb = 0;
FreeRDPSplitColor(colorA, formatA, &ar, &ag, &ab, NULL, NULL); FreeRDPSplitColor(colorA, formatA, &ar, &ag, &ab, nullptr, nullptr);
FreeRDPSplitColor(colorB, formatB, &br, &bg, &bb, NULL, NULL); FreeRDPSplitColor(colorB, formatB, &br, &bg, &bb, nullptr, nullptr);
if (ar != br) if (ar != br)
return FALSE; return FALSE;
@@ -323,7 +323,7 @@ rdpShadowCapture* shadow_capture_new(rdpShadowServer* server)
rdpShadowCapture* capture = (rdpShadowCapture*)calloc(1, sizeof(rdpShadowCapture)); rdpShadowCapture* capture = (rdpShadowCapture*)calloc(1, sizeof(rdpShadowCapture));
if (!capture) if (!capture)
return NULL; return nullptr;
capture->server = server; capture->server = server;
@@ -333,7 +333,7 @@ rdpShadowCapture* shadow_capture_new(rdpShadowServer* server)
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
shadow_capture_free(capture); shadow_capture_free(capture);
WINPR_PRAGMA_DIAG_POP WINPR_PRAGMA_DIAG_POP
return NULL; return nullptr;
} }
return capture; return capture;

View File

@@ -115,8 +115,8 @@ static inline BOOL shadow_client_rdpgfx_new_surface(rdpShadowClient* client)
UINT error = CHANNEL_RC_OK; UINT error = CHANNEL_RC_OK;
RDPGFX_CREATE_SURFACE_PDU createSurface; RDPGFX_CREATE_SURFACE_PDU createSurface;
RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU surfaceToOutput; RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU surfaceToOutput;
RdpgfxServerContext* context = NULL; RdpgfxServerContext* context = nullptr;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
WINPR_ASSERT(client); WINPR_ASSERT(client);
context = client->rdpgfx; context = client->rdpgfx;
@@ -158,7 +158,7 @@ static inline BOOL shadow_client_rdpgfx_release_surface(rdpShadowClient* client)
{ {
UINT error = CHANNEL_RC_OK; UINT error = CHANNEL_RC_OK;
RDPGFX_DELETE_SURFACE_PDU pdu; RDPGFX_DELETE_SURFACE_PDU pdu;
RdpgfxServerContext* context = NULL; RdpgfxServerContext* context = nullptr;
WINPR_ASSERT(client); WINPR_ASSERT(client);
@@ -182,8 +182,8 @@ static inline BOOL shadow_client_rdpgfx_reset_graphic(rdpShadowClient* client)
{ {
UINT error = CHANNEL_RC_OK; UINT error = CHANNEL_RC_OK;
RDPGFX_RESET_GRAPHICS_PDU pdu = WINPR_C_ARRAY_INIT; RDPGFX_RESET_GRAPHICS_PDU pdu = WINPR_C_ARRAY_INIT;
RdpgfxServerContext* context = NULL; RdpgfxServerContext* context = nullptr;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
WINPR_ASSERT(client); WINPR_ASSERT(client);
WINPR_ASSERT(client->rdpgfx); WINPR_ASSERT(client->rdpgfx);
@@ -218,14 +218,14 @@ static inline void shadow_client_free_queued_message(void* obj)
if (message->Free) if (message->Free)
{ {
message->Free(message); message->Free(message);
message->Free = NULL; message->Free = nullptr;
} }
} }
static void shadow_client_context_free(freerdp_peer* peer, rdpContext* context) static void shadow_client_context_free(freerdp_peer* peer, rdpContext* context)
{ {
rdpShadowClient* client = (rdpShadowClient*)context; rdpShadowClient* client = (rdpShadowClient*)context;
rdpShadowServer* server = NULL; rdpShadowServer* server = nullptr;
WINPR_UNUSED(peer); WINPR_UNUSED(peer);
if (!client) if (!client)
@@ -243,9 +243,9 @@ static void shadow_client_context_free(freerdp_peer* peer, rdpContext* context)
region16_uninit(&(client->invalidRegion)); region16_uninit(&(client->invalidRegion));
DeleteCriticalSection(&(client->lock)); DeleteCriticalSection(&(client->lock));
client->MsgQueue = NULL; client->MsgQueue = nullptr;
client->encoder = NULL; client->encoder = nullptr;
client->vcm = NULL; client->vcm = nullptr;
} }
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
@@ -254,10 +254,10 @@ static BOOL shadow_client_context_new(freerdp_peer* peer, rdpContext* context)
BOOL NSCodec = 0; BOOL NSCodec = 0;
const char bind_address[] = "bind-address,"; const char bind_address[] = "bind-address,";
rdpShadowClient* client = (rdpShadowClient*)context; rdpShadowClient* client = (rdpShadowClient*)context;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
const rdpSettings* srvSettings = NULL; const rdpSettings* srvSettings = nullptr;
rdpShadowServer* server = NULL; rdpShadowServer* server = nullptr;
const wObject cb = { NULL, NULL, NULL, shadow_client_free_queued_message, NULL }; const wObject cb = { nullptr, nullptr, nullptr, shadow_client_free_queued_message, nullptr };
WINPR_ASSERT(client); WINPR_ASSERT(client);
WINPR_ASSERT(peer); WINPR_ASSERT(peer);
@@ -396,8 +396,8 @@ static inline BOOL shadow_client_recalc_desktop_size(rdpShadowClient* client)
{ {
INT32 width = 0; INT32 width = 0;
INT32 height = 0; INT32 height = 0;
rdpShadowServer* server = NULL; rdpShadowServer* server = nullptr;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
RECTANGLE_16 viewport = WINPR_C_ARRAY_INIT; RECTANGLE_16 viewport = WINPR_C_ARRAY_INIT;
WINPR_ASSERT(client); WINPR_ASSERT(client);
@@ -433,8 +433,8 @@ static inline BOOL shadow_client_recalc_desktop_size(rdpShadowClient* client)
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL shadow_client_capabilities(freerdp_peer* peer) static BOOL shadow_client_capabilities(freerdp_peer* peer)
{ {
rdpShadowSubsystem* subsystem = NULL; rdpShadowSubsystem* subsystem = nullptr;
rdpShadowClient* client = NULL; rdpShadowClient* client = nullptr;
BOOL ret = TRUE; BOOL ret = TRUE;
WINPR_ASSERT(peer); WINPR_ASSERT(peer);
@@ -464,9 +464,9 @@ WINPR_ATTR_NODISCARD
static BOOL shadow_send_desktop_resize(rdpShadowClient* client) static BOOL shadow_send_desktop_resize(rdpShadowClient* client)
{ {
BOOL rc = 0; BOOL rc = 0;
rdpUpdate* update = NULL; rdpUpdate* update = nullptr;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
const freerdp_peer* peer = NULL; const freerdp_peer* peer = nullptr;
WINPR_ASSERT(client); WINPR_ASSERT(client);
@@ -518,10 +518,10 @@ WINPR_ATTR_NODISCARD
static BOOL shadow_client_post_connect(freerdp_peer* peer) static BOOL shadow_client_post_connect(freerdp_peer* peer)
{ {
int authStatus = 0; int authStatus = 0;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
rdpShadowClient* client = NULL; rdpShadowClient* client = nullptr;
rdpShadowServer* server = NULL; rdpShadowServer* server = nullptr;
rdpShadowSubsystem* subsystem = NULL; rdpShadowSubsystem* subsystem = nullptr;
WINPR_ASSERT(peer); WINPR_ASSERT(peer);
@@ -562,7 +562,7 @@ static BOOL shadow_client_post_connect(freerdp_peer* peer)
if (shadow_client_channels_post_connect(client) != CHANNEL_RC_OK) if (shadow_client_channels_post_connect(client) != CHANNEL_RC_OK)
return FALSE; return FALSE;
shadow_client_mark_invalid(client, 0, NULL); shadow_client_mark_invalid(client, 0, nullptr);
authStatus = -1; authStatus = -1;
const char* Username = freerdp_settings_get_string(settings, FreeRDP_Username); const char* Username = freerdp_settings_get_string(settings, FreeRDP_Username);
@@ -635,7 +635,7 @@ WINPR_ATTR_NODISCARD
static BOOL shadow_client_refresh_request(rdpShadowClient* client) static BOOL shadow_client_refresh_request(rdpShadowClient* client)
{ {
wMessage message = WINPR_C_ARRAY_INIT; wMessage message = WINPR_C_ARRAY_INIT;
wMessagePipe* MsgPipe = NULL; wMessagePipe* MsgPipe = nullptr;
WINPR_ASSERT(client); WINPR_ASSERT(client);
WINPR_ASSERT(client->subsystem); WINPR_ASSERT(client->subsystem);
@@ -644,10 +644,10 @@ static BOOL shadow_client_refresh_request(rdpShadowClient* client)
WINPR_ASSERT(MsgPipe); WINPR_ASSERT(MsgPipe);
message.id = SHADOW_MSG_IN_REFRESH_REQUEST_ID; message.id = SHADOW_MSG_IN_REFRESH_REQUEST_ID;
message.wParam = NULL; message.wParam = nullptr;
message.lParam = NULL; message.lParam = nullptr;
message.context = (void*)client; message.context = (void*)client;
message.Free = NULL; message.Free = nullptr;
return MessageQueue_Dispatch(MsgPipe->In, &message); return MessageQueue_Dispatch(MsgPipe->In, &message);
} }
@@ -655,7 +655,7 @@ WINPR_ATTR_NODISCARD
static BOOL shadow_client_refresh_rect(rdpContext* context, BYTE count, const RECTANGLE_16* areas) static BOOL shadow_client_refresh_rect(rdpContext* context, BYTE count, const RECTANGLE_16* areas)
{ {
rdpShadowClient* client = (rdpShadowClient*)context; rdpShadowClient* client = (rdpShadowClient*)context;
RECTANGLE_16* rects = NULL; RECTANGLE_16* rects = nullptr;
/* It is invalid if we have area count but no actual area */ /* It is invalid if we have area count but no actual area */
if (count && !areas) if (count && !areas)
@@ -676,7 +676,7 @@ static BOOL shadow_client_refresh_rect(rdpContext* context, BYTE count, const RE
} }
else else
{ {
shadow_client_mark_invalid(client, 0, NULL); shadow_client_mark_invalid(client, 0, nullptr);
} }
return shadow_client_refresh_request(client); return shadow_client_refresh_request(client);
@@ -701,7 +701,7 @@ static BOOL shadow_client_suppress_output(rdpContext* context, BYTE allow, const
} }
else else
{ {
shadow_client_mark_invalid(client, 0, NULL); shadow_client_mark_invalid(client, 0, nullptr);
} }
} }
@@ -731,7 +731,7 @@ static BOOL shadow_client_activate(freerdp_peer* peer)
} }
/* Update full screen in next update */ /* Update full screen in next update */
return shadow_client_refresh_rect(&client->context, 0, NULL); return shadow_client_refresh_rect(&client->context, 0, nullptr);
} }
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
@@ -739,10 +739,10 @@ static BOOL shadow_client_logon(freerdp_peer* peer, const SEC_WINNT_AUTH_IDENTIT
BOOL automatic) BOOL automatic)
{ {
BOOL rc = FALSE; BOOL rc = FALSE;
char* user = NULL; char* user = nullptr;
char* domain = NULL; char* domain = nullptr;
char* password = NULL; char* password = nullptr;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
WINPR_UNUSED(automatic); WINPR_UNUSED(automatic);
@@ -757,13 +757,14 @@ static BOOL shadow_client_logon(freerdp_peer* peer, const SEC_WINNT_AUTH_IDENTIT
if (identity->Flags & SEC_WINNT_AUTH_IDENTITY_UNICODE) if (identity->Flags & SEC_WINNT_AUTH_IDENTITY_UNICODE)
{ {
if (identity->User) if (identity->User)
user = ConvertWCharNToUtf8Alloc(identity->User, identity->UserLength, NULL); user = ConvertWCharNToUtf8Alloc(identity->User, identity->UserLength, nullptr);
if (identity->Domain) if (identity->Domain)
domain = ConvertWCharNToUtf8Alloc(identity->Domain, identity->DomainLength, NULL); domain = ConvertWCharNToUtf8Alloc(identity->Domain, identity->DomainLength, nullptr);
if (identity->Password) if (identity->Password)
password = ConvertWCharNToUtf8Alloc(identity->Password, identity->PasswordLength, NULL); password =
ConvertWCharNToUtf8Alloc(identity->Password, identity->PasswordLength, nullptr);
} }
else else
{ {
@@ -839,7 +840,7 @@ static UINT
shadow_client_rdpgfx_frame_acknowledge(RdpgfxServerContext* context, shadow_client_rdpgfx_frame_acknowledge(RdpgfxServerContext* context,
const RDPGFX_FRAME_ACKNOWLEDGE_PDU* frameAcknowledge) const RDPGFX_FRAME_ACKNOWLEDGE_PDU* frameAcknowledge)
{ {
rdpShadowClient* client = NULL; rdpShadowClient* client = nullptr;
WINPR_ASSERT(context); WINPR_ASSERT(context);
WINPR_ASSERT(frameAcknowledge); WINPR_ASSERT(frameAcknowledge);
@@ -894,8 +895,8 @@ static BOOL shadow_client_caps_test_version(RdpgfxServerContext* context, rdpSha
BOOL h264, const RDPGFX_CAPSET* capsSets, BOOL h264, const RDPGFX_CAPSET* capsSets,
UINT32 capsSetCount, UINT32 capsVersion, UINT* rc) UINT32 capsSetCount, UINT32 capsVersion, UINT* rc)
{ {
const rdpSettings* srvSettings = NULL; const rdpSettings* srvSettings = nullptr;
rdpSettings* clientSettings = NULL; rdpSettings* clientSettings = nullptr;
WINPR_ASSERT(context); WINPR_ASSERT(context);
WINPR_ASSERT(client); WINPR_ASSERT(client);
@@ -985,8 +986,8 @@ static UINT shadow_client_rdpgfx_caps_advertise(RdpgfxServerContext* context,
const RDPGFX_CAPS_ADVERTISE_PDU* capsAdvertise) const RDPGFX_CAPS_ADVERTISE_PDU* capsAdvertise)
{ {
UINT rc = ERROR_INTERNAL_ERROR; UINT rc = ERROR_INTERNAL_ERROR;
const rdpSettings* srvSettings = NULL; const rdpSettings* srvSettings = nullptr;
rdpSettings* clientSettings = NULL; rdpSettings* clientSettings = nullptr;
BOOL h264 = FALSE; BOOL h264 = FALSE;
UINT32 flags = 0; UINT32 flags = 0;
@@ -1017,7 +1018,7 @@ static UINT shadow_client_rdpgfx_caps_advertise(RdpgfxServerContext* context,
#endif #endif
/* Request full screen update for new gfx channel */ /* Request full screen update for new gfx channel */
if (!shadow_client_refresh_rect(&client->context, 0, NULL)) if (!shadow_client_refresh_rect(&client->context, 0, nullptr))
return rc; return rc;
if (shadow_client_caps_test_version(context, client, h264, capsAdvertise->capsSets, if (shadow_client_caps_test_version(context, client, h264, capsAdvertise->capsSets,
@@ -1166,8 +1167,8 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE*
UINT32 id = 0; UINT32 id = 0;
UINT error = CHANNEL_RC_OK; UINT error = CHANNEL_RC_OK;
const rdpContext* context = (const rdpContext*)client; const rdpContext* context = (const rdpContext*)client;
const rdpSettings* settings = NULL; const rdpSettings* settings = nullptr;
rdpShadowEncoder* encoder = NULL; rdpShadowEncoder* encoder = nullptr;
RDPGFX_SURFACE_COMMAND cmd = WINPR_C_ARRAY_INIT; RDPGFX_SURFACE_COMMAND cmd = WINPR_C_ARRAY_INIT;
RDPGFX_START_FRAME_PDU cmdstart = WINPR_C_ARRAY_INIT; RDPGFX_START_FRAME_PDU cmdstart = WINPR_C_ARRAY_INIT;
RDPGFX_END_FRAME_PDU cmdend = WINPR_C_ARRAY_INIT; RDPGFX_END_FRAME_PDU cmdend = WINPR_C_ARRAY_INIT;
@@ -1311,7 +1312,7 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE*
if (freerdp_settings_get_bool(settings, FreeRDP_RemoteFxCodec) && (id != 0)) if (freerdp_settings_get_bool(settings, FreeRDP_RemoteFxCodec) && (id != 0))
{ {
BOOL rc = 0; BOOL rc = 0;
wStream* s = NULL; wStream* s = nullptr;
RFX_RECT rect; RFX_RECT rect;
if (shadow_encoder_prepare(encoder, FREERDP_CODEC_REMOTEFX) < 0) if (shadow_encoder_prepare(encoder, FREERDP_CODEC_REMOTEFX) < 0)
@@ -1320,7 +1321,7 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE*
return FALSE; return FALSE;
} }
s = Stream_New(NULL, 1024); s = Stream_New(nullptr, 1024);
WINPR_ASSERT(s); WINPR_ASSERT(s);
WINPR_ASSERT(cmd.left <= UINT16_MAX); WINPR_ASSERT(cmd.left <= UINT16_MAX);
@@ -1431,7 +1432,7 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE*
freerdp_planar_topdown_image(encoder->planar, TRUE); freerdp_planar_topdown_image(encoder->planar, TRUE);
cmd.data = freerdp_bitmap_compress_planar(encoder->planar, src, SrcFormat, w, h, nSrcStep, cmd.data = freerdp_bitmap_compress_planar(encoder->planar, src, SrcFormat, w, h, nSrcStep,
NULL, &cmd.length); nullptr, &cmd.length);
WINPR_ASSERT(cmd.data || (cmd.length == 0)); WINPR_ASSERT(cmd.data || (cmd.length == 0));
cmd.codecId = RDPGFX_CODECID_PLANAR; cmd.codecId = RDPGFX_CODECID_PLANAR;
@@ -1456,7 +1457,7 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE*
return FALSE; return FALSE;
BOOL rc = freerdp_image_copy_no_overlap(data, PIXEL_FORMAT_BGRA32, 0, 0, 0, w, h, pSrcData, BOOL rc = freerdp_image_copy_no_overlap(data, PIXEL_FORMAT_BGRA32, 0, 0, 0, w, h, pSrcData,
SrcFormat, nSrcStep, cmd.left, cmd.top, NULL, 0); SrcFormat, nSrcStep, cmd.left, cmd.top, nullptr, 0);
if (!rc) if (!rc)
{ {
free(data); free(data);
@@ -1528,13 +1529,13 @@ static BOOL shadow_client_send_surface_bits(rdpShadowClient* client, BYTE* pSrcD
BOOL ret = TRUE; BOOL ret = TRUE;
BOOL first = 0; BOOL first = 0;
BOOL last = 0; BOOL last = 0;
wStream* s = NULL; wStream* s = nullptr;
size_t numMessages = 0; size_t numMessages = 0;
UINT32 frameId = 0; UINT32 frameId = 0;
rdpUpdate* update = NULL; rdpUpdate* update = nullptr;
rdpContext* context = (rdpContext*)client; rdpContext* context = (rdpContext*)client;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
rdpShadowEncoder* encoder = NULL; rdpShadowEncoder* encoder = nullptr;
SURFACE_BITS_COMMAND cmd = WINPR_C_ARRAY_INIT; SURFACE_BITS_COMMAND cmd = WINPR_C_ARRAY_INIT;
if (!context || !pSrcData) if (!context || !pSrcData)
@@ -1687,8 +1688,8 @@ static BOOL shadow_client_send_bitmap_update(rdpShadowClient* client, BYTE* pSrc
UINT16 nWidth, UINT16 nHeight) UINT16 nWidth, UINT16 nHeight)
{ {
BOOL ret = TRUE; BOOL ret = TRUE;
BYTE* data = NULL; BYTE* data = nullptr;
BYTE* buffer = NULL; BYTE* buffer = nullptr;
UINT32 k = 0; UINT32 k = 0;
UINT32 yIdx = 0; UINT32 yIdx = 0;
UINT32 xIdx = 0; UINT32 xIdx = 0;
@@ -1696,11 +1697,11 @@ static BOOL shadow_client_send_bitmap_update(rdpShadowClient* client, BYTE* pSrc
UINT32 cols = 0; UINT32 cols = 0;
UINT32 DstSize = 0; UINT32 DstSize = 0;
UINT32 SrcFormat = 0; UINT32 SrcFormat = 0;
BITMAP_DATA* bitmap = NULL; BITMAP_DATA* bitmap = nullptr;
rdpContext* context = (rdpContext*)client; rdpContext* context = (rdpContext*)client;
UINT32 totalBitmapSize = 0; UINT32 totalBitmapSize = 0;
UINT32 updateSizeEstimate = 0; UINT32 updateSizeEstimate = 0;
BITMAP_DATA* bitmapData = NULL; BITMAP_DATA* bitmapData = nullptr;
BITMAP_UPDATE bitmapUpdate = WINPR_C_ARRAY_INIT; BITMAP_UPDATE bitmapUpdate = WINPR_C_ARRAY_INIT;
if (!context || !pSrcData) if (!context || !pSrcData)
@@ -1797,9 +1798,9 @@ static BOOL shadow_client_send_bitmap_update(rdpShadowClient* client, BYTE* pSrc
DstSize = 64 * 64 * 4; DstSize = 64 * 64 * 4;
buffer = encoder->grid[k]; buffer = encoder->grid[k];
ret = interleaved_compress(encoder->interleaved, buffer, &DstSize, bitmap->width, ret = interleaved_compress(
bitmap->height, pSrcData, SrcFormat, nSrcStep, encoder->interleaved, buffer, &DstSize, bitmap->width, bitmap->height, pSrcData,
bitmap->destLeft, bitmap->destTop, NULL, bitsPerPixel); SrcFormat, nSrcStep, bitmap->destLeft, bitmap->destTop, nullptr, bitsPerPixel);
if (!ret) if (!ret)
goto out; goto out;
bitmap->bitmapDataStream = buffer; bitmap->bitmapDataStream = buffer;
@@ -1840,7 +1841,7 @@ static BOOL shadow_client_send_bitmap_update(rdpShadowClient* client, BYTE* pSrc
UINT32 j = 0; UINT32 j = 0;
UINT32 updateSize = 0; UINT32 updateSize = 0;
UINT32 newUpdateSize = 0; UINT32 newUpdateSize = 0;
BITMAP_DATA* fragBitmapData = NULL; BITMAP_DATA* fragBitmapData = nullptr;
if (k > 0) if (k > 0)
fragBitmapData = (BITMAP_DATA*)calloc(k, sizeof(BITMAP_DATA)); fragBitmapData = (BITMAP_DATA*)calloc(k, sizeof(BITMAP_DATA));
@@ -1905,17 +1906,17 @@ static BOOL shadow_client_send_surface_update(rdpShadowClient* client, SHADOW_GF
INT64 nWidth = 0; INT64 nWidth = 0;
INT64 nHeight = 0; INT64 nHeight = 0;
rdpContext* context = (rdpContext*)client; rdpContext* context = (rdpContext*)client;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
rdpShadowServer* server = NULL; rdpShadowServer* server = nullptr;
rdpShadowSurface* surface = NULL; rdpShadowSurface* surface = nullptr;
REGION16 invalidRegion; REGION16 invalidRegion;
RECTANGLE_16 surfaceRect; RECTANGLE_16 surfaceRect;
const RECTANGLE_16* extents = NULL; const RECTANGLE_16* extents = nullptr;
BYTE* pSrcData = NULL; BYTE* pSrcData = nullptr;
UINT32 nSrcStep = 0; UINT32 nSrcStep = 0;
UINT32 SrcFormat = 0; UINT32 SrcFormat = 0;
UINT32 numRects = 0; UINT32 numRects = 0;
const RECTANGLE_16* rects = NULL; const RECTANGLE_16* rects = nullptr;
if (!context || !pStatus) if (!context || !pStatus)
return FALSE; return FALSE;
@@ -2078,8 +2079,8 @@ WINPR_ATTR_NODISCARD
static BOOL shadow_client_send_resize(rdpShadowClient* client, SHADOW_GFX_STATUS* pStatus) static BOOL shadow_client_send_resize(rdpShadowClient* client, SHADOW_GFX_STATUS* pStatus)
{ {
rdpContext* context = (rdpContext*)client; rdpContext* context = (rdpContext*)client;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
freerdp_peer* peer = NULL; freerdp_peer* peer = nullptr;
if (!context || !pStatus) if (!context || !pStatus)
return FALSE; return FALSE;
@@ -2128,7 +2129,7 @@ WINPR_ATTR_NODISCARD
static BOOL shadow_client_surface_update(rdpShadowClient* client, REGION16* region) static BOOL shadow_client_surface_update(rdpShadowClient* client, REGION16* region)
{ {
UINT32 numRects = 0; UINT32 numRects = 0;
const RECTANGLE_16* rects = NULL; const RECTANGLE_16* rects = nullptr;
rects = region16_rects(region, &numRects); rects = region16_rects(region, &numRects);
shadow_client_mark_invalid(client, numRects, rects); shadow_client_mark_invalid(client, numRects, rects);
return TRUE; return TRUE;
@@ -2144,8 +2145,8 @@ WINPR_ATTR_NODISCARD
static inline BOOL shadow_client_no_surface_update(rdpShadowClient* client, static inline BOOL shadow_client_no_surface_update(rdpShadowClient* client,
SHADOW_GFX_STATUS* pStatus) SHADOW_GFX_STATUS* pStatus)
{ {
rdpShadowServer* server = NULL; rdpShadowServer* server = nullptr;
rdpShadowSurface* surface = NULL; rdpShadowSurface* surface = nullptr;
WINPR_UNUSED(pStatus); WINPR_UNUSED(pStatus);
WINPR_ASSERT(client); WINPR_ASSERT(client);
server = client->server; server = client->server;
@@ -2304,18 +2305,18 @@ static DWORD WINAPI shadow_client_thread(LPVOID arg)
wMessage pointerPositionMsg = WINPR_C_ARRAY_INIT; wMessage pointerPositionMsg = WINPR_C_ARRAY_INIT;
wMessage pointerAlphaMsg = WINPR_C_ARRAY_INIT; wMessage pointerAlphaMsg = WINPR_C_ARRAY_INIT;
wMessage audioVolumeMsg = WINPR_C_ARRAY_INIT; wMessage audioVolumeMsg = WINPR_C_ARRAY_INIT;
HANDLE ChannelEvent = 0; HANDLE ChannelEvent = nullptr;
void* UpdateSubscriber = NULL; void* UpdateSubscriber = nullptr;
HANDLE UpdateEvent = 0; HANDLE UpdateEvent = nullptr;
freerdp_peer* peer = NULL; freerdp_peer* peer = nullptr;
rdpContext* context = NULL; rdpContext* context = nullptr;
rdpSettings* settings = NULL; rdpSettings* settings = nullptr;
rdpShadowServer* server = NULL; rdpShadowServer* server = nullptr;
rdpShadowSubsystem* subsystem = NULL; rdpShadowSubsystem* subsystem = nullptr;
wMessageQueue* MsgQueue = NULL; wMessageQueue* MsgQueue = nullptr;
/* This should only be visited in client thread */ /* This should only be visited in client thread */
SHADOW_GFX_STATUS gfxstatus = WINPR_C_ARRAY_INIT; SHADOW_GFX_STATUS gfxstatus = WINPR_C_ARRAY_INIT;
rdpUpdate* update = NULL; rdpUpdate* update = nullptr;
WINPR_ASSERT(client); WINPR_ASSERT(client);
@@ -2542,11 +2543,11 @@ static DWORD WINAPI shadow_client_thread(LPVOID arg)
{ {
/* Drain messages. Pointer update could be accumulated. */ /* Drain messages. Pointer update could be accumulated. */
pointerPositionMsg.id = 0; pointerPositionMsg.id = 0;
pointerPositionMsg.Free = NULL; pointerPositionMsg.Free = nullptr;
pointerAlphaMsg.id = 0; pointerAlphaMsg.id = 0;
pointerAlphaMsg.Free = NULL; pointerAlphaMsg.Free = nullptr;
audioVolumeMsg.id = 0; audioVolumeMsg.id = 0;
audioVolumeMsg.Free = NULL; audioVolumeMsg.Free = nullptr;
while (MessageQueue_Peek(MsgQueue, &message, TRUE)) while (MessageQueue_Peek(MsgQueue, &message, TRUE))
{ {
@@ -2646,7 +2647,7 @@ fail:
if (UpdateSubscriber) if (UpdateSubscriber)
{ {
shadow_multiclient_release_subscriber(UpdateSubscriber); shadow_multiclient_release_subscriber(UpdateSubscriber);
UpdateSubscriber = NULL; UpdateSubscriber = nullptr;
} }
if (peer->connected && subsystem->ClientDisconnect) if (peer->connected && subsystem->ClientDisconnect)
@@ -2665,8 +2666,8 @@ out:
BOOL shadow_client_accepted(freerdp_listener* listener, freerdp_peer* peer) BOOL shadow_client_accepted(freerdp_listener* listener, freerdp_peer* peer)
{ {
rdpShadowClient* client = NULL; rdpShadowClient* client = nullptr;
rdpShadowServer* server = NULL; rdpShadowServer* server = nullptr;
if (!listener || !peer) if (!listener || !peer)
return FALSE; return FALSE;
@@ -2685,7 +2686,7 @@ BOOL shadow_client_accepted(freerdp_listener* listener, freerdp_peer* peer)
client = (rdpShadowClient*)peer->context; client = (rdpShadowClient*)peer->context;
WINPR_ASSERT(client); WINPR_ASSERT(client);
if (!(client->thread = CreateThread(NULL, 0, shadow_client_thread, client, 0, NULL))) if (!(client->thread = CreateThread(nullptr, 0, shadow_client_thread, client, 0, nullptr)))
{ {
freerdp_peer_context_free(peer); freerdp_peer_context_free(peer);
return FALSE; return FALSE;
@@ -2694,7 +2695,7 @@ BOOL shadow_client_accepted(freerdp_listener* listener, freerdp_peer* peer)
{ {
/* Close the thread handle to make it detached. */ /* Close the thread handle to make it detached. */
(void)CloseHandle(client->thread); (void)CloseHandle(client->thread);
client->thread = NULL; client->thread = nullptr;
} }
return TRUE; return TRUE;
@@ -2702,7 +2703,7 @@ BOOL shadow_client_accepted(freerdp_listener* listener, freerdp_peer* peer)
static void shadow_msg_out_addref(wMessage* message) static void shadow_msg_out_addref(wMessage* message)
{ {
SHADOW_MSG_OUT* msg = NULL; SHADOW_MSG_OUT* msg = nullptr;
WINPR_ASSERT(message); WINPR_ASSERT(message);
msg = (SHADOW_MSG_OUT*)message->wParam; msg = (SHADOW_MSG_OUT*)message->wParam;
@@ -2713,7 +2714,7 @@ static void shadow_msg_out_addref(wMessage* message)
static void shadow_msg_out_release(wMessage* message) static void shadow_msg_out_release(wMessage* message)
{ {
SHADOW_MSG_OUT* msg = NULL; SHADOW_MSG_OUT* msg = nullptr;
WINPR_ASSERT(message); WINPR_ASSERT(message);
msg = (SHADOW_MSG_OUT*)message->wParam; msg = (SHADOW_MSG_OUT*)message->wParam;
@@ -2796,7 +2797,7 @@ int shadow_client_boardcast_msg(rdpShadowServer* server, void* context, UINT32 t
int shadow_client_boardcast_quit(rdpShadowServer* server, int nExitCode) int shadow_client_boardcast_quit(rdpShadowServer* server, int nExitCode)
{ {
wMessageQueue* queue = NULL; wMessageQueue* queue = nullptr;
int count = 0; int count = 0;
WINPR_ASSERT(server); WINPR_ASSERT(server);

View File

@@ -115,13 +115,13 @@ static int shadow_encoder_uninit_grid(rdpShadowEncoder* encoder)
if (encoder->gridBuffer) if (encoder->gridBuffer)
{ {
free(encoder->gridBuffer); free(encoder->gridBuffer);
encoder->gridBuffer = NULL; encoder->gridBuffer = nullptr;
} }
if (encoder->grid) if (encoder->grid)
{ {
free((void*)encoder->grid); free((void*)encoder->grid);
encoder->grid = NULL; encoder->grid = nullptr;
} }
encoder->gridWidth = 0; encoder->gridWidth = 0;
@@ -305,7 +305,7 @@ static int shadow_encoder_init(rdpShadowEncoder* encoder)
return -1; return -1;
if (!encoder->bs) if (!encoder->bs)
encoder->bs = Stream_New(NULL, 4ULL * encoder->maxTileWidth * encoder->maxTileHeight); encoder->bs = Stream_New(nullptr, 4ULL * encoder->maxTileWidth * encoder->maxTileHeight);
if (!encoder->bs) if (!encoder->bs)
return -1; return -1;
@@ -318,7 +318,7 @@ static int shadow_encoder_uninit_rfx(rdpShadowEncoder* encoder)
if (encoder->rfx) if (encoder->rfx)
{ {
rfx_context_free(encoder->rfx); rfx_context_free(encoder->rfx);
encoder->rfx = NULL; encoder->rfx = nullptr;
} }
encoder->codecs &= (UINT32)~FREERDP_CODEC_REMOTEFX; encoder->codecs &= (UINT32)~FREERDP_CODEC_REMOTEFX;
@@ -330,7 +330,7 @@ static int shadow_encoder_uninit_nsc(rdpShadowEncoder* encoder)
if (encoder->nsc) if (encoder->nsc)
{ {
nsc_context_free(encoder->nsc); nsc_context_free(encoder->nsc);
encoder->nsc = NULL; encoder->nsc = nullptr;
} }
encoder->codecs &= (UINT32)~FREERDP_CODEC_NSCODEC; encoder->codecs &= (UINT32)~FREERDP_CODEC_NSCODEC;
@@ -342,7 +342,7 @@ static int shadow_encoder_uninit_planar(rdpShadowEncoder* encoder)
if (encoder->planar) if (encoder->planar)
{ {
freerdp_bitmap_planar_context_free(encoder->planar); freerdp_bitmap_planar_context_free(encoder->planar);
encoder->planar = NULL; encoder->planar = nullptr;
} }
encoder->codecs &= (UINT32)~FREERDP_CODEC_PLANAR; encoder->codecs &= (UINT32)~FREERDP_CODEC_PLANAR;
@@ -354,7 +354,7 @@ static int shadow_encoder_uninit_interleaved(rdpShadowEncoder* encoder)
if (encoder->interleaved) if (encoder->interleaved)
{ {
bitmap_interleaved_context_free(encoder->interleaved); bitmap_interleaved_context_free(encoder->interleaved);
encoder->interleaved = NULL; encoder->interleaved = nullptr;
} }
encoder->codecs &= (UINT32)~FREERDP_CODEC_INTERLEAVED; encoder->codecs &= (UINT32)~FREERDP_CODEC_INTERLEAVED;
@@ -366,7 +366,7 @@ static int shadow_encoder_uninit_h264(rdpShadowEncoder* encoder)
if (encoder->h264) if (encoder->h264)
{ {
h264_context_free(encoder->h264); h264_context_free(encoder->h264);
encoder->h264 = NULL; encoder->h264 = nullptr;
} }
encoder->codecs &= (UINT32) ~(FREERDP_CODEC_AVC420 | FREERDP_CODEC_AVC444); encoder->codecs &= (UINT32) ~(FREERDP_CODEC_AVC420 | FREERDP_CODEC_AVC444);
@@ -379,7 +379,7 @@ static int shadow_encoder_uninit_progressive(rdpShadowEncoder* encoder)
if (encoder->progressive) if (encoder->progressive)
{ {
progressive_context_free(encoder->progressive); progressive_context_free(encoder->progressive);
encoder->progressive = NULL; encoder->progressive = nullptr;
} }
encoder->codecs &= (UINT32)~FREERDP_CODEC_PROGRESSIVE; encoder->codecs &= (UINT32)~FREERDP_CODEC_PROGRESSIVE;
@@ -393,7 +393,7 @@ static int shadow_encoder_uninit(rdpShadowEncoder* encoder)
if (encoder->bs) if (encoder->bs)
{ {
Stream_Free(encoder->bs, TRUE); Stream_Free(encoder->bs, TRUE);
encoder->bs = NULL; encoder->bs = nullptr;
} }
shadow_encoder_uninit_rfx(encoder); shadow_encoder_uninit_rfx(encoder);
@@ -503,12 +503,12 @@ int shadow_encoder_prepare(rdpShadowEncoder* encoder, UINT32 codecs)
rdpShadowEncoder* shadow_encoder_new(rdpShadowClient* client) rdpShadowEncoder* shadow_encoder_new(rdpShadowClient* client)
{ {
rdpShadowEncoder* encoder = NULL; rdpShadowEncoder* encoder = nullptr;
rdpShadowServer* server = client->server; rdpShadowServer* server = client->server;
encoder = (rdpShadowEncoder*)calloc(1, sizeof(rdpShadowEncoder)); encoder = (rdpShadowEncoder*)calloc(1, sizeof(rdpShadowEncoder));
if (!encoder) if (!encoder)
return NULL; return nullptr;
encoder->client = client; encoder->client = client;
encoder->server = server; encoder->server = server;
@@ -518,7 +518,7 @@ rdpShadowEncoder* shadow_encoder_new(rdpShadowClient* client)
if (shadow_encoder_init(encoder) < 0) if (shadow_encoder_init(encoder) < 0)
{ {
shadow_encoder_free(encoder); shadow_encoder_free(encoder);
return NULL; return nullptr;
} }
return encoder; return encoder;

View File

@@ -133,6 +133,6 @@ void shadow_client_encomsp_uninit(rdpShadowClient* client)
{ {
client->encomsp->Stop(client->encomsp); client->encomsp->Stop(client->encomsp);
encomsp_server_context_free(client->encomsp); encomsp_server_context_free(client->encomsp);
client->encomsp = NULL; client->encomsp = nullptr;
} }
} }

View File

@@ -79,10 +79,10 @@ BOOL shadow_client_init_lobby(rdpShadowServer* server)
goto fail; goto fail;
if (rdtk_label_draw(surface, invalidRect.left, invalidRect.top, (UINT16)width, (UINT16)height, if (rdtk_label_draw(surface, invalidRect.left, invalidRect.top, (UINT16)width, (UINT16)height,
NULL, "Welcome", 0, 0) < 0) nullptr, "Welcome", 0, 0) < 0)
goto fail; goto fail;
// rdtk_button_draw(surface, 16, 64, 128, 32, NULL, "button"); // rdtk_button_draw(surface, 16, 64, 128, 32, nullptr, "button");
// rdtk_text_field_draw(surface, 16, 128, 128, 32, NULL, "text field"); // rdtk_text_field_draw(surface, 16, 128, 128, 32, nullptr, "text field");
#endif #endif
if (!region16_union_rect(&(lobby->invalidRegion), &(lobby->invalidRegion), &invalidRect)) if (!region16_union_rect(&(lobby->invalidRegion), &(lobby->invalidRegion), &invalidRect))

View File

@@ -51,15 +51,15 @@ rdpShadowMultiClientEvent* shadow_multiclient_new(void)
if (!event) if (!event)
goto out_error; goto out_error;
event->event = CreateEvent(NULL, TRUE, FALSE, NULL); event->event = CreateEvent(nullptr, TRUE, FALSE, nullptr);
if (!event->event) if (!event->event)
goto out_free; goto out_free;
event->barrierEvent = CreateEvent(NULL, TRUE, FALSE, NULL); event->barrierEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
if (!event->barrierEvent) if (!event->barrierEvent)
goto out_free_event; goto out_free_event;
event->doneEvent = CreateEvent(NULL, TRUE, FALSE, NULL); event->doneEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
if (!event->doneEvent) if (!event->doneEvent)
goto out_free_barrierEvent; goto out_free_barrierEvent;
@@ -87,7 +87,7 @@ out_free_event:
out_free: out_free:
free(event); free(event);
out_error: out_error:
return (rdpShadowMultiClientEvent*)NULL; return (rdpShadowMultiClientEvent*)nullptr;
} }
void shadow_multiclient_free(rdpShadowMultiClientEvent* event) void shadow_multiclient_free(rdpShadowMultiClientEvent* event)
@@ -106,8 +106,8 @@ void shadow_multiclient_free(rdpShadowMultiClientEvent* event)
static void Publish(rdpShadowMultiClientEvent* event) static void Publish(rdpShadowMultiClientEvent* event)
{ {
wArrayList* subscribers = NULL; wArrayList* subscribers = nullptr;
struct rdp_shadow_multiclient_subscriber* subscriber = NULL; struct rdp_shadow_multiclient_subscriber* subscriber = nullptr;
subscribers = event->subscribers; subscribers = event->subscribers;
@@ -240,10 +240,10 @@ static BOOL Consume(struct rdp_shadow_multiclient_subscriber* subscriber, BOOL w
void* shadow_multiclient_get_subscriber(rdpShadowMultiClientEvent* event) void* shadow_multiclient_get_subscriber(rdpShadowMultiClientEvent* event)
{ {
struct rdp_shadow_multiclient_subscriber* subscriber = NULL; struct rdp_shadow_multiclient_subscriber* subscriber = nullptr;
if (!event) if (!event)
return NULL; return nullptr;
EnterCriticalSection(&(event->lock)); EnterCriticalSection(&(event->lock));
@@ -272,7 +272,7 @@ out_free:
free(subscriber); free(subscriber);
out_error: out_error:
LeaveCriticalSection(&(event->lock)); LeaveCriticalSection(&(event->lock));
return NULL; return nullptr;
} }
/* /*
@@ -283,8 +283,8 @@ out_error:
*/ */
void shadow_multiclient_release_subscriber(void* subscriber) void shadow_multiclient_release_subscriber(void* subscriber)
{ {
struct rdp_shadow_multiclient_subscriber* s = NULL; struct rdp_shadow_multiclient_subscriber* s = nullptr;
rdpShadowMultiClientEvent* event = NULL; rdpShadowMultiClientEvent* event = nullptr;
if (!subscriber) if (!subscriber)
return; return;
@@ -309,8 +309,8 @@ void shadow_multiclient_release_subscriber(void* subscriber)
BOOL shadow_multiclient_consume(void* subscriber) BOOL shadow_multiclient_consume(void* subscriber)
{ {
struct rdp_shadow_multiclient_subscriber* s = NULL; struct rdp_shadow_multiclient_subscriber* s = nullptr;
rdpShadowMultiClientEvent* event = NULL; rdpShadowMultiClientEvent* event = nullptr;
BOOL ret = FALSE; BOOL ret = FALSE;
if (!subscriber) if (!subscriber)
@@ -335,7 +335,7 @@ BOOL shadow_multiclient_consume(void* subscriber)
HANDLE shadow_multiclient_getevent(void* subscriber) HANDLE shadow_multiclient_getevent(void* subscriber)
{ {
if (!subscriber) if (!subscriber)
return (HANDLE)NULL; return (HANDLE) nullptr;
return ((struct rdp_shadow_multiclient_subscriber*)subscriber)->ref->event; return ((struct rdp_shadow_multiclient_subscriber*)subscriber)->ref->event;
} }

View File

@@ -54,6 +54,6 @@ void shadow_client_rdpgfx_uninit(rdpShadowClient* client)
#if defined(CHANNEL_RDPGFX_SERVER) #if defined(CHANNEL_RDPGFX_SERVER)
rdpgfx_server_context_free(client->rdpgfx); rdpgfx_server_context_free(client->rdpgfx);
#endif #endif
client->rdpgfx = NULL; client->rdpgfx = nullptr;
} }
} }

View File

@@ -92,6 +92,6 @@ void shadow_client_rdpsnd_uninit(rdpShadowClient* client)
{ {
client->rdpsnd->Stop(client->rdpsnd); client->rdpsnd->Stop(client->rdpsnd);
rdpsnd_server_context_free(client->rdpsnd); rdpsnd_server_context_free(client->rdpsnd);
client->rdpsnd = NULL; client->rdpsnd = nullptr;
} }
} }

View File

@@ -52,6 +52,6 @@ void shadow_client_remdesk_uninit(rdpShadowClient* client)
{ {
client->remdesk->Stop(client->remdesk); client->remdesk->Stop(client->remdesk);
remdesk_server_context_free(client->remdesk); remdesk_server_context_free(client->remdesk);
client->remdesk = NULL; client->remdesk = nullptr;
} }
} }

View File

@@ -95,7 +95,7 @@ fail:
shadow_screen_free(screen); shadow_screen_free(screen);
WINPR_PRAGMA_DIAG_POP WINPR_PRAGMA_DIAG_POP
return NULL; return nullptr;
} }
void shadow_screen_free(rdpShadowScreen* screen) void shadow_screen_free(rdpShadowScreen* screen)
@@ -110,13 +110,13 @@ void shadow_screen_free(rdpShadowScreen* screen)
if (screen->primary) if (screen->primary)
{ {
shadow_surface_free(screen->primary); shadow_surface_free(screen->primary);
screen->primary = NULL; screen->primary = nullptr;
} }
if (screen->lobby) if (screen->lobby)
{ {
shadow_surface_free(screen->lobby); shadow_surface_free(screen->lobby);
screen->lobby = NULL; screen->lobby = nullptr;
} }
free(screen); free(screen);

View File

@@ -106,7 +106,7 @@ static int shadow_server_print_command_line_help(int argc, char** argv,
size_t nrArgs = 0; size_t nrArgs = 0;
{ {
const COMMAND_LINE_ARGUMENT_A* arg = largs; const COMMAND_LINE_ARGUMENT_A* arg = largs;
while (arg->Name != NULL) while (arg->Name != nullptr)
{ {
nrArgs++; nrArgs++;
arg++; arg++;
@@ -170,7 +170,7 @@ static int shadow_server_print_command_line_help(int argc, char** argv,
free(str); free(str);
} }
} while ((arg = CommandLineFindNextArgumentA(arg)) != NULL); } while ((arg = CommandLineFindNextArgumentA(arg)) != nullptr);
rc = 1; rc = 1;
fail: fail:
@@ -213,7 +213,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
{ {
int status = 0; int status = 0;
DWORD flags = 0; DWORD flags = 0;
const COMMAND_LINE_ARGUMENT_A* arg = NULL; const COMMAND_LINE_ARGUMENT_A* arg = nullptr;
rdpSettings* settings = server->settings; rdpSettings* settings = server->settings;
if ((argc < 2) || !argv || !cargs) if ((argc < 2) || !argv || !cargs)
@@ -222,7 +222,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
CommandLineClearArgumentsA(cargs); CommandLineClearArgumentsA(cargs);
flags = COMMAND_LINE_SEPARATOR_COLON; flags = COMMAND_LINE_SEPARATOR_COLON;
flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS; flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
status = CommandLineParseArgumentsA(argc, argv, cargs, flags, server, NULL, NULL); status = CommandLineParseArgumentsA(argc, argv, cargs, flags, server, nullptr, nullptr);
if (status < 0) if (status < 0)
return status; return status;
@@ -237,7 +237,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "port") CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "port")
{ {
long val = strtol(arg->Value, NULL, 0); long val = strtol(arg->Value, nullptr, 0);
if ((errno != 0) || (val <= 0) || (val > UINT16_MAX)) if ((errno != 0) || (val <= 0) || (val > UINT16_MAX))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
@@ -272,23 +272,23 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
} }
CommandLineSwitchCase(arg, "may-view") CommandLineSwitchCase(arg, "may-view")
{ {
server->mayView = arg->Value != NULL; server->mayView = arg->Value != nullptr;
} }
CommandLineSwitchCase(arg, "bitmap-compat") CommandLineSwitchCase(arg, "bitmap-compat")
{ {
server->SupportMultiRectBitmapUpdates = arg->Value == NULL; server->SupportMultiRectBitmapUpdates = arg->Value == nullptr;
} }
CommandLineSwitchCase(arg, "may-interact") CommandLineSwitchCase(arg, "may-interact")
{ {
server->mayInteract = arg->Value != NULL; server->mayInteract = arg->Value != nullptr;
} }
CommandLineSwitchCase(arg, "server-side-cursor") CommandLineSwitchCase(arg, "server-side-cursor")
{ {
server->ShowMouseCursor = arg->Value != NULL; server->ShowMouseCursor = arg->Value != nullptr;
} }
CommandLineSwitchCase(arg, "mouse-relative") CommandLineSwitchCase(arg, "mouse-relative")
{ {
const BOOL val = arg->Value != NULL; const BOOL val = arg->Value != nullptr;
if (!freerdp_settings_set_bool(settings, FreeRDP_MouseUseRelativeMove, val) || if (!freerdp_settings_set_bool(settings, FreeRDP_MouseUseRelativeMove, val) ||
!freerdp_settings_set_bool(settings, FreeRDP_HasRelativeMouseEvent, val)) !freerdp_settings_set_bool(settings, FreeRDP_HasRelativeMouseEvent, val))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
@@ -296,7 +296,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
CommandLineSwitchCase(arg, "max-connections") CommandLineSwitchCase(arg, "max-connections")
{ {
errno = 0; errno = 0;
unsigned long val = strtoul(arg->Value, NULL, 0); unsigned long val = strtoul(arg->Value, nullptr, 0);
if ((errno != 0) || (val > UINT32_MAX)) if ((errno != 0) || (val > UINT32_MAX))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
@@ -304,7 +304,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
} }
CommandLineSwitchCase(arg, "rect") CommandLineSwitchCase(arg, "rect")
{ {
char* p = NULL; char* p = nullptr;
char* tok[4]; char* tok[4];
long x = -1; long x = -1;
long y = -1; long y = -1;
@@ -346,22 +346,22 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
*p++ = '\0'; *p++ = '\0';
tok[3] = p; tok[3] = p;
x = strtol(tok[0], NULL, 0); x = strtol(tok[0], nullptr, 0);
if (errno != 0) if (errno != 0)
goto fail; goto fail;
y = strtol(tok[1], NULL, 0); y = strtol(tok[1], nullptr, 0);
if (errno != 0) if (errno != 0)
goto fail; goto fail;
w = strtol(tok[2], NULL, 0); w = strtol(tok[2], nullptr, 0);
if (errno != 0) if (errno != 0)
goto fail; goto fail;
h = strtol(tok[3], NULL, 0); h = strtol(tok[3], nullptr, 0);
if (errno != 0) if (errno != 0)
goto fail; goto fail;
@@ -383,23 +383,23 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
} }
CommandLineSwitchCase(arg, "auth") CommandLineSwitchCase(arg, "auth")
{ {
server->authentication = arg->Value != NULL; server->authentication = arg->Value != nullptr;
} }
CommandLineSwitchCase(arg, "remote-guard") CommandLineSwitchCase(arg, "remote-guard")
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteCredentialGuard, if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteCredentialGuard,
arg->Value != NULL)) arg->Value != nullptr))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
} }
CommandLineSwitchCase(arg, "restricted-admin") CommandLineSwitchCase(arg, "restricted-admin")
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_RestrictedAdminModeSupported, if (!freerdp_settings_set_bool(settings, FreeRDP_RestrictedAdminModeSupported,
arg->Value != NULL)) arg->Value != nullptr))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
} }
CommandLineSwitchCase(arg, "vmconnect") CommandLineSwitchCase(arg, "vmconnect")
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_VmConnectMode, arg->Value != NULL)) if (!freerdp_settings_set_bool(settings, FreeRDP_VmConnectMode, arg->Value != nullptr))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
} }
CommandLineSwitchCase(arg, "sec") CommandLineSwitchCase(arg, "sec")
@@ -458,22 +458,22 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
} }
CommandLineSwitchCase(arg, "sec-rdp") CommandLineSwitchCase(arg, "sec-rdp")
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_RdpSecurity, arg->Value != NULL)) if (!freerdp_settings_set_bool(settings, FreeRDP_RdpSecurity, arg->Value != nullptr))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
} }
CommandLineSwitchCase(arg, "sec-tls") CommandLineSwitchCase(arg, "sec-tls")
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_TlsSecurity, arg->Value != NULL)) if (!freerdp_settings_set_bool(settings, FreeRDP_TlsSecurity, arg->Value != nullptr))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
} }
CommandLineSwitchCase(arg, "sec-nla") CommandLineSwitchCase(arg, "sec-nla")
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_NlaSecurity, arg->Value != NULL)) if (!freerdp_settings_set_bool(settings, FreeRDP_NlaSecurity, arg->Value != nullptr))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
} }
CommandLineSwitchCase(arg, "sec-ext") CommandLineSwitchCase(arg, "sec-ext")
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_ExtSecurity, arg->Value != NULL)) if (!freerdp_settings_set_bool(settings, FreeRDP_ExtSecurity, arg->Value != nullptr))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
} }
CommandLineSwitchCase(arg, "sam-file") CommandLineSwitchCase(arg, "sam-file")
@@ -495,45 +495,45 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
} }
CommandLineSwitchCase(arg, "nsc") CommandLineSwitchCase(arg, "nsc")
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_NSCodec, arg->Value != NULL)) if (!freerdp_settings_set_bool(settings, FreeRDP_NSCodec, arg->Value != nullptr))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
} }
CommandLineSwitchCase(arg, "rfx") CommandLineSwitchCase(arg, "rfx")
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxCodec, arg->Value != NULL)) if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxCodec, arg->Value != nullptr))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
} }
CommandLineSwitchCase(arg, "gfx") CommandLineSwitchCase(arg, "gfx")
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportGraphicsPipeline, if (!freerdp_settings_set_bool(settings, FreeRDP_SupportGraphicsPipeline,
arg->Value != NULL)) arg->Value != nullptr))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
} }
CommandLineSwitchCase(arg, "gfx-progressive") CommandLineSwitchCase(arg, "gfx-progressive")
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_GfxProgressive, arg->Value != NULL)) if (!freerdp_settings_set_bool(settings, FreeRDP_GfxProgressive, arg->Value != nullptr))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
} }
CommandLineSwitchCase(arg, "gfx-rfx") CommandLineSwitchCase(arg, "gfx-rfx")
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxCodec, arg->Value != NULL)) if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxCodec, arg->Value != nullptr))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
} }
CommandLineSwitchCase(arg, "gfx-planar") CommandLineSwitchCase(arg, "gfx-planar")
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_GfxPlanar, arg->Value != NULL)) if (!freerdp_settings_set_bool(settings, FreeRDP_GfxPlanar, arg->Value != nullptr))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
} }
CommandLineSwitchCase(arg, "gfx-avc420") CommandLineSwitchCase(arg, "gfx-avc420")
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_GfxH264, arg->Value != NULL)) if (!freerdp_settings_set_bool(settings, FreeRDP_GfxH264, arg->Value != nullptr))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
} }
CommandLineSwitchCase(arg, "gfx-avc444") CommandLineSwitchCase(arg, "gfx-avc444")
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_GfxAVC444v2, arg->Value != NULL)) if (!freerdp_settings_set_bool(settings, FreeRDP_GfxAVC444v2, arg->Value != nullptr))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
if (!freerdp_settings_set_bool(settings, FreeRDP_GfxAVC444, arg->Value != NULL)) if (!freerdp_settings_set_bool(settings, FreeRDP_GfxAVC444, arg->Value != nullptr))
return fail_at(arg, COMMAND_LINE_ERROR); return fail_at(arg, COMMAND_LINE_ERROR);
} }
CommandLineSwitchCase(arg, "keytab") CommandLineSwitchCase(arg, "keytab")
@@ -555,7 +555,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
{ {
} }
CommandLineSwitchEnd(arg) CommandLineSwitchEnd(arg)
} while ((arg = CommandLineFindNextArgumentA(arg)) != NULL); } while ((arg = CommandLineFindNextArgumentA(arg)) != nullptr);
arg = CommandLineFindArgumentA(cargs, "monitors"); arg = CommandLineFindArgumentA(cargs, "monitors");
@@ -568,7 +568,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT) if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
{ {
/* Select monitors */ /* Select monitors */
long val = strtol(arg->Value, NULL, 0); long val = strtol(arg->Value, nullptr, 0);
if ((val < 0) || (errno != 0) || ((UINT32)val >= numMonitors)) if ((val < 0) || (errno != 0) || ((UINT32)val >= numMonitors))
status = COMMAND_LINE_STATUS_PRINT; status = COMMAND_LINE_STATUS_PRINT;
@@ -751,12 +751,12 @@ int shadow_server_start(rdpShadowServer* server)
{ {
size_t count = 0; size_t count = 0;
char** ptr = CommandLineParseCommaSeparatedValuesEx(NULL, server->ipcSocket, &count); char** ptr = CommandLineParseCommaSeparatedValuesEx(nullptr, server->ipcSocket, &count);
if (!ptr || (count <= 1)) if (!ptr || (count <= 1))
{ {
if (server->ipcSocket == NULL) if (server->ipcSocket == nullptr)
{ {
if (!open_port(server, NULL)) if (!open_port(server, nullptr))
{ {
CommandLineParserFree(ptr); CommandLineParserFree(ptr);
return -1; return -1;
@@ -793,7 +793,8 @@ int shadow_server_start(rdpShadowServer* server)
} }
} }
if (!(server->thread = CreateThread(NULL, 0, shadow_server_thread, (void*)server, 0, NULL))) if (!(server->thread =
CreateThread(nullptr, 0, shadow_server_thread, (void*)server, 0, nullptr)))
{ {
return -1; return -1;
} }
@@ -811,7 +812,7 @@ int shadow_server_stop(rdpShadowServer* server)
(void)SetEvent(server->StopEvent); (void)SetEvent(server->StopEvent);
(void)WaitForSingleObject(server->thread, INFINITE); (void)WaitForSingleObject(server->thread, INFINITE);
(void)CloseHandle(server->thread); (void)CloseHandle(server->thread);
server->thread = NULL; server->thread = nullptr;
if (server->listener && server->listener->Close) if (server->listener && server->listener->Close)
server->listener->Close(server->listener); server->listener->Close(server->listener);
} }
@@ -819,13 +820,13 @@ int shadow_server_stop(rdpShadowServer* server)
if (server->screen) if (server->screen)
{ {
shadow_screen_free(server->screen); shadow_screen_free(server->screen);
server->screen = NULL; server->screen = nullptr;
} }
if (server->capture) if (server->capture)
{ {
shadow_capture_free(server->capture); shadow_capture_free(server->capture);
server->capture = NULL; server->capture = nullptr;
} }
return 0; return 0;
@@ -840,7 +841,7 @@ static int shadow_server_init_config_path(rdpShadowServer* server)
if (configHome) if (configHome)
{ {
if (!winpr_PathFileExists(configHome) && !winpr_PathMakePath(configHome, 0)) if (!winpr_PathFileExists(configHome) && !winpr_PathMakePath(configHome, nullptr))
{ {
WLog_ERR(TAG, "Failed to create directory '%s'", configHome); WLog_ERR(TAG, "Failed to create directory '%s'", configHome);
free(configHome); free(configHome);
@@ -899,12 +900,13 @@ out_fail:
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD
static BOOL shadow_server_init_certificate(rdpShadowServer* server) static BOOL shadow_server_init_certificate(rdpShadowServer* server)
{ {
char* filepath = NULL; char* filepath = nullptr;
BOOL ret = FALSE; BOOL ret = FALSE;
WINPR_ASSERT(server); WINPR_ASSERT(server);
if (!winpr_PathFileExists(server->ConfigPath) && !winpr_PathMakePath(server->ConfigPath, 0)) if (!winpr_PathFileExists(server->ConfigPath) &&
!winpr_PathMakePath(server->ConfigPath, nullptr))
{ {
WLog_ERR(TAG, "Failed to create directory '%s'", server->ConfigPath); WLog_ERR(TAG, "Failed to create directory '%s'", server->ConfigPath);
return FALSE; return FALSE;
@@ -913,9 +915,9 @@ static BOOL shadow_server_init_certificate(rdpShadowServer* server)
if (!(filepath = GetCombinedPath(server->ConfigPath, "shadow"))) if (!(filepath = GetCombinedPath(server->ConfigPath, "shadow")))
return FALSE; return FALSE;
if (!winpr_PathFileExists(filepath) && !winpr_PathMakePath(filepath, 0)) if (!winpr_PathFileExists(filepath) && !winpr_PathMakePath(filepath, nullptr))
{ {
if (!winpr_PathMakePath(filepath, NULL)) if (!winpr_PathMakePath(filepath, nullptr))
{ {
WLog_ERR(TAG, "Failed to create directory '%s'", filepath); WLog_ERR(TAG, "Failed to create directory '%s'", filepath);
goto out_fail; goto out_fail;
@@ -940,7 +942,7 @@ static BOOL shadow_server_init_certificate(rdpShadowServer* server)
WINPR_ASSERT(settings); WINPR_ASSERT(settings);
{ {
rdpPrivateKey* key = freerdp_key_new_from_file_enc(server->PrivateKeyFile, NULL); rdpPrivateKey* key = freerdp_key_new_from_file_enc(server->PrivateKeyFile, nullptr);
if (!key) if (!key)
goto out_fail; goto out_fail;
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerRsaKey, key, 1)) if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerRsaKey, key, 1))
@@ -1002,7 +1004,7 @@ int shadow_server_init(rdpShadowServer* server)
if (!(server->clients = ArrayList_New(TRUE))) if (!(server->clients = ArrayList_New(TRUE)))
goto fail; goto fail;
if (!(server->StopEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) if (!(server->StopEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
goto fail; goto fail;
if (!InitializeCriticalSectionAndSpinCount(&(server->lock), 4000)) if (!InitializeCriticalSectionAndSpinCount(&(server->lock), 4000))
@@ -1049,30 +1051,30 @@ int shadow_server_uninit(rdpShadowServer* server)
shadow_server_stop(server); shadow_server_stop(server);
shadow_subsystem_uninit(server->subsystem); shadow_subsystem_uninit(server->subsystem);
shadow_subsystem_free(server->subsystem); shadow_subsystem_free(server->subsystem);
server->subsystem = NULL; server->subsystem = nullptr;
freerdp_listener_free(server->listener); freerdp_listener_free(server->listener);
server->listener = NULL; server->listener = nullptr;
free(server->CertificateFile); free(server->CertificateFile);
server->CertificateFile = NULL; server->CertificateFile = nullptr;
free(server->PrivateKeyFile); free(server->PrivateKeyFile);
server->PrivateKeyFile = NULL; server->PrivateKeyFile = nullptr;
free(server->ConfigPath); free(server->ConfigPath);
server->ConfigPath = NULL; server->ConfigPath = nullptr;
DeleteCriticalSection(&(server->lock)); DeleteCriticalSection(&(server->lock));
(void)CloseHandle(server->StopEvent); (void)CloseHandle(server->StopEvent);
server->StopEvent = NULL; server->StopEvent = nullptr;
ArrayList_Free(server->clients); ArrayList_Free(server->clients);
server->clients = NULL; server->clients = nullptr;
return 1; return 1;
} }
rdpShadowServer* shadow_server_new(void) rdpShadowServer* shadow_server_new(void)
{ {
rdpShadowServer* server = NULL; rdpShadowServer* server = nullptr;
server = (rdpShadowServer*)calloc(1, sizeof(rdpShadowServer)); server = (rdpShadowServer*)calloc(1, sizeof(rdpShadowServer));
if (!server) if (!server)
return NULL; return nullptr;
server->SupportMultiRectBitmapUpdates = TRUE; server->SupportMultiRectBitmapUpdates = TRUE;
server->port = 3389; server->port = 3389;
@@ -1093,8 +1095,8 @@ void shadow_server_free(rdpShadowServer* server)
return; return;
free(server->ipcSocket); free(server->ipcSocket);
server->ipcSocket = NULL; server->ipcSocket = nullptr;
freerdp_settings_free(server->settings); freerdp_settings_free(server->settings);
server->settings = NULL; server->settings = nullptr;
free(server); free(server);
} }

View File

@@ -22,7 +22,7 @@
#include "shadow_subsystem.h" #include "shadow_subsystem.h"
static pfnShadowSubsystemEntry pSubsystemEntry = NULL; static pfnShadowSubsystemEntry pSubsystemEntry = nullptr;
void shadow_subsystem_set_entry(pfnShadowSubsystemEntry pEntry) void shadow_subsystem_set_entry(pfnShadowSubsystemEntry pEntry)
{ {
@@ -49,15 +49,15 @@ rdpShadowSubsystem* shadow_subsystem_new(void)
RDP_SHADOW_ENTRY_POINTS ep = WINPR_C_ARRAY_INIT; RDP_SHADOW_ENTRY_POINTS ep = WINPR_C_ARRAY_INIT;
if (shadow_subsystem_load_entry_points(&ep) < 0) if (shadow_subsystem_load_entry_points(&ep) < 0)
return NULL; return nullptr;
if (!ep.New) if (!ep.New)
return NULL; return nullptr;
rdpShadowSubsystem* subsystem = ep.New(); rdpShadowSubsystem* subsystem = ep.New();
if (!subsystem) if (!subsystem)
return NULL; return nullptr;
subsystem->ep = ep; subsystem->ep = ep;
@@ -94,13 +94,13 @@ fail:
if (subsystem->MsgPipe) if (subsystem->MsgPipe)
{ {
MessagePipe_Free(subsystem->MsgPipe); MessagePipe_Free(subsystem->MsgPipe);
subsystem->MsgPipe = NULL; subsystem->MsgPipe = nullptr;
} }
if (subsystem->updateEvent) if (subsystem->updateEvent)
{ {
shadow_multiclient_free(subsystem->updateEvent); shadow_multiclient_free(subsystem->updateEvent);
subsystem->updateEvent = NULL; subsystem->updateEvent = nullptr;
} }
return status; return status;
@@ -112,7 +112,7 @@ static void shadow_subsystem_free_queued_message(void* obj)
if (message->Free) if (message->Free)
{ {
message->Free(message); message->Free(message);
message->Free = NULL; message->Free = nullptr;
} }
} }
@@ -126,8 +126,8 @@ void shadow_subsystem_uninit(rdpShadowSubsystem* subsystem)
if (subsystem->MsgPipe) if (subsystem->MsgPipe)
{ {
wObject* obj1 = NULL; wObject* obj1 = nullptr;
wObject* obj2 = NULL; wObject* obj2 = nullptr;
/* Release resource in messages before free */ /* Release resource in messages before free */
obj1 = MessageQueue_Object(subsystem->MsgPipe->In); obj1 = MessageQueue_Object(subsystem->MsgPipe->In);
@@ -138,13 +138,13 @@ void shadow_subsystem_uninit(rdpShadowSubsystem* subsystem)
obj2->fnObjectFree = shadow_subsystem_free_queued_message; obj2->fnObjectFree = shadow_subsystem_free_queued_message;
MessageQueue_Clear(subsystem->MsgPipe->Out); MessageQueue_Clear(subsystem->MsgPipe->Out);
MessagePipe_Free(subsystem->MsgPipe); MessagePipe_Free(subsystem->MsgPipe);
subsystem->MsgPipe = NULL; subsystem->MsgPipe = nullptr;
} }
if (subsystem->updateEvent) if (subsystem->updateEvent)
{ {
shadow_multiclient_free(subsystem->updateEvent); shadow_multiclient_free(subsystem->updateEvent);
subsystem->updateEvent = NULL; subsystem->updateEvent = nullptr;
} }
} }
@@ -208,7 +208,7 @@ int shadow_subsystem_pointer_convert_alpha_pointer_data_to_format(
UINT32 xorStep = 0; UINT32 xorStep = 0;
UINT32 andStep = 0; UINT32 andStep = 0;
UINT32 andBit = 0; UINT32 andBit = 0;
BYTE* andBits = NULL; BYTE* andBits = nullptr;
UINT32 andPixel = 0; UINT32 andPixel = 0;
const size_t bpp = FreeRDPGetBytesPerPixel(format); const size_t bpp = FreeRDPGetBytesPerPixel(format);
@@ -230,7 +230,7 @@ int shadow_subsystem_pointer_convert_alpha_pointer_data_to_format(
if (!pointerColor->andMaskData) if (!pointerColor->andMaskData)
{ {
free(pointerColor->xorMaskData); free(pointerColor->xorMaskData);
pointerColor->xorMaskData = NULL; pointerColor->xorMaskData = nullptr;
return -1; return -1;
} }
@@ -250,7 +250,7 @@ int shadow_subsystem_pointer_convert_alpha_pointer_data_to_format(
BYTE A = 0; BYTE A = 0;
const UINT32 color = FreeRDPReadColor(&pSrc8[x * bpp], format); const UINT32 color = FreeRDPReadColor(&pSrc8[x * bpp], format);
FreeRDPSplitColor(color, format, &R, &G, &B, &A, NULL); FreeRDPSplitColor(color, format, &R, &G, &B, &A, nullptr);
andPixel = 0; andPixel = 0;

View File

@@ -49,7 +49,7 @@ static pfnShadowSubsystemEntry shadow_subsystem_load_static_entry(const char* na
return cur->entry; return cur->entry;
} }
return NULL; return nullptr;
} }
for (size_t index = 0; index < g_SubsystemCount; index++) for (size_t index = 0; index < g_SubsystemCount; index++)
@@ -62,7 +62,7 @@ static pfnShadowSubsystemEntry shadow_subsystem_load_static_entry(const char* na
return cur->entry; return cur->entry;
} }
return NULL; return nullptr;
} }
void shadow_subsystem_set_entry_builtin(const char* name) void shadow_subsystem_set_entry_builtin(const char* name)

View File

@@ -27,11 +27,11 @@
rdpShadowSurface* shadow_surface_new(rdpShadowServer* server, UINT16 x, UINT16 y, UINT32 width, rdpShadowSurface* shadow_surface_new(rdpShadowServer* server, UINT16 x, UINT16 y, UINT32 width,
UINT32 height) UINT32 height)
{ {
rdpShadowSurface* surface = NULL; rdpShadowSurface* surface = nullptr;
surface = (rdpShadowSurface*)calloc(1, sizeof(rdpShadowSurface)); surface = (rdpShadowSurface*)calloc(1, sizeof(rdpShadowSurface));
if (!surface) if (!surface)
return NULL; return nullptr;
surface->server = server; surface->server = server;
surface->x = x; surface->x = x;
@@ -45,14 +45,14 @@ rdpShadowSurface* shadow_surface_new(rdpShadowServer* server, UINT16 x, UINT16 y
if (!surface->data) if (!surface->data)
{ {
free(surface); free(surface);
return NULL; return nullptr;
} }
if (!InitializeCriticalSectionAndSpinCount(&(surface->lock), 4000)) if (!InitializeCriticalSectionAndSpinCount(&(surface->lock), 4000))
{ {
free(surface->data); free(surface->data);
free(surface); free(surface);
return NULL; return nullptr;
} }
region16_init(&(surface->invalidRegion)); region16_init(&(surface->invalidRegion));
@@ -73,7 +73,7 @@ void shadow_surface_free(rdpShadowSurface* surface)
BOOL shadow_surface_resize(rdpShadowSurface* surface, UINT16 x, UINT16 y, UINT32 width, BOOL shadow_surface_resize(rdpShadowSurface* surface, UINT16 x, UINT16 y, UINT32 width,
UINT32 height) UINT32 height)
{ {
BYTE* buffer = NULL; BYTE* buffer = nullptr;
UINT32 scanline = ALIGN_SCREEN_SIZE(width, 4) * 4; UINT32 scanline = ALIGN_SCREEN_SIZE(width, 4) * 4;
if (!surface) if (!surface)