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