Skip to content

Commit

Permalink
[ACPPAGE] Enable version lies until Win7 + some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
learn-more committed Feb 24, 2018
1 parent 0dd7143 commit 9b55e64
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 23 deletions.
57 changes: 39 additions & 18 deletions dll/shellext/acppage/ACPPage.cpp
Expand Up @@ -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"
Expand All @@ -15,10 +15,6 @@ LONG g_ModuleRefCnt = 0;
class CLayerUIPropPageModule : public CComModule
{
public:
void Term()
{
CComModule::Term();
}
};

BEGIN_OBJECT_MAP(ObjectMap)
Expand All @@ -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);
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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));
}
2 changes: 1 addition & 1 deletion dll/shellext/acppage/CLayerStringList.hpp
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions dll/shellext/acppage/CLayerUIPropPage.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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 }
};

Expand Down
2 changes: 1 addition & 1 deletion dll/shellext/acppage/CLayerUIPropPage.hpp
Expand Up @@ -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
Expand Down

0 comments on commit 9b55e64

Please sign in to comment.