Fix compilation with mingw

This patch addresses some issues when compiling against mingw. With these changes
FreeRDP can be compiled out-of-the box on a Ubuntu 20.04.
This commit is contained in:
David Fort
2021-11-12 11:20:04 +01:00
committed by akallabeth
parent 67f632982a
commit 67986ea298
18 changed files with 162 additions and 55 deletions

View File

@@ -37,6 +37,11 @@
#include "audin_main.h"
/* fix missing definitions in mingw */
#ifndef WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE
#define WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE 0x0010
#endif
typedef struct _AudinWinmmDevice
{
IAudinDevice iface;

View File

@@ -35,8 +35,8 @@ set(${MODULE_PREFIX}_SRCS
wf_client.h
wf_floatbar.c
wf_floatbar.h
wfreerdp.rc
resource.h)
resource/wfreerdp.rc
resource/resource.h)
# On windows create dll version information.
# Vendor, product and year are already set in top level CMakeLists.txt

View File

@@ -36,7 +36,7 @@
#include <freerdp/client/channels.h>
#include <freerdp/channels/channels.h>
#include "resource.h"
#include "../resource/resource.h"
#include "wf_client.h"

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -0,0 +1,14 @@
#include "resource.h"
IDI_ICON1 ICON "FreeRDP.ico"
IDB_MINIMIZE BITMAP "minimize.bmp"
IDB_MINIMIZE_ACT BITMAP "minimize_active.bmp"
IDB_LOCK BITMAP "lock.bmp"
IDB_LOCK_ACT BITMAP "lock_active.bmp"
IDB_UNLOCK BITMAP "unlock.bmp"
IDB_UNLOCK_ACT BITMAP "unlock_active.bmp"
IDB_CLOSE BITMAP "close.bmp"
IDB_CLOSE_ACT BITMAP "close_active.bmp"
IDB_RESTORE BITMAP "restore.bmp"
IDB_RESTORE_ACT BITMAP "restore_active.bmp"

View File

@@ -64,7 +64,7 @@
#include "wf_client.h"
#include "resource.h"
#include "resource/resource.h"
#define TAG CLIENT_TAG("windows")

View File

@@ -20,10 +20,10 @@
#include <winpr/crt.h>
#include <winpr/windows.h>
#include "resource.h"
#include "wf_client.h"
#include "wf_floatbar.h"
#include "resource/resource.h"
#include "wf_gdi.h"
#ifdef _MSC_VER
#pragma comment(lib, "Msimg32.lib")

View File

@@ -1,14 +0,0 @@
#include "resource.h"
IDI_ICON1 ICON "FreeRDP.ico"
IDB_MINIMIZE BITMAP "resource\\minimize.bmp"
IDB_MINIMIZE_ACT BITMAP "resource\\minimize_active.bmp"
IDB_LOCK BITMAP "resource\\lock.bmp"
IDB_LOCK_ACT BITMAP "resource\\lock_active.bmp"
IDB_UNLOCK BITMAP "resource\\unlock.bmp"
IDB_UNLOCK_ACT BITMAP "resource\\unlock_active.bmp"
IDB_CLOSE BITMAP "resource\\close.bmp"
IDB_CLOSE_ACT BITMAP "resource\\close_active.bmp"
IDB_RESTORE BITMAP "resource\\restore.bmp"
IDB_RESTORE_ACT BITMAP "resource\\restore_active.bmp"

View File

@@ -392,6 +392,9 @@ if (WITH_LIBRARY_VERSIONING)
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION})
endif()
if (MINGW)
freerdp_library_add(ucrt)
endif()
target_link_libraries(${MODULE_NAME} PRIVATE ${LIBFREERDP_LIBS} winpr)

View File

@@ -27,6 +27,15 @@
#include <winerror.h>
/* mingw is possibly missing some definitions */
#ifndef RPC_S_PROXY_ACCESS_DENIED
#define RPC_S_PROXY_ACCESS_DENIED 0x000006C1
#endif
#ifndef RPC_S_COOKIE_AUTH_FAILED
#define RPC_S_COOKIE_AUTH_FAILED 0x00000729
#endif
#else
#ifndef NO_ERROR

View File

