shpolicy.c 19.2 KB
Newer Older
1 2 3
/*
 * shpolicy.c - Data for shell/system policies.
 *
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 * Copyright 1999 Ian Schmidt <ischmidt@cfl.rr.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * NOTES:
21 22 23 24 25
 *
 * Some of these policies can be tweaked via the System Policy
 * Editor which came with the Win95 Migration Guide, although
 * there doesn't appear to be an updated Win98 version that
 * 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 34 35
#include <stdlib.h>
#include <string.h>

36
#include "windef.h"
37
#include "winbase.h"
38 39
#include "winerror.h"
#include "winreg.h"
40

41
#include "shell32_main.h"
42
#include "shlobj.h"
43

44
#include "wine/debug.h"
45

46
WINE_DEFAULT_DEBUG_CHANNEL(shell);
47 48 49 50 51

#define SHELL_NO_POLICY 0xffffffff

typedef struct tagPOLICYDAT
{
52
  DWORD policy;          /* policy value passed to SHRestricted */
53 54
  LPCSTR appstr;         /* application str such as "Explorer" */
  LPCSTR keystr;         /* name of the actual registry key / policy */
55 56 57
  DWORD cache;           /* cached value or 0xffffffff for invalid */
} POLICYDATA, *LPPOLICYDATA;

