15#define MAX_KEY_LENGTH 255
58 WCHAR maintenanceServiceKey[
MAX_PATH + 1];
60 maintenanceServiceKey))
72 LONG retCode = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
73 maintenanceServiceKey, 0,
74 KEY_READ | KEY_WOW64_64KEY, &baseKeyRaw);
75 if (retCode != ERROR_SUCCESS)
77 LOG_WARN((
"Could not open key. (%d)", retCode));
81 retCode = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
83 KEY_READ | KEY_WOW64_64KEY, &baseKeyRaw);
84 if (retCode != ERROR_SUCCESS)
86 LOG_WARN((
"Could not open fallback key. (%d)", retCode));
90 AutoRegKey baseKey(baseKeyRaw);
93 DWORD subkeyCount = 0;
94 retCode = RegQueryInfoKeyW(baseKey.get(),
nullptr,
nullptr,
nullptr, &subkeyCount,
95 nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
97 if (retCode != ERROR_SUCCESS)
99 LOG_WARN((
"Could not query info key. (%d)", retCode));
104 for (DWORD
i = 0;
i < subkeyCount;
i++)
108 retCode = RegEnumKeyExW(baseKey.get(),
i, subkeyBuffer,
109 &subkeyBufferCount,
nullptr,
110 nullptr,
nullptr,
nullptr);
111 if (retCode != ERROR_SUCCESS)
113 LOG_WARN((
"Could not enum certs. (%d)", retCode));
119 retCode = RegOpenKeyExW(baseKey.get(),
122 KEY_READ | KEY_WOW64_64KEY,
124 AutoRegKey subKey(subKeyRaw);
125 if (retCode != ERROR_SUCCESS)
127 LOG_WARN((
"Could not open subkey. (%d)", retCode));
131 const int MAX_CHAR_COUNT = 256;
132 DWORD valueBufSize = MAX_CHAR_COUNT *
sizeof(WCHAR);
133 WCHAR
name[MAX_CHAR_COUNT] = { L
'\0' };
134 WCHAR issuer[MAX_CHAR_COUNT] = { L
'\0' };
137 retCode = RegQueryValueExW(subKey.get(), L
"name", 0,
nullptr,
138 (LPBYTE)
name, &valueBufSize);
139 if (retCode != ERROR_SUCCESS)
141 LOG_WARN((
"Could not obtain name from registry. (%d)", retCode));
146 valueBufSize = MAX_CHAR_COUNT *
sizeof(WCHAR);
147 retCode = RegQueryValueExW(subKey.get(), L
"issuer", 0,
nullptr,
148 (LPBYTE)issuer, &valueBufSize);
149 if (retCode != ERROR_SUCCESS)
151 LOG_WARN((
"Could not obtain issuer from registry. (%d)", retCode));
162 if (retCode != ERROR_SUCCESS)
164 LOG_WARN((
"Error on certificate check. (%d)", retCode));
169 if (retCode != ERROR_SUCCESS)
171 LOG_WARN((
"Error on certificate trust check. (%d)", retCode));
DWORD CheckCertificateForPEFile(LPCWSTR filePath, CertificateCheckInfo &infoToMatch)
Checks to see if a file stored at filePath matches the specified info.
DWORD VerifyCertificateTrustForFile(LPCWSTR filePath)
Verifies the trust of the specified file path.
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
BOOL CalculateRegistryPathFromFilePath(const LPCWSTR filePath, LPWSTR registryPath)
Converts a file path into a unique registry location for cert storage.
const wchar_t *typedef BOOL
BOOL DoesBinaryMatchAllowedCertificates(LPCWSTR basePathForUpdate, LPCWSTR filePath)
Verifies if the file path matches any certificate stored in the registry.
void REGISTRY_CALLTYPE releaseKey(RegKeyHandle hKey)
#define TEST_ONLY_FALLBACK_KEY_PATH