[ACPPAGE] Enable version lies until Win7 + some cleanup

This commit is contained in:
Mark Jansen 2018-02-06 19:32:51 +01:00
parent 0dd71438a4
commit 9b55e647fa
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
4 changed files with 42 additions and 23 deletions

View file

@ -2,7 +2,7 @@
* PROJECT: ReactOS Compatibility Layer Shell Extension
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: acppage entrypoint
* COPYRIGHT: Copyright 2015 Mark Jansen (mark.jansen@reactos.org)
* COPYRIGHT: Copyright 2015-2018 Mark Jansen (mark.jansen@reactos.org)
*/
#include "precomp.h"
@ -15,10 +15,6 @@ LONG g_ModuleRefCnt = 0;
class CLayerUIPropPageModule : public CComModule
{
public:
void Term()
{
CComModule::Term();
}
};
BEGIN_OBJECT_MAP(ObjectMap)
@ -37,6 +33,9 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
g_hModule = hInstance;
gModule.Init(ObjectMap, hInstance, NULL);
break;
case DLL_PROCESS_DETACH:
gModule.Term();
break;
}
return(TRUE);
@ -62,10 +61,6 @@ STDAPI DllRegisterServer()
if (FAILED(hr))
return hr;
hr = gModule.UpdateRegistryFromResource(IDR_ACPPAGE, TRUE, NULL);
if (FAILED(hr))
return hr;
return S_OK;
}
@ -77,10 +72,6 @@ STDAPI DllUnregisterServer()
if (FAILED(hr))
return hr;
hr = gModule.UpdateRegistryFromResource(IDR_ACPPAGE, FALSE, NULL);
if (FAILED(hr))
return hr;
return S_OK;
}
@ -91,23 +82,53 @@ struct CCoInit
HRESULT hres;
};
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;
}
EXTERN_C
BOOL WINAPI GetExeFromLnk(PCWSTR pszLnk, PWSTR pszExe, size_t cchSize)
{
CCoInit init;
if (FAILED(init.hres))
if (FAILED_UNEXPECTEDLY(init.hres))
return FALSE;
CComPtr<IShellLinkW> spShellLink;
if (FAILED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IShellLinkW, &spShellLink))))
if (FAILED_UNEXPECTEDLY(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IShellLinkW, &spShellLink))))
return FALSE;
CComPtr<IPersistFile> spPersistFile;
if (FAILED(spShellLink->QueryInterface(IID_PPV_ARG(IPersistFile, &spPersistFile))))
if (FAILED_UNEXPECTEDLY(spShellLink->QueryInterface(IID_PPV_ARG(IPersistFile, &spPersistFile))))
return FALSE;
if (FAILED(spPersistFile->Load(pszLnk, STGM_READ)) || FAILED(spShellLink->Resolve(NULL, SLR_NO_UI | SLR_NOUPDATE | SLR_NOSEARCH)))
if (FAILED_UNEXPECTEDLY(spPersistFile->Load(pszLnk, STGM_READ)) || FAILED_UNEXPECTEDLY(spShellLink->Resolve(NULL, SLR_NO_UI | SLR_NOUPDATE | SLR_NOSEARCH)))
return FALSE;
return SUCCEEDED(spShellLink->GetPath(pszExe, cchSize, NULL, SLGP_RAWPATH));
return !FAILED_UNEXPECTEDLY(spShellLink->GetPath(pszExe, cchSize, NULL, SLGP_RAWPATH));
}

View file

@ -2,7 +2,7 @@
* PROJECT: ReactOS Compatibility Layer Shell Extension
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: CLayerStringList implementation
* COPYRIGHT: Copyright 2015-2017 Mark Jansen (mark.jansen@reactos.org)
* COPYRIGHT: Copyright 2015-2018 Mark Jansen (mark.jansen@reactos.org)
*/
#pragma once

View file

@ -2,7 +2,7 @@
* PROJECT: ReactOS Compatibility Layer Shell Extension
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: CLayerUIPropPage implementation
* COPYRIGHT: Copyright 2015-2017 Mark Jansen (mark.jansen@reactos.org)
* COPYRIGHT: Copyright 2015-2018 Mark Jansen (mark.jansen@reactos.org)
*/
#include "precomp.h"
@ -33,13 +33,11 @@ static struct {
{ L"Windows XP (SP2)", L"WINXPSP2" },
{ L"Windows XP (SP3)", L"WINXPSP3" },
{ L"Windows Server 2003 (SP1)", L"WINSRV03SP1" },
#if 0
{ L"Windows Server 2008 (SP1)", L"WINSRV08SP1" },
{ L"Windows Vista", L"VISTARTM" },
{ L"Windows Vista (SP1)", L"VISTASP1" },
{ L"Windows Vista (SP2)", L"VISTASP2" },
{ L"Windows 7", L"WIN7RTM" },
#endif
{ NULL, NULL }
};

View file

@ -2,7 +2,7 @@
* PROJECT: ReactOS Compatibility Layer Shell Extension
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: CLayerUIPropPage definition
* COPYRIGHT: Copyright 2015-2017 Mark Jansen (mark.jansen@reactos.org)
* COPYRIGHT: Copyright 2015-2018 Mark Jansen (mark.jansen@reactos.org)
*/
#pragma once