From: Marc-André Moreau Date: Tue, 29 Mar 2016 20:03:15 +0000 (-0400) Subject: freerdp: UWP porting X-Git-Tag: 2.0.0-beta1+android10~223^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4d629a799913caaafeaa11bc35072e4066a35c92;p=platform%2Fupstream%2Ffreerdp.git freerdp: UWP porting --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 79a4657..e7c569c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,12 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) # Include our extra modules set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/) +if((CMAKE_SYSTEM_NAME MATCHES "WindowsStore") AND (CMAKE_SYSTEM_VERSION MATCHES "10.0")) + set(UWP 1) + add_definitions("-D_UWP") + set(CMAKE_WINDOWS_VERSION "WIN10") +endif() + # Check for cmake compatibility (enable/disable features) include(CheckCmakeCompat) @@ -323,6 +329,7 @@ if(WIN32) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNICODE -D_UNICODE") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32_LEAN_AND_MEAN") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_WINSOCK_DEPRECATED_NO_WARNINGS") set(CMAKE_USE_RELATIVE_PATH ON) if (${CMAKE_GENERATOR} MATCHES "NMake Makefile*") @@ -354,6 +361,9 @@ if(WIN32) elseif(CMAKE_WINDOWS_VERSION STREQUAL "WIN8") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINVER=0x0602 -D_WIN32_WINNT=0x0602") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWINVER=0x0602 -D_WIN32_WINNT=0x0602") + elseif(CMAKE_WINDOWS_VERSION STREQUAL "WIN10") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINVER=0x0A00 -D_WIN32_WINNT=0x0A00") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWINVER=0x0A00 -D_WIN32_WINNT=0x0A00") endif() if (FREERDP_EXTERNAL_SSL_PATH) diff --git a/channels/drive/client/dirent.h b/channels/drive/client/dirent.h index d9efa36..7c61d6a 100644 --- a/channels/drive/client/dirent.h +++ b/channels/drive/client/dirent.h @@ -222,7 +222,7 @@ static DIR *opendir(const char *dirname) * allows rewinddir() to function correctly when the current working * directory is changed between opendir() and rewinddir(). */ - if (GetFullPathNameA (dirname, MAX_PATH, dirp->patt, NULL)) { + if (GetFullPathNameA(dirname, MAX_PATH, dirp->patt, NULL)) { char *p; /* append the search pattern "\\*\0" to the directory name */ @@ -234,7 +234,7 @@ static DIR *opendir(const char *dirname) *p = '\0'; /* open directory stream and retrieve the first entry */ - dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->find_data); + dirp->search_handle = FindFirstFileA(dirp->patt, &dirp->find_data); if (dirp->search_handle != INVALID_HANDLE_VALUE) { /* a directory entry is now waiting in memory */ dirp->cached = 1; diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index f1ad8bf..2bff792 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -43,6 +43,7 @@ #include #include +#include #include #include diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index 39ed054..6e858db 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -38,10 +38,12 @@ #include #include +#include #include #include #include #include +#include #include #include @@ -936,7 +938,9 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) /* Special case: path[0] == '%' -> user home dir */ if (strcmp(drive->Path, "%") == 0) { - sprintf_s(buf, sizeof(buf), "%s\\", getenv("USERPROFILE")); + GetEnvironmentVariableA("USERPROFILE", buf, sizeof(buf)); + PathCchAddBackslashA(buf, sizeof(buf)); + free(drive->Path); drive->Path = _strdup(buf); if (!drive->Path) diff --git a/channels/printer/client/CMakeLists.txt b/channels/printer/client/CMakeLists.txt index b433d8a..94c3cb0 100644 --- a/channels/printer/client/CMakeLists.txt +++ b/channels/printer/client/CMakeLists.txt @@ -30,7 +30,7 @@ if(WITH_CUPS) add_definitions(-DWITH_CUPS) endif() -if(WIN32) +if(WIN32 AND NOT UWP) set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} printer_win.c printer_win.h) diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index d18cc5b..e4da463 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -110,7 +110,24 @@ static UINT rdpdr_send_device_list_remove_request(rdpdrPlugin* rdpdr, UINT32 cou return rdpdr_send(rdpdr, s); } -#ifdef _WIN32 +#ifdef _UWP + +void first_hotplug(rdpdrPlugin *rdpdr) +{ + +} + +static void* drive_hotplug_thread_func(void* arg) +{ + return NULL; +} + +static UINT drive_hotplug_thread_terminate(rdpdrPlugin* rdpdr) +{ + return CHANNEL_RC_OK; +} + +#elif _WIN32 BOOL check_path(char* path) { diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index bb8e4f6..166847e 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -20,8 +20,8 @@ add_subdirectory(common) if(FREERDP_VENDOR AND WITH_CLIENT) - if(WIN32) - add_subdirectory(Windows) + if(WIN32 AND NOT UWP) + add_subdirectory(Windows) else() if(WITH_SAMPLE) add_subdirectory(Sample) diff --git a/cmake/ConfigOptions.cmake b/cmake/ConfigOptions.cmake index 19db014..8b25a25 100644 --- a/cmake/ConfigOptions.cmake +++ b/cmake/ConfigOptions.cmake @@ -44,10 +44,12 @@ endif() if(NOT WIN32) option(WITH_VALGRIND_MEMCHECK "Compile with valgrind helpers." OFF) else() - option(WITH_MEDIA_FOUNDATION "Enable H264 media foundation decoder." ON) + if(NOT UWP) + option(WITH_MEDIA_FOUNDATION "Enable H264 media foundation decoder." ON) + endif() endif() -if(MSVC) +if(WIN32 AND NOT UWP) option(WITH_NATIVE_SSPI "Use native SSPI modules" ON) option(WITH_WINMM "Use Windows Multimedia" ON) option(WITH_WIN8 "Use Windows 8 libraries" OFF) diff --git a/libfreerdp/codec/h264.c b/libfreerdp/codec/h264.c index 230b3ab..82dd6d3 100644 --- a/libfreerdp/codec/h264.c +++ b/libfreerdp/codec/h264.c @@ -23,6 +23,7 @@ #include #include +#include #include #include diff --git a/libfreerdp/locale/locale.c b/libfreerdp/locale/locale.c index 4b7b5d4..1833a4f 100644 --- a/libfreerdp/locale/locale.c +++ b/libfreerdp/locale/locale.c @@ -26,6 +26,7 @@ #include #include +#include #include "liblocale.h" @@ -633,19 +634,28 @@ static const LOCALE_KEYBOARD_LAYOUTS LOCALE_KEYBOARD_LAYOUTS_TABLE[] = BOOL freerdp_get_system_language_and_country_codes(char* language, char* country) { int dot; + DWORD nSize; int underscore; - char* env_lang; + char* env_lang = NULL; /* LANG = _. */ - env_lang = getenv("LANG"); /* Get locale from environment variable LANG */ + nSize = GetEnvironmentVariableA("LANG", NULL, 0); - if (env_lang == NULL) + if (!nSize) return FALSE; /* LANG environment variable was not set */ + env_lang = (char*) malloc(nSize); + + if (!env_lang) + return FALSE; + + GetEnvironmentVariableA("LANG", env_lang, nSize); /* Get locale from environment variable LANG */ + underscore = strcspn(env_lang, "_"); if (underscore > 3) { + free(env_lang); return FALSE; /* The language name should not be more than 3 letters long */ } else @@ -665,9 +675,11 @@ BOOL freerdp_get_system_language_and_country_codes(char* language, char* country } else { + free(env_lang); return FALSE; /* Invalid locale */ } + free(env_lang); return TRUE; } diff --git a/winpr/include/winpr/dsparse.h b/winpr/include/winpr/dsparse.h index 9145587..f93afee 100644 --- a/winpr/include/winpr/dsparse.h +++ b/winpr/include/winpr/dsparse.h @@ -20,7 +20,7 @@ #ifndef WINPR_DSPARSE_H #define WINPR_DSPARSE_H -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_UWP) #include #include diff --git a/winpr/include/winpr/file.h b/winpr/include/winpr/file.h index 386705e..f8d33d8 100644 --- a/winpr/include/winpr/file.h +++ b/winpr/include/winpr/file.h @@ -350,6 +350,27 @@ typedef struct _HANDLE_CREATOR #endif /* _WIN32 */ +#ifdef _UWP + +#ifdef __cplusplus +extern "C" { +#endif + +WINPR_API HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData); +WINPR_API HANDLE FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData); + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define FindFirstFile FindFirstFileW +#else +#define FindFirstFile FindFirstFileA +#endif + +#endif + #define WILDCARD_STAR 0x00000001 #define WILDCARD_QM 0x00000002 #define WILDCARD_DOS 0x00000100 diff --git a/winpr/include/winpr/io.h b/winpr/include/winpr/io.h index 502debe..d125c7d 100644 --- a/winpr/include/winpr/io.h +++ b/winpr/include/winpr/io.h @@ -187,6 +187,37 @@ WINPR_API VOID _IoDeleteDeviceEx(PDEVICE_OBJECT_EX DeviceObject); #endif +#ifdef _UWP + +#ifdef __cplusplus +extern "C" { +#endif + +WINPR_API BOOL GetOverlappedResult(HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait); + +WINPR_API BOOL DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, + LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped); + +WINPR_API HANDLE CreateIoCompletionPort(HANDLE FileHandle, HANDLE ExistingCompletionPort, ULONG_PTR CompletionKey, DWORD NumberOfConcurrentThreads); + +WINPR_API BOOL GetQueuedCompletionStatus(HANDLE CompletionPort, LPDWORD lpNumberOfBytesTransferred, + PULONG_PTR lpCompletionKey, LPOVERLAPPED* lpOverlapped, DWORD dwMilliseconds); + +WINPR_API BOOL GetQueuedCompletionStatusEx(HANDLE CompletionPort, LPOVERLAPPED_ENTRY lpCompletionPortEntries, + ULONG ulCount, PULONG ulNumEntriesRemoved, DWORD dwMilliseconds, BOOL fAlertable); + +WINPR_API BOOL PostQueuedCompletionStatus(HANDLE CompletionPort, DWORD dwNumberOfBytesTransferred, ULONG_PTR dwCompletionKey, LPOVERLAPPED lpOverlapped); + +WINPR_API BOOL CancelIo(HANDLE hFile); + +WINPR_API BOOL CancelSynchronousIo(HANDLE hThread); + +#ifdef __cplusplus +} +#endif + +#endif + /** * Extended API */ diff --git a/winpr/include/winpr/nt.h b/winpr/include/winpr/nt.h index 95693cc..f16ffaf 100644 --- a/winpr/include/winpr/nt.h +++ b/winpr/include/winpr/nt.h @@ -89,7 +89,7 @@ /* Defined in wincred.h, do not redefine */ -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_UWP) #include @@ -1421,7 +1421,11 @@ typedef struct _IO_STATUS_BLOCK { union { +#ifdef _WIN32 + NTSTATUS Status; +#else NTSTATUS status; +#endif PVOID Pointer; }; ULONG_PTR Information; diff --git a/winpr/include/winpr/registry.h b/winpr/include/winpr/registry.h index 229bc6f..1102b04 100644 --- a/winpr/include/winpr/registry.h +++ b/winpr/include/winpr/registry.h @@ -22,7 +22,7 @@ #include -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_UWP) #include @@ -39,6 +39,8 @@ extern "C" { #include #include +#ifndef _WIN32 + #define OWNER_SECURITY_INFORMATION 0x00000001 #define GROUP_SECURITY_INFORMATION 0x00000002 #define DACL_SECURITY_INFORMATION 0x00000004 @@ -105,6 +107,8 @@ extern "C" { typedef HANDLE HKEY; typedef HANDLE* PHKEY; +#endif + typedef ACCESS_MASK REGSAM; #define HKEY_CLASSES_ROOT ((HKEY) (LONG_PTR) (LONG) 0x80000000) diff --git a/winpr/include/winpr/rpc.h b/winpr/include/winpr/rpc.h index 428ebf7..ec2716f 100644 --- a/winpr/include/winpr/rpc.h +++ b/winpr/include/winpr/rpc.h @@ -34,7 +34,7 @@ typedef PCONTEXT_HANDLE PTUNNEL_CONTEXT_HANDLE_SERIALIZE; typedef PCONTEXT_HANDLE PCHANNEL_CONTEXT_HANDLE_NOSERIALIZE; typedef PCONTEXT_HANDLE PCHANNEL_CONTEXT_HANDLE_SERIALIZE; -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_UWP) #include @@ -72,8 +72,10 @@ typedef PCONTEXT_HANDLE PCHANNEL_CONTEXT_HANDLE_SERIALIZE; typedef long RPC_STATUS; +#ifndef _WIN32 typedef CHAR* RPC_CSTR; typedef WCHAR* RPC_WSTR; +#endif typedef void* I_RPC_HANDLE; typedef I_RPC_HANDLE RPC_BINDING_HANDLE; @@ -197,6 +199,8 @@ typedef struct RPC_IF_ID *IfId[1]; } RPC_IF_ID_VECTOR; +#ifndef _WIN32 + typedef void *RPC_AUTH_IDENTITY_HANDLE; typedef void *RPC_AUTHZ_HANDLE; @@ -371,6 +375,8 @@ typedef void (*RPC_HTTP_PROXY_FREE_STRING)(unsigned short* String); #define RPC_C_AUTHZ_DCE 2 #define RPC_C_AUTHZ_DEFAULT 0xFFFFFFFF +#endif + typedef void (*RPC_AUTH_KEY_RETRIEVAL_FN)(void* Arg, unsigned short* ServerPrincName, unsigned long KeyVer, void** Key, RPC_STATUS* pStatus); #define DCE_C_ERROR_STRING_LEN 256 diff --git a/winpr/include/winpr/schannel.h b/winpr/include/winpr/schannel.h index b1afab8..118f627 100644 --- a/winpr/include/winpr/schannel.h +++ b/winpr/include/winpr/schannel.h @@ -23,7 +23,7 @@ #include #include -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_UWP) #include diff --git a/winpr/include/winpr/sspi.h b/winpr/include/winpr/sspi.h index 8ce7831..f069fb2 100644 --- a/winpr/include/winpr/sspi.h +++ b/winpr/include/winpr/sspi.h @@ -36,7 +36,7 @@ #endif -#ifndef _WIN32 +#if !defined(_WIN32) || defined(_UWP) #ifndef SEC_ENTRY #define SEC_ENTRY @@ -55,7 +55,10 @@ typedef struct _SECURITY_INTEGER SECURITY_INTEGER; typedef SECURITY_INTEGER TimeStamp; typedef SECURITY_INTEGER* PTimeStamp; -typedef UINT32 SECURITY_STATUS; +#ifndef __SECSTATUS_DEFINED__ +typedef LONG SECURITY_STATUS; +#define __SECSTATUS_DEFINED__ +#endif struct _SecPkgInfoA { @@ -252,7 +255,7 @@ typedef SecPkgInfoW* PSecPkgInfoW; #define SECPKG_ATTR_NEGO_STATUS 32 #define SECPKG_ATTR_CONTEXT_DELETED 33 -#ifndef _WIN32 +#if !defined(_WIN32) || defined(_UWP) struct _SecPkgContext_AccessToken { @@ -579,7 +582,10 @@ typedef SecPkgCredentials_NamesW* PSecPkgCredentials_NamesW; #define SEC_WINNT_AUTH_IDENTITY_ANSI 0x1 #define SEC_WINNT_AUTH_IDENTITY_UNICODE 0x2 -#ifndef _WIN32 +#if !defined(_WIN32) || defined(_UWP) + +#ifndef _AUTH_IDENTITY_DEFINED +#define _AUTH_IDENTITY_DEFINED typedef struct _SEC_WINNT_AUTH_IDENTITY_W { @@ -615,6 +621,8 @@ struct _SEC_WINNT_AUTH_IDENTITY }; typedef struct _SEC_WINNT_AUTH_IDENTITY SEC_WINNT_AUTH_IDENTITY; +#endif /* _AUTH_IDENTITY_DEFINED */ + struct _SecHandle { ULONG_PTR dwLower; @@ -665,7 +673,7 @@ typedef CtxtHandle* PCtxtHandle; #define SECBUFFER_READONLY_WITH_CHECKSUM 0x10000000 #define SECBUFFER_RESERVED 0x60000000 -#ifndef _WIN32 +#if !defined(_WIN32) || defined(_UWP) struct _SecBuffer { diff --git a/winpr/include/winpr/sysinfo.h b/winpr/include/winpr/sysinfo.h index faf1be8..c62c636 100644 --- a/winpr/include/winpr/sysinfo.h +++ b/winpr/include/winpr/sysinfo.h @@ -94,8 +94,6 @@ typedef struct _SYSTEM_INFO WORD wProcessorRevision; } SYSTEM_INFO, *LPSYSTEM_INFO; -#define MAX_COMPUTERNAME_LENGTH 31 - WINPR_API void GetSystemInfo(LPSYSTEM_INFO lpSystemInfo); WINPR_API void GetNativeSystemInfo(LPSYSTEM_INFO lpSystemInfo); @@ -185,15 +183,6 @@ typedef struct _OSVERSIONINFOEXW #define VER_NT_SERVER 0x0000003 #define VER_NT_WORKSTATION 0x0000001 -WINPR_API BOOL GetVersionExA(LPOSVERSIONINFOA lpVersionInformation); -WINPR_API BOOL GetVersionExW(LPOSVERSIONINFOW lpVersionInformation); - -#ifdef UNICODE -#define GetVersionEx GetVersionExW -#else -#define GetVersionEx GetVersionExA -#endif - WINPR_API void GetSystemTime(LPSYSTEMTIME lpSystemTime); WINPR_API BOOL SetSystemTime(CONST SYSTEMTIME* lpSystemTime); WINPR_API VOID GetLocalTime(LPSYSTEMTIME lpSystemTime); @@ -269,6 +258,19 @@ WINPR_API BOOL IsProcessorFeaturePresent(DWORD ProcessorFeature); #if !defined(_WIN32) || defined(_UWP) +WINPR_API BOOL GetVersionExA(LPOSVERSIONINFOA lpVersionInformation); +WINPR_API BOOL GetVersionExW(LPOSVERSIONINFOW lpVersionInformation); + +#ifdef UNICODE +#define GetVersionEx GetVersionExW +#else +#define GetVersionEx GetVersionExA +#endif + +#endif + +#if !defined(_WIN32) || defined(_UWP) + WINPR_API DWORD GetTickCount(void); typedef enum _COMPUTER_NAME_FORMAT @@ -284,6 +286,8 @@ typedef enum _COMPUTER_NAME_FORMAT ComputerNameMax } COMPUTER_NAME_FORMAT; +#define MAX_COMPUTERNAME_LENGTH 31 + WINPR_API BOOL GetComputerNameExA(COMPUTER_NAME_FORMAT NameType, LPSTR lpBuffer, LPDWORD lpnSize); WINPR_API BOOL GetComputerNameExW(COMPUTER_NAME_FORMAT NameType, LPWSTR lpBuffer, LPDWORD lpnSize); diff --git a/winpr/include/winpr/winhttp.h b/winpr/include/winpr/winhttp.h index 07762bc..462e917 100644 --- a/winpr/include/winpr/winhttp.h +++ b/winpr/include/winpr/winhttp.h @@ -24,7 +24,7 @@ #include #include -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_UWP) #include diff --git a/winpr/include/winpr/wtsapi.h b/winpr/include/winpr/wtsapi.h index 4b83c5e..a623a33 100644 --- a/winpr/include/winpr/wtsapi.h +++ b/winpr/include/winpr/wtsapi.h @@ -33,7 +33,7 @@ #endif -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_UWP) #include diff --git a/winpr/libwinpr/dsparse/dsparse.c b/winpr/libwinpr/dsparse/dsparse.c index 5d8b0aa..0a09bbf 100644 --- a/winpr/libwinpr/dsparse/dsparse.c +++ b/winpr/libwinpr/dsparse/dsparse.c @@ -43,7 +43,7 @@ * DsUnquoteRdnValueW */ -#ifndef _WIN32 +#if !defined(_WIN32) || defined(_UWP) DWORD DsCrackSpnW(LPCWSTR pszSpn, DWORD* pcServiceClass, LPWSTR ServiceClass, DWORD* pcServiceName, LPWSTR ServiceName, DWORD* pcInstanceName, LPWSTR InstanceName, USHORT* pInstancePort) @@ -73,8 +73,8 @@ DWORD DsMakeSpnA(LPCSTR ServiceClass, LPCSTR ServiceName, LPCSTR InstanceName, if ((*pcSpnLength != 0) && (pszSpn == NULL)) return ERROR_INVALID_PARAMETER; - ServiceClassLength = strlen(ServiceClass); - ServiceNameLength = strlen(ServiceName); + ServiceClassLength = (DWORD) strlen(ServiceClass); + ServiceNameLength = (DWORD) strlen(ServiceName); SpnLength = ServiceClassLength + 1 + ServiceNameLength + 1; diff --git a/winpr/libwinpr/file/file.c b/winpr/libwinpr/file/file.c index d8008ac..dea02d4 100644 --- a/winpr/libwinpr/file/file.c +++ b/winpr/libwinpr/file/file.c @@ -702,6 +702,20 @@ BOOL SetStdHandleEx(DWORD dwStdHandle, HANDLE hNewHandle, HANDLE* phOldHandle) #endif /* _WIN32 */ +#ifdef _UWP + +HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData) +{ + return FindFirstFileExA(lpFileName, FindExInfoStandard, lpFindFileData, FindExSearchNameMatch, NULL, 0); +} + +HANDLE FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData) +{ + return FindFirstFileExW(lpFileName, FindExInfoStandard, lpFindFileData, FindExSearchNameMatch, NULL, 0); +} + +#endif + /* Extended API */ #ifdef _WIN32 diff --git a/winpr/libwinpr/io/io.c b/winpr/libwinpr/io/io.c index 4340320..7b114ac 100644 --- a/winpr/libwinpr/io/io.c +++ b/winpr/libwinpr/io/io.c @@ -169,3 +169,50 @@ BOOL CancelSynchronousIo(HANDLE hThread) } #endif + +#ifdef _UWP + +BOOL GetOverlappedResult(HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait) +{ + return GetOverlappedResultEx(hFile, lpOverlapped, lpNumberOfBytesTransferred, bWait ? INFINITE : 0, TRUE); +} + +BOOL DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, + LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped) +{ + return TRUE; +} + +HANDLE CreateIoCompletionPort(HANDLE FileHandle, HANDLE ExistingCompletionPort, ULONG_PTR CompletionKey, DWORD NumberOfConcurrentThreads) +{ + return NULL; +} + +BOOL GetQueuedCompletionStatus(HANDLE CompletionPort, LPDWORD lpNumberOfBytesTransferred, + PULONG_PTR lpCompletionKey, LPOVERLAPPED* lpOverlapped, DWORD dwMilliseconds) +{ + return TRUE; +} + +BOOL GetQueuedCompletionStatusEx(HANDLE CompletionPort, LPOVERLAPPED_ENTRY lpCompletionPortEntries, + ULONG ulCount, PULONG ulNumEntriesRemoved, DWORD dwMilliseconds, BOOL fAlertable) +{ + return TRUE; +} + +BOOL PostQueuedCompletionStatus(HANDLE CompletionPort, DWORD dwNumberOfBytesTransferred, ULONG_PTR dwCompletionKey, LPOVERLAPPED lpOverlapped) +{ + return TRUE; +} + +BOOL CancelIo(HANDLE hFile) +{ + return CancelIoEx(hFile, NULL); +} + +BOOL CancelSynchronousIo(HANDLE hThread) +{ + return TRUE; +} + +#endif diff --git a/winpr/libwinpr/registry/registry.c b/winpr/libwinpr/registry/registry.c index 9e40509..32d5f8f 100644 --- a/winpr/libwinpr/registry/registry.c +++ b/winpr/libwinpr/registry/registry.c @@ -29,7 +29,7 @@ * Functions: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724875/ */ -#ifndef _WIN32 +#if !defined(_WIN32) || defined(_UWP) #include #include @@ -224,7 +224,7 @@ LONG RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesire { if (_stricmp(pKey->subname, lpSubKey) == 0) { - *phkResult = pKey; + *phkResult = (HKEY) pKey; return ERROR_SUCCESS; } @@ -294,7 +294,7 @@ LONG RegQueryValueExA(HKEY hKey, LPCSTR lpValueName, int length; char* pData = (char*) lpData; - length = strlen(pValue->data.string); + length = (int) strlen(pValue->data.string); if (pData != NULL) { diff --git a/winpr/libwinpr/rpc/rpc.c b/winpr/libwinpr/rpc/rpc.c index 82da88a..03eaca2 100644 --- a/winpr/libwinpr/rpc/rpc.c +++ b/winpr/libwinpr/rpc/rpc.c @@ -25,7 +25,7 @@ #include #include -#ifndef _WIN32 +#if !defined(_WIN32) || defined(_UWP) #include "../log.h" #define TAG WINPR_TAG("rpc") diff --git a/winpr/libwinpr/sspi/NTLM/ntlm.c b/winpr/libwinpr/sspi/NTLM/ntlm.c index 0602466..05c7bab 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm.c @@ -81,7 +81,7 @@ int ntlm_SetContextServicePrincipalNameW(NTLM_CONTEXT* context, LPWSTR ServicePr return 1; } - context->ServicePrincipalName.Length = _wcslen(ServicePrincipalName) * 2; + context->ServicePrincipalName.Length = (USHORT) (_wcslen(ServicePrincipalName) * 2); context->ServicePrincipalName.Buffer = (PWSTR) malloc(context->ServicePrincipalName.Length + 2); if (!context->ServicePrincipalName.Buffer) diff --git a/winpr/libwinpr/sysinfo/sysinfo.c b/winpr/libwinpr/sysinfo/sysinfo.c index 2d577b0..611690d 100644 --- a/winpr/libwinpr/sysinfo/sysinfo.c +++ b/winpr/libwinpr/sysinfo/sysinfo.c @@ -174,44 +174,6 @@ void GetNativeSystemInfo(LPSYSTEM_INFO lpSystemInfo) GetSystemInfo(lpSystemInfo); } -/* OSVERSIONINFOEX Structure: - * http://msdn.microsoft.com/en-us/library/windows/desktop/ms724833 - */ - -BOOL GetVersionExA(LPOSVERSIONINFOA lpVersionInformation) -{ - /* Windows 7 SP1 Version Info */ - if ((lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOA)) || - (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA))) - { - lpVersionInformation->dwMajorVersion = 6; - lpVersionInformation->dwMinorVersion = 1; - lpVersionInformation->dwBuildNumber = 7601; - lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT; - ZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion)); - - if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA)) - { - LPOSVERSIONINFOEXA lpVersionInformationEx = (LPOSVERSIONINFOEXA) lpVersionInformation; - lpVersionInformationEx->wServicePackMajor = 1; - lpVersionInformationEx->wServicePackMinor = 0; - lpVersionInformationEx->wSuiteMask = 0; - lpVersionInformationEx->wProductType = VER_NT_WORKSTATION; - lpVersionInformationEx->wReserved = 0; - } - - return TRUE; - } - - return FALSE; -} - -BOOL GetVersionExW(LPOSVERSIONINFOW lpVersionInformation) -{ - WLog_ERR(TAG, "GetVersionExW unimplemented"); - return TRUE; -} - void GetSystemTime(LPSYSTEMTIME lpSystemTime) { time_t ct = 0; @@ -314,6 +276,73 @@ DWORD GetTickCount(void) #if !defined(_WIN32) || defined(_UWP) +/* OSVERSIONINFOEX Structure: +* http://msdn.microsoft.com/en-us/library/windows/desktop/ms724833 +*/ + +BOOL GetVersionExA(LPOSVERSIONINFOA lpVersionInformation) +{ +#ifdef _UWP + /* Windows 10 Version Info */ + if ((lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOA)) || + (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA))) + { + lpVersionInformation->dwMajorVersion = 10; + lpVersionInformation->dwMinorVersion = 0; + lpVersionInformation->dwBuildNumber = 0; + lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT; + ZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion)); + + if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA)) + { + LPOSVERSIONINFOEXA lpVersionInformationEx = (LPOSVERSIONINFOEXA)lpVersionInformation; + lpVersionInformationEx->wServicePackMajor = 0; + lpVersionInformationEx->wServicePackMinor = 0; + lpVersionInformationEx->wSuiteMask = 0; + lpVersionInformationEx->wProductType = VER_NT_WORKSTATION; + lpVersionInformationEx->wReserved = 0; + } + + return TRUE; + } +#else + /* Windows 7 SP1 Version Info */ + if ((lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOA)) || + (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA))) + { + lpVersionInformation->dwMajorVersion = 6; + lpVersionInformation->dwMinorVersion = 1; + lpVersionInformation->dwBuildNumber = 7601; + lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT; + ZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion)); + + if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA)) + { + LPOSVERSIONINFOEXA lpVersionInformationEx = (LPOSVERSIONINFOEXA)lpVersionInformation; + lpVersionInformationEx->wServicePackMajor = 1; + lpVersionInformationEx->wServicePackMinor = 0; + lpVersionInformationEx->wSuiteMask = 0; + lpVersionInformationEx->wProductType = VER_NT_WORKSTATION; + lpVersionInformationEx->wReserved = 0; + } + + return TRUE; + } +#endif + + return FALSE; +} + +BOOL GetVersionExW(LPOSVERSIONINFOW lpVersionInformation) +{ + ZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion)); + return GetVersionExA((LPOSVERSIONINFOA) lpVersionInformation); +} + +#endif + +#if !defined(_WIN32) || defined(_UWP) + BOOL GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize) { char* dot; diff --git a/winpr/libwinpr/wtsapi/wtsapi_win32.c b/winpr/libwinpr/wtsapi/wtsapi_win32.c index 998ccfb..d6d708c 100644 --- a/winpr/libwinpr/wtsapi/wtsapi_win32.c +++ b/winpr/libwinpr/wtsapi/wtsapi_win32.c @@ -660,7 +660,7 @@ BOOL WINAPI Win32_WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLAS else if (WtsVirtualClass == WTSVirtualFileHandle) { *pBytesReturned = sizeof(HANDLE); - *ppBuffer = LocalAlloc(LMEM_ZEROINIT, *pBytesReturned); + *ppBuffer = calloc(1, *pBytesReturned); if (*ppBuffer == NULL) { @@ -673,7 +673,7 @@ BOOL WINAPI Win32_WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLAS else if (WtsVirtualClass == WTSVirtualEventHandle) { *pBytesReturned = sizeof(HANDLE); - *ppBuffer = LocalAlloc(LMEM_ZEROINIT, *pBytesReturned); + *ppBuffer = calloc(1, *pBytesReturned); if (*ppBuffer == NULL) { @@ -697,7 +697,7 @@ BOOL WINAPI Win32_WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLAS VOID WINAPI Win32_WTSFreeMemory(PVOID pMemory) { - LocalFree(pMemory); + free(pMemory); } BOOL WINAPI Win32_WTSFreeMemoryExW(WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory, ULONG NumberOfEntries)