ReactOS  0.4.14-dev-614-gbfd8a84
userenv.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _PROFILEINFOA
 
struct  _PROFILEINFOW
 

Macros

#define PI_NOUI   (1)
 
#define PI_APPLYPOLICY   (2)
 
#define CreateUserProfile   CreateUserProfileA
 
#define CreateUserProfileEx   CreateUserProfileExA
 
#define AddDesktopItem   AddDesktopItemA
 
#define DeleteDesktopItem   DeleteDesktopItemA
 
#define CreateGroup   CreateGroupA
 
#define DeleteGroup   DeleteGroupA
 
#define AddItem   AddItemA
 
#define DeleteItem   DeleteItemA
 
#define CopyProfileDirectory   CopyProfileDirectoryA
 
#define LoadUserProfile   LoadUserProfileA
 
#define GetAllUsersProfileDirectory   GetAllUsersProfileDirectoryA
 
#define GetDefaultUserProfileDirectory   GetDefaultUserProfileDirectoryA
 
#define GetProfilesDirectory   GetProfilesDirectoryA
 
#define GetUserProfileDirectory   GetUserProfileDirectoryA
 

Typedefs

typedef struct _PROFILEINFOA PROFILEINFOA
 
typedef struct _PROFILEINFOALPPROFILEINFOA
 
typedef struct _PROFILEINFOW PROFILEINFOW
 
typedef struct _PROFILEINFOWLPPROFILEINFOW
 
typedef PROFILEINFOA PROFILEINFO
 
typedef LPPROFILEINFOA LPPROFILEINFO
 

Functions

BOOL WINAPI InitializeProfiles (VOID)
 
BOOL WINAPI CreateUserProfileA (PSID, LPCSTR)
 
BOOL WINAPI CreateUserProfileW (PSID, LPCWSTR)
 
BOOL WINAPI CreateUserProfileExA (PSID, LPCSTR, LPCSTR, LPSTR, DWORD, BOOL)
 
BOOL WINAPI CreateUserProfileExW (PSID, LPCWSTR, LPCWSTR, LPWSTR, DWORD, BOOL)
 
BOOL WINAPI AddDesktopItemA (BOOL, LPCSTR, LPCSTR, LPCSTR, INT, LPCSTR, WORD, INT)
 
BOOL WINAPI AddDesktopItemW (BOOL, LPCWSTR, LPCWSTR, LPCWSTR, INT, LPCWSTR, WORD, INT)
 
BOOL WINAPI DeleteDesktopItemA (BOOL, LPCSTR)
 
BOOL WINAPI DeleteDesktopItemW (BOOL, LPCWSTR)
 
BOOL WINAPI CreateGroupA (LPCSTR, BOOL)
 
BOOL WINAPI CreateGroupW (LPCWSTR, BOOL)
 
BOOL WINAPI DeleteGroupA (LPCSTR, BOOL)
 
BOOL WINAPI DeleteGroupW (LPCWSTR, BOOL)
 
BOOL WINAPI AddItemA (LPCSTR, BOOL, LPCSTR, LPCSTR, LPCSTR, INT, LPCSTR, WORD, INT)
 
BOOL WINAPI AddItemW (LPCWSTR, BOOL, LPCWSTR, LPCWSTR, LPCWSTR, INT, LPCWSTR, WORD, INT)
 
BOOL WINAPI DeleteItemA (LPCSTR, BOOL, LPCSTR, BOOL)
 
BOOL WINAPI DeleteItemW (LPCWSTR, BOOL, LPCWSTR, BOOL)
 
BOOL WINAPI CopyProfileDirectoryA (LPCSTR, LPCSTR, DWORD)
 
BOOL WINAPI CopyProfileDirectoryW (LPCWSTR, LPCWSTR, DWORD)
 
PSID WINAPI GetUserSid (HANDLE)
 
BOOL WINAPI CopySystemProfile (ULONG)
 
BOOL WINAPI LoadUserProfileA (HANDLE, LPPROFILEINFOA)
 
BOOL WINAPI LoadUserProfileW (HANDLE, LPPROFILEINFOW)
 
BOOL WINAPI UnloadUserProfile (HANDLE, HANDLE)
 
BOOL WINAPI GetAllUsersProfileDirectoryA (LPSTR, LPDWORD)
 
BOOL WINAPI GetAllUsersProfileDirectoryW (LPWSTR, LPDWORD)
 
BOOL WINAPI GetDefaultUserProfileDirectoryA (LPSTR, LPDWORD)
 
BOOL WINAPI GetDefaultUserProfileDirectoryW (LPWSTR, LPDWORD)
 
BOOL WINAPI GetProfilesDirectoryA (LPSTR, LPDWORD)
 
BOOL WINAPI GetProfilesDirectoryW (LPWSTR, LPDWORD)
 
BOOL WINAPI GetUserProfileDirectoryA (HANDLE, LPSTR, LPDWORD)
 
BOOL WINAPI GetUserProfileDirectoryW (HANDLE, LPWSTR, LPDWORD)
 
BOOL WINAPI CreateEnvironmentBlock (LPVOID *, HANDLE, BOOL)
 
BOOL WINAPI DestroyEnvironmentBlock (LPVOID)
 
HANDLE WINAPI EnterCriticalPolicySection (BOOL)
 
BOOL WINAPI LeaveCriticalPolicySection (HANDLE)
 
BOOL WINAPI RefreshPolicy (BOOL)
 
BOOL WINAPI RegisterGPNotification (HANDLE, BOOL)
 
BOOL WINAPI UnregisterGPNotification (HANDLE)
 

Macro Definition Documentation

◆ AddDesktopItem

#define AddDesktopItem   AddDesktopItemA

Definition at line 205 of file userenv.h.

◆ AddItem

#define AddItem   AddItemA

Definition at line 209 of file userenv.h.

