Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

203 lines
4.3 KiB

  1. //
  2. // Debug message types
  3. //
  4. #define DM_WARNING 0
  5. #define DM_ASSERT 1
  6. #define DM_VERBOSE 2
  7. //
  8. // Debug macros
  9. //
  10. #ifdef DBG
  11. #define DEBUGMSG(x) _DebugMsg x
  12. VOID _DebugMsg(UINT mask, PCSTR pszMsg, ...);
  13. #define DMASSERT(x) if (!(x)) \
  14. _DebugMsg(DM_ASSERT,"profmap.dll assertion " #x " failed\n, line %u of %s", __LINE__, TEXT(__FILE__));
  15. #else
  16. #define DEBUGMSG(x)
  17. #define DMASSERT(x)
  18. #endif
  19. //
  20. // userenv.c
  21. //
  22. BOOL OurConvertSidToStringSid (PSID Sid, PWSTR *SidString);
  23. VOID DeleteSidString (PWSTR SidString);
  24. BOOL RegDelnode (HKEY KeyRoot, PWSTR SubKey);
  25. PACL
  26. CreateDefaultAcl (
  27. PSID pSid
  28. );
  29. VOID
  30. FreeDefaultAcl (
  31. PACL Acl OPTIONAL
  32. );
  33. BOOL
  34. GetProfileRoot (
  35. IN PSID Sid,
  36. OUT PWSTR ProfileDir
  37. );
  38. #define USER_PROFILE_MUTEX TEXT("Global\\userenv: User Profile Mutex for ")
  39. #define PROFILE_LIST_PATH TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList")
  40. #define PROFILE_IMAGE_VALUE_NAME TEXT("ProfileImagePath")
  41. #define PROFILE_GUID TEXT("Guid")
  42. #define PROFILE_GUID_PATH TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileGuid")
  43. #define WINDOWS_POLICIES_KEY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies")
  44. #define ROOT_POLICIES_KEY TEXT("Software\\Policies")
  45. BOOL
  46. UpdateProfileSecurity (
  47. PSID Sid
  48. );
  49. BOOL DeleteProfileRegistrySettings (LPTSTR lpSidString);
  50. PSID GetUserSid (HANDLE UserToken);
  51. VOID DeleteUserSid(PSID Sid);
  52. #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
  53. LONG MyRegLoadKey(HKEY hKey, LPTSTR lpSubKey, LPTSTR lpFile);
  54. BOOL MyRegUnLoadKey(HKEY hKey, LPTSTR lpSubKey);
  55. BOOL SetupNewHive(LPTSTR lpSidString, PSID pSid);
  56. DWORD ApplySecurityToRegistryTree(HKEY RootKey, PSECURITY_DESCRIPTOR pSD);
  57. BOOL SecureUserKey(LPTSTR lpKey, PSID pSid);
  58. LPWSTR ProduceWFromA(LPCSTR pszA);
  59. BOOL IsUserAnAdminMember(HANDLE hToken);
  60. //
  61. // Stuff lifted from win9x upgrade code
  62. //
  63. #define MemAlloc(s) LocalAlloc(LPTR,s)
  64. #define MemReAlloc(x,s) LocalReAlloc(x,s,LMEM_MOVEABLE)
  65. #define MemFree(x) LocalFree(x)
  66. typedef struct {
  67. PBYTE Buf;
  68. DWORD Size;
  69. DWORD End;
  70. DWORD GrowSize;
  71. DWORD UserIndex; // Unused by Growbuf. For caller use.
  72. } GROWBUFFER, *PGROWBUFFER;
  73. #define GROWBUF_INIT {NULL,0,0,0,0}
  74. PBYTE
  75. GrowBuffer (
  76. IN OUT PGROWBUFFER GrowBuf,
  77. IN DWORD SpaceNeeded
  78. );
  79. VOID
  80. FreeGrowBuffer (
  81. IN PGROWBUFFER GrowBuf
  82. );
  83. typedef struct {
  84. GROWBUFFER ListArray;
  85. POOLHANDLE ListData;
  86. } GROWLIST, *PGROWLIST;
  87. #define GROWLIST_INIT {GROWBUF_INIT, NULL}
  88. VOID
  89. FreeGrowList (
  90. IN PGROWLIST GrowList
  91. );
  92. PBYTE
  93. GrowListAppend (
  94. IN OUT PGROWLIST GrowList,
  95. IN PBYTE DataToAppend, OPTIONAL
  96. IN UINT SizeOfData
  97. );
  98. PBYTE
  99. RealGrowListAppendAddNul (
  100. IN OUT PGROWLIST GrowList,
  101. IN PBYTE DataToAppend, OPTIONAL
  102. IN UINT SizeOfData
  103. );
  104. #define GrowListAppendAddNul(list,data,size) RealGrowListAppendAddNul (list,data,size)
  105. PBYTE
  106. GrowListGetItem (
  107. IN PGROWLIST GrowList,
  108. IN UINT Index
  109. );
  110. UINT
  111. GrowListGetSize (
  112. IN PGROWLIST GrowList
  113. );
  114. PWSTR
  115. GetEndOfStringW (
  116. PCWSTR p
  117. );
  118. PWSTR
  119. StringCopyABW (
  120. OUT PWSTR Buf,
  121. IN PCWSTR a,
  122. IN PCWSTR b
  123. );
  124. UINT
  125. SizeOfStringW (
  126. PCWSTR str
  127. );
  128. __inline
  129. PCWSTR
  130. RealGrowListAppendStringABW (
  131. IN OUT PGROWLIST GrowList,
  132. IN PCWSTR String,
  133. IN PCWSTR End
  134. )
  135. {
  136. return (PCWSTR) GrowListAppendAddNul (
  137. GrowList,
  138. (PBYTE) String,
  139. String < End ? (UINT)((PBYTE) End - (PBYTE) String) : 0
  140. );
  141. }
  142. #define GrowListAppendStringABW(list,a,b) RealGrowListAppendStringABW(list,a,b)
  143. #define GrowListAppendStringW(list,str) GrowListAppendStringABW(list,str,GetEndOfStringW(str))
  144. #define GrowListAppendStringNW(list,str,len) GrowListAppendStringABW(list,str,CharCountToPointerW(str,len))
  145. #define GrowListGetStringW(list,index) (PCWSTR)(GrowListGetItem(list,index))
  146. #define GrowListAppendEmptyItem(list) GrowListAppend (list,NULL,0)
  147. #ifdef UNICODE
  148. #define GrowListAppendString GrowListAppendStringW
  149. #define GrowListAppendStringAB GrowListAppendStringABW
  150. #define GrowListAppendStringN GrowListAppendStringNW
  151. #define GrowListGetString GrowListGetStringW
  152. #endif
  153.