58 59 60 61 62 63 64 65
/* registry strings */
static const CHAR strRegistryPolicyA[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies";
static const WCHAR strRegistryPolicyW[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o',
                                           's','o','f','t','\\','W','i','n','d','o','w','s','\\',
                                           'C','u','r','r','e','n','t','V','e','r','s','i','o','n',
                                           '\\','P','o','l','i','c','i','e','s',0};
static const CHAR strPolicyA[] = "Policy";
static const WCHAR strPolicyW[] = {'P','o','l','i','c','y',0};
66 67 68

/* application strings */

69 70 71
static const char strExplorer[] = {"Explorer"};
static const char strActiveDesk[] = {"ActiveDesktop"};
static const char strWinOldApp[] = {"WinOldApp"};
72
static const char strAddRemoveProgs[] = {"AddRemoveProgs"};
73 74 75

/* key strings */

76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
static const char strNoFileURL[] = {"NoFileUrl"};
static const char strNoFolderOptions[] = {"NoFolderOptions"};
static const char strNoChangeStartMenu[] = {"NoChangeStartMenu"};
static const char strNoWindowsUpdate[] = {"NoWindowsUpdate"};
static const char strNoSetActiveDesktop[] = {"NoSetActiveDesktop"};
static const char strNoForgetSoftwareUpdate[] = {"NoForgetSoftwareUpdate"};
static const char strNoMSAppLogo[] = {"NoMSAppLogo5ChannelNotify"};
static const char strForceCopyACLW[] = {"ForceCopyACLWithFile"};
static const char strNoResolveTrk[] = {"NoResolveTrack"};
static const char strNoResolveSearch[] = {"NoResolveSearch"};
static const char strNoEditComponent[] = {"NoEditingComponents"};
static const char strNoMovingBand[] = {"NoMovingBands"};
static const char strNoCloseDragDrop[] = {"NoCloseDragDropBands"};
static const char strNoCloseComponent[] = {"NoClosingComponents"};
static const char strNoDelComponent[] = {"NoDeletingComponents"};
static const char strNoAddComponent[] = {"NoAddingComponents"};
static const char strNoComponent[] = {"NoComponents"};
static const char strNoChangeWallpaper[] = {"NoChangingWallpaper"};
static const char strNoHTMLWallpaper[] = {"NoHTMLWallpaper"};
static const char strNoCustomWebView[] = {"NoCustomizeWebView"};
static const char strClassicShell[] = {"ClassicShell"};
static const char strClearRecentDocs[] = {"ClearRecentDocsOnExit"};
static const char strNoFavoritesMenu[] = {"NoFavoritesMenu"};
static const char strNoActiveDesktopChanges[] = {"NoActiveDesktopChanges"};
static const char strNoActiveDesktop[] = {"NoActiveDesktop"};
static const char strNoRecentDocMenu[] = {"NoRecentDocsMenu"};
static const char strNoRecentDocHistory[] = {"NoRecentDocsHistory"};
static const char strNoInetIcon[] = {"NoInternetIcon"};
104
static const char strNoSettingsWizard[] = {"NoSettingsWizards"};
105 106
static const char strNoLogoff[] = {"NoLogoff"};
static const char strNoNetConDis[] = {"NoNetConnectDisconnect"};
107 108
static const char strNoViewContextMenu[] = {"NoViewContextMenu"};
static const char strNoTrayContextMenu[] = {"NoTrayContextMenu"};
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
static const char strNoWebMenu[] = {"NoWebMenu"};
static const char strLnkResolveIgnoreLnkInfo[] = {"LinkResolveIgnoreLinkInfo"};
static const char strNoCommonGroups[] = {"NoCommonGroups"};
static const char strEnforceShlExtSecurity[] = {"EnforceShellExtensionSecurity"};
static const char strNoRealMode[] = {"NoRealMode"};
static const char strMyDocsOnNet[] = {"MyDocsOnNet"};
static const char strNoStartMenuSubfolder[] = {"NoStartMenuSubFolders"};
static const char strNoAddPrinters[] = {"NoAddPrinter"};
static const char strNoDeletePrinters[] = {"NoDeletePrinter"};
static const char strNoPrintTab[] = {"NoPrinterTabs"};
static const char strRestrictRun[] = {"RestrictRun"};
static const char strNoStartBanner[] = {"NoStartBanner"};
static const char strNoNetworkNeighborhood[] = {"NoNetHood"};
static const char strNoDriveTypeAtRun[] = {"NoDriveTypeAutoRun"};
static const char strNoDrivesAutoRun[] = {"NoDriveAutoRun"};
124
static const char strSeparateProcess[] = {"SeparateProcess"};
125 126 127 128 129 130
static const char strNoDrives[] = {"NoDrives"};
static const char strNoFind[] = {"NoFind"};
static const char strNoDesktop[] = {"NoDesktop"};
static const char strNoSetTaskBar[] = {"NoSetTaskbar"};
static const char strNoSetFld[] = {"NoSetFolders"};
static const char strNoFileMenu[] = {"NoFileMenu"};
131
static const char strNoSaveSetting[] = {"NoSaveSettings"};
132 133
static const char strNoClose[] = {"NoClose"};
static const char strNoRun[] = {"NoRun"};
134 135

/* policy data array */
136
POLICYDATA sh32_policy_table[] =
137 138
{
  {
139
    REST_NORUN,
140 141 142 143 144
    strExplorer,
    strNoRun,
    SHELL_NO_POLICY
  },
  {
145
    REST_NOCLOSE,
146 147 148 149 150
    strExplorer,
    strNoClose,
    SHELL_NO_POLICY
  },
  {
151
    REST_NOSAVESET,
152
    strExplorer,
153
    strNoSaveSetting,
154 155 156
    SHELL_NO_POLICY
  },
  {
157
    REST_NOFILEMENU,
158 159 160 161 162
    strExplorer,
    strNoFileMenu,
    SHELL_NO_POLICY
  },
  {
163
    REST_NOSETFOLDERS,
164 165 166 167 168
    strExplorer,
    strNoSetFld,
    SHELL_NO_POLICY
  },
  {
169
    REST_NOSETTASKBAR,
170 171 172 173 174
    strExplorer,
    strNoSetTaskBar,
    SHELL_NO_POLICY
  },
  {
175
    REST_NODESKTOP,
176 177 178 179 180
    strExplorer,
    strNoDesktop,
    SHELL_NO_POLICY
  },
  {
181
    REST_NOFIND,
182 183 184 185 186
    strExplorer,
    strNoFind,
    SHELL_NO_POLICY
  },
  {
187
    REST_NODRIVES,
188 189 190 191 192
    strExplorer,
    strNoDrives,
    SHELL_NO_POLICY
  },
  {
193
    REST_NODRIVEAUTORUN,
194 195 196 197 198
    strExplorer,
    strNoDrivesAutoRun,
    SHELL_NO_POLICY
  },
  {
199
    REST_NODRIVETYPEAUTORUN,
200 201 202 203 204
    strExplorer,
    strNoDriveTypeAtRun,
    SHELL_NO_POLICY
  },
  {
205
    REST_NONETHOOD,
206 207 208 209 210
    strExplorer,
    strNoNetworkNeighborhood,
    SHELL_NO_POLICY
  },
  {
211
    REST_STARTBANNER,
212 213 214 215 216
    strExplorer,
    strNoStartBanner,
    SHELL_NO_POLICY
  },
  {
217
    REST_RESTRICTRUN,
218 219 220 221 222
    strExplorer,
    strRestrictRun,
    SHELL_NO_POLICY
  },
  {
223
    REST_NOPRINTERTABS,
224 225 226 227 228
    strExplorer,
    strNoPrintTab,
    SHELL_NO_POLICY
  },
  {
229
    REST_NOPRINTERDELETE,
230 231 232 233 234
    strExplorer,
    strNoDeletePrinters,
    SHELL_NO_POLICY
  },
  {
235
    REST_NOPRINTERADD,
236 237 238 239 240
    strExplorer,
    strNoAddPrinters,
    SHELL_NO_POLICY
  },
  {
241
    REST_NOSTARTMENUSUBFOLDERS,
242 243 244 245 246
    strExplorer,
    strNoStartMenuSubfolder,
    SHELL_NO_POLICY
  },
  {
247
    REST_MYDOCSONNET,
248 249 250 251 252
    strExplorer,
    strMyDocsOnNet,
    SHELL_NO_POLICY
  },
  {
253
    REST_NOEXITTODOS,
254 255 256 257 258
    strWinOldApp,
    strNoRealMode,
    SHELL_NO_POLICY
  },
  {
259
    REST_ENFORCESHELLEXTSECURITY,
260 261 262 263 264
    strExplorer,
    strEnforceShlExtSecurity,
    SHELL_NO_POLICY
  },
  {
265
    REST_LINKRESOLVEIGNORELINKINFO,
266 267 268 269 270
    strExplorer,
    strLnkResolveIgnoreLnkInfo,
    SHELL_NO_POLICY
  },
  {
271
    REST_NOCOMMONGROUPS,
272 273 274 275
    strExplorer,
    strNoCommonGroups,
    SHELL_NO_POLICY
  },
276
  {
277
    REST_SEPARATEDESKTOPPROCESS,
278
    strExplorer,
279
    strSeparateProcess,
280 281
    SHELL_NO_POLICY
  },
282
  {
283
    REST_NOWEB,
284 285 286 287 288
    strExplorer,
    strNoWebMenu,
    SHELL_NO_POLICY
  },
  {
289
    REST_NOTRAYCONTEXTMENU,
290
    strExplorer,
291
    strNoTrayContextMenu,
292 293 294
    SHELL_NO_POLICY
  },
  {
295
    REST_NOVIEWCONTEXTMENU,
296
    strExplorer,
297
    strNoViewContextMenu,
298 299 300
    SHELL_NO_POLICY
  },
  {
301
    REST_NONETCONNECTDISCONNECT,
302 303 304 305 306
    strExplorer,
    strNoNetConDis,
    SHELL_NO_POLICY
  },
  {
307
    REST_STARTMENULOGOFF,
308 309 310 311 312
    strExplorer,
    strNoLogoff,
    SHELL_NO_POLICY
  },
  {
313
    REST_NOSETTINGSASSIST,
314
    strExplorer,
315
    strNoSettingsWizard,
316 317 318
    SHELL_NO_POLICY
  },
  {
319
    REST_NOINTERNETICON,
320 321 322 323 324
    strExplorer,
    strNoInetIcon,
    SHELL_NO_POLICY
  },
  {
325
    REST_NORECENTDOCSHISTORY,
326 327 328 329 330
    strExplorer,
    strNoRecentDocHistory,
    SHELL_NO_POLICY
  },
  {
331
    REST_NORECENTDOCSMENU,
332 333 334 335 336
    strExplorer,
    strNoRecentDocMenu,
    SHELL_NO_POLICY
  },
  {
337
    REST_NOACTIVEDESKTOP,
338 339 340 341 342
    strExplorer,
    strNoActiveDesktop,
    SHELL_NO_POLICY
  },
  {
343
    REST_NOACTIVEDESKTOPCHANGES,
344 345 346 347 348
    strExplorer,
    strNoActiveDesktopChanges,
    SHELL_NO_POLICY
  },
  {
349
    REST_NOFAVORITESMENU,
350 351 352 353 354
    strExplorer,
    strNoFavoritesMenu,
    SHELL_NO_POLICY
  },
  {
355
    REST_CLEARRECENTDOCSONEXIT,
356 357 358 359 360
    strExplorer,
    strClearRecentDocs,
    SHELL_NO_POLICY
  },
  {
361
    REST_CLASSICSHELL,
362 363 364 365 366
    strExplorer,
    strClassicShell,
    SHELL_NO_POLICY
  },
  {
367
    REST_NOCUSTOMIZEWEBVIEW,
368 369 370 371 372
    strExplorer,
    strNoCustomWebView,
    SHELL_NO_POLICY
  },
  {
373
    REST_NOHTMLWALLPAPER,
374 375 376 377 378
    strActiveDesk,
    strNoHTMLWallpaper,
    SHELL_NO_POLICY
  },
  {
379
    REST_NOCHANGINGWALLPAPER,
380 381 382 383 384
    strActiveDesk,
    strNoChangeWallpaper,
    SHELL_NO_POLICY
  },
  {
385
    REST_NODESKCOMP,
386 387 388 389 390
    strActiveDesk,
    strNoComponent,
    SHELL_NO_POLICY
  },
  {
391
    REST_NOADDDESKCOMP,
392 393 394 395 396
    strActiveDesk,
    strNoAddComponent,
    SHELL_NO_POLICY
  },
  {
397
    REST_NODELDESKCOMP,
398 399 400 401 402
    strActiveDesk,
    strNoDelComponent,
    SHELL_NO_POLICY
  },
  {
403
    REST_NOCLOSEDESKCOMP,
404 405 406 407 408
    strActiveDesk,
    strNoCloseComponent,
    SHELL_NO_POLICY
  },
  {
409
    REST_NOCLOSE_DRAGDROPBAND,
410 411 412 413 414
    strActiveDesk,
    strNoCloseDragDrop,
    SHELL_NO_POLICY
  },
  {
415
    REST_NOMOVINGBAND,
416 417 418 419 420
    strActiveDesk,
    strNoMovingBand,
    SHELL_NO_POLICY
  },
  {
421
    REST_NOEDITDESKCOMP,
422 423 424 425 426
    strActiveDesk,
    strNoEditComponent,
    SHELL_NO_POLICY
  },
  {
427
    REST_NORESOLVESEARCH,
428 429 430 431 432
    strExplorer,
    strNoResolveSearch,
    SHELL_NO_POLICY
  },
  {
433
    REST_NORESOLVETRACK,
434 435 436 437 438
    strExplorer,
    strNoResolveTrk,
    SHELL_NO_POLICY
  },
  {
439
    REST_FORCECOPYACLWITHFILE,
440 441 442 443 444
    strExplorer,
    strForceCopyACLW,
    SHELL_NO_POLICY
  },
  {
445
    REST_NOLOGO3CHANNELNOTIFY,
446 447 448 449 450
    strExplorer,
    strNoMSAppLogo,
    SHELL_NO_POLICY
  },
  {
451
    REST_NOFORGETSOFTWAREUPDATE,
452 453 454 455 456
    strExplorer,
    strNoForgetSoftwareUpdate,
    SHELL_NO_POLICY
  },
  {
457
    REST_NOSETACTIVEDESKTOP,
458 459 460 461 462
    strExplorer,
    strNoSetActiveDesktop,
    SHELL_NO_POLICY
  },
  {
463
    REST_NOUPDATEWINDOWS,
464 465 466 467 468
    strExplorer,
    strNoWindowsUpdate,
    SHELL_NO_POLICY
  },
  {
469
    REST_NOCHANGESTARMENU,
470 471 472 473 474
    strExplorer,
    strNoChangeStartMenu,
    SHELL_NO_POLICY
  },
  {
475
    REST_NOFOLDEROPTIONS,
476 477 478 479 480
    strExplorer,
    strNoFolderOptions,
    SHELL_NO_POLICY
  },
  {
481
    REST_HASFINDCOMPUTERS,
482 483 484 485 486
    strExplorer,
    "FindComputers",
    SHELL_NO_POLICY
  },
  {
487
    REST_INTELLIMENUS,
488 489 490 491 492
    strExplorer,
    "IntelliMenus",
    SHELL_NO_POLICY
  },
  {
493
    REST_RUNDLGMEMCHECKBOX,
494 495 496 497 498
    strExplorer,
    "MemCheckBoxInRunDlg",
    SHELL_NO_POLICY
  },
  {
499
    REST_ARP_ShowPostSetup,
500 501 502 503 504
    strAddRemoveProgs,
    "ShowPostSetup",
    SHELL_NO_POLICY
  },
  {
505
    REST_NOCSC,
506 507 508 509 510
    strExplorer,
    "NoSyncAll",
    SHELL_NO_POLICY
  },
  {
511
    REST_NOCONTROLPANEL,
512 513 514 515 516
    strExplorer,
    "NoControlPanel",
    SHELL_NO_POLICY
  },
  {
517
    REST_ENUMWORKGROUP,
518 519 520 521 522
    strExplorer,
    "EnumWorkgroup",
    SHELL_NO_POLICY
  },
  {
523
    REST_ARP_NOARP,
524 525 526 527 528
    strAddRemoveProgs,
    "NoAddRemovePrograms",
    SHELL_NO_POLICY
  },
  {
529
    REST_ARP_NOREMOVEPAGE,
530 531 532 533 534
    strAddRemoveProgs,
    "NoRemovePage",
    SHELL_NO_POLICY
  },
  {
535
    REST_ARP_NOADDPAGE,
536 537 538 539 540
    strAddRemoveProgs,
    "NoAddPage",
    SHELL_NO_POLICY
  },
  {
541
    REST_ARP_NOWINSETUPPAGE,
542 543 544 545 546
    strAddRemoveProgs,
    "NoWindowsSetupPage",
    SHELL_NO_POLICY
  },
  {
547 548 549 550 551 552 553
    REST_GREYMSIADS,
    strExplorer,
    "",
    SHELL_NO_POLICY
  },
  {
    REST_NOCHANGEMAPPEDDRIVELABEL,
554 555 556 557 558
    strExplorer,
    "NoChangeMappedDriveLabel",
    SHELL_NO_POLICY
  },
  {
559
    REST_NOCHANGEMAPPEDDRIVECOMMENT,
560 561 562 563 564
    strExplorer,
    "NoChangeMappedDriveComment",
    SHELL_NO_POLICY
  },
  {
565
    REST_MaxRecentDocs,
566 567 568 569 570
    strExplorer,
    "MaxRecentDocs",
    SHELL_NO_POLICY
  },
  {
571
    REST_NONETWORKCONNECTIONS,
572 573 574 575 576
    strExplorer,
    "NoNetworkConnections",
    SHELL_NO_POLICY
  },
  {
577
    REST_FORCESTARTMENULOGOFF,
578 579 580 581 582
    strExplorer,
    "ForceStartMenuLogoff",
    SHELL_NO_POLICY
  },
  {
583
    REST_NOWEBVIEW,
584 585 586 587 588
    strExplorer,
     "NoWebView",
    SHELL_NO_POLICY
  },
  {
589
    REST_NOCUSTOMIZETHISFOLDER,
590 591 592 593 594
    strExplorer,
    "NoCustomizeThisFolder",
    SHELL_NO_POLICY
  },
  {
595
    REST_NOENCRYPTION,
596 597 598 599 600
    strExplorer,
    "NoEncryption",
    SHELL_NO_POLICY
  },
  {
601
    REST_ALLOWFRENCHENCRYPTION,
602 603 604 605 606
    strExplorer,
    "AllowFrenchEncryption",
    SHELL_NO_POLICY
  },
  {
607
    REST_DONTSHOWSUPERHIDDEN,
608 609 610 611 612
    strExplorer,
    "DontShowSuperHidden",
    SHELL_NO_POLICY
  },
  {
613
    REST_NOSHELLSEARCHBUTTON,
614 615 616 617 618
    strExplorer,
    "NoShellSearchButton",
    SHELL_NO_POLICY
  },
  {
619
    REST_NOHARDWARETAB,
620 621 622 623 624
    strExplorer,
    "NoHardwareTab",
    SHELL_NO_POLICY
  },
  {
625
    REST_NORUNASINSTALLPROMPT,
626 627 628 629 630
    strExplorer,
    "NoRunasInstallPrompt",
    SHELL_NO_POLICY
  },
  {
631
    REST_PROMPTRUNASINSTALLNETPATH,
632 633 634 635 636
    strExplorer,
    "PromptRunasInstallNetPath",
    SHELL_NO_POLICY
  },
  {
637
    REST_NOMANAGEMYCOMPUTERVERB,
638 639 640 641 642
    strExplorer,
    "NoManageMyComputerVerb",
    SHELL_NO_POLICY
  },
  {
643
    REST_NORECENTDOCSNETHOOD,
644 645 646 647 648
    strExplorer,
    "NoRecentDocsNetHood",
    SHELL_NO_POLICY
  },
  {
649
    REST_DISALLOWRUN,
650 651 652 653 654
    strExplorer,
    "DisallowRun",
    SHELL_NO_POLICY
  },
  {
655
    REST_NOWELCOMESCREEN,
656 657 658 659 660
    strExplorer,
    "NoWelcomeScreen",
    SHELL_NO_POLICY
  },
  {
661
    REST_RESTRICTCPL,
662 663 664 665 666
    strExplorer,
    "RestrictCpl",
    SHELL_NO_POLICY
  },
  {
667
    REST_DISALLOWCPL,
668 669 670 671 672
    strExplorer,
    "DisallowCpl",
    SHELL_NO_POLICY
  },
  {
673
    REST_NOSMBALLOONTIP,
674 675 676 677 678
    strExplorer,
    "NoSMBalloonTip",
    SHELL_NO_POLICY
  },
  {
679
    REST_NOSMHELP,
680 681 682 683 684
    strExplorer,
    "NoSMHelp",
    SHELL_NO_POLICY
  },
  {
685
    REST_NOWINKEYS,
686 687 688 689 690
    strExplorer,
    "NoWinKeys",
    SHELL_NO_POLICY
  },
  {
691
    REST_NOENCRYPTONMOVE,
692 693 694 695 696
    strExplorer,
    "NoEncryptOnMove",
    SHELL_NO_POLICY
  },
  {
697
    REST_NOLOCALMACHINERUN,
698 699 700 701 702
    strExplorer,
    "DisableLocalMachineRun",
    SHELL_NO_POLICY
  },
  {
703
    REST_NOCURRENTUSERRUN,
704 705 706 707 708
    strExplorer,
    "DisableCurrentUserRun",
    SHELL_NO_POLICY
  },
  {
709
    REST_NOLOCALMACHINERUNONCE,
710 711 712 713 714
    strExplorer,
    "DisableLocalMachineRunOnce",
    SHELL_NO_POLICY
  },
  {
715
    REST_NOCURRENTUSERRUNONCE,
716 717 718 719 720
    strExplorer,
    "DisableCurrentUserRunOnce",
    SHELL_NO_POLICY
  },
  {
721
    REST_FORCEACTIVEDESKTOPON,
722 723 724 725 726
    strExplorer,
    "ForceActiveDesktopOn",
    SHELL_NO_POLICY
  },
  {
727
    REST_NOCOMPUTERSNEARME,
728 729 730 731 732
    strExplorer,
    "NoComputersNearMe",
    SHELL_NO_POLICY
  },
  {
733
    REST_NOVIEWONDRIVE,
734 735 736 737 738
    strExplorer,
    "NoViewOnDrive",
    SHELL_NO_POLICY
  },
  {
739 740 741 742 743 744 745 746 747 748 749 750 751
    REST_NONETCRAWL,
    strExplorer,
    "NoNetCrawl",
    SHELL_NO_POLICY
  },
  {
    REST_NOSHAREDDOCUMENTS,
    strExplorer,
    "NoSharedDocs",
    SHELL_NO_POLICY
  },
  {
    REST_NOSMMYDOCS,
752 753 754 755
    strExplorer,
    "NoSMMyDocs",
    SHELL_NO_POLICY
  },
756
/* 0x4000050 - 0x4000060 */
757 758 759 760 761 762
  {
    REST_NONLEGACYSHELLMODE,
    strExplorer,
    "NoneLegacyShellMode",
    SHELL_NO_POLICY
  },
763
  {
764
    REST_STARTRUNNOHOMEPATH,
765 766 767 768
    strExplorer,
    "StartRunNoHOMEPATH",
    SHELL_NO_POLICY
  },
769
/* 0x4000061 - 0x4000086 */
770
  {
771
    REST_NODISCONNECT,
772 773 774 775 776
    strExplorer,
    "NoDisconnect",
    SHELL_NO_POLICY
  },
  {
777
    REST_NOSECURITY,
778 779 780 781 782
    strExplorer,
    "NoNTSecurity",
    SHELL_NO_POLICY
  },
  {
783
    REST_NOFILEASSOCIATE,
784 785 786 787
    strExplorer,
    "NoFileAssociate",
    SHELL_NO_POLICY
  },
788 789 790 791 792 793
  {
    0x50000024,
    strExplorer,
    strNoFileURL,
    SHELL_NO_POLICY
  },
794 795 796 797 798 799
  {
    0,
    0,
    0,
    SHELL_NO_POLICY
	}
800
};
801 802

/*************************************************************************
803
 * SHRestricted				 [SHELL32.100]
804
 *
805 806 807 808 809 810 811
 * Get the value associated with a policy Id.
 *
 * PARAMS
 *     pol [I] Policy Id
 *
 * RETURNS
 *     The queried value for the policy.
812 813
 *
 * NOTES
814 815 816
 *     Exported by ordinal.
 *     This function caches the retrieved values to prevent unnecessary registry access,
 *     if SHInitRestricted() was previously called.
817
 *
818 819 820 821
 * REFERENCES
 *     a: MS System Policy Editor.
 *     b: 98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/
 *     c: 'The Windows 95 Registry', by John Woram, 1996 MIS: Press
822
 */
823
DWORD WINAPI SHRestricted (RESTRICTIONS policy)
824 825 826 827 828
{
	char regstr[256];
	HKEY    xhkey;
	DWORD   retval, datsize = 4;
	LPPOLICYDATA p;
829

830
	TRACE("(%08x)\n", policy);
831 832

	/* scan to see if we know this policy ID */
833
	for (p = sh32_policy_table; p->policy; p++)
834
	{
835 836 837 838
	  if (policy == p->policy)
	  {
	    break;
	  }
839 840
	}

841
	if (p->policy == 0)
842 843
	{
	    /* we don't know this policy, return 0 */
844
	    TRACE("unknown policy: (%08x)\n", policy);
845 846 847 848 849 850
		return 0;
	}

	/* we have a known policy */

	/* first check if this policy has been cached, return it if so */
851
	if (p->cache != SHELL_NO_POLICY)
852
	{
853
	    return p->cache;
854 855
	}

856 857 858
	lstrcpyA(regstr, strRegistryPolicyA);
	lstrcatA(regstr, p->appstr);

859 860 861 862
	/* return 0 and don't set the cache if any registry errors occur */
	retval = 0;
	if (RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey) == ERROR_SUCCESS)
	{
863 864 865 866 867
	  if (RegQueryValueExA(xhkey, p->keystr, NULL, NULL, (LPBYTE)&retval, &datsize) == ERROR_SUCCESS)
	  {
	    p->cache = retval;
	  }
	  RegCloseKey(xhkey);
868
	}
869 870 871 872
	return retval;
}

