ReactOS 0.4.16-dev-1481-ga753f34
internal.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DYN_FUNCS
 
struct  _DYN_MODULE
 
struct  _POLICY_VALUES
 

Typedefs

typedef struct _DYN_FUNCS DYN_FUNCS
 
typedef struct _DYN_FUNCSPDYN_FUNCS
 
typedef struct _DYN_MODULE DYN_MODULE
 
typedef struct _DYN_MODULEPDYN_MODULE
 
typedef struct _POLICY_VALUES POLICY_VALUES
 
typedef struct _POLICY_VALUESPPOLICY_VALUES
 

Functions

BOOL CopyDirectory (LPCWSTR lpDestinationPath, LPCWSTR lpSourcePath)
 
BOOL CreateDirectoryPath (LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
 
BOOL RemoveDirectoryPath (LPCWSTR lpPathName)
 
BOOL LoadDynamicImports (PDYN_MODULE Module, PDYN_FUNCS DynFuncs)
 
VOID UnloadDynamicImports (PDYN_FUNCS DynFuncs)
 
LPWSTR AppendBackslash (LPWSTR String)
 
PSECURITY_DESCRIPTOR CreateDefaultSecurityDescriptor (VOID)
 
LONG GetPolicyValues (_In_ HKEY hRootKey, _Inout_ PPOLICY_VALUES QueryTable)
 
LONG GetPolicyValue (_In_ HKEY hRootKey, _In_ PCWSTR ValueName, _In_ DWORD Type, _Out_opt_ PVOID pData, _Inout_opt_ PDWORD pcbData)
 
VOID ReportErrorWorker (_In_ DWORD dwFlags, _In_ PCWSTR pszStr)
 
VOID ReportErrorV (_In_ DWORD dwFlags, _In_ PCWSTR pszStr, _In_ va_list args)
 
VOID __cdecl ReportError (_In_ DWORD dwFlags, _In_ PCWSTR pszStr,...)
 
BOOL AppendSystemPostfix (LPWSTR lpName, DWORD dwMaxLength)
 
BOOL CreateUserHive (LPCWSTR lpKeyName, LPCWSTR lpProfilePath)
 
BOOL UpdateUsersShellFolderSettings (LPCWSTR lpUserProfilePath, HKEY hUserKey)
 
BOOL GetUserSidStringFromToken (HANDLE hToken, PUNICODE_STRING SidString)
 
VOID InitializeGPNotifications (VOID)
 
VOID UninitializeGPNotifications (VOID)
 

Variables

SID_IDENTIFIER_AUTHORITY LocalSystemAuthority
 
SID_IDENTIFIER_AUTHORITY WorldAuthority
 
DYN_MODULE DynOle32
 
HINSTANCE hInstance
 

Typedef Documentation

◆ DYN_FUNCS

◆ DYN_MODULE

◆ PDYN_FUNCS

◆ PDYN_MODULE

◆ POLICY_VALUES

◆ PPOLICY_VALUES

Function Documentation

◆ AppendBackslash()

LPWSTR AppendBackslash ( LPWSTR  String)

Definition at line 41 of file misc.c.

42{
44
46 if (String[Length - 1] != L'\\')
47 {
48 String[Length] = L'\\';
49 Length++;
50 String[Length] = (WCHAR)0;
51 }
52
53 return &String[Length];
54}
#define lstrlenW
Definition: compat.h:750
#define L(x)
Definition: resources.c:13
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CopyDirectory().

◆ AppendSystemPostfix()

BOOL AppendSystemPostfix ( LPWSTR  lpName,
DWORD  dwMaxLength 
)

Definition at line 20 of file profile.c.

22{
23 WCHAR szSystemRoot[MAX_PATH];
24 LPWSTR lpszPostfix;
25 LPWSTR lpszPtr;
26
27 /* Build profile name postfix */
28 if (!ExpandEnvironmentStringsW(L"%SystemRoot%",
29 szSystemRoot,
30 ARRAYSIZE(szSystemRoot)))
31 {
32 DPRINT1("Error: %lu\n", GetLastError());
33 return FALSE;
34 }
35
36 _wcsupr(szSystemRoot);
37
38 /* Get name postfix */
39 szSystemRoot[2] = L'.';
40 lpszPostfix = &szSystemRoot[2];
41 lpszPtr = lpszPostfix;
42 while (*lpszPtr != (WCHAR)0)
43 {
44 if (*lpszPtr == L'\\')
45 *lpszPtr = L'_';
46 lpszPtr++;
47 }
48
49 if (wcslen(lpName) + wcslen(lpszPostfix) + 1 >= dwMaxLength)
50 {
51 DPRINT1("Error: buffer overflow\n");
53 return FALSE;
54 }
55
56 wcscat(lpName, lpszPostfix);
57
58 return TRUE;
59}
#define DPRINT1
Definition: precomp.h:8
wcscat
_wcsupr
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define SetLastError(x)
Definition: compat.h:752
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LPCSTR lpName
Definition: winbase.h:2830
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CreateStandardProfile().

◆ CopyDirectory()

BOOL CopyDirectory ( LPCWSTR  lpDestinationPath,
LPCWSTR  lpSourcePath 
)

Definition at line 82 of file directory.c.

84{
85 WCHAR szFileName[MAX_PATH];
86 WCHAR szFullSrcName[MAX_PATH];
87 WCHAR szFullDstName[MAX_PATH];
88 WIN32_FIND_DATAW FindFileData;
89 LPWSTR lpSrcPtr;
90 LPWSTR lpDstPtr;
91 HANDLE hFind;
92
93 DPRINT("CopyDirectory (%S, %S) called\n",
94 lpDestinationPath, lpSourcePath);
95
96 wcscpy(szFileName, lpSourcePath);
97 wcscat(szFileName, L"\\*.*");
98
99 hFind = FindFirstFileW(szFileName,
100 &FindFileData);
101 if (hFind == INVALID_HANDLE_VALUE)
102 {
103 DPRINT1("Error: %lu\n", GetLastError());
104 return FALSE;
105 }
106
107 wcscpy(szFullSrcName, lpSourcePath);
108 lpSrcPtr = AppendBackslash(szFullSrcName);
109
110 wcscpy(szFullDstName, lpDestinationPath);
111 lpDstPtr = AppendBackslash(szFullDstName);
112
113 for (;;)
114 {
115 if (wcscmp(FindFileData.cFileName, L".") &&
116 wcscmp(FindFileData.cFileName, L".."))
117 {
118 wcscpy(lpSrcPtr, FindFileData.cFileName);
119 wcscpy(lpDstPtr, FindFileData.cFileName);
120
121 if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
122 {
123 DPRINT("Create directory: %S\n", szFullDstName);
124 if (!CreateDirectoryExW(szFullSrcName, szFullDstName, NULL))
125 {
127 {
128 DPRINT1("Error: %lu\n", GetLastError());
129
130 FindClose(hFind);
131 return FALSE;
132 }
133 }
134
135 if (!CopyDirectory(szFullDstName, szFullSrcName))
136 {
137 DPRINT1("Error: %lu\n", GetLastError());
138
139 FindClose(hFind);
140 return FALSE;
141 }
142 }
143 else
144 {
145 DPRINT("Copy file: %S -> %S\n", szFullSrcName, szFullDstName);
146 if (!CopyFileW(szFullSrcName, szFullDstName, FALSE))
147 {
148 DPRINT1("Error: %lu\n", GetLastError());
149
150 FindClose(hFind);
151 return FALSE;
152 }
153 }
154 }
155
156 if (!FindNextFileW(hFind, &FindFileData))
157 {
159 {
160 DPRINT1("Error: %lu\n", GetLastError());
161 }
162
163 break;
164 }
165 }
166
167 FindClose(hFind);
168
169 DPRINT("CopyDirectory() done\n");
170
171 return TRUE;
172}
wcscpy
#define NULL
Definition: types.h:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:439
BOOL WINAPI CreateDirectoryExW(IN LPCWSTR lpTemplateDirectory, IN LPCWSTR lpNewDirectory, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:193
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
BOOL CopyDirectory(LPCWSTR lpDestinationPath, LPCWSTR lpSourcePath)
Definition: directory.c:82
LPWSTR AppendBackslash(LPWSTR String)
Definition: misc.c:41
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define DPRINT
Definition: sndvol32.h:73
#define ERROR_NO_MORE_FILES
Definition: winerror.h:121

Referenced by CopyDirectory(), CopyProfileDirectoryW(), CopySystemProfile(), and CreateUserProfileExW().

◆ CreateDefaultSecurityDescriptor()

PSECURITY_DESCRIPTOR CreateDefaultSecurityDescriptor ( VOID  )

Definition at line 57 of file misc.c.

58{
60 PSID AdministratorsSid = NULL;
61 PSID EveryoneSid = NULL;
62 PACL Dacl;
65
66 /* create the SYSTEM, Administrators and Everyone SIDs */
68 1,
70 0,
71 0,
72 0,
73 0,
74 0,
75 0,
76 0,
79 2,
82 0,
83 0,
84 0,
85 0,
86 0,
87 0,
88 &AdministratorsSid) ||
90 1,
92 0,
93 0,
94 0,
95 0,
96 0,
97 0,
98 0,
99 &EveryoneSid))
100 {
101 DPRINT1("Failed initializing the SIDs for the default security descriptor (0x%p, 0x%p, 0x%p)\n",
102 LocalSystemSid, AdministratorsSid, EveryoneSid);
103 goto Cleanup;
104 }
105
106 /* allocate the security descriptor and DACL */
107 DaclSize = sizeof(ACL) +
109 GetLengthSid(AdministratorsSid) +
110 GetLengthSid(EveryoneSid)) +
112 SidStart)));
113
116 if (pSD == NULL)
117 {
118 DPRINT1("Failed to allocate the default security descriptor and ACL\n");
119 goto Cleanup;
120 }
121
124 {
125 DPRINT1("Failed to initialize the default security descriptor\n");
126 goto Cleanup;
127 }
128
129 /* initialize and build the DACL */
130 Dacl = (PACL)((ULONG_PTR)pSD + sizeof(SECURITY_DESCRIPTOR));
131 if (!InitializeAcl(Dacl,
134 {
135 DPRINT1("Failed to initialize the DACL of the default security descriptor\n");
136 goto Cleanup;
137 }
138
139 /* add the SYSTEM Ace */
144 {
145 DPRINT1("Failed to add the SYSTEM ACE\n");
146 goto Cleanup;
147 }
148
149 /* add the Administrators Ace */
153 AdministratorsSid))
154 {
155 DPRINT1("Failed to add the Administrators ACE\n");
156 goto Cleanup;
157 }
158
159 /* add the Everyone Ace */
163 EveryoneSid))
164 {
165 DPRINT1("Failed to add the Everyone ACE\n");
166 goto Cleanup;
167 }
168
169 /* set the DACL */
171 TRUE,
172 Dacl,
173 FALSE))
174 {
175 DPRINT1("Failed to set the DACL of the default security descriptor\n");
176
177Cleanup:
178 if (pSD != NULL)
179 {
180 LocalFree((HLOCAL)pSD);
181 pSD = NULL;
182 }
183 }
184
185 if (LocalSystemSid != NULL)
186 {
188 }
189 if (AdministratorsSid != NULL)
190 {
191 FreeSid(AdministratorsSid);
192 }
193 if (EveryoneSid != NULL)
194 {
195 FreeSid(EveryoneSid);
196 }
197
198 return pSD;
199}
PSID LocalSystemSid
Definition: globals.c:16
BOOL WINAPI AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, PSID *pSid)
Definition: security.c:674
BOOL WINAPI InitializeAcl(PACL pAcl, DWORD nAclLength, DWORD dwAclRevision)
Definition: security.c:1006
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
Definition: security.c:929
BOOL WINAPI AddAccessAllowedAce(PACL pAcl, DWORD dwAceRevision, DWORD AccessMask, PSID pSid)
Definition: security.c:1039
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:919
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:698
SID_IDENTIFIER_AUTHORITY WorldAuthority
Definition: misc.c:36
SID_IDENTIFIER_AUTHORITY LocalSystemAuthority
Definition: misc.c:35
static const WCHAR Cleanup[]
Definition: register.c:80
unsigned long DWORD
Definition: ntddk_ex.h:95
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
struct _SECURITY_DESCRIPTOR * PSECURITY_DESCRIPTOR
Definition: security.c:98
struct _ACL ACL
struct _SECURITY_DESCRIPTOR SECURITY_DESCRIPTOR
struct _ACL * PACL
Definition: security.c:105
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
Definition: rtlfuncs.h:1617
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG DaclSize
Definition: rtlfuncs.h:1618
#define GENERIC_ALL
Definition: nt_native.h:92
#define GENERIC_EXECUTE
Definition: nt_native.h:91
BOOL WINAPI SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bDaclPresent, PACL pDacl, BOOL bDaclDefaulted)
Definition: sec.c:262
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define LMEM_FIXED
Definition: winbase.h:401
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:581
#define SECURITY_WORLD_RID
Definition: setypes.h:541
#define SECURITY_LOCAL_SYSTEM_RID
Definition: setypes.h:574
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
#define ACL_REVISION
Definition: setypes.h:39
#define DOMAIN_ALIAS_RID_ADMINS
Definition: setypes.h:652