◆ CopyProfileDirectory

#define CopyProfileDirectory   CopyProfileDirectoryA

Definition at line 211 of file userenv.h.

◆ CreateGroup

#define CreateGroup   CreateGroupA

Definition at line 207 of file userenv.h.

◆ CreateUserProfile

#define CreateUserProfile   CreateUserProfileA

Definition at line 203 of file userenv.h.

◆ CreateUserProfileEx

#define CreateUserProfileEx   CreateUserProfileExA

Definition at line 204 of file userenv.h.

◆ DeleteDesktopItem

#define DeleteDesktopItem   DeleteDesktopItemA

Definition at line 206 of file userenv.h.

◆ DeleteGroup

#define DeleteGroup   DeleteGroupA

Definition at line 208 of file userenv.h.

◆ DeleteItem

#define DeleteItem   DeleteItemA

Definition at line 210 of file userenv.h.

◆ GetAllUsersProfileDirectory

#define GetAllUsersProfileDirectory   GetAllUsersProfileDirectoryA

Definition at line 217 of file userenv.h.

◆ GetDefaultUserProfileDirectory

#define GetDefaultUserProfileDirectory   GetDefaultUserProfileDirectoryA

Definition at line 218 of file userenv.h.

◆ GetProfilesDirectory

#define GetProfilesDirectory   GetProfilesDirectoryA

Definition at line 219 of file userenv.h.

◆ GetUserProfileDirectory

#define GetUserProfileDirectory   GetUserProfileDirectoryA

Definition at line 220 of file userenv.h.

◆ LoadUserProfile

#define LoadUserProfile   LoadUserProfileA

Definition at line 216 of file userenv.h.

◆ PI_APPLYPOLICY

#define PI_APPLYPOLICY   (2)

Definition at line 9 of file userenv.h.

◆ PI_NOUI

#define PI_NOUI   (1)

Definition at line 8 of file userenv.h.

Typedef Documentation

◆ LPPROFILEINFO

Definition at line 201 of file userenv.h.

◆ LPPROFILEINFOA

◆ LPPROFILEINFOW

◆ PROFILEINFO

Definition at line 200 of file userenv.h.

◆ PROFILEINFOA

◆ PROFILEINFOW

Function Documentation

◆ AddDesktopItemA()

BOOL WINAPI AddDesktopItemA ( BOOL  ,
LPCSTR  ,
LPCSTR  ,
LPCSTR  ,
INT  ,
LPCSTR  ,
WORD  ,
INT   
)

Definition at line 157 of file desktop.c.

165 {
166  UNICODE_STRING ItemName;
167  UNICODE_STRING Arguments;
169  UNICODE_STRING WorkingDirectory;
170  BOOL bResult;
171 
172  if (!RtlCreateUnicodeStringFromAsciiz(&ItemName,
173  (LPSTR)lpItemName))
174  {
176  return FALSE;
177  }
178 
179  if (!RtlCreateUnicodeStringFromAsciiz(&Arguments,
180  (LPSTR)lpArguments))
181  {
182  RtlFreeUnicodeString(&ItemName);
184  return FALSE;
185  }
186 
188  (LPSTR)lpIconLocation))
189  {
190  RtlFreeUnicodeString(&Arguments);
191  RtlFreeUnicodeString(&ItemName);
193  return FALSE;
194  }
195 
196  if (lpWorkingDirectory != NULL)
197  {
198  if (!RtlCreateUnicodeStringFromAsciiz(&WorkingDirectory,
199  (LPSTR)lpWorkingDirectory))
200  {
202  RtlFreeUnicodeString(&Arguments);
203  RtlFreeUnicodeString(&ItemName);
205  return FALSE;
206  }
207  }
208 
209  bResult = AddDesktopItemW(bCommonItem,
210  ItemName.Buffer,
211  Arguments.Buffer,
212  IconLocation.Buffer,
213  iIcon,
214  (lpWorkingDirectory != NULL) ? WorkingDirectory.Buffer : NULL,
215  wHotKey,
216  iShowCmd);
217 
218  if (lpWorkingDirectory != NULL)
219  {
220  RtlFreeUnicodeString(&WorkingDirectory);
221  }
222 
224  RtlFreeUnicodeString(&Arguments);
225  RtlFreeUnicodeString(&ItemName);
226 
227  return bResult;
228 }
BOOL WINAPI AddDesktopItemW(BOOL bCommonDesktop, LPCWSTR lpItemName, LPCWSTR lpArguments, LPCWSTR lpIconLocation, INT iIcon, LPCWSTR lpWorkingDirectory, WORD wHotKey, INT iShowCmd)
Definition: desktop.c:233
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
char * LPSTR
Definition: xmlstorage.h:182
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:417

◆ AddDesktopItemW()

BOOL WINAPI AddDesktopItemW ( BOOL  ,
LPCWSTR  ,
LPCWSTR  ,
LPCWSTR  ,
INT  ,
LPCWSTR  ,
WORD  ,
INT   
)

Definition at line 233 of file desktop.c.

