ReactOS  0.4.14-dev-77-gd9e7c48
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
 

Typedefs

typedef struct _DYN_FUNCS DYN_FUNCS
 
typedef struct _DYN_FUNCSPDYN_FUNCS
 
typedef struct _DYN_MODULE DYN_MODULE
 
typedef struct _DYN_MODULEPDYN_MODULE
 

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)
 
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

Function Documentation

◆ AppendBackslash()

LPWSTR AppendBackslash ( LPWSTR  String)

Definition at line 40 of file misc.c.

41 {
42  ULONG Length;
43 
45  if (String[Length - 1] != L'\\')
46  {
47  String[Length] = L'\\';
48  Length++;
49  String[Length] = (WCHAR)0;
50  }
51 
52  return &String[Length];
53 }
static WCHAR String[]
Definition: stringtable.c:55
#define lstrlenW
Definition: compat.h:407
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static const WCHAR L[]
Definition: oid.c:1250
unsigned int ULONG
Definition: retypes.h:1

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 TRUE
Definition: types.h:120
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
_In_ LPCSTR lpName
Definition: winbase.h:2729
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
_CRTIMP wchar_t *__cdecl _wcsupr(_Inout_z_ wchar_t *_String)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define SetLastError(x)
Definition: compat.h:409
static const WCHAR L[]
Definition: oid.c:1250
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
#define DPRINT1
Definition: precomp.h:8
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

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 }
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
#define TRUE
Definition: types.h:120
LPWSTR AppendBackslash(LPWSTR String)
Definition: misc.c:40
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL CopyDirectory(LPCWSTR lpDestinationPath, LPCWSTR lpSourcePath)
Definition: directory.c:82
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define ERROR_NO_MORE_FILES
Definition: winerror.h:121
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:439
#define MAX_PATH
Definition: compat.h:26
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
BOOL WINAPI CreateDirectoryExW(IN LPCWSTR lpTemplateDirectory, IN LPCWSTR lpNewDirectory, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:193
#define DPRINT1
Definition: precomp.h:8
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
WCHAR * LPWSTR
Definition: xmlstorage.h:184
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

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,
77  &LocalSystemSid) ||
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 
115  (SIZE_T)DaclSize + sizeof(SECURITY_DESCRIPTOR));
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,
132  (DWORD)DaclSize,
133  ACL_REVISION))
134  {
135  DPRINT1("Failed to initialize the DACL of the default security descriptor\n");
136  goto Cleanup;
137  }
138 
139  /* add the SYSTEM Ace */
141  ACL_REVISION,
142  GENERIC_ALL,
144  {
145  DPRINT1("Failed to add the SYSTEM ACE\n");
146  goto Cleanup;
147  }
148 
149  /* add the Administrators Ace */
151  ACL_REVISION,
152  GENERIC_ALL,
153  AdministratorsSid))
154  {
155  DPRINT1("Failed to add the Administrators ACE\n");
156  goto Cleanup;
157  }
158 
159  /* add the Everyone Ace */
161  ACL_REVISION,
163  EveryoneSid))
164  {
165  DPRINT1("Failed to add the Everyone ACE\n");
166  goto Cleanup;
167  }
168 
169  /* set the DACL */
170  if (!SetSecurityDescriptorDacl(pSD,
171  TRUE,
172  Dacl,
173  FALSE))
174  {
175  DPRINT1("Failed to set the DACL of the default security descriptor\n");
176 
177 Cleanup:
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 }
struct _SECURITY_DESCRIPTOR * PSECURITY_DESCRIPTOR
Definition: security.c:97
#define GENERIC_ALL
Definition: nt_native.h:92
#define SECURITY_LOCAL_SYSTEM_RID
Definition: setypes.h:546
#define TRUE
Definition: types.h:120
BOOL WINAPI InitializeAcl(PACL pAcl, DWORD nAclLength, DWORD dwAclRevision)
Definition: security.c:885
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
Definition: security.c:808
BOOL WINAPI AddAccessAllowedAce(PACL pAcl, DWORD dwAceRevision, DWORD AccessMask, PSID pSid)
Definition: security.c:918
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:577
struct _ACL ACL
smooth NULL
Definition: ftsmooth.c:416
struct _ACL * PACL
Definition: security.c:104
#define LMEM_FIXED
Definition: winbase.h:349
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:553
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:798
PSID LocalSystemSid
Definition: globals.c:16
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SECURITY_WORLD_RID
Definition: setypes.h:513
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
Definition: rtlfuncs.h:1553
static const WCHAR Cleanup[]
Definition: register.c:80
struct _SECURITY_DESCRIPTOR SECURITY_DESCRIPTOR
ULONG_PTR SIZE_T
Definition: typedefs.h:78
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
BOOL WINAPI SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bDaclPresent, PACL pDacl, BOOL bDaclDefaulted)
Definition: sec.c:262
#define DPRINT1
Definition: precomp.h:8
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG DaclSize
Definition: rtlfuncs.h:1553
#define ACL_REVISION
Definition: setypes.h:39
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
SID_IDENTIFIER_AUTHORITY WorldAuthority
Definition: misc.c:35
#define GENERIC_EXECUTE
Definition: nt_native.h:91
#define DOMAIN_ALIAS_RID_ADMINS
Definition: setypes.h:624
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:553
SID_IDENTIFIER_AUTHORITY LocalSystemAuthority
Definition: misc.c:34

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 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
#define TRUE
Definition: types.h:120
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
LPCWSTR szPath
Definition: env.c:35
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by AddDesktopItemW(), and CreateGroupW().

