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.

279 lines
13 KiB

  1. /* Copyright (c) Microsoft Corporation. All rights reserved. */
  2. #ifndef __IMAGE_H__
  3. #define __IMAGE_H__
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif //__cplusplus
  7. /*
  8. * Constant declarations section.
  9. */
  10. #define IMAGE_TYPE_REDBOOK_AUDIO_BLOCKSIZE 2352 // or 0x930
  11. #define IMAGE_TYPE_DATA_MODE1_BLOCKSIZE 2048 // or 0x800
  12. /*
  13. * Type definitions section.
  14. */
  15. // Following are the definitions used to describe the content of the
  16. // image file for various content types.
  17. typedef enum _IMAGE_RECORDER_MODE_ENUM {
  18. eImageRecorderModeInvalid = 0,
  19. eImageRecorderModeTrackAtOnce,
  20. eImageRecorderModeSessionAtOnce,
  21. eImageRecorderModeDiscAtOnce,
  22. eImageRecorderModeMAX
  23. } IMAGE_RECORDER_MODE_ENUM, *PIMAGE_RECORDER_MODE_ENUM;
  24. typedef enum _IMAGE_DISC_FORMAT_ENUM {
  25. eImageDiscFormatInvalid = 0,
  26. eImageDiscFormatDataMode1,
  27. eImageDiscFormatAudioRedbook,
  28. eImageDiscFormatMAX
  29. } IMAGE_DISC_FORMAT_ENUM, *PIMAGE_DISC_FORMAT_ENUM;
  30. typedef enum _IMAGE_SECTION_DESCRIPTOR_TYPE_ENUM {
  31. eImageSectionDescInvalid = 0,
  32. eImageSectionDescConstantBlockStash,
  33. eImageSectionDescMAX
  34. } IMAGE_SECTION_DESCRIPTOR_TYPE_ENUM, *PIMAGE_SECTION_DESCRIPTOR_TYPE_ENUM;
  35. typedef enum _IMAGE_SECTION_DATA_TYPE_ENUM {
  36. eImageSectionDataInvalid = 0,
  37. eImageSectionDataDataMode1,
  38. eImageSectionDataAudioRedbook,
  39. eImageSectionDataMAX
  40. } IMAGE_SECTION_DATA_TYPE_ENUM, *PIMAGE_SECTION_DATA_TYPE_ENUM;
  41. typedef enum _IMAGE_SOURCE_TYPE_ENUM {
  42. eImageSourceTypeInvalid = 0,
  43. eImageSourceTypeStashFile,
  44. eImageSourceTypeMAX
  45. } IMAGE_SOURCE_TYPE_ENUM, *PIMAGE_SOURCE_TYPE_ENUM;
  46. // The structure of the image file ready to be burned as a Redboook
  47. // audio disc is simply a series of tracks, already in the 2352-byte
  48. // block-size format:
  49. //
  50. //
  51. // |------------------------------------------------------------
  52. // | Track 1 (N1 blocks of 2352 bytes)
  53. // |------------------------------------------------------------
  54. // | Track 2 (N2 blocks of 2352 bytes)
  55. // |------------------------------------------------------------
  56. // | ...
  57. // |------------------------------------------------------------
  58. // | Track T (NT blocks of 2352 bytes)
  59. // |------------------------------------------------------------
  60. //
  61. // The structure of the image file ready to be burned as a Mode 1 Data disc:
  62. // This diagram is of a Joliet (a derivative of ISO 9660) data disc for example.
  63. // The on-disk structure is simply the complete set of 2048 blocks that are to
  64. // comprise the single data-track. Coincidentally, this is the strcture of
  65. // an ISO9660 image file, so tools like CDWorkshop may be used to view the
  66. // image in the on-disk stash file.
  67. //
  68. // |------------------------------------------------------------
  69. // | Block 0 (zeroes) (2048 bytes)
  70. // |------------------------------------------------------------
  71. // | Block 1 (zeroes) (2048 bytes)
  72. // |------------------------------------------------------------
  73. // | ...
  74. // |------------------------------------------------------------
  75. // | Block 15 (zeroes) (2048 bytes)
  76. // |------------------------------------------------------------
  77. // | Block 16 (ISO 9660 PVD) (2048 bytes)
  78. // |------------------------------------------------------------
  79. // | Block 17 (SVD) (2048 bytes)
  80. // |------------------------------------------------------------
  81. // | Block 18 (file system or data) (2048 bytes)
  82. // |------------------------------------------------------------
  83. // | Block 19 (file system or data) (2048 bytes)
  84. // |------------------------------------------------------------
  85. // | ...
  86. // |------------------------------------------------------------
  87. // | Block T (file system or data) (2048 bytes)
  88. // |------------------------------------------------------------
  89. //
  90. // The in-memory structure (the Content List) used to describe the
  91. // stash-file is as follows (structure definitions follow):
  92. //
  93. // |------------------------------------------------------------
  94. // | IMAGE_CONTENT_LIST
  95. // |------------------------------------------------------------
  96. // | IMAGE_DESCRIPTOR_HEADER
  97. // |------------------------------------------------------------
  98. // | IMAGE_SOURCE_DESCRIPTOR (including ndwSectionCount = N)
  99. // |------------------------------------------------------------
  100. // | IMAGE_SECTION_DESCRIPTOR 1
  101. // |------------------------------------------------------------
  102. // | IMAGE_SECTION_DESCRIPTOR 2
  103. // |------------------------------------------------------------
  104. // | ...
  105. // |------------------------------------------------------------
  106. // | IMAGE_SECTION_DESCRIPTOR N
  107. // |------------------------------------------------------------
  108. // The new in-memory structure (the Content List) used to describe the
  109. // stash file is as follows:
  110. //
  111. // |------------------------------------------------------------
  112. // | IMAGE_CONTENT_LIST
  113. // | -------------------------
  114. // | IMAGE_SOURCE_DESCRIPTOR
  115. // | Defines the source file
  116. // | -------------------------
  117. // | IMAGE_DESCRIPTOR_HEADER
  118. // | Defines Track-at-once, SAO, DAO recording,
  119. // | As well as data mode for TAO
  120. // | Has byte offsets to all section descriptors
  121. // |
  122. // | Minimum size == sizeof(IMAGE_CONTENT_LIST) +
  123. // | ndwSectionCount*sizeof(PULONG_PTR) +
  124. // | ndwSectionCount*sizeof(IMAGE_SECTION_DESCRIPTOR)
  125. // |------------------------------------------------------------
  126. // | IMAGE_SECTION_DESCRIPTOR 1
  127. // |------------------------------------------------------------
  128. // | IMAGE_SECTION_DESCRIPTOR 2
  129. // |------------------------------------------------------------
  130. // | ...
  131. // |------------------------------------------------------------
  132. // | IMAGE_SECTION_DESCRIPTOR N
  133. // |------------------------------------------------------------
  134. // One could imagine a more flexible structure would allow a different
  135. // stash file for each section. This would make it easy for the user-mode
  136. // application to reuse sections, or pass in raw WAV files for processing
  137. // directly (i.e. skipping the header and reading the original WAV file).
  138. // It is also reasonable to presume that this could then be used to accept
  139. // *any* sort of input, such as being a Kernel Streaming destination, where
  140. // KS would just provide real-time audio, and the drive would burn it in
  141. // real-time. Some consideration should be made, then, to allow for using
  142. // the same stash file as the previous section without closing/opening a
  143. // handle each time.
  144. //
  145. // This more efficient structure would be:
  146. //
  147. // |------------------------------------------------------------
  148. // | IMAGE_CONTENT_LIST
  149. // | -------------------------
  150. // | IMAGE_DESCRIPTOR_HEADER
  151. // | Defines Track-at-once, SAO, DAO recording,
  152. // | As well as data mode for TAO
  153. // | Has byte offsets to all section descriptors
  154. // |
  155. // | Minimum size == sizeof(IMAGE_CONTENT_LIST) +
  156. // | ndwSectionCount*sizeof(PULONG_PTR) +
  157. // | ndwSectionCount*sizeof(IMAGE_SECTION_DESCRIPTOR)
  158. // |------------------------------------------------------------
  159. // | IMAGE_SECTION_DESCRIPTOR 1
  160. // | -------------------------
  161. // | IMAGE_SOURCE_DESCRIPTOR
  162. // | Defines the source file(s) for the section
  163. // |------------------------------------------------------------
  164. // | IMAGE_SECTION_DESCRIPTOR 2
  165. // | -------------------------
  166. // | IMAGE_SOURCE_DESCRIPTOR
  167. // | Defines the source file(s) for the section
  168. // |------------------------------------------------------------
  169. // | ...
  170. // |------------------------------------------------------------
  171. // | IMAGE_SECTION_DESCRIPTOR N
  172. // | -------------------------
  173. // | IMAGE_SOURCE_DESCRIPTOR
  174. // | Defines the source file(s) for the section
  175. // |------------------------------------------------------------
  176. typedef struct _IMAGE_SECTION_CONSTANT_BLOCK_TRACK {
  177. DWORD dwBlockSize; // Block size in source.
  178. DWORD ndwBlockCount; // Number of blocks in the track.
  179. DWORD idwTrackNumber; // 1-based Track Number.
  180. DWORD dwaReserved[ 5 ]; // Must be zero.
  181. // liOffsetStart and liOffsetEnd point to the starting and
  182. // ending bytes within the image of the track. Subtracting
  183. // liOffsetStart from liOffsetEnd must equal (dwBlockSize * ndwBlockCount).
  184. LARGE_INTEGER liOffsetStart;
  185. LARGE_INTEGER liOffsetEnd;
  186. } IMAGE_SECTION_CONSTANT_BLOCK_TRACK, *PIMAGE_SECTION_CONSTANT_BLOCK_TRACK;
  187. typedef struct _IMAGE_SECTION_DESCRIPTOR {
  188. DWORD dwDescriptorSize;
  189. IMAGE_SECTION_DESCRIPTOR_TYPE_ENUM SectionDescType;
  190. IMAGE_SECTION_DATA_TYPE_ENUM SectionDataType;
  191. union {
  192. IMAGE_SECTION_CONSTANT_BLOCK_TRACK dataConstantBlockTrack;
  193. } dcbt;
  194. } IMAGE_SECTION_DESCRIPTOR, *PIMAGE_SECTION_DESCRIPTOR;
  195. typedef struct _IMAGE_SOURCE_TYPE_STASH {
  196. HANDLE hStashFileHandle; // BUGBUG - review how this is taken into kernel mode safely?
  197. void *pIDiscStash; // BUGBUG - review how this is taken into kernel mode safely?
  198. } IMAGE_SOURCE_TYPE_STASH, *PIMAGE_SOURCE_TYPE_STASH;
  199. typedef struct _IMAGE_SOURCE_DESCRIPTOR {
  200. DWORD dwHeaderSize; // sizeof(IMAGE_SOURCE_DESCRIPTOR)
  201. IMAGE_SOURCE_TYPE_ENUM SourceType;
  202. union {
  203. IMAGE_SOURCE_TYPE_STASH SourceStash;
  204. } ss;
  205. } IMAGE_SOURCE_DESCRIPTOR, *PIMAGE_SOURCE_DESCRIPTOR;
  206. //BUGBUG - should add an array of byte offsets to find
  207. // all sections, for easy access and verification
  208. // this would also allow declaration of all these
  209. // structures as DECLSPEC_ALIGN() to ensure optimum
  210. // alignment while allowing ioctl to verify it is
  211. // safe to access any of the structures.
  212. typedef struct _IMAGE_DESCRIPTOR_HEADER {
  213. DWORD dwHeaderSize; // sizeof( IMAGE_DESCRIPTOR_HEADER )
  214. IMAGE_DISC_FORMAT_ENUM DiscFormat;
  215. IMAGE_RECORDER_MODE_ENUM RecorderMode;
  216. DWORD ndwSectionCount; // Section count
  217. } IMAGE_DESCRIPTOR_HEADER, *PIMAGE_DESCRIPTOR_HEADER;
  218. //
  219. // TODO: Remove final references to this structure
  220. //
  221. typedef struct _IMAGE_CONTENT_LIST {
  222. DWORD dwHeaderSize; // sizeof( IMAGE_CONTENT_LIST )
  223. DWORD dwVersion; // Must be IMAGE_VERSION.
  224. DWORD dwSignature; // IMAGE_SIGNATURE
  225. DWORD dwContentListSize; // Sum of all size of all sections.
  226. } IMAGE_CONTENT_LIST, *PIMAGE_CONTENT_LIST;
  227. typedef struct _NEW_IMAGE_CONTENT_LIST {
  228. DWORD dwHeaderSize; // sizeof( NEW_IMAGE_CONTENT_LIST )
  229. DWORD dwContentListSize; // Sum of all size of all sections.
  230. IMAGE_SOURCE_DESCRIPTOR ImageSource; // describes this source file (stash file only for now)
  231. IMAGE_DESCRIPTOR_HEADER ImageHeader; // describes the disc format, recorder mode, and number of sections
  232. IMAGE_SECTION_DESCRIPTOR ImageSection[1]; // each image section has one of these
  233. } NEW_IMAGE_CONTENT_LIST, *PNEW_IMAGE_CONTENT_LIST;
  234. #ifdef __cplusplus
  235. }
  236. #endif //__cplusplus
  237. #endif //__IMAGE_H__