13 #include <string_view>
18 #if !defined WIN32_LEAN_AND_MEAN
19 #define WIN32_LEAN_AND_MEAN
30 else if (rString ==
"7")
32 else if (rString ==
"8")
34 else if (rString ==
"8_1")
36 else if (rString ==
"10")
38 else if (rString ==
"windows")
40 else if (rString ==
"linux")
42 else if (rString ==
"osx_10_5")
44 else if (rString ==
"osx_10_6")
46 else if (rString ==
"osx_10_7")
48 else if (rString ==
"osx_10_8")
50 else if (rString ==
"osx")
52 else if (rString ==
"android")
59 if (rString ==
"less")
63 else if (rString ==
"less_equal")
67 else if (rString ==
"greater")
71 else if (rString ==
"greater_equal")
75 else if (rString ==
"equal")
79 else if (rString ==
"not_equal")
83 else if (rString ==
"between_exclusive")
87 else if (rString ==
"between_inclusive")
91 else if (rString ==
"between_inclusive_start")
101 if (rString ==
"all")
105 else if (rString ==
"intel")
109 else if (rString ==
"nvidia")
113 else if (rString ==
"amd")
117 else if (rString ==
"microsoft")
124 return OStringToOUString(rString, RTL_TEXTENCODING_UTF8);
184 , mrDriverList(rDriverList)
186 , mVersionType(versionType)
212 for (
int i = 0;
i < 4;
i++)
216 for (
int c = i; c < 4; c++)
231 int len = strlen(aSource);
232 char* dest[4] = { aAStr, aBStr, aCStr, aDStr };
233 unsigned destIdx = 0;
234 unsigned destPos = 0;
236 for (
int i = 0;
i < len;
i++)
244 if (aSource[
i] ==
'.')
246 dest[destIdx++][destPos] = 0;
258 dest[destIdx][destPos++] = aSource[
i];
262 dest[destIdx][destPos] = 0;
266 dest[++destIdx][0] =
'\0';
280 char aStr[8], bStr[8], cStr[8], dStr[8];
301 if (a < 0 || a > 0xffff)
303 if (b < 0 || b > 0xffff)
305 if (c < 0 || c > 0xffff)
307 if (d < 0 || d > 0xffff)
316 OUString aString = OStringToOUString(rString, RTL_TEXTENCODING_UTF8);
351 else if (name ==
"device")
361 OStringToOUString(aDeviceId, RTL_TEXTENCODING_UTF8));
380 rDriver.
maMsg = OStringToOUString(sMsg, RTL_TEXTENCODING_UTF8);
412 else if (name ==
"vendor")
418 else if (name ==
"compare")
424 else if (name ==
"version")
430 else if (name ==
"minVersion")
436 else if (name ==
"maxVersion")
445 SAL_WARN(
"vcl.driver",
"unsupported attribute: " << aAttrName);
470 else if (name ==
"entryRange")
500 if (name ==
"allowlist")
505 else if (name ==
"denylist")
510 else if (name ==
"root")
520 if (name ==
"allowlist" || name ==
"denylist")
537 switch (DriverBlocklist::GetWindowsVersion())
559 struct compareIgnoreAsciiCase
561 explicit compareIgnoreAsciiCase(
const OUString& rString)
566 bool operator()(std::u16string_view rCompare)
568 return maString.equalsIgnoreAsciiCase(rCompare);
581 , mbAllowlisted(false)
584 , mnDriverVersionMax(0)
589 uint64_t driverVersion,
bool bAllowlisted,
590 const char* suggestedVersion )
591 : meOperatingSystem(os)
592 , maAdapterVendor(vendor)
593 , mbAllowlisted(bAllowlisted)
595 , mnDriverVersion(driverVersion)
596 , mnDriverVersionMax(0)
598 if (suggestedVersion)
600 = OStringToOUString(std::string_view(suggestedVersion), RTL_TEXTENCODING_UTF8);
604 std::u16string_view sDriverVersion,
605 std::u16string_view sAdapterVendorID,
607 const OUString& blocklistURL)
609 uint64_t driverVersion;
613 for (std::vector<DriverInfo>::size_type
i = 0;
i < aDeviceInfos.size();
i++)
615 bool osMatch =
false;
618 else if (aDeviceInfos[
i].meOperatingSystem == system)
632 && !aDeviceInfos[
i].maAdapterVendor.equalsIgnoreAsciiCase(sAdapterVendorID))
637 if (std::none_of(aDeviceInfos[
i].maDevices.begin(), aDeviceInfos[
i].maDevices.end(),
638 compareIgnoreAsciiCase(
"all"))
639 && std::none_of(aDeviceInfos[
i].maDevices.begin(), aDeviceInfos[
i].maDevices.end(),
640 compareIgnoreAsciiCase(sAdapterDeviceID)))
645 switch (aDeviceInfos[
i].meComparisonOp)
648 match = driverVersion < aDeviceInfos[
i].mnDriverVersion;
651 match = driverVersion <= aDeviceInfos[
i].mnDriverVersion;
654 match = driverVersion > aDeviceInfos[
i].mnDriverVersion;
657 match = driverVersion >= aDeviceInfos[
i].mnDriverVersion;
660 match = driverVersion == aDeviceInfos[
i].mnDriverVersion;
663 match = driverVersion != aDeviceInfos[
i].mnDriverVersion;
666 match = driverVersion > aDeviceInfos[
i].mnDriverVersion
667 && driverVersion < aDeviceInfos[
i].mnDriverVersionMax;
670 match = driverVersion >= aDeviceInfos[
i].mnDriverVersion
671 && driverVersion <= aDeviceInfos[
i].mnDriverVersionMax;
674 match = driverVersion >= aDeviceInfos[
i].mnDriverVersion
675 && driverVersion < aDeviceInfos[
i].mnDriverVersionMax;
682 SAL_WARN(
"vcl.driver",
"Bogus op in " << blocklistURL);
686 if (match || aDeviceInfos[
i].mnDriverVersion == allDriverVersions)
689 if (aDeviceInfos[
i].mbAllowlisted)
691 SAL_INFO(
"vcl.driver",
"allowlisted driver");
696 if (!aDeviceInfos[
i].maSuggestedVersion.isEmpty())
698 SAL_WARN(
"vcl.driver",
"use : " << aDeviceInfos[
i].maSuggestedVersion);
704 SAL_INFO(
"vcl.driver", (match ?
"denylisted" :
"not denylisted") <<
" in " << blocklistURL);
709 std::u16string_view driverVersion, std::u16string_view
vendorId,
710 const OUString& deviceId)
712 std::vector<DriverInfo> driverList;
716 SAL_WARN(
"vcl.driver",
"error parsing denylist " << blocklistURL);
724 int32_t GetWindowsVersion()
726 static int32_t winVersion = [&]() {
733 HINSTANCE hLibrary = LoadLibraryW(L
"kernel32.dll");
734 if (hLibrary !=
nullptr)
737 DWORD dwCount = GetModuleFileNameW(hLibrary, szPath,
SAL_N_ELEMENTS(szPath));
738 FreeLibrary(hLibrary);
741 dwCount = GetFileVersionInfoSizeW(szPath,
nullptr);
744 std::unique_ptr<char[]> ver(
new char[dwCount]);
745 if (GetFileVersionInfoW(szPath, 0, dwCount, ver.get()) != FALSE)
747 void* pBlock =
nullptr;
749 if (VerQueryValueW(ver.get(), L
"\\", &pBlock, &dwBlockSz) != FALSE
750 && dwBlockSz >=
sizeof(VS_FIXEDFILEINFO))
752 VS_FIXEDFILEINFO* vinfo =
static_cast<VS_FIXEDFILEINFO*
>(pBlock);
753 return int32_t(vinfo->dwProductVersionMS);
static OUString GetVendorId(std::string_view rString)
VersionComparisonOp meComparisonOp
std::vector< OUString > maDevices
static VersionComparisonOp getComparison(std::string_view rString)
bool FindBlocklistedDeviceInList(std::vector< DriverInfo > &aDeviceInfos, VersionType versionType, std::u16string_view sDriverVersion, std::u16string_view sAdapterVendorID, OUString const &sAdapterDeviceID, OperatingSystem system, const OUString &blocklistURL)
static void PadDriverDecimal(char *aString)
DeviceVendor GetVendorFromId(uint32_t id)
Returns vendor for the given vendor ID, or VendorAll if not known.
OUString maSuggestedVersion
bool IsDeviceBlocked(const OUString &blocklistURL, VersionType versionType, std::u16string_view driverVersion, std::u16string_view vendorId, const OUString &deviceId)
bool match(const sal_Unicode *pWild, const sal_Unicode *pStr, const sal_Unicode cEscape)
std::string_view GetVendorNameFromId(uint32_t id)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
#define GFX_DRIVER_VERSION(a, b, c, d)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
Parser(const OUString &rURL, std::vector< DriverInfo > &rDriverList, VersionType versionType)
const uint64_t allDriverVersions
const VersionType mVersionType
#define SAL_N_ELEMENTS(arr)
void handleContent(xmlreader::XmlReader &rReader)
OperatingSystem meOperatingSystem
static OperatingSystem getOperatingSystem(std::string_view rString)
uint64_t getVersion(std::string_view rString)
VCL_DLLPUBLIC uint32_t vendorId
const int DeviceVendorMax
Span getAttributeValue(bool fullyNormalize)
#define SAL_INFO(area, stream)
static void handleDevices(DriverInfo &rDriver, xmlreader::XmlReader &rReader)
uint64_t mnDriverVersionMax
void handleEntry(DriverInfo &rDriver, xmlreader::XmlReader &rReader)
void handleList(xmlreader::XmlReader &rReader)
bool nextAttribute(int *nsId, Span *localName)
#define SAL_WARN(area, stream)
Result nextItem(Text reportText, Span *data, int *nsId)
std::vector< DriverInfo > & mrDriverList
static bool SplitDriverVersion(const char *aSource, char *aAStr, char *aBStr, char *aCStr, char *aDStr, VersionType versionType)
static bool ParseDriverVersion(std::u16string_view aVersion, uint64_t &rNumericVersion, VersionType versionType)