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

Last change on this file since 10367 was 8614, checked in by sandervl, 23 years ago

compile fixes

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