c9f0ef3668eac2a19efd46d58041bcc779b0cfaa
[reactos.git] / reactos / dll / win32 / shell32 / shpolicy.cpp
1 /*
2 * shpolicy.c - Data for shell/system policies.
3 *
4 * Copyright 1999 Ian Schmidt <ischmidt@cfl.rr.com>
5 *
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.
10 *
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.
15 *
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
19 *
20 * NOTES:
21 *
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
27 * this file...
28 *
29 * Up to date as of SHELL32 v5.00 (W2K)
30 */
31
32 #include "precomp.h"
33
34 WINE_DEFAULT_DEBUG_CHANNEL(shell);
35
36 #define SHELL_NO_POLICY 0xffffffff
37
38 typedef struct tagPOLICYDAT
39 {
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;
45
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};
54
55 /* application strings */
56
57 static const char strExplorer[] = {"Explorer"};
58 static const char strActiveDesk[] = {"ActiveDesktop"};
59 static const char strWinOldApp[] = {"WinOldApp"};
60 static const char strAddRemoveProgs[] = {"AddRemoveProgs"};
61
62 /* key strings */
63
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"};
122
123 /* policy data array */
124 static POLICYDATA sh32_policy_table[] =
125 {
126 {
127 REST_NORUN,
128 strExplorer,
129 strNoRun,
130 SHELL_NO_POLICY
131 },
132 {
133 REST_NOCLOSE,
134 strExplorer,
135 strNoClose,
136 SHELL_NO_POLICY
137 },
138 {
139 REST_NOSAVESET,
140 strExplorer,
141 strNoSaveSetting,
142 SHELL_NO_POLICY
143 },
144 {
145 REST_NOFILEMENU,
146 strExplorer,
147 strNoFileMenu,
148 SHELL_NO_POLICY
149 },
150 {
151 REST_NOSETFOLDERS,
152 strExplorer,
153 strNoSetFld,
154 SHELL_NO_POLICY
155 },
156 {
157 REST_NOSETTASKBAR,
158 strExplorer,
159 strNoSetTaskBar,
160 SHELL_NO_POLICY
161 },
162 {
163 REST_NODESKTOP,
164 strExplorer,
165 strNoDesktop,
166 SHELL_NO_POLICY
167 },
168 {
169 REST_NOFIND,
170 strExplorer,
171 strNoFind,
172 SHELL_NO_POLICY
173 },
174 {
175 REST_NODRIVES,
176 strExplorer,
177 strNoDrives,
178 SHELL_NO_POLICY
179 },
180 {
181 REST_NODRIVEAUTORUN,
182 strExplorer,
183 strNoDrivesAutoRun,
184 SHELL_NO_POLICY
185 },
186 {
187 REST_NODRIVETYPEAUTORUN,
188 strExplorer,
189 strNoDriveTypeAtRun,
190 SHELL_NO_POLICY
191 },
192 {
193 REST_NONETHOOD,
194 strExplorer,
195 strNoNetworkNeighborhood,
196 SHELL_NO_POLICY
197 },
198 {
199 REST_STARTBANNER,
200 strExplorer,
201 strNoStartBanner,
202 SHELL_NO_POLICY
203 },
204 {
205 REST_RESTRICTRUN,
206 strExplorer,
207 strRestrictRun,
208 SHELL_NO_POLICY
209 },
210 {
211 REST_NOPRINTERTABS,
212 strExplorer,
213 strNoPrintTab,
214 SHELL_NO_POLICY
215 },
216 {
217 REST_NOPRINTERDELETE,
218 strExplorer,
219 strNoDeletePrinters,
220 SHELL_NO_POLICY
221 },
222 {
223 REST_NOPRINTERADD,
224 strExplorer,
225 strNoAddPrinters,
226 SHELL_NO_POLICY
227 },
228 {
229 REST_NOSTARTMENUSUBFOLDERS,
230 strExplorer,
231 strNoStartMenuSubfolder,
232 SHELL_NO_POLICY
233 },
234 {
235 REST_MYDOCSONNET,
236 strExplorer,
237 strMyDocsOnNet,
238 SHELL_NO_POLICY
239 },
240 {
241 REST_NOEXITTODOS,
242 strWinOldApp,
243 strNoRealMode,
244 SHELL_NO_POLICY
245 },
246 {
247 REST_ENFORCESHELLEXTSECURITY,
248 strExplorer,
249 strEnforceShlExtSecurity,
250 SHELL_NO_POLICY
251 },
252 {
253 REST_LINKRESOLVEIGNORELINKINFO,
254 strExplorer,
255 strLnkResolveIgnoreLnkInfo,
256 SHELL_NO_POLICY
257 },
258 {
259 REST_NOCOMMONGROUPS,
260 strExplorer,
261 strNoCommonGroups,
262 SHELL_NO_POLICY
263 },
264 {
265 REST_SEPARATEDESKTOPPROCESS,
266 strExplorer,
267 strSeparateProcess,
268 SHELL_NO_POLICY
269 },
270 {
271 REST_NOWEB,
272 strExplorer,
273 strNoWebMenu,
274 SHELL_NO_POLICY
275 },
276 {
277 REST_NOTRAYCONTEXTMENU,
278 strExplorer,
279 strNoTrayContextMenu,
280 SHELL_NO_POLICY
281 },
282 {
283 REST_NOVIEWCONTEXTMENU,
284 strExplorer,
285 strNoViewContextMenu,
286 SHELL_NO_POLICY
287 },
288 {
289 REST_NONETCONNECTDISCONNECT,
290 strExplorer,
291 strNoNetConDis,
292 SHELL_NO_POLICY
293 },
294 {
295 REST_STARTMENULOGOFF,
296 strExplorer,
297 strNoLogoff,
298 SHELL_NO_POLICY
299 },
300 {
301 REST_NOSETTINGSASSIST,
302 strExplorer,
303 strNoSettingsWizard,
304 SHELL_NO_POLICY
305 },
306 {
307 REST_NOINTERNETICON,
308 strExplorer,
309 strNoInetIcon,
310 SHELL_NO_POLICY
311 },
312 {
313 REST_NORECENTDOCSHISTORY,
314 strExplorer,
315 strNoRecentDocHistory,
316 SHELL_NO_POLICY
317 },
318 {
319 REST_NORECENTDOCSMENU,
320 strExplorer,
321 strNoRecentDocMenu,
322 SHELL_NO_POLICY
323 },
324 {
325 REST_NOACTIVEDESKTOP,
326 strExplorer,
327 strNoActiveDesktop,
328 SHELL_NO_POLICY
329 },
330 {
331 REST_NOACTIVEDESKTOPCHANGES,
332 strExplorer,
333 strNoActiveDesktopChanges,
334 SHELL_NO_POLICY
335 },
336 {
337 REST_NOFAVORITESMENU,
338 strExplorer,
339 strNoFavoritesMenu,
340 SHELL_NO_POLICY
341 },
342 {
343 REST_CLEARRECENTDOCSONEXIT,
344 strExplorer,
345 strClearRecentDocs,
346 SHELL_NO_POLICY
347 },
348 {
349 REST_CLASSICSHELL,
350 strExplorer,
351 strClassicShell,
352 SHELL_NO_POLICY
353 },
354 {
355 REST_NOCUSTOMIZEWEBVIEW,
356 strExplorer,
357 strNoCustomWebView,
358 SHELL_NO_POLICY
359 },
360 {
361 REST_NOHTMLWALLPAPER,
362 strActiveDesk,
363 strNoHTMLWallpaper,
364 SHELL_NO_POLICY
365 },
366 {
367 REST_NOCHANGINGWALLPAPER,
368 strActiveDesk,
369 strNoChangeWallpaper,
370 SHELL_NO_POLICY
371 },
372 {
373 REST_NODESKCOMP,
374 strActiveDesk,
375 strNoComponent,
376 SHELL_NO_POLICY
377 },
378 {
379 REST_NOADDDESKCOMP,
380 strActiveDesk,
381 strNoAddComponent,
382 SHELL_NO_POLICY
383 },
384 {
385 REST_NODELDESKCOMP,
386 strActiveDesk,
387 strNoDelComponent,
388 SHELL_NO_POLICY
389 },
390 {
391 REST_NOCLOSEDESKCOMP,
392 strActiveDesk,
393 strNoCloseComponent,
394 SHELL_NO_POLICY
395 },
396 {
397 REST_NOCLOSE_DRAGDROPBAND,
398 strActiveDesk,
399 strNoCloseDragDrop,
400 SHELL_NO_POLICY
401 },
402 {
403 REST_NOMOVINGBAND,
404 strActiveDesk,
405 strNoMovingBand,
406 SHELL_NO_POLICY
407 },
408 {
409 REST_NOEDITDESKCOMP,
410 strActiveDesk,
411 strNoEditComponent,
412 SHELL_NO_POLICY
413 },
414 {
415 REST_NORESOLVESEARCH,
416 strExplorer,
417 strNoResolveSearch,
418 SHELL_NO_POLICY
419 },
420 {
421 REST_NORESOLVETRACK,
422 strExplorer,
423 strNoResolveTrk,
424 SHELL_NO_POLICY
425 },
426 {
427 REST_FORCECOPYACLWITHFILE,
428 strExplorer,
429 strForceCopyACLW,
430 SHELL_NO_POLICY
431 },
432 #if (NTDDI_VERSION < NTDDI_LONGHORN)
433 {
434 REST_NOLOGO3CHANNELNOTIFY,
435 strExplorer,
436 strNoMSAppLogo,
437 SHELL_NO_POLICY
438 },
439 #endif
440 {
441 REST_NOFORGETSOFTWAREUPDATE,
442 strExplorer,
443 strNoForgetSoftwareUpdate,
444 SHELL_NO_POLICY
445 },
446 {
447 REST_NOSETACTIVEDESKTOP,
448 strExplorer,
449 strNoSetActiveDesktop,
450 SHELL_NO_POLICY
451 },
452 {
453 REST_NOUPDATEWINDOWS,
454 strExplorer,
455 strNoWindowsUpdate,
456 SHELL_NO_POLICY
457 },
458 {
459 REST_NOCHANGESTARMENU,
460 strExplorer,
461 strNoChangeStartMenu,
462 SHELL_NO_POLICY
463 },
464 {
465 REST_NOFOLDEROPTIONS,
466 strExplorer,
467 strNoFolderOptions,
468 SHELL_NO_POLICY
469 },
470 {
471 REST_HASFINDCOMPUTERS,
472 strExplorer,
473 "FindComputers",
474 SHELL_NO_POLICY
475 },
476 {
477 REST_INTELLIMENUS,
478 strExplorer,
479 "IntelliMenus",
480 SHELL_NO_POLICY
481 },
482 {
483 REST_RUNDLGMEMCHECKBOX,
484 strExplorer,
485 "MemCheckBoxInRunDlg",
486 SHELL_NO_POLICY
487 },
488 {
489 REST_ARP_ShowPostSetup,
490 strAddRemoveProgs,
491 "ShowPostSetup",
492 SHELL_NO_POLICY
493 },
494 {
495 REST_NOCSC,
496 strExplorer,
497 "NoSyncAll",
498 SHELL_NO_POLICY
499 },
500 {
501 REST_NOCONTROLPANEL,
502 strExplorer,
503 "NoControlPanel",
504 SHELL_NO_POLICY
505 },
506 {
507 REST_ENUMWORKGROUP,
508 strExplorer,
509 "EnumWorkgroup",
510 SHELL_NO_POLICY
511 },
512 {
513 REST_ARP_NOARP,
514 strAddRemoveProgs,
515 "NoAddRemovePrograms",
516 SHELL_NO_POLICY
517 },
518 {
519 REST_ARP_NOREMOVEPAGE,
520 strAddRemoveProgs,
521 "NoRemovePage",
522 SHELL_NO_POLICY
523 },
524 {
525 REST_ARP_NOADDPAGE,
526 strAddRemoveProgs,
527 "NoAddPage",
528 SHELL_NO_POLICY
529 },
530 {
531 REST_ARP_NOWINSETUPPAGE,
532 strAddRemoveProgs,
533 "NoWindowsSetupPage",
534 SHELL_NO_POLICY
535 },
536 {
537 REST_GREYMSIADS,
538 strExplorer,
539 "",
540 SHELL_NO_POLICY
541 },
542 {
543 REST_NOCHANGEMAPPEDDRIVELABEL,
544 strExplorer,
545 "NoChangeMappedDriveLabel",
546 SHELL_NO_POLICY
547 },
548 {
549 REST_NOCHANGEMAPPEDDRIVECOMMENT,
550 strExplorer,
551 "NoChangeMappedDriveComment",
552 SHELL_NO_POLICY
553 },
554 {
555 REST_MaxRecentDocs,
556 strExplorer,
557 "MaxRecentDocs",
558 SHELL_NO_POLICY
559 },
560 {
561 REST_NONETWORKCONNECTIONS,
562 strExplorer,
563 "NoNetworkConnections",
564 SHELL_NO_POLICY
565 },
566 {
567 REST_FORCESTARTMENULOGOFF,
568 strExplorer,
569 "ForceStartMenuLogoff",
570 SHELL_NO_POLICY
571 },
572 {
573 REST_NOWEBVIEW,
574 strExplorer,
575 "NoWebView",
576 SHELL_NO_POLICY
577 },
578 {
579 REST_NOCUSTOMIZETHISFOLDER,
580 strExplorer,
581 "NoCustomizeThisFolder",
582 SHELL_NO_POLICY
583 },
584 {
585 REST_NOENCRYPTION,
586 strExplorer,
587 "NoEncryption",
588 SHELL_NO_POLICY
589 },
590 {
591 REST_ALLOWFRENCHENCRYPTION,
592 strExplorer,
593 "AllowFrenchEncryption",
594 SHELL_NO_POLICY
595 },
596 {
597 REST_DONTSHOWSUPERHIDDEN,
598 strExplorer,
599 "DontShowSuperHidden",
600 SHELL_NO_POLICY
601 },
602 {
603 REST_NOSHELLSEARCHBUTTON,
604 strExplorer,
605 "NoShellSearchButton",
606 SHELL_NO_POLICY
607 },
608 {
609 REST_NOHARDWARETAB,
610 strExplorer,
611 "NoHardwareTab",
612 SHELL_NO_POLICY
613 },
614 {
615 REST_NORUNASINSTALLPROMPT,
616 strExplorer,
617 "NoRunasInstallPrompt",
618 SHELL_NO_POLICY
619 },
620 {
621 REST_PROMPTRUNASINSTALLNETPATH,
622 strExplorer,
623 "PromptRunasInstallNetPath",
624 SHELL_NO_POLICY
625 },
626 {
627 REST_NOMANAGEMYCOMPUTERVERB,
628 strExplorer,
629 "NoManageMyComputerVerb",
630 SHELL_NO_POLICY
631 },
632 {
633 REST_NORECENTDOCSNETHOOD,
634 strExplorer,
635 "NoRecentDocsNetHood",
636 SHELL_NO_POLICY
637 },
638 {
639 REST_DISALLOWRUN,
640 strExplorer,
641 "DisallowRun",
642 SHELL_NO_POLICY
643 },
644 {
645 REST_NOWELCOMESCREEN,
646 strExplorer,
647 "NoWelcomeScreen",
648 SHELL_NO_POLICY
649 },
650 {
651 REST_RESTRICTCPL,
652 strExplorer,
653 "RestrictCpl",
654 SHELL_NO_POLICY
655 },
656 {
657 REST_DISALLOWCPL,
658 strExplorer,
659 "DisallowCpl",
660 SHELL_NO_POLICY
661 },
662 {
663 REST_NOSMBALLOONTIP,
664 strExplorer,
665 "NoSMBalloonTip",
666 SHELL_NO_POLICY
667 },
668 {
669 REST_NOSMHELP,
670 strExplorer,
671 "NoSMHelp",
672 SHELL_NO_POLICY
673 },
674 {
675 REST_NOWINKEYS,
676 strExplorer,
677 "NoWinKeys",
678 SHELL_NO_POLICY
679 },
680 {
681 REST_NOENCRYPTONMOVE,
682 strExplorer,
683 "NoEncryptOnMove",
684 SHELL_NO_POLICY
685 },
686 {
687 REST_NOLOCALMACHINERUN,
688 strExplorer,
689 "DisableLocalMachineRun",
690 SHELL_NO_POLICY
691 },
692 {
693 REST_NOCURRENTUSERRUN,
694 strExplorer,
695 "DisableCurrentUserRun",
696 SHELL_NO_POLICY
697 },
698 {
699 REST_NOLOCALMACHINERUNONCE,
700 strExplorer,
701 "DisableLocalMachineRunOnce",
702 SHELL_NO_POLICY
703 },
704 {
705 REST_NOCURRENTUSERRUNONCE,
706 strExplorer,
707 "DisableCurrentUserRunOnce",
708 SHELL_NO_POLICY
709 },
710 {
711 REST_FORCEACTIVEDESKTOPON,
712 strExplorer,
713 "ForceActiveDesktopOn",
714 SHELL_NO_POLICY
715 },
716 {
717 REST_NOCOMPUTERSNEARME,
718 strExplorer,
719 "NoComputersNearMe",
720 SHELL_NO_POLICY
721 },
722 {
723 REST_NOVIEWONDRIVE,
724 strExplorer,
725 "NoViewOnDrive",
726 SHELL_NO_POLICY
727 },
728 {
729 REST_NONETCRAWL,
730 strExplorer,
731 "NoNetCrawl",
732 SHELL_NO_POLICY
733 },
734 {
735 REST_NOSHAREDDOCUMENTS,
736 strExplorer,
737 "NoSharedDocs",
738 SHELL_NO_POLICY
739 },
740 {
741 REST_NOSMMYDOCS,
742 strExplorer,
743 "NoSMMyDocs",
744 SHELL_NO_POLICY
745 },
746 /* 0x4000050 - 0x4000060 */
747 {
748 REST_NONLEGACYSHELLMODE,
749 strExplorer,
750 "NoneLegacyShellMode",
751 SHELL_NO_POLICY
752 },
753 {
754 REST_STARTRUNNOHOMEPATH,
755 strExplorer,
756 "StartRunNoHOMEPATH",
757 SHELL_NO_POLICY
758 },
759 /* 0x4000061 - 0x4000086 */
760 {
761 REST_NODISCONNECT,
762 strExplorer,
763 "NoDisconnect",
764 SHELL_NO_POLICY
765 },
766 {
767 REST_NOSECURITY,
768 strExplorer,
769 "NoNTSecurity",
770 SHELL_NO_POLICY
771 },
772 {
773 REST_NOFILEASSOCIATE,
774 strExplorer,
775 "NoFileAssociate",
776 SHELL_NO_POLICY
777 },
778 {
779 (RESTRICTIONS)0x50000024,
780 strExplorer,
781 strNoFileURL,
782 SHELL_NO_POLICY
783 },
784 {
785 (RESTRICTIONS)0,
786 0,
787 0,
788 SHELL_NO_POLICY
789 }
790 };
791
792 /*************************************************************************
793 * SHRestricted [SHELL32.100]
794 *
795 * Get the value associated with a policy Id.
796 *
797 * PARAMS
798 * pol [I] Policy Id
799 *
800 * RETURNS
801 * The queried value for the policy.
802 *
803 * NOTES
804 * Exported by ordinal.
805 * This function caches the retrieved values to prevent unnecessary registry access,
806 * if SHInitRestricted() was previously called.
807 *
808 * REFERENCES
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
812 */
813 DWORD WINAPI SHRestricted (RESTRICTIONS policy)
814 {
815 char regstr[256];
816 HKEY xhkey;
817 DWORD retval, datsize = 4;
818 LPPOLICYDATA p;
819
820 TRACE("(%08x)\n", policy);
821
822 /* scan to see if we know this policy ID */
823 for (p = sh32_policy_table; p->policy; p++)
824 {
825 if (policy == p->policy)
826 {
827 break;
828 }
829 }
830
831 if (p->policy == 0)
832 {
833 /* we don't know this policy, return 0 */
834 TRACE("unknown policy: (%08x)\n", policy);
835 return 0;
836 }
837
838 /* we have a known policy */
839
840 /* first check if this policy has been cached, return it if so */
841 if (p->cache != SHELL_NO_POLICY)
842 {
843 return p->cache;
844 }
845
846 lstrcpyA(regstr, strRegistryPolicyA);
847 lstrcatA(regstr, p->appstr);
848
849 /* return 0 and don't set the cache if any registry errors occur */
850 retval = 0;
851 if (RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey) == ERROR_SUCCESS)
852 {
853 if (RegQueryValueExA(xhkey, p->keystr, NULL, NULL, (LPBYTE)&retval, &datsize) == ERROR_SUCCESS)
854 {
855 p->cache = retval;
856 }
857 RegCloseKey(xhkey);
858 }
859 return retval;
860 }
861
862 /*************************************************************************
863 * SHInitRestricted [SHELL32.244]
864 *
865 * Initialise the policy cache to speed up calls to SHRestricted().
866 *
867 * PARAMS
868 * unused [I] Reserved.
869 * inpRegKey [I] Registry key to scan.
870 *
871 * RETURNS
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".
875 *
876 * NOTES
877 * Exported by ordinal. Introduced in Win98.
878 */
879 BOOL WINAPI SHInitRestricted(LPCVOID unused, LPCVOID inpRegKey)
880 {
881 TRACE("(%p, %p)\n", unused, inpRegKey);
882
883 /* first check - if input is non-NULL and points to the secret
884 key string, then pass. Otherwise return 0.
885 */
886 if (inpRegKey != NULL)
887 {
888 if (SHELL_OsIsUnicode())
889 {
890 if (lstrcmpiW((LPCWSTR)inpRegKey, strRegistryPolicyW) &&
891 lstrcmpiW((LPCWSTR)inpRegKey, strPolicyW))
892 /* doesn't match, fail */
893 return 0;
894 }
895 else
896 {
897 if (lstrcmpiA((LPCSTR)inpRegKey, strRegistryPolicyA) &&
898 lstrcmpiA((LPCSTR)inpRegKey, strPolicyA))
899 /* doesn't match, fail */
900 return 0;
901 }
902 }
903
904 return TRUE;
905 }