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.

378 lines
5.9 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. blobs.h
  5. Abstract:
  6. Declares the interface functions to manage BLOBS and arrays of BLOBS.
  7. Author:
  8. Ovidiu Temereanca (ovidiut) 24-Nov-1999
  9. Revision History:
  10. <alias> <date> <comments>
  11. --*/
  12. //
  13. // Types
  14. //
  15. typedef enum {
  16. BDT_NONE = 0,
  17. BDT_SZW,
  18. BDT_SZA,
  19. BDT_MULTISZW,
  20. BDT_MULTISZA,
  21. BDT_DWORD,
  22. BDT_QWORD,
  23. BDT_BINARY,
  24. BDT_LAST
  25. } BLOB_DATA_TYPE;
  26. typedef enum {
  27. BF_RECORDDATATYPE = 0x0001,
  28. BF_RECORDDATASIZE = 0x0002,
  29. BF_UNICODESTRINGS = 0x0004,
  30. } BLOB_FLAGS;
  31. typedef struct {
  32. PBYTE Data;
  33. DWORD End;
  34. DWORD AllocSize;
  35. DWORD GrowSize;
  36. DWORD Index;
  37. DWORD Flags;
  38. DWORD UserIndex;
  39. } OURBLOB, *POURBLOB;
  40. typedef struct {
  41. DWORD Signature;
  42. POURBLOB* Blobs;
  43. DWORD BlobsCount;
  44. DWORD BlobsAllocated;
  45. DWORD BlobsGrowCount;
  46. } BLOBS, *PBLOBS;
  47. typedef struct {
  48. POURBLOB CurrentBlob;
  49. PBLOBS Array;
  50. DWORD Index;
  51. } BLOB_ENUM, *PBLOB_ENUM;
  52. //
  53. // Macros
  54. //
  55. #define OURBLOB_INIT { NULL, 0, 0, 0, 0, 0, 0 }
  56. #define BLOBS_INIT { 0, NULL, 0, 0, 0 }
  57. //
  58. // Blob APIs
  59. //
  60. __inline
  61. BOOL
  62. BlobRecordsDataType (
  63. IN POURBLOB Blob
  64. )
  65. {
  66. return Blob->Flags & BF_RECORDDATATYPE;
  67. }
  68. __inline
  69. BOOL
  70. BlobRecordsDataSize (
  71. IN POURBLOB Blob
  72. )
  73. {
  74. return Blob->Flags & BF_RECORDDATASIZE;
  75. }
  76. __inline
  77. BOOL
  78. BlobRecordsUnicodeStrings (
  79. IN POURBLOB Blob
  80. )
  81. {
  82. return Blob->Flags & BF_UNICODESTRINGS;
  83. }
  84. __inline
  85. BOOL
  86. BlobIsEOF (
  87. IN POURBLOB Blob
  88. )
  89. {
  90. return !Blob->Data || Blob->Index == Blob->End;
  91. }
  92. __inline
  93. PBYTE
  94. BlobGetPointer (
  95. IN POURBLOB Blob
  96. )
  97. {
  98. return Blob->Data ? Blob->Data + Blob->Index : NULL;
  99. }
  100. __inline
  101. PBYTE
  102. BlobGetEOF (
  103. IN POURBLOB Blob
  104. )
  105. {
  106. return Blob->Data ? Blob->Data + Blob->End : NULL;
  107. }
  108. __inline
  109. DWORD
  110. BlobGetIndex (
  111. IN POURBLOB Blob
  112. )
  113. {
  114. return Blob->Index;
  115. }
  116. __inline
  117. DWORD
  118. BlobGetDataSize (
  119. IN POURBLOB Blob
  120. )
  121. {
  122. return Blob->End;
  123. }
  124. POURBLOB
  125. BlobCreate (
  126. VOID
  127. );
  128. POURBLOB
  129. BlobDuplicate (
  130. IN POURBLOB SourceBlob
  131. );
  132. VOID
  133. BlobClear (
  134. IN OUT POURBLOB Blob
  135. );
  136. VOID
  137. BlobDestroy (
  138. IN OUT POURBLOB Blob
  139. );
  140. BOOL
  141. BlobSetIndex (
  142. IN OUT POURBLOB Blob,
  143. IN DWORD Index
  144. );
  145. DWORD
  146. BlobGetRecordedDataType (
  147. IN POURBLOB Blob
  148. );
  149. BOOL
  150. BlobWriteEx (
  151. IN OUT POURBLOB Blob,
  152. IN DWORD DataType, OPTIONAL
  153. IN BOOL RecordDataSize,
  154. IN DWORD DataSize,
  155. IN PCVOID Data
  156. );
  157. PBYTE
  158. BlobReadEx (
  159. IN OUT POURBLOB Blob,
  160. IN DWORD ExpectedDataType, OPTIONAL
  161. IN DWORD ExpectedDataSize, OPTIONAL
  162. IN BOOL RecordedDataSize,
  163. OUT PDWORD ActualDataSize, OPTIONAL
  164. OUT PVOID Data, OPTIONAL
  165. IN PMHANDLE Pool OPTIONAL
  166. );
  167. BOOL
  168. BlobWriteDword (
  169. IN OUT POURBLOB Blob,
  170. IN DWORD Data
  171. );
  172. BOOL
  173. BlobReadDword (
  174. IN OUT POURBLOB Blob,
  175. OUT PDWORD Data
  176. );
  177. BOOL
  178. BlobWriteQword (
  179. IN OUT POURBLOB Blob,
  180. IN DWORDLONG Data
  181. );
  182. BOOL
  183. BlobReadQword (
  184. IN OUT POURBLOB Blob,
  185. OUT PDWORDLONG Data
  186. );
  187. BOOL
  188. BlobWriteStringA (
  189. IN OUT POURBLOB Blob,
  190. IN PCSTR Data
  191. );
  192. BOOL
  193. BlobWriteStringW (
  194. IN OUT POURBLOB Blob,
  195. IN PCWSTR Data
  196. );
  197. BOOL
  198. BlobReadStringA (
  199. IN OUT POURBLOB Blob,
  200. OUT PCSTR* Data,
  201. IN PMHANDLE Pool OPTIONAL
  202. );
  203. BOOL
  204. BlobReadStringW (
  205. IN OUT POURBLOB Blob,
  206. OUT PCWSTR* Data,
  207. IN PMHANDLE Pool OPTIONAL
  208. );
  209. BOOL
  210. BlobWriteMultiSzA (
  211. IN OUT POURBLOB Blob,
  212. IN PCSTR Data
  213. );
  214. BOOL
  215. BlobWriteMultiSzW (
  216. IN OUT POURBLOB Blob,
  217. IN PCWSTR Data
  218. );
  219. BOOL
  220. BlobReadMultiSzA (
  221. IN OUT POURBLOB Blob,
  222. OUT PCSTR* Data,
  223. IN PMHANDLE Pool OPTIONAL
  224. );
  225. BOOL
  226. BlobReadMultiSzW (
  227. IN OUT POURBLOB Blob,
  228. OUT PCWSTR* Data,
  229. IN PMHANDLE Pool OPTIONAL
  230. );
  231. BOOL
  232. BlobWriteBinary (
  233. IN OUT POURBLOB Blob,
  234. IN PBYTE Data,
  235. IN DWORD Size
  236. );
  237. BOOL
  238. BlobReadBinary (
  239. IN OUT POURBLOB Blob,
  240. OUT PBYTE* Data,
  241. OUT PDWORD Size,
  242. IN PMHANDLE Pool
  243. );
  244. BOOL
  245. BlobWriteToFile (
  246. IN POURBLOB Blob,
  247. IN HANDLE File
  248. );
  249. BOOL
  250. BlobReadFromFile (
  251. OUT POURBLOB Blob,
  252. IN HANDLE File
  253. );
  254. //
  255. // Blob Array APIs
  256. //
  257. __inline
  258. DWORD
  259. BlobsGetCount (
  260. IN PBLOBS BlobsArray
  261. )
  262. {
  263. return BlobsArray->BlobsCount;
  264. }
  265. BOOL
  266. BlobsAdd (
  267. IN OUT PBLOBS BlobsArray,
  268. IN POURBLOB Blob
  269. );
  270. VOID
  271. BlobsFree (
  272. IN OUT PBLOBS BlobsArray,
  273. IN BOOL DestroyBlobs
  274. );
  275. BOOL
  276. EnumFirstBlob (
  277. OUT PBLOB_ENUM BlobEnum,
  278. IN PBLOBS BlobsArray
  279. );
  280. BOOL
  281. EnumNextBlob (
  282. IN OUT PBLOB_ENUM BlobEnum
  283. );
  284. BOOL
  285. BlobsWriteToFile (
  286. IN PBLOBS BlobsArray,
  287. IN HANDLE File
  288. );
  289. BOOL
  290. BlobsReadFromFile (
  291. OUT PBLOBS BlobsArray,
  292. IN HANDLE File
  293. );
  294. //
  295. // Macros
  296. //
  297. #ifdef UNICODE
  298. #define BlobWriteString BlobWriteStringW
  299. #define BlobReadString BlobReadStringW
  300. #define BlobWriteMultiSz BlobWriteMultiSzW
  301. #define BlobReadMultiSz BlobReadMultiSzW
  302. #else
  303. #define BlobWriteString BlobWriteStringA
  304. #define BlobReadString BlobReadStringA
  305. #define BlobWriteMultiSz BlobWriteMultiSzA
  306. #define BlobReadMultiSz BlobReadMultiSzA
  307. #endif