Referenced by EnterCriticalPolicySection(), and RegisterGPNotification().

◆ CreateDirectoryPath()

BOOL CreateDirectoryPath ( LPCWSTR  lpPathName,
LPSECURITY_ATTRIBUTES  lpSecurityAttributes 
)

Definition at line 176 of file directory.c.

178{
180 LPWSTR Ptr;
181 DWORD dwError;
182
183 DPRINT("CreateDirectoryPath() called\n");
184
185 if (lpPathName == NULL || *lpPathName == 0)
186 return TRUE;
187
188 if (CreateDirectoryW(lpPathName,
189 lpSecurityAttributes))
190 return TRUE;
191
192 dwError = GetLastError();
193 if (dwError == ERROR_ALREADY_EXISTS)
194 return TRUE;
195
196 wcscpy(szPath, lpPathName);
197
198 if (wcslen(szPath) > 3 && szPath[1] == ':' && szPath[2] == '\\')
199 {
200 Ptr = &szPath[3];
201 }
202 else
203 {
204 Ptr = szPath;
205 }
206
207 while (Ptr != NULL)
208 {
209 Ptr = wcschr(Ptr, L'\\');
210 if (Ptr != NULL)
211 *Ptr = 0;
212
213 DPRINT("CreateDirectory(%S)\n", szPath);
215 lpSecurityAttributes))
216 {
217 dwError = GetLastError();
218 if (dwError != ERROR_ALREADY_EXISTS)
219 return FALSE;
220 }
221
222 if (Ptr != NULL)
223 {
224 *Ptr = L'\\';
225 Ptr++;
226 }
227 }
228
229 DPRINT("CreateDirectoryPath() done\n");
230
231 return TRUE;
232}
#define wcschr
Definition: compat.h:17
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
LPCWSTR szPath
Definition: env.c:37

