Source code of Windows XP (NT5)
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.

1842 lines
54 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. regprintres.cpp
  5. Abstract:
  6. This file contains the implementation of the member functions
  7. of PRINT_MANAGER class.
  8. Author:
  9. Jaime Sasson (jaimes) 18-Sep-1991
  10. Environment:
  11. Ulib, Regedit, Windows, User Mode
  12. --*/
  13. #include "regprintres.h"
  14. #include "array.hxx"
  15. #include "regsys.hxx"
  16. #include "iterator.hxx"
  17. #include "regresid.h"
  18. extern "C"
  19. {
  20. // from regprint.c
  21. void PrintBinaryData(PBYTE ValueData, UINT cbcbValueData);
  22. void PrintLiteral(PTSTR lpLiteral);
  23. void PrintNewLine();
  24. }
  25. BOOL PrintString(PWSTRING pwsString)
  26. {
  27. PrintLiteral((PTSTR)pwsString->GetWSTR());
  28. return TRUE;
  29. }
  30. void PrintResourceData(PBYTE pbData, UINT uSize, DWORD dwType)
  31. {
  32. PRINT_RESOURCE::_PrintResources(pbData, uSize, dwType);
  33. }
  34. BOOL PRINT_RESOURCE::s_StringsInitialized = FALSE;
  35. PWSTRING PRINT_RESOURCE::s_IndentString;
  36. PWSTRING PRINT_RESOURCE::s_StringFullDescriptor;
  37. PWSTRING PRINT_RESOURCE::s_StringInterfaceType;
  38. PWSTRING PRINT_RESOURCE::s_StringBusNumber;
  39. PWSTRING PRINT_RESOURCE::s_StringVersion;
  40. PWSTRING PRINT_RESOURCE::s_StringRevision;
  41. PWSTRING PRINT_RESOURCE::s_StringPartialDescriptor;
  42. PWSTRING PRINT_RESOURCE::s_StringResource;
  43. PWSTRING PRINT_RESOURCE::s_StringDisposition;
  44. PWSTRING PRINT_RESOURCE::s_StringVector;
  45. PWSTRING PRINT_RESOURCE::s_StringLevel;
  46. PWSTRING PRINT_RESOURCE::s_StringAffinity;
  47. PWSTRING PRINT_RESOURCE::s_StringType;
  48. PWSTRING PRINT_RESOURCE::s_StringStart;
  49. PWSTRING PRINT_RESOURCE::s_StringLength;
  50. PWSTRING PRINT_RESOURCE::s_StringChannel;
  51. PWSTRING PRINT_RESOURCE::s_StringPort;
  52. PWSTRING PRINT_RESOURCE::s_StringReserved1;
  53. PWSTRING PRINT_RESOURCE::s_StringReserved2;
  54. PWSTRING PRINT_RESOURCE::s_StringDevSpecificData;
  55. PWSTRING PRINT_RESOURCE::s_StringIoInterfaceType;
  56. PWSTRING PRINT_RESOURCE::s_StringIoBusNumber;
  57. PWSTRING PRINT_RESOURCE::s_StringIoSlotNumber;
  58. PWSTRING PRINT_RESOURCE::s_StringIoListNumber;
  59. PWSTRING PRINT_RESOURCE::s_StringIoDescriptorNumber;
  60. PWSTRING PRINT_RESOURCE::s_StringIoOption;
  61. PWSTRING PRINT_RESOURCE::s_StringIoMinimumVector;
  62. PWSTRING PRINT_RESOURCE::s_StringIoMaximumVector;
  63. PWSTRING PRINT_RESOURCE::s_StringIoMinimumAddress;
  64. PWSTRING PRINT_RESOURCE::s_StringIoMaximumAddress;
  65. PWSTRING PRINT_RESOURCE::s_StringIoAlignment;
  66. PWSTRING PRINT_RESOURCE::s_StringIoMinimumChannel;
  67. PWSTRING PRINT_RESOURCE::s_StringIoMaximumChannel;
  68. //------------------------------------------------------------------------------
  69. // PrintResources
  70. //
  71. // DESCRIPTION: Prints a resouce by type
  72. //
  73. //------------------------------------------------------------------------------
  74. void PRINT_RESOURCE::_PrintResources(PBYTE pbData, UINT uSize, DWORD dwType)
  75. {
  76. if(!s_StringsInitialized)
  77. {
  78. s_StringsInitialized = _InitializeStrings();
  79. }
  80. if (s_StringsInitialized)
  81. {
  82. switch (dwType)
  83. {
  84. case REG_RESOURCE_LIST:
  85. _PrintDataRegResourceList(pbData, uSize);
  86. break;
  87. case REG_FULL_RESOURCE_DESCRIPTOR:
  88. {
  89. FULL_DESCRIPTOR FullDescriptor;
  90. if (FullDescriptor.Initialize(pbData, uSize))
  91. {
  92. _PrintFullResourceDescriptor(&FullDescriptor, 0, FALSE);
  93. }
  94. }
  95. break;
  96. case REG_RESOURCE_REQUIREMENTS_LIST:
  97. _PrintDataRegRequirementsList(pbData, uSize);
  98. break;
  99. default:
  100. PrintBinaryData(pbData, uSize);
  101. break;
  102. }
  103. }
  104. }
  105. //------------------------------------------------------------------------------
  106. // PrintDataRegResourceList
  107. //
  108. // DESCRIPTION: Initializes the static strings.
  109. //
  110. //------------------------------------------------------------------------------
  111. BOOL PRINT_RESOURCE::_InitializeStrings()
  112. {
  113. PWSTR Buffer;
  114. ULONG Size;
  115. ULONG Count;
  116. BOOLEAN fSuccess = TRUE;
  117. s_IndentString = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_KEY_NAME_INDENT, "" );
  118. s_StringFullDescriptor = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_FULL_DESCRIPTOR, "" );
  119. s_StringPartialDescriptor = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_PARTIAL_DESCRIPTOR, "" );
  120. s_StringInterfaceType = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_INTERFACE_TYPE, "" );
  121. s_StringBusNumber = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_BUS_NUMBER, "" );
  122. s_StringVersion = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_VERSION, "" );
  123. s_StringRevision = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_REVISION, "" );
  124. s_StringResource = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_RESOURCE, "" );
  125. s_StringDisposition = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_DISPOSITION, "" );
  126. s_StringType = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_IO_TYPE, "" );
  127. s_StringStart = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_START, "" );
  128. s_StringLength = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_LENGTH, "" );
  129. s_StringLevel = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_LEVEL, "" );
  130. s_StringVector = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_VECTOR, "" );
  131. s_StringAffinity = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_AFFINITY, "" );
  132. s_StringChannel = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_CHANNEL, "" );
  133. s_StringPort = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_PORT, "" );
  134. s_StringReserved1 = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_RESERVED1, "" );
  135. s_StringReserved2 = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_RESERVED2, "" );
  136. s_StringDevSpecificData = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_DEV_SPECIFIC_DATA, "" );
  137. s_StringIoInterfaceType = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_IO_INTERFACE_TYPE, "" );
  138. s_StringIoBusNumber = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_IO_BUS_NUMBER, "" );
  139. s_StringIoSlotNumber = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_IO_SLOT_NUMBER, "" );
  140. s_StringIoListNumber = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_IO_LIST_NUMBER, "" );
  141. s_StringIoOption = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_IO_OPTION, "" );
  142. s_StringIoDescriptorNumber = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_IO_DESCRIPTOR_NUMBER, "" );
  143. s_StringIoAlignment = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_IO_ALIGNMENT, "" );
  144. s_StringIoMinimumAddress = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_IO_MINIMUM_ADDRESS, "" );
  145. s_StringIoMaximumAddress = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_IO_MAXIMUM_ADDRESS, "" );
  146. s_StringIoMinimumVector = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_IO_MINIMUM_VECTOR, "" );
  147. s_StringIoMaximumVector = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_IO_MAXIMUM_VECTOR, "" );
  148. s_StringIoMinimumChannel = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_IO_MINIMUM_CHANNEL, "" );
  149. s_StringIoMaximumChannel = REGEDIT_BASE_SYSTEM::QueryString(IDS_PRINT_IO_MAXIMUM_CHANNEL, "" );
  150. if ((s_StringFullDescriptor == NULL) ||
  151. (s_StringPartialDescriptor == NULL) ||
  152. (s_StringInterfaceType == NULL) ||
  153. (s_StringBusNumber == NULL) ||
  154. (s_StringVersion == NULL) ||
  155. (s_StringRevision == NULL) ||
  156. (s_StringResource == NULL) ||
  157. (s_StringDisposition == NULL) ||
  158. (s_StringType == NULL) ||
  159. (s_StringStart == NULL) ||
  160. (s_StringLength == NULL) ||
  161. (s_StringLevel == NULL) ||
  162. (s_StringVector == NULL) ||
  163. (s_StringAffinity == NULL) ||
  164. (s_StringChannel == NULL) ||
  165. (s_StringPort == NULL) ||
  166. (s_StringReserved1 == NULL) ||
  167. (s_StringReserved2 == NULL) ||
  168. (s_StringDevSpecificData == NULL) ||
  169. (s_StringIoInterfaceType == NULL) ||
  170. (s_StringIoBusNumber == NULL) ||
  171. (s_StringIoSlotNumber == NULL) ||
  172. (s_StringIoListNumber == NULL) ||
  173. (s_StringIoOption == NULL) ||
  174. (s_StringIoDescriptorNumber == NULL) ||
  175. (s_StringIoAlignment == NULL) ||
  176. (s_StringIoMinimumAddress == NULL) ||
  177. (s_StringIoMaximumAddress == NULL) ||
  178. (s_StringIoMinimumVector == NULL) ||
  179. (s_StringIoMaximumVector == NULL) ||
  180. (s_StringIoMinimumChannel == NULL) ||
  181. (s_StringIoMaximumChannel == NULL))
  182. {
  183. DELETE(s_StringFullDescriptor);
  184. DELETE(s_StringPartialDescriptor);
  185. DELETE(s_StringInterfaceType);
  186. DELETE(s_StringBusNumber);
  187. DELETE(s_StringVersion);
  188. DELETE(s_StringRevision);
  189. DELETE(s_StringResource);
  190. DELETE(s_StringDisposition);
  191. DELETE(s_StringType);
  192. DELETE(s_StringStart);
  193. DELETE(s_StringLength);
  194. DELETE(s_StringLevel);
  195. DELETE(s_StringVector);
  196. DELETE(s_StringAffinity);
  197. DELETE(s_StringChannel);
  198. DELETE(s_StringPort);
  199. DELETE(s_StringReserved1);
  200. DELETE(s_StringReserved2);
  201. DELETE(s_StringDevSpecificData);
  202. DELETE(s_StringIoInterfaceType);
  203. DELETE(s_StringIoBusNumber);
  204. DELETE(s_StringIoSlotNumber);
  205. DELETE(s_StringIoListNumber);
  206. DELETE(s_StringIoOption);
  207. DELETE(s_StringIoDescriptorNumber);
  208. DELETE(s_StringIoAlignment);
  209. DELETE(s_StringIoMinimumAddress);
  210. DELETE(s_StringIoMaximumAddress);
  211. DELETE(s_StringIoMinimumVector);
  212. DELETE(s_StringIoMaximumVector);
  213. DELETE(s_StringIoMinimumChannel);
  214. DELETE(s_StringIoMaximumChannel);
  215. fSuccess = FALSE;
  216. }
  217. return fSuccess;
  218. }
  219. //------------------------------------------------------------------------------
  220. // PrintDataRegResourceList
  221. //
  222. // DESCRIPTION: Print a REG_RESOURCE_LIST stored in a value entry of a registry
  223. // key.
  224. // PARAMETERS: Data - Pointer to the buffer that contais a REG_RESOURCE_LIST
  225. // data.
  226. // Size - Number of bytes in the buffer.
  227. //------------------------------------------------------------------------------
  228. void PRINT_RESOURCE::_PrintDataRegResourceList(PBYTE Data, UINT Size)
  229. {
  230. RESOURCE_LIST ResourceList;
  231. PARRAY FullResourceDescriptors;
  232. PITERATOR Iterator;
  233. PCFULL_DESCRIPTOR FullDescriptor;
  234. ULONG DescriptorNumber;
  235. PrintNewLine();
  236. if( ( Size == 0 ) ||
  237. ( Data == NULL ) ||
  238. !ResourceList.Initialize( Data, Size ) )
  239. {
  240. return;
  241. }
  242. if( ( ( FullResourceDescriptors = ResourceList.GetFullResourceDescriptors() ) == NULL ) ||
  243. ( ( Iterator = FullResourceDescriptors->QueryIterator() ) == NULL ) )
  244. {
  245. return;
  246. }
  247. DescriptorNumber = 0;
  248. while( ( FullDescriptor = ( PCFULL_DESCRIPTOR )( Iterator->GetNext() ) ) != NULL )
  249. {
  250. if( !_PrintFullResourceDescriptor( FullDescriptor, DescriptorNumber ) )
  251. {
  252. DELETE( Iterator );
  253. return;
  254. }
  255. DescriptorNumber++;
  256. }
  257. DELETE( Iterator );
  258. return;
  259. }
  260. //------------------------------------------------------------------------------
  261. // PrintFullResourceDescriptor
  262. //
  263. // DESCRIPTION: Print the contents of a FULL_DESCRIPTOR object.
  264. //
  265. // PARAMETERS: FullDescriptor - Pointer to object to be printed.
  266. // DescriptorNumber -
  267. // PrintDescriptorNumber - A flag that indicates whether or not the
  268. // descriptor number should be printed.
  269. //------------------------------------------------------------------------------
  270. BOOL PRINT_RESOURCE::_PrintFullResourceDescriptor(PCFULL_DESCRIPTOR FullDescriptor,
  271. UINT DescriptorNumber, BOOL PrintDescriptorNumber)
  272. {
  273. DSTRING FullDescriptorNumberString;
  274. DSTRING AuxString;
  275. DSTRING InterfaceType;
  276. DSTRING BusNumber;
  277. DSTRING Version;
  278. DSTRING Revision;
  279. WCHAR AuxNumber[11];
  280. PWSTRING TypeString;
  281. ULONG InterfaceId;
  282. PARRAY Descriptors;
  283. PITERATOR Iterator;
  284. PCPARTIAL_DESCRIPTOR PartialDescriptor;
  285. ULONG Count;
  286. if( !FullDescriptorNumberString.Initialize( s_IndentString ) ||
  287. !FullDescriptorNumberString.Strcat( s_StringFullDescriptor ) ||
  288. !InterfaceType.Initialize( s_IndentString ) ||
  289. !InterfaceType.Strcat( s_StringInterfaceType ) ||
  290. !BusNumber.Initialize( s_IndentString ) ||
  291. !BusNumber.Strcat( s_StringBusNumber ) ||
  292. !Version.Initialize( s_IndentString ) ||
  293. !Version.Strcat( s_StringVersion ) ||
  294. !Revision.Initialize( s_IndentString ) ||
  295. !Revision.Strcat( s_StringRevision )
  296. )
  297. {
  298. return FALSE;
  299. }
  300. //
  301. // Build a string that contains the full descriptor number
  302. // and print it
  303. //
  304. if( PrintDescriptorNumber ) {
  305. wsprintf( AuxNumber, (LPWSTR)L"%d", DescriptorNumber );
  306. if( !AuxString.Initialize( AuxNumber ) )
  307. {
  308. return FALSE;
  309. }
  310. FullDescriptorNumberString.Strcat( &AuxString );
  311. if( !PrintString( &FullDescriptorNumberString ) )
  312. {
  313. return FALSE;
  314. }
  315. }
  316. PrintNewLine();
  317. //
  318. // Print the interface type
  319. switch( FullDescriptor->GetInterfaceType() )
  320. {
  321. case Internal:
  322. InterfaceId = IDS_BUS_INTERNAL;
  323. break;
  324. case Isa:
  325. InterfaceId = IDS_BUS_ISA;
  326. break;
  327. case Eisa:
  328. InterfaceId = IDS_BUS_EISA;
  329. break;
  330. case MicroChannel:
  331. InterfaceId = IDS_BUS_MICRO_CHANNEL;
  332. break;
  333. case TurboChannel:
  334. InterfaceId = IDS_BUS_TURBO_CHANNEL;
  335. break;
  336. case PCIBus:
  337. InterfaceId = IDS_BUS_PCI_BUS;
  338. break;
  339. case VMEBus:
  340. InterfaceId = IDS_BUS_VME_BUS;
  341. break;
  342. case NuBus:
  343. InterfaceId = IDS_BUS_NU_BUS;
  344. break;
  345. case PCMCIABus:
  346. InterfaceId = IDS_BUS_PCMCIA_BUS;
  347. break;
  348. case CBus:
  349. InterfaceId = IDS_BUS_C_BUS;
  350. break;
  351. case MPIBus:
  352. InterfaceId = IDS_BUS_MPI_BUS;
  353. break;
  354. case MPSABus:
  355. InterfaceId = IDS_BUS_MPSA_BUS;
  356. break;
  357. default:
  358. InterfaceId = IDS_INVALID;
  359. break;
  360. }
  361. TypeString = REGEDIT_BASE_SYSTEM::QueryString( InterfaceId, "" );
  362. if( TypeString == NULL )
  363. {
  364. return FALSE;
  365. }
  366. InterfaceType.Strcat( TypeString );
  367. DELETE( TypeString );
  368. if(!PrintString( &InterfaceType ))
  369. {
  370. return FALSE;
  371. }
  372. PrintNewLine();
  373. //
  374. // Print the bus number
  375. //
  376. wsprintf( AuxNumber, (LPWSTR)L"%d", FullDescriptor->GetBusNumber() );
  377. if( !AuxString.Initialize( AuxNumber ) )
  378. {
  379. return FALSE;
  380. }
  381. BusNumber.Strcat( &AuxString );
  382. if( !PrintString( &BusNumber ) )
  383. {
  384. return FALSE;
  385. }
  386. PrintNewLine();
  387. //
  388. // Print version
  389. //
  390. wsprintf( AuxNumber, (LPWSTR)L"%d", FullDescriptor->GetVersion() );
  391. if( !AuxString.Initialize( AuxNumber ) )
  392. {
  393. return FALSE;
  394. }
  395. Version.Strcat( &AuxString );
  396. if( !PrintString( &Version ) )
  397. {
  398. return FALSE;
  399. }
  400. PrintNewLine();
  401. //
  402. // Print revision
  403. //
  404. wsprintf( AuxNumber, (LPWSTR)L"%d", FullDescriptor->GetRevision() );
  405. if( !AuxString.Initialize( AuxNumber ) )
  406. {
  407. return FALSE;
  408. }
  409. Revision.Strcat( &AuxString );
  410. if( !PrintString( &Revision ) )
  411. {
  412. return FALSE;
  413. }
  414. PrintNewLine();
  415. Descriptors = FullDescriptor->GetResourceDescriptors();
  416. if( ( Descriptors == NULL ) ||
  417. ( ( Iterator = Descriptors->QueryIterator() ) == NULL )
  418. )
  419. {
  420. return FALSE;
  421. }
  422. Count = 0;
  423. while( ( PartialDescriptor = ( PCPARTIAL_DESCRIPTOR )( Iterator->GetNext() ) ) != NULL )
  424. {
  425. if( !_PrintPartialDescriptor( PartialDescriptor, Count ) )
  426. {
  427. DELETE( Iterator );
  428. return FALSE;
  429. }
  430. Count++;
  431. }
  432. DELETE( Iterator );
  433. PrintNewLine();
  434. return TRUE;
  435. }
  436. //------------------------------------------------------------------------------
  437. // PrintPartialDescriptor
  438. //
  439. // DESCRIPTION: Print the contents of a PARTIAL_DESCRIPTOR object.
  440. //
  441. // PARAMETERS: PartialDescriptor - Pointer to object to be printed.
  442. // DescriptorNumber -
  443. //------------------------------------------------------------------------------
  444. BOOL PRINT_RESOURCE::_PrintPartialDescriptor(PCPARTIAL_DESCRIPTOR PartialDescriptor,
  445. ULONG DescriptorNumber)
  446. {
  447. DSTRING PartialDescriptorNumberString;
  448. DSTRING AuxString;
  449. WCHAR AuxNumber[11];
  450. DSTRING ResourceString;
  451. DSTRING DispositionString;
  452. ULONG StringId;
  453. PWSTRING String;
  454. if( !PartialDescriptorNumberString.Initialize( s_IndentString ) ||
  455. !PartialDescriptorNumberString.Strcat( s_StringPartialDescriptor ) ||
  456. !ResourceString.Initialize( s_IndentString ) ||
  457. !ResourceString.Strcat( s_StringResource ) ||
  458. !DispositionString.Initialize( s_IndentString ) ||
  459. !DispositionString.Strcat( s_StringDisposition )
  460. )
  461. {
  462. return FALSE;
  463. }
  464. //
  465. // Build a string that contains the full descriptor number
  466. // and print it
  467. //
  468. wsprintf( AuxNumber, (LPWSTR)L"%d", DescriptorNumber );
  469. if( !AuxString.Initialize( AuxNumber ) )
  470. {
  471. return FALSE;
  472. }
  473. PartialDescriptorNumberString.Strcat( &AuxString );
  474. if( !PrintString( &PartialDescriptorNumberString ) )
  475. {
  476. return FALSE;
  477. }
  478. PrintNewLine();
  479. //
  480. // Print the resource type
  481. //
  482. if( PartialDescriptor->IsDescriptorTypeDma() ) {
  483. StringId = IDS_DEV_DMA;
  484. } else if( PartialDescriptor->IsDescriptorTypeInterrupt() ) {
  485. StringId = IDS_DEV_INTERRUPT;
  486. } else if( PartialDescriptor->IsDescriptorTypeMemory() ) {
  487. StringId = IDS_DEV_MEMORY;
  488. } else if( PartialDescriptor->IsDescriptorTypePort() ) {
  489. StringId = IDS_DEV_PORT;
  490. } else if( PartialDescriptor->IsDescriptorTypeDeviceSpecific() ) {
  491. StringId = IDS_DEV_DEVICE_SPECIFIC;
  492. } else {
  493. StringId = IDS_INVALID;
  494. }
  495. String = REGEDIT_BASE_SYSTEM::QueryString( StringId, "" );
  496. if( String == NULL )
  497. {
  498. return FALSE;
  499. }
  500. ResourceString.Strcat( String );
  501. DELETE( String );
  502. if( !PrintString( &ResourceString ) )
  503. {
  504. return FALSE;
  505. }
  506. PrintNewLine();
  507. //
  508. // Print the disposition
  509. //
  510. if( PartialDescriptor->IsResourceShareUndetermined() ) {
  511. StringId = IDS_SHARE_UNDETERMINED;
  512. } else if( PartialDescriptor->IsResourceShareDeviceExclusive() ) {
  513. StringId = IDS_SHARE_DEVICE_EXCLUSIVE;
  514. } else if( PartialDescriptor->IsResourceShareDriverExclusive() ) {
  515. StringId = IDS_SHARE_DRIVER_EXCLUSIVE;
  516. } else {
  517. StringId = IDS_SHARE_SHARED;
  518. }
  519. String = REGEDIT_BASE_SYSTEM::QueryString( StringId, "" );
  520. if( String == NULL )
  521. {
  522. return FALSE;
  523. }
  524. DispositionString.Strcat( String );
  525. DELETE( String );
  526. if( !PrintString( &DispositionString ) )
  527. {
  528. return FALSE;
  529. }
  530. PrintNewLine();
  531. if( PartialDescriptor->IsDescriptorTypeDma() )
  532. {
  533. if( !_PrintDmaDescriptor( ( PCDMA_DESCRIPTOR )PartialDescriptor ) )
  534. {
  535. return FALSE;
  536. }
  537. }
  538. else if( PartialDescriptor->IsDescriptorTypeInterrupt() )
  539. {
  540. if( !_PrintInterruptDescriptor( ( PCINTERRUPT_DESCRIPTOR )PartialDescriptor ) )
  541. {
  542. return FALSE;
  543. }
  544. }
  545. else if( PartialDescriptor->IsDescriptorTypeMemory() )
  546. {
  547. if( !_PrintMemoryDescriptor( ( PCMEMORY_DESCRIPTOR )PartialDescriptor ) )
  548. {
  549. return FALSE;
  550. }
  551. }
  552. else if( PartialDescriptor->IsDescriptorTypePort() )
  553. {
  554. if( !_PrintPortDescriptor( ( PCPORT_DESCRIPTOR )PartialDescriptor ) )
  555. {
  556. return FALSE;
  557. }
  558. }
  559. else if( PartialDescriptor->IsDescriptorTypeDeviceSpecific() )
  560. {
  561. if( !_PrintDeviceSpecificDescriptor( ( PCDEVICE_SPECIFIC_DESCRIPTOR )PartialDescriptor ) )
  562. {
  563. return FALSE;
  564. }
  565. }
  566. PrintNewLine();
  567. return TRUE;
  568. }
  569. //------------------------------------------------------------------------------
  570. // PrintInterruptDescriptor
  571. //
  572. // DESCRIPTION: Print the contents of a INTERRUPT_DESCRIPTOR object.
  573. //
  574. // PARAMETERS: Descriptor - Pointer to object to be printed.
  575. //------------------------------------------------------------------------------
  576. BOOL PRINT_RESOURCE::_PrintInterruptDescriptor(PCINTERRUPT_DESCRIPTOR Descriptor)
  577. {
  578. DSTRING VectorString;
  579. DSTRING LevelString;
  580. DSTRING AffinityString;;
  581. DSTRING TypeString;
  582. DSTRING AuxString;
  583. WCHAR AuxNumber[19];
  584. ULONG StringId;
  585. PWSTRING String;
  586. if( !VectorString.Initialize( s_IndentString ) ||
  587. !VectorString.Strcat( s_StringVector ) ||
  588. !LevelString.Initialize( s_IndentString ) ||
  589. !LevelString.Strcat( s_StringLevel ) ||
  590. !AffinityString.Initialize( s_IndentString ) ||
  591. !AffinityString.Strcat( s_StringAffinity ) ||
  592. !TypeString.Initialize( s_IndentString ) ||
  593. !TypeString.Strcat( s_StringType )
  594. )
  595. {
  596. return FALSE;
  597. }
  598. //
  599. // Print the vector
  600. //
  601. wsprintf( AuxNumber, (LPWSTR)L"%d", Descriptor->GetVector() );
  602. if( !AuxString.Initialize( AuxNumber ) )
  603. {
  604. return FALSE;
  605. }
  606. VectorString.Strcat( &AuxString );
  607. if( !PrintString( &VectorString ) )
  608. {
  609. return FALSE;
  610. }
  611. PrintNewLine();
  612. //
  613. // Print the level
  614. //
  615. wsprintf( AuxNumber, (LPWSTR)L"%d", Descriptor->GetLevel() );
  616. if( !AuxString.Initialize( AuxNumber ) )
  617. {
  618. return FALSE;
  619. }
  620. LevelString.Strcat( &AuxString );
  621. if( !PrintString( &LevelString ) )
  622. {
  623. return FALSE;
  624. }
  625. PrintNewLine();
  626. //
  627. // Print the affinity
  628. //
  629. wsprintf( AuxNumber, (LPWSTR)L"0x%08x", Descriptor->GetAffinity() );
  630. if( !AuxString.Initialize( AuxNumber ) )
  631. {
  632. return FALSE;
  633. }
  634. AffinityString.Strcat( &AuxString );
  635. if( !PrintString( &AffinityString ) )
  636. {
  637. return FALSE;
  638. }
  639. PrintNewLine();
  640. // Print the type
  641. StringId = ( Descriptor->IsInterruptLevelSensitive() )? IDS_INT_LEVEL_SENSITIVE :
  642. IDS_INT_LATCHED;
  643. String = REGEDIT_BASE_SYSTEM::QueryString( StringId, "" );
  644. if( String == NULL )
  645. {
  646. return FALSE;
  647. }
  648. TypeString.Strcat( String );
  649. DELETE( String );
  650. if( !PrintString( &TypeString ) )
  651. {
  652. return FALSE;
  653. }
  654. PrintNewLine();
  655. return TRUE;
  656. }
  657. //------------------------------------------------------------------------------
  658. // PrintPortDescriptor
  659. //
  660. // DESCRIPTION: Print the contents of a PORT_DESCRIPTOR object.
  661. //
  662. // PARAMETERS: Descriptor - Pointer to object to be printed.
  663. //------------------------------------------------------------------------------
  664. BOOL PRINT_RESOURCE::_PrintPortDescriptor(PCPORT_DESCRIPTOR Descriptor)
  665. {
  666. DSTRING StartAddressString;
  667. DSTRING LengthString;
  668. DSTRING TypeString;
  669. DSTRING AuxString;
  670. WCHAR AuxNumber[19];
  671. ULONG StringId;
  672. PWSTRING String;
  673. if( !StartAddressString.Initialize( s_IndentString ) ||
  674. !StartAddressString.Strcat( s_StringStart ) ||
  675. !LengthString.Initialize( s_IndentString ) ||
  676. !LengthString.Strcat( s_StringLength ) ||
  677. !TypeString.Initialize( s_IndentString ) ||
  678. !TypeString.Strcat( s_StringType )
  679. ) {
  680. DebugPrint( "REGEDT32: Initialization failure" );
  681. return FALSE;
  682. }
  683. //
  684. // Print the start address
  685. //
  686. if( ( ( ( PPORT_DESCRIPTOR )Descriptor )->GetPhysicalAddress() )->HighPart != 0 ) {
  687. wsprintf( AuxNumber,
  688. (LPWSTR)L"0x%08x%08x",
  689. ( ( ( PPORT_DESCRIPTOR )Descriptor )->GetPhysicalAddress() )->HighPart,
  690. ( ( ( PPORT_DESCRIPTOR )Descriptor )->GetPhysicalAddress() )->LowPart );
  691. } else {
  692. wsprintf( AuxNumber, (LPWSTR)L"0x%08x", ( ( ( PPORT_DESCRIPTOR )Descriptor )->GetPhysicalAddress() )->LowPart );
  693. }
  694. if( !AuxString.Initialize( AuxNumber ) ) {
  695. DebugPrint( "AuxString.Initialize() failed" );
  696. return FALSE;
  697. }
  698. StartAddressString.Strcat( &AuxString );
  699. if( !PrintString( &StartAddressString ) ) {
  700. return FALSE;
  701. }
  702. PrintNewLine();
  703. //
  704. // Print the length
  705. //
  706. wsprintf( AuxNumber, (LPWSTR)L"%#x", Descriptor->GetLength() );
  707. if( !AuxString.Initialize( AuxNumber ) ) {
  708. DebugPrint( "AuxString.Initialize() failed" );
  709. return FALSE;
  710. }
  711. LengthString.Strcat( &AuxString );
  712. if( !PrintString( &LengthString ) ) {
  713. return FALSE;
  714. }
  715. PrintNewLine();
  716. //
  717. // Print the type
  718. //
  719. StringId = ( Descriptor->IsPortMemory() )? IDS_PORT_MEMORY :
  720. IDS_PORT_PORT;
  721. String = REGEDIT_BASE_SYSTEM::QueryString( StringId, "" );
  722. if( String == NULL ) {
  723. DebugPrintTrace(( "REGEDT32: Unable to retrieve string \n" ));
  724. return FALSE;
  725. }
  726. TypeString.Strcat( String );
  727. DELETE( String );
  728. if( !PrintString( &TypeString ) ) {
  729. return FALSE;
  730. }
  731. PrintNewLine();
  732. return TRUE;
  733. }
  734. //------------------------------------------------------------------------------
  735. // PrintMemoryDescriptor
  736. //
  737. // DESCRIPTION: Print the contents of a MEMORY_DESCRIPTOR object.
  738. //
  739. // PARAMETERS: Descriptor - Pointer to object to be printed.
  740. //------------------------------------------------------------------------------
  741. BOOL PRINT_RESOURCE::_PrintMemoryDescriptor(PCMEMORY_DESCRIPTOR Descriptor)
  742. {
  743. DSTRING StartAddressString;
  744. DSTRING LengthString;
  745. DSTRING TypeString;
  746. DSTRING AuxString;
  747. WCHAR AuxNumber[19];
  748. ULONG StringId;
  749. PWSTRING String;
  750. if( !StartAddressString.Initialize( s_IndentString ) ||
  751. !StartAddressString.Strcat( s_StringStart ) ||
  752. !LengthString.Initialize( s_IndentString ) ||
  753. !LengthString.Strcat( s_StringLength ) ||
  754. !TypeString.Initialize( s_IndentString ) ||
  755. !TypeString.Strcat( s_StringType )
  756. ) {
  757. DebugPrint( "REGEDT32: Initialization failure" );
  758. return FALSE;
  759. }
  760. //
  761. // Print the start address
  762. //
  763. if( ( ( ( PMEMORY_DESCRIPTOR )Descriptor )->GetStartAddress() )->HighPart != 0 ) {
  764. wsprintf( AuxNumber,
  765. (LPWSTR)L"0x%08x%08x",
  766. ( ( ( PMEMORY_DESCRIPTOR )Descriptor )->GetStartAddress() )->HighPart,
  767. ( ( ( PMEMORY_DESCRIPTOR )Descriptor )->GetStartAddress() )->LowPart );
  768. } else {
  769. wsprintf( AuxNumber, (LPWSTR)L"0x%08x", ( ( ( PMEMORY_DESCRIPTOR )Descriptor )->GetStartAddress() )->LowPart );
  770. }
  771. if( !AuxString.Initialize( AuxNumber ) ) {
  772. DebugPrint( "AuxString.Initialize() failed" );
  773. return FALSE;
  774. }
  775. StartAddressString.Strcat( &AuxString );
  776. if( !PrintString( &StartAddressString ) ) {
  777. return FALSE;
  778. }
  779. PrintNewLine();
  780. //
  781. // Print the length
  782. //
  783. wsprintf( AuxNumber, (LPWSTR)L"%#x", Descriptor->GetLength() );
  784. if( !AuxString.Initialize( AuxNumber ) ) {
  785. DebugPrint( "AuxString.Initialize() failed" );
  786. return FALSE;
  787. }
  788. LengthString.Strcat( &AuxString );
  789. if( !PrintString( &LengthString ) ) {
  790. return FALSE;
  791. }
  792. PrintNewLine();
  793. //
  794. // Print the type
  795. //
  796. StringId = ( Descriptor->IsMemoryReadWrite() )? IDS_MEM_READ_WRITE :
  797. ( ( Descriptor->IsMemoryReadWrite() )? IDS_MEM_READ_ONLY :
  798. IDS_MEM_WRITE_ONLY );
  799. String = REGEDIT_BASE_SYSTEM::QueryString( StringId, "" );
  800. if( String == NULL ) {
  801. DebugPrintTrace(( "REGEDT32: Unable to retrieve string \n" ));
  802. return FALSE;
  803. }
  804. TypeString.Strcat( String );
  805. DELETE( String );
  806. if( !PrintString( &TypeString ) ) {
  807. return FALSE;
  808. }
  809. PrintNewLine();
  810. return TRUE;
  811. }
  812. //------------------------------------------------------------------------------
  813. // PrintDmaDescriptor
  814. //
  815. // DESCRIPTION: Print the contents of a DMA_DESCRIPTOR object.
  816. //
  817. // PARAMETERS: Descriptor - Pointer to object to be printed.
  818. //------------------------------------------------------------------------------
  819. BOOL PRINT_RESOURCE::_PrintDmaDescriptor(PCDMA_DESCRIPTOR Descriptor)
  820. {
  821. DSTRING ChannelString;
  822. DSTRING PortString;
  823. DSTRING AuxString;
  824. WCHAR AuxNumber[19];
  825. if( !ChannelString.Initialize( s_IndentString ) ||
  826. !ChannelString.Strcat( s_StringChannel ) ||
  827. !PortString.Initialize( s_IndentString ) ||
  828. !PortString.Strcat( s_StringPort )
  829. ) {
  830. DebugPrint( "REGEDT32: Initialization failure" );
  831. return FALSE;
  832. }
  833. //
  834. // Print the channel
  835. //
  836. wsprintf( AuxNumber, (LPWSTR)L"%d", Descriptor->GetChannel() );
  837. if( !AuxString.Initialize( AuxNumber ) ) {
  838. DebugPrint( "AuxString.Initialize() failed" );
  839. return FALSE;
  840. }
  841. ChannelString.Strcat( &AuxString );
  842. if( !PrintString( &ChannelString ) ) {
  843. return FALSE;
  844. }
  845. PrintNewLine();
  846. //
  847. // Print the port
  848. //
  849. wsprintf( AuxNumber, (LPWSTR)L"%d", Descriptor->GetPort() );
  850. if( !AuxString.Initialize( AuxNumber ) ) {
  851. DebugPrint( "AuxString.Initialize() failed" );
  852. return FALSE;
  853. }
  854. PortString.Strcat( &AuxString );
  855. if( !PrintString( &PortString ) ) {
  856. return FALSE;
  857. }
  858. PrintNewLine();
  859. return TRUE;
  860. }
  861. //------------------------------------------------------------------------------
  862. // PrintDeviceSpecificDescriptor
  863. //
  864. // DESCRIPTION: Print the contents of a DEVICE_SPECIFIC_DESCRIPTOR object.
  865. //
  866. // PARAMETERS: Descriptor - Pointer to object to be printed.
  867. //------------------------------------------------------------------------------
  868. BOOL PRINT_RESOURCE::_PrintDeviceSpecificDescriptor(PCDEVICE_SPECIFIC_DESCRIPTOR Descriptor)
  869. {
  870. DSTRING Reserved1String;
  871. DSTRING Reserved2String;
  872. DSTRING DataString;
  873. DSTRING AuxString;
  874. WCHAR AuxNumber[19];
  875. ULONG Size;
  876. PCBYTE Data;
  877. if( !Reserved1String.Initialize( s_IndentString ) ||
  878. !Reserved1String.Strcat( s_StringReserved1 ) ||
  879. !Reserved2String.Initialize( s_IndentString ) ||
  880. !Reserved2String.Strcat( s_StringReserved2 ) ||
  881. !DataString.Initialize( s_IndentString ) ||
  882. !DataString.Strcat( s_StringDevSpecificData )
  883. ) {
  884. DebugPrint( "REGEDT32: Initialization failure" );
  885. return FALSE;
  886. }
  887. //
  888. // Print reserved1
  889. //
  890. wsprintf( AuxNumber, (LPWSTR)L"0x%08x", Descriptor->GetReserved1() );
  891. if( !AuxString.Initialize( AuxNumber ) ) {
  892. DebugPrint( "AuxString.Initialize() failed" );
  893. return FALSE;
  894. }
  895. Reserved1String.Strcat( &AuxString );
  896. if( !PrintString( &Reserved1String ) ) {
  897. return FALSE;
  898. }
  899. PrintNewLine();
  900. //
  901. // Print reserved2
  902. //
  903. wsprintf( AuxNumber, (LPWSTR)L"0x%08x", Descriptor->GetReserved2() );
  904. if( !AuxString.Initialize( AuxNumber ) ) {
  905. DebugPrint( "AuxString.Initialize() failed" );
  906. return FALSE;
  907. }
  908. Reserved2String.Strcat( &AuxString );
  909. if( !PrintString( &Reserved2String ) ) {
  910. return FALSE;
  911. }
  912. PrintNewLine();
  913. Size = Descriptor->GetData( &Data );
  914. if( ( Size != 0 ) &&
  915. ( Data != NULL ) ) {
  916. if( !PrintString( &DataString ) )
  917. {
  918. return FALSE;
  919. }
  920. PrintBinaryData((PBYTE)Data, Size);
  921. PrintNewLine();
  922. }
  923. return TRUE;
  924. }
  925. //------------------------------------------------------------------------------
  926. // PrintDataRegRequirementsList
  927. //
  928. // DESCRIPTION: Print the contents of a DEVICE_SPECIFIC_DESCRIPTOR object.
  929. //
  930. // PARAMETERS:
  931. //------------------------------------------------------------------------------
  932. BOOL PRINT_RESOURCE::_PrintDataRegRequirementsList(PBYTE Data, ULONG Size)
  933. {
  934. IO_REQUIREMENTS_LIST RequirementsList;
  935. PARRAY AlternativeLists;
  936. PITERATOR Iterator;
  937. PCIO_DESCRIPTOR_LIST ResourceList;
  938. ULONG ListNumber;
  939. DSTRING AuxString;
  940. DSTRING InterfaceType;
  941. DSTRING BusNumber;
  942. DSTRING SlotNumber;
  943. WCHAR AuxNumber[11];
  944. PWSTRING TypeString;
  945. ULONG InterfaceId;
  946. PrintNewLine();
  947. if( ( Size == 0 ) ||
  948. ( Data == NULL ) ||
  949. !RequirementsList.Initialize( Data, Size ) ) {
  950. DebugPrintTrace(( "REGEDT32: Unable to initialize RequirementsList \n" ));
  951. return FALSE;
  952. }
  953. if( !InterfaceType.Initialize( s_IndentString ) ||
  954. !InterfaceType.Strcat( s_StringIoInterfaceType ) ||
  955. !BusNumber.Initialize( s_IndentString ) ||
  956. !BusNumber.Strcat( s_StringIoBusNumber ) ||
  957. !SlotNumber.Initialize( s_IndentString ) ||
  958. !SlotNumber.Strcat( s_StringIoSlotNumber )
  959. ) {
  960. DebugPrint( "REGEDT32: Initialization failure" );
  961. return FALSE;
  962. }
  963. //
  964. // Print the interface type
  965. //
  966. switch( RequirementsList.GetInterfaceType() ) {
  967. case Internal:
  968. InterfaceId = IDS_BUS_INTERNAL;
  969. break;
  970. case Isa:
  971. InterfaceId = IDS_BUS_ISA;
  972. break;
  973. case Eisa:
  974. InterfaceId = IDS_BUS_EISA;
  975. break;
  976. case MicroChannel:
  977. InterfaceId = IDS_BUS_MICRO_CHANNEL;
  978. break;
  979. case TurboChannel:
  980. InterfaceId = IDS_BUS_TURBO_CHANNEL;
  981. break;
  982. case PCIBus:
  983. InterfaceId = IDS_BUS_PCI_BUS;
  984. break;
  985. case VMEBus:
  986. InterfaceId = IDS_BUS_VME_BUS;
  987. break;
  988. case NuBus:
  989. InterfaceId = IDS_BUS_NU_BUS;
  990. break;
  991. case PCMCIABus:
  992. InterfaceId = IDS_BUS_PCMCIA_BUS;
  993. break;
  994. case CBus:
  995. InterfaceId = IDS_BUS_C_BUS;
  996. break;
  997. case MPIBus:
  998. InterfaceId = IDS_BUS_MPI_BUS;
  999. break;
  1000. case MPSABus:
  1001. InterfaceId = IDS_BUS_MPSA_BUS;
  1002. break;
  1003. default:
  1004. InterfaceId = IDS_INVALID;
  1005. break;
  1006. }
  1007. TypeString = REGEDIT_BASE_SYSTEM::QueryString( InterfaceId, "" );
  1008. if( TypeString == NULL ) {
  1009. DebugPrintTrace(( "REGEDT32: Unable to retrieve string \n" ));
  1010. return FALSE;
  1011. }
  1012. InterfaceType.Strcat( TypeString );
  1013. DELETE( TypeString );
  1014. if( !PrintString( &InterfaceType ) ) {
  1015. return FALSE;
  1016. }
  1017. PrintNewLine();
  1018. //
  1019. // Print the bus number
  1020. //
  1021. wsprintf( AuxNumber, (LPWSTR)L"%d", RequirementsList.GetBusNumber() );
  1022. if( !AuxString.Initialize( AuxNumber ) ) {
  1023. DebugPrint( "AuxString.Initialize() failed" );
  1024. return FALSE;
  1025. }
  1026. BusNumber.Strcat( &AuxString );
  1027. if( !PrintString( &BusNumber ) ) {
  1028. return FALSE;
  1029. }
  1030. PrintNewLine();
  1031. //
  1032. // Print the slot number
  1033. //
  1034. wsprintf( AuxNumber, (LPWSTR)L"%d", RequirementsList.GetSlotNumber() );
  1035. if( !AuxString.Initialize( AuxNumber ) ) {
  1036. DebugPrint( "AuxString.Initialize() failed" );
  1037. return FALSE;
  1038. }
  1039. SlotNumber.Strcat( &AuxString );
  1040. if( !PrintString( &SlotNumber ) ) {
  1041. return FALSE;
  1042. }
  1043. PrintNewLine();
  1044. //
  1045. // Print the resource lists
  1046. //
  1047. if( ( ( AlternativeLists = RequirementsList.GetAlternativeLists() ) == NULL ) ||
  1048. ( ( Iterator = AlternativeLists->QueryIterator() ) == NULL ) ) {
  1049. DebugPrintTrace(( "REGEDT32: Out of memory! \n" ));
  1050. return FALSE;
  1051. }
  1052. ListNumber = 0;
  1053. while( ( ResourceList = ( PCIO_DESCRIPTOR_LIST )( Iterator->GetNext() ) ) != NULL ) {
  1054. if( !_PrintIoResourceList( ResourceList, ListNumber ) ) {
  1055. DELETE( Iterator );
  1056. return FALSE;
  1057. }
  1058. ListNumber++;
  1059. }
  1060. DELETE( Iterator );
  1061. return TRUE;
  1062. }
  1063. //------------------------------------------------------------------------------
  1064. // PrintIoResourceList
  1065. //
  1066. // DESCRIPTION: Print the contents of an IO_DESCRIPTOR_LIST object.
  1067. //
  1068. // PARAMETERS: Descriptor - Pointer to object to be printed.
  1069. //------------------------------------------------------------------------------
  1070. BOOL PRINT_RESOURCE::_PrintIoResourceList(PCIO_DESCRIPTOR_LIST DescriptorList, UINT ListNumber)
  1071. {
  1072. DSTRING ListNumberString;
  1073. DSTRING AuxString;
  1074. WCHAR AuxNumber[11];
  1075. PARRAY Descriptors;
  1076. PITERATOR Iterator;
  1077. PCIO_DESCRIPTOR IoDescriptor;
  1078. ULONG Count;
  1079. if( !ListNumberString.Initialize( s_IndentString ) ||
  1080. !ListNumberString.Strcat( s_StringIoListNumber )
  1081. ) {
  1082. DebugPrint( "REGEDT32: Initialization failure" );
  1083. return FALSE;
  1084. }
  1085. //
  1086. // Build a string that contains the list number
  1087. // and print it
  1088. //
  1089. wsprintf( AuxNumber, (LPWSTR)L"%d", ListNumber );
  1090. if( !AuxString.Initialize( AuxNumber ) ) {
  1091. DebugPrint( "AuxString.Initialize() failed" );
  1092. return FALSE;
  1093. }
  1094. ListNumberString.Strcat( &AuxString );
  1095. if( !PrintString( &ListNumberString ) ) {
  1096. return FALSE;
  1097. }
  1098. PrintNewLine();
  1099. Descriptors = DescriptorList->GetDescriptorsList();
  1100. if( ( Descriptors == NULL ) ||
  1101. ( ( Iterator = Descriptors->QueryIterator() ) == NULL )
  1102. ) {
  1103. return FALSE;
  1104. }
  1105. Count = 0;
  1106. while( ( IoDescriptor = ( PCIO_DESCRIPTOR )( Iterator->GetNext() ) ) != NULL ) {
  1107. if( !_PrintIoDescriptor( IoDescriptor, Count ) ) {
  1108. DELETE( Iterator );
  1109. return FALSE;
  1110. }
  1111. Count++;
  1112. }
  1113. DELETE( Iterator );
  1114. PrintNewLine();
  1115. return TRUE;
  1116. }
  1117. //------------------------------------------------------------------------------
  1118. // PrintIoDescriptor
  1119. //
  1120. // DESCRIPTION: Print the contents of an IO_DESCRIPTOR object.
  1121. //
  1122. // PARAMETERS: Descriptor - Pointer to object to be printed.
  1123. //------------------------------------------------------------------------------
  1124. BOOL PRINT_RESOURCE::_PrintIoDescriptor(PCIO_DESCRIPTOR IoDescriptor, ULONG DescriptorNumber)
  1125. {
  1126. DSTRING IoDescriptorNumberString;
  1127. DSTRING AuxString;
  1128. WCHAR AuxNumber[11];
  1129. DSTRING ResourceString;
  1130. DSTRING DispositionString;
  1131. DSTRING OptionString;
  1132. ULONG StringId;
  1133. PWSTRING String;
  1134. if( !IoDescriptorNumberString.Initialize( s_IndentString ) ||
  1135. !IoDescriptorNumberString.Strcat( s_StringIoDescriptorNumber ) ||
  1136. !ResourceString.Initialize( s_IndentString ) ||
  1137. !ResourceString.Strcat( s_StringResource ) ||
  1138. !OptionString.Initialize( s_IndentString ) ||
  1139. !OptionString.Strcat( s_StringIoOption ) ||
  1140. !DispositionString.Initialize( s_IndentString ) ||
  1141. !DispositionString.Strcat( s_StringDisposition )
  1142. ) {
  1143. DebugPrint( "REGEDT32: Initialization failure" );
  1144. return FALSE;
  1145. }
  1146. //
  1147. // Build a string that contains the full descriptor number
  1148. // and print it
  1149. //
  1150. wsprintf( AuxNumber, (LPWSTR)L"%d", DescriptorNumber );
  1151. if( !AuxString.Initialize( AuxNumber ) ) {
  1152. DebugPrint( "AuxString.Initialize() failed" );
  1153. return FALSE;
  1154. }
  1155. IoDescriptorNumberString.Strcat( &AuxString );
  1156. if( !PrintString( &IoDescriptorNumberString ) ) {
  1157. return FALSE;
  1158. }
  1159. PrintNewLine();
  1160. //
  1161. // Print the resource type
  1162. //
  1163. if( IoDescriptor->IsDescriptorTypeDma() ) {
  1164. StringId = IDS_DEV_DMA;
  1165. } else if( IoDescriptor->IsDescriptorTypeInterrupt() ) {
  1166. StringId = IDS_DEV_INTERRUPT;
  1167. } else if( IoDescriptor->IsDescriptorTypeMemory() ) {
  1168. StringId = IDS_DEV_MEMORY;
  1169. } else if( IoDescriptor->IsDescriptorTypePort() ) {
  1170. StringId = IDS_DEV_PORT;
  1171. } else {
  1172. StringId = IDS_INVALID;
  1173. }
  1174. String = REGEDIT_BASE_SYSTEM::QueryString( StringId, "" );
  1175. if( String == NULL )
  1176. {
  1177. DebugPrintTrace(( "REGEDT32: Unable to retrieve string \n" ));
  1178. return FALSE;
  1179. }
  1180. ResourceString.Strcat( String );
  1181. DELETE( String );
  1182. if( !PrintString( &ResourceString ) ) {
  1183. return FALSE;
  1184. }
  1185. PrintNewLine();
  1186. //
  1187. // Print the option
  1188. //
  1189. wsprintf( AuxNumber, (LPWSTR)L"0x%08x", IoDescriptor->GetOption() );
  1190. if( !AuxString.Initialize( AuxNumber ) ) {
  1191. DebugPrint( "AuxString.Initialize() failed" );
  1192. return FALSE;
  1193. }
  1194. OptionString.Strcat( &AuxString );
  1195. if( !PrintString( &OptionString ) ) {
  1196. return FALSE;
  1197. }
  1198. PrintNewLine();
  1199. //
  1200. // Print the disposition
  1201. //
  1202. if( IoDescriptor->IsResourceShareUndetermined() ) {
  1203. StringId = IDS_SHARE_UNDETERMINED;
  1204. } else if( IoDescriptor->IsResourceShareDeviceExclusive() ) {
  1205. StringId = IDS_SHARE_DEVICE_EXCLUSIVE;
  1206. } else if( IoDescriptor->IsResourceShareDriverExclusive() ) {
  1207. StringId = IDS_SHARE_DRIVER_EXCLUSIVE;
  1208. } else {
  1209. StringId = IDS_SHARE_SHARED;
  1210. }
  1211. String = REGEDIT_BASE_SYSTEM::QueryString( StringId, "" );
  1212. if( String == NULL ) {
  1213. DebugPrintTrace(( "REGEDT32: Unable to retrieve string \n" ));
  1214. return FALSE;
  1215. }
  1216. DispositionString.Strcat( String );
  1217. DELETE( String );
  1218. if( !PrintString( &DispositionString ) ) {
  1219. return FALSE;
  1220. }
  1221. PrintNewLine();
  1222. if( IoDescriptor->IsDescriptorTypeDma() ) {
  1223. if( !_PrintIoDmaDescriptor( ( PCIO_DMA_DESCRIPTOR )IoDescriptor ) ) {
  1224. return FALSE;
  1225. }
  1226. } else if( IoDescriptor->IsDescriptorTypeInterrupt() ) {
  1227. if( !_PrintIoInterruptDescriptor( ( PCIO_INTERRUPT_DESCRIPTOR )IoDescriptor ) ) {
  1228. return FALSE;
  1229. }
  1230. } else if( IoDescriptor->IsDescriptorTypeMemory() ) {
  1231. if( !_PrintIoMemoryDescriptor( ( PCIO_MEMORY_DESCRIPTOR )IoDescriptor ) ) {
  1232. return FALSE;
  1233. }
  1234. } else if( IoDescriptor->IsDescriptorTypePort() ) {
  1235. if( !_PrintIoPortDescriptor( ( PCIO_PORT_DESCRIPTOR )IoDescriptor ) ) {
  1236. return FALSE;
  1237. }
  1238. }
  1239. PrintNewLine();
  1240. return TRUE;
  1241. }
  1242. //------------------------------------------------------------------------------
  1243. // PrintIoInterruptDescriptor
  1244. //
  1245. // DESCRIPTION: Print the contents of an IO_INTERRUPT_DESCRIPTOR object.
  1246. //
  1247. // PARAMETERS: Descriptor - Pointer to object to be printed.
  1248. //------------------------------------------------------------------------------
  1249. BOOL PRINT_RESOURCE::_PrintIoInterruptDescriptor(PCIO_INTERRUPT_DESCRIPTOR Descriptor)
  1250. {
  1251. DSTRING MinimumVectorString;
  1252. DSTRING MaximumVectorString;
  1253. DSTRING TypeString;
  1254. DSTRING AuxString;
  1255. WCHAR AuxNumber[19];
  1256. ULONG StringId;
  1257. PWSTRING String;
  1258. if( !MinimumVectorString.Initialize( s_IndentString ) ||
  1259. !MinimumVectorString.Strcat( s_StringIoMinimumVector ) ||
  1260. !MaximumVectorString.Initialize( s_IndentString ) ||
  1261. !MaximumVectorString.Strcat( s_StringIoMaximumVector ) ||
  1262. !TypeString.Initialize( s_IndentString ) ||
  1263. !TypeString.Strcat( s_StringType )
  1264. ) {
  1265. DebugPrint( "REGEDT32: Initialization failure" );
  1266. return FALSE;
  1267. }
  1268. //
  1269. // Print the type
  1270. //
  1271. StringId = ( Descriptor->IsInterruptLevelSensitive() )? IDS_INT_LEVEL_SENSITIVE :
  1272. IDS_INT_LATCHED;
  1273. String = REGEDIT_BASE_SYSTEM::QueryString( StringId, "" );
  1274. if( String == NULL ) {
  1275. DebugPrintTrace(( "REGEDT32: Unable to retrieve string \n" ));
  1276. return FALSE;
  1277. }
  1278. TypeString.Strcat( String );
  1279. DELETE( String );
  1280. if( !PrintString( &TypeString ) ) {
  1281. return FALSE;
  1282. }
  1283. PrintNewLine();
  1284. //
  1285. // Print the minimum vector
  1286. //
  1287. wsprintf( AuxNumber, (LPWSTR)L"%#x", Descriptor->GetMinimumVector() );
  1288. if( !AuxString.Initialize( AuxNumber ) ) {
  1289. DebugPrint( "AuxString.Initialize() failed" );
  1290. return FALSE;
  1291. }
  1292. MinimumVectorString.Strcat( &AuxString );
  1293. if( !PrintString( &MinimumVectorString ) ) {
  1294. return FALSE;
  1295. }
  1296. PrintNewLine();
  1297. //
  1298. // Print the maximum vector
  1299. //
  1300. wsprintf( AuxNumber, (LPWSTR)L"%#x", Descriptor->GetMaximumVector() );
  1301. if( !AuxString.Initialize( AuxNumber ) ) {
  1302. DebugPrint( "AuxString.Initialize() failed" );
  1303. return FALSE;
  1304. }
  1305. MaximumVectorString.Strcat( &AuxString );
  1306. if( !PrintString( &MaximumVectorString ) ) {
  1307. return FALSE;
  1308. }
  1309. PrintNewLine();
  1310. return TRUE;
  1311. }
  1312. //------------------------------------------------------------------------------
  1313. // PrintIoPortDescriptor
  1314. //
  1315. // DESCRIPTION: Print the contents of an IO_PORT_DESCRIPTOR object.
  1316. //
  1317. // PARAMETERS: Descriptor - Pointer to object to be printed.
  1318. //------------------------------------------------------------------------------
  1319. BOOL PRINT_RESOURCE::_PrintIoPortDescriptor(PCIO_PORT_DESCRIPTOR Descriptor)
  1320. {
  1321. DSTRING MinimumAddressString;
  1322. DSTRING MaximumAddressString;
  1323. DSTRING LengthString;
  1324. DSTRING AlignmentString;
  1325. DSTRING TypeString;
  1326. DSTRING AuxString;
  1327. WCHAR AuxNumber[19];
  1328. ULONG StringId;
  1329. PWSTRING String;
  1330. if( !MinimumAddressString.Initialize( s_IndentString ) ||
  1331. !MinimumAddressString.Strcat( s_StringIoMinimumAddress ) ||
  1332. !MaximumAddressString.Initialize( s_IndentString ) ||
  1333. !MaximumAddressString.Strcat( s_StringIoMaximumAddress ) ||
  1334. !LengthString.Initialize( s_IndentString ) ||
  1335. !LengthString.Strcat( s_StringLength ) ||
  1336. !AlignmentString.Initialize( s_IndentString ) ||
  1337. !AlignmentString.Strcat( s_StringIoAlignment ) ||
  1338. !TypeString.Initialize( s_IndentString ) ||
  1339. !TypeString.Strcat( s_StringType )
  1340. ) {
  1341. DebugPrint( "REGEDT32: Initialization failure" );
  1342. return FALSE;
  1343. }
  1344. //
  1345. // Print the type
  1346. //
  1347. StringId = ( Descriptor->IsPortMemory() )? IDS_PORT_MEMORY :
  1348. IDS_PORT_PORT;
  1349. String = REGEDIT_BASE_SYSTEM::QueryString( StringId, "" );
  1350. if( String == NULL ) {
  1351. DebugPrintTrace(( "REGEDT32: Unable to retrieve string \n" ));
  1352. return FALSE;
  1353. }
  1354. TypeString.Strcat( String );
  1355. DELETE( String );
  1356. if( !PrintString( &TypeString ) ) {
  1357. return FALSE;
  1358. }
  1359. PrintNewLine();
  1360. //
  1361. // Print the length
  1362. //
  1363. wsprintf( AuxNumber, (LPWSTR)L"%#x", Descriptor->GetLength() );
  1364. if( !AuxString.Initialize( AuxNumber ) ) {
  1365. DebugPrint( "AuxString.Initialize() failed" );
  1366. return FALSE;
  1367. }
  1368. LengthString.Strcat( &AuxString );
  1369. if( !PrintString( &LengthString ) ) {
  1370. return FALSE;
  1371. }
  1372. PrintNewLine();
  1373. //
  1374. // Print the alignment
  1375. //
  1376. wsprintf( AuxNumber, (LPWSTR)L"%#x", Descriptor->GetAlignment() );
  1377. if( !AuxString.Initialize( AuxNumber ) ) {
  1378. DebugPrint( "AuxString.Initialize() failed" );
  1379. return FALSE;
  1380. }
  1381. AlignmentString.Strcat( &AuxString );
  1382. if( !PrintString( &AlignmentString ) ) {
  1383. return FALSE;
  1384. }
  1385. PrintNewLine();
  1386. //
  1387. // Print the minimum address
  1388. //
  1389. if( ( ( ( PIO_PORT_DESCRIPTOR )Descriptor )->GetMinimumAddress() )->HighPart != 0 ) {
  1390. wsprintf( AuxNumber,
  1391. (LPWSTR)L"0x%08x%08x",
  1392. ( ( ( PIO_PORT_DESCRIPTOR )Descriptor )->GetMinimumAddress() )->HighPart,
  1393. ( ( ( PIO_PORT_DESCRIPTOR )Descriptor )->GetMinimumAddress() )->LowPart );
  1394. } else {
  1395. wsprintf( AuxNumber, (LPWSTR)L"0x%08x", ( ( ( PIO_PORT_DESCRIPTOR )Descriptor )->GetMinimumAddress() )->LowPart );
  1396. }
  1397. if( !AuxString.Initialize( AuxNumber ) ) {
  1398. DebugPrint( "AuxString.Initialize() failed" );
  1399. return FALSE;
  1400. }
  1401. MinimumAddressString.Strcat( &AuxString );
  1402. if( !PrintString( &MinimumAddressString ) ) {
  1403. return FALSE;
  1404. }
  1405. PrintNewLine();
  1406. //
  1407. // Print the maximum address
  1408. //
  1409. if( ( ( ( PIO_PORT_DESCRIPTOR )Descriptor )->GetMaximumAddress() )->HighPart != 0 ) {
  1410. wsprintf( AuxNumber,
  1411. (LPWSTR)L"0x%08x%08x",
  1412. ( ( ( PIO_PORT_DESCRIPTOR )Descriptor )->GetMaximumAddress() )->HighPart,
  1413. ( ( ( PIO_PORT_DESCRIPTOR )Descriptor )->GetMaximumAddress() )->LowPart );
  1414. } else {
  1415. wsprintf( AuxNumber, (LPWSTR)L"0x%08x", ( ( ( PIO_PORT_DESCRIPTOR )Descriptor )->GetMaximumAddress() )->LowPart );
  1416. }
  1417. if( !AuxString.Initialize( AuxNumber ) ) {
  1418. DebugPrint( "AuxString.Initialize() failed" );
  1419. return FALSE;
  1420. }
  1421. MaximumAddressString.Strcat( &AuxString );
  1422. if( !PrintString( &MaximumAddressString ) ) {
  1423. return FALSE;
  1424. }
  1425. PrintNewLine();
  1426. return TRUE;
  1427. }
  1428. //------------------------------------------------------------------------------
  1429. // PrintIoMemoryDescriptor
  1430. //
  1431. // DESCRIPTION: Print the contents of an IO_MEMORY_DESCRIPTOR object.
  1432. //
  1433. // PARAMETERS: Descriptor - Pointer to object to be printed.
  1434. //------------------------------------------------------------------------------
  1435. BOOL PRINT_RESOURCE::_PrintIoMemoryDescriptor(PCIO_MEMORY_DESCRIPTOR Descriptor)
  1436. {
  1437. DSTRING MinimumAddressString;
  1438. DSTRING MaximumAddressString;
  1439. DSTRING LengthString;
  1440. DSTRING AlignmentString;
  1441. DSTRING TypeString;
  1442. DSTRING AuxString;
  1443. WCHAR AuxNumber[19];
  1444. ULONG StringId;
  1445. PWSTRING String;
  1446. if( !MinimumAddressString.Initialize( s_IndentString ) ||
  1447. !MinimumAddressString.Strcat( s_StringIoMinimumAddress ) ||
  1448. !MaximumAddressString.Initialize( s_IndentString ) ||
  1449. !MaximumAddressString.Strcat( s_StringIoMaximumAddress ) ||
  1450. !LengthString.Initialize( s_IndentString ) ||
  1451. !LengthString.Strcat( s_StringLength ) ||
  1452. !AlignmentString.Initialize( s_IndentString ) ||
  1453. !AlignmentString.Strcat( s_StringIoAlignment ) ||
  1454. !TypeString.Initialize( s_IndentString ) ||
  1455. !TypeString.Strcat( s_StringType )
  1456. ) {
  1457. DebugPrint( "REGEDT32: Initialization failure" );
  1458. return FALSE;
  1459. }
  1460. //
  1461. // Print the type
  1462. //
  1463. StringId = ( Descriptor->IsMemoryReadWrite() )? IDS_MEM_READ_WRITE :
  1464. ( ( Descriptor->IsMemoryReadWrite() )? IDS_MEM_READ_ONLY :
  1465. IDS_MEM_WRITE_ONLY );
  1466. String = REGEDIT_BASE_SYSTEM::QueryString( StringId, "" );
  1467. if( String == NULL ) {
  1468. DebugPrintTrace(( "REGEDT32: Unable to retrieve string \n" ));
  1469. return FALSE;
  1470. }
  1471. TypeString.Strcat( String );
  1472. DELETE( String );
  1473. if( !PrintString( &TypeString ) ) {
  1474. return FALSE;
  1475. }
  1476. PrintNewLine();
  1477. //
  1478. // Print the length
  1479. //
  1480. wsprintf( AuxNumber, (LPWSTR)L"%#x", Descriptor->GetLength() );
  1481. if( !AuxString.Initialize( AuxNumber ) ) {
  1482. DebugPrint( "AuxString.Initialize() failed" );
  1483. return FALSE;
  1484. }
  1485. LengthString.Strcat( &AuxString );
  1486. if( !PrintString( &LengthString ) ) {
  1487. return FALSE;
  1488. }
  1489. PrintNewLine();
  1490. //
  1491. // Print the alignment
  1492. //
  1493. wsprintf( AuxNumber, (LPWSTR)L"%#x", Descriptor->GetAlignment() );
  1494. if( !AuxString.Initialize( AuxNumber ) ) {
  1495. DebugPrint( "AuxString.Initialize() failed" );
  1496. return FALSE;
  1497. }
  1498. AlignmentString.Strcat( &AuxString );
  1499. if( !PrintString( &AlignmentString ) ) {
  1500. return FALSE;
  1501. }
  1502. PrintNewLine();
  1503. //
  1504. // Print the minimum address
  1505. //
  1506. if( ( ( ( PIO_PORT_DESCRIPTOR )Descriptor )->GetMinimumAddress() )->HighPart != 0 ) {
  1507. wsprintf( AuxNumber,
  1508. (LPWSTR)L"0x%08x%08x",
  1509. ( ( ( PIO_PORT_DESCRIPTOR )Descriptor )->GetMinimumAddress() )->HighPart,
  1510. ( ( ( PIO_PORT_DESCRIPTOR )Descriptor )->GetMinimumAddress() )->LowPart );
  1511. } else {
  1512. wsprintf( AuxNumber, (LPWSTR)L"0x%08x", ( ( ( PIO_PORT_DESCRIPTOR )Descriptor )->GetMinimumAddress() )->LowPart );
  1513. }
  1514. if( !AuxString.Initialize( AuxNumber ) ) {
  1515. DebugPrint( "AuxString.Initialize() failed" );
  1516. return FALSE;
  1517. }
  1518. MinimumAddressString.Strcat( &AuxString );
  1519. if( !PrintString( &MinimumAddressString ) ) {
  1520. return FALSE;
  1521. }
  1522. PrintNewLine();
  1523. //
  1524. // Print the maximum address
  1525. //
  1526. if( ( ( ( PIO_PORT_DESCRIPTOR )Descriptor )->GetMaximumAddress() )->HighPart != 0 ) {
  1527. wsprintf( AuxNumber,
  1528. (LPWSTR)L"0x%08x%08x",
  1529. ( ( ( PIO_PORT_DESCRIPTOR )Descriptor )->GetMaximumAddress() )->HighPart,
  1530. ( ( ( PIO_PORT_DESCRIPTOR )Descriptor )->GetMaximumAddress() )->LowPart );
  1531. } else {
  1532. wsprintf( AuxNumber, (LPWSTR)L"0x%08x", ( ( ( PIO_PORT_DESCRIPTOR )Descriptor )->GetMaximumAddress() )->LowPart );
  1533. }
  1534. if( !AuxString.Initialize( AuxNumber ) ) {
  1535. DebugPrint( "AuxString.Initialize() failed" );
  1536. return FALSE;
  1537. }
  1538. MaximumAddressString.Strcat( &AuxString );
  1539. if( !PrintString( &MaximumAddressString ) ) {
  1540. return FALSE;
  1541. }
  1542. PrintNewLine();
  1543. return TRUE;
  1544. }
  1545. //------------------------------------------------------------------------------
  1546. // PrintIoDmaDescriptor
  1547. //
  1548. // DESCRIPTION: Print the contents of an IO_DMA_DESCRIPTOR object.
  1549. //
  1550. // PARAMETERS: Descriptor - Pointer to object to be printed.
  1551. //------------------------------------------------------------------------------
  1552. BOOL PRINT_RESOURCE::_PrintIoDmaDescriptor(PCIO_DMA_DESCRIPTOR Descriptor)
  1553. {
  1554. DSTRING MinimumChannelString;
  1555. DSTRING MaximumChannelString;
  1556. DSTRING AuxString;
  1557. WCHAR AuxNumber[19];
  1558. if( !MinimumChannelString.Initialize( s_IndentString ) ||
  1559. !MinimumChannelString.Strcat( s_StringIoMinimumChannel ) ||
  1560. !MaximumChannelString.Initialize( s_IndentString ) ||
  1561. !MaximumChannelString.Strcat( s_StringIoMaximumChannel )
  1562. ) {
  1563. DebugPrint( "REGEDT32: Initialization failure" );
  1564. return FALSE;
  1565. }
  1566. //
  1567. // Print the minimum channel
  1568. //
  1569. wsprintf( AuxNumber, (LPWSTR)L"%#x", Descriptor->GetMinimumChannel() );
  1570. if( !AuxString.Initialize( AuxNumber ) ) {
  1571. DebugPrint( "AuxString.Initialize() failed" );
  1572. return FALSE;
  1573. }
  1574. MinimumChannelString.Strcat( &AuxString );
  1575. if( !PrintString( &MinimumChannelString ) ) {
  1576. return FALSE;
  1577. }
  1578. PrintNewLine();
  1579. //
  1580. // Print the maximum channel
  1581. //
  1582. wsprintf( AuxNumber, (LPWSTR)L"%#x", Descriptor->GetMaximumChannel() );
  1583. if( !AuxString.Initialize( AuxNumber ) ) {
  1584. DebugPrint( "AuxString.Initialize() failed" );
  1585. return FALSE;
  1586. }
  1587. MaximumChannelString.Strcat( &AuxString );
  1588. if( !PrintString( &MaximumChannelString ) ) {
  1589. return FALSE;
  1590. }
  1591. PrintNewLine();
  1592. return TRUE;
  1593. }