ReactOS  0.4.14-dev-52-g6116262
ACPPage.cpp
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Compatibility Layer Shell Extension
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: acppage entrypoint
5  * COPYRIGHT: Copyright 2015-2018 Mark Jansen (mark.jansen@reactos.org)
6  */
7 
8 #include "precomp.h"
9 
10 #include <shellutils.h>
11 
14 
16 {
17 public:
18 };
19 
20 BEGIN_OBJECT_MAP(ObjectMap)
23 
25 
28 {
29  switch (dwReason)
30  {
31  case DLL_PROCESS_ATTACH:
34  gModule.Init(ObjectMap, hInstance, NULL);
35  break;
36  case DLL_PROCESS_DETACH:
37  gModule.Term();
38  break;
39  }
40 
41  return(TRUE);
42 }
43 
45 {
46  if (g_ModuleRefCnt)
47  return S_FALSE;
48  return gModule.DllCanUnloadNow();
49 }
50 
52 {
53  return gModule.DllGetClassObject(rclsid, riid, ppv);
54 }
55 
57 {
58  HRESULT hr;
59 
61  if (FAILED(hr))
62  return hr;
63 
64  return S_OK;
65 }
66 
68 {
69  HRESULT hr;
70 
72  if (FAILED(hr))
73  return hr;
74 
75  return S_OK;
76 }
77 
78 struct CCoInit
79 {
83 };
84 
86 BOOL WINAPI GetExeFromLnk(PCWSTR pszLnk, PWSTR pszExe, size_t cchSize)
87 {
88  CCoInit init;
89  if (FAILED_UNEXPECTEDLY(init.hres))
90  return FALSE;
91 
92  CComPtr<IShellLinkW> spShellLink;
93  if (FAILED_UNEXPECTEDLY(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IShellLinkW, &spShellLink))))
94  return FALSE;
95 
96  CComPtr<IPersistFile> spPersistFile;
97  if (FAILED_UNEXPECTEDLY(spShellLink->QueryInterface(IID_PPV_ARG(IPersistFile, &spPersistFile))))
98  return FALSE;
99 
100  if (FAILED_UNEXPECTEDLY(spPersistFile->Load(pszLnk, STGM_READ)) || FAILED_UNEXPECTEDLY(spShellLink->Resolve(NULL, SLR_NO_UI | SLR_NOUPDATE | SLR_NOSEARCH)))
101  return FALSE;
102 
103  return !FAILED_UNEXPECTEDLY(spShellLink->GetPath(pszExe, cchSize, NULL, SLGP_RAWPATH));
104 }
#define STDAPI
Definition: basetyps.h:41
HRESULT DllCanUnloadNow()
Definition: atlbase.h:928
~CCoInit()
Definition: ACPPage.cpp:81
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
HRESULT DllRegisterServer(BOOL bRegTypeLib=TRUE)
Definition: atlbase.h:940
HRESULT hr
Definition: shlfolder.c:183
HRESULT hres
Definition: ACPPage.cpp:82
#define OBJECT_ENTRY(clsid, class)
Definition: atlcom.h:653
REFIID riid
Definition: precomp.h:44
uint16_t * PWSTR
Definition: typedefs.h:54
LONG g_ModuleRefCnt
Definition: ACPPage.cpp:13
#define REFCLSID
Definition: guiddef.h:117
REFIID LPVOID * ppv
Definition: atlbase.h:39
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
HMODULE g_hModule
Definition: ACPPage.cpp:12
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
#define IID_PPV_ARG(Itype, ppType)
static int init
Definition: wintirpc.c:33
void Term()
Definition: atlbase.h:820
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: ACPPage.cpp:51
DWORD dwReason
Definition: misc.cpp:154
HRESULT Init(_ATL_OBJMAP_ENTRY *p, HINSTANCE, const GUID *plibid)
Definition: atlbase.h:797
HINSTANCE hInstance
Definition: charmap.c:20
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define S_FALSE
Definition: winerror.h:2357
HRESULT DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: atlbase.h:935
smooth NULL
Definition: ftsmooth.c:416
EXTERN_C BOOL WINAPI GetExeFromLnk(PCWSTR pszLnk, PWSTR pszExe, size_t cchSize)
Definition: ACPPage.cpp:86
#define DLL_PROCESS_DETACH
Definition: compat.h:119
#define STGM_READ
Definition: objbase.h:916
STDAPI DllUnregisterServer()
Definition: ACPPage.cpp:67
CLayerUIPropPageModule gModule
Definition: ACPPage.cpp:24
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
CCoInit()
Definition: ACPPage.cpp:80
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
STDAPI DllCanUnloadNow()
Definition: ACPPage.cpp:44
#define S_OK
Definition: intsafe.h:59
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
EXTERN_C BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
Definition: ACPPage.cpp:27
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1897
const GUID CLSID_CLayerUIPropPage
#define BEGIN_OBJECT_MAP(x)
Definition: atlcom.h:649
HRESULT DllUnregisterServer(BOOL bUnRegTypeLib=TRUE)
Definition: atlbase.h:945
STDAPI DllRegisterServer()
Definition: ACPPage.cpp:56
#define EXTERN_C
Definition: basetyps.h:12
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define END_OBJECT_MAP()
Definition: atlcom.h:651