241 {
242  DYN_FUNCS Ole32;
243  WCHAR szLinkPath[MAX_PATH];
244  WCHAR szArguments[MAX_PATH];
245  WCHAR szCommand[MAX_PATH];
246  WIN32_FIND_DATAW FindData;
247  HANDLE hFind;
248  LPWSTR Ptr;
249  DWORD dwLength;
250  IShellLinkW* psl;
251  IPersistFile* ppf;
252  HRESULT hr;
253  BOOL bResult;
254 
255  DPRINT("AddDesktopItemW() called\n");
256 
257  bResult = FALSE;
258 
259  if (!GetDesktopPath(bCommonDesktop, szLinkPath))
260  {
261  DPRINT1("GetDesktopPath() failed\n");
262  return FALSE;
263  }
264  DPRINT("Desktop path: '%S'\n", szLinkPath);
265 
266  /* Make sure the path exists */
267  hFind = FindFirstFileW(szLinkPath,
268  &FindData);
269  if (hFind == INVALID_HANDLE_VALUE)
270  {
271  DPRINT("'%S' does not exist\n", szLinkPath);
272 
273  /* Create directory path */
274  if (!CreateDirectoryPath(szLinkPath, NULL))
275  return FALSE;
276  }
277  else
278  {
279  DPRINT("'%S' exists\n", szLinkPath);
280  FindClose(hFind);
281  }
282 
283  /* Append backslash, item name and ".lnk" extension */
284  wcscat(szLinkPath, L"\\");
285  wcscat(szLinkPath, lpItemName);
286  wcscat(szLinkPath, L".lnk");
287  DPRINT("Link path: '%S'\n", szLinkPath);
288 
289  /* Split 'lpArguments' string into command and arguments */
290  Ptr = wcschr(lpArguments, L' ');
291  DPRINT("Ptr %p lpArguments %p\n", Ptr, lpArguments);
292  if (Ptr != NULL)
293  {
294  dwLength = (DWORD)(Ptr - lpArguments);
295  DPRINT("dwLength %lu\n", dwLength);
296  memcpy(szCommand, lpArguments, dwLength * sizeof(WCHAR));
297  szCommand[dwLength] = 0;
298  Ptr++;
299  wcscpy(szArguments, Ptr);
300  }
301  else
302  {
303  wcscpy(szCommand, lpArguments);
304  szArguments[0] = 0;
305  }
306  DPRINT("szCommand: '%S'\n", szCommand);
307  DPRINT("szArguments: '%S'\n", szArguments);
308 
309  /* Dynamically load ole32.dll */
310  if (!LoadDynamicImports(&DynOle32, &Ole32))
311  {
312  DPRINT1("USERENV: Unable to load OLE32.DLL\n");
313  return FALSE;
314  }
315 
316  Ole32.fn.CoInitialize(NULL);
317 
318  hr = Ole32.fn.CoCreateInstance(&CLSID_ShellLink,
319  NULL,
320  CLSCTX_INPROC_SERVER,
321  &IID_IShellLinkW,
322  (LPVOID*)&psl);
323  if (!SUCCEEDED(hr))
324  {
325  Ole32.fn.CoUninitialize();
326  UnloadDynamicImports(&Ole32);
327  return FALSE;
328  }
329 
330  hr = psl->lpVtbl->QueryInterface(psl,
332  (LPVOID*)&ppf);
333  if (SUCCEEDED(hr))
334  {
335  psl->lpVtbl->SetDescription(psl,
336  lpItemName);
337 
338  psl->lpVtbl->SetPath(psl,
339  szCommand);
340 
341  psl->lpVtbl->SetArguments(psl,
342  szArguments);
343 
344  psl->lpVtbl->SetIconLocation(psl,
345  lpIconLocation,
346  iIcon);
347 
348  if (lpWorkingDirectory != NULL)
349  {
350  psl->lpVtbl->SetWorkingDirectory(psl,
351  lpWorkingDirectory);
352  }
353  else
354  {
355  psl->lpVtbl->SetWorkingDirectory(psl,
356  L"%HOMEDRIVE%%HOMEPATH%");
357  }
358 
359  psl->lpVtbl->SetHotkey(psl,
360  wHotKey);
361 
362  psl->lpVtbl->SetShowCmd(psl,
363  iShowCmd);
364 
365  hr = ppf->lpVtbl->Save(ppf,
366  szLinkPath,
367  TRUE);
368  if (SUCCEEDED(hr))
369  bResult = TRUE;
370 
371  ppf->lpVtbl->Release(ppf);
372  }
373 
374  psl->lpVtbl->Release(psl);
375 
376  Ole32.fn.CoUninitialize();
377 
378  UnloadDynamicImports(&Ole32);
379 
380  DPRINT("AddDesktopItemW() done\n");
381 
382  return bResult;
383 }
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
#define DWORD
Definition: nt_native.h:44
VOID UnloadDynamicImports(PDYN_FUNCS DynFuncs)
Definition: misc.c:259
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static BOOL GetDesktopPath(BOOL bCommonPath, LPWSTR lpDesktopPath)
Definition: desktop.c:38
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:85
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
nsrefcnt Release()
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
BOOL LoadDynamicImports(PDYN_MODULE Module, PDYN_FUNCS DynFuncs)
Definition: misc.c:223
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
DYN_MODULE DynOle32
Definition: misc.c:204
BOOL CreateDirectoryPath(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: directory.c:176
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define DPRINT1
Definition: precomp.h:8
const GUID IID_IPersistFile
WCHAR * LPWSTR
Definition: xmlstorage.h:184
nsresult QueryInterface(nsIIDRef riid, void **result)
union _DYN_FUNCS::@549 fn
#define SUCCEEDED(hr)
Definition: intsafe.h:57
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 AddDesktopItemA().

◆ AddItemA()

BOOL WINAPI AddItemA ( LPCSTR  ,
BOOL  ,
LPCSTR  ,
LPCSTR  ,
LPCSTR  ,
INT  ,
LPCSTR  ,
WORD  ,
INT   
)

Definition at line 552 of file desktop.c.

561 {
562  UNICODE_STRING GroupName;
563  UNICODE_STRING ItemName;
564  UNICODE_STRING Arguments;
566  UNICODE_STRING WorkingDirectory;
567  BOOL bResult;
568 
569  if (!RtlCreateUnicodeStringFromAsciiz(&ItemName,
570  (LPSTR)lpItemName))
571  {
573  return FALSE;
574  }
575 
576  if (!RtlCreateUnicodeStringFromAsciiz(&Arguments,
577  (LPSTR)lpArguments))
578  {
579  RtlFreeUnicodeString(&ItemName);
581  return FALSE;
582  }
583 
585  (LPSTR)lpIconLocation))
586  {
587  RtlFreeUnicodeString(&Arguments);
588  RtlFreeUnicodeString(&ItemName);
590  return FALSE;
591  }
592 
593  if (lpGroupName != NULL)
594  {
595  if (!RtlCreateUnicodeStringFromAsciiz(&GroupName,
596  (LPSTR)lpGroupName))
597  {
599  RtlFreeUnicodeString(&Arguments);
600  RtlFreeUnicodeString(&ItemName);
602  return FALSE;
603  }
604  }
605 
606  if (lpWorkingDirectory != NULL)
607  {
608  if (!RtlCreateUnicodeStringFromAsciiz(&WorkingDirectory,
609  (LPSTR)lpWorkingDirectory))
610  {
611  if (lpGroupName != NULL)
612  {
613  RtlFreeUnicodeString(&GroupName);
614  }
616  RtlFreeUnicodeString(&Arguments);
617  RtlFreeUnicodeString(&ItemName);
619  return FALSE;
620  }
621  }
622 
623  bResult = AddItemW((lpGroupName != NULL) ? GroupName.Buffer : NULL,
624  bCommonGroup,
625  ItemName.Buffer,
626  Arguments.Buffer,
627  IconLocation.Buffer,
628  iIcon,
629  (lpWorkingDirectory != NULL) ? WorkingDirectory.Buffer : NULL,
630  wHotKey,
631  iShowCmd);
632 
633  if (lpGroupName != NULL)
634  {
635  RtlFreeUnicodeString(&GroupName);
636  }
637 
638  if (lpWorkingDirectory != NULL)
639  {
640  RtlFreeUnicodeString(&WorkingDirectory);
641  }
642 
644  RtlFreeUnicodeString(&Arguments);
645  RtlFreeUnicodeString(&ItemName);
646 
647  return bResult;
648 }
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
char * LPSTR
Definition: xmlstorage.h:182
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI AddItemW(LPCWSTR lpGroupName, BOOL bCommonGroup, LPCWSTR lpItemName, LPCWSTR lpArguments, LPCWSTR lpIconLocation, INT iIcon, LPCWSTR lpWorkingDirectory, WORD wHotKey, INT iShowCmd)
Definition: desktop.c:653
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:417