Referenced by AddDesktopItemW(), and CreateGroupW().

◆ CreateUserHive()

BOOL CreateUserHive ( LPCWSTR  lpKeyName,
LPCWSTR  lpProfilePath 
)

Definition at line 57 of file registry.c.

59{
60 HKEY hDefaultKey = NULL;
61 HKEY hUserKey = NULL;
62 LONG Error;
63 BOOL Ret = FALSE;
64
65 DPRINT("CreateUserHive(%S) called\n", lpKeyName);
66
68 L".Default",
69 0,
71 &hDefaultKey);
72 if (Error != ERROR_SUCCESS)
73 {
75 goto Cleanup;
76 }
77
79 lpKeyName,
80 0,
82 &hUserKey);
83 if (Error != ERROR_SUCCESS)
84 {
86 goto Cleanup;
87 }
88
89 if (!CopyKey(hUserKey, hDefaultKey))
90 {
91 goto Cleanup;
92 }
93
94 if (!UpdateUsersShellFolderSettings(lpProfilePath,
95 hUserKey))
96 {
97 goto Cleanup;
98 }
99
100 RegFlushKey(hUserKey);
101 Ret = TRUE;
102
103Cleanup:
104 if (hUserKey != NULL)
105 RegCloseKey (hUserKey);
106
107 if (hDefaultKey != NULL)
108 RegCloseKey (hDefaultKey);
109
110 return Ret;
111}
BOOL Error
Definition: chkdsk.c:66
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegFlushKey(HKEY hKey)
Definition: reg.c:2951
BOOL UpdateUsersShellFolderSettings(LPCWSTR lpUserProfilePath, HKEY hUserKey)
Definition: setup.c:434
static BOOL CopyKey(HKEY hDstKey, HKEY hSrcKey)
Definition: registry.c:38
unsigned int BOOL
Definition: ntddk_ex.h:94
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define KEY_READ
Definition: nt_native.h:1023
long LONG
Definition: pedump.c:60
#define HKEY_USERS
Definition: winreg.h:13

