forked from coddec/Classic-Shell
-
Notifications
You must be signed in to change notification settings - Fork 452
/
Copy pathClassicExplorer.cpp
91 lines (78 loc) · 2.38 KB
/
ClassicExplorer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Classic Shell (c) 2009-2017, Ivo Beltchev
// Open-Shell (c) 2017-2018, The Open-Shell Team
// Confidential information of Ivo Beltchev. Not for disclosure or distribution without prior written consent from the author
// ClassicExplorer.cpp : Implementation of DLL Exports.
#include "stdafx.h"
#include "resource.h"
#include "ClassicExplorer_h.h"
#include "dllmain.h"
// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
return _AtlModule.DllCanUnloadNow();
}
extern bool g_bExplorerExe;
// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
WaitDllInitThread();
if (!g_bExplorerExe && rclsid!=CLSID_ShareOverlay)
return CLASS_E_CLASSNOTAVAILABLE;
return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
}
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
WaitDllInitThread();
// registers object, typelib and all interfaces in typelib
HRESULT res=_AtlModule.DllRegisterServer();
if (SUCCEEDED(res))
{
// mark the extensions as compatible with the enhanced protected mode of IE10
// they are not technically IE extensions, but it complains about them as
// being incompatible
CComPtr<ICatRegister> catRegister;
catRegister.CoCreateInstance(CLSID_StdComponentCategoriesMgr);
if (catRegister)
{
CATID CATID_AppContainerCompatible={0x59fb2056,0xd625,0x48d0,{0xa9,0x44,0x1a,0x85,0xb5,0xab,0x26,0x40}};
catRegister->RegisterClassImplCategories(CLSID_ExplorerBHO,1,&CATID_AppContainerCompatible);
catRegister->RegisterClassImplCategories(CLSID_ExplorerBand,1,&CATID_AppContainerCompatible);
}
}
return res;
}
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
WaitDllInitThread();
return _AtlModule.DllUnregisterServer();
}
// DllInstall - Adds/Removes entries to the system registry per user
// per machine.
STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine)
{
WaitDllInitThread();
HRESULT hr = E_FAIL;
static const wchar_t szUserSwitch[] = L"user";
if (pszCmdLine != NULL)
{
if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0)
{
AtlSetPerUserRegistration(true);
}
}
if (bInstall)
{
hr = DllRegisterServer();
if (FAILED(hr))
{
DllUnregisterServer();
}
}
else
{
hr = DllUnregisterServer();
}
return hr;
}