◆ AddItemW()

BOOL WINAPI AddItemW ( LPCWSTR  ,
BOOL  ,
LPCWSTR  ,
LPCWSTR  ,
LPCWSTR  ,
INT  ,
LPCWSTR  ,
WORD  ,
INT   
)

Definition at line 653 of file desktop.c.

662 {
663  DYN_FUNCS Ole32;
664  WCHAR szLinkPath[MAX_PATH];
665  WCHAR szArguments[MAX_PATH];
666  WCHAR szCommand[MAX_PATH];
667  WIN32_FIND_DATAW FindData;
668  HANDLE hFind;
669  LPWSTR Ptr;
670  DWORD dwLength;
671  IShellLinkW* psl;
672  IPersistFile* ppf;
673  HRESULT hr;
674  BOOL bResult;
675 
676  DPRINT("AddItemW() called\n");
677 
678  bResult = FALSE;
679 
680  if (!GetProgramsPath(bCommonGroup, szLinkPath))
681  {
682  DPRINT1("GetProgramsPath() failed\n");
683  return FALSE;
684  }
685 
686  DPRINT("Programs path: '%S'\n", szLinkPath);
687 
688  if (lpGroupName != NULL && *lpGroupName != 0)
689  {
690  wcscat(szLinkPath, L"\\");
691  wcscat(szLinkPath, lpGroupName);
692 
693  /* Make sure the path exists */
694  hFind = FindFirstFileW(szLinkPath,
695  &FindData);
696  if (hFind == INVALID_HANDLE_VALUE)
697  {
698  DPRINT("'%S' does not exist\n", szLinkPath);
699  if (!CreateGroupW(lpGroupName,
700  bCommonGroup))
701  return FALSE;
702  }
703  else
704  {
705  DPRINT("'%S' exists\n", szLinkPath);
706  FindClose(hFind);
707  }
708  }
709 
710  wcscat(szLinkPath, L"\\");
711  wcscat(szLinkPath, lpItemName);
712  wcscat(szLinkPath, L".lnk");
713  DPRINT("Link path: '%S'\n", szLinkPath);
714 
715  /* Split 'lpArguments' string into command and arguments */
716  Ptr = wcschr(lpArguments, L' ');
717  DPRINT("Ptr %p lpArguments %p\n", Ptr, lpArguments);
718  if (Ptr != NULL)
719  {
720  dwLength = (DWORD)(Ptr - lpArguments);
721  DPRINT("dwLength %lu\n", dwLength);
722  memcpy(szCommand, lpArguments, dwLength * sizeof(WCHAR));
723  szCommand[dwLength] = 0;
724  Ptr++;
725  wcscpy(szArguments, Ptr);
726  }
727  else
728  {
729  wcscpy(szCommand, lpArguments);
730  szArguments[0] = 0;
731  }
732  DPRINT("szCommand: '%S'\n", szCommand);
733  DPRINT("szArguments: '%S'\n", szArguments);
734 
735  /* Dynamically load ole32.dll */
736  if (!LoadDynamicImports(&DynOle32, &Ole32))
737  {
738  DPRINT1("USERENV: Unable to load OLE32.DLL\n");
739  return FALSE;
740  }
741 
742  Ole32.fn.CoInitialize(NULL);
743 
744  hr = Ole32.fn.CoCreateInstance(&CLSID_ShellLink,
745  NULL,
746  CLSCTX_INPROC_SERVER,
747  &IID_IShellLinkW,
748  (LPVOID*)&psl);
749  if (!SUCCEEDED(hr))
750  {
751  Ole32.fn.CoUninitialize();
752  UnloadDynamicImports(&Ole32);
753  return FALSE;
754  }
755 
756  hr = psl->lpVtbl->QueryInterface(psl,
758  (LPVOID*)&ppf);
759  if (SUCCEEDED(hr))
760  {
761  psl->lpVtbl->SetDescription(psl,
762  lpItemName);
763 
764  psl->lpVtbl->SetPath(psl,
765  szCommand);
766 
767  psl->lpVtbl->SetArguments(psl,
768  szArguments);
769 
770  psl->lpVtbl->SetIconLocation(psl,
771  lpIconLocation,
772  iIcon);
773 
774  if (lpWorkingDirectory != NULL)
775  {
776  psl->lpVtbl->SetWorkingDirectory(psl,
777  lpWorkingDirectory);
778  }
779  else
780  {
781  psl->lpVtbl->SetWorkingDirectory(psl,
782  L"%HOMEDRIVE%%HOMEPATH%");
783  }
784 
785  psl->lpVtbl->SetHotkey(psl,
786  wHotKey);
787 
788  psl->lpVtbl->SetShowCmd(psl,
789  iShowCmd);
790 
791  hr = ppf->lpVtbl->Save(ppf,
792  szLinkPath,
793  TRUE);
794  if (SUCCEEDED(hr))
795  bResult = TRUE;
796 
797  ppf->lpVtbl->Release(ppf);
798  }
799 
800  psl->lpVtbl->Release(psl);
801 
802  Ole32.fn.CoUninitialize();
803  UnloadDynamicImports(&Ole32);
804 
805  DPRINT("AddItemW() done\n");
806 
807  return bResult;
808 }
static BOOL GetProgramsPath(BOOL bCommonPath, LPWSTR lpProgramsPath)
Definition: desktop.c:97
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
#define DWORD
Definition: nt_native.h:44
VOID UnloadDynamicImports(PDYN_FUNCS DynFuncs)
Definition: misc.c:259
unsigned int BOOL
Definition: ntddk_ex.h:94
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
static DWORD DWORD * dwLength
Definition: fusion.c:85
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
nsrefcnt Release()
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
BOOL LoadDynamicImports(PDYN_MODULE Module, PDYN_FUNCS DynFuncs)
Definition: misc.c:223
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
DYN_MODULE DynOle32
Definition: misc.c:204
_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 CreateGroupW(LPCWSTR lpGroupName, BOOL bCommonGroup)
Definition: desktop.c:459
#define DPRINT1
Definition: precomp.h:8
const GUID IID_IPersistFile
WCHAR * LPWSTR
Definition: xmlstorage.h:184
nsresult QueryInterface(nsIIDRef riid, void **result)
union _DYN_FUNCS::@549 fn
#define SUCCEEDED(hr)
Definition: intsafe.h:57
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 AddItemA().

