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