◆ CreateUserHive()

BOOL CreateUserHive ( LPCWSTR  lpKeyName,
LPCWSTR  lpProfilePath 
)

Definition at line 279 of file registry.c.

281 {
282  HKEY hDefaultKey = NULL;
283  HKEY hUserKey = NULL;
284  LONG Error;
285  BOOL Ret = FALSE;
286 
287  DPRINT("CreateUserHive(%S) called\n", lpKeyName);
288 
290  L".Default",
291  0,
292  KEY_READ,
293  &hDefaultKey);
294  if (Error != ERROR_SUCCESS)
295  {
297  goto Cleanup;
298  }
299 
301  lpKeyName,
302  0,
304  &hUserKey);
305  if (Error != ERROR_SUCCESS)
306  {
308  goto Cleanup;
309  }
310 
311  if (!CopyKey(hUserKey, hDefaultKey))
312  {
313  goto Cleanup;
314  }
315 
316  if (!UpdateUsersShellFolderSettings(lpProfilePath,
317  hUserKey))
318  {
319  goto Cleanup;
320  }
321 
322  RegFlushKey(hUserKey);
323  Ret = TRUE;
324 
325 Cleanup:
326  if (hUserKey != NULL)
327  RegCloseKey (hUserKey);
328 
329  if (hDefaultKey != NULL)
330  RegCloseKey (hDefaultKey);
331 
332  return Ret;
333 }
#define HKEY_USERS
Definition: winreg.h:13
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
LONG WINAPI RegFlushKey(HKEY hKey)
Definition: reg.c:2974
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
static BOOL CopyKey(HKEY hDstKey, HKEY hSrcKey)
Definition: registry.c:36
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL Error
Definition: chkdsk.c:66
#define SetLastError(x)
Definition: compat.h:409
static const WCHAR L[]
Definition: oid.c:1250
static const WCHAR Cleanup[]
Definition: register.c:80
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
BOOL UpdateUsersShellFolderSettings(LPCWSTR lpUserProfilePath, HKEY hUserKey)
Definition: setup.c:434

Referenced by CreateUserProfileExW().

◆ GetUserSidStringFromToken()

BOOL GetUserSidStringFromToken ( HANDLE  hToken,
PUNICODE_STRING  SidString 
)

Definition at line 102 of file sid.c.