◆ CopyProfileDirectoryA()

BOOL WINAPI CopyProfileDirectoryA ( LPCSTR  ,
LPCSTR  ,
DWORD   
)

Definition at line 36 of file directory.c.

39 {
40  UNICODE_STRING SrcPath;
41  UNICODE_STRING DstPath;
42  BOOL bResult;
43 
45  (LPSTR)lpSourcePath))
46  {
48  return FALSE;
49  }
50 
52  (LPSTR)lpDestinationPath))
53  {
54  RtlFreeUnicodeString(&SrcPath);
56  return FALSE;
57  }
58 
59  bResult = CopyProfileDirectoryW(SrcPath.Buffer,
60  DstPath.Buffer,
61  dwFlags);
62 
63  RtlFreeUnicodeString(&DstPath);
64  RtlFreeUnicodeString(&SrcPath);
65 
66  return bResult;
67 }
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
char * LPSTR
Definition: xmlstorage.h:182
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:417
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
BOOL WINAPI CopyProfileDirectoryW(LPCWSTR lpSourcePath, LPCWSTR lpDestinationPath, DWORD dwFlags)
Definition: directory.c:72

◆ CopyProfileDirectoryW()

BOOL WINAPI CopyProfileDirectoryW ( LPCWSTR  ,
LPCWSTR  ,
DWORD   
)

Definition at line 72 of file directory.c.

75 {
76  /* FIXME: dwFlags are ignored! */
77  return CopyDirectory(lpDestinationPath, lpSourcePath);
78 }
BOOL CopyDirectory(LPCWSTR lpDestinationPath, LPCWSTR lpSourcePath)
Definition: directory.c:82

Referenced by CopyProfileDirectoryA().

◆ CopySystemProfile()

BOOL WINAPI CopySystemProfile ( ULONG  )

◆ CreateEnvironmentBlock()

BOOL WINAPI CreateEnvironmentBlock ( LPVOID ,
HANDLE  ,
BOOL   
)

◆ CreateGroupA()

BOOL WINAPI CreateGroupA ( LPCSTR  ,
BOOL   
)

Definition at line 436 of file desktop.c.

438 {
439  UNICODE_STRING GroupName;
440  BOOL bResult;
441 
442  if (!RtlCreateUnicodeStringFromAsciiz(&GroupName,
443  (LPSTR)lpGroupName))
444  {
446  return FALSE;
447  }
448 
449  bResult = CreateGroupW(GroupName.Buffer, bCommonGroup);
450 
451  RtlFreeUnicodeString(&GroupName);
452 
453  return bResult;
454 }
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
char * LPSTR
Definition: xmlstorage.h:182
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:417
BOOL WINAPI CreateGroupW(LPCWSTR lpGroupName, BOOL bCommonGroup)
Definition: desktop.c:459

◆ CreateGroupW()

BOOL WINAPI CreateGroupW ( LPCWSTR  ,
BOOL   
)

Definition at line 459 of file desktop.c.

