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.

259 lines
4.8 KiB

  1. /*
  2. */
  3. //#include "sptlib.h"
  4. #include <windows.h> // sdk
  5. #include <devioctl.h> // sdk
  6. #include <ntddscsi.h> // sdk
  7. #include <ntddcdrm.h>
  8. #include <ntddmmc.h>
  9. #include <ntddcdvd.h>
  10. #include "cue.h"
  11. typedef struct _OPTIONS {
  12. ULONG TestBurn : 1;
  13. ULONG Erase : 1;
  14. ULONG SessionAtOnce : 1;
  15. ULONG PrintWrites : 1;
  16. ULONG NoPostgap : 1;
  17. ULONG Reserved : 3;
  18. ULONG BurnSpeed : 8; // don't limit to 4x
  19. ULONG Reserved1 : 16;
  20. PUCHAR DeviceName ;
  21. PUCHAR ImageName ;
  22. } OPTIONS, *POPTIONS;
  23. #define OPTIONS_FLAG_BURN_SPEED_INVALID 0x00
  24. #define OPTIONS_FLAG_BURN_SPEED_DEFAULT 0x04
  25. #define OPTIONS_FLAG_BURN_SPEED_MAX 0xff
  26. typedef struct _CDVD_BUFFER_CAPACITY {
  27. UCHAR DataLength[2];
  28. UCHAR Reserved[2];
  29. UCHAR TotalLength[4];
  30. UCHAR BlankLength[4];
  31. } CDVD_BUFFER_CAPACITY, *PCDVD_BUFFER_CAPACITY;
  32. typedef struct _CDVD_WRITE_PARAMETERS_PAGE {
  33. UCHAR PageCode : 6; // 0x05
  34. UCHAR Reserved : 1;
  35. UCHAR PSBit : 1;
  36. UCHAR PageLength; // 0x32
  37. UCHAR WriteType : 4;
  38. UCHAR TestWrite : 1;
  39. UCHAR LinkSizeValid : 1;
  40. UCHAR BufferUnderrunFreeEnabled : 1;
  41. UCHAR Reserved2 : 1;
  42. UCHAR TrackMode : 4;
  43. UCHAR Copy : 1;
  44. UCHAR FixedPacket : 1;
  45. UCHAR MultiSession :2;
  46. UCHAR DataBlockType : 4;
  47. UCHAR Reserved3 : 4;
  48. UCHAR LinkSize;
  49. UCHAR Reserved4;
  50. UCHAR HostApplicationCode : 7;
  51. UCHAR Reserved5 : 1;
  52. UCHAR SessionFormat;
  53. UCHAR Reserved6;
  54. UCHAR PacketSize[4];
  55. UCHAR AudioPauseLength[2];
  56. UCHAR Reserved7 : 7;
  57. UCHAR MediaCatalogNumberValid : 1;
  58. UCHAR MediaCatalogNumber[13];
  59. UCHAR MediaCatalogNumberZero;
  60. UCHAR MediaCatalogNumberAFrame;
  61. UCHAR Reserved8 : 7;
  62. UCHAR ISRCValid : 1;
  63. UCHAR ISRCCountry[2];
  64. UCHAR ISRCOwner[3];
  65. UCHAR ISRCRecordingYear[2];
  66. UCHAR ISRCSerialNumber[5];
  67. UCHAR ISRCZero;
  68. UCHAR ISRCAFrame;
  69. UCHAR ISRCReserved;
  70. UCHAR SubHeaderData[4];
  71. UCHAR Data[0];
  72. } CDVD_WRITE_PARAMETERS_PAGE, *PCDVD_WRITE_PARAMETERS_PAGE;
  73. typedef struct MSF {
  74. UCHAR Min;
  75. UCHAR Sec;
  76. UCHAR Frame;
  77. } MSF, *PMSF;
  78. __inline
  79. MSF
  80. LbaToMsf(
  81. IN ULONG Lba
  82. )
  83. {
  84. ULONG m, s, f;
  85. MSF msf;
  86. m = (Lba / (75 * 60));
  87. Lba %= (75 * 60);
  88. s = (Lba / 75);
  89. f = (Lba % 75);
  90. msf.Min = (UCHAR) m;
  91. msf.Sec = (UCHAR) s;
  92. msf.Frame = (UCHAR) f;
  93. return msf;
  94. }
  95. __inline
  96. MSF
  97. AddMsf(
  98. MSF Msf1,
  99. MSF Msf2
  100. )
  101. {
  102. ULONG m = 0, s = 0, f = 0;
  103. MSF total;
  104. f = Msf1.Frame + Msf2.Frame;
  105. if(f >= 75) {
  106. f -= 75;
  107. s += 1;
  108. }
  109. s = Msf1.Sec + Msf2.Sec;
  110. if(s >= 60) {
  111. s -= 60;
  112. m += 1;
  113. }
  114. m = Msf1.Min + Msf2.Min;
  115. total.Min = (UCHAR) m;
  116. total.Sec = (UCHAR) s;
  117. total.Frame = (UCHAR) f;
  118. return total;
  119. }
  120. DWORD
  121. BurnCommand(
  122. IN HANDLE CdromHandle,
  123. IN HANDLE IsoImageHandle
  124. );
  125. BOOLEAN
  126. BurnThisSession(
  127. IN HANDLE CdromHandle,
  128. IN HANDLE IsoImageHandle,
  129. IN ULONG NumberOfBlocks,
  130. IN ULONG FirstLba,
  131. IN ULONG AdditionalZeroSectors
  132. );
  133. BOOLEAN
  134. CloseSession(
  135. IN HANDLE CdromHandle
  136. );
  137. BOOLEAN
  138. CloseTrack(
  139. IN HANDLE CdromHandle,
  140. IN LONG Track
  141. );
  142. BOOLEAN
  143. GetNextWritableAddress(
  144. IN HANDLE CdromHandle,
  145. IN UCHAR Track,
  146. OUT PLONG NextWritableAddress,
  147. OUT PLONG AvailableBlocks
  148. );
  149. VOID
  150. PrintBuffer(
  151. IN PVOID Buffer,
  152. IN DWORD Size
  153. );
  154. BOOLEAN
  155. SendOptimumPowerCalibration(
  156. IN HANDLE CdromHandle
  157. );
  158. BOOLEAN
  159. SendStartStopUnit(
  160. IN HANDLE CdromHandle,
  161. IN BOOLEAN Start,
  162. IN BOOLEAN Eject
  163. );
  164. BOOLEAN
  165. SetRecordingSpeed(
  166. IN HANDLE CdromHandle,
  167. IN DWORD Speed
  168. );
  169. BOOLEAN
  170. SetWriteModePage(
  171. IN HANDLE CdromHandle,
  172. IN BOOLEAN TestBurn,
  173. IN UCHAR WriteType,
  174. IN UCHAR MultiSession,
  175. IN UCHAR DataBlockType,
  176. IN UCHAR SessionFormat
  177. );
  178. BOOLEAN
  179. VerifyBlankMedia(
  180. IN HANDLE CdromHandle
  181. );
  182. BOOLEAN
  183. VerifyIsoImage(
  184. IN HANDLE IsoImageHandle,
  185. OUT PLONG NumberOfBlocks
  186. );
  187. BOOLEAN
  188. EraseTargetMedia(
  189. IN HANDLE CdromHandle
  190. );
  191. BOOLEAN
  192. BurnTrack(
  193. HANDLE CdromHandle,
  194. HANDLE IsoImageHandle,
  195. LONG NumberOfBlocks
  196. );
  197. BOOLEAN
  198. BurnDisk(
  199. HANDLE CdromHandle,
  200. HANDLE IsoImageHandle,
  201. LONG NumberOfBlocks
  202. );
  203. BOOLEAN
  204. SendCueSheet(
  205. IN HANDLE CdromHandle,
  206. IN ULONG NumberOfBlocks
  207. );
  208. BOOLEAN
  209. BurnLeadIn(
  210. IN HANDLE CdromHandle
  211. );
  212. BOOLEAN
  213. SendWriteCommand(
  214. IN HANDLE CdromHandle,
  215. IN LONG Block,
  216. IN PVOID Buffer,
  217. IN ULONG Length,
  218. OUT PVOID SenseData
  219. );