source: trunk/src/shell32/shpolicy.cpp@ 4032

Last change on this file since 4032 was 4032, checked in by phaller, 25 years ago

Synchronized shell32 with wine

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