461 {
462  WCHAR szGroupPath[MAX_PATH];
463 
464  DPRINT1("CreateGroupW() called\n");
465 
466  if (lpGroupName == NULL || *lpGroupName == 0)
467  return TRUE;
468 
469  if (!GetProgramsPath(bCommonGroup, szGroupPath))
470  {
471  DPRINT1("GetProgramsPath() failed\n");
472  return FALSE;
473  }
474  DPRINT1("Programs path: '%S'\n", szGroupPath);
475 
476  wcscat(szGroupPath, L"\\");
477  wcscat(szGroupPath, lpGroupName);
478  DPRINT1("Group path: '%S'\n", szGroupPath);
479 
480  /* Create directory path */
481  if (!CreateDirectoryPath (szGroupPath, NULL))
482  return FALSE;
483 
484  /* FIXME: Notify the shell */
485 
486  DPRINT1("CreateGroupW() done\n");
487 
488  return TRUE;
489 }
static BOOL GetProgramsPath(BOOL bCommonPath, LPWSTR lpProgramsPath)
Definition: desktop.c:97
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
static const WCHAR L[]
Definition: oid.c:1250
BOOL CreateDirectoryPath(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: directory.c:176
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define DPRINT1
Definition: precomp.h:8

Referenced by AddItemW(), and CreateGroupA().

◆ CreateUserProfileA()

BOOL WINAPI CreateUserProfileA ( PSID  ,
LPCSTR   
)

◆ CreateUserProfileExA()

BOOL WINAPI CreateUserProfileExA ( PSID  ,
LPCSTR  ,
LPCSTR  ,
LPSTR  ,
DWORD  ,
BOOL   
)

◆ CreateUserProfileExW()

BOOL WINAPI CreateUserProfileExW ( PSID  ,
LPCWSTR  ,
LPCWSTR  ,
LPWSTR  ,
DWORD  ,
BOOL   
)

◆ CreateUserProfileW()

BOOL WINAPI CreateUserProfileW ( PSID  ,
LPCWSTR   
)

◆ DeleteDesktopItemA()

BOOL WINAPI DeleteDesktopItemA ( BOOL  ,
LPCSTR   
)

Definition at line 388 of file desktop.c.

390 {
391  UNICODE_STRING ItemName;
392  BOOL bResult;
393 
394  if (!RtlCreateUnicodeStringFromAsciiz(&ItemName,
395  (LPSTR)lpItemName))
396  {
398  return FALSE;
399  }
400 
401  bResult = DeleteDesktopItemW(bCommonItem,
402  ItemName.Buffer);
403 
404  RtlFreeUnicodeString(&ItemName);
405 
406  return bResult;
407 }
BOOL WINAPI DeleteDesktopItemW(BOOL bCommonItem, LPCWSTR lpItemName)
Definition: desktop.c:412
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
char * LPSTR
Definition: xmlstorage.h:182
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:417

◆ DeleteDesktopItemW()

BOOL WINAPI DeleteDesktopItemW ( BOOL  ,
LPCWSTR   
)

Definition at line 412 of file desktop.c.

414 {
415  WCHAR szLinkPath[MAX_PATH];
416 
417  DPRINT("DeleteDesktopItemW() called\n");
418 
419  if (!GetDesktopPath(bCommonItem, szLinkPath))
420  {
421  DPRINT1("GetDesktopPath() failed\n");
422  return FALSE;
423  }
424 
425  wcscat(szLinkPath, L"\\");
426  wcscat(szLinkPath, lpItemName);
427  wcscat(szLinkPath, L".lnk");
428  DPRINT("Link path: '%S'\n", szLinkPath);
429 
430  return DeleteFileW (szLinkPath);
431 }
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
void DPRINT(...)
Definition: polytest.cpp:61
static BOOL GetDesktopPath(BOOL bCommonPath, LPWSTR lpDesktopPath)
Definition: desktop.c:38
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
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)
#define DPRINT1
Definition: precomp.h:8

Referenced by DeleteDesktopItemA().

◆ DeleteGroupA()

BOOL WINAPI DeleteGroupA ( LPCSTR  ,
BOOL   
)

Definition at line 494 of file desktop.c.

496 {
497  UNICODE_STRING GroupName;
498  BOOL bResult;
499 
500  if (!RtlCreateUnicodeStringFromAsciiz(&GroupName,
501  (LPSTR)lpGroupName))
502  {
504  return FALSE;
505  }
506 
507  bResult = DeleteGroupW(GroupName.Buffer, bCommonGroup);
508 
509  RtlFreeUnicodeString(&GroupName);
510 
511  return bResult;
512 }
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
char * LPSTR
Definition: xmlstorage.h:182
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
BOOL WINAPI DeleteGroupW(LPCWSTR lpGroupName, BOOL bCommonGroup)
Definition: desktop.c:517
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:417

◆ DeleteGroupW()

BOOL WINAPI DeleteGroupW ( LPCWSTR  ,
BOOL   
)

Definition at line 517 of file desktop.c.

519 {
520  WCHAR szGroupPath[MAX_PATH];
521 
522  DPRINT("DeleteGroupW() called\n");
523 
524  if (lpGroupName == NULL || *lpGroupName == 0)
525  return TRUE;
526 
527  if (!GetProgramsPath(bCommonGroup, szGroupPath))
528  {
529  DPRINT1("GetProgramsPath() failed\n");
530  return FALSE;
531  }
532  DPRINT("Programs path: '%S'\n", szGroupPath);
533 
534  wcscat(szGroupPath, L"\\");
535  wcscat(szGroupPath, lpGroupName);
536  DPRINT("Group path: '%S'\n", szGroupPath);
537 
538  /* Remove directory path */
539  if (!RemoveDirectoryPath (szGroupPath))
540  return FALSE;
541 
542  /* FIXME: Notify the shell */
543 
544  DPRINT("DeleteGroupW() done\n");
545 
546  return TRUE;
547 }
static BOOL GetProgramsPath(BOOL bCommonPath, LPWSTR lpProgramsPath)
Definition: desktop.c:97
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
BOOL RemoveDirectoryPath(LPCWSTR lpPathName)
Definition: directory.c:324
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
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)
#define DPRINT1
Definition: precomp.h:8

