2 * shpolicy.c - Data for shell/system policies.
4 * Copyright 1999 Ian Schmidt <ischmidt@cfl.rr.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Some of these policies can be tweaked via the System Policy
23 * Editor which came with the Win95 Migration Guide, although
24 * there doesn't appear to be an updated Win98 version that
25 * would handle the many new policies introduced since then.
26 * You could easily write one with the information in
29 * Up to date as of SHELL32 v4.72 (Win98, Win95 with MSIE 5)
39 #include "undocshell.h"
40 #include "wine/winuser16.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(shell);
46 #define SHELL_MAX_POLICIES 57
48 #define SHELL_NO_POLICY 0xffffffff
50 typedef struct tagPOLICYDAT
52 DWORD polflags; /* flags value passed to SHRestricted */
53 LPSTR appstr; /* application str such as "Explorer" */
54 LPSTR keystr; /* name of the actual registry key / policy */
55 DWORD cache; /* cached value or 0xffffffff for invalid */
56 } POLICYDATA, *LPPOLICYDATA;
59 extern POLICYDATA sh32_policy_table[SHELL_MAX_POLICIES];
62 /* application strings */
64 static char strExplorer[] = {"Explorer"};
65 static char strActiveDesk[] = {"ActiveDesktop"};
66 static char strWinOldApp[] = {"WinOldApp"};
70 static char strNoFileURL[] = {"NoFileUrl"};
71 static char strNoFolderOptions[] = {"NoFolderOptions"};
72 static char strNoChangeStartMenu[] = {"NoChangeStartMenu"};
73 static char strNoWindowsUpdate[] = {"NoWindowsUpdate"};
74 static char strNoSetActiveDesktop[] = {"NoSetActiveDesktop"};
75 static char strNoForgetSoftwareUpdate[] = {"NoForgetSoftwareUpdate"};
76 static char strNoMSAppLogo[] = {"NoMSAppLogo5ChannelNotify"};
77 static char strForceCopyACLW[] = {"ForceCopyACLWithFile"};
78 static char strNoResolveTrk[] = {"NoResolveTrack"};
79 static char strNoResolveSearch[] = {"NoResolveSearch"};
80 static char strNoEditComponent[] = {"NoEditingComponents"};
81 static char strNoMovingBand[] = {"NoMovingBands"};
82 static char strNoCloseDragDrop[] = {"NoCloseDragDropBands"};
83 static char strNoCloseComponent[] = {"NoClosingComponents"};
84 static char strNoDelComponent[] = {"NoDeletingComponents"};
85 static char strNoAddComponent[] = {"NoAddingComponents"};
86 static char strNoComponent[] = {"NoComponents"};
87 static char strNoChangeWallpaper[] = {"NoChangingWallpaper"};
88 static char strNoHTMLWallpaper[] = {"NoHTMLWallpaper"};
89 static char strNoCustomWebView[] = {"NoCustomizeWebView"};
90 static char strClassicShell[] = {"ClassicShell"};
91 static char strClearRecentDocs[] = {"ClearRecentDocsOnExit"};
92 static char strNoFavoritesMenu[] = {"NoFavoritesMenu"};
93 static char strNoActiveDesktopChanges[] = {"NoActiveDesktopChanges"};
94 static char strNoActiveDesktop[] = {"NoActiveDesktop"};
95 static char strNoRecentDocMenu[] = {"NoRecentDocsMenu"};
96 static char strNoRecentDocHistory[] = {"NoRecentDocsHistory"};
97 static char strNoInetIcon[] = {"NoInternetIcon"};
98 static char strNoStngsWizard[] = {"NoSettingsWizards"};
99 static char strNoLogoff[] = {"NoLogoff"};
100 static char strNoNetConDis[] = {"NoNetConnectDisconnect"};
101 static char strNoContextMenu[] = {"NoViewContextMenu"};
102 static char strNoTryContextMenu[] = {"NoTrayContextMenu"};
103 static char strNoWebMenu[] = {"NoWebMenu"};
104 static char strLnkResolveIgnoreLnkInfo[] = {"LinkResolveIgnoreLinkInfo"};
105 static char strNoCommonGroups[] = {"NoCommonGroups"};
106 static char strEnforceShlExtSecurity[] = {"EnforceShellExtensionSecurity"};
107 static char strNoRealMode[] = {"NoRealMode"};
108 static char strMyDocsOnNet[] = {"MyDocsOnNet"};
109 static char strNoStartMenuSubfolder[] = {"NoStartMenuSubFolders"};
110 static char strNoAddPrinters[] = {"NoAddPrinter"};
111 static char strNoDeletePrinters[] = {"NoDeletePrinter"};
112 static char strNoPrintTab[] = {"NoPrinterTabs"};
113 static char strRestrictRun[] = {"RestrictRun"};
114 static char strNoStartBanner[] = {"NoStartBanner"};
115 static char strNoNetworkNeighborhood[] = {"NoNetHood"};
116 static char strNoDriveTypeAtRun[] = {"NoDriveTypeAutoRun"};
117 static char strNoDrivesAutoRun[] = {"NoDriveAutoRun"};
118 static char strNoDrives[] = {"NoDrives"};
119 static char strNoFind[] = {"NoFind"};
120 static char strNoDesktop[] = {"NoDesktop"};
121 static char strNoSetTaskBar[] = {"NoSetTaskbar"};
122 static char strNoSetFld[] = {"NoSetFolders"};
123 static char strNoFileMenu[] = {"NoFileMenu"};
124 static char strNoSavSetng[] = {"NoSaveSettings"};
125 static char strNoClose[] = {"NoClose"};
126 static char strNoRun[] = {"NoRun"};
128 /* policy data array */
130 POLICYDATA sh32_policy_table[] =
201 strNoNetworkNeighborhood,
237 strNoStartMenuSubfolder,
255 strEnforceShlExtSecurity,
261 strLnkResolveIgnoreLnkInfo,
315 strNoRecentDocHistory,
333 strNoActiveDesktopChanges,
369 strNoChangeWallpaper,
441 strNoForgetSoftwareUpdate,
447 strNoSetActiveDesktop,
459 strNoChangeStartMenu,
476 /*************************************************************************
477 * SHRestricted [SHELL32.100]
479 * walks through policy table, queries <app> key, <type> value, returns
480 * queried (DWORD) value, and caches it between called to SHInitRestricted
481 * to prevent unnecessary registry access.
484 * exported by ordinal
487 * MS System Policy Editor
488 * 98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/
489 * "The Windows 95 Registry", by John Woram, 1996 MIS: Press
491 DWORD WINAPI SHRestricted (DWORD pol) {
494 DWORD retval, polidx, i, datsize = 4;
496 TRACE("(%08lx)\n",pol);
500 /* scan to see if we know this policy ID */
501 for (i = 0; i < SHELL_MAX_POLICIES; i++)
503 if (pol == sh32_policy_table[i].polflags)
512 /* we don't know this policy, return 0 */
513 TRACE("unknown policy: (%08lx)\n", pol);
517 /* we have a known policy */
518 strcpy(regstr, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\");
519 strcat(regstr, sh32_policy_table[polidx].appstr);
521 /* first check if this policy has been cached, return it if so */
522 if (sh32_policy_table[polidx].cache != SHELL_NO_POLICY)
524 return sh32_policy_table[polidx].cache;
527 /* return 0 and don't set the cache if any registry errors occur */
529 if (RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey) == ERROR_SUCCESS)
531 if (RegQueryValueExA(xhkey, sh32_policy_table[polidx].keystr, NULL, NULL, (LPBYTE)&retval, &datsize) == ERROR_SUCCESS)
533 sh32_policy_table[polidx].cache = retval;
542 /*************************************************************************
543 * SHInitRestricted [SHELL32.244]
545 * Win98+ by-ordinal only routine called by Explorer and MSIE 4 and 5.
546 * Inits the policy cache used by SHRestricted to avoid excess
550 * Two inputs: one is a string or NULL. If non-NULL the pointer
551 * should point to a string containing the following exact text:
552 * "Software\Microsoft\Windows\CurrentVersion\Policies".
553 * The other input is unused.
556 * If the input is non-NULL and does not point to a string containing
557 * that exact text the routine will do nothing.
559 * If the text does match or the pointer is NULL, then the routine
560 * will init SHRestricted()'s policy cache to all 0xffffffff and
561 * returns 0xffffffff as well.
563 * I haven't yet run into anything calling this with inputs other than
564 * (NULL, NULL), so I may have the inputs reversed.
567 BOOL WINAPI SHInitRestricted(LPSTR inpRegKey, LPSTR parm2)
571 TRACE("(%p, %p)\n", inpRegKey, parm2);
573 /* first check - if input is non-NULL and points to the secret
574 key string, then pass. Otherwise return 0.
577 if (inpRegKey != (LPSTR)NULL)
579 if (lstrcmpiA(inpRegKey, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies"))
581 /* doesn't match, fail */
586 /* check passed, init all policy cache entries with SHELL_NO_POLICY */
587 for (i = 0; i < SHELL_MAX_POLICIES; i++)
589 sh32_policy_table[i].cache = SHELL_NO_POLICY;
592 return SHELL_NO_POLICY;