shpolicy.c 18.7 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
 * 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
18
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 20
 *
 * 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
/* application strings */

60 61 62
static const char strExplorer[] = {"Explorer"};
static const char strActiveDesk[] = {"ActiveDesktop"};
static const char strWinOldApp[] = {"WinOldApp"};
63
static const char strAddRemoveProgs[] = {"AddRemoveProgs"};
64 65 66

/* key strings */

67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
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"};
95
static const char strNoSettingsWizard[] = {"NoSettingsWizards"};
96 97
static const char strNoLogoff[] = {"NoLogoff"};
static const char strNoNetConDis[] = {"NoNetConnectDisconnect"};
98 99
static const char strNoViewContextMenu[] = {"NoViewContextMenu"};
static const char strNoTrayContextMenu[] = {"NoTrayContextMenu"};
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
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"};
115
static const char strSeparateProcess[] = {"SeparateProcess"};
116 117 118 119 120 121
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"};
122
static const char strNoSaveSetting[] = {"NoSaveSettings"};
123 124
static const char strNoClose[] = {"NoClose"};
static const char strNoRun[] = {"NoRun"};
125 126

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

/*************************************************************************
794
 * SHRestricted				 [SHELL32.100]
795
 *
796 797 798 799 800 801 802
 * Get the value associated with a policy Id.
 *
 * PARAMS
 *     pol [I] Policy Id
 *
 * RETURNS
 *     The queried value for the policy.
803 804
 *
 * NOTES
805 806 807
 *     Exported by ordinal.
 *     This function caches the retrieved values to prevent unnecessary registry access,
 *     if SHInitRestricted() was previously called.
808
 *
809 810 811 812
 * 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
813
 */
814
DWORD WINAPI SHRestricted (RESTRICTIONS policy)
815 816 817 818 819
{
	char regstr[256];
	HKEY    xhkey;
	DWORD   retval, datsize = 4;
	LPPOLICYDATA p;
820

821
	TRACE("(%08x)\n", policy);
822 823

	/* scan to see if we know this policy ID */
824
	for (p = sh32_policy_table; p->policy; p++)
825
	{
826 827 828 829
	  if (policy == p->policy)
	  {
	    break;
	  }
830 831
	}

832
	if (p->policy == 0)
833 834
	{
	    /* we don't know this policy, return 0 */
835
	    TRACE("unknown policy: (%08x)\n", policy);
836 837 838 839 840 841
		return 0;
	}

	/* we have a known policy */

	/* first check if this policy has been cached, return it if so */
842
	if (p->cache != SHELL_NO_POLICY)
843
	{
844
	    return p->cache;
845 846
	}

847
	lstrcpyA(regstr, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\");
848 849
	lstrcatA(regstr, p->appstr);

850 851 852 853
	/* return 0 and don't set the cache if any registry errors occur */
	retval = 0;
	if (RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey) == ERROR_SUCCESS)
	{
854 855 856 857 858
	  if (RegQueryValueExA(xhkey, p->keystr, NULL, NULL, (LPBYTE)&retval, &datsize) == ERROR_SUCCESS)
	  {
	    p->cache = retval;
	  }
	  RegCloseKey(xhkey);
859
	}
860 861 862 863
	return retval;
}

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

884
	/* first check - if input is non-NULL and points to the secret
885
	   key string, then pass. Otherwise return 0.
886 887 888 889 890
	 */
	if (inpRegKey != NULL)
	{
	  if (SHELL_OsIsUnicode())
	  {
891 892
            if (lstrcmpiW(inpRegKey, L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies") &&
                lstrcmpiW(inpRegKey, L"Policy"))
893
	      /* doesn't match, fail */
894
	      return FALSE;
895 896 897
	  }
	  else
	  {
898 899
            if (lstrcmpiA(inpRegKey, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies") &&
                lstrcmpiA(inpRegKey, "Policy"))
900
	      /* doesn't match, fail */
901
	      return FALSE;
902 903
	  }
	}
904

905
	return TRUE;
906
}