Referenced by CreateUserProfileExW().

◆ GetPolicyValue()

LONG GetPolicyValue ( _In_ HKEY  hRootKey,
_In_ PCWSTR  ValueName,
_In_ DWORD  Type,
_Out_opt_ PVOID  pData,
_Inout_opt_ PDWORD  pcbData 
)

Definition at line 261 of file misc.c.

267{
269 {
270 {ValueName, Type, pData, pcbData ? *pcbData : 0},
271 {NULL, 0, NULL, 0}
272 };
273 LONG ret = GetPolicyValues(hRootKey, QueryTable);
274 if ((ret == ERROR_SUCCESS) && pcbData)
275 *pcbData = QueryTable[0].Length;
276
277 return ret;
278}
Type
Definition: Type.h:7
LONG GetPolicyValues(_In_ HKEY hRootKey, _Inout_ PPOLICY_VALUES QueryTable)
Definition: misc.c:204
return ret
Definition: mutex.c:146
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
Definition: rtlfuncs.h:4203
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243

Referenced by ReportErrorWorker().

◆ GetPolicyValues()

LONG GetPolicyValues ( _In_ HKEY  hRootKey,
_Inout_ PPOLICY_VALUES  QueryTable 
)

Definition at line 204 of file misc.c.

207{
208 static PCWSTR PolicyKeys[] =
209 {
210 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
211 L"Software\\Policies\\Microsoft\\Windows\\System"
212 };
213
214 /* Retrieve the sought policy values in each of the policy keys */
215 DWORD i;
216 for (i = 0; i < _countof(PolicyKeys); ++i)
217 {
218 HKEY hKey;
220 DWORD dwType, cbData;
221
222 if (RegOpenKeyExW(hRootKey, PolicyKeys[i], 0,
224 {
225 continue;
226 }
227
228 for (Value = QueryTable; Value->ValueName || Value->Data; ++Value)
229 {
230 /* Retrieve the type and data length for validation checks */
231 if (RegQueryValueExW(hKey, Value->ValueName, NULL,
232 &dwType, NULL, &cbData) != ERROR_SUCCESS)
233 {
234 continue;
235 }
236
237 /* Verify for compatible types */
238 if ( ((Value->Type == REG_SZ || Value->Type == REG_EXPAND_SZ) &&
239 (dwType == REG_SZ || dwType == REG_EXPAND_SZ)) ||
240 (Value->Type == REG_DWORD && dwType == REG_DWORD) ||
241 (Value->Type == REG_QWORD && dwType == REG_QWORD) ||
242 (Value->Type == REG_MULTI_SZ && dwType == REG_MULTI_SZ) ||
243 (Value->Type == REG_NONE || Value->Type == REG_BINARY) )
244 {
245 /* Verify whether the given buffer can hold the data;
246 * if so, retrieve the actual data */
247 if (Value->Length >= cbData)
248 {
249 RegQueryValueExW(hKey, Value->ValueName, NULL,
250 &dwType, Value->Data, &cbData);
251 }
252 }
253 }
255 }
256
257 return ERROR_SUCCESS;
258}
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
FxAutoRegKey hKey
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define REG_SZ
Definition: layer.c:22
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define REG_NONE
Definition: nt_native.h:1492
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define REG_QWORD
Definition: sdbapi.c:597
#define REG_DWORD
Definition: sdbapi.c:596
#define _countof(array)
Definition: sndvol32.h:70
const uint16_t * PCWSTR
Definition: typedefs.h:57
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by GetPolicyValue().

◆ GetUserSidStringFromToken()

BOOL GetUserSidStringFromToken ( HANDLE  hToken,
PUNICODE_STRING  SidString 
)

Definition at line 102 of file sid.c.

104{
105 PTOKEN_USER UserBuffer, nsb;
108
109 Length = 256;
110 UserBuffer = LocalAlloc(LPTR, Length);
111 if (UserBuffer == NULL)
112 return FALSE;
113
115 TokenUser,
116 (PVOID)UserBuffer,
117 Length,
118 &Length);
120 {
121 nsb = LocalReAlloc(UserBuffer,
122 Length,
124 if (nsb == NULL)
125 {
126 LocalFree(UserBuffer);
127 return FALSE;
128 }
129
130 UserBuffer = nsb;
132 TokenUser,
133 (PVOID)UserBuffer,
134 Length,
135 &Length);
136 }
137
138 if (!NT_SUCCESS (Status))
139 {
140 LocalFree(UserBuffer);
142 return FALSE;
143 }
144
145 DPRINT("SidLength: %lu\n", RtlLengthSid (UserBuffer->User.Sid));
146
148 UserBuffer->User.Sid,
149 TRUE);
150
151 LocalFree(UserBuffer);
152
153 if (!NT_SUCCESS(Status))
154 {
156 return FALSE;
157 }
158
159 DPRINT("SidString.Length: %lu\n", SidString->Length);
160 DPRINT("SidString.MaximumLength: %lu\n", SidString->MaximumLength);
161 DPRINT("SidString: '%wZ'\n", SidString);
162
163 return TRUE;
164}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
HLOCAL NTAPI LocalReAlloc(HLOCAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:1625
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
NTSYSAPI ULONG NTAPI RtlLengthSid(IN PSID Sid)
Definition: sid.c:150
NTSYSAPI NTSTATUS NTAPI RtlConvertSidToUnicodeString(OUT PUNICODE_STRING DestinationString, IN PVOID Sid, IN BOOLEAN AllocateDestinationString)
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
SID_AND_ATTRIBUTES User
Definition: setypes.h:1022
USHORT MaximumLength
Definition: env_spec_w32.h:370
_Must_inspect_result_ __kernel_entry NTSTATUS NTAPI NtQueryInformationToken(_In_ HANDLE TokenHandle, _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, _Out_writes_bytes_to_opt_(TokenInformationLength, *ReturnLength) PVOID TokenInformation, _In_ ULONG TokenInformationLength, _Out_ PULONG ReturnLength)
Queries a specific type of information in regard of an access token based upon the information class....
Definition: tokencls.c:473
#define LMEM_MOVEABLE
Definition: winbase.h:402
#define LPTR
Definition: winbase.h:414
@ TokenUser
Definition: setypes.h:978

Referenced by CheckForLoadedProfile(), CopySystemProfile(), GetCurrentUserKey(), GetProfileType(), GetUserProfileDirectoryW(), LoadUserProfileW(), and UnloadUserProfile().

◆ InitializeGPNotifications()

VOID InitializeGPNotifications ( VOID  )

Definition at line 65 of file gpolicy.c.

66{
68}
static CRITICAL_SECTION GPNotifyLock
Definition: gpolicy.c:56
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751

Referenced by DllMain().

◆ LoadDynamicImports()

BOOL LoadDynamicImports ( PDYN_MODULE  Module,
PDYN_FUNCS  DynFuncs 
)

Definition at line 515 of file misc.c.

517{
518 LPSTR *fname;
519 PVOID *fn;
520
521 ZeroMemory(DynFuncs, sizeof(DYN_FUNCS));
522
523 DynFuncs->hModule = LoadLibraryW(Module->Library);
524 if (!DynFuncs->hModule)
525 {
526 return FALSE;
527 }
528
529 fn = &DynFuncs->fn.foo;
530
531 /* load the imports */
532 for (fname = Module->Functions; *fname != NULL; fname++)
533 {
534 *fn = GetProcAddress(DynFuncs->hModule, *fname);
535 if (*fn == NULL)
536 {
537 FreeLibrary(DynFuncs->hModule);
538 DynFuncs->hModule = (HMODULE)0;
539
540 return FALSE;
541 }
542
543 fn++;
544 }
545
546 return TRUE;
547}
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
union _DYN_FUNCS::@636 fn
HMODULE hModule
Definition: internal.h:49
PVOID foo
Definition: internal.h:52
LPWSTR Library
Definition: internal.h:64
LPSTR Functions[]
Definition: internal.h:65
HANDLE HMODULE
Definition: typedefs.h:77
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
#define ZeroMemory
Definition: winbase.h:1753
char * LPSTR
Definition: xmlstorage.h:182

Referenced by AddDesktopItemW(), and AddItemW().

◆ RemoveDirectoryPath()

BOOL RemoveDirectoryPath ( LPCWSTR  lpPathName)

Definition at line 324 of file directory.c.

325{
326 if (!RecursiveRemoveDir(lpPathName))
327 return FALSE;
328
329 DPRINT("Delete directory: '%S'\n", lpPathName);
330 return RemoveDirectoryW(lpPathName);
331}
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
static BOOL RecursiveRemoveDir(LPCWSTR lpPath)
Definition: directory.c:237

Referenced by DeleteGroupW(), and DeleteProfileW().

◆ ReportError()

VOID __cdecl ReportError ( _In_ DWORD  dwFlags,
_In_ PCWSTR  pszStr,
  ... 
)

Definition at line 481 of file misc.c.

485{
487
488 va_start(args, pszStr);
489 ReportErrorV(dwFlags, pszStr, args);
490 va_end(args);
491}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
VOID ReportErrorV(_In_ DWORD dwFlags, _In_ PCWSTR pszStr, _In_ va_list args)
Definition: misc.c:469
LPCWSTR LPCWSTR LPCWSTR DWORD dwFlags
Definition: env.c:37
#define args
Definition: format.c:66
Definition: match.c:390

Referenced by LoadUserProfileW().

◆ ReportErrorV()

VOID ReportErrorV ( _In_ DWORD  dwFlags,
_In_ PCWSTR  pszStr,
_In_ va_list  args 
)

Definition at line 469 of file misc.c.

473{
474 WCHAR Buffer[4096];
477}
Definition: bufpool.h:45
VOID ReportErrorWorker(_In_ DWORD dwFlags, _In_ PCWSTR pszStr)
Definition: misc.c:446
_CRTIMP int __cdecl _vsnwprintf(wchar_t *_Dest, size_t _Count, const wchar_t *_Format, va_list _Args)

Referenced by ReportError().

◆ ReportErrorWorker()

VOID ReportErrorWorker ( _In_ DWORD  dwFlags,
_In_ PCWSTR  pszStr 
)

Definition at line 446 of file misc.c.

449{
450 // TODO: Report event to Application log, "Userenv" source.
451 DPRINT1("%S", pszStr);
452
453 if (!(dwFlags & PI_NOUI))
454 {
455 /* Retrieve the "Profile Dialog Time Out" policy value,
456 * defaulting to 30 seconds timeout */
457 ULONG ulTimeout = 30;
458 DWORD cbData = sizeof(ulTimeout);
460 L"ProfileDlgTimeOut",
461 REG_DWORD,
462 &ulTimeout,
463 &cbData);
464 ErrorDialogEx(ulTimeout, pszStr);
465 }
466}
LONG GetPolicyValue(_In_ HKEY hRootKey, _In_ PCWSTR ValueName, _In_ DWORD Type, _Out_opt_ PVOID pData, _Inout_opt_ PDWORD pcbData)
Definition: misc.c:261
VOID ErrorDialogEx(_In_ ULONG ulTimeout, _In_ PCWSTR pszString)
Definition: misc.c:436
#define PI_NOUI
Definition: userenv.h:8
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ReportErrorV().

