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.

225 lines
6.1 KiB

  1. #pragma once
  2. #ifdef __cplusplus
  3. extern "C" {
  4. #endif
  5. #define STATUS_MANIFEST_MISSING_XML_DECL (0xc0100001)
  6. #define STATUS_MANIFEST_NOT_STANDALONE (0xc0100002)
  7. #define STATUS_MANIFEST_NOT_VERSION_1_0 (0xc0100003)
  8. #define STATUS_MANIFEST_ASSEMBLY_NOT_AT_ROOT (0xc0100004)
  9. #define STATUS_MANIFEST_MULTIPLE_ROOT_IDENTITIES (0xc0100005)
  10. #define STATUS_MANIFEST_MISSING_ROOT_IDENTITY (0xc0100006)
  11. #define STATUS_MANIFEST_FILE_TAG_MISSING_NAME (0xc0100007)
  12. #define STATUS_MANIFEST_COMCLASS_MISSING_CLSID (0xc0100008)
  13. #define STATUS_MANIFEST_PCDATA_NOT_ALLOWED_HERE (0xc0100009)
  14. #define STATUS_MANIFEST_UNEXPECTED_CHILD_ELEMENT (0xc010000a)
  15. #define STATUS_MANIFEST_UNKNOWN_ATTRIBUTES (0xc010000b)
  16. #define STATUS_MANIFEST_WRONG_ROOT_ELEMENT (0xc010000c)
  17. #define RTL_INSTALL_ASM_FLAT_TYPE_MASK (0x0000000F)
  18. #define RTL_INSTALL_ASM_FLAG_TYPE_OS_INSTALLATION (0x00000001)
  19. #define RTL_INSTALL_ASM_FLAG_ACTION_MASK (0000000FF0)
  20. #define RTL_INSTALL_ASM_FLAG_ACTION_REPLACE_EXISTING (0x00000010)
  21. #define RTL_INSTALL_ASM_FLAG_ACTION_MOVE_FROM_SOURCE (0x00000020)
  22. #define RTL_INSTALL_ASM_FLAG_ACTION_TRANSACTIONAL (0000000040)
  23. typedef struct _RTL_ALLOCATOR
  24. {
  25. NTSTATUS (FASTCALL *pfnAlloc)(SIZE_T, PVOID*, PVOID);
  26. NTSTATUS (FASTCALL *pfnFree)(PVOID, PVOID);
  27. PVOID pvContext;
  28. } RTL_ALLOCATOR, *PRTL_ALLOCATOR;
  29. EXTERN_C RTL_ALLOCATOR g_DefaultAllocator;
  30. typedef struct _RTL_INSTALL_ASSEMBLY {
  31. //
  32. // Flags indicating the type of installation we're performing
  33. //
  34. //
  35. // Path to the manifest that we're installing
  36. //
  37. UNICODE_STRING ucsManifestPath;
  38. //
  39. // Path to the codebase that we're installing from, for recovery purposes
  40. //
  41. UNICODE_STRING ucsCodebaseName;
  42. } RTL_INSTALL_ASSEMBLY, *PRTL_INSTALL_ASSEMBLY;
  43. NTSTATUS
  44. RtlInstallAssembly(
  45. ULONG ulFlags,
  46. PCWSTR pcwszManifestPath
  47. );
  48. NTSTATUS
  49. RtlOpenAndMapEntireFile(
  50. PCWSTR pcwszFilePath,
  51. PVOID *ppvMappedView,
  52. PSIZE_T pcbFileSize
  53. );
  54. NTSTATUS
  55. RtlUnmapViewOfFile(
  56. PVOID pvBase
  57. );
  58. #define RTLIMS_GATHER_FILES (0x00000001)
  59. #define RTLIMS_GATHER_COMCLASSES (0x00000002)
  60. #define RTLIMS_GATHER_WINDOWCLASSES (0x00000004)
  61. #define RTLIMS_GATHER_TYPELIBRARIES (0x00000008)
  62. #define RTLIMS_GATHER_INTERFACEPROXIES (0x00000010)
  63. #define RTLIMS_GATHER_EXTERNALPROXIES (0x00000020)
  64. #define RTLIMS_GATHER_DEPENDENCIES (0x00000040)
  65. #define RTLIMS_GATHER_COMCLASS_PROGIDS (0x00000080)
  66. #define RTLIMS_GATHER_SIGNATURES (0x00000100)
  67. #define CONTENT_FILTER_MASK (RTLIMS_GATHER_SIGNATURES | RTLIMS_GATHER_COMCLASS_PROGIDS | RTLIMS_GATHER_FILES | RTLIMS_GATHER_COMCLASSES | RTLIMS_GATHER_WINDOWCLASSES | RTLIMS_GATHER_TYPELIBRARIES | RTLIMS_GATHER_INTERFACEPROXIES | RTLIMS_GATHER_EXTERNALPROXIES | RTLIMS_GATHER_DEPENDENCIES)
  68. #ifndef INVALID_HANDLE_VALUE
  69. #define INVALID_HANDLE_VALUE ((HANDLE)-1)
  70. #endif
  71. #ifndef MAX_ULONG
  72. #define MAX_ULONG ((ULONG)-1)
  73. #endif
  74. typedef struct _tagRTL_MINI_HEAP {
  75. PVOID pvNextAvailableByte;
  76. PVOID pvAllocationBase;
  77. SIZE_T cbOriginalSize;
  78. SIZE_T cbAvailableBytes;
  79. } RTL_MINI_HEAP, *PRTL_MINI_HEAP;
  80. #define DEFAULT_MINI_HEAP_SIZE (2048)
  81. NTSTATUS FASTCALL
  82. RtlMiniHeapAlloc(
  83. SIZE_T cb,
  84. PVOID *ppvAllocated,
  85. PVOID pvContext
  86. );
  87. NTSTATUS FASTCALL
  88. RtlMiniHeapFree(
  89. PVOID pvAllocation,
  90. PVOID pvContext
  91. );
  92. NTSTATUS FASTCALL
  93. RtlInitializeMiniHeap(
  94. PRTL_MINI_HEAP MiniHeap,
  95. PVOID pvTargetRegion,
  96. SIZE_T cbRegionSize
  97. );
  98. NTSTATUS FASTCALL
  99. RtlInitializeMiniHeapInPlace(
  100. PVOID pvRegion,
  101. SIZE_T cbOriginalSize,
  102. PRTL_MINI_HEAP *ppMiniHeap
  103. );
  104. typedef struct _MINI_BUFFER {
  105. PVOID pvNext;
  106. SIZE_T cbRemains;
  107. } MINI_BUFFER, *PMINI_BUFFER;
  108. #ifndef ROUND_UP_COUNT
  109. #define ROUND_UP_COUNT(Count,Pow2) \
  110. ( ((Count)+(Pow2)-1) & (~(((LONG)(Pow2))-1)) )
  111. #endif
  112. #ifndef POINTER_IS_ALIGNED
  113. #define POINTER_IS_ALIGNED(Ptr,Pow2) \
  114. ( ( ( ((ULONG_PTR)(Ptr)) & (((Pow2)-1)) ) == 0) ? TRUE : FALSE )
  115. #endif
  116. #define RtlMiniBufferInit(mb, pv, cb) do { \
  117. (mb)->pvNext = (pv); \
  118. (mb)->cbRemains = (cb); \
  119. } while (0)
  120. #define RtlMiniBufferSpaceLeft(mb) ((mb)->cbRemains)
  121. #define RtlMiniBufferAllocate(mb, type, pvtgt) RtlMiniBufferAllocateBytes((mb), sizeof(type), (PVOID*)(pvtgt))
  122. #define ALIGNMENT_VALUE (sizeof(PVOID)*2)
  123. NTSTATUS FORCEINLINE
  124. RtlMiniBufferAllocateBytes(PMINI_BUFFER Buffer, SIZE_T Bytes, PVOID* pvTarget)
  125. {
  126. const SIZE_T AllocatedSize = ROUND_UP_COUNT(Bytes, ALIGNMENT_VALUE);
  127. ASSERT(POINTER_IS_ALIGNED(Buffer->pvNext, ALIGNMENT_VALUE));
  128. if (Buffer->cbRemains >= AllocatedSize) {
  129. *pvTarget = Buffer->pvNext;
  130. Buffer->pvNext = (PVOID)(((ULONG_PTR)Buffer->pvNext) + AllocatedSize);
  131. Buffer->cbRemains -= AllocatedSize;
  132. return STATUS_SUCCESS;
  133. }
  134. else {
  135. *pvTarget = NULL;
  136. return STATUS_BUFFER_TOO_SMALL;
  137. }
  138. }
  139. #define RtlMiniBufferAllocateCount(mb, type, count, pvtgt) \
  140. (RtlMiniBufferAllocateBytes(mb, (sizeof(type) * (count)), (PVOID*)pvtgt))
  141. typedef enum {
  142. HashType_Sha1,
  143. HashType_Sha256,
  144. HashType_Sha384,
  145. HashType_Sha512,
  146. HashType_MD5,
  147. HashType_MD4,
  148. HashType_MD2,
  149. } HashType;
  150. typedef enum {
  151. DigestType_Imports = 0x1,
  152. DigestType_Resources = 0x2,
  153. DigestType_Code = 0x3,
  154. DigestType_FullFile = 0x4,
  155. DigestType_Default = (DigestType_Imports | DigestType_Resources | DigestType_Code),
  156. } DigestType;
  157. NTSTATUS
  158. RtlpConvertHexStringToBytes(
  159. PUNICODE_STRING pSourceString,
  160. PUCHAR pbTarget,
  161. SIZE_T cbTarget
  162. );
  163. NTSTATUS
  164. RtlBase64Encode(
  165. PVOID pvBuffer,
  166. SIZE_T cbBuffer,
  167. PWSTR pwszEncoded,
  168. PSIZE_T pcchEncoded
  169. );
  170. #ifndef offsetof
  171. #define offsetof(s, m) ((SIZE_T)(&((s *)NULL)->m))
  172. #endif
  173. #ifdef __cplusplus
  174. };
  175. #endif