Referenced by DeleteGroupA().

◆ DeleteItemA()

BOOL WINAPI DeleteItemA ( LPCSTR  ,
BOOL  ,
LPCSTR  ,
BOOL   
)

Definition at line 813 of file desktop.c.

817 {
818  UNICODE_STRING GroupName;
819  UNICODE_STRING ItemName;
820  BOOL bResult;
821 
822  if (lpGroupName != NULL)
823  {
824  if (!RtlCreateUnicodeStringFromAsciiz(&GroupName,
825  (LPSTR)lpGroupName))
826  {
828  return FALSE;
829  }
830  }
831 
832  if (!RtlCreateUnicodeStringFromAsciiz(&ItemName,
833  (LPSTR)lpItemName))
834  {
835  if (lpGroupName != NULL)
836  {
837  RtlFreeUnicodeString(&GroupName);
838  }
839 
841  return FALSE;
842  }
843 
844  bResult = DeleteItemW((lpGroupName != NULL) ? GroupName.Buffer : NULL,
845  bCommonGroup,
846  ItemName.Buffer,
847  bDeleteGroup);
848 
849  RtlFreeUnicodeString(&ItemName);
850  if (lpGroupName != NULL)
851  {
852  RtlFreeUnicodeString(&GroupName);
853  }
854 
855  return bResult;
856 }
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
char * LPSTR
Definition: xmlstorage.h:182
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:417
BOOL WINAPI DeleteItemW(LPCWSTR lpGroupName, BOOL bCommonGroup, LPCWSTR lpItemName, BOOL bDeleteGroup)
Definition: desktop.c:861

◆ DeleteItemW()

BOOL WINAPI DeleteItemW ( LPCWSTR  ,
BOOL  ,
LPCWSTR  ,
BOOL   
)

Definition at line 861 of file desktop.c.

865 {
866  WCHAR szItemPath[MAX_PATH];
867  LPWSTR Ptr;
868 
869  DPRINT("DeleteItemW() called\n");
870 
871  if (!GetProgramsPath(bCommonGroup, szItemPath))
872  {
873  DPRINT1("GetProgramsPath() failed\n");
874  return FALSE;
875  }
876  DPRINT("Programs path: '%S'\n", szItemPath);
877 
878  if (lpGroupName != NULL && *lpGroupName != 0)
879  {
880  wcscat(szItemPath, L"\\");
881  wcscat(szItemPath, lpGroupName);
882  }
883 
884  wcscat(szItemPath, L"\\");
885  wcscat(szItemPath, lpItemName);
886  wcscat(szItemPath, L".lnk");
887  DPRINT("Item path: '%S'\n", szItemPath);
888 
889  if (!DeleteFileW(szItemPath))
890  return FALSE;
891 
892  /* FIXME: Notify the shell */
893 
894  if (bDeleteGroup)
895  {
896  Ptr = wcsrchr(szItemPath, L'\\');
897  if (Ptr == NULL)
898  return TRUE;
899 
900  *Ptr = 0;
901  DPRINT("Item path: '%S'\n", szItemPath);
902  if (RemoveDirectoryW(szItemPath))
903  {
904  /* FIXME: Notify the shell */
905  }
906  }
907 
908  DPRINT("DeleteItemW() done\n");
909 
910  return TRUE;
911 }
static BOOL GetProgramsPath(BOOL bCommonPath, LPWSTR lpProgramsPath)
Definition: desktop.c:97
#define TRUE
Definition: types.h:120
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
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)
#define DPRINT1
Definition: precomp.h:8
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DeleteItemA().

◆ DestroyEnvironmentBlock()

BOOL WINAPI DestroyEnvironmentBlock ( LPVOID  )

◆ EnterCriticalPolicySection()

HANDLE WINAPI EnterCriticalPolicySection ( BOOL  )

◆ GetAllUsersProfileDirectoryA()

BOOL WINAPI GetAllUsersProfileDirectoryA ( LPSTR  ,
LPDWORD   
)

◆ GetAllUsersProfileDirectoryW()

BOOL WINAPI GetAllUsersProfileDirectoryW ( LPWSTR  ,
LPDWORD   
)

◆ GetDefaultUserProfileDirectoryA()

BOOL WINAPI GetDefaultUserProfileDirectoryA ( LPSTR  ,
LPDWORD   
)

◆ GetDefaultUserProfileDirectoryW()

BOOL WINAPI GetDefaultUserProfileDirectoryW ( LPWSTR  ,
LPDWORD   
)

◆ GetProfilesDirectoryA()

BOOL WINAPI GetProfilesDirectoryA ( LPSTR  ,
LPDWORD   
)

◆ GetProfilesDirectoryW()

BOOL WINAPI GetProfilesDirectoryW ( LPWSTR  ,
LPDWORD   
)

◆ GetUserProfileDirectoryA()

BOOL WINAPI GetUserProfileDirectoryA ( HANDLE  ,
LPSTR  ,
LPDWORD   
)

◆ GetUserProfileDirectoryW()

BOOL WINAPI GetUserProfileDirectoryW ( HANDLE  ,
LPWSTR  ,
LPDWORD   
)

◆ GetUserSid()

PSID WINAPI GetUserSid ( HANDLE  )

Definition at line 36 of file sid.c.

