From 53a61f512cee5919a8646b5c5ab963d888e98a07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Fri, 2 Dec 2016 13:18:55 -0500 Subject: [PATCH] winpr: fix UWP portability --- winpr/libwinpr/io/io.c | 7 +++++++ winpr/libwinpr/path/shell.c | 4 +++- winpr/libwinpr/wtsapi/wtsapi_win32.c | 12 ++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/winpr/libwinpr/io/io.c b/winpr/libwinpr/io/io.c index 2aa5881d2..cac97e9e9 100644 --- a/winpr/libwinpr/io/io.c +++ b/winpr/libwinpr/io/io.c @@ -199,6 +199,13 @@ BOOL CancelSynchronousIo(HANDLE hThread) #ifdef _UWP +#include +#include + +#include "../log.h" + +#define TAG WINPR_TAG("io") + BOOL GetOverlappedResult(HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait) { return GetOverlappedResultEx(hFile, lpOverlapped, lpNumberOfBytesTransferred, bWait ? INFINITE : 0, TRUE); diff --git a/winpr/libwinpr/path/shell.c b/winpr/libwinpr/path/shell.c index adf73e7ae..3ed11ce46 100644 --- a/winpr/libwinpr/path/shell.c +++ b/winpr/libwinpr/path/shell.c @@ -450,7 +450,9 @@ char* GetCombinedPath(const char* basePath, const char* subPath) BOOL PathMakePathA(LPCSTR path, LPSECURITY_ATTRIBUTES lpAttributes) { -#ifdef _WIN32 +#if defined(_UWP) + return FALSE; +#elif defined(_WIN32) return (SHCreateDirectoryExA(NULL, path, lpAttributes) == ERROR_SUCCESS); #else const char delim = PathGetSeparatorA(PATH_STYLE_NATIVE); diff --git a/winpr/libwinpr/wtsapi/wtsapi_win32.c b/winpr/libwinpr/wtsapi/wtsapi_win32.c index 2a2556bd8..300a9642c 100644 --- a/winpr/libwinpr/wtsapi/wtsapi_win32.c +++ b/winpr/libwinpr/wtsapi/wtsapi_win32.c @@ -89,17 +89,29 @@ BOOL WINAPI Win32_WTSVirtualChannelClose(HANDLE hChannel); static void *_wts_malloc(size_t size) { +#ifdef _UWP + return malloc(size); +#else return (PVOID)LocalAlloc(LMEM_FIXED, size); +#endif } static void *_wts_calloc(size_t nmemb, size_t size) { +#ifdef _UWP + return calloc(nmemb, size); +#else return (PVOID)LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, nmemb * size); +#endif } static void _wts_free(void* ptr) { +#ifdef _UWP + free(ptr); +#else LocalFree((HLOCAL)ptr); +#endif } BOOL Win32_WTSVirtualChannelReadAsync(WTSAPI_CHANNEL* pChannel)