From fd9f0d8b86b71fb33bb804142e37bbb365ea9db2 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Mon, 3 Nov 2014 13:59:23 +0000 Subject: [PATCH] [SHELL32] * Move shpolicy.cpp to the wine folder. * Rename shpolicy.cpp to shpolicy.c. * Sync shpolicy.c with Wine 1.7.27. CORE-8540 svn path=/branches/shell-experiments/; revision=65223 --- dll/win32/shell32/CMakeLists.txt | 2 +- .../shell32/{shpolicy.cpp => wine/shpolicy.c} | 142 ++++++++++-------- 2 files changed, 78 insertions(+), 66 deletions(-) rename dll/win32/shell32/{shpolicy.cpp => wine/shpolicy.c} (90%) diff --git a/dll/win32/shell32/CMakeLists.txt b/dll/win32/shell32/CMakeLists.txt index 678a503a078..76300a4345b 100644 --- a/dll/win32/shell32/CMakeLists.txt +++ b/dll/win32/shell32/CMakeLists.txt @@ -63,7 +63,6 @@ list(APPEND SOURCE shlfsbind.cpp shlmenu.cpp shlview.cpp - shpolicy.cpp stubs.cpp systray.cpp defcontextmenu.cpp @@ -78,6 +77,7 @@ add_library(shell32 SHARED wine/shellole.c wine/shellpath.c wine/shellstring.c + wine/shpolicy.c vista.c shell32.rc ${CMAKE_CURRENT_BINARY_DIR}/shell32_stubs.c diff --git a/dll/win32/shell32/shpolicy.cpp b/dll/win32/shell32/wine/shpolicy.c similarity index 90% rename from dll/win32/shell32/shpolicy.cpp rename to dll/win32/shell32/wine/shpolicy.c index 69d92968da1..1e1c919b2ac 100644 --- a/dll/win32/shell32/shpolicy.cpp +++ b/dll/win32/shell32/wine/shpolicy.c @@ -29,7 +29,19 @@ * Up to date as of SHELL32 v5.00 (W2K) */ -#include "precomp.h" +#include +#include +#include + +#define WIN32_NO_STATUS +#define _INC_WINDOWS + +#include +#include +#include +#include + +#include "shell32_main.h" WINE_DEFAULT_DEBUG_CHANNEL(shell); @@ -37,7 +49,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); typedef struct tagPOLICYDAT { - RESTRICTIONS policy; /* policy value passed to SHRestricted */ + DWORD policy; /* policy value passed to SHRestricted */ LPCSTR appstr; /* application str such as "Explorer" */ LPCSTR keystr; /* name of the actual registry key / policy */ DWORD cache; /* cached value or 0xffffffff for invalid */ @@ -776,13 +788,13 @@ static POLICYDATA sh32_policy_table[] = SHELL_NO_POLICY }, { - (RESTRICTIONS)0x50000024, + 0x50000024, strExplorer, strNoFileURL, SHELL_NO_POLICY }, { - (RESTRICTIONS)0, + 0, 0, 0, SHELL_NO_POLICY @@ -790,7 +802,7 @@ static POLICYDATA sh32_policy_table[] = }; /************************************************************************* - * SHRestricted [SHELL32.100] + * SHRestricted [SHELL32.100] * * Get the value associated with a policy Id. * @@ -812,51 +824,51 @@ static POLICYDATA sh32_policy_table[] = */ DWORD WINAPI SHRestricted (RESTRICTIONS policy) { - char regstr[256]; - HKEY xhkey; - DWORD retval, datsize = 4; - LPPOLICYDATA p; + char regstr[256]; + HKEY xhkey; + DWORD retval, datsize = 4; + LPPOLICYDATA p; - TRACE("(%08x)\n", policy); + TRACE("(%08x)\n", policy); - /* scan to see if we know this policy ID */ - for (p = sh32_policy_table; p->policy; p++) - { - if (policy == p->policy) - { - break; - } - } + /* scan to see if we know this policy ID */ + for (p = sh32_policy_table; p->policy; p++) + { + if (policy == p->policy) + { + break; + } + } - if (p->policy == 0) - { - /* we don't know this policy, return 0 */ - TRACE("unknown policy: (%08x)\n", policy); - return 0; - } + if (p->policy == 0) + { + /* we don't know this policy, return 0 */ + TRACE("unknown policy: (%08x)\n", policy); + return 0; + } - /* we have a known policy */ + /* we have a known policy */ - /* first check if this policy has been cached, return it if so */ - if (p->cache != SHELL_NO_POLICY) - { - return p->cache; - } + /* first check if this policy has been cached, return it if so */ + if (p->cache != SHELL_NO_POLICY) + { + return p->cache; + } - lstrcpyA(regstr, strRegistryPolicyA); - lstrcatA(regstr, p->appstr); + lstrcpyA(regstr, strRegistryPolicyA); + lstrcatA(regstr, p->appstr); - /* return 0 and don't set the cache if any registry errors occur */ - retval = 0; - if (RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey) == ERROR_SUCCESS) - { - if (RegQueryValueExA(xhkey, p->keystr, NULL, NULL, (LPBYTE)&retval, &datsize) == ERROR_SUCCESS) - { - p->cache = retval; - } - RegCloseKey(xhkey); - } - return retval; + /* return 0 and don't set the cache if any registry errors occur */ + retval = 0; + if (RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey) == ERROR_SUCCESS) + { + if (RegQueryValueExA(xhkey, p->keystr, NULL, NULL, (LPBYTE)&retval, &datsize) == ERROR_SUCCESS) + { + p->cache = retval; + } + RegCloseKey(xhkey); + } + return retval; } /************************************************************************* @@ -878,28 +890,28 @@ DWORD WINAPI SHRestricted (RESTRICTIONS policy) */ BOOL WINAPI SHInitRestricted(LPCVOID unused, LPCVOID inpRegKey) { - TRACE("(%p, %p)\n", unused, inpRegKey); + TRACE("(%p, %p)\n", unused, inpRegKey); - /* first check - if input is non-NULL and points to the secret - key string, then pass. Otherwise return 0. - */ - if (inpRegKey != NULL) - { - if (SHELL_OsIsUnicode()) - { - if (lstrcmpiW((LPCWSTR)inpRegKey, strRegistryPolicyW) && - lstrcmpiW((LPCWSTR)inpRegKey, strPolicyW)) - /* doesn't match, fail */ - return 0; - } - else - { - if (lstrcmpiA((LPCSTR)inpRegKey, strRegistryPolicyA) && - lstrcmpiA((LPCSTR)inpRegKey, strPolicyA)) - /* doesn't match, fail */ - return 0; - } - } + /* first check - if input is non-NULL and points to the secret + key string, then pass. Otherwise return 0. + */ + if (inpRegKey != NULL) + { + if (SHELL_OsIsUnicode()) + { + if (lstrcmpiW(inpRegKey, strRegistryPolicyW) && + lstrcmpiW(inpRegKey, strPolicyW)) + /* doesn't match, fail */ + return FALSE; + } + else + { + if (lstrcmpiA(inpRegKey, strRegistryPolicyA) && + lstrcmpiA(inpRegKey, strPolicyA)) + /* doesn't match, fail */ + return FALSE; + } + } - return TRUE; + return TRUE; }