@@ -86,7 +86,7 @@ typedef VOID (*PTP_TIMER_CALLBACK)(PTP_CALLBACK_INSTANCE Instance, PVOID Context
typedef VOID (*PTP_WAIT_CALLBACK)(PTP_CALLBACK_INSTANCE Instance, PVOID Context, PTP_WAIT Wait,
TP_WAIT_RESULT WaitResult);
#endif
#endif /* _WIN32 not defined */
/*
There is a bug in the Win8 header that defines the IO
@@ -210,6 +210,42 @@ extern "C"
#define SetThreadpoolThreadMinimum winpr_SetThreadpoolThreadMinimum
#define SetThreadpoolThreadMaximum winpr_SetThreadpoolThreadMaximum
/* Callback */
WINPR_API BOOL winpr_CallbackMayRunLong(PTP_CALLBACK_INSTANCE pci);
/* Callback Clean-up */
WINPR_API VOID winpr_SetEventWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, HANDLE evt);
WINPR_API VOID winpr_ReleaseSemaphoreWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, HANDLE sem,
DWORD crel);
WINPR_API VOID winpr_ReleaseMutexWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, HANDLE mut);
WINPR_API VOID winpr_LeaveCriticalSectionWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci,
PCRITICAL_SECTION pcs);
WINPR_API VOID winpr_FreeLibraryWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, HMODULE mod);
WINPR_API VOID winpr_DisassociateCurrentThreadFromCallback(PTP_CALLBACK_INSTANCE pci);
#define SetEventWhenCallbackReturns winpr_SetEventWhenCallbackReturns
#define ReleaseSemaphoreWhenCallbackReturns winpr_ReleaseSemaphoreWhenCallbackReturns
#define ReleaseMutexWhenCallbackReturns winpr_ReleaseMutexWhenCallbackReturns
#define LeaveCriticalSectionWhenCallbackReturns winpr_LeaveCriticalSectionWhenCallbackReturns
#define FreeLibraryWhenCallbackReturns winpr_FreeLibraryWhenCallbackReturns
#define DisassociateCurrentThreadFromCallback winpr_DisassociateCurrentThreadFromCallback
#endif /* WINPR_THREAD_POOL */
#if !defined(_WIN32)
#define WINPR_CALLBACK_ENVIRON 1
#elif defined(_WIN32) && (_WIN32_WINNT < 0x0600)
#define WINPR_CALLBACK_ENVIRON 1
#elif defined(__MINGW32__) && (__MINGW64_VERSION_MAJOR < 9)
#define WINPR_CALLBACK_ENVIRON 1
#endif
#ifdef WINPR_CALLBACK_ENVIRON
/* some version of mingw are missing Callback Environment functions */
/* Callback Environment */
static INLINE VOID InitializeThreadpoolEnvironment(PTP_CALLBACK_ENVIRON pcbe)
@@ -243,29 +279,6 @@ extern "C"
{
pcbe->RaceDll = mod;
}
/* Callback */
WINPR_API BOOL winpr_CallbackMayRunLong(PTP_CALLBACK_INSTANCE pci);
/* Callback Clean-up */
WINPR_API VOID winpr_SetEventWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, HANDLE evt);
WINPR_API VOID winpr_ReleaseSemaphoreWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, HANDLE sem,
DWORD crel);
WINPR_API VOID winpr_ReleaseMutexWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, HANDLE mut);
WINPR_API VOID winpr_LeaveCriticalSectionWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci,
PCRITICAL_SECTION pcs);
WINPR_API VOID winpr_FreeLibraryWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, HMODULE mod);
WINPR_API VOID winpr_DisassociateCurrentThreadFromCallback(PTP_CALLBACK_INSTANCE pci);
#define SetEventWhenCallbackReturns winpr_SetEventWhenCallbackReturns
#define ReleaseSemaphoreWhenCallbackReturns winpr_ReleaseSemaphoreWhenCallbackReturns
#define ReleaseMutexWhenCallbackReturns winpr_ReleaseMutexWhenCallbackReturns
#define LeaveCriticalSectionWhenCallbackReturns winpr_LeaveCriticalSectionWhenCallbackReturns
#define FreeLibraryWhenCallbackReturns winpr_FreeLibraryWhenCallbackReturns
#define DisassociateCurrentThreadFromCallback winpr_DisassociateCurrentThreadFromCallback
#endif
#ifdef __cplusplus

View File

@@ -115,6 +115,24 @@
#endif
/* ------------------------ missing definition with mingw --------------------*/
#ifndef SCARD_E_PIN_CACHE_EXPIRED
#define SCARD_E_PIN_CACHE_EXPIRED (HRESULT)(0x80100032L)
#endif
#ifndef SCARD_E_NO_PIN_CACHE
#define SCARD_E_NO_PIN_CACHE (HRESULT)(0x80100033L)
#endif
#ifndef SCARD_E_READ_ONLY_CARD
#define SCARD_E_READ_ONLY_CARD (HRESULT)(0x80100034L)
#endif
#ifndef SCARD_W_CACHE_ITEM_TOO_BIG
#define SCARD_W_CACHE_ITEM_TOO_BIG (HRESULT)(0x80100072L)
#endif
/* -------------------------------------------------------------------------- */
#define SCARD_ATR_LENGTH 33
#define SCARD_PROTOCOL_UNDEFINED 0x00000000u

View File

@@ -965,6 +965,7 @@ extern "C++"
#endif
#if !defined(__MINGW32__)
#if defined(_WIN32) || defined(__CYGWIN__)
#ifdef __GNUC__
#define DECLSPEC_EXPORT __attribute__((dllexport))
@@ -982,5 +983,6 @@ extern "C++"
#define DECLSPEC_IMPORT
#endif
#endif
#endif
#endif /* WINPR_SPEC_H */

View File

