2016-04-09 21:40:32 +00:00
|
|
|
/*
|
2017-09-08 20:19:51 +00:00
|
|
|
* PROJECT: ReactOS Compatibility Layer Shell Extension
|
|
|
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
|
|
|
* PURPOSE: acppage entrypoint
|
2018-02-06 18:32:51 +00:00
|
|
|
* COPYRIGHT: Copyright 2015-2018 Mark Jansen (mark.jansen@reactos.org)
|
2016-04-09 21:40:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
|
2016-08-23 19:37:31 +00:00
|
|
|
#include <shellutils.h>
|
|
|
|
|
2016-04-09 21:40:32 +00:00
|
|
|
HMODULE g_hModule = NULL;
|
|
|
|
LONG g_ModuleRefCnt = 0;
|
|
|
|
|
|
|
|
class CLayerUIPropPageModule : public CComModule
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
};
|
|
|
|
|
|
|
|
BEGIN_OBJECT_MAP(ObjectMap)
|
|
|
|
OBJECT_ENTRY(CLSID_CLayerUIPropPage, CLayerUIPropPage)
|
|
|
|
END_OBJECT_MAP()
|
|
|
|
|
|
|
|
CLayerUIPropPageModule gModule;
|
|
|
|
|
|
|
|
EXTERN_C
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
|
|
|
{
|
|
|
|
switch (dwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls(hInstance);
|
|
|
|
g_hModule = hInstance;
|
|
|
|
gModule.Init(ObjectMap, hInstance, NULL);
|
|
|
|
break;
|
2018-02-06 18:32:51 +00:00
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
gModule.Term();
|
|
|
|
break;
|
2016-04-09 21:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
STDAPI DllCanUnloadNow()
|
|
|
|
{
|
|
|
|
if (g_ModuleRefCnt)
|
|
|
|
return S_FALSE;
|
|
|
|
return gModule.DllCanUnloadNow();
|
|
|
|
}
|
|
|
|
|
|
|
|
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
return gModule.DllGetClassObject(rclsid, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
STDAPI DllRegisterServer()
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = gModule.DllRegisterServer(FALSE);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
STDAPI DllUnregisterServer()
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = gModule.DllUnregisterServer(FALSE);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct CCoInit
|
|
|
|
{
|
|
|
|
CCoInit() { hres = CoInitialize(NULL); }
|
|
|
|
~CCoInit() { if (SUCCEEDED(hres)) { CoUninitialize(); } }
|
|
|
|
HRESULT hres;
|
|
|
|
};
|
|
|
|
|
2018-02-06 18:32:51 +00:00
|
|
|
EXTERN_C
|
|
|
|
inline ULONG
|
|
|
|
Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
|
|
|
|
{
|
|
|
|
char Buffer[512];
|
|
|
|
char* Current = Buffer;
|
|
|
|
size_t Length = _countof(Buffer);
|
|
|
|
const char* fname = strrchr(filename, '\\');
|
|
|
|
if (fname == NULL)
|
|
|
|
{
|
|
|
|
fname = strrchr(filename, '/');
|
|
|
|
if (fname != NULL)
|
|
|
|
fname++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fname++;
|
|
|
|
|
|
|
|
if (fname == NULL)
|
|
|
|
fname = filename;
|
|
|
|
|
|
|
|
StringCchPrintfExA(Current, Length, &Current, &Length, STRSAFE_NULL_ON_FAILURE, "%s:%d: ", fname, line);
|
|
|
|
va_list ArgList;
|
|
|
|
va_start(ArgList, lpFormat);
|
|
|
|
StringCchVPrintfExA(Current, Length, &Current, &Length, STRSAFE_NULL_ON_FAILURE, lpFormat, ArgList);
|
|
|
|
va_end(ArgList);
|
|
|
|
OutputDebugStringA(Buffer);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-09 21:40:32 +00:00
|
|
|
EXTERN_C
|
|
|
|
BOOL WINAPI GetExeFromLnk(PCWSTR pszLnk, PWSTR pszExe, size_t cchSize)
|
|
|
|
{
|
|
|
|
CCoInit init;
|
2018-02-06 18:32:51 +00:00
|
|
|
if (FAILED_UNEXPECTEDLY(init.hres))
|
2016-04-09 21:40:32 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
CComPtr<IShellLinkW> spShellLink;
|
2018-02-06 18:32:51 +00:00
|
|
|
if (FAILED_UNEXPECTEDLY(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IShellLinkW, &spShellLink))))
|
2016-04-09 21:40:32 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
CComPtr<IPersistFile> spPersistFile;
|
2018-02-06 18:32:51 +00:00
|
|
|
if (FAILED_UNEXPECTEDLY(spShellLink->QueryInterface(IID_PPV_ARG(IPersistFile, &spPersistFile))))
|
2016-04-09 21:40:32 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2018-02-06 18:32:51 +00:00
|
|
|
if (FAILED_UNEXPECTEDLY(spPersistFile->Load(pszLnk, STGM_READ)) || FAILED_UNEXPECTEDLY(spShellLink->Resolve(NULL, SLR_NO_UI | SLR_NOUPDATE | SLR_NOSEARCH)))
|
2016-04-09 21:40:32 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2018-02-06 18:32:51 +00:00
|
|
|
return !FAILED_UNEXPECTEDLY(spShellLink->GetPath(pszExe, cchSize, NULL, SLGP_RAWPATH));
|
2016-04-09 21:40:32 +00:00
|
|
|
}
|