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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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 /* application strings */
60 static const char strExplorer
[] = {"Explorer"};
61 static const char strActiveDesk
[] = {"ActiveDesktop"};
62 static const char strWinOldApp
[] = {"WinOldApp"};
63 static const char strAddRemoveProgs
[] = {"AddRemoveProgs"};
67 static const char strNoFileURL
[] = {"NoFileUrl"};
68 static const char strNoFolderOptions
[] = {"NoFolderOptions"};
69 static const char strNoChangeStartMenu
[] = {"NoChangeStartMenu"};
70 static const char strNoWindowsUpdate
[] = {"NoWindowsUpdate"};
71 static const char strNoSetActiveDesktop
[] = {"NoSetActiveDesktop"};
72 static const char strNoForgetSoftwareUpdate
[] = {"NoForgetSoftwareUpdate"};
73 static const char strNoMSAppLogo
[] = {"NoMSAppLogo5ChannelNotify"};
74 static const char strForceCopyACLW
[] = {"ForceCopyACLWithFile"};
75 static const char strNoResolveTrk
[] = {"NoResolveTrack"};
76 static const char strNoResolveSearch
[] = {"NoResolveSearch"};
77 static const char strNoEditComponent
[] = {"NoEditingComponents"};
78 static const char strNoMovingBand
[] = {"NoMovingBands"};
79 static const char strNoCloseDragDrop
[] = {"NoCloseDragDropBands"};
80 static const char strNoCloseComponent
[] = {"NoClosingComponents"};
81 static const char strNoDelComponent
[] = {"NoDeletingComponents"};
82 static const char strNoAddComponent
[] = {"NoAddingComponents"};
83 static const char strNoComponent
[] = {"NoComponents"};
84 static const char strNoChangeWallpaper
[] = {"NoChangingWallpaper"};
85 static const char strNoHTMLWallpaper
[] = {"NoHTMLWallpaper"};
86 static const char strNoCustomWebView
[] = {"NoCustomizeWebView"};
87 static const char strClassicShell
[] = {"ClassicShell"};
88 static const char strClearRecentDocs
[] = {"ClearRecentDocsOnExit"};
89 static const char strNoFavoritesMenu
[] = {"NoFavoritesMenu"};
90 static const char strNoActiveDesktopChanges
[] = {"NoActiveDesktopChanges"};
91 static const char strNoActiveDesktop
[] = {"NoActiveDesktop"};
92 static const char strNoRecentDocMenu
[] = {"NoRecentDocsMenu"};
93 static const char strNoRecentDocHistory
[] = {"NoRecentDocsHistory"};
94 static const char strNoInetIcon
[] = {"NoInternetIcon"};
95 static const char strNoSettingsWizard
[] = {"NoSettingsWizards"};
96 static const char strNoLogoff
[] = {"NoLogoff"};
97 static const char strNoNetConDis
[] = {"NoNetConnectDisconnect"};
98 static const char strNoViewContextMenu
[] = {"NoViewContextMenu"};
99 static const char strNoTrayContextMenu
[] = {"NoTrayContextMenu"};
100 static const char strNoWebMenu
[] = {"NoWebMenu"};
101 static const char strLnkResolveIgnoreLnkInfo
[] = {"LinkResolveIgnoreLinkInfo"};
102 static const char strNoCommonGroups
[] = {"NoCommonGroups"};
103 static const char strEnforceShlExtSecurity
[] = {"EnforceShellExtensionSecurity"};
104 static const char strNoRealMode
[] = {"NoRealMode"};
105 static const char strMyDocsOnNet
[] = {"MyDocsOnNet"};
106 static const char strNoStartMenuSubfolder
[] = {"NoStartMenuSubFolders"};
107 static const char strNoAddPrinters
[] = {"NoAddPrinter"};
108 static const char strNoDeletePrinters
[] = {"NoDeletePrinter"};
109 static const char strNoPrintTab
[] = {"NoPrinterTabs"};
110 static const char strRestrictRun
[] = {"RestrictRun"};
111 static const char strNoStartBanner
[] = {"NoStartBanner"};
112 static const char strNoNetworkNeighborhood
[] = {"NoNetHood"};
113 static const char strNoDriveTypeAtRun
[] = {"NoDriveTypeAutoRun"};
114 static const char strNoDrivesAutoRun
[] = {"NoDriveAutoRun"};
115 static const char strSeparateProcess
[] = {"SeparateProcess"};
116 static const char strNoDrives
[] = {"NoDrives"};
117 static const char strNoFind
[] = {"NoFind"};
118 static const char strNoDesktop
[] = {"NoDesktop"};
119 static const char strNoSetTaskBar
[] = {"NoSetTaskbar"};
120 static const char strNoSetFld
[] = {"NoSetFolders"};
121 static const char strNoFileMenu
[] = {"NoFileMenu"};
122 static const char strNoSaveSetting
[] = {"NoSaveSettings"};
123 static const char strNoClose
[] = {"NoClose"};
124 static const char strNoRun
[] = {"NoRun"};
126 /* policy data array */
127 static POLICYDATA sh32_policy_table
[] =
190 REST_NODRIVETYPEAUTORUN
,
198 strNoNetworkNeighborhood
,
220 REST_NOPRINTERDELETE
,
232 REST_NOSTARTMENUSUBFOLDERS
,
234 strNoStartMenuSubfolder
,
250 REST_ENFORCESHELLEXTSECURITY
,
252 strEnforceShlExtSecurity
,
256 REST_LINKRESOLVEIGNORELINKINFO
,
258 strLnkResolveIgnoreLnkInfo
,
268 REST_SEPARATEDESKTOPPROCESS
,
280 REST_NOTRAYCONTEXTMENU
,
282 strNoTrayContextMenu
,
286 REST_NOVIEWCONTEXTMENU
,
288 strNoViewContextMenu
,
292 REST_NONETCONNECTDISCONNECT
,
298 REST_STARTMENULOGOFF
,
304 REST_NOSETTINGSASSIST
,
316 REST_NORECENTDOCSHISTORY
,
318 strNoRecentDocHistory
,
322 REST_NORECENTDOCSMENU
,
328 REST_NOACTIVEDESKTOP
,
334 REST_NOACTIVEDESKTOPCHANGES
,
336 strNoActiveDesktopChanges
,
340 REST_NOFAVORITESMENU
,
346 REST_CLEARRECENTDOCSONEXIT
,
358 REST_NOCUSTOMIZEWEBVIEW
,
364 REST_NOHTMLWALLPAPER
,
370 REST_NOCHANGINGWALLPAPER
,
372 strNoChangeWallpaper
,
394 REST_NOCLOSEDESKCOMP
,
400 REST_NOCLOSE_DRAGDROPBAND
,
418 REST_NORESOLVESEARCH
,
430 REST_FORCECOPYACLWITHFILE
,
436 REST_NOLOGO3CHANNELNOTIFY
,
442 REST_NOFORGETSOFTWAREUPDATE
,
444 strNoForgetSoftwareUpdate
,
448 REST_NOSETACTIVEDESKTOP
,
450 strNoSetActiveDesktop
,
454 REST_NOUPDATEWINDOWS
,
460 REST_NOCHANGESTARMENU
,
462 strNoChangeStartMenu
,
466 REST_NOFOLDEROPTIONS
,
472 REST_HASFINDCOMPUTERS
,
484 REST_RUNDLGMEMCHECKBOX
,
486 "MemCheckBoxInRunDlg",
490 REST_ARP_ShowPostSetup
,
516 "NoAddRemovePrograms",
520 REST_ARP_NOREMOVEPAGE
,
532 REST_ARP_NOWINSETUPPAGE
,
534 "NoWindowsSetupPage",
544 REST_NOCHANGEMAPPEDDRIVELABEL
,
546 "NoChangeMappedDriveLabel",
550 REST_NOCHANGEMAPPEDDRIVECOMMENT
,
552 "NoChangeMappedDriveComment",
562 REST_NONETWORKCONNECTIONS
,
564 "NoNetworkConnections",
568 REST_FORCESTARTMENULOGOFF
,
570 "ForceStartMenuLogoff",
580 REST_NOCUSTOMIZETHISFOLDER
,
582 "NoCustomizeThisFolder",
592 REST_ALLOWFRENCHENCRYPTION
,
594 "AllowFrenchEncryption",
598 REST_DONTSHOWSUPERHIDDEN
,
600 "DontShowSuperHidden",
604 REST_NOSHELLSEARCHBUTTON
,
606 "NoShellSearchButton",
616 REST_NORUNASINSTALLPROMPT
,
618 "NoRunasInstallPrompt",
622 REST_PROMPTRUNASINSTALLNETPATH
,
624 "PromptRunasInstallNetPath",
628 REST_NOMANAGEMYCOMPUTERVERB
,
630 "NoManageMyComputerVerb",
634 REST_NORECENTDOCSNETHOOD
,
636 "NoRecentDocsNetHood",
646 REST_NOWELCOMESCREEN
,
682 REST_NOENCRYPTONMOVE
,
688 REST_NOLOCALMACHINERUN
,
690 "DisableLocalMachineRun",
694 REST_NOCURRENTUSERRUN
,
696 "DisableCurrentUserRun",
700 REST_NOLOCALMACHINERUNONCE
,
702 "DisableLocalMachineRunOnce",
706 REST_NOCURRENTUSERRUNONCE
,
708 "DisableCurrentUserRunOnce",
712 REST_FORCEACTIVEDESKTOPON
,
714 "ForceActiveDesktopOn",
718 REST_NOCOMPUTERSNEARME
,
736 REST_NOSHAREDDOCUMENTS
,
747 /* 0x4000050 - 0x4000060 */
749 REST_NONLEGACYSHELLMODE
,
751 "NoneLegacyShellMode",
755 REST_STARTRUNNOHOMEPATH
,
757 "StartRunNoHOMEPATH",
760 /* 0x4000061 - 0x4000086 */
774 REST_NOFILEASSOCIATE
,
793 /*************************************************************************
794 * SHRestricted [SHELL32.100]
796 * Get the value associated with a policy Id.
802 * The queried value for the policy.
805 * Exported by ordinal.
806 * This function caches the retrieved values to prevent unnecessary registry access,
807 * if SHInitRestricted() was previously called.
810 * a: MS System Policy Editor.
811 * b: 98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/
812 * c: 'The Windows 95 Registry', by John Woram, 1996 MIS: Press
814 DWORD WINAPI
SHRestricted (RESTRICTIONS policy
)
818 DWORD retval
, datsize
= 4;
821 TRACE("(%08x)\n", policy
);
823 /* scan to see if we know this policy ID */
824 for (p
= sh32_policy_table
; p
->policy
; p
++)
826 if (policy
== p
->policy
)
834 /* we don't know this policy, return 0 */
835 TRACE("unknown policy: (%08x)\n", policy
);
839 /* we have a known policy */
841 /* first check if this policy has been cached, return it if so */
842 if (p
->cache
!= SHELL_NO_POLICY
)
847 lstrcpyA(regstr
, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\");
848 lstrcatA(regstr
, p
->appstr
);
850 /* return 0 and don't set the cache if any registry errors occur */
852 if (RegOpenKeyA(HKEY_CURRENT_USER
, regstr
, &xhkey
) == ERROR_SUCCESS
)
854 if (RegQueryValueExA(xhkey
, p
->keystr
, NULL
, NULL
, (LPBYTE
)&retval
, &datsize
) == ERROR_SUCCESS
)
863 /*************************************************************************
864 * SHInitRestricted [SHELL32.244]
866 * Initialise the policy cache to speed up calls to SHRestricted().
869 * unused [I] Reserved.
870 * inpRegKey [I] Registry key to scan.
873 * Success: -1. The policy cache is initialised.
874 * Failure: 0, if inpRegKey is any value other than NULL, "Policy", or
875 * "Software\Microsoft\Windows\CurrentVersion\Policies".
878 * Exported by ordinal. Introduced in Win98.
880 BOOL WINAPI
SHInitRestricted(LPCVOID unused
, LPCVOID inpRegKey
)
882 TRACE("(%p, %p)\n", unused
, inpRegKey
);
884 /* first check - if input is non-NULL and points to the secret
885 key string, then pass. Otherwise return 0.
887 if (inpRegKey
!= NULL
)
889 if (SHELL_OsIsUnicode())
891 if (lstrcmpiW(inpRegKey
, L
"Software\\Microsoft\\Windows\\CurrentVersion\\Policies") &&
892 lstrcmpiW(inpRegKey
, L
"Policy"))
893 /* doesn't match, fail */
898 if (lstrcmpiA(inpRegKey
, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies") &&
899 lstrcmpiA(inpRegKey
, "Policy"))
900 /* doesn't match, fail */