@@ -222,6 +222,41 @@ typedef SecPkgInfoW* PSecPkgInfoW;
#endif
/* ============== some definitions missing in mingw ========================*/
#ifndef SEC_E_INVALID_PARAMETER
#define SEC_E_INVALID_PARAMETER (SECURITY_STATUS)0x8009035DL
#endif
#ifndef SEC_E_DELEGATION_POLICY
#define SEC_E_DELEGATION_POLICY (SECURITY_STATUS)0x8009035EL
#endif
#ifndef SEC_E_POLICY_NLTM_ONLY
#define SEC_E_POLICY_NLTM_ONLY (SECURITY_STATUS)0x8009035FL
#endif
#ifndef SEC_E_NO_CONTEXT
#define SEC_E_NO_CONTEXT (SECURITY_STATUS)0x80090361L
#endif
#ifndef SEC_E_PKU2U_CERT_FAILURE
#define SEC_E_PKU2U_CERT_FAILURE (SECURITY_STATUS)0x80090362L
#endif
#ifndef SEC_E_MUTUAL_AUTH_FAILED
#define SEC_E_MUTUAL_AUTH_FAILED (SECURITY_STATUS)0x80090363L
#endif
#ifndef SEC_I_SIGNATURE_NEEDED
#define SEC_I_SIGNATURE_NEEDED (SECURITY_STATUS)0x0009035CL
#endif
#ifndef SEC_I_NO_RENEGOTIATION
#define SEC_I_NO_RENEGOTIATION (SECURITY_STATUS)0x00090360L
#endif
/* ==================================================================================== */
#define SECURITY_NATIVE_DREP 0x00000010
#define SECURITY_NETWORK_DREP 0x00000000
@@ -334,13 +369,6 @@ struct _SEC_CHANNEL_BINDINGS
};
typedef struct _SEC_CHANNEL_BINDINGS SEC_CHANNEL_BINDINGS;
struct _SecPkgContext_Bindings
{
UINT32 BindingsLength;
SEC_CHANNEL_BINDINGS* Bindings;
};
typedef struct _SecPkgContext_Bindings SecPkgContext_Bindings;
struct _SecPkgContext_EapKeyBlock
{
BYTE rgbKeys[128];
@@ -485,6 +513,16 @@ typedef SecPkgCredentials_NamesW* PSecPkgCredentials_NamesW;
#endif
#if !defined(_WIN32) || defined(_UWP) || defined(__MINGW32__)
struct _SecPkgContext_Bindings
{
UINT32 BindingsLength;
SEC_CHANNEL_BINDINGS* Bindings;
};
typedef struct _SecPkgContext_Bindings SecPkgContext_Bindings;
#endif
/* InitializeSecurityContext Flags */
#define ISC_REQ_DELEGATE 0x00000001

View File

@@ -77,6 +77,20 @@ enum _NTLM_STATE
};
typedef enum _NTLM_STATE NTLM_STATE;
#ifdef __MINGW32__
typedef MSV1_0_AVID NTLM_AV_ID;
#if __MINGW64_VERSION_MAJOR < 9
enum {
MsvAvTimestamp = MsvAvFlags + 1,
MsvAvRestrictions,
MsvAvTargetName,
MsvAvChannelBindings,
MsvAvSingleHost = MsvAvRestrictions
};
#endif
#else
enum _NTLM_AV_ID
{
MsvAvEOL,
@@ -92,6 +106,7 @@ enum _NTLM_AV_ID
MsvAvChannelBindings
};
typedef enum _NTLM_AV_ID NTLM_AV_ID;
#endif /* __MINGW32__ */
struct _NTLM_AV_PAIR
{

View File

@@ -27,7 +27,7 @@
#include <winpr/assert.h>
#include <winpr/collections.h>
#if defined(_WIN32) && (_MSC_VER < 1800)
#if defined(_WIN32) && (_MSC_VER < 1800) && !defined(__MINGW32__)
#define va_copy(dest, src) (dest = src)
#endif

View File

@@ -52,9 +52,13 @@ static const WtsApiFunctionTable* g_WtsApi = NULL;
static HMODULE g_WtsApi32Module = NULL;
static WtsApiFunctionTable WtsApi32_WtsApiFunctionTable = { 0 };
#define WTSAPI32_LOAD_PROC(_name, _type) \
WtsApi32_WtsApiFunctionTable.p##_name = (##_type)GetProcAddress(g_WtsApi32Module, "WT" \
"S" #_name);
#ifdef __MINGW32__
#define WTSAPI32_LOAD_PROC(NAME, TYPE) \
WtsApi32_WtsApiFunctionTable.p##NAME = (TYPE)GetProcAddress(g_WtsApi32Module, "WTS" #NAME);
#else
#define WTSAPI32_LOAD_PROC(NAME, TYPE) \
WtsApi32_WtsApiFunctionTable.p##NAME = (##TYPE)GetProcAddress(g_WtsApi32Module, "WTS" #NAME);
#endif
static BOOL WtsApi32_InitializeWtsApi(void)
{