ReactOS  0.4.14-dev-376-gaedba84
shpolicy.c File Reference
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <windef.h>
#include <winbase.h>
#include <shlobj.h>
#include <wine/debug.h>
#include "shell32_main.h"
Include dependency graph for shpolicy.c:

Go to the source code of this file.

Classes

struct  tagPOLICYDAT
 

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define SHELL_NO_POLICY   0xffffffff
 

Typedefs

typedef struct tagPOLICYDAT POLICYDATA
 
typedef struct tagPOLICYDATLPPOLICYDATA
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
DWORD WINAPI SHRestricted (RESTRICTIONS policy)
 
BOOL WINAPI SHSettingsChanged (LPCVOID unused, LPCVOID inpRegKey)
 

Variables

static const CHAR strRegistryPolicyA [] = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies"
 
static const WCHAR strRegistryPolicyW []
 
static const CHAR strPolicyA [] = "Policy"
 
static const WCHAR strPolicyW [] = {'P','o','l','i','c','y',0}
 
static const char strExplorer [] = {"Explorer"}
 
static const char strActiveDesk [] = {"ActiveDesktop"}
 
static const char strWinOldApp [] = {"WinOldApp"}
 
static const char strAddRemoveProgs [] = {"AddRemoveProgs"}
 
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 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"}
 
static const char strNoSettingsWizard [] = {"NoSettingsWizards"}
 
static const char strNoLogoff [] = {"NoLogoff"}
 
static const char strNoNetConDis [] = {"NoNetConnectDisconnect"}
 
static const char strNoViewContextMenu [] = {"NoViewContextMenu"}
 
static const char strNoTrayContextMenu [] = {"NoTrayContextMenu"}
 
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"}
 
static const char strSeparateProcess [] = {"SeparateProcess"}
 
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"}
 
static const char strNoSaveSetting [] = {"NoSaveSettings"}
 
static const char strNoClose [] = {"NoClose"}
 
static const char strNoRun [] = {"NoRun"}
 
static POLICYDATA sh32_policy_table []
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 37 of file shpolicy.c.

◆ SHELL_NO_POLICY

#define SHELL_NO_POLICY   0xffffffff

Definition at line 48 of file shpolicy.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 36 of file shpolicy.c.

Typedef Documentation

◆ LPPOLICYDATA

◆ POLICYDATA

Function Documentation

◆ SHRestricted()

DWORD WINAPI SHRestricted ( RESTRICTIONS  policy)

Definition at line 836 of file shpolicy.c.

837 {
838  char regstr[256];
839  HKEY xhkey;
840  DWORD retval, datsize = 4;
841  LPPOLICYDATA p;
842 
843  TRACE("(%08x)\n", policy);
844 
845  /* scan to see if we know this policy ID */
846  for (p = sh32_policy_table; p->policy; p++)
847  {
848  if (policy == p->policy)
849  {
850  break;
851  }
852  }
853 
854  if (p->policy == 0)
855  {
856  /* we don't know this policy, return 0 */
857  TRACE("unknown policy: (%08x)\n", policy);
858  return 0;
859  }
860 
861  /* we have a known policy */
862 
863  /* first check if this policy has been cached, return it if so */
864  if (p->cache != SHELL_NO_POLICY)
865  {
866  return p->cache;
867  }
868 
869  lstrcpyA(regstr, strRegistryPolicyA);
870  lstrcatA(regstr, "\\");
871  lstrcatA(regstr, p->appstr);
872 
873  /* return 0 and don't set the cache if any registry errors occur */
874 #ifndef __REACTOS__
875  retval = 0;
876  if (RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey) == ERROR_SUCCESS)
877 #else // FIXME: Actually this *MUST* use shlwapi!SHRestrictionLookup()
878  // See http://www.geoffchappell.com/studies/windows/shell/shell32/api/util/shrestricted.htm
879  retval = RegOpenKeyA(HKEY_LOCAL_MACHINE, regstr, &xhkey);
880  if (retval != ERROR_SUCCESS)
881  {
882  retval = RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey);
883  if (retval != ERROR_SUCCESS)
884  return 0;
885  }
886 #endif
887  {
888  if (RegQueryValueExA(xhkey, p->keystr, NULL, NULL, (LPBYTE)&retval, &datsize) == ERROR_SUCCESS)
889  {
890  p->cache = retval;
891  }
892  RegCloseKey(xhkey);
893  }
894  return retval;
895 }
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define SHELL_NO_POLICY
Definition: shpolicy.c:48
smooth NULL
Definition: ftsmooth.c:416
static const CHAR strRegistryPolicyA[]
Definition: shpolicy.c:59
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
DWORD policy
Definition: shpolicy.c:52
GLfloat GLfloat p
Definition: glext.h:8902
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
static POLICYDATA sh32_policy_table[]
Definition: shpolicy.c:139

