From 9e2de7688b82fc5c36254a44fe7cb9250bb86aa6 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Tue, 22 May 2018 17:42:57 +0200 Subject: [PATCH] Allow to specify the exact path from where to load the shell extension dll Based on TortoiseSVN rev. 28225. Signed-off-by: Sven Strickroth --- src/TortoiseShell/TortoiseStub.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/TortoiseShell/TortoiseStub.cpp b/src/TortoiseShell/TortoiseStub.cpp index 26994ba4f..7dbb27938 100644 --- a/src/TortoiseShell/TortoiseStub.cpp +++ b/src/TortoiseShell/TortoiseStub.cpp @@ -1,7 +1,7 @@ // TortoiseGit - a Windows shell extension for easy version control // Copyright (C) 2012-2014, 2016-2017 - TortoiseGit -// Copyright (C) 2007, 2009, 2013-2014 - TortoiseSVN +// Copyright (C) 2007, 2009, 2013-2014, 2018 - TortoiseSVN // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -30,10 +30,13 @@ static HINSTANCE hTortoiseGit = nullptr; static LPFNGETCLASSOBJECT pDllGetClassObject = nullptr; static LPFNCANUNLOADNOW pDllCanUnloadNow = nullptr; +static wchar_t DebugDllPath[MAX_PATH] = { 0 }; + static BOOL DebugActive(void) { static const WCHAR TGitRootKey[] = L"Software\\TortoiseGit"; - static const WCHAR ExplorerOnlyValue[] = L"DebugShell"; + static const WCHAR DebugShellValue[] = L"DebugShell"; + static const WCHAR DebugShellPathValue[] = L"DebugShellPath"; DWORD bDebug = 0; @@ -52,16 +55,34 @@ static BOOL DebugActive(void) Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TGitRootKey, 0, KEY_READ, &hKey); if (Result == ERROR_SUCCESS) { - Result = RegQueryValueEx(hKey, ExplorerOnlyValue, nullptr, &Type, (BYTE*)&bDebug, &Len); + Result = RegQueryValueEx(hKey, DebugShellValue, nullptr, &Type, (BYTE*)&bDebug, &Len); if ((Result == ERROR_SUCCESS) && (Type == REG_DWORD) && (Len == sizeof(DWORD)) && bDebug) { TRACE(L"DebugActive() - debug active\n"); bDebugActive = TRUE; + Len = sizeof(wchar_t)*MAX_PATH; + Type = REG_SZ; + Result = RegQueryValueEx(hKey, DebugShellPathValue, nullptr, &Type, (BYTE*)DebugDllPath, &Len); + if ((Result == ERROR_SUCCESS) && (Type == REG_SZ) && bDebug) + TRACE(L"DebugActive() - debug path set\n"); } RegCloseKey(hKey); } } + else + { + Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TGitRootKey, 0, KEY_READ, &hKey); + if (Result == ERROR_SUCCESS) + { + Len = sizeof(wchar_t)*MAX_PATH; + Type = REG_SZ; + Result = RegQueryValueEx(hKey, DebugShellPathValue, nullptr, &Type, (BYTE*)DebugDllPath, &Len); + if ((Result == ERROR_SUCCESS) && (Type == REG_SZ) && bDebug) + TRACE(L"DebugActive() - debug path set\n"); + RegCloseKey(hKey); + } + } TRACE(L"WantRealVersion() - Exit\n"); return bDebugActive; @@ -135,6 +156,7 @@ static void LoadRealLibrary(void) WCHAR ModuleName[MAX_PATH] = {0}; DWORD Len = 0; HINSTANCE hUseInst = hInst; + DebugDllPath[0] = 0; if (hTortoiseGit) return; @@ -179,6 +201,8 @@ static void LoadRealLibrary(void) #else lstrcat(ModuleName, L"\\TortoiseGit32.dll"); #endif + if (DebugDllPath[0]) + lstrcpy(ModuleName, DebugDllPath); TRACE(L"LoadRealLibrary() - Load %s\n", ModuleName); hTortoiseGit = LoadLibraryEx(ModuleName, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH); @@ -257,6 +281,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID /*Reserved*/) { case DLL_PROCESS_ATTACH: hInst = hInstance; + DebugDllPath[0] = 0; break; /*case DLL_THREAD_ATTACH: -- 2.11.4.GIT