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