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)
34 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
36 #define SHELL_NO_POLICY 0xffffffff
38 typedef struct tagPOLICYDAT
40 RESTRICTIONS policy
; /* policy value passed to SHRestricted */
41 LPCSTR appstr
; /* application str such as "Explorer" */
42 LPCSTR keystr
; /* name of the actual registry key / policy */
43 DWORD cache
; /* cached value or 0xffffffff for invalid */
44 } POLICYDATA
, *LPPOLICYDATA
;
46 /* registry strings */
47 static const CHAR strRegistryPolicyA
[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies";
48 static const WCHAR strRegistryPolicyW
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o',
49 's','o','f','t','\\','W','i','n','d','o','w','s','\\',
50 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',
51 '\\','P','o','l','i','c','i','e','s',0};
52 static const CHAR strPolicyA
[] = "Policy";
53 static const WCHAR strPolicyW
[] = {'P','o','l','i','c','y',0};
55 /* application strings */
57 static const char strExplorer
[] = {"Explorer"};
58 static const char strActiveDesk
[] = {"ActiveDesktop"};
59 static const char strWinOldApp
[] = {"WinOldApp"};
60 static const char strAddRemoveProgs
[] = {"AddRemoveProgs"};
64 static const char strNoFileURL
[] = {"NoFileUrl"};
65 static const char strNoFolderOptions
[] = {"NoFolderOptions"};
66 static const char strNoChangeStartMenu
[] = {"NoChangeStartMenu"};
67 static const char strNoWindowsUpdate
[] = {"NoWindowsUpdate"};
68 static const char strNoSetActiveDesktop
[] = {"NoSetActiveDesktop"};
69 static const char strNoForgetSoftwareUpdate
[] = {"NoForgetSoftwareUpdate"};
70 //static const char strNoMSAppLogo[] = {"NoMSAppLogo5ChannelNotify"};
71 static const char strForceCopyACLW
[] = {"ForceCopyACLWithFile"};
72 static const char strNoResolveTrk
[] = {"NoResolveTrack"};
73 static const char strNoResolveSearch
[] = {"NoResolveSearch"};
74 static const char strNoEditComponent
[] = {"NoEditingComponents"};
75 static const char strNoMovingBand
[] = {"NoMovingBands"};
76 static const char strNoCloseDragDrop
[] = {"NoCloseDragDropBands"};
77 static const char strNoCloseComponent
[] = {"NoClosingComponents"};
78 static const char strNoDelComponent
[] = {"NoDeletingComponents"};
79 static const char strNoAddComponent
[] = {"NoAddingComponents"};
80 static const char strNoComponent
[] = {"NoComponents"};
81 static const char strNoChangeWallpaper
[] = {"NoChangingWallpaper"};
82 static const char strNoHTMLWallpaper
[] = {"NoHTMLWallpaper"};
83 static const char strNoCustomWebView
[] = {"NoCustomizeWebView"};
84 static const char strClassicShell
[] = {"ClassicShell"};
85 static const char strClearRecentDocs
[] = {"ClearRecentDocsOnExit"};
86 static const char strNoFavoritesMenu
[] = {"NoFavoritesMenu"};
87 static const char strNoActiveDesktopChanges
[] = {"NoActiveDesktopChanges"};
88 static const char strNoActiveDesktop
[] = {"NoActiveDesktop"};
89 static const char strNoRecentDocMenu
[] = {"NoRecentDocsMenu"};
90 static const char strNoRecentDocHistory
[] = {"NoRecentDocsHistory"};
91 static const char strNoInetIcon
[] = {"NoInternetIcon"};
92 static const char strNoSettingsWizard
[] = {"NoSettingsWizards"};
93 static const char strNoLogoff
[] = {"NoLogoff"};
94 static const char strNoNetConDis
[] = {"NoNetConnectDisconnect"};
95 static const char strNoViewContextMenu
[] = {"NoViewContextMenu"};
96 static const char strNoTrayContextMenu
[] = {"NoTrayContextMenu"};
97 static const char strNoWebMenu
[] = {"NoWebMenu"};
98 static const char strLnkResolveIgnoreLnkInfo
[] = {"LinkResolveIgnoreLinkInfo"};
99 static const char strNoCommonGroups
[] = {"NoCommonGroups"};
100 static const char strEnforceShlExtSecurity
[] = {"EnforceShellExtensionSecurity"};
101 static const char strNoRealMode
[] = {"NoRealMode"};
102 static const char strMyDocsOnNet
[] = {"MyDocsOnNet"};
103 static const char strNoStartMenuSubfolder
[] = {"NoStartMenuSubFolders"};
104 static const char strNoAddPrinters
[] = {"NoAddPrinter"};
105 static const char strNoDeletePrinters
[] = {"NoDeletePrinter"};
106 static const char strNoPrintTab
[] = {"NoPrinterTabs"};
107 static const char strRestrictRun
[] = {"RestrictRun"};
108 static const char strNoStartBanner
[] = {"NoStartBanner"};
109 static const char strNoNetworkNeighborhood
[] = {"NoNetHood"};
110 static const char strNoDriveTypeAtRun
[] = {"NoDriveTypeAutoRun"};
111 static const char strNoDrivesAutoRun
[] = {"NoDriveAutoRun"};
112 static const char strSeparateProcess
[] = {"SeparateProcess"};
113 static const char strNoDrives
[] = {"NoDrives"};
114 static const char strNoFind
[] = {"NoFind"};
115 static const char strNoDesktop
[] = {"NoDesktop"};
116 static const char strNoSetTaskBar
[] = {"NoSetTaskbar"};
117 static const char strNoSetFld
[] = {"NoSetFolders"};
118 static const char strNoFileMenu
[] = {"NoFileMenu"};
119 static const char strNoSaveSetting
[] = {"NoSaveSettings"};
120 static const char strNoClose
[] = {"NoClose"};
121 static const char strNoRun
[] = {"NoRun"};
123 /* policy data array */
124 static POLICYDATA sh32_policy_table
[] =
187 REST_NODRIVETYPEAUTORUN
,
195 strNoNetworkNeighborhood
,
217 REST_NOPRINTERDELETE
,
229 REST_NOSTARTMENUSUBFOLDERS
,
231 strNoStartMenuSubfolder
,
247 REST_ENFORCESHELLEXTSECURITY
,
249 strEnforceShlExtSecurity
,
253 REST_LINKRESOLVEIGNORELINKINFO
,
255 strLnkResolveIgnoreLnkInfo
,
265 REST_SEPARATEDESKTOPPROCESS
,
277 REST_NOTRAYCONTEXTMENU
,
279 strNoTrayContextMenu
,
283 REST_NOVIEWCONTEXTMENU
,
285 strNoViewContextMenu
,
289 REST_NONETCONNECTDISCONNECT
,
295 REST_STARTMENULOGOFF
,
301 REST_NOSETTINGSASSIST
,
313 REST_NORECENTDOCSHISTORY
,
315 strNoRecentDocHistory
,
319 REST_NORECENTDOCSMENU
,
325 REST_NOACTIVEDESKTOP
,
331 REST_NOACTIVEDESKTOPCHANGES
,
333 strNoActiveDesktopChanges
,
337 REST_NOFAVORITESMENU
,
343 REST_CLEARRECENTDOCSONEXIT
,
355 REST_NOCUSTOMIZEWEBVIEW
,
361 REST_NOHTMLWALLPAPER
,
367 REST_NOCHANGINGWALLPAPER
,
369 strNoChangeWallpaper
,
391 REST_NOCLOSEDESKCOMP
,
397 REST_NOCLOSE_DRAGDROPBAND
,
415 REST_NORESOLVESEARCH
,
427 REST_FORCECOPYACLWITHFILE
,
432 #if (NTDDI_VERSION < NTDDI_LONGHORN)
434 REST_NOLOGO3CHANNELNOTIFY
,
441 REST_NOFORGETSOFTWAREUPDATE
,
443 strNoForgetSoftwareUpdate
,
447 REST_NOSETACTIVEDESKTOP
,
449 strNoSetActiveDesktop
,
453 REST_NOUPDATEWINDOWS
,
459 REST_NOCHANGESTARMENU
,
461 strNoChangeStartMenu
,
465 REST_NOFOLDEROPTIONS
,
471 REST_HASFINDCOMPUTERS
,
483 REST_RUNDLGMEMCHECKBOX
,
485 "MemCheckBoxInRunDlg",
489 REST_ARP_ShowPostSetup
,
515 "NoAddRemovePrograms",
519 REST_ARP_NOREMOVEPAGE
,
531 REST_ARP_NOWINSETUPPAGE
,
533 "NoWindowsSetupPage",
543 REST_NOCHANGEMAPPEDDRIVELABEL
,
545 "NoChangeMappedDriveLabel",
549 REST_NOCHANGEMAPPEDDRIVECOMMENT
,
551 "NoChangeMappedDriveComment",
561 REST_NONETWORKCONNECTIONS
,
563 "NoNetworkConnections",
567 REST_FORCESTARTMENULOGOFF
,
569 "ForceStartMenuLogoff",
579 REST_NOCUSTOMIZETHISFOLDER
,
581 "NoCustomizeThisFolder",
591 REST_ALLOWFRENCHENCRYPTION
,
593 "AllowFrenchEncryption",
597 REST_DONTSHOWSUPERHIDDEN
,
599 "DontShowSuperHidden",
603 REST_NOSHELLSEARCHBUTTON
,
605 "NoShellSearchButton",
615 REST_NORUNASINSTALLPROMPT
,
617 "NoRunasInstallPrompt",
621 REST_PROMPTRUNASINSTALLNETPATH
,
623 "PromptRunasInstallNetPath",
627 REST_NOMANAGEMYCOMPUTERVERB
,
629 "NoManageMyComputerVerb",
633 REST_NORECENTDOCSNETHOOD
,
635 "NoRecentDocsNetHood",
645 REST_NOWELCOMESCREEN
,
681 REST_NOENCRYPTONMOVE
,
687 REST_NOLOCALMACHINERUN
,
689 "DisableLocalMachineRun",
693 REST_NOCURRENTUSERRUN
,
695 "DisableCurrentUserRun",
699 REST_NOLOCALMACHINERUNONCE
,
701 "DisableLocalMachineRunOnce",
705 REST_NOCURRENTUSERRUNONCE
,
707 "DisableCurrentUserRunOnce",
711 REST_FORCEACTIVEDESKTOPON
,
713 "ForceActiveDesktopOn",
717 REST_NOCOMPUTERSNEARME
,
735 REST_NOSHAREDDOCUMENTS
,
746 /* 0x4000050 - 0x4000060 */
748 REST_NONLEGACYSHELLMODE
,
750 "NoneLegacyShellMode",
754 REST_STARTRUNNOHOMEPATH
,
756 "StartRunNoHOMEPATH",
759 /* 0x4000061 - 0x4000086 */
773 REST_NOFILEASSOCIATE
,
779 (RESTRICTIONS
)0x50000024,
792 /*************************************************************************
793 * SHRestricted [SHELL32.100]
795 * Get the value associated with a policy Id.
801 * The queried value for the policy.
804 * Exported by ordinal.
805 * This function caches the retrieved values to prevent unnecessary registry access,
806 * if SHInitRestricted() was previously called.
809 * a: MS System Policy Editor.
810 * b: 98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/
811 * c: 'The Windows 95 Registry', by John Woram, 1996 MIS: Press
813 DWORD WINAPI
SHRestricted (RESTRICTIONS policy
)
817 DWORD retval
, datsize
= 4;
820 TRACE("(%08x)\n", policy
);
822 /* scan to see if we know this policy ID */
823 for (p
= sh32_policy_table
; p
->policy
; p
++)
825 if (policy
== p
->policy
)
833 /* we don't know this policy, return 0 */
834 TRACE("unknown policy: (%08x)\n", policy
);
838 /* we have a known policy */
840 /* first check if this policy has been cached, return it if so */
841 if (p
->cache
!= SHELL_NO_POLICY
)
846 lstrcpyA(regstr
, strRegistryPolicyA
);
847 lstrcatA(regstr
, p
->appstr
);
849 /* return 0 and don't set the cache if any registry errors occur */
851 if (RegOpenKeyA(HKEY_CURRENT_USER
, regstr
, &xhkey
) == ERROR_SUCCESS
)
853 if (RegQueryValueExA(xhkey
, p
->keystr
, NULL
, NULL
, (LPBYTE
)&retval
, &datsize
) == ERROR_SUCCESS
)
862 /*************************************************************************
863 * SHInitRestricted [SHELL32.244]
865 * Initialise the policy cache to speed up calls to SHRestricted().
868 * unused [I] Reserved.
869 * inpRegKey [I] Registry key to scan.
872 * Success: -1. The policy cache is initialised.
873 * Failure: 0, if inpRegKey is any value other than NULL, "Policy", or
874 * "Software\Microsoft\Windows\CurrentVersion\Policies".
877 * Exported by ordinal. Introduced in Win98.
879 BOOL WINAPI
SHInitRestricted(LPCVOID unused
, LPCVOID inpRegKey
)
881 TRACE("(%p, %p)\n", unused
, inpRegKey
);
883 /* first check - if input is non-NULL and points to the secret
884 key string, then pass. Otherwise return 0.
886 if (inpRegKey
!= NULL
)
888 if (SHELL_OsIsUnicode())
890 if (lstrcmpiW((LPCWSTR
)inpRegKey
, strRegistryPolicyW
) &&
891 lstrcmpiW((LPCWSTR
)inpRegKey
, strPolicyW
))
892 /* doesn't match, fail */
897 if (lstrcmpiA((LPCSTR
)inpRegKey
, strRegistryPolicyA
) &&
898 lstrcmpiA((LPCSTR
)inpRegKey
, strPolicyA
))
899 /* doesn't match, fail */