104 {
105  PTOKEN_USER UserBuffer, nsb;
106  ULONG Length;
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,
123  LMEM_MOVEABLE);
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 }
#define TRUE
Definition: types.h:120
USHORT MaximumLength
Definition: env_spec_w32.h:370
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
NTSTATUS NTAPI RtlConvertSidToUnicodeString(IN PUNICODE_STRING String, IN PSID Sid_, IN BOOLEAN AllocateBuffer)
Definition: sid.c:342
smooth NULL
Definition: ftsmooth.c:416
_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)
Definition: token.c:1839
ULONG NTAPI RtlLengthSid(IN PSID Sid_)
Definition: sid.c:150
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define LMEM_MOVEABLE
Definition: winbase.h:350
#define SetLastError(x)
Definition: compat.h:409
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
HLOCAL NTAPI LocalReAlloc(HLOCAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:1608
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
unsigned int ULONG
Definition: retypes.h:1
#define LPTR
Definition: winbase.h:362
SID_AND_ATTRIBUTES User
Definition: setypes.h:956
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373

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 223 of file misc.c.

225 {
226  LPSTR *fname;
227  PVOID *fn;
228 
229  ZeroMemory(DynFuncs, sizeof(DYN_FUNCS));
230 
231  DynFuncs->hModule = LoadLibraryW(Module->Library);
232  if (!DynFuncs->hModule)
233  {
234  return FALSE;
235  }
236 
237  fn = &DynFuncs->fn.foo;
238 
239  /* load the imports */
240  for (fname = Module->Functions; *fname != NULL; fname++)
241  {
242  *fn = GetProcAddress(DynFuncs->hModule, *fname);
243  if (*fn == NULL)
244  {
245  FreeLibrary(DynFuncs->hModule);
246  DynFuncs->hModule = (HMODULE)0;
247 
248  return FALSE;
249  }
250 
251  fn++;
252  }
253 
254  return TRUE;
255 }
#define TRUE
Definition: types.h:120
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
union _DYN_FUNCS::@536 fn
#define ZeroMemory
Definition: winbase.h:1635
char * LPSTR
Definition: xmlstorage.h:182
LPWSTR Library
Definition: internal.h:64
#define LoadLibraryW(x)
Definition: compat.h:404
smooth NULL
Definition: ftsmooth.c:416
LPSTR Functions[]
Definition: internal.h:65
#define FreeLibrary(x)
Definition: compat.h:405
PVOID foo
Definition: internal.h:52
HANDLE HMODULE
Definition: typedefs.h:75
#define GetProcAddress(x, y)
Definition: compat.h:410
HMODULE hModule
Definition: internal.h:49

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 }
void DPRINT(...)
Definition: polytest.cpp:61
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
static BOOL RecursiveRemoveDir(LPCWSTR lpPath)
Definition: directory.c:237

Referenced by DeleteGroupW().

◆ 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:398
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static CRITICAL_SECTION GPNotifyLock
Definition: gpolicy.c:56
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static HANDLE hNotificationThreadEvent
Definition: gpolicy.c:60
static HANDLE hNotificationThread
Definition: gpolicy.c:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static GP_ACTION GPNotificationAction
Definition: gpolicy.c:58
#define INFINITE
Definition: serial.h:102

Referenced by DllMain().

◆ UnloadDynamicImports()

VOID UnloadDynamicImports ( PDYN_FUNCS  DynFuncs)

Definition at line 259 of file misc.c.

260 {
261  if (DynFuncs->hModule)
262  {
263  FreeLibrary(DynFuncs->hModule);
264  DynFuncs->hModule = (HMODULE)0;
265  }
266 }
#define FreeLibrary(x)
Definition: compat.h:405
HANDLE HMODULE
Definition: typedefs.h:75
HMODULE hModule
Definition: internal.h:49

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];
438  DWORD dwLength;
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);
469  if (!LoadStringW(hInstance,
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 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
LPWSTR lpPath
Definition: setup.c:20
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
LPWSTR lpValueName
Definition: setup.c:19
HINSTANCE hInstance
Definition: charmap.c:20
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
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:4895
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:83
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL Error
Definition: chkdsk.c:66
#define SetLastError(x)
Definition: compat.h:409
static FOLDERDATA UserShellFolders[]
Definition: setup.c:29
static const WCHAR L[]
Definition: oid.c:1250
BOOL bShellFolder
Definition: setup.c:23
#define DPRINT1
Definition: precomp.h:8
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
UINT uId
Definition: setup.c:21
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22

Referenced by CreateUserHive().

Variable Documentation

◆ DynOle32

DYN_MODULE DynOle32

Definition at line 204 of file misc.c.

Referenced by AddDesktopItemW(), and AddItemW().

◆ hInstance

HINSTANCE hInstance

Definition at line 20 of file charmap.c.

◆ LocalSystemAuthority

SID_IDENTIFIER_AUTHORITY LocalSystemAuthority

Definition at line 34 of file misc.c.

Referenced by CheckForGuestsAndAdmins(), and CreateDefaultSecurityDescriptor().

◆ WorldAuthority

SID_IDENTIFIER_AUTHORITY WorldAuthority

Definition at line 35 of file misc.c.

Referenced by CreateDefaultSecurityDescriptor().