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 v5.00 (W2K)
41 #include "shell32_main.h"
44 #include "wine/debug.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(shell);
48 #define SHELL_NO_POLICY 0xffffffff
50 typedef struct tagPOLICYDAT
52 DWORD policy; /* policy value passed to SHRestricted */
53 LPCSTR appstr; /* application str such as "Explorer" */
54 LPCSTR keystr; /* name of the actual registry key / policy */
55 DWORD cache; /* cached value or 0xffffffff for invalid */
56 } POLICYDATA, *LPPOLICYDATA;
58 /* registry strings */
59 static const CHAR strRegistryPolicyA[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies";
60 static const WCHAR strRegistryPolicyW[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o',
61 's','o','f','t','\\','W','i','n','d','o','w','s','\\',
62 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',
63 '\\','P','o','l','i','c','i','e','s',0};
64 static const CHAR strPolicyA[] = "Policy";
65 static const WCHAR strPolicyW[] = {'P','o','l','i','c','y',0};
67 /* application strings */
69 static const char strExplorer[] = {"Explorer"};
70 static const char strActiveDesk[] = {"ActiveDesktop"};
71 static const char strWinOldApp[] = {"WinOldApp"};
72 static const char strAddRemoveProgs[] = {"AddRemoveProgs"};
76 static const char strNoFileURL[] = {"NoFileUrl"};
77 static const char strNoFolderOptions[] = {"NoFolderOptions"};
78 static const char strNoChangeStartMenu[] = {"NoChangeStartMenu"};
79 static const char strNoWindowsUpdate[] = {"NoWindowsUpdate"};
80 static const char strNoSetActiveDesktop[] = {"NoSetActiveDesktop"};
81 static const char strNoForgetSoftwareUpdate[] = {"NoForgetSoftwareUpdate"};
82 static const char strNoMSAppLogo[] = {"NoMSAppLogo5ChannelNotify"};
83 static const char strForceCopyACLW[] = {"ForceCopyACLWithFile"};
84 static const char strNoResolveTrk[] = {"NoResolveTrack"};
85 static const char strNoResolveSearch[] = {"NoResolveSearch"};
86 static const char strNoEditComponent[] = {"NoEditingComponents"};
87 static const char strNoMovingBand[] = {"NoMovingBands"};
88 static const char strNoCloseDragDrop[] = {"NoCloseDragDropBands"};
89 static const char strNoCloseComponent[] = {"NoClosingComponents"};
90 static const char strNoDelComponent[] = {"NoDeletingComponents"};
91 static const char strNoAddComponent[] = {"NoAddingComponents"};
92 static const char strNoComponent[] = {"NoComponents"};
93 static const char strNoChangeWallpaper[] = {"NoChangingWallpaper"};
94 static const char strNoHTMLWallpaper[] = {"NoHTMLWallpaper"};
95 static const char strNoCustomWebView[] = {"NoCustomizeWebView"};
96 static const char strClassicShell[] = {"ClassicShell"};
97 static const char strClearRecentDocs[] = {"ClearRecentDocsOnExit"};
98 static const char strNoFavoritesMenu[] = {"NoFavoritesMenu"};
99 static const char strNoActiveDesktopChanges[] = {"NoActiveDesktopChanges"};
100 static const char strNoActiveDesktop[] = {"NoActiveDesktop"};
101 static const char strNoRecentDocMenu[] = {"NoRecentDocsMenu"};
102 static const char strNoRecentDocHistory[] = {"NoRecentDocsHistory"};
103 static const char strNoInetIcon[] = {"NoInternetIcon"};
104 static const char strNoSettingsWizard[] = {"NoSettingsWizards"};
105 static const char strNoLogoff[] = {"NoLogoff"};
106 static const char strNoNetConDis[] = {"NoNetConnectDisconnect"};
107 static const char strNoViewContextMenu[] = {"NoViewContextMenu"};
108 static const char strNoTrayContextMenu[] = {"NoTrayContextMenu"};
109 static const char strNoWebMenu[] = {"NoWebMenu"};
110 static const char strLnkResolveIgnoreLnkInfo[] = {"LinkResolveIgnoreLinkInfo"};
111 static const char strNoCommonGroups[] = {"NoCommonGroups"};
112 static const char strEnforceShlExtSecurity[] = {"EnforceShellExtensionSecurity"};
113 static const char strNoRealMode[] = {"NoRealMode"};
114 static const char strMyDocsOnNet[] = {"MyDocsOnNet"};
115 static const char strNoStartMenuSubfolder[] = {"NoStartMenuSubFolders"};
116 static const char strNoAddPrinters[] = {"NoAddPrinter"};
117 static const char strNoDeletePrinters[] = {"NoDeletePrinter"};
118 static const char strNoPrintTab[] = {"NoPrinterTabs"};
119 static const char strRestrictRun[] = {"RestrictRun"};
120 static const char strNoStartBanner[] = {"NoStartBanner"};
121 static const char strNoNetworkNeighborhood[] = {"NoNetHood"};
122 static const char strNoDriveTypeAtRun[] = {"NoDriveTypeAutoRun"};
123 static const char strNoDrivesAutoRun[] = {"NoDriveAutoRun"};
124 static const char strSeparateProcess[] = {"SeparateProcess"};
125 static const char strNoDrives[] = {"NoDrives"};
126 static const char strNoFind[] = {"NoFind"};
127 static const char strNoDesktop[] = {"NoDesktop"};
128 static const char strNoSetTaskBar[] = {"NoSetTaskbar"};
129 static const char strNoSetFld[] = {"NoSetFolders"};
130 static const char strNoFileMenu[] = {"NoFileMenu"};
131 static const char strNoSaveSetting[] = {"NoSaveSettings"};
132 static const char strNoClose[] = {"NoClose"};
133 static const char strNoRun[] = {"NoRun"};
135 /* policy data array */
136 POLICYDATA sh32_policy_table[] =
199 REST_NODRIVETYPEAUTORUN,
207 strNoNetworkNeighborhood,
229 REST_NOPRINTERDELETE,
241 REST_NOSTARTMENUSUBFOLDERS,
243 strNoStartMenuSubfolder,
259 REST_ENFORCESHELLEXTSECURITY,
261 strEnforceShlExtSecurity,
265 REST_LINKRESOLVEIGNORELINKINFO,
267 strLnkResolveIgnoreLnkInfo,
277 REST_SEPARATEDESKTOPPROCESS,
289 REST_NOTRAYCONTEXTMENU,
291 strNoTrayContextMenu,
295 REST_NOVIEWCONTEXTMENU,
297 strNoViewContextMenu,
301 REST_NONETCONNECTDISCONNECT,
307 REST_STARTMENULOGOFF,
313 REST_NOSETTINGSASSIST,
325 REST_NORECENTDOCSHISTORY,
327 strNoRecentDocHistory,
331 REST_NORECENTDOCSMENU,
337 REST_NOACTIVEDESKTOP,
343 REST_NOACTIVEDESKTOPCHANGES,
345 strNoActiveDesktopChanges,
349 REST_NOFAVORITESMENU,
355 REST_CLEARRECENTDOCSONEXIT,
367 REST_NOCUSTOMIZEWEBVIEW,
373 REST_NOHTMLWALLPAPER,
379 REST_NOCHANGINGWALLPAPER,
381 strNoChangeWallpaper,
403 REST_NOCLOSEDESKCOMP,
409 REST_NOCLOSE_DRAGDROPBAND,
427 REST_NORESOLVESEARCH,
439 REST_FORCECOPYACLWITHFILE,
445 REST_NOLOGO3CHANNELNOTIFY,
451 REST_NOFORGETSOFTWAREUPDATE,
453 strNoForgetSoftwareUpdate,
457 REST_NOSETACTIVEDESKTOP,
459 strNoSetActiveDesktop,
463 REST_NOUPDATEWINDOWS,
469 REST_NOCHANGESTARMENU,
471 strNoChangeStartMenu,
475 REST_NOFOLDEROPTIONS,
481 REST_HASFINDCOMPUTERS,
493 REST_RUNDLGMEMCHECKBOX,
495 "MemCheckBoxInRunDlg",
499 REST_ARP_ShowPostSetup,
525 "NoAddRemovePrograms",
529 REST_ARP_NOREMOVEPAGE,
541 REST_ARP_NOWINSETUPPAGE,
543 "NoWindowsSetupPage",
553 REST_NOCHANGEMAPPEDDRIVELABEL,
555 "NoChangeMappedDriveLabel",
559 REST_NOCHANGEMAPPEDDRIVECOMMENT,
561 "NoChangeMappedDriveComment",
571 REST_NONETWORKCONNECTIONS,
573 "NoNetworkConnections",
577 REST_FORCESTARTMENULOGOFF,
579 "ForceStartMenuLogoff",
589 REST_NOCUSTOMIZETHISFOLDER,
591 "NoCustomizeThisFolder",
601 REST_ALLOWFRENCHENCRYPTION,
603 "AllowFrenchEncryption",
607 REST_DONTSHOWSUPERHIDDEN,
609 "DontShowSuperHidden",
613 REST_NOSHELLSEARCHBUTTON,
615 "NoShellSearchButton",
625 REST_NORUNASINSTALLPROMPT,
627 "NoRunasInstallPrompt",
631 REST_PROMPTRUNASINSTALLNETPATH,
633 "PromptRunasInstallNetPath",
637 REST_NOMANAGEMYCOMPUTERVERB,
639 "NoManageMyComputerVerb",
643 REST_NORECENTDOCSNETHOOD,
645 "NoRecentDocsNetHood",
655 REST_NOWELCOMESCREEN,
691 REST_NOENCRYPTONMOVE,
697 REST_NOLOCALMACHINERUN,
699 "DisableLocalMachineRun",
703 REST_NOCURRENTUSERRUN,
705 "DisableCurrentUserRun",
709 REST_NOLOCALMACHINERUNONCE,
711 "DisableLocalMachineRunOnce",
715 REST_NOCURRENTUSERRUNONCE,
717 "DisableCurrentUserRunOnce",
721 REST_FORCEACTIVEDESKTOPON,
723 "ForceActiveDesktopOn",
727 REST_NOCOMPUTERSNEARME,
745 REST_NOSHAREDDOCUMENTS,
756 /* 0x4000050 - 0x4000060 */
758 REST_STARTRUNNOHOMEPATH,
760 "StartRunNoHOMEPATH",
763 /* 0x4000061 - 0x4000086 */
777 REST_NOFILEASSOCIATE,
796 /*************************************************************************
797 * SHRestricted [SHELL32.100]
799 * Get the value associated with a policy Id.
805 * The queried value for the policy.
808 * Exported by ordinal.
809 * This function caches the retrieved values to prevent unnecessary registry access,
810 * if SHInitRestricted() was previously called.
813 * a: MS System Policy Editor.
814 * b: 98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/
815 * c: 'The Windows 95 Registry', by John Woram, 1996 MIS: Press
817 DWORD WINAPI SHRestricted (RESTRICTIONS policy)
821 DWORD retval, datsize = 4;
824 TRACE("(%08x)\n", policy);
826 /* scan to see if we know this policy ID */
827 for (p = sh32_policy_table; p->policy; p++)
829 if (policy == p->policy)
837 /* we don't know this policy, return 0 */
838 TRACE("unknown policy: (%08x)\n", policy);
842 /* we have a known policy */
844 /* first check if this policy has been cached, return it if so */
845 if (p->cache != SHELL_NO_POLICY)
850 lstrcpyA(regstr, strRegistryPolicyA);
851 lstrcatA(regstr, p->appstr);
853 /* return 0 and don't set the cache if any registry errors occur */
855 if (RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey) == ERROR_SUCCESS)
857 if (RegQueryValueExA(xhkey, p->keystr, NULL, NULL, (LPBYTE)&retval, &datsize) == ERROR_SUCCESS)
866 /*************************************************************************
867 * SHInitRestricted [SHELL32.244]
869 * Initialise the policy cache to speed up calls to SHRestricted().
872 * unused [I] Reserved.
873 * inpRegKey [I] Registry key to scan.
876 * Success: -1. The policy cache is initialised.
877 * Failure: 0, if inpRegKey is any value other than NULL, "Policy", or
878 * "Software\Microsoft\Windows\CurrentVersion\Policies".
881 * Exported by ordinal. Introduced in Win98.
883 BOOL WINAPI SHInitRestricted(LPCVOID unused, LPCVOID inpRegKey)
885 TRACE("(%p, %p)\n", unused, inpRegKey);
887 /* first check - if input is non-NULL and points to the secret
888 key string, then pass. Otherwise return 0.
890 if (inpRegKey != NULL)
892 if (SHELL_OsIsUnicode())
894 if (lstrcmpiW((LPWSTR)inpRegKey, strRegistryPolicyW) &&
895 lstrcmpiW((LPWSTR)inpRegKey, strPolicyW))
896 /* doesn't match, fail */
901 if (lstrcmpiA((LPSTR)inpRegKey, strRegistryPolicyA) &&
902 lstrcmpiA((LPSTR)inpRegKey, strPolicyA))
903 /* doesn't match, fail */