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
;
58 //extern POLICYDATA sh32_policy_table[SHELL_MAX_POLICIES];
60 /* application strings */
62 static char strExplorer
[] = {"Explorer"};
63 static char strActiveDesk
[] = {"ActiveDesktop"};
64 static char strWinOldApp
[] = {"WinOldApp"};
68 static char strNoFileURL
[] = {"NoFileUrl"};
69 static char strNoFolderOptions
[] = {"NoFolderOptions"};
70 static char strNoChangeStartMenu
[] = {"NoChangeStartMenu"};
71 static char strNoWindowsUpdate
[] = {"NoWindowsUpdate"};
72 static char strNoSetActiveDesktop
[] = {"NoSetActiveDesktop"};
73 static char strNoForgetSoftwareUpdate
[] = {"NoForgetSoftwareUpdate"};
74 static char strNoMSAppLogo
[] = {"NoMSAppLogo5ChannelNotify"};
75 static char strForceCopyACLW
[] = {"ForceCopyACLWithFile"};
76 static char strNoResolveTrk
[] = {"NoResolveTrack"};
77 static char strNoResolveSearch
[] = {"NoResolveSearch"};
78 static char strNoEditComponent
[] = {"NoEditingComponents"};
79 static char strNoMovingBand
[] = {"NoMovingBands"};
80 static char strNoCloseDragDrop
[] = {"NoCloseDragDropBands"};
81 static char strNoCloseComponent
[] = {"NoClosingComponents"};
82 static char strNoDelComponent
[] = {"NoDeletingComponents"};
83 static char strNoAddComponent
[] = {"NoAddingComponents"};
84 static char strNoComponent
[] = {"NoComponents"};
85 static char strNoChangeWallpaper
[] = {"NoChangingWallpaper"};
86 static char strNoHTMLWallpaper
[] = {"NoHTMLWallpaper"};
87 static char strNoCustomWebView
[] = {"NoCustomizeWebView"};
88 static char strClassicShell
[] = {"ClassicShell"};
89 static char strClearRecentDocs
[] = {"ClearRecentDocsOnExit"};
90 static char strNoFavoritesMenu
[] = {"NoFavoritesMenu"};
91 static char strNoActiveDesktopChanges
[] = {"NoActiveDesktopChanges"};
92 static char strNoActiveDesktop
[] = {"NoActiveDesktop"};
93 static char strNoRecentDocMenu
[] = {"NoRecentDocsMenu"};
94 static char strNoRecentDocHistory
[] = {"NoRecentDocsHistory"};
95 static char strNoInetIcon
[] = {"NoInternetIcon"};
96 static char strNoStngsWizard
[] = {"NoSettingsWizards"};
97 static char strNoLogoff
[] = {"NoLogoff"};
98 static char strNoNetConDis
[] = {"NoNetConnectDisconnect"};
99 static char strNoContextMenu
[] = {"NoViewContextMenu"};
100 static char strNoTryContextMenu
[] = {"NoTrayContextMenu"};
101 static char strNoWebMenu
[] = {"NoWebMenu"};
102 static char strLnkResolveIgnoreLnkInfo
[] = {"LinkResolveIgnoreLinkInfo"};
103 static char strNoCommonGroups
[] = {"NoCommonGroups"};
104 static char strEnforceShlExtSecurity
[] = {"EnforceShellExtensionSecurity"};
105 static char strNoRealMode
[] = {"NoRealMode"};
106 static char strMyDocsOnNet
[] = {"MyDocsOnNet"};
107 static char strNoStartMenuSubfolder
[] = {"NoStartMenuSubFolders"};
108 static char strNoAddPrinters
[] = {"NoAddPrinter"};
109 static char strNoDeletePrinters
[] = {"NoDeletePrinter"};
110 static char strNoPrintTab
[] = {"NoPrinterTabs"};
111 static char strRestrictRun
[] = {"RestrictRun"};
112 static char strNoStartBanner
[] = {"NoStartBanner"};
113 static char strNoNetworkNeighborhood
[] = {"NoNetHood"};
114 static char strNoDriveTypeAtRun
[] = {"NoDriveTypeAutoRun"};
115 static char strNoDrivesAutoRun
[] = {"NoDriveAutoRun"};
116 static char strNoDrives
[] = {"NoDrives"};
117 static char strNoFind
[] = {"NoFind"};
118 static char strNoDesktop
[] = {"NoDesktop"};
119 static char strNoSetTaskBar
[] = {"NoSetTaskbar"};
120 static char strNoSetFld
[] = {"NoSetFolders"};
121 static char strNoFileMenu
[] = {"NoFileMenu"};
122 static char strNoSavSetng
[] = {"NoSaveSettings"};
123 static char strNoClose
[] = {"NoClose"};
124 static char strNoRun
[] = {"NoRun"};
126 /* policy data array */
128 POLICYDATA sh32_policy_table
[] =
199 strNoNetworkNeighborhood
,
235 strNoStartMenuSubfolder
,
253 strEnforceShlExtSecurity
,
259 strLnkResolveIgnoreLnkInfo
,
313 strNoRecentDocHistory
,
331 strNoActiveDesktopChanges
,
367 strNoChangeWallpaper
,
439 strNoForgetSoftwareUpdate
,
445 strNoSetActiveDesktop
,
457 strNoChangeStartMenu
,
474 /*************************************************************************
475 * SHRestricted [SHELL32.100]
477 * walks through policy table, queries <app> key, <type> value, returns
478 * queried (DWORD) value, and caches it between called to SHInitRestricted
479 * to prevent unnecessary registry access.
482 * exported by ordinal
485 * MS System Policy Editor
486 * 98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/
487 * "The Windows 95 Registry", by John Woram, 1996 MIS: Press
489 DWORD WINAPI
SHRestricted (DWORD pol
) {
492 DWORD retval
, polidx
, i
, datsize
= 4;
494 TRACE("(%08lx)\n",pol
);
498 /* scan to see if we know this policy ID */
499 for (i
= 0; i
< SHELL_MAX_POLICIES
; i
++)
501 if (pol
== sh32_policy_table
[i
].polflags
)
510 /* we don't know this policy, return 0 */
511 TRACE("unknown policy: (%08lx)\n", pol
);
515 /* we have a known policy */
516 strcpy(regstr
, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\");
517 strcat(regstr
, sh32_policy_table
[polidx
].appstr
);
519 /* first check if this policy has been cached, return it if so */
520 if (sh32_policy_table
[polidx
].cache
!= SHELL_NO_POLICY
)
522 return sh32_policy_table
[polidx
].cache
;
525 /* return 0 and don't set the cache if any registry errors occur */
527 if (RegOpenKeyA(HKEY_CURRENT_USER
, regstr
, &xhkey
) == ERROR_SUCCESS
)
529 if (RegQueryValueExA(xhkey
, sh32_policy_table
[polidx
].keystr
, NULL
, NULL
, (LPBYTE
)&retval
, &datsize
) == ERROR_SUCCESS
)
531 sh32_policy_table
[polidx
].cache
= retval
;
540 /*************************************************************************
541 * SHInitRestricted [SHELL32.244]
543 * Win98+ by-ordinal only routine called by Explorer and MSIE 4 and 5.
544 * Inits the policy cache used by SHRestricted to avoid excess
548 * Two inputs: one is a string or NULL. If non-NULL the pointer
549 * should point to a string containing the following exact text:
550 * "Software\Microsoft\Windows\CurrentVersion\Policies".
551 * The other input is unused.
554 * If the input is non-NULL and does not point to a string containing
555 * that exact text the routine will do nothing.
557 * If the text does match or the pointer is NULL, then the routine
558 * will init SHRestricted()'s policy cache to all 0xffffffff and
559 * returns 0xffffffff as well.
561 * I haven't yet run into anything calling this with inputs other than
562 * (NULL, NULL), so I may have the inputs reversed.
565 BOOL WINAPI
SHInitRestricted(LPSTR inpRegKey
, LPSTR parm2
)
569 TRACE("(%p, %p)\n", inpRegKey
, parm2
);
571 /* first check - if input is non-NULL and points to the secret
572 key string, then pass. Otherwise return 0.
575 if (inpRegKey
!= (LPSTR
)NULL
)
577 if (lstrcmpiA(inpRegKey
, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies"))
579 /* doesn't match, fail */
584 /* check passed, init all policy cache entries with SHELL_NO_POLICY */
585 for (i
= 0; i
< SHELL_MAX_POLICIES
; i
++)
587 sh32_policy_table
[i
].cache
= SHELL_NO_POLICY
;
590 return SHELL_NO_POLICY
;