Add Debuggers And Tools Wow64 dbghelp support
@@ -210,13 +210,13 @@ VOID PhpSymbolProviderCompleteInitialization(
VOID
)
{
-#ifdef _WIN64
- static PH_STRINGREF windowsKitsRootKeyName = PH_STRINGREF_INIT(L"Software\\Wow6432Node\\Microsoft\\Windows Kits\\Installed Roots");
-#else
static PH_STRINGREF windowsKitsRootKeyName = PH_STRINGREF_INIT(L"Software\\Microsoft\\Windows Kits\\Installed Roots");
+#ifdef _WIN64
+ static PH_STRINGREF windowsKitsRootKeyNameWow64 = PH_STRINGREF_INIT(L"Software\\Wow6432Node\\Microsoft\\Windows Kits\\Installed Roots");
#endif
static PH_STRINGREF dbghelpFileName = PH_STRINGREF_INIT(L"dbghelp.dll");
static PH_STRINGREF symsrvFileName = PH_STRINGREF_INIT(L"symsrv.dll");
+ PPH_STRING winsdkPath;
PVOID dbghelpHandle;
PVOID symsrvHandle;
HANDLE keyHandle;
@@ -227,6 +227,7 @@ VOID PhpSymbolProviderCompleteInitialization(
return;
}
+ winsdkPath = NULL;
dbghelpHandle = NULL;
symsrvHandle = NULL;
@@ -238,29 +239,48 @@ VOID PhpSymbolProviderCompleteInitialization(
0
)))
{
- PPH_STRING winsdkPath;
- PPH_STRING dbghelpName;
- PPH_STRING symsrvName;
+ PhMoveReference(&winsdkPath, PhQueryRegistryString(keyHandle, L"KitsRoot10")); // Windows 10 SDK
+ if (PhIsNullOrEmptyString(winsdkPath))
+ PhMoveReference(&winsdkPath, PhQueryRegistryString(keyHandle, L"KitsRoot81")); // Windows 8.1 SDK
+ if (PhIsNullOrEmptyString(winsdkPath))
+ PhMoveReference(&winsdkPath, PhQueryRegistryString(keyHandle, L"KitsRoot")); // Windows 8 SDK
- winsdkPath = PhQueryRegistryString(keyHandle, L"KitsRoot10"); // Windows 10 SDK
+ NtClose(keyHandle);
+ }
+#ifdef _WIN64
+ if (PhIsNullOrEmptyString(winsdkPath))
+ {
+ if (NT_SUCCESS(PhOpenKey(
+ &keyHandle,
+ KEY_READ,
+ PH_KEY_LOCAL_MACHINE,
+ &windowsKitsRootKeyNameWow64,
+ 0
+ )))
+ {
+ PhMoveReference(&winsdkPath, PhQueryRegistryString(keyHandle, L"KitsRoot10")); // Windows 10 SDK
if (PhIsNullOrEmptyString(winsdkPath))
PhMoveReference(&winsdkPath, PhQueryRegistryString(keyHandle, L"KitsRoot81")); // Windows 8.1 SDK
-
if (PhIsNullOrEmptyString(winsdkPath))
PhMoveReference(&winsdkPath, PhQueryRegistryString(keyHandle, L"KitsRoot")); // Windows 8 SDK
- if (!PhIsNullOrEmptyString(winsdkPath))
+ NtClose(keyHandle);
+ }
+ }
+#endif
+
+ if (winsdkPath)
{
+ PPH_STRING dbghelpName;
+ PPH_STRING symsrvName;
+
#ifdef _WIN64
PhMoveReference(&winsdkPath, PhConcatStringRefZ(&winsdkPath->sr, L"\\Debuggers\\x64\\"));
#else
PhMoveReference(&winsdkPath, PhConcatStringRefZ(&winsdkPath->sr, L"\\Debuggers\\x86\\"));
#endif
- }
- if (winsdkPath)
- {
if (dbghelpName = PhConcatStringRef2(&winsdkPath->sr, &dbghelpFileName))
{
dbghelpHandle = LoadLibrary(dbghelpName->Buffer);
@@ -276,9 +296,6 @@ VOID PhpSymbolProviderCompleteInitialization(
PhDereferenceObject(winsdkPath);
}
- NtClose(keyHandle);
- }
-
if (!dbghelpHandle)
dbghelpHandle = LoadLibrary(L"dbghelp.dll");
