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.

1483 lines
42 KiB

  1. /*--
  2. Copyright (C) Microsoft Corporation, 1999
  3. --*/
  4. // @@BEGIN_DDKSPLIT
  5. /*--
  6. Module Name:
  7. sec.c
  8. Abstract:
  9. !!! THIS IS SENSITIVE INFORMATION !!!
  10. THIS CODE MUST NEVER BE INCLUDED IN ANY EXTERNAL DOCUMENTATION
  11. These functions MUST be static to prevent symbols when we ship
  12. Environment:
  13. kernel mode only
  14. Revision History:
  15. --*/
  16. /*
  17. KEY1 == \Registry\Machine\Software\Microsoft\
  18. DPID == \Registry\Machine\Software\Microsoft\
  19. Windows NT\CurrentVersion\DigitalProductId [REG_BINARY]
  20. KEY2 == KEY1 + DPID Hash
  21. PHSH == DPID Hash
  22. DHSH == Drive Hash based off vendor, product, revision, and serial no.
  23. UVAL == obfuscated value containing both current region and reset count
  24. Overview:
  25. KEY1 and DPID must both exist. furthermore, it is a given that the
  26. DPID is unique to a machine and changing it is catastrophic. Based
  27. upon these presumptions, we use the DPID to create a semi-unique key
  28. under KEY1 that is based off the DPID (KEY2). KEY2 will store values
  29. for each DVD RPC Phase 1 drive.
  30. It is also a given that both the region AND reset count will change
  31. each time the key is written. This allows the obfuscation method to
  32. rely on either the reset or the region, but does not require both.
  33. Each byte should rely on one of the above, in order to prevent any
  34. large sequences of bytes from staying the same between changes.
  35. Each value under KEY2 will have a one-to-one correlation to a
  36. specific TYPE of drive (UVAL). Identical drives will share regions
  37. and region reset counts. This is a "better" solution than sharing
  38. region and reset counts for all devices, which was the only other
  39. choice. OEMs must be made aware of this. This is a good reason to
  40. install RPC Phase 2 drives into machines.
  41. The UVAL is read by CdromGetRpc0Settings(). If the read results in
  42. invalid data, we will mark the device as VIOLATING the license
  43. agreements.
  44. The UVAL name is based upon the DHSH as follows:
  45. Take the DHSH and copy it as legal characters for the registry
  46. by OR'ing with the value 0x20 (all characters higher than 20
  47. are legal? -- verify with JVERT). This also has the benefit of
  48. being a LOSSY method, but with a FIXED string length.
  49. The data within UVAL is REG_QWORD. The data breakdown can be found
  50. in the functions SecureDvdEncodeSettings() and SecureDvdDecodeSettings()
  51. NOTE: One main difficulty still exists in determining the difference
  52. between the above key not existing due to user deletion vs. the above
  53. key not existing due to first install of this drive.
  54. OPTIONAL: It is highly preferred to have KEY3 seeded in the system
  55. hive. This will prevent the casual deletion of the KEY3 tree to reset
  56. all the region counts to max. It is unknown if this is simple at
  57. this time, but allows option 2 (below) to change to deletion, which
  58. may be a better option.
  59. OPTIONAL: save another key (UKEY), which, if it exists, means this
  60. machine should NEVER be allowed to work again. this will force a
  61. reinstall, and reduce the effectiveness of a brute-force attack
  62. to an unmodified driver unless they realize this key is being set.
  63. this will also allow a method to determine if a user deleted KEY2.
  64. PSS can know about this magic key. cdrom should log an EVENTLOG
  65. saying that the CSS license agreement has been breached. this key
  66. should never be set for any error conditions when reading the key.
  67. FunctionalFlow:
  68. ReadDvdRegionAndResetCount()
  69. [O] if (SecureDvdLicenseBreachDetected()) {
  70. [O] LogLicenseError();
  71. [O] return;
  72. [O] }
  73. if (!NT_SUCCESS(SecureDvdGetRegKeyHandle(h)) &&
  74. reason was DNE) {
  75. LogLicenseError();
  76. return;
  77. }
  78. PHSH = SecureDvdGetProductHash();
  79. if (PHSH == INVALID_HASH) {
  80. return;
  81. }
  82. DHSH = SecureDvdGetDriveHash();
  83. if (DHSH == INVALID_HASH) {
  84. return;
  85. }
  86. if (!ReadValue( DriveKey, Data )) {
  87. INITIALIZE_DRIVE_DATA( Data );
  88. }
  89. //
  90. // data exists, if it's incorrect, LogLicenseError()
  91. //
  92. if (!DecodeSettings( QWORD, DHSH, PHSH )) {
  93. LogLicenseError();
  94. return;
  95. }
  96. // set region & count
  97. return;
  98. WriteDvdRegionAndResetCount()
  99. [O] if (SecureDvdLicenseBreachDetected()) {
  100. [O] return FALSE;
  101. [O] }
  102. if (!NT_SUCCESS(SecureDvdGetRegKeyHandle(h)) &&
  103. reason was DNE) {
  104. return FALSE;
  105. }
  106. PHSH = SecureDvdGetProductHash();
  107. if (PHSH == INVALID_HASH) {
  108. return FALSE;
  109. }
  110. DHSH = SecureDvdGetDriveHash();
  111. if (DHSH == INVALID_HASH) {
  112. return FALSE;
  113. }
  114. QWORD = EncodeSettings( DHSH, PHSH, Region, Resets );
  115. if (QWORD == INVALID_HASH) {
  116. return FALSE;
  117. }
  118. if (!WriteValue( DriveKey, Data )) {
  119. return FALSE;
  120. }
  121. return TRUE;
  122. */
  123. // @@END_DDKSPLIT
  124. #include "sec.h"
  125. #include "sec.tmh"
  126. // @@BEGIN_DDKSPLIT
  127. //
  128. // the digital product id structure is defined
  129. // in \nt\private\windows\setup\pidgen\inc\pidgen.h
  130. // (this was as of 10/06/1999)
  131. //
  132. typedef struct {
  133. ULONG dwLength;
  134. SHORT wVersionMajor;
  135. SHORT wVersionMinor;
  136. UCHAR szPid2[24];
  137. ULONG dwKeyIdx;
  138. UCHAR szSku[16];
  139. UCHAR abCdKey[16];
  140. ULONG dwCloneStatus;
  141. ULONG dwTime;
  142. ULONG dwRandom;
  143. ULONG dwLicenseType;
  144. ULONG adwLicenseData[2];
  145. UCHAR szOemId[8];
  146. ULONG dwBundleId;
  147. UCHAR aszHardwareIdStatic[8];
  148. ULONG dwHardwareIdTypeStatic;
  149. ULONG dwBiosChecksumStatic;
  150. ULONG dwVolSerStatic;
  151. ULONG dwTotalRamStatic;
  152. ULONG dwVideoBiosChecksumStatic;
  153. UCHAR aszHardwareIdDynamic[8];
  154. ULONG dwHardwareIdTypeDynamic;
  155. ULONG dwBiosChecksumDynamic;
  156. ULONG dwVolSerDynamic;
  157. ULONG dwTotalRamDynamic;
  158. ULONG dwVideoBiosChecksumDynamic;
  159. ULONG dwCrc32;
  160. } DIGITALPID, *PDIGITALPID;
  161. ////////////////////////////////////////////////////////////////////////////////
  162. //
  163. // These functions are not called externally. Make them static to make
  164. // debugging more difficult in the shipping versions.
  165. //
  166. ////////////////////////////////////////////////////////////////////////////////
  167. STATIC
  168. ULONG
  169. RotateULong(
  170. IN ULONG N,
  171. IN LONG BitsToRotate
  172. )
  173. // validated for -64 through +64
  174. {
  175. if (BitsToRotate < 0) {
  176. BitsToRotate = - BitsToRotate; // negate
  177. BitsToRotate %= 8*sizeof(ULONG); // less than bits
  178. BitsToRotate = 8*sizeof(ULONG) - BitsToRotate; // equivalent positive
  179. } else {
  180. BitsToRotate %= 8*sizeof(ULONG); // less than bits
  181. }
  182. return ((N << BitsToRotate) |
  183. (N >> ((8*sizeof(ULONG)) - BitsToRotate)));
  184. }
  185. STATIC
  186. ULONGLONG
  187. RotateULongLong(
  188. IN ULONGLONG N,
  189. IN LONG BitsToRotate
  190. )
  191. // validated for -128 through +128
  192. {
  193. if (BitsToRotate < 0) {
  194. BitsToRotate = - BitsToRotate;
  195. BitsToRotate %= 8*sizeof(ULONGLONG);
  196. BitsToRotate = 8*sizeof(ULONGLONG) - BitsToRotate;
  197. } else {
  198. BitsToRotate %= 8*sizeof(ULONGLONG);
  199. }
  200. return ((N << BitsToRotate) |
  201. (N >> ((8*sizeof(ULONGLONG)) - BitsToRotate)));
  202. }
  203. STATIC
  204. BOOLEAN
  205. SecureDvdRegionInvalid(
  206. IN UCHAR NegativeRegionMask
  207. )
  208. // validated for all inputs
  209. {
  210. UCHAR positiveMask = ~NegativeRegionMask;
  211. if (positiveMask == 0) {
  212. ASSERT(!"This routine should never be called with the value 0xff");
  213. return TRUE;
  214. }
  215. //
  216. // region non-zero, drop the lowest bit
  217. // (this is a cool hack, learned when implementing a fast
  218. // way to count the number of set bits in a variable.)
  219. //
  220. positiveMask = positiveMask & (positiveMask-1);
  221. //
  222. // if still non-zero, had more than one bit set
  223. //
  224. if (positiveMask) {
  225. TraceLog((CdromSecInfo, "DvdInvalidRegion: TRUE for many bits\n"));
  226. return TRUE;
  227. }
  228. return FALSE;
  229. }
  230. STATIC
  231. ULONGLONG
  232. SecureDvdGetDriveHash(
  233. IN PSTORAGE_DEVICE_DESCRIPTOR Descriptor
  234. )
  235. // validated for all fields filled
  236. // validated for some fields NULL
  237. // validated for all fields NULL
  238. // validated for some fields invalid (too large?)
  239. // validated for all fields invalid (too large?)
  240. /*
  241. ** returns a ULONGLONG which is the HASH for a given DVD device.
  242. ** NOTE: because this does not check SCSI IDs, identical drives
  243. ** will share the same region and reset counts.
  244. */
  245. {
  246. ULONGLONG checkSum = 0;
  247. ULONG characters = 0;
  248. LONG i;
  249. if (Descriptor->VendorIdOffset > 0x12345678) {
  250. TraceLog((CdromSecError,
  251. "DvdDriveHash: VendorIdOffset is too large (%x)\n",
  252. Descriptor->VendorIdOffset));
  253. Descriptor->VendorIdOffset = 0;
  254. }
  255. if (Descriptor->ProductIdOffset > 0x12345678) {
  256. TraceLog((CdromSecError,
  257. "DvdDriveHash: ProductIdOffset is too large (%x)\n",
  258. Descriptor->ProductIdOffset));
  259. Descriptor->ProductIdOffset = 0;
  260. }
  261. if (Descriptor->ProductRevisionOffset > 0x12345678) {
  262. TraceLog((CdromSecError,
  263. "DvdDriveHash: ProducetRevisionOffset is too "
  264. " large (%x)\n", Descriptor->ProductRevisionOffset));
  265. Descriptor->ProductRevisionOffset = 0;
  266. }
  267. if (Descriptor->SerialNumberOffset > 0x12345678) {
  268. TraceLog((CdromSecError,
  269. "DvdDriveHash: SerialNumberOffset is too "
  270. "large (%x)\n", Descriptor->SerialNumberOffset));
  271. Descriptor->SerialNumberOffset = 0;
  272. }
  273. if ((!Descriptor->VendorIdOffset ) &&
  274. (!Descriptor->ProductIdOffset ) &&
  275. (!Descriptor->ProductRevisionOffset) ) {
  276. TraceLog((CdromSecError, "DvdDriveHash: Invalid Descriptor at %p!\n",
  277. Descriptor));
  278. return INVALID_HASH;
  279. }
  280. //
  281. // take one byte at a time, XOR together
  282. // should provide a semi-unique hash
  283. //
  284. for (i=0;i<4;i++) {
  285. PUCHAR string = (PUCHAR)Descriptor;
  286. ULONG offset = 0;
  287. switch(i) {
  288. case 0: // vendorId
  289. TraceLog((CdromSecInfo, "DvdDriveHash: Adding Vendor\n"));
  290. offset = Descriptor->VendorIdOffset;
  291. break;
  292. case 1: // productId
  293. TraceLog((CdromSecInfo, "DvdDriveHash: Adding Product\n"));
  294. offset = Descriptor->ProductIdOffset;
  295. break;
  296. case 2: // revision
  297. TraceLog((CdromSecInfo, "DvdDriveHash: Adding Revision\n"));
  298. offset = Descriptor->ProductRevisionOffset;
  299. break;
  300. case 3: // serialNumber
  301. TraceLog((CdromSecInfo, "DvdDriveHash: Adding SerialNumber\n"));
  302. offset = Descriptor->SerialNumberOffset;
  303. break;
  304. default:
  305. TraceLog((CdromSecError, "DvdDriveHash: TOO MANY LOOPS!!!\n"));
  306. offset = 0;
  307. break;
  308. }
  309. //
  310. // add the string to our checksum
  311. //
  312. if (offset != 0) {
  313. for (string += offset; *string; string++) {
  314. //
  315. // take each character, multiply it by a "random"
  316. // value. rotate the value.
  317. //
  318. ULONGLONG temp;
  319. if (*string == ' ') {
  320. // don't include spaces in the character count
  321. // nor in the hash
  322. continue;
  323. }
  324. //
  325. // dereference the value first!
  326. //
  327. temp = (ULONGLONG)(*string);
  328. //
  329. // guaranteed no overflow in UCHAR * ULONG in ULONGLONG
  330. //
  331. temp *= DVD_RANDOMIZER[ characters%DVD_RANDOMIZER_SIZE ];
  332. //
  333. // this rotation is just to spread the values around
  334. // the 64 bits more evenly
  335. //
  336. temp = RotateULongLong(temp, 8*characters);
  337. //
  338. // increment number of characters used in checksum
  339. // (used to verify we have enough characters)
  340. //
  341. characters++;
  342. //
  343. // XOR it into the checksum
  344. //
  345. checkSum ^= temp;
  346. } // end of string
  347. if (checkSum == 0) {
  348. TraceLog((CdromSecInfo, "DvdDriveHash: zero checksum -- using "
  349. "random value\n"));
  350. checkSum ^= DVD_RANDOMIZER[ characters%DVD_RANDOMIZER_SIZE ];
  351. characters++;
  352. }
  353. } // end of non-zero offset
  354. } // end of four strings (vendor, product, revision, serialNo)
  355. //
  356. // we have to use more than four characters
  357. // for this to be useful
  358. //
  359. if (characters <= 4) {
  360. TraceLog((CdromSecError, "DvdDriveHash: Too few useful characters (%x) "
  361. "for unique disk hash\n", characters));
  362. return INVALID_HASH;
  363. }
  364. return checkSum;
  365. }
  366. //
  367. // static, not called externally
  368. //
  369. STATIC
  370. NTSTATUS
  371. SecureDvdEncodeSettings(
  372. IN ULONGLONG DpidHash,
  373. IN ULONGLONG DriveHash,
  374. OUT PULONGLONG Obfuscated,
  375. IN UCHAR RegionMask,
  376. IN UCHAR ResetCount
  377. )
  378. // validated for all valid inputs.
  379. // validated for invalid inputs.
  380. {
  381. LARGE_INTEGER largeInteger = {0};
  382. ULONGLONG set;
  383. LONG i;
  384. LONG rotate;
  385. UCHAR temp = 0;
  386. UCHAR random1;
  387. UCHAR random2;
  388. //
  389. // using the return from KeQueryTickCount() should give
  390. // semi-random data
  391. //
  392. KeQueryTickCount(&largeInteger);
  393. random2 = 0;
  394. for (i=0; i < sizeof(ULONGLONG); i++) {
  395. random2 ^= ((largeInteger.QuadPart >> (8*i)) & 0xff);
  396. }
  397. // set temp == sum of all 4-bit values
  398. // 16 in ULONGLONG, times max value of
  399. // 15 each is less than MAX_UCHAR
  400. for (i=0; i < 2*sizeof(ULONGLONG); i++) {
  401. temp += (UCHAR)( (DpidHash >> (4*i)) & 0xf );
  402. }
  403. //
  404. // validate these settings here
  405. //
  406. if (DpidHash == INVALID_HASH) {
  407. TraceLog((CdromSecError, "DvdEncode: Invalid DigitalProductId Hash\n"));
  408. goto UserFailure;
  409. }
  410. if (DriveHash == INVALID_HASH) {
  411. TraceLog((CdromSecError, "DvdEncode: Invalid Drive Hash\n"));
  412. goto UserFailure;
  413. }
  414. if (RegionMask == 0xff) {
  415. TraceLog((CdromSecError, "DvdEncode: Shouldn't attempt to write "
  416. "mask of 0xff\n"));
  417. goto UserFailure;
  418. }
  419. if (SecureDvdRegionInvalid(RegionMask)) {
  420. TraceLog((CdromSecError, "DvdEncode: Invalid region\n"));
  421. goto LicenseViolation;
  422. }
  423. if (ResetCount >= 2) {
  424. TraceLog((CdromSecError, "DvdEncode: Too many reset counts\n"));
  425. goto LicenseViolation;
  426. }
  427. //
  428. // using the return from KeQueryTickCount() should give
  429. // semi-random data
  430. //
  431. KeQueryTickCount(&largeInteger);
  432. random1 = 0;
  433. for (i=0; i < sizeof(ULONGLONG); i++) {
  434. random1 ^= ((largeInteger.QuadPart >> (8*i)) & 0xff);
  435. }
  436. TraceLog((CdromSecInfo,
  437. "DvdEncode: Random1 = %x Random2 = %x\n",
  438. random1, random2));
  439. //
  440. // they must all fit into UCHAR! they should, since each one is
  441. // individually a UCHAR, and only bitwise operations are being
  442. // performed on them.
  443. //
  444. //
  445. // the first cast to UCHAR prevents signed extension.
  446. // the second cast to ULONGLONG allows high bits preserved by '|'
  447. //
  448. set = (ULONGLONG)0;
  449. for (i=0; i < sizeof(ULONGLONG); i++) {
  450. set ^= (ULONGLONG)random2 << (8*i);
  451. }
  452. set ^= (ULONGLONG)
  453. ((ULONGLONG)((UCHAR)(random1 ^ temp)) << 8*7) |
  454. ((ULONGLONG)((UCHAR)(RegionMask ^ temp)) << 8*6) |
  455. ((ULONGLONG)((UCHAR)(ResetCount ^ RegionMask ^ random1)) << 8*5) |
  456. ((ULONGLONG)((UCHAR)(0)) << 8*4) |
  457. ((ULONGLONG)((UCHAR)(ResetCount ^ temp)) << 8*3) |
  458. ((ULONGLONG)((UCHAR)(ResetCount ^ ((DriveHash >> 13) & 0xff))) << 8*2) |
  459. ((ULONGLONG)((UCHAR)(random1)) << 8*1) |
  460. ((ULONGLONG)((UCHAR)(RegionMask ^ ((DriveHash >> 23) & 0xff))) << 8*0) ;
  461. TraceLog((CdromSecInfo,
  462. "DvdEncode: Pre-rotate: %016I64x temp = %x\n",
  463. set, temp));
  464. //
  465. // rotate it a semi-random, non-multiple-of-eight bits
  466. //
  467. rotate = (LONG)((DpidHash & 0xb) + 1); // {15,14,10,9,7,5,2,1}
  468. TraceLog((CdromSecInfo,
  469. "DvdEncode: Rotating %x bits\n", rotate));
  470. *Obfuscated = RotateULongLong(set, rotate);
  471. return STATUS_SUCCESS;
  472. UserFailure:
  473. *Obfuscated = INVALID_HASH;
  474. return STATUS_UNSUCCESSFUL;
  475. LicenseViolation:
  476. *Obfuscated = INVALID_HASH;
  477. return STATUS_LICENSE_VIOLATION;
  478. }
  479. STATIC
  480. NTSTATUS
  481. SecureDvdDecodeSettings(
  482. IN ULONGLONG DpidHash,
  483. IN ULONGLONG DriveHash,
  484. IN ULONGLONG Set,
  485. OUT PUCHAR RegionMask,
  486. OUT PUCHAR ResetCount
  487. )
  488. // validated for many correct inputs, of all region/reset combinations
  489. // validated for many incorrect inputs.
  490. {
  491. UCHAR random;
  492. UCHAR region;
  493. UCHAR resets;
  494. UCHAR temp = 0;
  495. LONG i, rotate;
  496. // set temp == sum of all 4-bit values
  497. // 16 in ULONGLONG, times max value of
  498. // 15 each is less than MAX_UCHAR
  499. for (i=0; i < 2*sizeof(ULONGLONG); i++) {
  500. temp += (UCHAR)( (DpidHash >> (4*i)) & 0xf );
  501. }
  502. rotate = (LONG)((DpidHash & 0xb) + 1); // {15,14,10,9,7,5,2,1}
  503. Set = RotateULongLong(Set, -rotate);
  504. TraceLog((CdromSecInfo, "DvdDecode: Post-rotate: %016I64x\n", Set));
  505. random = (UCHAR)(Set >> 8*4); // random2
  506. TraceLog((CdromSecInfo, "DvdDecode: Random2 = %x\n", random));
  507. for (i = 0; i < sizeof(ULONGLONG); i++) {
  508. Set ^= (ULONGLONG)random << (8*i);
  509. }
  510. //
  511. // bytes 6,4,3,1 are taken 'as-is'
  512. // bytes 7,5,2,0 are verified
  513. //
  514. region = ((UCHAR)(Set >> 8*6)) ^ temp;
  515. resets = ((UCHAR)(Set >> 8*3)) ^ temp;
  516. random = ((UCHAR)(Set >> 8*1)); // make it random1
  517. TraceLog((CdromSecInfo, "DvdDecode: Random1 = %x Region = %x Resets = %x\n",
  518. random, region, resets));
  519. // verify the bits
  520. if (((UCHAR)(Set >> 8*7)) != (random ^ temp)) {
  521. TraceLog((CdromSecError, "DvdDecode: Invalid Byte 7\n"));
  522. goto ViolatedLicense;
  523. }
  524. random ^= (UCHAR)(Set >> 8*5);
  525. if (random != (resets ^ region)) {
  526. TraceLog((CdromSecError, "DvdDecode: Invalid Byte 5\n"));
  527. goto ViolatedLicense;
  528. }
  529. random = (UCHAR)(DriveHash >> 13);
  530. random ^= (UCHAR)(Set >> 8*2);
  531. if (random != resets) {
  532. TraceLog((CdromSecError, "DvdDecode: Invalid Byte 2\n"));
  533. goto ViolatedLicense;
  534. }
  535. random = (UCHAR)(DriveHash >> 23);
  536. random ^= (UCHAR)(Set >> 8*0);
  537. if (random != region) {
  538. TraceLog((CdromSecError, "DvdDecode: Invalid Byte 0\n"));
  539. goto ViolatedLicense;
  540. }
  541. if (SecureDvdRegionInvalid(region)) {
  542. TraceLog((CdromSecError, "DvdDecode: Region was invalid\n"));
  543. goto ViolatedLicense;
  544. }
  545. if (resets >= 2) {
  546. TraceLog((CdromSecError, "DvdDecode: Reset count was invalid\n"));
  547. goto ViolatedLicense;
  548. }
  549. TraceLog((CdromSecInfo, "DvdDecode: Successfully validated stored data\n"));
  550. *RegionMask = region;
  551. *ResetCount = resets;
  552. return STATUS_SUCCESS;
  553. ViolatedLicense:
  554. *RegionMask = 0x00;
  555. *ResetCount = 0x00;
  556. return STATUS_LICENSE_VIOLATION;
  557. }
  558. STATIC
  559. NTSTATUS
  560. SecureDvdGetSettingsCallBack(
  561. IN PWSTR ValueName,
  562. IN ULONG ValueType,
  563. IN PVOID ValueData,
  564. IN ULONG ValueLength,
  565. IN PVOID UnusedContext,
  566. IN PDVD_REGISTRY_CONTEXT Context
  567. )
  568. {
  569. ULONGLONG hash = 0;
  570. NTSTATUS status;
  571. if (ValueType != REG_QWORD) {
  572. TraceLog((CdromSecError, "DvdGetSettingsCallback: Not REG_BINARY\n"));
  573. goto ViolatedLicense;
  574. }
  575. if (ValueLength != sizeof(ULONGLONG)) {
  576. TraceLog((CdromSecError, "DvdGetSettingsCallback: DVD Settings data too "
  577. "small (%x bytes)\n", ValueLength));
  578. goto ViolatedLicense;
  579. }
  580. hash = *((PULONGLONG)ValueData);
  581. if (hash == INVALID_HASH) {
  582. TraceLog((CdromSecError, "DvdGetSettingsCallback: Invalid hash stored?\n"));
  583. goto ViolatedLicense;
  584. }
  585. //
  586. // validate the data
  587. // this also sets the values in the context upon success.
  588. //
  589. status = SecureDvdDecodeSettings(Context->DpidHash,
  590. Context->DriveHash,
  591. hash,
  592. &Context->RegionMask,
  593. &Context->ResetCount);
  594. if (status == STATUS_LICENSE_VIOLATION) {
  595. TraceLog((CdromSecError, "DvdGetSettingsCallback: data was violated!\n"));
  596. goto ViolatedLicense;
  597. }
  598. //
  599. // the above call to SecureDvdDecodeSettings can only return
  600. // success or a license violation
  601. //
  602. ASSERT(NT_SUCCESS(status));
  603. return STATUS_SUCCESS;
  604. ViolatedLicense:
  605. Context->DriveHash = INVALID_HASH;
  606. Context->DpidHash = INVALID_HASH;
  607. Context->RegionMask = 0;
  608. Context->ResetCount = 0;
  609. return STATUS_LICENSE_VIOLATION;
  610. }
  611. STATIC
  612. NTSTATUS
  613. SecureDvdGetDigitalProductIdCallBack(
  614. IN PWSTR ValueName,
  615. IN ULONG ValueType,
  616. IN PDIGITALPID DigitalPid, // ValueData
  617. IN ULONG ValueLength,
  618. IN PVOID UnusedVariable,
  619. IN PULONGLONG DpidHash
  620. )
  621. // validated for non-REG_BINARY
  622. // validated for good data
  623. // validated for short data
  624. {
  625. NTSTATUS status = STATUS_LICENSE_VIOLATION;
  626. ULONGLONG hash = 0;
  627. if (ValueType != REG_BINARY) {
  628. TraceLog((CdromSecError, "DvdDPIDCallback: Not REG_BINARY\n"));
  629. *DpidHash = INVALID_HASH;
  630. return STATUS_LICENSE_VIOLATION;
  631. }
  632. if (ValueLength < 4*sizeof(ULONGLONG)) {
  633. TraceLog((CdromSecError,
  634. "DvdDPIDCallback: DPID data too small (%x bytes)\n",
  635. ValueLength));
  636. *DpidHash = INVALID_HASH;
  637. return STATUS_LICENSE_VIOLATION;
  638. }
  639. //
  640. // apparently, only 13 bytes of the DigitalPID are
  641. // going to stay static across upgrades. even these
  642. // will change if the boot hard drive, video card, or
  643. // bios signature changes. nonetheless, this is only
  644. // supposed to keep the honest people honest. :)
  645. //
  646. //
  647. // 8 bytes to fill == 64 bytes (need to rotate at least 48 bits)
  648. //
  649. TraceLog((CdromSecInfo,
  650. "Bios %08x Video %08x VolSer %08x\n",
  651. DigitalPid->dwBiosChecksumStatic,
  652. DigitalPid->dwVideoBiosChecksumStatic,
  653. DigitalPid->dwVolSerStatic));
  654. hash ^= DigitalPid->dwBiosChecksumStatic; // 4 bytes // bios signature
  655. hash = RotateULongLong(hash, 13); // prime number
  656. hash ^= DigitalPid->dwVideoBiosChecksumStatic; // 4 bytes // video card
  657. hash = RotateULongLong(hash, 13); // prime number
  658. hash ^= DigitalPid->dwVolSerStatic; // 4 bytes // hard drive
  659. hash = RotateULongLong(hash, 13); // prime number
  660. *DpidHash = hash;
  661. return STATUS_SUCCESS;
  662. }
  663. STATIC
  664. NTSTATUS
  665. SecureDvdReturnDPIDHash(
  666. PULONGLONG DpidHash
  667. )
  668. {
  669. RTL_QUERY_REGISTRY_TABLE queryTable[2] = {0};
  670. NTSTATUS status;
  671. // cannot be PAGED_CODE() because queryTable cannot be swapped out!
  672. //
  673. // query the value
  674. //
  675. queryTable[0].Name = L"DigitalProductId";
  676. queryTable[0].EntryContext = DpidHash;
  677. queryTable[0].DefaultType = 0;
  678. queryTable[0].DefaultData = NULL;
  679. queryTable[0].DefaultLength = 0;
  680. queryTable[0].Flags = RTL_QUERY_REGISTRY_REQUIRED;
  681. queryTable[0].QueryRoutine = SecureDvdGetDigitalProductIdCallBack;
  682. *DpidHash = INVALID_HASH;
  683. status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE,
  684. L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion",
  685. &(queryTable[0]),
  686. NULL,
  687. NULL);
  688. if (status == STATUS_LICENSE_VIOLATION) {
  689. TraceLog((CdromSecError,
  690. "DvdReturnDPIDHash: Invalid DPID!\n"));
  691. } else if (!NT_SUCCESS(status)) {
  692. TraceLog((CdromSecError,
  693. "DvdReturnDPIDHash: Cannot get DPID (%x)\n", status));
  694. } else {
  695. TraceLog((CdromSecInfo,
  696. "DvdReturnDPIDHash: Hash is now %I64x\n",
  697. *DpidHash));
  698. }
  699. return status;
  700. }
  701. ////////////////////////////////////////////////////////////////////////////////
  702. //// Everything past here has not been component tested
  703. ////////////////////////////////////////////////////////////////////////////////
  704. #define SECURE_DVD_SET_SECURITY_ON_HANDLE 0
  705. STATIC
  706. NTSTATUS
  707. SecureDvdSetHandleSecurity(
  708. IN HANDLE Handle
  709. )
  710. {
  711. #if SECURE_DVD_SET_SECURITY_ON_HANDLE
  712. PACL newAcl = NULL;
  713. ULONG newAclSize;
  714. SECURITY_DESCRIPTOR securityDescriptor = { 0 };
  715. NTSTATUS status;
  716. //
  717. // from \nt\private\ntos\io\pnpinit.c
  718. //
  719. //SeEnableAccessToExports();
  720. TRY {
  721. newAclSize = sizeof(ACL);
  722. newAclSize += sizeof(ACCESS_ALLOWED_ACE);
  723. newAclSize -= sizeof(ULONG);
  724. newAclSize += RtlLengthSid(SeExports->SeLocalSystemSid);
  725. newAcl = ExAllocatePoolWithTag(PagedPool, newAclSize, DVD_TAG_SECURITY);
  726. if (newAcl == NULL) {
  727. status = STATUS_INSUFFICIENT_RESOURCES;
  728. LEAVE;
  729. }
  730. status = RtlCreateSecurityDescriptor(&securityDescriptor,
  731. SECURITY_DESCRIPTOR_REVISION);
  732. if (!NT_SUCCESS(status)) {
  733. ASSERT(!"failed to create a security descriptor?");
  734. LEAVE;
  735. }
  736. status = RtlCreateAcl(newAcl, newAclSize, ACL_REVISION);
  737. if (!NT_SUCCESS(status)) {
  738. ASSERT(!"failed to create a new ACL?");
  739. LEAVE;
  740. }
  741. status = RtlAddAccessAllowedAce(newAcl,
  742. ACL_REVISION,
  743. KEY_ALL_ACCESS,
  744. SeExports->SeLocalSystemSid);
  745. if (!NT_SUCCESS(status)) {
  746. ASSERT(!"failed to add LocalSystem to ACL");
  747. LEAVE;
  748. }
  749. status = RtlSetDaclSecurityDescriptor(&securityDescriptor,
  750. TRUE,
  751. newAcl,
  752. FALSE);
  753. if (!NT_SUCCESS(status)) {
  754. ASSERT(!"failed to set acl in security descriptor?");
  755. LEAVE;
  756. }
  757. status = RtlValidSecurityDescriptor(&securityDescriptor);
  758. if (!NT_SUCCESS(status)) {
  759. ASSERT(!"failed to validate security descriptor?");
  760. LEAVE;
  761. }
  762. status = ZwSetSecurityObject(Handle,
  763. // PROTECTED_DACL_SECURITY_INFORMATION,
  764. DACL_SECURITY_INFORMATION,
  765. &securityDescriptor);
  766. if (!NT_SUCCESS(status)) {
  767. ASSERT(!"Failed to set security on handle\n");
  768. LEAVE;
  769. }
  770. status = STATUS_SUCCESS;
  771. } FINALLY {
  772. if (newAcl != NULL) {
  773. ExFreePool(newAcl);
  774. newAcl = NULL;
  775. }
  776. }
  777. #endif
  778. return STATUS_SUCCESS;
  779. }
  780. STATIC
  781. NTSTATUS
  782. SecureDvdGetRegistryHandle(
  783. IN ULONGLONG DpidHash,
  784. OUT PHANDLE Handle
  785. )
  786. {
  787. OBJECT_ATTRIBUTES objectAttributes = {0};
  788. UNICODE_STRING hashString = {0};
  789. NTSTATUS status;
  790. LONG i;
  791. //
  792. // using char[] instead of char* allows modification of the
  793. // string in this routine (a way of obfuscating the string)
  794. // 0 ....+.... 1....+.. ..2....+. ...3....+. ...4
  795. WCHAR string[] = L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT";
  796. WCHAR *hash = &(string[37]);
  797. PULONGLONG hashAsUlonglong = (PULONGLONG)hash;
  798. for (i = 0; i < sizeof(ULONGLONG); i++) {
  799. UCHAR temp;
  800. temp = (UCHAR)(DpidHash >> (8*i));
  801. SET_FLAG(temp, 0x20); // more than 32
  802. CLEAR_FLAG(temp, 0x80); // less than 128
  803. hash[i] = (WCHAR)temp; // make it a wide char
  804. }
  805. hash[i] = UNICODE_NULL;
  806. RtlInitUnicodeString(&hashString, string);
  807. RtlZeroMemory(&objectAttributes, sizeof(OBJECT_ATTRIBUTES));
  808. InitializeObjectAttributes(&objectAttributes,
  809. &hashString,
  810. OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
  811. RTL_REGISTRY_ABSOLUTE, // NULL?
  812. NULL // no security descriptor
  813. );
  814. status = ZwCreateKey(Handle,
  815. KEY_ALL_ACCESS,
  816. &objectAttributes,
  817. 0,
  818. NULL, // can be a unicode string....
  819. REG_OPTION_NON_VOLATILE,
  820. NULL);
  821. if (!NT_SUCCESS(status)) {
  822. TraceLog((CdromSecError,
  823. "DvdGetRegistryHandle: Failed to create key (%x)\n",
  824. status));
  825. return status;
  826. }
  827. status = SecureDvdSetHandleSecurity(*Handle);
  828. if (!NT_SUCCESS(status)) {
  829. TraceLog((CdromSecError,
  830. "DvdGetRegistryHandle: Failed to set key security (%x)\n",
  831. status));
  832. ZwClose(*Handle);
  833. *Handle = INVALID_HANDLE_VALUE;
  834. }
  835. return status;
  836. }
  837. STATIC
  838. VOID
  839. SecureDvdCreateValueNameFromHash(
  840. IN ULONGLONG DriveHash,
  841. OUT PWCHAR HashString
  842. )
  843. {
  844. PUCHAR buffer = (PUCHAR)HashString;
  845. LONG i;
  846. RtlZeroMemory(HashString, 17*sizeof(WCHAR));
  847. sprintf(buffer, "%016I64x", DriveHash);
  848. // now massage the data to be unicode
  849. for (i = 15; i >= 0; i--) {
  850. HashString[i] = buffer[i];
  851. }
  852. }
  853. STATIC
  854. NTSTATUS
  855. SecureDvdReadOrWriteRegionAndResetCount(
  856. IN PDEVICE_OBJECT Fdo,
  857. IN UCHAR NewRegion,
  858. IN BOOLEAN ReadingTheValues
  859. )
  860. //
  861. // NewRegion is ignored if ReadingTheValues is TRUE
  862. //
  863. {
  864. PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
  865. PCOMMON_DEVICE_EXTENSION commonExtension = Fdo->DeviceExtension;
  866. PCDROM_DATA cddata;
  867. NTSTATUS status;
  868. ULONG keyDisposition;
  869. DVD_REGISTRY_CONTEXT registryContext = {0};
  870. HANDLE semiSecureHandle = INVALID_HANDLE_VALUE;
  871. PAGED_CODE();
  872. ASSERT(commonExtension->IsFdo);
  873. cddata = (PCDROM_DATA)(commonExtension->DriverData);
  874. if (cddata->DvdRpc0LicenseFailure) {
  875. TraceLog((CdromSecError,
  876. "Dvd%sSettings: Already violated licensing\n",
  877. (ReadingTheValues ? "Read" : "Write")
  878. ));
  879. goto ViolatedLicense;
  880. }
  881. RtlZeroMemory(&registryContext, sizeof(DVD_REGISTRY_CONTEXT));
  882. //
  883. // then, get the DigitalProductIdHash and this DriveHash
  884. //
  885. {
  886. status = SecureDvdReturnDPIDHash(&registryContext.DpidHash);
  887. // if this fails, we are in serious trouble!
  888. if (status == STATUS_LICENSE_VIOLATION) {
  889. TraceLog((CdromSecError,
  890. "Dvd%sSettings: License error getting DPIDHash?\n",
  891. (ReadingTheValues ? "Read" : "Write")));
  892. goto ViolatedLicense;
  893. } else if (!NT_SUCCESS(status)) {
  894. TraceLog((CdromSecError,
  895. "Dvd%sSettings: Couldn't get DPID Hash! (%x)\n",
  896. (ReadingTheValues ? "Read" : "Write"), status));
  897. goto RetryExit;
  898. }
  899. if (registryContext.DpidHash == INVALID_HASH) {
  900. goto ErrorExit;
  901. }
  902. registryContext.DriveHash =
  903. SecureDvdGetDriveHash(fdoExtension->DeviceDescriptor);
  904. if (registryContext.DriveHash == INVALID_HASH) {
  905. TraceLog((CdromSecError,
  906. "Dvd%sSettings: Couldn't create drive hash(!)\n",
  907. (ReadingTheValues ? "Read" : "Write")));
  908. goto ErrorExit;
  909. }
  910. }
  911. //
  912. // finally get a handle based upon the DigitalProductIdHash
  913. // to our "semi-secure" registry key, creating it if neccessary.
  914. //
  915. status= SecureDvdGetRegistryHandle(registryContext.DpidHash,
  916. &semiSecureHandle);
  917. if (!NT_SUCCESS(status)) {
  918. TraceLog((CdromSecError,
  919. "Dvd%sSettings: Could not get semi-secure handle %x\n",
  920. (ReadingTheValues ? "Read" : "Write"), status));
  921. goto ErrorExit;
  922. }
  923. //
  924. // if reading the values, use the semi-secure handle to open a subkey,
  925. // read its data, close the handle, it.
  926. //
  927. //
  928. if (ReadingTheValues) {
  929. WCHAR hashString[17] = {0}; // 16 + NULL
  930. RTL_QUERY_REGISTRY_TABLE queryTable[2] = {0};
  931. SecureDvdCreateValueNameFromHash(registryContext.DriveHash, hashString);
  932. RtlZeroMemory(&queryTable[0], 2*sizeof(RTL_QUERY_REGISTRY_TABLE));
  933. queryTable[0].DefaultData = NULL;
  934. queryTable[0].DefaultLength = 0;
  935. queryTable[0].DefaultType = 0;
  936. queryTable[0].EntryContext = &registryContext;
  937. queryTable[0].Flags = RTL_QUERY_REGISTRY_REQUIRED;
  938. queryTable[0].Name = hashString;
  939. queryTable[0].QueryRoutine = SecureDvdGetSettingsCallBack;
  940. status = RtlQueryRegistryValues(RTL_REGISTRY_HANDLE,
  941. semiSecureHandle,
  942. &queryTable[0],
  943. &registryContext,
  944. NULL);
  945. if (status == STATUS_LICENSE_VIOLATION) {
  946. TraceLog((CdromSecError,
  947. "Dvd%sSettings: Invalid value in registry!\n",
  948. (ReadingTheValues ? "Read" : "Write")));
  949. goto ViolatedLicense;
  950. } else if (!NT_SUCCESS(status)) {
  951. TraceLog((CdromSecError,
  952. "Dvd%sSettings: Other non-license error (%x)\n",
  953. (ReadingTheValues ? "Read" : "Write"), status));
  954. goto ErrorExit;
  955. }
  956. //
  957. // set the real values....
  958. //
  959. cddata->Rpc0SystemRegion = registryContext.RegionMask;
  960. cddata->Rpc0SystemRegionResetCount = registryContext.ResetCount;
  961. //
  962. // everything is kosher!
  963. //
  964. TraceLog((CdromSecInfo,
  965. "Dvd%sSettings: Region %x Reset %x\n",
  966. (ReadingTheValues ? "Read" : "Write"),
  967. cddata->Rpc0SystemRegion,
  968. cddata->Rpc0SystemRegionResetCount));
  969. } else { // !ReadingTheValues, iow, writing them....
  970. //
  971. // if writing the values, obfuscate them first (which also validates),
  972. // then use the semi-secure handle to write the subkey
  973. //
  974. WCHAR hashString[17] = {0}; // 16 + NULL
  975. ULONGLONG obfuscated;
  976. //
  977. // don't munge the device extension until we modify the registry
  978. // (see below for modification of device extension data)
  979. //
  980. registryContext.RegionMask = NewRegion;
  981. registryContext.ResetCount = cddata->Rpc0SystemRegionResetCount-1;
  982. //
  983. // this also validates the settings
  984. //
  985. SecureDvdCreateValueNameFromHash(registryContext.DriveHash, hashString);
  986. status = SecureDvdEncodeSettings(registryContext.DpidHash,
  987. registryContext.DriveHash,
  988. &obfuscated,
  989. registryContext.RegionMask,
  990. registryContext.ResetCount);
  991. if (status == STATUS_LICENSE_VIOLATION) {
  992. TraceLog((CdromSecError,
  993. "Dvd%sSettings: User may have modified memory! "
  994. "%x %x\n", (ReadingTheValues ? "Read" : "Write"),
  995. registryContext.RegionMask,
  996. registryContext.ResetCount));
  997. goto ViolatedLicense;
  998. } else if (!NT_SUCCESS(status)) {
  999. TraceLog((CdromSecError,
  1000. "Dvd%sSettings: Couldn't obfuscate data %x %x\n",
  1001. (ReadingTheValues ? "Read" : "Write"),
  1002. registryContext.RegionMask,
  1003. registryContext.ResetCount));
  1004. goto ErrorExit;
  1005. }
  1006. //
  1007. // save them for posterity
  1008. //
  1009. TraceLog((CdromSecInfo,
  1010. "Dvd%sSettings: Data is %016I64x\n",
  1011. (ReadingTheValues ? "Read" : "Write"),
  1012. obfuscated));
  1013. status = RtlWriteRegistryValue(RTL_REGISTRY_HANDLE,
  1014. semiSecureHandle,
  1015. hashString,
  1016. REG_QWORD,
  1017. &obfuscated,
  1018. (ULONG)(sizeof(ULONGLONG))
  1019. );
  1020. if (!NT_SUCCESS(status)) {
  1021. TraceLog((CdromSecError,
  1022. "Dvd%sSettings: Couldn't save %x\n",
  1023. (ReadingTheValues ? "Read" : "Write"), status));
  1024. goto ErrorExit;
  1025. }
  1026. //
  1027. // make the change in the device extension data also
  1028. //
  1029. cddata->Rpc0SystemRegion = NewRegion;
  1030. cddata->Rpc0SystemRegionResetCount--;
  1031. TraceLog((CdromSecInfo,
  1032. "Dvd%sSettings: Region %x Reset %x\n",
  1033. (ReadingTheValues ? "Read" : "Write"),
  1034. cddata->Rpc0SystemRegion,
  1035. cddata->Rpc0SystemRegionResetCount));
  1036. }
  1037. if (semiSecureHandle != INVALID_HANDLE_VALUE) {
  1038. ZwClose(semiSecureHandle);
  1039. }
  1040. return STATUS_SUCCESS;
  1041. ViolatedLicense: {
  1042. PIO_ERROR_LOG_PACKET errorLogEntry;
  1043. if (semiSecureHandle != INVALID_HANDLE_VALUE) {
  1044. ZwClose(semiSecureHandle);
  1045. }
  1046. /*
  1047. errorLogEntry = (PIO_ERROR_LOG_ENTRY)
  1048. IoAllocateErrorLogEntry(Fdo,
  1049. (UCHAR)(sizeof(IO_ERROR_LOG_PACKET)));
  1050. if (errorLogEntry != NULL) {
  1051. errorLogEntry->FinalStatus = STATUS_LICENSE_VIOLATION;
  1052. errorLogEntry->ErrorCode = STATUS_LICENSE_VIOLATION;
  1053. errorLogEntry->MajorFunctionCode = IRP_MJ_START_DEVICE;
  1054. IoWriteErrorLogEntry(errorLogEntry);
  1055. }
  1056. */
  1057. TraceLog((CdromSecError,
  1058. "Dvd%sSettings: License Violation Detected\n",
  1059. (ReadingTheValues ? "Read" : "Write")));
  1060. cddata->DvdRpc0LicenseFailure = TRUE; // no playback
  1061. cddata->Rpc0SystemRegion = 0xff; // no regions
  1062. cddata->Rpc0SystemRegionResetCount = 0; // no resets
  1063. return STATUS_LICENSE_VIOLATION;
  1064. }
  1065. RetryExit:
  1066. if (ReadingTheValues) {
  1067. cddata->Rpc0RetryRegistryCallback = 1;
  1068. }
  1069. //
  1070. // fall-through to Error Exit...
  1071. //
  1072. ErrorExit:
  1073. TraceLog((CdromSecError,
  1074. "Dvd%sSettings: Non-License Error Detected\n",
  1075. (ReadingTheValues ? "Read" : "Write")));
  1076. //
  1077. // don't modify the device extension on non-license-violation errors
  1078. //
  1079. if (semiSecureHandle != INVALID_HANDLE_VALUE) {
  1080. ZwClose(semiSecureHandle);
  1081. }
  1082. return STATUS_UNSUCCESSFUL;
  1083. }
  1084. ////////////////////////////////////////////////////////////////////////////////
  1085. //
  1086. // The following functions are externally accessible. They therefore cannot
  1087. // be either STATIC nor INLINE
  1088. // static to make debugging more difficult in the shipping versions.
  1089. //
  1090. // These exports return one of only three NTSTATUS values:
  1091. // STATUS_SUCCESS
  1092. // STATUS_UNSUCCESSFUL
  1093. // STATUS_LICENSE_VIOLATION
  1094. //
  1095. ////////////////////////////////////////////////////////////////////////////////
  1096. NTSTATUS
  1097. CdRomGetRpc0Settings(
  1098. IN PDEVICE_OBJECT Fdo
  1099. )
  1100. {
  1101. PCOMMON_DEVICE_EXTENSION commonExtension = Fdo->DeviceExtension;
  1102. PCDROM_DATA cddata = (PCDROM_DATA)(commonExtension->DriverData);
  1103. NTSTATUS status;
  1104. KeWaitForMutexObject(&cddata->Rpc0RegionMutex, UserRequest, KernelMode,
  1105. FALSE, NULL);
  1106. status = SecureDvdReadOrWriteRegionAndResetCount(Fdo, 0, TRUE);
  1107. KeReleaseMutex(&cddata->Rpc0RegionMutex, FALSE);
  1108. return status;
  1109. }
  1110. NTSTATUS
  1111. CdRomSetRpc0Settings(
  1112. IN PDEVICE_OBJECT Fdo,
  1113. IN UCHAR NewRegion
  1114. )
  1115. {
  1116. PCOMMON_DEVICE_EXTENSION commonExtension = Fdo->DeviceExtension;
  1117. PCDROM_DATA cddata = (PCDROM_DATA)(commonExtension->DriverData);
  1118. NTSTATUS status;
  1119. KeWaitForMutexObject(&cddata->Rpc0RegionMutex, UserRequest, KernelMode,
  1120. FALSE, NULL);
  1121. status = SecureDvdReadOrWriteRegionAndResetCount(Fdo, NewRegion, FALSE);
  1122. KeReleaseMutex(&cddata->Rpc0RegionMutex, FALSE);
  1123. return status;
  1124. }
  1125. #if 0
  1126. // @@END_DDKSPLIT
  1127. NTSTATUS
  1128. CdRomGetRpc0Settings(
  1129. IN PDEVICE_OBJECT Fdo
  1130. )
  1131. {
  1132. PCOMMON_DEVICE_EXTENSION commonExtension = Fdo->DeviceExtension;
  1133. PCDROM_DATA cddata = (PCDROM_DATA)(commonExtension->DriverData);
  1134. cddata->Rpc0SystemRegion = (UCHAR)(~1); // region one
  1135. cddata->Rpc0SystemRegionResetCount = 0; // no resets
  1136. return STATUS_SUCCESS;
  1137. }
  1138. NTSTATUS
  1139. CdRomSetRpc0Settings(
  1140. IN PDEVICE_OBJECT Fdo,
  1141. IN UCHAR NewRegion
  1142. )
  1143. {
  1144. return STATUS_SUCCESS;
  1145. }
  1146. // @@BEGIN_DDKSPLIT
  1147. #endif // 0 -- DDK stub for all the stuff we do...
  1148. // @@END_DDKSPLIT