Referenced by SettingsMenu::AddEntries(), BrowseMenu::AddEntries(), SearchMenu::AddEntries(), CStartMenuBtnCtxMenu::AddStartContextMenuItems(), CStartMenuSite::AppendMenu(), CTrayWindow::ExecContextMenuCmd(), CTrayWindow::HandleCommand(), DesktopBar::Init(), StartMenuRoot::Init(), CTrayWindow::OnContextMenu(), CTrayWindow::OnSysChar(), CTrayBandSite::ProcessMessage(), ProcessStartupItems(), CTrayWindowCtxMenu::QueryContextMenu(), NotifyArea::read_config(), SHFindFiles(), StartMenuRoot::StartMenuRoot(), and CStartMenuSettingsPage::UpdateDialog().

◆ SHSettingsChanged()

BOOL WINAPI SHSettingsChanged ( LPCVOID  unused,
LPCVOID  inpRegKey 
)

Definition at line 914 of file shpolicy.c.

915 {
916  TRACE("(%p, %p)\n", unused, inpRegKey);
917 
918  /* first check - if input is non-NULL and points to the secret
919  key string, then pass. Otherwise return 0.
920  */
921  if (inpRegKey != NULL)
922  {
923  if (SHELL_OsIsUnicode())
924  {
925  if (lstrcmpiW(inpRegKey, strRegistryPolicyW) &&
926  lstrcmpiW(inpRegKey, strPolicyW))
927  /* doesn't match, fail */
928  return FALSE;
929  }
930  else
931  {
932  if (lstrcmpiA(inpRegKey, strRegistryPolicyA) &&
933  lstrcmpiA(inpRegKey, strPolicyA))
934  /* doesn't match, fail */
935  return FALSE;
936  }
937  }
938 
939  return TRUE;
940 }
#define TRUE
Definition: types.h:120
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
WORD unused[29]
Definition: crypt.c:1155
static const CHAR strPolicyA[]
Definition: shpolicy.c:64
smooth NULL
Definition: ftsmooth.c:416
static const CHAR strRegistryPolicyA[]
Definition: shpolicy.c:59
#define TRACE(s)
Definition: solgame.cpp:4
static const WCHAR strPolicyW[]
Definition: shpolicy.c:65
static const WCHAR strRegistryPolicyW[]
Definition: shpolicy.c:60

Referenced by IntSetShellStateSettings(), and IntSetUnderlineState().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ sh32_policy_table

POLICYDATA sh32_policy_table[]
static

Definition at line 139 of file shpolicy.c.

Referenced by SHRestricted().

◆ strActiveDesk

const char strActiveDesk[] = {"ActiveDesktop"}
static

Definition at line 70 of file shpolicy.c.

◆ strAddRemoveProgs

const char strAddRemoveProgs[] = {"AddRemoveProgs"}
static

Definition at line 72 of file shpolicy.c.

◆ strClassicShell

const char strClassicShell[] = {"ClassicShell"}
static

Definition at line 96 of file shpolicy.c.

◆ strClearRecentDocs

const char strClearRecentDocs[] = {"ClearRecentDocsOnExit"}
static

Definition at line 97 of file shpolicy.c.

◆ strEnforceShlExtSecurity

const char strEnforceShlExtSecurity[] = {"EnforceShellExtensionSecurity"}
static

Definition at line 112 of file shpolicy.c.

◆ strExplorer

const char strExplorer[] = {"Explorer"}
static

Definition at line 69 of file shpolicy.c.

◆ strForceCopyACLW

const char strForceCopyACLW[] = {"ForceCopyACLWithFile"}
static

Definition at line 83 of file shpolicy.c.

◆ strLnkResolveIgnoreLnkInfo

const char strLnkResolveIgnoreLnkInfo[] = {"LinkResolveIgnoreLinkInfo"}
static

Definition at line 110 of file shpolicy.c.

◆ strMyDocsOnNet

const char strMyDocsOnNet[] = {"MyDocsOnNet"}
static

Definition at line 114 of file shpolicy.c.

