From ca53e78f7daef5f3e4cd9e024a05a4cb32e07d88 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 19 May 2023 22:02:44 +0200 Subject: [PATCH] fix unrar deps errors when cross-compiling with mingw --- deps/unrar/isnt.cpp | 14 ++++++++++---- deps/unrar/os.hpp | 7 ++++++- deps/unrar/scantree.cpp | 8 +++++--- src/Makefile | 1 + 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/deps/unrar/isnt.cpp b/deps/unrar/isnt.cpp index 4b3bcc551..31da8c158 100644 --- a/deps/unrar/isnt.cpp +++ b/deps/unrar/isnt.cpp @@ -26,7 +26,7 @@ DWORD WinNT() // Replace it with documented Windows 11 check when available. #include -#include +#include #pragma comment(lib, "wbemuuid.lib") static bool WMI_IsWindows10() @@ -40,8 +40,10 @@ static bool WMI_IsWindows10() return false; IWbemServices *pSvc = NULL; - - hres = pLoc->ConnectServer(_bstr_t(L"ROOT\\CIMV2"),NULL,NULL,NULL,NULL,0,0,&pSvc); + + BSTR bstr_root_cimv2 = SysAllocString(L"ROOT\\CIMV2"); + + hres = pLoc->ConnectServer(bstr_root_cimv2,NULL,NULL,NULL,0,0,0,&pSvc); if (FAILED(hres)) { @@ -60,7 +62,11 @@ static bool WMI_IsWindows10() } IEnumWbemClassObject *pEnumerator = NULL; - hres = pSvc->ExecQuery(bstr_t("WQL"), bstr_t("SELECT * FROM Win32_OperatingSystem"), + + BSTR bstr_wql = SysAllocString(L"WQL"); + BSTR bstr_sql = SysAllocString(L"SELECT * FROM Win32_OperatingSystem"); + + hres = pSvc->ExecQuery(bstr_wql, bstr_sql, WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator); if (FAILED(hres)) diff --git a/deps/unrar/os.hpp b/deps/unrar/os.hpp index 4b21e49d7..8b2cdc42d 100644 --- a/deps/unrar/os.hpp +++ b/deps/unrar/os.hpp @@ -41,6 +41,11 @@ #define _UNICODE // Set _T() macro to convert from narrow to wide strings. #endif + +#ifdef _WIN32_WINNT +#undef _WIN32_WINNT +#endif + #if 0 // 2021.09.05: Allow newer Vista+ APIs like IFileOpenDialog for WinRAR, // but still keep SFX modules XP compatible. @@ -61,7 +66,7 @@ #include #include #pragma comment(lib, "Shlwapi.lib") -#include +#include #pragma comment(lib, "PowrProf.lib") #include #include diff --git a/deps/unrar/scantree.cpp b/deps/unrar/scantree.cpp index dbaf1e427..03c830e71 100644 --- a/deps/unrar/scantree.cpp +++ b/deps/unrar/scantree.cpp @@ -215,9 +215,11 @@ bool ScanTree::GetNextMask() UnixSlashToDos(CurMask,CurMask,ASIZE(CurMask)); #endif - // We prefer to scan entire disk if mask like \\server\share\ or c:\ - // is specified regardless of recursion mode. Use \\server\share\*.* - // or c:\*.* mask to scan only the root directory. + /* + We prefer to scan entire disk if mask like \\server\share\ or c:\ + is specified regardless of recursion mode. Use \\server\share\*.* + or c:\*.* mask to scan only the root directory. + */ if (CurMask[0]=='\\' && CurMask[1]=='\\') { const wchar *Slash=wcschr(CurMask+2,'\\'); diff --git a/src/Makefile b/src/Makefile index 57329aa89..76b79b284 100644 --- a/src/Makefile +++ b/src/Makefile @@ -752,6 +752,7 @@ LFLAGS_CROSS_WIN += -lpsapi LFLAGS_CROSS_WIN += -lws2_32 LFLAGS_CROSS_WIN += -lpowrprof LFLAGS_CROSS_WIN += -static -static-libgcc -static-libstdc++ +LFLAGS_CROSS_WIN += -lole32 -loleaut32 -lwbemuuid ## ## Targets