37 {
38  PTOKEN_USER UserBuffer;
39  PTOKEN_USER TempBuffer;
41  ULONG Length;
42  PSID pSid;
43 
44  Length = 256;
45  UserBuffer = LocalAlloc(LPTR, Length);
46  if (UserBuffer == NULL)
47  {
48  return NULL;
49  }
50 
52  TokenUser,
53  (PVOID)UserBuffer,
54  Length,
55  &Length);
57  {
58  TempBuffer = LocalReAlloc(UserBuffer, Length, LMEM_MOVEABLE);
59  if (TempBuffer == NULL)
60  {
61  LocalFree(UserBuffer);
62  return NULL;
63  }
64 
65  UserBuffer = TempBuffer;
67  TokenUser,
68  (PVOID)UserBuffer,
69  Length,
70  &Length);
71  }
72 
73  if (!NT_SUCCESS(Status))
74  {
75  LocalFree(UserBuffer);
76  return NULL;
77  }
78 
79  Length = RtlLengthSid(UserBuffer->User.Sid);
80 
82  if (pSid == NULL)
83  {
84  LocalFree(UserBuffer);
85  return NULL;
86  }
87 
88  Status = RtlCopySid(Length, pSid, UserBuffer->User.Sid);
89 
90  LocalFree(UserBuffer);
91 
92  if (!NT_SUCCESS(Status))
93  {
94  LocalFree(pSid);
95  return NULL;
96  }
97 
98  return pSid;
99 }
NTSTATUS NTAPI RtlCopySid(IN ULONG BufferLength, IN PSID Dest, IN PSID Src)
Definition: sid.c:165
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
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
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define LMEM_MOVEABLE
Definition: winbase.h:350
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Status
Definition: gdiplustypes.h:24
HLOCAL NTAPI LocalReAlloc(HLOCAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:1608
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static PSID pSid
Definition: security.c:74
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 CopySystemProfile(), and GetUserAndDomainName().

◆ InitializeProfiles()

BOOL WINAPI InitializeProfiles ( VOID  )

Definition at line 335 of file setup.c.

336 {
337  LONG Error;
338  HKEY hKey;
339  DWORD dwLength;
340  WCHAR szProfilesPath[MAX_PATH];
341  WCHAR szBuffer[MAX_PATH];
342 
343  DPRINT("InitializeProfiles()\n");
344 
345  /* Load profiles directory path */
346  if (!LoadStringW(hInstance,
348  szBuffer,
349  ARRAYSIZE(szBuffer)))
350  {
351  DPRINT1("Error: %lu\n", GetLastError());
352  return FALSE;
353  }
354 
356  L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",
357  0,
359  &hKey);
360  if (Error != ERROR_SUCCESS)
361  {
362  DPRINT1("Error: %lu\n", Error);
364  return FALSE;
365  }
366 
367  /* Expand it */
368  if (!ExpandEnvironmentStringsW(szBuffer,
369  szProfilesPath,
370  ARRAYSIZE(szProfilesPath)))
371  {
372  DPRINT1("Error: %lu\n", GetLastError());
373  RegCloseKey(hKey);
374  return FALSE;
375  }
376 
377  /* Create profiles directory */
378  // FIXME: Security!
379  if (!CreateDirectoryW(szProfilesPath, NULL))
380  {
382  {
383  DPRINT1("Error: %lu\n", GetLastError());
384  RegCloseKey(hKey);
385  return FALSE;
386  }
387  }
388 
389  /* Store the profiles directory path (unexpanded) in the registry */
390  dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
391  Error = RegSetValueExW(hKey,
392  L"ProfilesDirectory",
393  0,
395  (LPBYTE)szBuffer,
396  dwLength);
397  if (Error != ERROR_SUCCESS)
398  {
399  DPRINT1("Error: %lu\n", Error);
400  RegCloseKey(hKey);
402  return FALSE;
403  }
404 
405  /* Create 'Default User' profile directory path */
406  if (!CreateStandardProfile(szProfilesPath, hKey, &StandardProfiles[0]))
407  {
408  DPRINT1("CreateStandardProfile(L\"%S\") failed.\n", StandardProfiles[0].pszProfileName);
409  RegCloseKey(hKey);
410  return FALSE;
411  }
412 
413  /* Create 'All Users' profile directory path */
414  if (!CreateStandardProfile(szProfilesPath, hKey, &StandardProfiles[1]))
415  {
416  DPRINT1("CreateStandardProfile(L\"%S\") failed.\n", StandardProfiles[1].pszProfileName);
417  RegCloseKey(hKey);
418  return FALSE;
419  }
420 
421  RegCloseKey(hKey);
422 
423  DPRINT("Success\n");
424 
425  return TRUE;
426 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
static PROFILEPARAMS StandardProfiles[]
Definition: setup.c:82
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
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
#define IDS_PROFILEPATH
Definition: resources.h:11
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:85
#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:417
static const WCHAR L[]
Definition: oid.c:1250
static BOOL CreateStandardProfile(IN LPCWSTR pszProfilesPath, IN HKEY hProfileListKey, IN PPROFILEPARAMS pProfileParams)
Definition: setup.c:105
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
#define DPRINT1
Definition: precomp.h:8
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by InstallReactOS().

◆ LeaveCriticalPolicySection()

BOOL WINAPI LeaveCriticalPolicySection ( HANDLE  )

◆ LoadUserProfileA()

BOOL WINAPI LoadUserProfileA ( HANDLE  ,
LPPROFILEINFOA   
)

◆ LoadUserProfileW()

BOOL WINAPI LoadUserProfileW ( HANDLE  ,
LPPROFILEINFOW   
)

◆ RefreshPolicy()

BOOL WINAPI RefreshPolicy ( BOOL  )

◆ RegisterGPNotification()

BOOL WINAPI RegisterGPNotification ( HANDLE  ,
BOOL   
)

◆ UnloadUserProfile()

BOOL WINAPI UnloadUserProfile ( HANDLE  ,
HANDLE   
)

◆ UnregisterGPNotification()

BOOL WINAPI UnregisterGPNotification ( HANDLE  )