freerdp: more UWP porting

This commit is contained in:
Marc-André Moreau 2016-03-29 20:34:52 -04:00
parent 4d629a7999
commit cedf6d98e2
9 changed files with 262 additions and 8 deletions

View File

@ -45,7 +45,7 @@
#include "printer_main.h"
#ifdef WIN32
#if defined(_WIN32) && !defined(_UWP)
#include "printer_win.h"
#endif
@ -476,7 +476,7 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
driver = printer_cups_get_driver();
#endif
#ifdef WIN32
#if defined(_WIN32) && !defined(_UWP)
driver = printer_win_get_driver();
#endif

View File

@ -286,8 +286,8 @@ int clear_decompress(CLEAR_CONTEXT* clear, BYTE* pSrcData, UINT32 SrcSize,
UINT32 vBarHeight;
UINT32 vBarPixelCount;
UINT32 vBarShortPixelCount;
CLEAR_VBAR_ENTRY* vBarEntry;
CLEAR_VBAR_ENTRY* vBarShortEntry;
CLEAR_VBAR_ENTRY* vBarEntry = NULL;
CLEAR_VBAR_ENTRY* vBarShortEntry = NULL;
if ((bandsByteCount - suboffset) < 11)
return -1021;

View File

@ -1469,6 +1469,9 @@ int freerdp_image_copy_from_pointer_data(BYTE* pDstData, UINT32 DstFormat,
int dstBitsPerPixel;
int dstBytesPerPixel;
xorBits = xorMask;
andBits = andMask;
dstBitsPerPixel = FREERDP_PIXEL_FORMAT_DEPTH(DstFormat);
dstBytesPerPixel = (FREERDP_PIXEL_FORMAT_BPP(DstFormat) / 8);
dstFlip = FREERDP_PIXEL_FORMAT_FLIP(DstFormat);

View File

@ -938,7 +938,7 @@ INT16 progressive_rfx_srl_read(RFX_PROGRESSIVE_UPGRADE_STATE* state, UINT32 numB
mag++;
}
return sign ? -mag : mag;
return sign ? -1 * mag : mag;
}
int progressive_rfx_upgrade_state_finish(RFX_PROGRESSIVE_UPGRADE_STATE* state)

View File

@ -121,7 +121,7 @@ static int certificate_data_match_legacy(rdpCertificateStore* certificate_store,
char* data;
char* mdata;
char* pline;
char* hostname;
char* hostname = NULL;
DWORD lowSize, highSize;
UINT64 size;
size_t length;
@ -129,8 +129,10 @@ static int certificate_data_match_legacy(rdpCertificateStore* certificate_store,
/* Assure POSIX style paths, CreateFile expects either '/' or '\\' */
PathCchConvertStyleA(certificate_store->legacy_file, strlen(certificate_store->legacy_file), PATH_STYLE_UNIX);
fp = CreateFileA(certificate_store->legacy_file, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (fp == INVALID_HANDLE_VALUE)
return match;

View File

@ -437,7 +437,7 @@ void rdtk_nine_patch_free(rdtkNinePatch* ninePatch)
int rdtk_nine_patch_engine_init(rdtkEngine* engine)
{
int status;
wImage* image;
wImage* image = NULL;
rdtkNinePatch* ninePatch;
if (!engine->button9patch)

View File

@ -156,7 +156,7 @@ add_subdirectory(include)
add_subdirectory(libwinpr)
if(NOT ANDROID AND NOT IOS)
if(NOT ANDROID AND NOT IOS AND NOT UWP)
add_subdirectory(tools)
endif()

View File

@ -356,9 +356,44 @@ typedef struct _HANDLE_CREATOR
extern "C" {
#endif
WINPR_API HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
WINPR_API HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
WINPR_API DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh);
WINPR_API DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove,
PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod);
WINPR_API HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData);
WINPR_API HANDLE FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData);
WINPR_API DWORD GetFullPathNameA(LPCSTR lpFileName, DWORD nBufferLength, LPSTR lpBuffer, LPSTR* lpFilePart);
WINPR_API BOOL GetDiskFreeSpaceA(LPCSTR lpRootPathName, LPDWORD lpSectorsPerCluster,
LPDWORD lpBytesPerSector, LPDWORD lpNumberOfFreeClusters, LPDWORD lpTotalNumberOfClusters);
WINPR_API BOOL GetDiskFreeSpaceW(LPCWSTR lpRootPathName, LPDWORD lpSectorsPerCluster,
LPDWORD lpBytesPerSector, LPDWORD lpNumberOfFreeClusters, LPDWORD lpTotalNumberOfClusters);
WINPR_API DWORD GetLogicalDriveStringsA(DWORD nBufferLength, LPSTR lpBuffer);
WINPR_API DWORD GetLogicalDriveStringsW(DWORD nBufferLength, LPWSTR lpBuffer);
WINPR_API BOOL PathIsDirectoryEmptyA(LPCSTR pszPath);
WINPR_API UINT GetACP(void);
#ifdef UNICODE
#define CreateFile CreateFileW
#define FindFirstFile FindFirstFileW
#else
#define CreateFile CreateFileA
#define FindFirstFile FindFirstFileA
#endif
#ifdef __cplusplus
}
#endif

View File

@ -22,6 +22,7 @@
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include <winpr/crt.h>
#include <winpr/file.h>
#ifdef _WIN32
@ -704,6 +705,119 @@ BOOL SetStdHandleEx(DWORD dwStdHandle, HANDLE hNewHandle, HANDLE* phOldHandle)
#ifdef _UWP
HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
HANDLE hFile;
CREATEFILE2_EXTENDED_PARAMETERS params;
ZeroMemory(&params, sizeof(CREATEFILE2_EXTENDED_PARAMETERS));
params.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
if (dwFlagsAndAttributes & FILE_FLAG_BACKUP_SEMANTICS) params.dwFileFlags |= FILE_FLAG_BACKUP_SEMANTICS;
if (dwFlagsAndAttributes & FILE_FLAG_DELETE_ON_CLOSE) params.dwFileFlags |= FILE_FLAG_DELETE_ON_CLOSE;
if (dwFlagsAndAttributes & FILE_FLAG_NO_BUFFERING) params.dwFileFlags |= FILE_FLAG_NO_BUFFERING;
if (dwFlagsAndAttributes & FILE_FLAG_OPEN_NO_RECALL) params.dwFileFlags |= FILE_FLAG_OPEN_NO_RECALL;
if (dwFlagsAndAttributes & FILE_FLAG_OPEN_REPARSE_POINT) params.dwFileFlags |= FILE_FLAG_OPEN_REPARSE_POINT;
if (dwFlagsAndAttributes & FILE_FLAG_OPEN_REQUIRING_OPLOCK) params.dwFileFlags |= FILE_FLAG_OPEN_REQUIRING_OPLOCK;
if (dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED) params.dwFileFlags |= FILE_FLAG_OVERLAPPED;
if (dwFlagsAndAttributes & FILE_FLAG_POSIX_SEMANTICS) params.dwFileFlags |= FILE_FLAG_POSIX_SEMANTICS;
if (dwFlagsAndAttributes & FILE_FLAG_RANDOM_ACCESS) params.dwFileFlags |= FILE_FLAG_RANDOM_ACCESS;
if (dwFlagsAndAttributes & FILE_FLAG_SESSION_AWARE) params.dwFileFlags |= FILE_FLAG_SESSION_AWARE;
if (dwFlagsAndAttributes & FILE_FLAG_SEQUENTIAL_SCAN) params.dwFileFlags |= FILE_FLAG_SEQUENTIAL_SCAN;
if (dwFlagsAndAttributes & FILE_FLAG_WRITE_THROUGH) params.dwFileFlags |= FILE_FLAG_WRITE_THROUGH;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_ARCHIVE) params.dwFileAttributes |= FILE_ATTRIBUTE_ARCHIVE;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_COMPRESSED) params.dwFileAttributes |= FILE_ATTRIBUTE_COMPRESSED;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_DEVICE) params.dwFileAttributes |= FILE_ATTRIBUTE_DEVICE;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_DIRECTORY) params.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_ENCRYPTED) params.dwFileAttributes |= FILE_ATTRIBUTE_ENCRYPTED;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_HIDDEN) params.dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_INTEGRITY_STREAM) params.dwFileAttributes |= FILE_ATTRIBUTE_INTEGRITY_STREAM;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_NORMAL) params.dwFileAttributes |= FILE_ATTRIBUTE_NORMAL;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_NOT_CONTENT_INDEXED) params.dwFileAttributes |= FILE_ATTRIBUTE_NOT_CONTENT_INDEXED;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_NO_SCRUB_DATA) params.dwFileAttributes |= FILE_ATTRIBUTE_NO_SCRUB_DATA;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_OFFLINE) params.dwFileAttributes |= FILE_ATTRIBUTE_OFFLINE;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_READONLY) params.dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_REPARSE_POINT) params.dwFileAttributes |= FILE_ATTRIBUTE_REPARSE_POINT;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_SPARSE_FILE) params.dwFileAttributes |= FILE_ATTRIBUTE_SPARSE_FILE;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_SYSTEM) params.dwFileAttributes |= FILE_ATTRIBUTE_SYSTEM;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_TEMPORARY) params.dwFileAttributes |= FILE_ATTRIBUTE_TEMPORARY;
if (dwFlagsAndAttributes & FILE_ATTRIBUTE_VIRTUAL) params.dwFileAttributes |= FILE_ATTRIBUTE_VIRTUAL;
if (dwFlagsAndAttributes & SECURITY_ANONYMOUS) params.dwSecurityQosFlags |= SECURITY_ANONYMOUS;
if (dwFlagsAndAttributes & SECURITY_CONTEXT_TRACKING) params.dwSecurityQosFlags |= SECURITY_CONTEXT_TRACKING;
if (dwFlagsAndAttributes & SECURITY_DELEGATION) params.dwSecurityQosFlags |= SECURITY_DELEGATION;
if (dwFlagsAndAttributes & SECURITY_EFFECTIVE_ONLY) params.dwSecurityQosFlags |= SECURITY_EFFECTIVE_ONLY;
if (dwFlagsAndAttributes & SECURITY_IDENTIFICATION) params.dwSecurityQosFlags |= SECURITY_IDENTIFICATION;
if (dwFlagsAndAttributes & SECURITY_IMPERSONATION) params.dwSecurityQosFlags |= SECURITY_IMPERSONATION;
params.lpSecurityAttributes = lpSecurityAttributes;
params.hTemplateFile = hTemplateFile;
hFile = CreateFile2(lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, &params);
return hFile;
}
HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
HANDLE hFile;
WCHAR* lpFileNameW = NULL;
ConvertToUnicode(CP_UTF8, 0, lpFileName, -1, &lpFileNameW, 0);
if (!lpFileNameW)
return NULL;
hFile = CreateFileW(lpFileNameW, dwDesiredAccess, dwShareMode, lpSecurityAttributes,
dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
free(lpFileNameW);
return hFile;
}
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
{
BOOL status;
LARGE_INTEGER fileSize = { 0, 0 };
if (!lpFileSizeHigh)
return INVALID_FILE_SIZE;
status = GetFileSizeEx(hFile, &fileSize);
if (!status)
return INVALID_FILE_SIZE;
*lpFileSizeHigh = fileSize.HighPart;
return fileSize.LowPart;
}
DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove,
PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
{
BOOL status;
LARGE_INTEGER liDistanceToMove = { 0, 0 };
LARGE_INTEGER liNewFilePointer = { 0, 0 };
liDistanceToMove.LowPart = lDistanceToMove;
status = SetFilePointerEx(hFile, liDistanceToMove, &liNewFilePointer, dwMoveMethod);
if (!status)
return INVALID_SET_FILE_POINTER;
if (lpDistanceToMoveHigh)
*lpDistanceToMoveHigh = liNewFilePointer.HighPart;
return liNewFilePointer.LowPart;
}
HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData)
{
return FindFirstFileExA(lpFileName, FindExInfoStandard, lpFindFileData, FindExSearchNameMatch, NULL, 0);
@ -714,6 +828,106 @@ HANDLE FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData)
return FindFirstFileExW(lpFileName, FindExInfoStandard, lpFindFileData, FindExSearchNameMatch, NULL, 0);
}
DWORD GetFullPathNameA(LPCSTR lpFileName, DWORD nBufferLength, LPSTR lpBuffer, LPSTR* lpFilePart)
{
DWORD dwStatus;
WCHAR* lpFileNameW = NULL;
WCHAR* lpBufferW = NULL;
WCHAR* lpFilePartW = NULL;
DWORD nBufferLengthW = nBufferLength * 2;
if (!lpFileName || (nBufferLength < 1))
return 0;
ConvertToUnicode(CP_UTF8, 0, lpFileName, -1, &lpFileNameW, 0);
if (!lpFileNameW)
return 0;
lpBufferW = (WCHAR*) malloc(nBufferLengthW);
if (!lpBufferW)
return 0;
dwStatus = GetFullPathNameW(lpFileNameW, nBufferLengthW, lpBufferW, &lpFilePartW);
ConvertFromUnicode(CP_UTF8, 0, lpBufferW, nBufferLengthW, &lpBuffer, nBufferLength, NULL, NULL);
if (lpFilePart)
lpFilePart = lpBuffer + (lpFilePartW - lpBufferW);
free(lpFileNameW);
free(lpBufferW);
return dwStatus * 2;
}
BOOL GetDiskFreeSpaceA(LPCSTR lpRootPathName, LPDWORD lpSectorsPerCluster,
LPDWORD lpBytesPerSector, LPDWORD lpNumberOfFreeClusters, LPDWORD lpTotalNumberOfClusters)
{
BOOL status;
ULARGE_INTEGER FreeBytesAvailableToCaller = { 0, 0 };
ULARGE_INTEGER TotalNumberOfBytes = { 0, 0 };
ULARGE_INTEGER TotalNumberOfFreeBytes = { 0, 0 };
status = GetDiskFreeSpaceExA(lpRootPathName, &FreeBytesAvailableToCaller,
&TotalNumberOfBytes, &TotalNumberOfFreeBytes);
if (!status)
return FALSE;
*lpBytesPerSector = 1;
*lpSectorsPerCluster = TotalNumberOfBytes.LowPart;
*lpNumberOfFreeClusters = FreeBytesAvailableToCaller.LowPart;
*lpTotalNumberOfClusters = TotalNumberOfFreeBytes.LowPart;
return TRUE;
}
BOOL GetDiskFreeSpaceW(LPCWSTR lpRootPathName, LPDWORD lpSectorsPerCluster,
LPDWORD lpBytesPerSector, LPDWORD lpNumberOfFreeClusters, LPDWORD lpTotalNumberOfClusters)
{
BOOL status;
ULARGE_INTEGER FreeBytesAvailableToCaller = { 0, 0 };
ULARGE_INTEGER TotalNumberOfBytes = { 0, 0 };
ULARGE_INTEGER TotalNumberOfFreeBytes = { 0, 0 };
status = GetDiskFreeSpaceExW(lpRootPathName, &FreeBytesAvailableToCaller,
&TotalNumberOfBytes, &TotalNumberOfFreeBytes);
if (!status)
return FALSE;
*lpBytesPerSector = 1;
*lpSectorsPerCluster = TotalNumberOfBytes.LowPart;
*lpNumberOfFreeClusters = FreeBytesAvailableToCaller.LowPart;
*lpTotalNumberOfClusters = TotalNumberOfFreeBytes.LowPart;
return TRUE;
}
DWORD GetLogicalDriveStringsA(DWORD nBufferLength, LPSTR lpBuffer)
{
SetLastError(ERROR_INVALID_FUNCTION);
return 0;
}
DWORD GetLogicalDriveStringsW(DWORD nBufferLength, LPWSTR lpBuffer)
{
SetLastError(ERROR_INVALID_FUNCTION);
return 0;
}
BOOL PathIsDirectoryEmptyA(LPCSTR pszPath)
{
return FALSE;
}
UINT GetACP(void)
{
return CP_UTF8;
}
#endif
/* Extended API */