source: trunk/src/shell32/shpolicy.c@ 6650

Last change on this file since 6650 was 6650, checked in by bird, 24 years ago

Added $Id:$ keyword.

File size: 12.5 KB
Line 
1/* $Id: shpolicy.c,v 1.3 2001-09-05 13:47:00 bird Exp $ */
2/*
3 * shpolicy.c - Data for shell/system policies.
4 *
5 * Created 1999 by Ian Schmidt <ischmidt@cfl.rr.com>
6 *
7 * Some of these policies can be tweaked via the System Policy
8 * Editor which came with the Win95 Migration Guide, although
9 * there doesn't appear to be an updated Win98 version that
10 * would handle the many new policies introduced since then.
11 * You could easily write one with the information in
12 * this file...
13 *
14 * Up to date as of SHELL32 v4.72 (Win98, Win95 with MSIE 5)
15 */
16
17#include <stdlib.h>
18#include <string.h>
19
20#include "windef.h"
21#include "wingdi.h"
22#include "winerror.h"
23#include "winreg.h"
24#include "debugtools.h"
25#include "wine/winuser16.h"
26
27DEFAULT_DEBUG_CHANNEL(shell);
28
29#define SHELL_MAX_POLICIES 57
30
31#define SHELL_NO_POLICY 0xffffffff
32
33typedef struct tagPOLICYDAT
34{
35 DWORD polflags; /* flags value passed to SHRestricted */
36 LPSTR appstr; /* application str such as "Explorer" */
37 LPSTR keystr; /* name of the actual registry key / policy */
38 DWORD cache; /* cached value or 0xffffffff for invalid */
39} POLICYDATA, *LPPOLICYDATA;
40
41//extern POLICYDATA sh32_policy_table[SHELL_MAX_POLICIES];
42
43/* application strings */
44
45static char strExplorer[] = {"Explorer"};
46static char strActiveDesk[] = {"ActiveDesktop"};
47static char strWinOldApp[] = {"WinOldApp"};
48
49/* key strings */
50
51static char strNoFileURL[] = {"NoFileUrl"};
52static char strNoFolderOptions[] = {"NoFolderOptions"};
53static char strNoChangeStartMenu[] = {"NoChangeStartMenu"};
54static char strNoWindowsUpdate[] = {"NoWindowsUpdate"};
55static char strNoSetActiveDesktop[] = {"NoSetActiveDesktop"};
56static char strNoForgetSoftwareUpdate[] = {"NoForgetSoftwareUpdate"};
57static char strNoMSAppLogo[] = {"NoMSAppLogo5ChannelNotify"};
58static char strForceCopyACLW[] = {"ForceCopyACLWithFile"};
59static char strNoResolveTrk[] = {"NoResolveTrack"};
60static char strNoResolveSearch[] = {"NoResolveSearch"};
61static char strNoEditComponent[] = {"NoEditingComponents"};
62static char strNoMovingBand[] = {"NoMovingBands"};
63static char strNoCloseDragDrop[] = {"NoCloseDragDropBands"};
64static char strNoCloseComponent[] = {"NoClosingComponents"};
65static char strNoDelComponent[] = {"NoDeletingComponents"};
66static char strNoAddComponent[] = {"NoAddingComponents"};
67static char strNoComponent[] = {"NoComponents"};
68static char strNoChangeWallpaper[] = {"NoChangingWallpaper"};
69static char strNoHTMLWallpaper[] = {"NoHTMLWallpaper"};
70static char strNoCustomWebView[] = {"NoCustomizeWebView"};
71static char strClassicShell[] = {"ClassicShell"};
72static char strClearRecentDocs[] = {"ClearRecentDocsOnExit"};
73static char strNoFavoritesMenu[] = {"NoFavoritesMenu"};
74static char strNoActiveDesktopChanges[] = {"NoActiveDesktopChanges"};
75static char strNoActiveDesktop[] = {"NoActiveDesktop"};
76static char strNoRecentDocMenu[] = {"NoRecentDocsMenu"};
77static char strNoRecentDocHistory[] = {"NoRecentDocsHistory"};
78static char strNoInetIcon[] = {"NoInternetIcon"};
79static char strNoStngsWizard[] = {"NoSettingsWizards"};
80static char strNoLogoff[] = {"NoLogoff"};
81static char strNoNetConDis[] = {"NoNetConnectDisconnect"};
82static char strNoContextMenu[] = {"NoViewContextMenu"};
83static char strNoTryContextMenu[] = {"NoTrayContextMenu"};
84static char strNoWebMenu[] = {"NoWebMenu"};
85static char strLnkResolveIgnoreLnkInfo[] = {"LinkResolveIgnoreLinkInfo"};
86static char strNoCommonGroups[] = {"NoCommonGroups"};
87static char strEnforceShlExtSecurity[] = {"EnforceShellExtensionSecurity"};
88static char strNoRealMode[] = {"NoRealMode"};
89static char strMyDocsOnNet[] = {"MyDocsOnNet"};
90static char strNoStartMenuSubfolder[] = {"NoStartMenuSubFolders"};
91static char strNoAddPrinters[] = {"NoAddPrinter"};
92static char strNoDeletePrinters[] = {"NoDeletePrinter"};
93static char strNoPrintTab[] = {"NoPrinterTabs"};
94static char strRestrictRun[] = {"RestrictRun"};
95static char strNoStartBanner[] = {"NoStartBanner"};
96static char strNoNetworkNeighborhood[] = {"NoNetHood"};
97static char strNoDriveTypeAtRun[] = {"NoDriveTypeAutoRun"};
98static char strNoDrivesAutoRun[] = {"NoDriveAutoRun"};
99static char strNoDrives[] = {"NoDrives"};
100static char strNoFind[] = {"NoFind"};
101static char strNoDesktop[] = {"NoDesktop"};
102static char strNoSetTaskBar[] = {"NoSetTaskbar"};
103static char strNoSetFld[] = {"NoSetFolders"};
104static char strNoFileMenu[] = {"NoFileMenu"};
105static char strNoSavSetng[] = {"NoSaveSettings"};
106static char strNoClose[] = {"NoClose"};
107static char strNoRun[] = {"NoRun"};
108
109/* policy data array */
110
111POLICYDATA sh32_policy_table[] =
112{
113 {
114 0x1,
115 strExplorer,
116 strNoRun,
117 SHELL_NO_POLICY
118 },
119 {
120 0x2,
121 strExplorer,
122 strNoClose,
123 SHELL_NO_POLICY
124 },
125 {
126 0x4,
127 strExplorer,
128 strNoSavSetng,
129 SHELL_NO_POLICY
130 },
131 {
132 0x8,
133 strExplorer,
134 strNoFileMenu,
135 SHELL_NO_POLICY
136 },
137 {
138 0x10,
139 strExplorer,
140 strNoSetFld,
141 SHELL_NO_POLICY
142 },
143 {
144 0x20,
145 strExplorer,
146 strNoSetTaskBar,
147 SHELL_NO_POLICY
148 },
149 {
150 0x40,
151 strExplorer,
152 strNoDesktop,
153 SHELL_NO_POLICY
154 },
155 {
156 0x80,
157 strExplorer,
158 strNoFind,
159 SHELL_NO_POLICY
160 },
161 {
162 0x100,
163 strExplorer,
164 strNoDrives,
165 SHELL_NO_POLICY
166 },
167 {
168 0x200,
169 strExplorer,
170 strNoDrivesAutoRun,
171 SHELL_NO_POLICY
172 },
173 {
174 0x400,
175 strExplorer,
176 strNoDriveTypeAtRun,
177 SHELL_NO_POLICY
178 },
179 {
180 0x800,
181 strExplorer,
182 strNoNetworkNeighborhood,
183 SHELL_NO_POLICY
184 },
185 {
186 0x1000,
187 strExplorer,
188 strNoStartBanner,
189 SHELL_NO_POLICY
190 },
191 {
192 0x2000,
193 strExplorer,
194 strRestrictRun,
195 SHELL_NO_POLICY
196 },
197 {
198 0x4000,
199 strExplorer,
200 strNoPrintTab,
201 SHELL_NO_POLICY
202 },
203 {
204 0x8000,
205 strExplorer,
206 strNoDeletePrinters,
207 SHELL_NO_POLICY
208 },
209 {
210 0x10000,
211 strExplorer,
212 strNoAddPrinters,
213 SHELL_NO_POLICY
214 },
215 {
216 0x20000,
217 strExplorer,
218 strNoStartMenuSubfolder,
219 SHELL_NO_POLICY
220 },
221 {
222 0x40000,
223 strExplorer,
224 strMyDocsOnNet,
225 SHELL_NO_POLICY
226 },
227 {
228 0x80000,
229 strWinOldApp,
230 strNoRealMode,
231 SHELL_NO_POLICY
232 },
233 {
234 0x100000,
235 strExplorer,
236 strEnforceShlExtSecurity,
237 SHELL_NO_POLICY
238 },
239 {
240 0x200000,
241 strExplorer,
242 strLnkResolveIgnoreLnkInfo,
243 SHELL_NO_POLICY
244 },
245 {
246 0x400000,
247 strExplorer,
248 strNoCommonGroups,
249 SHELL_NO_POLICY
250 },
251 {
252 0x1000000,
253 strExplorer,
254 strNoWebMenu,
255 SHELL_NO_POLICY
256 },
257 {
258 0x2000000,
259 strExplorer,
260 strNoTryContextMenu,
261 SHELL_NO_POLICY
262 },
263 {
264 0x4000000,
265 strExplorer,
266 strNoContextMenu,
267 SHELL_NO_POLICY
268 },
269 {
270 0x8000000,
271 strExplorer,
272 strNoNetConDis,
273 SHELL_NO_POLICY
274 },
275 {
276 0x10000000,
277 strExplorer,
278 strNoLogoff,
279 SHELL_NO_POLICY
280 },
281 {
282 0x20000000,
283 strExplorer,
284 strNoStngsWizard,
285 SHELL_NO_POLICY
286 },
287 {
288 0x40000001,
289 strExplorer,
290 strNoInetIcon,
291 SHELL_NO_POLICY
292 },
293 {
294 0x40000002,
295 strExplorer,
296 strNoRecentDocHistory,
297 SHELL_NO_POLICY
298 },
299 {
300 0x40000003,
301 strExplorer,
302 strNoRecentDocMenu,
303 SHELL_NO_POLICY
304 },
305 {
306 0x40000004,
307 strExplorer,
308 strNoActiveDesktop,
309 SHELL_NO_POLICY
310 },
311 {
312 0x40000005,
313 strExplorer,
314 strNoActiveDesktopChanges,
315 SHELL_NO_POLICY
316 },
317 {
318 0x40000006,
319 strExplorer,
320 strNoFavoritesMenu,
321 SHELL_NO_POLICY
322 },
323 {
324 0x40000007,
325 strExplorer,
326 strClearRecentDocs,
327 SHELL_NO_POLICY
328 },
329 {
330 0x40000008,
331 strExplorer,
332 strClassicShell,
333 SHELL_NO_POLICY
334 },
335 {
336 0x40000009,
337 strExplorer,
338 strNoCustomWebView,
339 SHELL_NO_POLICY
340 },
341 {
342 0x40000010,
343 strActiveDesk,
344 strNoHTMLWallpaper,
345 SHELL_NO_POLICY
346 },
347 {
348 0x40000011,
349 strActiveDesk,
350 strNoChangeWallpaper,
351 SHELL_NO_POLICY
352 },
353 {
354 0x40000012,
355 strActiveDesk,
356 strNoComponent,
357 SHELL_NO_POLICY
358 },
359 {
360 0x40000013,
361 strActiveDesk,
362 strNoAddComponent,
363 SHELL_NO_POLICY
364 },
365 {
366 0x40000014,
367 strActiveDesk,
368 strNoDelComponent,
369 SHELL_NO_POLICY
370 },
371 {
372 0x40000015,
373 strActiveDesk,
374 strNoCloseComponent,
375 SHELL_NO_POLICY
376 },
377 {
378 0x40000016,
379 strActiveDesk,
380 strNoCloseDragDrop,
381 SHELL_NO_POLICY
382 },
383 {
384 0x40000017,
385 strActiveDesk,
386 strNoMovingBand,
387 SHELL_NO_POLICY
388 },
389 {
390 0x40000018,
391 strActiveDesk,
392 strNoEditComponent,
393 SHELL_NO_POLICY
394 },
395 {
396 0x40000019,
397 strExplorer,
398 strNoResolveSearch,
399 SHELL_NO_POLICY
400 },
401 {
402 0x4000001a,
403 strExplorer,
404 strNoResolveTrk,
405 SHELL_NO_POLICY
406 },
407 {
408 0x4000001b,
409 strExplorer,
410 strForceCopyACLW,
411 SHELL_NO_POLICY
412 },
413 {
414 0x4000001c,
415 strExplorer,
416 strNoMSAppLogo,
417 SHELL_NO_POLICY
418 },
419 {
420 0x4000001d,
421 strExplorer,
422 strNoForgetSoftwareUpdate,
423 SHELL_NO_POLICY
424 },
425 {
426 0x4000001e,
427 strExplorer,
428 strNoSetActiveDesktop,
429 SHELL_NO_POLICY
430 },
431 {
432 0x4000001f,
433 strExplorer,
434 strNoWindowsUpdate,
435 SHELL_NO_POLICY
436 },
437 {
438 0x40000020,
439 strExplorer,
440 strNoChangeStartMenu,
441 SHELL_NO_POLICY
442 },
443 {
444 0x40000021,
445 strExplorer,
446 strNoFolderOptions,
447 SHELL_NO_POLICY
448 },
449 {
450 0x50000024,
451 strExplorer,
452 strNoFileURL,
453 SHELL_NO_POLICY
454 }
455};
456
457/*************************************************************************
458 * SHRestricted [SHELL32.100]
459 *
460 * walks through policy table, queries <app> key, <type> value, returns
461 * queried (DWORD) value, and caches it between called to SHInitRestricted
462 * to prevent unnecessary registry access.
463 *
464 * NOTES
465 * exported by ordinal
466 *
467 * REFERENCES:
468 * MS System Policy Editor
469 * 98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/
470 * "The Windows 95 Registry", by John Woram, 1996 MIS: Press
471 */
472DWORD WINAPI SHRestricted (DWORD pol) {
473 char regstr[256];
474 HKEY xhkey;
475 DWORD retval, polidx, i, datsize = 4;
476
477 TRACE("(%08lx)\n",pol);
478
479 polidx = -1;
480
481 /* scan to see if we know this policy ID */
482 for (i = 0; i < SHELL_MAX_POLICIES; i++)
483 {
484 if (pol == sh32_policy_table[i].polflags)
485 {
486 polidx = i;
487 break;
488 }
489 }
490
491 if (polidx == -1)
492 {
493 /* we don't know this policy, return 0 */
494 TRACE("unknown policy: (%08lx)\n", pol);
495 return 0;
496 }
497
498 /* we have a known policy */
499 strcpy(regstr, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\");
500 strcat(regstr, sh32_policy_table[polidx].appstr);
501
502 /* first check if this policy has been cached, return it if so */
503 if (sh32_policy_table[polidx].cache != SHELL_NO_POLICY)
504 {
505 return sh32_policy_table[polidx].cache;
506 }
507
508 /* return 0 and don't set the cache if any registry errors occur */
509 retval = 0;
510 if (RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey) == ERROR_SUCCESS)
511 {
512 if (RegQueryValueExA(xhkey, sh32_policy_table[polidx].keystr, NULL, NULL, (LPBYTE)&retval, &datsize) == ERROR_SUCCESS)
513 {
514 sh32_policy_table[polidx].cache = retval;
515 }
516
517 RegCloseKey(xhkey);
518}
519
520 return retval;
521}
522
523/*************************************************************************
524 * SHInitRestricted [SHELL32.244]
525 *
526 * Win98+ by-ordinal only routine called by Explorer and MSIE 4 and 5.
527 * Inits the policy cache used by SHRestricted to avoid excess
528 * registry access.
529 *
530 * INPUTS
531 * Two inputs: one is a string or NULL. If non-NULL the pointer
532 * should point to a string containing the following exact text:
533 * "Software\Microsoft\Windows\CurrentVersion\Policies".
534 * The other input is unused.
535 *
536 * NOTES
537 * If the input is non-NULL and does not point to a string containing
538 * that exact text the routine will do nothing.
539 *
540 * If the text does match or the pointer is NULL, then the routine
541 * will init SHRestricted()'s policy cache to all 0xffffffff and
542 * returns 0xffffffff as well.
543 *
544 * I haven't yet run into anything calling this with inputs other than
545 * (NULL, NULL), so I may have the inputs reversed.
546 */
547
548BOOL WINAPI SHInitRestricted(LPSTR inpRegKey, LPSTR parm2)
549{
550 int i;
551
552 TRACE("(%p, %p)\n", inpRegKey, parm2);
553
554 /* first check - if input is non-NULL and points to the secret
555 key string, then pass. Otherwise return 0.
556 */
557
558 if (inpRegKey != (LPSTR)NULL)
559 {
560 if (lstrcmpiA(inpRegKey, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies"))
561 {
562 /* doesn't match, fail */
563 return 0;
564 }
565 }
566
567 /* check passed, init all policy cache entries with SHELL_NO_POLICY */
568 for (i = 0; i < SHELL_MAX_POLICIES; i++)
569 {
570 sh32_policy_table[i].cache = SHELL_NO_POLICY;
571 }
572
573 return SHELL_NO_POLICY;
574}
Note: See TracBrowser for help on using the repository browser.