While fiddling around with SHRestricted() I came across this undocumented function in shlwapi.dll. It is used by the native SHRestricted function to do the search for a policy but Wine uses a different internal structure, so that I did not make SHRestricted() call this function. Changelog * dlls/shlwapi/shlwapi.spec Fix signature for SHLWAPI_266 and add SHLWAPI_271 * dlls/shlwapi/ordinal.h Add some declarations used by SHLWAPI_266 * dlls/shlwapi/ordinal.c Implement SHLWAPI_266 and SHLWAPI_271 License: X11, LGPL Rolf Kalbermatter Index: dlls/shlwapi/shlwapi.spec =================================================================== RCS file: /home/wine/wine/dlls/shlwapi/shlwapi.spec,v retrieving revision 1.71 diff -u -r1.71 shlwapi.spec --- dlls/shlwapi/shlwapi.spec 20 Mar 2003 03:53:13 -0000 1.71 +++ dlls/shlwapi/shlwapi.spec 27 Mar 2003 00:48:49 -0000 @@ -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 @ Index: dlls/shlwapi/ordinal.h =================================================================== RCS file: /home/wine/wine/dlls/shlwapi/ordinal.h,v retrieving revision 1.5 diff -u -r1.5 ordinal.h --- dlls/shlwapi/ordinal.h 3 Apr 2002 02:43:03 -0000 1.5 +++ dlls/shlwapi/ordinal.h 27 Mar 2003 00:55:00 -0000 @@ -51,6 +51,17 @@ if (!(func = (void*)GetProcAddress(SHLWAPI_h##module, name))) return fail; \ } \ } 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; Index: dlls/shlwapi/ordinal.c =================================================================== RCS file: /home/wine/wine/dlls/shlwapi/ordinal.c,v retrieving revision 1.64 diff -u -r1.64 ordinal.c --- dlls/shlwapi/ordinal.c 3 Jan 2003 19:12:56 -0000 1.64 +++ dlls/shlwapi/ordinal.c 27 Mar 2003 00:57:01 -0000 @@ -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 @@ /************************************************************************* * @ [SHLWAPI.169] * - * * Release an interface. * * PARAMS @@ -1371,7 +1371,7 @@ * 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 @@ 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.271] + * + * 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] + * @ [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 * - * native does at least approximately: - * strcpyW(newstr, x); - * strcatW(newstr, "\\Restrictions"); - * if (RegOpenKeyExA(80000001, newstr, 00000000,00000001,40520b78)) - * return 0; - * *unknown* + * 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%08x %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; } /*************************************************************************