From 40cfe48b7d76be268f3aafe138722344230ff83b Mon Sep 17 00:00:00 2001 From: Rolf Kalbermatter Date: Thu, 27 Mar 2003 18:34:34 +0000 Subject: [PATCH] Implemented SHLWAPI_266 and SHLWAPI_271. --- dlls/shlwapi/ordinal.c | 96 +++++++++++++++++++++++++++++++++------ dlls/shlwapi/ordinal.h | 11 +++++ dlls/shlwapi/shlwapi.spec | 6 +-- 3 files changed, 95 insertions(+), 18 deletions(-) diff --git a/dlls/shlwapi/ordinal.c b/dlls/shlwapi/ordinal.c index e6d2c361c88..6cd32787c9f 100644 --- a/dlls/shlwapi/ordinal.c +++ b/dlls/shlwapi/ordinal.c @@ -46,6 +46,7 @@ #include "winuser.h" #include "wine/debug.h" #include "shlwapi.h" +#include "ordinal.h" WINE_DEFAULT_DEBUG_CHANNEL(shell); @@ -1068,7 +1069,6 @@ HRESULT WINAPI SHLWAPI_168(IUnknown* lpUnkSink, REFIID riid, BOOL bAdviseOnly, /************************************************************************* * @ [SHLWAPI.169] * - * * Release an interface. * * PARAMS @@ -1371,7 +1371,7 @@ DWORD WINAPI SHLWAPI_180(HMENU hMenu) * bEnable [I] Whether to enable (TRUE) or disable (FALSE) the item. * * RETURNS - * The return code from CheckMenuItem. + * The return code from EnableMenuItem. */ UINT WINAPI SHLWAPI_181(HMENU hMenu, UINT wItemID, BOOL bEnable) { @@ -1912,24 +1912,90 @@ DWORD WINAPI SHLWAPI_241 () return /* 0xabba1243 */ 0; } +/* default shell policy registry key */ +static WCHAR strRegistryPolicyW[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o', + 's','o','f','t','\\','W','i','n','d','o','w','s','\\', + 'C','u','r','r','e','n','t','V','e','r','s','i','o','n', + '\\','P','o','l','i','c','i','e','s',0}; + /************************************************************************* - * @ [SHLWAPI.266] + * @ [SHLWAPI.271] * - * native does at least approximately: - * strcpyW(newstr, x); - * strcatW(newstr, "\\Restrictions"); - * if (RegOpenKeyExA(80000001, newstr, 00000000,00000001,40520b78)) - * return 0; - * *unknown* + * Retrieve a policy value from the registry. + * + * PARAMS + * lpSubKey [I] registry key name + * lpSubName [I] subname of registry key + * lpValue [I] value name of registry value + * + * RETURNS + * the value associated with the registry key or 0 if not found + */ +DWORD WINAPI SHLWAPI_271(LPCWSTR lpSubKey, LPCWSTR lpSubName, LPCWSTR lpValue) +{ + DWORD retval, datsize = 4; + HKEY hKey; + + if (!lpSubKey) + lpSubKey = (LPCWSTR)strRegistryPolicyW; + + retval = RegOpenKeyW(HKEY_LOCAL_MACHINE, lpSubKey, &hKey); + if (retval != ERROR_SUCCESS) + retval = RegOpenKeyW(HKEY_CURRENT_USER, lpSubKey, &hKey); + if (retval != ERROR_SUCCESS) + return 0; + + SHGetValueW(hKey, lpSubName, lpValue, NULL, (LPBYTE)&retval, &datsize); + RegCloseKey(hKey); + return retval; +} + +/************************************************************************* + * @ [SHLWAPI.266] + * + * Helper function to retrieve the possibly cached value for a specific policy + * + * PARAMS + * policy [I] The policy to look for + * initial [I] Main registry key to open, if NULL use default + * polTable [I] Table of known policies, 0 terminated + * polArr [I] Cache array of policy values + * + * RETURNS + * The retrieved policy value or 0 if not successful + * + * NOTES + * This function is used by the native SHRestricted function to search for the + * policy and cache it once retrieved. The current Wine implementation uses a + * different POLICYDATA structure and implements a similar algorithme adapted to + * that structure. */ DWORD WINAPI SHLWAPI_266 ( - LPVOID w, - LPVOID x, /* [in] partial registry key */ - LPVOID y, - LPVOID z) + DWORD policy, + LPCWSTR initial, /* [in] partial registry key */ + LPPOLICYDATA polTable, + LPDWORD polArr) { - FIXME("(%p %p %p %p)stub\n",w,x,y,z); - return /* 0xabba1248 */ 0; + TRACE("(0x%08lx %s %p %p)\n", policy, debugstr_w(initial), polTable, polArr); + + if (!polTable || !polArr) + return 0; + + for (;polTable->policy; polTable++, polArr++) + { + if (policy == polTable->policy) + { + /* we have a known policy */ + + /* check if this policy has been cached */ + if (*polArr == SHELL_NO_POLICY) + *polArr = SHLWAPI_271(initial, polTable->appstr, polTable->keystr); + return *polArr; + } + } + /* we don't know this policy, return 0 */ + TRACE("unknown policy: (%08lx)\n", policy); + return 0; } /************************************************************************* diff --git a/dlls/shlwapi/ordinal.h b/dlls/shlwapi/ordinal.h index 86460676714..5ee3d28ef23 100644 --- a/dlls/shlwapi/ordinal.h +++ b/dlls/shlwapi/ordinal.h @@ -52,6 +52,17 @@ DWORD WINAPI SHLWAPI_2(LPCWSTR x, UNKNOWN_SHLWAPI_2 *y); } \ } while (0) +/* SHLWAPI_266 definitions and structures */ +#define SHELL_NO_POLICY -1 + +typedef struct tagPOLICYDATA +{ + DWORD policy; /* flags value passed to SHRestricted */ + LPCWSTR appstr; /* application str such as "Explorer" */ + LPCWSTR keystr; /* name of the actual registry key / policy */ +} POLICYDATA, *LPPOLICYDATA; + + extern HMODULE SHLWAPI_hshell32; /* Shared internal functions */ diff --git a/dlls/shlwapi/shlwapi.spec b/dlls/shlwapi/shlwapi.spec index 283a7168dbd..ed647299e6c 100644 --- a/dlls/shlwapi/shlwapi.spec +++ b/dlls/shlwapi/shlwapi.spec @@ -212,7 +212,7 @@ 212 stdcall @(ptr ptr long) SHLWAPI_212 213 stdcall @(ptr) SHLWAPI_213 214 stdcall @(ptr ptr) SHLWAPI_214 -215 stdcall @(long long long) SHLWAPI_215 +215 stdcall @(str ptr long) SHLWAPI_215 216 stub @ 217 stdcall @(wstr ptr ptr) SHLWAPI_217 218 stdcall @(long wstr ptr ptr) SHLWAPI_218 @@ -263,12 +263,12 @@ 263 stub @ 264 stub @ 265 stub @ -266 stdcall @(long long long long) SHLWAPI_266 +266 stdcall @(long wstr ptr ptr) SHLWAPI_266 267 stdcall @(long long long long) SHLWAPI_267 268 stdcall @(long long) SHLWAPI_268 269 stub @ 270 stub @ -271 stub @ +271 stdcall @(wstr wstr wstr) SHLWAPI_271 272 stub @ 273 stub @ 274 stub @