◆ UninitializeGPNotifications()

VOID UninitializeGPNotifications ( VOID  )

Definition at line 71 of file gpolicy.c.

72{
74
75 /* rundown the notification thread */
77 {
79
80 /* notify the thread */
83
85
86 /* wait for the thread to terminate itself */
88 INFINITE);
89
91
93 {
94 /* the handle should be closed by the thread,
95 just in case that didn't happen for an unknown reason */
98 }
99 }
100
102 {
105 }
106
108
110}
#define CloseHandle
Definition: compat.h:739
#define INFINITE
Definition: serial.h:102
static HANDLE hNotificationThread
Definition: gpolicy.c:59
@ gpaTerminate
Definition: gpolicy.c:42
static GP_ACTION GPNotificationAction
Definition: gpolicy.c:58
static HANDLE hNotificationThreadEvent
Definition: gpolicy.c:60
#define ASSERT(a)
Definition: mode.c:44
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Referenced by DllMain().

◆ UnloadDynamicImports()

VOID UnloadDynamicImports ( PDYN_FUNCS  DynFuncs)

Definition at line 550 of file misc.c.

551{
552 if (DynFuncs->hModule)
553 {
554 FreeLibrary(DynFuncs->hModule);
555 DynFuncs->hModule = (HMODULE)0;
556 }
557}