/*************************************************************************
873
 * SHInitRestricted          [SHELL32.244]
874
 *
875
 * Initialise the policy cache to speed up calls to SHRestricted().
876
 *
877
 * PARAMS
878
 *  unused    [I] Reserved.
879
 *  inpRegKey [I] Registry key to scan.
880
 *
881
 * RETURNS
882 883
 *  Success: -1. The policy cache is initialised.
 *  Failure: 0, if inpRegKey is any value other than NULL, "Policy", or
884
 *           "Software\Microsoft\Windows\CurrentVersion\Policies".
885
 *
886 887
 * NOTES
 *  Exported by ordinal. Introduced in Win98.
888
 */
889
BOOL WINAPI SHInitRestricted(LPCVOID unused, LPCVOID inpRegKey)
890
{
891
	TRACE("(%p, %p)\n", unused, inpRegKey);
892

893
	/* first check - if input is non-NULL and points to the secret
894
	   key string, then pass. Otherwise return 0.
895 896 897 898 899
	 */
	if (inpRegKey != NULL)
	{
	  if (SHELL_OsIsUnicode())
	  {
Eric Pouech's avatar
Eric Pouech committed
900 901
	    if (lstrcmpiW((LPCWSTR)inpRegKey, strRegistryPolicyW) &&
	        lstrcmpiW((LPCWSTR)inpRegKey, strPolicyW))
902 903 904 905 906
	      /* doesn't match, fail */
	      return 0;
	  }
	  else
	  {
Eric Pouech's avatar
Eric Pouech committed
907 908
	    if (lstrcmpiA((LPCSTR)inpRegKey, strRegistryPolicyA) &&
	        lstrcmpiA((LPCSTR)inpRegKey, strPolicyA))
909 910 911 912
	      /* doesn't match, fail */
	      return 0;
	  }
	}
913

914
	return TRUE;
915
}