[RSHELL]: When rshell is compiled and used on Windows (as a testing replacement for shell32), it should correctly initialize the shell32_instance handle so that the rest of shell32 code can use something valid!

svn path=/trunk/; revision=71520
This commit is contained in:
Hermès Bélusca-Maïto 2016-06-04 22:50:33 +00:00
parent fe2ef00a13
commit 1b3d6dfdc1

View file

@ -20,8 +20,6 @@
#include "shellmenu.h" #include "shellmenu.h"
HINSTANCE shell32_hInstance = NULL;
DWORD WINAPI WinList_Init(void) DWORD WINAPI WinList_Init(void)
{ {
/* do something here (perhaps we may want to add our own implementation fo win8) */ /* do something here (perhaps we may want to add our own implementation fo win8) */
@ -41,7 +39,7 @@ public:
CRShellModule gModule; CRShellModule gModule;
CAtlWinModule gWinModule; CAtlWinModule gWinModule;
HINSTANCE g_hRShell; HINSTANCE shell32_hInstance = NULL;
static LSTATUS inline _RegSetStringValueW(HKEY hKey, LPCWSTR lpValueName, LPCWSTR lpStringData) static LSTATUS inline _RegSetStringValueW(HKEY hKey, LPCWSTR lpValueName, LPCWSTR lpStringData)
{ {
@ -59,7 +57,7 @@ static HRESULT RegisterComponent(REFGUID clsid, LPCWSTR szDisplayName)
if (!StringFromGUID2(clsid, szClsid, _countof(szClsid))) if (!StringFromGUID2(clsid, szClsid, _countof(szClsid)))
return E_FAIL; return E_FAIL;
if (!GetModuleFileNameW(g_hRShell, szFilename, _countof(szFilename))) if (!GetModuleFileNameW(shell32_hInstance, szFilename, _countof(szFilename)))
return E_FAIL; return E_FAIL;
HRESULT hr = StringCchPrintfW(szRoot, 0x104u, L"CLSID\\%s", szClsid); HRESULT hr = StringCchPrintfW(szRoot, 0x104u, L"CLSID\\%s", szClsid);
@ -117,13 +115,14 @@ STDAPI_(BOOL) DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID fImpLoad)
{ {
if (dwReason == DLL_PROCESS_ATTACH) if (dwReason == DLL_PROCESS_ATTACH)
{ {
g_hRShell = hInstance; shell32_hInstance = hInstance;
gModule.Init(NULL, hInstance, NULL); gModule.Init(NULL, hInstance, NULL);
DisableThreadLibraryCalls(hInstance); DisableThreadLibraryCalls(hInstance);
} }
else if (dwReason == DLL_PROCESS_DETACH) else if (dwReason == DLL_PROCESS_DETACH)
{ {
shell32_hInstance = NULL;
gModule.Term(); gModule.Term();
} }
return TRUE; return TRUE;