◆ strNoActiveDesktop

const char strNoActiveDesktop[] = {"NoActiveDesktop"}
static

Definition at line 100 of file shpolicy.c.

◆ strNoActiveDesktopChanges

const char strNoActiveDesktopChanges[] = {"NoActiveDesktopChanges"}
static

Definition at line 99 of file shpolicy.c.

◆ strNoAddComponent

const char strNoAddComponent[] = {"NoAddingComponents"}
static

Definition at line 91 of file shpolicy.c.

◆ strNoAddPrinters

const char strNoAddPrinters[] = {"NoAddPrinter"}
static

Definition at line 116 of file shpolicy.c.

◆ strNoChangeStartMenu

const char strNoChangeStartMenu[] = {"NoChangeStartMenu"}
static

Definition at line 78 of file shpolicy.c.

◆ strNoChangeWallpaper

const char strNoChangeWallpaper[] = {"NoChangingWallpaper"}
static

Definition at line 93 of file shpolicy.c.

◆ strNoClose

const char strNoClose[] = {"NoClose"}
static

Definition at line 132 of file shpolicy.c.

◆ strNoCloseComponent

const char strNoCloseComponent[] = {"NoClosingComponents"}
static

Definition at line 89 of file shpolicy.c.

◆ strNoCloseDragDrop

const char strNoCloseDragDrop[] = {"NoCloseDragDropBands"}
static

Definition at line 88 of file shpolicy.c.

◆ strNoCommonGroups

const char strNoCommonGroups[] = {"NoCommonGroups"}
static

Definition at line 111 of file shpolicy.c.

◆ strNoComponent

const char strNoComponent[] = {"NoComponents"}
static

Definition at line 92 of file shpolicy.c.

◆ strNoCustomWebView

const char strNoCustomWebView[] = {"NoCustomizeWebView"}
static

Definition at line 95 of file shpolicy.c.

◆ strNoDelComponent

const char strNoDelComponent[] = {"NoDeletingComponents"}
static

Definition at line 90 of file shpolicy.c.

◆ strNoDeletePrinters

const char strNoDeletePrinters[] = {"NoDeletePrinter"}
static

Definition at line 117 of file shpolicy.c.

◆ strNoDesktop

const char strNoDesktop[] = {"NoDesktop"}
static

Definition at line 127 of file shpolicy.c.

◆ strNoDrives

const char strNoDrives[] = {"NoDrives"}
static

Definition at line 125 of file shpolicy.c.

◆ strNoDrivesAutoRun

const char strNoDrivesAutoRun[] = {"NoDriveAutoRun"}
static

Definition at line 123 of file shpolicy.c.

◆ strNoDriveTypeAtRun

const char strNoDriveTypeAtRun[] = {"NoDriveTypeAutoRun"}
static

Definition at line 122 of file shpolicy.c.

◆ strNoEditComponent

const char strNoEditComponent[] = {"NoEditingComponents"}
static

Definition at line 86 of file shpolicy.c.

◆ strNoFavoritesMenu

const char strNoFavoritesMenu[] = {"NoFavoritesMenu"}
static

Definition at line 98 of file shpolicy.c.

◆ strNoFileMenu

const char strNoFileMenu[] = {"NoFileMenu"}
static

Definition at line 130 of file shpolicy.c.

◆ strNoFileURL

const char strNoFileURL[] = {"NoFileUrl"}
static

Definition at line 76 of file shpolicy.c.

◆ strNoFind

const char strNoFind[] = {"NoFind"}
static

Definition at line 126 of file shpolicy.c.

◆ strNoFolderOptions

const char strNoFolderOptions[] = {"NoFolderOptions"}
static

Definition at line 77 of file shpolicy.c.

◆ strNoForgetSoftwareUpdate

const char strNoForgetSoftwareUpdate[] = {"NoForgetSoftwareUpdate"}
static

Definition at line 81 of file shpolicy.c.

◆ strNoHTMLWallpaper

const char strNoHTMLWallpaper[] = {"NoHTMLWallpaper"}
static

Definition at line 94 of file shpolicy.c.

◆ strNoInetIcon

const char strNoInetIcon[] = {"NoInternetIcon"}
static

Definition at line 103 of file shpolicy.c.

◆ strNoLogoff

const char strNoLogoff[] = {"NoLogoff"}
static

Definition at line 105 of file shpolicy.c.

◆ strNoMovingBand

const char strNoMovingBand[] = {"NoMovingBands"}
static

