Leaked source code of windows server 2003
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.

248 lines
5.9 KiB

  1. #ifndef __DSKQUOTA_PRIVATE_H
  2. #define __DSKQUOTA_PRIVATE_H
  3. ///////////////////////////////////////////////////////////////////////////////
  4. /* File: private.h
  5. Description: Private stuff used in the quota management library.
  6. Revision History:
  7. Date Description Programmer
  8. -------- --------------------------------------------------- ----------
  9. 05/22/96 Initial creation. BrianAu
  10. */
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #define USEQUICKSORT // Tell comctl32 to use QuickSort for sorting DPA's.
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #ifndef NT_INCLUDED
  17. # include <nt.h>
  18. #endif
  19. #ifndef _NTRTL_
  20. # include <ntrtl.h>
  21. #endif
  22. #ifndef _NTURTL_
  23. # include <nturtl.h>
  24. #endif
  25. #ifndef _NTSEAPI_
  26. # include <ntseapi.h>
  27. #endif
  28. #ifdef __cplusplus
  29. } // end of extern "C"
  30. #endif
  31. #ifndef _WINDOWS_
  32. # include <windows.h>
  33. #endif
  34. #ifndef _INC_WINDOWSX
  35. # include <windowsx.h>
  36. #endif
  37. #ifndef _OLE2_H_
  38. # include <ole2.h>
  39. #endif
  40. #ifndef _OLECTL_H_
  41. # include <olectl.h> // Standard OLE interfaces.
  42. #endif
  43. #ifndef _INC_SHELLAPI
  44. # include <shellapi.h>
  45. #endif
  46. #ifndef _SHLGUID_H_
  47. # include <shlguid.h>
  48. #endif
  49. #ifndef _INC_SHLWAPI
  50. # include <shlwapi.h>
  51. #endif
  52. #ifndef _SHLOBJ_H_
  53. # include <shlobj.h>
  54. #endif
  55. #ifndef _STRSAFE_H_INCLUDED_
  56. # include <strsafe.h>
  57. #endif
  58. //
  59. // Disable warnings.
  60. //
  61. #pragma warning( disable : 4100 ) // Unreferenced formal parameter
  62. #pragma warning( disable : 4710 ) // Inline was not expanded
  63. //
  64. // Disable "inline" for DEBUG builds so we can set breakpoints
  65. // on inlined methods.
  66. //
  67. #if DBG
  68. # define INLINE inline
  69. #else
  70. # define INLINE
  71. #endif
  72. //
  73. // Define PROFILE to activate IceCAP profiler.
  74. //
  75. #ifdef PROFILE
  76. # include "icapexp.h"
  77. # define ICAP_START StartCAP()
  78. # define ICAP_START_ALL StartCAPAll()
  79. # define ICAP_STOP StopCAP()
  80. # define ICAP_STOP_ALL StopCAPAll()
  81. # define ICAP_SUSPEND SuspendCAP()
  82. # define ICAP_SUSPEND_ALL SuspendCAPAll()
  83. # define ICAP_RESUME ResumeCAP()
  84. # define ICAP_RESUME_ALL SuspendCAPAll()
  85. #else
  86. # define ICAP_START 0
  87. # define ICAP_START_ALL 0
  88. # define ICAP_STOP 0
  89. # define ICAP_STOP_ALL 0
  90. # define ICAP_SUSPEND 0
  91. # define ICAP_SUSPEND_ALL 0
  92. # define ICAP_RESUME 0
  93. # define ICAP_RESUME_ALL 0
  94. #endif
  95. typedef unsigned __int64 UINT64;
  96. typedef __int64 INT64;
  97. #ifndef _INC_DSKQUOTA_DEBUG_H
  98. # include "debug.h"
  99. #endif
  100. #ifndef _INC_DSKQUOTA_DEBUGP_H
  101. # include "debugp.h"
  102. #endif
  103. #ifndef _INC_DSKQUOTA_EXCEPT_H
  104. # include "except.h"
  105. #endif
  106. #ifndef _INC_DSKQUOTA_THDSYNC_H
  107. # include "thdsync.h"
  108. #endif
  109. #ifndef _INC_DSKQUOTA_AUTOPTR_H
  110. # include "autoptr.h"
  111. #endif
  112. #ifndef _INC_DSKQUOTA_CARRAY_H
  113. # include "carray.h"
  114. #endif
  115. #ifndef _INC_DSKQUOTA_ALLOC_H
  116. # include "alloc.h"
  117. #endif
  118. #ifndef _INC_DSKQUOTA_STRCLASS_H
  119. # include "strclass.h"
  120. #endif
  121. #ifndef _INC_DSKQUOTA_PATHSTR_H
  122. # include "pathstr.h"
  123. #endif
  124. #ifndef _INC_DSKQUOTA_UTILS_H
  125. # include "utils.h"
  126. #endif
  127. #ifndef _INC_DSKQUOTA_DBLNUL_H
  128. # include "dblnul.h"
  129. #endif
  130. #ifndef _INC_DSKQUOTA_XBYTES_H
  131. # include "xbytes.h"
  132. #endif
  133. #ifndef _INC_DSKQUOTA_REGSTR_H
  134. # include "regstr.h"
  135. #endif
  136. extern HINSTANCE g_hInstDll; // Global module instance handle.
  137. extern LONG g_cRefThisDll; // Global module reference count.
  138. //
  139. // Unlimited quota threshold and limit are indicated by a value of -1.
  140. // A limit of -2 marks a record for deletion.
  141. // This is the way NTFS wants it.
  142. //
  143. const LONGLONG NOLIMIT = (LONGLONG)-1;
  144. const LONGLONG MARK4DEL = (LONGLONG)-2;
  145. //
  146. // Convenience macro for calculating number of elements in an array.
  147. //
  148. #ifdef ARRAYSIZE
  149. #undef ARRAYSIZE
  150. #endif
  151. #define ARRAYSIZE(a) (sizeof(a)/sizeof((a)[0]))
  152. //
  153. // Per-volume quota information.
  154. //
  155. typedef struct DiskQuotaFSObjectInformation {
  156. LONGLONG DefaultQuotaThreshold;
  157. LONGLONG DefaultQuotaLimit;
  158. ULONG FileSystemControlFlags;
  159. } DISKQUOTA_FSOBJECT_INFORMATION, *PDISKQUOTA_FSOBJECT_INFORMATION;
  160. //
  161. // SIDLIST is a synonym for FILE_GET_QUOTA_INFORMATION.
  162. //
  163. #define SIDLIST FILE_GET_QUOTA_INFORMATION
  164. #define PSIDLIST PFILE_GET_QUOTA_INFORMATION
  165. //
  166. // Private stuff for twiddling bits in quota state DWORD.
  167. // Public clients don't need these.
  168. // Note that the LOG_VOLUME_XXXX flags are not included.
  169. // This feature is not exposed through the quota APIs.
  170. //
  171. #define DISKQUOTA_LOGFLAG_MASK 0x00000030
  172. #define DISKQUOTA_LOGFLAG_SHIFT 4
  173. #define DISKQUOTA_FLAGS_MASK 0x00000337
  174. #define DISKQUOTA_FILEFLAG_MASK 0x00000300
  175. //
  176. // Maximum length of a SID.
  177. //
  178. const UINT MAX_SID_LEN = (FIELD_OFFSET(SID, SubAuthority) +
  179. sizeof(ULONG) * SID_MAX_SUB_AUTHORITIES);
  180. //
  181. // SID is a variable length structure.
  182. // This defines how large the FILE_QUOTA_INFORMATION structure can be if the SID
  183. // is maxed out.
  184. //
  185. const UINT FILE_QUOTA_INFORMATION_MAX_LEN = sizeof(FILE_QUOTA_INFORMATION) -
  186. sizeof(SID) +
  187. MAX_SID_LEN;
  188. //
  189. // FEATURE: These may actually be shorter than MAX_PATH.
  190. // Need to find out what actual max is.
  191. //
  192. const UINT MAX_USERNAME = MAX_PATH; // i.e. BrianAu
  193. const UINT MAX_DOMAIN = MAX_PATH; // i.e. REDMOND
  194. const UINT MAX_FULL_USERNAME = MAX_PATH; // i.e. Brian Aust
  195. const UINT MAX_VOL_LABEL = 33; // Includes term NUL.
  196. const UINT MAX_GUIDSTR_LEN = 40;
  197. __inline HRESULT ResultFromWin32(DWORD dwErr)
  198. {
  199. return HRESULT_FROM_WIN32(dwErr);
  200. }
  201. __inline HRESULT ResultFromLastError(void)
  202. {
  203. return ResultFromWin32(GetLastError());
  204. }
  205. #endif // __DSKQUOTA_PRIVATE_H