Referenced by AddDesktopItemW(), and AddItemW().

◆ UpdateUsersShellFolderSettings()

BOOL UpdateUsersShellFolderSettings ( LPCWSTR  lpUserProfilePath,
HKEY  hUserKey 
)

Definition at line 434 of file setup.c.

436{
437 WCHAR szBuffer[MAX_PATH];
439 PFOLDERDATA lpFolderData;
440 HKEY hFoldersKey;
441 LONG Error;
442
443 DPRINT("UpdateUsersShellFolderSettings() called\n");
444
445 DPRINT("User profile path: %S\n", lpUserProfilePath);
446
447 Error = RegOpenKeyExW(hUserKey,
448 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
449 0,
451 &hFoldersKey);
452 if (Error != ERROR_SUCCESS)
453 {
454 DPRINT1("Error: %lu\n", Error);
456 return FALSE;
457 }
458
459 lpFolderData = &UserShellFolders[0];
460 while (lpFolderData->lpValueName != NULL)
461 {
462 if (lpFolderData->bShellFolder)
463 {
464 StringCbCopyW(szBuffer, sizeof(szBuffer), lpUserProfilePath);
465 StringCbCatW(szBuffer, sizeof(szBuffer), L"\\");
466
467 /* Append the folder name */
468 dwLength = wcslen(szBuffer);
470 lpFolderData->uId,
471 &szBuffer[dwLength],
472 ARRAYSIZE(szBuffer) - dwLength))
473 {
474 /* Use the default name instead */
475 StringCbCatW(szBuffer, sizeof(szBuffer), lpFolderData->lpPath);
476 }
477
478 DPRINT("%S: %S\n", lpFolderData->lpValueName, szBuffer);
479
480 dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
481 Error = RegSetValueExW(hFoldersKey,
482 lpFolderData->lpValueName,
483 0,
484 REG_SZ,
485 (LPBYTE)szBuffer,
486 dwLength);
487 if (Error != ERROR_SUCCESS)
488 {
489 DPRINT1("Error: %lu\n", Error);
490 RegCloseKey(hFoldersKey);
492 return FALSE;
493 }
494 }
495
496 lpFolderData++;
497 }
498
499 RegCloseKey(hFoldersKey);
500
501 DPRINT("UpdateUsersShellFolderSettings() done\n");
502
503 return TRUE;
504}
HINSTANCE hInstance
Definition: charmap.c:19
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
static DWORD DWORD * dwLength
Definition: fusion.c:86
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
Definition: string.c:1220
static FOLDERDATA UserShellFolders[]
Definition: setup.c:29
#define KEY_SET_VALUE
Definition: nt_native.h:1017
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
UINT uId
Definition: setup.c:21
LPWSTR lpPath
Definition: setup.c:20
LPWSTR lpValueName
Definition: setup.c:19
BOOL bShellFolder
Definition: setup.c:23
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by CreateUserHive().

Variable Documentation

◆ DynOle32

DYN_MODULE DynOle32
extern

Definition at line 497 of file misc.c.

Referenced by AddDesktopItemW(), and AddItemW().

◆ hInstance

HINSTANCE hInstance
extern

Definition at line 19 of file charmap.c.

◆ LocalSystemAuthority

SID_IDENTIFIER_AUTHORITY LocalSystemAuthority
extern

Definition at line 35 of file misc.c.

Referenced by CheckForGuestsAndAdmins(), and CreateDefaultSecurityDescriptor().

◆ WorldAuthority

SID_IDENTIFIER_AUTHORITY WorldAuthority
extern

Definition at line 36 of file misc.c.

Referenced by CreateDefaultSecurityDescriptor().