Definition at line 87 of file shpolicy.c.

◆ strNoNetConDis

const char strNoNetConDis[] = {"NoNetConnectDisconnect"}
static

Definition at line 106 of file shpolicy.c.

◆ strNoNetworkNeighborhood

const char strNoNetworkNeighborhood[] = {"NoNetHood"}
static

Definition at line 121 of file shpolicy.c.

◆ strNoPrintTab

const char strNoPrintTab[] = {"NoPrinterTabs"}
static

Definition at line 118 of file shpolicy.c.

◆ strNoRealMode

const char strNoRealMode[] = {"NoRealMode"}
static

Definition at line 113 of file shpolicy.c.

◆ strNoRecentDocHistory

const char strNoRecentDocHistory[] = {"NoRecentDocsHistory"}
static

Definition at line 102 of file shpolicy.c.

◆ strNoRecentDocMenu

const char strNoRecentDocMenu[] = {"NoRecentDocsMenu"}
static

Definition at line 101 of file shpolicy.c.

◆ strNoResolveSearch

const char strNoResolveSearch[] = {"NoResolveSearch"}
static

Definition at line 85 of file shpolicy.c.

◆ strNoResolveTrk

const char strNoResolveTrk[] = {"NoResolveTrack"}
static

Definition at line 84 of file shpolicy.c.

◆ strNoRun

const char strNoRun[] = {"NoRun"}
static

Definition at line 133 of file shpolicy.c.

◆ strNoSaveSetting

const char strNoSaveSetting[] = {"NoSaveSettings"}
static

Definition at line 131 of file shpolicy.c.

◆ strNoSetActiveDesktop

const char strNoSetActiveDesktop[] = {"NoSetActiveDesktop"}
static

Definition at line 80 of file shpolicy.c.

◆ strNoSetFld

const char strNoSetFld[] = {"NoSetFolders"}
static

Definition at line 129 of file shpolicy.c.

◆ strNoSetTaskBar

const char strNoSetTaskBar[] = {"NoSetTaskbar"}
static

Definition at line 128 of file shpolicy.c.

◆ strNoSettingsWizard

const char strNoSettingsWizard[] = {"NoSettingsWizards"}
static

Definition at line 104 of file shpolicy.c.

◆ strNoStartBanner

const char strNoStartBanner[] = {"NoStartBanner"}
static

Definition at line 120 of file shpolicy.c.

◆ strNoStartMenuSubfolder

const char strNoStartMenuSubfolder[] = {"NoStartMenuSubFolders"}
static

Definition at line 115 of file shpolicy.c.

◆ strNoTrayContextMenu

const char strNoTrayContextMenu[] = {"NoTrayContextMenu"}
static

Definition at line 108 of file shpolicy.c.

◆ strNoViewContextMenu

const char strNoViewContextMenu[] = {"NoViewContextMenu"}
static

Definition at line 107 of file shpolicy.c.

◆ strNoWebMenu

const char strNoWebMenu[] = {"NoWebMenu"}
static

Definition at line 109 of file shpolicy.c.

◆ strNoWindowsUpdate

const char strNoWindowsUpdate[] = {"NoWindowsUpdate"}
static

Definition at line 79 of file shpolicy.c.

◆ strPolicyA

const CHAR strPolicyA[] = "Policy"
static

Definition at line 64 of file shpolicy.c.

Referenced by SHSettingsChanged().

◆ strPolicyW

const WCHAR strPolicyW[] = {'P','o','l','i','c','y',0}
static

Definition at line 65 of file shpolicy.c.

Referenced by SHSettingsChanged().

◆ strRegistryPolicyA

const CHAR strRegistryPolicyA[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies"
static

Definition at line 59 of file shpolicy.c.

Referenced by SHRestricted(), and SHSettingsChanged().

◆ strRegistryPolicyW

const WCHAR strRegistryPolicyW[]
static
Initial value:
= {'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}

Definition at line 60 of file shpolicy.c.

Referenced by SHSettingsChanged().

◆ strRestrictRun

const char strRestrictRun[] = {"RestrictRun"}
static

Definition at line 119 of file shpolicy.c.

◆ strSeparateProcess

const char strSeparateProcess[] = {"SeparateProcess"}
static

Definition at line 124 of file shpolicy.c.

◆ strWinOldApp

const char strWinOldApp[] = {"WinOldApp"}
static

Definition at line 71 of file shpolicy.c.