19#if !defined WIN32_LEAN_AND_MEAN
20#define WIN32_LEAN_AND_MEAN
31 else if (rString ==
"7")
33 else if (rString ==
"8")
35 else if (rString ==
"8_1")
37 else if (rString ==
"10")
39 else if (rString ==
"windows")
41 else if (rString ==
"linux")
43 else if (rString ==
"osx_10_5")
45 else if (rString ==
"osx_10_6")
47 else if (rString ==
"osx_10_7")
49 else if (rString ==
"osx_10_8")
51 else if (rString ==
"osx")
53 else if (rString ==
"android")
60 if (rString ==
"less")
64 else if (rString ==
"less_equal")
68 else if (rString ==
"greater")
72 else if (rString ==
"greater_equal")
76 else if (rString ==
"equal")
80 else if (rString ==
"not_equal")
84 else if (rString ==
"between_exclusive")
88 else if (rString ==
"between_inclusive")
92 else if (rString ==
"between_inclusive_start")
102 if (rString ==
"all")
106 else if (rString ==
"intel")
110 else if (rString ==
"nvidia")
114 else if (rString ==
"amd")
118 else if (rString ==
"microsoft")
125 return OStringToOUString(rString, RTL_TEXTENCODING_UTF8);
185 , mrDriverList(rDriverList)
187 , mVersionType(versionType)
213 for (
int i = 0;
i < 4;
i++)
217 for (
int c =
i; c < 4; c++)
232 int len = strlen(aSource);
233 char* dest[4] = { aAStr, aBStr, aCStr, aDStr };
234 unsigned destIdx = 0;
235 unsigned destPos = 0;
237 for (
int i = 0;
i < len;
i++)
245 if (aSource[
i] ==
'.')
247 dest[destIdx++][destPos] = 0;
259 dest[destIdx][destPos++] = aSource[
i];
263 dest[destIdx][destPos] = 0;
267 dest[++destIdx][0] =
'\0';
281 char aStr[8], bStr[8], cStr[8], dStr[8];
302 if (a < 0 || a > 0xffff)
304 if (b < 0 || b > 0xffff)
306 if (c < 0 || c > 0xffff)
308 if (d < 0 || d > 0xffff)
317 OUString aString = OStringToOUString(rString, RTL_TEXTENCODING_UTF8);
340 = rReader.
nextItem(xmlreader::XmlReader::Text::Normalized, &
name, &nsId);
342 if (res == xmlreader::XmlReader::Result::Begin)
352 else if (
name ==
"device")
360 OString aDeviceId(
name.begin,
name.length);
362 OStringToOUString(aDeviceId, RTL_TEXTENCODING_UTF8));
369 else if (res == xmlreader::XmlReader::Result::End)
376 else if (res == xmlreader::XmlReader::Result::Text)
380 OString sMsg(
name.begin,
name.length);
381 rDriver.
maMsg = OStringToOUString(sMsg, RTL_TEXTENCODING_UTF8);
410 OString sOS(
name.begin,
name.length);
413 else if (
name ==
"vendor")
416 OString sVendor(
name.begin,
name.length);
419 else if (
name ==
"compare")
422 OString sCompare(
name.begin,
name.length);
425 else if (
name ==
"version")
428 OString sVersion(
name.begin,
name.length);
431 else if (
name ==
"minVersion")
434 OString sMinVersion(
name.begin,
name.length);
437 else if (
name ==
"maxVersion")
440 OString sMaxVersion(
name.begin,
name.length);
445 OString aAttrName(
name.begin,
name.length);
446 SAL_WARN(
"vcl.driver",
"unsupported attribute: " << aAttrName);
461 = rReader.
nextItem(xmlreader::XmlReader::Text::NONE, &
name, &nsId);
463 if (res == xmlreader::XmlReader::Result::Begin)
471 else if (
name ==
"entryRange")
482 else if (res == xmlreader::XmlReader::Result::End)
497 = rReader.
nextItem(xmlreader::XmlReader::Text::NONE, &
name, &nsId);
499 if (res == xmlreader::XmlReader::Result::Begin)
501 if (
name ==
"allowlist")
506 else if (
name ==
"denylist")
511 else if (
name ==
"root")
519 else if (res == xmlreader::XmlReader::Result::End)
521 if (
name ==
"allowlist" ||
name ==
"denylist")
526 else if (res == xmlreader::XmlReader::Result::Done)
538 switch (DriverBlocklist::GetWindowsVersion())
560struct compareIgnoreAsciiCase
562 explicit compareIgnoreAsciiCase(OUString aString)
567 bool operator()(std::u16string_view rCompare)
569 return maString.equalsIgnoreAsciiCase(rCompare);
582 , mbAllowlisted(false)
585 , mnDriverVersionMax(0)
590 uint64_t driverVersion,
bool bAllowlisted,
591 const char* suggestedVersion )
592 : meOperatingSystem(os)
593 , maAdapterVendor(
std::move(vendor))
594 , mbAllowlisted(bAllowlisted)
596 , mnDriverVersion(driverVersion)
597 , mnDriverVersionMax(0)
599 if (suggestedVersion)
601 = OStringToOUString(std::string_view(suggestedVersion), RTL_TEXTENCODING_UTF8);
605 std::u16string_view sDriverVersion,
606 std::u16string_view sAdapterVendorID,
608 const OUString& blocklistURL)
610 uint64_t driverVersion;
614 for (std::vector<DriverInfo>::size_type
i = 0;
i < aDeviceInfos.size();
i++)
616 bool osMatch =
false;
619 else if (aDeviceInfos[
i].meOperatingSystem == system)
633 && !aDeviceInfos[
i].maAdapterVendor.equalsIgnoreAsciiCase(sAdapterVendorID))
638 if (std::none_of(aDeviceInfos[
i].maDevices.begin(), aDeviceInfos[
i].maDevices.end(),
639 compareIgnoreAsciiCase(
"all"))
640 && std::none_of(aDeviceInfos[
i].maDevices.begin(), aDeviceInfos[
i].maDevices.end(),
641 compareIgnoreAsciiCase(sAdapterDeviceID)))
646 switch (aDeviceInfos[
i].meComparisonOp)
649 match = driverVersion < aDeviceInfos[
i].mnDriverVersion;
652 match = driverVersion <= aDeviceInfos[
i].mnDriverVersion;
655 match = driverVersion > aDeviceInfos[
i].mnDriverVersion;
658 match = driverVersion >= aDeviceInfos[
i].mnDriverVersion;
661 match = driverVersion == aDeviceInfos[
i].mnDriverVersion;
664 match = driverVersion != aDeviceInfos[
i].mnDriverVersion;
667 match = driverVersion > aDeviceInfos[
i].mnDriverVersion
668 && driverVersion < aDeviceInfos[
i].mnDriverVersionMax;
671 match = driverVersion >= aDeviceInfos[
i].mnDriverVersion
672 && driverVersion <= aDeviceInfos[
i].mnDriverVersionMax;
675 match = driverVersion >= aDeviceInfos[
i].mnDriverVersion
676 && driverVersion < aDeviceInfos[
i].mnDriverVersionMax;
683 SAL_WARN(
"vcl.driver",
"Bogus op in " << blocklistURL);
690 if (aDeviceInfos[
i].mbAllowlisted)
692 SAL_INFO(
"vcl.driver",
"allowlisted driver");
697 if (!aDeviceInfos[
i].maSuggestedVersion.isEmpty())
699 SAL_WARN(
"vcl.driver",
"use : " << aDeviceInfos[
i].maSuggestedVersion);
705 SAL_INFO(
"vcl.driver", (
match ?
"denylisted" :
"not denylisted") <<
" in " << blocklistURL);
710 std::u16string_view driverVersion, std::u16string_view
vendorId,
711 const OUString& deviceId)
713 std::vector<DriverInfo> driverList;
717 SAL_WARN(
"vcl.driver",
"error parsing denylist " << blocklistURL);
725int32_t GetWindowsVersion()
727 static int32_t winVersion = []() {
734 HINSTANCE hLibrary = LoadLibraryW(L
"kernel32.dll");
735 if (hLibrary !=
nullptr)
738 DWORD dwCount = GetModuleFileNameW(hLibrary, szPath,
SAL_N_ELEMENTS(szPath));
739 FreeLibrary(hLibrary);
742 dwCount = GetFileVersionInfoSizeW(szPath,
nullptr);
745 std::unique_ptr<char[]> ver(
new char[dwCount]);
746 if (GetFileVersionInfoW(szPath, 0, dwCount, ver.get()) != FALSE)
748 void* pBlock =
nullptr;
750 if (VerQueryValueW(ver.get(), L
"\\", &pBlock, &dwBlockSz) != FALSE
751 && dwBlockSz >=
sizeof(VS_FIXEDFILEINFO))
753 VS_FIXEDFILEINFO* vinfo =
static_cast<VS_FIXEDFILEINFO*
>(pBlock);
754 return int32_t(vinfo->dwProductVersionMS);
static void handleDevices(DriverInfo &rDriver, xmlreader::XmlReader &rReader)
void handleEntry(DriverInfo &rDriver, xmlreader::XmlReader &rReader)
const VersionType mVersionType
Parser(OUString aURL, std::vector< DriverInfo > &rDriverList, VersionType versionType)
std::vector< DriverInfo > & mrDriverList
void handleContent(xmlreader::XmlReader &rReader)
uint64_t getVersion(std::string_view rString)
void handleList(xmlreader::XmlReader &rReader)
Result nextItem(Text reportText, Span *data, int *nsId)
bool nextAttribute(int *nsId, Span *localName)
Span getAttributeValue(bool fullyNormalize)
#define GFX_DRIVER_VERSION(a, b, c, d)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
#define SAL_N_ELEMENTS(arr)
static OperatingSystem getOperatingSystem(std::string_view rString)
DeviceVendor GetVendorFromId(uint32_t id)
Returns vendor for the given vendor ID, or VendorAll if not known.
std::string_view GetVendorNameFromId(uint32_t id)
static void PadDriverDecimal(char *aString)
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 bool ParseDriverVersion(std::u16string_view aVersion, uint64_t &rNumericVersion, VersionType versionType)
const int DeviceVendorMax
@ DRIVER_OS_WINDOWS_FIRST
const uint64_t allDriverVersions
static OUString GetVendorId(std::string_view rString)
bool IsDeviceBlocked(const OUString &blocklistURL, VersionType versionType, std::u16string_view driverVersion, std::u16string_view vendorId, const OUString &deviceId)
@ DRIVER_BETWEEN_INCLUSIVE_START
@ DRIVER_BETWEEN_EXCLUSIVE
@ DRIVER_GREATER_THAN_OR_EQUAL
@ DRIVER_BETWEEN_INCLUSIVE
@ DRIVER_LESS_THAN_OR_EQUAL
@ DRIVER_COMPARISON_IGNORED
static bool SplitDriverVersion(const char *aSource, char *aAStr, char *aBStr, char *aCStr, char *aDStr, VersionType versionType)
VCL_DLLPUBLIC uint32_t vendorId
bool match(const sal_Unicode *pWild, const sal_Unicode *pStr, const sal_Unicode cEscape)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
std::vector< OUString > maDevices
OUString maSuggestedVersion
uint64_t mnDriverVersionMax
VersionComparisonOp meComparisonOp
OperatingSystem meOperatingSystem