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.

2957 lines
106 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. regdata.cxx
  5. Abstract:
  6. This module contains the definition for the REGISTRY_DATA
  7. class. This class is used to display registry data of type
  8. REG_RESOURCE_LIST and REG_FULL_RESOURCE_DESCRIPTOR.
  9. Author:
  10. Jaime Sasson (jaimes) - 30-Nov-1993
  11. Environment:
  12. Ulib, Regedit, Windows, User Mode
  13. --*/
  14. #include "regdata.hxx"
  15. #include "regdesc.hxx"
  16. #include "regfdesc.hxx"
  17. #include "regresls.hxx"
  18. #include "regiodsc.hxx"
  19. #include "regiodls.hxx"
  20. #include "regioreq.hxx"
  21. #include "iterator.hxx"
  22. #include "regsys.hxx"
  23. #include "regresid.h"
  24. #include <stdio.h>
  25. extern "C"
  26. {
  27. #include "clb.h"
  28. HINSTANCE g_hInstance;
  29. }
  30. // Definition of the structure used to pass information
  31. // to the DisplayBinaryDataDialogProc
  32. typedef struct _BUFFER_INFORMATION
  33. {
  34. PBYTE Buffer;
  35. ULONG BufferSize;
  36. BOOL DisplayValueType;
  37. ULONG ValueType;
  38. } BUFFER_INFORMATION, *PBUFFER_INFORMATION;
  39. // Constants that define buffer sizes for strings that represent a DWORD
  40. // and a BIG_INT.
  41. // These constants take into consideration the trailing '0x' and the terminating NUL
  42. // character.
  43. #define MAX_LENGTH_DWORD_STRING 1+1+8+1 // 0x12345678'\0'
  44. #define MAX_LENGTH_BIG_INT_STRING 1+1+16+1 // 0x1234567812345678'\0'
  45. DEFINE_CONSTRUCTOR( REGISTRY_DATA, OBJECT );
  46. DEFINE_CAST_MEMBER_FUNCTION( REGISTRY_DATA );
  47. //
  48. // Static data
  49. //
  50. BOOL REGISTRY_DATA::s_StringsInitialized = FALSE;
  51. PWSTRING REGISTRY_DATA::s_MsgBusInternal;
  52. PWSTRING REGISTRY_DATA::s_MsgBusIsa;
  53. PWSTRING REGISTRY_DATA::s_MsgBusEisa;
  54. PWSTRING REGISTRY_DATA::s_MsgBusMicroChannel;
  55. PWSTRING REGISTRY_DATA::s_MsgBusTurboChannel;
  56. PWSTRING REGISTRY_DATA::s_MsgBusPCIBus;
  57. PWSTRING REGISTRY_DATA::s_MsgBusVMEBus;
  58. PWSTRING REGISTRY_DATA::s_MsgBusNuBus;
  59. PWSTRING REGISTRY_DATA::s_MsgBusPCMCIABus;
  60. PWSTRING REGISTRY_DATA::s_MsgBusCBus;
  61. PWSTRING REGISTRY_DATA::s_MsgBusMPIBus;
  62. PWSTRING REGISTRY_DATA::s_MsgBusMPSABus;
  63. PWSTRING REGISTRY_DATA::s_MsgInvalid;
  64. PWSTRING REGISTRY_DATA::s_MsgDevPort;
  65. PWSTRING REGISTRY_DATA::s_MsgDevInterrupt;
  66. PWSTRING REGISTRY_DATA::s_MsgDevMemory;
  67. PWSTRING REGISTRY_DATA::s_MsgDevDma;
  68. PWSTRING REGISTRY_DATA::s_MsgIntLevelSensitive;
  69. PWSTRING REGISTRY_DATA::s_MsgIntLatched;
  70. PWSTRING REGISTRY_DATA::s_MsgMemReadWrite;
  71. PWSTRING REGISTRY_DATA::s_MsgMemReadOnly;
  72. PWSTRING REGISTRY_DATA::s_MsgMemWriteOnly;
  73. PWSTRING REGISTRY_DATA::s_MsgPortMemory;
  74. PWSTRING REGISTRY_DATA::s_MsgPortPort;
  75. PWSTRING REGISTRY_DATA::s_MsgShareUndetermined;
  76. PWSTRING REGISTRY_DATA::s_MsgShareDeviceExclusive;
  77. PWSTRING REGISTRY_DATA::s_MsgShareDriverExclusive;
  78. PWSTRING REGISTRY_DATA::s_MsgShareShared;
  79. //------------------------------------------------------------------------------
  80. // _InitializeStrings
  81. //
  82. // DESCRIPTION: Initialize all strings used by this class.
  83. //
  84. // RETURN: Returns TRUE if the initialization succeeds.
  85. //------------------------------------------------------------------------------
  86. BOOL REGISTRY_DATA::_InitializeStrings()
  87. {
  88. s_MsgBusInternal = REGEDIT_BASE_SYSTEM::QueryString( IDS_BUS_INTERNAL, "" );
  89. s_MsgBusIsa = REGEDIT_BASE_SYSTEM::QueryString( IDS_BUS_ISA, "" );
  90. s_MsgBusEisa = REGEDIT_BASE_SYSTEM::QueryString( IDS_BUS_EISA, "" );
  91. s_MsgBusMicroChannel = REGEDIT_BASE_SYSTEM::QueryString( IDS_BUS_MICRO_CHANNEL, "" );
  92. s_MsgBusTurboChannel = REGEDIT_BASE_SYSTEM::QueryString( IDS_BUS_TURBO_CHANNEL, "" );
  93. s_MsgBusPCIBus = REGEDIT_BASE_SYSTEM::QueryString( IDS_BUS_PCI_BUS, "" );
  94. s_MsgBusVMEBus = REGEDIT_BASE_SYSTEM::QueryString( IDS_BUS_VME_BUS, "" );
  95. s_MsgBusNuBus = REGEDIT_BASE_SYSTEM::QueryString( IDS_BUS_NU_BUS, "" );
  96. s_MsgBusPCMCIABus = REGEDIT_BASE_SYSTEM::QueryString( IDS_BUS_PCMCIA_BUS, "" );
  97. s_MsgBusCBus = REGEDIT_BASE_SYSTEM::QueryString( IDS_BUS_C_BUS, "" );
  98. s_MsgBusMPIBus = REGEDIT_BASE_SYSTEM::QueryString( IDS_BUS_MPI_BUS, "" );
  99. s_MsgBusMPSABus = REGEDIT_BASE_SYSTEM::QueryString( IDS_BUS_MPSA_BUS, "" );
  100. s_MsgInvalid = REGEDIT_BASE_SYSTEM::QueryString( IDS_INVALID, "" );
  101. s_MsgDevPort = REGEDIT_BASE_SYSTEM::QueryString( IDS_DEV_PORT, "" );
  102. s_MsgDevInterrupt = REGEDIT_BASE_SYSTEM::QueryString( IDS_DEV_INTERRUPT, "" );
  103. s_MsgDevMemory = REGEDIT_BASE_SYSTEM::QueryString( IDS_DEV_MEMORY, "" );
  104. s_MsgDevDma = REGEDIT_BASE_SYSTEM::QueryString( IDS_DEV_DMA, "" );
  105. s_MsgIntLevelSensitive = REGEDIT_BASE_SYSTEM::QueryString( IDS_INT_LEVEL_SENSITIVE, "" );
  106. s_MsgIntLatched = REGEDIT_BASE_SYSTEM::QueryString( IDS_INT_LATCHED, "" );
  107. s_MsgMemReadWrite = REGEDIT_BASE_SYSTEM::QueryString( IDS_MEM_READ_WRITE, "" );
  108. s_MsgMemReadOnly = REGEDIT_BASE_SYSTEM::QueryString( IDS_MEM_READ_ONLY, "" );
  109. s_MsgMemWriteOnly = REGEDIT_BASE_SYSTEM::QueryString( IDS_MEM_WRITE_ONLY, "" );
  110. s_MsgPortMemory = REGEDIT_BASE_SYSTEM::QueryString( IDS_PORT_MEMORY, "" );
  111. s_MsgPortPort = REGEDIT_BASE_SYSTEM::QueryString( IDS_PORT_PORT, "" );
  112. s_MsgShareUndetermined = REGEDIT_BASE_SYSTEM::QueryString( IDS_SHARE_UNDETERMINED, "" );
  113. s_MsgShareDeviceExclusive = REGEDIT_BASE_SYSTEM::QueryString( IDS_SHARE_DEVICE_EXCLUSIVE, "" );
  114. s_MsgShareDriverExclusive = REGEDIT_BASE_SYSTEM::QueryString( IDS_SHARE_DRIVER_EXCLUSIVE, "" );
  115. s_MsgShareShared = REGEDIT_BASE_SYSTEM::QueryString( IDS_SHARE_SHARED, "" );
  116. if ( ( s_MsgBusInternal == NULL ) ||
  117. ( s_MsgBusIsa == NULL ) ||
  118. ( s_MsgBusEisa == NULL ) ||
  119. ( s_MsgBusMicroChannel == NULL ) ||
  120. ( s_MsgBusTurboChannel == NULL ) ||
  121. ( s_MsgBusPCIBus == NULL ) ||
  122. ( s_MsgBusVMEBus == NULL ) ||
  123. ( s_MsgBusNuBus == NULL ) ||
  124. ( s_MsgBusPCMCIABus == NULL ) ||
  125. ( s_MsgBusCBus == NULL ) ||
  126. ( s_MsgBusMPIBus == NULL ) ||
  127. ( s_MsgBusMPSABus == NULL ) ||
  128. ( s_MsgInvalid == NULL ) ||
  129. ( s_MsgDevPort == NULL ) ||
  130. ( s_MsgDevInterrupt == NULL ) ||
  131. ( s_MsgDevMemory == NULL ) ||
  132. ( s_MsgDevDma == NULL ) ||
  133. ( s_MsgIntLevelSensitive == NULL ) ||
  134. ( s_MsgIntLatched == NULL ) ||
  135. ( s_MsgMemReadWrite == NULL ) ||
  136. ( s_MsgMemReadOnly == NULL ) ||
  137. ( s_MsgMemWriteOnly == NULL ) ||
  138. ( s_MsgPortMemory == NULL ) ||
  139. ( s_MsgPortPort == NULL ) ||
  140. ( s_MsgShareUndetermined == NULL ) ||
  141. ( s_MsgShareDeviceExclusive == NULL ) ||
  142. ( s_MsgShareDriverExclusive == NULL ) ||
  143. ( s_MsgShareShared == NULL )
  144. ) {
  145. DELETE( s_MsgBusInternal );
  146. DELETE( s_MsgBusIsa );
  147. DELETE( s_MsgBusEisa );
  148. DELETE( s_MsgBusMicroChannel );
  149. DELETE( s_MsgBusTurboChannel );
  150. DELETE( s_MsgBusPCIBus );
  151. DELETE( s_MsgBusVMEBus );
  152. DELETE( s_MsgBusNuBus );
  153. DELETE( s_MsgBusPCMCIABus );
  154. DELETE( s_MsgBusCBus );
  155. DELETE( s_MsgBusMPIBus );
  156. DELETE( s_MsgBusMPSABus );
  157. DELETE( s_MsgInvalid );
  158. DELETE( s_MsgDevPort );
  159. DELETE( s_MsgDevInterrupt );
  160. DELETE( s_MsgDevMemory );
  161. DELETE( s_MsgDevDma );
  162. DELETE( s_MsgIntLevelSensitive );
  163. DELETE( s_MsgIntLatched );
  164. DELETE( s_MsgMemReadWrite );
  165. DELETE( s_MsgMemReadOnly );
  166. DELETE( s_MsgMemWriteOnly );
  167. DELETE( s_MsgPortMemory );
  168. DELETE( s_MsgPortPort );
  169. DELETE( s_MsgShareUndetermined );
  170. DELETE( s_MsgShareDeviceExclusive );
  171. DELETE( s_MsgShareDriverExclusive );
  172. DELETE( s_MsgShareShared );
  173. DebugPrintTrace(( "REGEDT32: Unable to initialize strings on REGISTRY_DATA \n" ));
  174. s_StringsInitialized = FALSE;
  175. } else {
  176. s_StringsInitialized = TRUE;
  177. }
  178. return( s_StringsInitialized );
  179. }
  180. VOID DisplayResourceData(HWND hWnd, DWORD dwType, LPEDITVALUEPARAM lpEditValueParam)
  181. {
  182. REGISTRY_DATA::_DisplayData(hWnd, dwType, lpEditValueParam);
  183. }
  184. //------------------------------------------------------------------------------
  185. // DisplayResourceData
  186. //
  187. // DESCRIPTION: Invoke the appropriate dialog that displays registry data of type
  188. // REG_RESOURCE_LIST and REG_FULL_RESOURCE_DESCRIPTOR.
  189. //
  190. // PARAMETERS: hWnd - A handle to the owner window.
  191. // dwType - Indicates the type of the data to be displayed.
  192. // EditValueParam - the edit value information
  193. //------------------------------------------------------------------------------
  194. VOID REGISTRY_DATA::_DisplayData(HWND hWnd, DWORD dwType, LPEDITVALUEPARAM lpEditValueParam)
  195. {
  196. PBYTE pbValueData = lpEditValueParam->pValueData;
  197. UINT cbValueData = lpEditValueParam->cbValueData;
  198. if(!s_StringsInitialized)
  199. {
  200. _InitializeStrings();
  201. }
  202. if (s_StringsInitialized)
  203. {
  204. switch(dwType)
  205. {
  206. case REG_RESOURCE_LIST:
  207. {
  208. RESOURCE_LIST ResourceList;
  209. if(ResourceList.Initialize(pbValueData, cbValueData))
  210. {
  211. REGISTRY_DATA::_DisplayResourceList(hWnd, &ResourceList);
  212. }
  213. }
  214. break;
  215. case REG_FULL_RESOURCE_DESCRIPTOR:
  216. {
  217. FULL_DESCRIPTOR FullDescriptor;
  218. if(FullDescriptor.Initialize(pbValueData, cbValueData))
  219. {
  220. REGISTRY_DATA::_DisplayFullResourceDescriptor( hWnd, &FullDescriptor );
  221. }
  222. }
  223. break;
  224. case REG_RESOURCE_REQUIREMENTS_LIST:
  225. {
  226. IO_REQUIREMENTS_LIST RequirementsList;
  227. if( RequirementsList.Initialize(pbValueData, cbValueData))
  228. {
  229. REGISTRY_DATA::_DisplayRequirementsList( hWnd, &RequirementsList );
  230. }
  231. }
  232. break;
  233. }
  234. }
  235. }
  236. //------------------------------------------------------------------------------
  237. // _DisplayResourceList
  238. //
  239. // DESCRIPTION: Invoke the dialog that displays registry data of type
  240. // REG_RESOURCE_LIST
  241. //
  242. // PARAMETERS: hWnd - A handle to the owner window.
  243. // pResourceList - Pointer to a RESOURCE_LIST object to be displayed.
  244. //------------------------------------------------------------------------------
  245. VOID REGISTRY_DATA::_DisplayResourceList(HWND hWnd, PCRESOURCE_LIST pResourceList)
  246. {
  247. DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_RESOURCE_LIST), hWnd,
  248. (DLGPROC)REGISTRY_DATA::_DisplayResourceListDialogProc,
  249. (DWORD_PTR) pResourceList);
  250. }
  251. //------------------------------------------------------------------------------
  252. // _DisplayFullResourceDescriptor
  253. //
  254. // DESCRIPTION: Invoke the dialog that displays registry data of type
  255. // REG_FULL_RESOURCE_DESCRIPTOR.
  256. //
  257. // PARAMETERS: hWnd - A handle to the owner window.
  258. // pFullDescriptor - Pointer to a FULL_DESCRIPTOR object to be displayed.
  259. //------------------------------------------------------------------------------
  260. VOID REGISTRY_DATA::_DisplayFullResourceDescriptor(HWND hWnd, PCFULL_DESCRIPTOR pFullDescriptor)
  261. {
  262. DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_FULL_RES_DESCRIPTOR), hWnd,
  263. (DLGPROC)REGISTRY_DATA::_DisplayFullResourceDescriptorDialogProc,
  264. (DWORD_PTR) pFullDescriptor);
  265. }
  266. //------------------------------------------------------------------------------
  267. // _DisplayRequirementsList
  268. //
  269. // DESCRIPTION: Invoke the dialog that displays registry data of type
  270. // REG_IO_RESOURCE_REQUIREMENTS_LIST.
  271. //
  272. // PARAMETERS: hWnd - A handle to the owner window.
  273. // pRequirementsList - Pointer to an IO_REQUIREMENTS_LIST object to be displayed.
  274. //------------------------------------------------------------------------------
  275. VOID REGISTRY_DATA::_DisplayRequirementsList(HWND hWnd, PCIO_REQUIREMENTS_LIST pRequirementsList)
  276. {
  277. DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_IO_REQUIREMENTS_LIST), hWnd,
  278. (DLGPROC)REGISTRY_DATA::_DisplayRequirementsListDialogProc,
  279. (DWORD_PTR) pRequirementsList );
  280. }
  281. //------------------------------------------------------------------------------
  282. // _DisplayIoDescriptor
  283. //
  284. // DESCRIPTION: Invoke appropriate that displays a Port, Memory, Interrupt or DMA,
  285. // depending on the type of the object received as parameter.
  286. //
  287. // PARAMETERS: hWnd - A handle to the owner window.
  288. // pIODescriptor - Pointer to the object to be displayed.
  289. //------------------------------------------------------------------------------
  290. VOID REGISTRY_DATA::_DisplayIoDescriptor(HWND hWnd, PCIO_DESCRIPTOR pIODescriptor)
  291. {
  292. DLGPROC Pointer;
  293. LPCWSTR Template;
  294. if(pIODescriptor->IsDescriptorTypePort())
  295. {
  296. Pointer = (DLGPROC)REGISTRY_DATA::_DisplayIoPortDialogProc;
  297. Template = MAKEINTRESOURCE(IDD_IO_PORT_RESOURCE);
  298. }
  299. else if(pIODescriptor->IsDescriptorTypeMemory())
  300. {
  301. Pointer = (DLGPROC)REGISTRY_DATA::_DisplayIoMemoryDialogProc;
  302. Template = MAKEINTRESOURCE(IDD_IO_MEMORY_RESOURCE);
  303. }
  304. else if(pIODescriptor->IsDescriptorTypeInterrupt())
  305. {
  306. Pointer = (DLGPROC)REGISTRY_DATA::_DisplayIoInterruptDialogProc;
  307. Template = MAKEINTRESOURCE(IDD_IO_INTERRUPT_RESOURCE);
  308. }
  309. else if(pIODescriptor->IsDescriptorTypeDma())
  310. {
  311. Pointer = (DLGPROC)REGISTRY_DATA::_DisplayIoDmaDialogProc;
  312. Template = MAKEINTRESOURCE(IDD_IO_DMA_RESOURCE);
  313. }
  314. else
  315. {
  316. Pointer = NULL;
  317. }
  318. if(Pointer)
  319. {
  320. DialogBoxParam(g_hInstance, Template, hWnd, Pointer, (DWORD_PTR)pIODescriptor );
  321. }
  322. }
  323. //------------------------------------------------------------------------------
  324. // _DisplayResourceListDialogProc
  325. //
  326. // DESCRIPTION: The dialog proceedure for displaying data of type REG_RESOURCE_LIST.
  327. //
  328. // PARAMETERS: hDlg - a handle to the dialog proceedure.
  329. // Msg - the message passed from Windows.
  330. // wParam - extra message dependent data.
  331. // lParam - extra message dependent data.
  332. //------------------------------------------------------------------------------
  333. BOOL REGISTRY_DATA::_DisplayResourceListDialogProc(HWND hDlg, DWORD dwMsg, WPARAM wParam,
  334. LPARAM lParam)
  335. {
  336. switch(dwMsg)
  337. {
  338. case WM_INITDIALOG:
  339. {
  340. LPCWSTR InterfaceString;
  341. ULONG StringSize;
  342. WCHAR BusNumber[ MAX_LENGTH_DWORD_STRING ];
  343. PARRAY Descriptors;
  344. PITERATOR Iterator;
  345. PCFULL_DESCRIPTOR FullResourceDescriptor;
  346. PCRESOURCE_LIST pResourceList;
  347. CLB_ROW ClbRow;
  348. CLB_STRING ClbString[ ] = {{ BusNumber, 0, CLB_LEFT, NULL },
  349. { NULL, 0, CLB_LEFT, NULL }};
  350. ULONG Widths[] = {14, ( ULONG ) -1};
  351. if (((pResourceList = (PCRESOURCE_LIST)lParam) == NULL) ||
  352. ((Descriptors = pResourceList->GetFullResourceDescriptors()) == NULL) ||
  353. ((Iterator = Descriptors->QueryIterator()) == NULL ))
  354. {
  355. EndDialog( hDlg, 0 );
  356. return( TRUE );
  357. }
  358. ClbSetColumnWidths(hDlg, IDC_LIST_RESOURCE_LISTS, Widths );
  359. while( ( FullResourceDescriptor = ( PCFULL_DESCRIPTOR )Iterator->GetNext() ) != NULL )
  360. {
  361. switch( FullResourceDescriptor->GetInterfaceType() )
  362. {
  363. case Internal:
  364. InterfaceString = s_MsgBusInternal->GetWSTR();
  365. StringSize = s_MsgBusInternal->QueryChCount();
  366. break;
  367. case Isa:
  368. InterfaceString = s_MsgBusIsa->GetWSTR();
  369. StringSize = s_MsgBusIsa->QueryChCount();
  370. break;
  371. case Eisa:
  372. InterfaceString = s_MsgBusEisa->GetWSTR();
  373. StringSize = s_MsgBusEisa->QueryChCount();
  374. break;
  375. case MicroChannel:
  376. InterfaceString = s_MsgBusMicroChannel->GetWSTR();
  377. StringSize = s_MsgBusMicroChannel->QueryChCount();
  378. break;
  379. case TurboChannel:
  380. InterfaceString = s_MsgBusTurboChannel->GetWSTR();
  381. StringSize = s_MsgBusTurboChannel->QueryChCount();
  382. break;
  383. case PCIBus:
  384. InterfaceString = s_MsgBusPCIBus->GetWSTR();
  385. StringSize = s_MsgBusPCIBus->QueryChCount();
  386. break;
  387. case VMEBus:
  388. InterfaceString = s_MsgBusVMEBus->GetWSTR();
  389. StringSize = s_MsgBusVMEBus->QueryChCount();
  390. break;
  391. case NuBus:
  392. InterfaceString = s_MsgBusNuBus->GetWSTR();
  393. StringSize = s_MsgBusNuBus->QueryChCount();
  394. break;
  395. case PCMCIABus:
  396. InterfaceString = s_MsgBusPCMCIABus->GetWSTR();
  397. StringSize = s_MsgBusPCMCIABus->QueryChCount();
  398. break;
  399. case CBus:
  400. InterfaceString = s_MsgBusCBus->GetWSTR();
  401. StringSize = s_MsgBusCBus->QueryChCount();
  402. break;
  403. case MPIBus:
  404. InterfaceString = s_MsgBusMPIBus->GetWSTR();
  405. StringSize = s_MsgBusMPIBus->QueryChCount();
  406. break;
  407. case MPSABus:
  408. InterfaceString = s_MsgBusMPSABus->GetWSTR();
  409. StringSize = s_MsgBusMPSABus->QueryChCount();
  410. break;
  411. default:
  412. InterfaceString = s_MsgInvalid->GetWSTR();
  413. StringSize = s_MsgInvalid->QueryChCount();
  414. break;
  415. }
  416. swprintf( BusNumber, ( LPWSTR )L"%d", FullResourceDescriptor->GetBusNumber() );
  417. ClbString[ 0 ].Length = wcslen( BusNumber );
  418. ClbString[ 0 ].Format = CLB_LEFT;
  419. ClbString[ 1 ].String = ( LPWSTR )InterfaceString;
  420. ClbString[ 1 ].Format = CLB_LEFT;
  421. ClbString[ 1 ].Length = StringSize;
  422. ClbRow.Count = 2;
  423. ClbRow.Strings = ClbString;
  424. ClbRow.Data = ( PVOID )FullResourceDescriptor;
  425. ClbAddData(hDlg, IDC_LIST_RESOURCE_LISTS, &ClbRow );
  426. }
  427. DELETE(Iterator);
  428. // Disble the Display button
  429. EnableWindow( GetDlgItem( hDlg, IDC_PUSH_DISPLAY_RESOURCES ), FALSE );
  430. return( TRUE );
  431. }
  432. case WM_COMPAREITEM:
  433. {
  434. LPCOMPAREITEMSTRUCT lpcis;
  435. LPCLB_ROW ClbRow1;
  436. LPCLB_ROW ClbRow2;
  437. LONG Compare;
  438. PCFULL_DESCRIPTOR FullDescriptor1;
  439. PCFULL_DESCRIPTOR FullDescriptor2;
  440. PWSTR String1;
  441. PWSTR String2;
  442. lpcis = ( LPCOMPAREITEMSTRUCT ) lParam;
  443. //
  444. // Extract the rows to be compared.
  445. // First compare by bus number, and if they
  446. // are equal, compare by interface type
  447. //
  448. ClbRow1 = ( LPCLB_ROW ) lpcis->itemData1;
  449. ClbRow2 = ( LPCLB_ROW ) lpcis->itemData2;
  450. FullDescriptor1 = ( PCFULL_DESCRIPTOR )ClbRow1->Data;
  451. FullDescriptor2 = ( PCFULL_DESCRIPTOR )ClbRow2->Data;
  452. Compare = FullDescriptor1->GetBusNumber() -
  453. FullDescriptor2->GetBusNumber();
  454. if( Compare == 0 )
  455. {
  456. String1 = ClbRow1->Strings[1].String;
  457. String2 = ClbRow2->Strings[1].String;
  458. Compare = wcscmp( String1, String2 );
  459. }
  460. return Compare;
  461. }
  462. case WM_COMMAND:
  463. switch(LOWORD(wParam))
  464. {
  465. case IDOK:
  466. case IDCANCEL:
  467. EndDialog( hDlg, TRUE );
  468. return( TRUE );
  469. case IDC_LIST_RESOURCE_LISTS:
  470. {
  471. switch( HIWORD( wParam ))
  472. {
  473. case LBN_SELCHANGE:
  474. {
  475. // Enable the display drive details button
  476. EnableWindow( GetDlgItem( hDlg, IDC_PUSH_DISPLAY_RESOURCES ), TRUE);
  477. }
  478. break;
  479. case LBN_DBLCLK:
  480. {
  481. // Simulate that the details button was pushed
  482. SendMessage(hDlg, WM_COMMAND,
  483. MAKEWPARAM( IDC_PUSH_DISPLAY_RESOURCES, BN_CLICKED),
  484. ( LPARAM ) GetDlgItem( hDlg, IDC_PUSH_DISPLAY_RESOURCES));
  485. }
  486. break;
  487. }
  488. break;
  489. }
  490. case IDC_PUSH_DISPLAY_RESOURCES:
  491. {
  492. PCFULL_DESCRIPTOR FullDescriptor;
  493. FullDescriptor = ( PCFULL_DESCRIPTOR )(_GetSelectedItem ( hDlg, IDC_LIST_RESOURCE_LISTS ) );
  494. if( FullDescriptor != NULL )
  495. {
  496. _DisplayFullResourceDescriptor( hDlg, FullDescriptor );
  497. }
  498. return(TRUE);
  499. }
  500. }
  501. }
  502. return(FALSE);
  503. }
  504. //------------------------------------------------------------------------------
  505. // _DisplayFullResourceDescriptorDialogProc
  506. //
  507. // DESCRIPTION: The dialog proceedure for displaying data of type
  508. // REG_FULL_RESOURCE_DESCRIPTOR.
  509. //
  510. // PARAMETERS: hDlg - a handle to the dialog proceedure.
  511. // dwMsg - the message passed from Windows.
  512. // wParam - extra message dependent data.
  513. // lParam - extra message dependent data.
  514. //------------------------------------------------------------------------------
  515. BOOL REGISTRY_DATA::_DisplayFullResourceDescriptorDialogProc(HWND hDlg, DWORD dwMsg,
  516. WPARAM wParam, LPARAM lParam)
  517. {
  518. PCBYTE Pointer;
  519. ULONG Size;
  520. STATIC PCDEVICE_SPECIFIC_DESCRIPTOR LastSelectedDevSpecific;
  521. switch(dwMsg)
  522. {
  523. case WM_INITDIALOG:
  524. {
  525. LPCWSTR InterfaceString;
  526. WCHAR BusNumber[ MAX_LENGTH_DWORD_STRING ];
  527. PARRAY PartialDescriptors;
  528. PITERATOR Iterator;
  529. PCFULL_DESCRIPTOR FullResourceDescriptor;
  530. PCPARTIAL_DESCRIPTOR PartialDescriptor;
  531. PCPORT_DESCRIPTOR Port;
  532. PCINTERRUPT_DESCRIPTOR Interrupt;
  533. PCMEMORY_DESCRIPTOR Memory;
  534. PCDMA_DESCRIPTOR Dma;
  535. PCDEVICE_SPECIFIC_DESCRIPTOR DeviceSpecific;
  536. CLB_ROW ClbRow;
  537. CLB_STRING ClbString[ ] = {
  538. { NULL, 0, CLB_LEFT, NULL },
  539. { NULL, 0, CLB_LEFT, NULL },
  540. { NULL, 0, CLB_LEFT, NULL },
  541. { NULL, 0, CLB_LEFT, NULL }
  542. };
  543. WCHAR PortAddressString[ MAX_LENGTH_BIG_INT_STRING ];
  544. WCHAR PortLengthString[ MAX_LENGTH_DWORD_STRING ];
  545. PCWSTRING PortType;
  546. WCHAR InterruptVectorString[ MAX_LENGTH_DWORD_STRING ];
  547. WCHAR InterruptLevelString[ MAX_LENGTH_DWORD_STRING ];
  548. WCHAR InterruptAffinityString[ MAX_LENGTH_DWORD_STRING ];
  549. PCWSTRING InterruptType;
  550. WCHAR MemoryAddressString[ MAX_LENGTH_BIG_INT_STRING ];
  551. WCHAR MemoryLengthString[ MAX_LENGTH_DWORD_STRING ];
  552. PCWSTRING MemoryAccess;
  553. WCHAR DmaChannelString[ MAX_LENGTH_DWORD_STRING ];
  554. WCHAR DmaPortString[ MAX_LENGTH_DWORD_STRING ];
  555. WCHAR Reserved1String[ MAX_LENGTH_DWORD_STRING ];
  556. WCHAR Reserved2String[ MAX_LENGTH_DWORD_STRING ];
  557. WCHAR DataSizeString[ MAX_LENGTH_DWORD_STRING ];
  558. PCBYTE AuxPointer;
  559. LastSelectedDevSpecific = NULL;
  560. if( ( FullResourceDescriptor = ( PCFULL_DESCRIPTOR )lParam ) == NULL )
  561. {
  562. EndDialog( hDlg, 0 );
  563. return( TRUE );
  564. }
  565. //
  566. // Write the interface type
  567. //
  568. switch( FullResourceDescriptor->GetInterfaceType() )
  569. {
  570. case Internal:
  571. InterfaceString = s_MsgBusInternal->GetWSTR();
  572. break;
  573. case Isa:
  574. InterfaceString = s_MsgBusIsa->GetWSTR();
  575. break;
  576. case Eisa:
  577. InterfaceString = s_MsgBusEisa->GetWSTR();
  578. break;
  579. case MicroChannel:
  580. InterfaceString = s_MsgBusMicroChannel->GetWSTR();
  581. break;
  582. case TurboChannel:
  583. InterfaceString = s_MsgBusTurboChannel->GetWSTR();
  584. break;
  585. case PCIBus:
  586. InterfaceString = s_MsgBusPCIBus->GetWSTR();
  587. break;
  588. case VMEBus:
  589. InterfaceString = s_MsgBusVMEBus->GetWSTR();
  590. break;
  591. case NuBus:
  592. InterfaceString = s_MsgBusNuBus->GetWSTR();
  593. break;
  594. case PCMCIABus:
  595. InterfaceString = s_MsgBusPCMCIABus->GetWSTR();
  596. break;
  597. case CBus:
  598. InterfaceString = s_MsgBusCBus->GetWSTR();
  599. break;
  600. case MPIBus:
  601. InterfaceString = s_MsgBusMPIBus->GetWSTR();
  602. break;
  603. case MPSABus:
  604. InterfaceString = s_MsgBusMPSABus->GetWSTR();
  605. break;
  606. default:
  607. InterfaceString = s_MsgInvalid->GetWSTR();
  608. break;
  609. }
  610. SendDlgItemMessage( hDlg,
  611. IDC_FULL_RES_TEXT_INTERFACE_TYPE,
  612. WM_SETTEXT,
  613. 0,
  614. ( LPARAM )InterfaceString );
  615. //
  616. // Write the bus number
  617. //
  618. swprintf( BusNumber, ( LPWSTR )L"%d", FullResourceDescriptor->GetBusNumber() );
  619. SendDlgItemMessage( hDlg,
  620. IDC_FULL_RES_TEXT_BUS_NUMBER,
  621. WM_SETTEXT,
  622. 0,
  623. ( LPARAM )BusNumber );
  624. //
  625. // Write the version and revision
  626. //
  627. swprintf( BusNumber, ( LPWSTR )L"%d", FullResourceDescriptor->GetVersion() );
  628. SendDlgItemMessage( hDlg,
  629. IDC_FULL_RES_TEXT_VERSION,
  630. WM_SETTEXT,
  631. 0,
  632. ( LPARAM )BusNumber );
  633. swprintf( BusNumber, ( LPWSTR )L"%d", FullResourceDescriptor->GetRevision() );
  634. SendDlgItemMessage( hDlg,
  635. IDC_FULL_RES_TEXT_REVISION,
  636. WM_SETTEXT,
  637. 0,
  638. ( LPARAM )BusNumber );
  639. //
  640. // Write partial descriptors
  641. //
  642. if( ( ( PartialDescriptors = FullResourceDescriptor->GetResourceDescriptors() ) == NULL ) ||
  643. ( ( Iterator = PartialDescriptors->QueryIterator() ) == NULL ) ) {
  644. EndDialog( hDlg, 0 );
  645. return( TRUE );
  646. }
  647. ClbRow.Strings = ClbString;
  648. while( ( PartialDescriptor = ( PCPARTIAL_DESCRIPTOR )Iterator->GetNext() ) != NULL ) {
  649. ClbRow.Data = ( PVOID )PartialDescriptor;
  650. if( PartialDescriptor->IsDescriptorTypePort() ) {
  651. Port = ( PCPORT_DESCRIPTOR )PartialDescriptor;
  652. if( ( ( ( PPORT_DESCRIPTOR )Port )->GetPhysicalAddress() )->HighPart != 0 ) {
  653. swprintf( PortAddressString,
  654. ( LPWSTR )L"0x%08x%08x",
  655. ( ( ( PPORT_DESCRIPTOR )Port )->GetPhysicalAddress() )->HighPart,
  656. ( ( ( PPORT_DESCRIPTOR )Port )->GetPhysicalAddress() )->LowPart );
  657. } else {
  658. swprintf( PortAddressString,
  659. ( LPWSTR )L"0x%08x",
  660. ( ( ( PPORT_DESCRIPTOR )Port )->GetPhysicalAddress() )->LowPart );
  661. }
  662. swprintf( PortLengthString,
  663. ( LPWSTR )L"%#x",
  664. Port->GetLength() );
  665. ClbString[ 0 ].String = ( LPWSTR )PortAddressString;
  666. ClbString[ 0 ].Format = CLB_LEFT;
  667. ClbString[ 0 ].Length = wcslen( PortAddressString );
  668. ClbString[ 1 ].String = ( LPWSTR )PortLengthString;
  669. ClbString[ 1 ].Format = CLB_LEFT;
  670. ClbString[ 1 ].Length = wcslen( PortLengthString );
  671. if( Port->IsPortMemory() ) {
  672. PortType = s_MsgPortMemory;
  673. } else {
  674. PortType = s_MsgPortPort;
  675. }
  676. ClbString[ 2 ].String = ( LPWSTR )PortType->GetWSTR();
  677. ClbString[ 2 ].Format = CLB_LEFT;
  678. ClbString[ 2 ].Length = PortType->QueryChCount();
  679. ClbRow.Count = 3;
  680. ClbAddData( hDlg,
  681. IDC_FULL_RES_LIST_PORTS,
  682. &ClbRow );
  683. } else if( PartialDescriptor->IsDescriptorTypeInterrupt() ) {
  684. Interrupt = ( PCINTERRUPT_DESCRIPTOR )PartialDescriptor;
  685. swprintf( InterruptVectorString,
  686. ( LPWSTR )L"%d",
  687. Interrupt->GetVector() );
  688. swprintf( InterruptLevelString,
  689. ( LPWSTR )L"%d",
  690. Interrupt->GetLevel() );
  691. swprintf( InterruptAffinityString,
  692. ( LPWSTR )L"0x%08x",
  693. Interrupt->GetAffinity() );
  694. ClbString[ 0 ].String = ( LPWSTR )InterruptVectorString;
  695. ClbString[ 0 ].Length = wcslen( InterruptVectorString );
  696. ClbString[ 0 ].Format = CLB_LEFT;
  697. ClbString[ 1 ].String = ( LPWSTR )InterruptLevelString;
  698. ClbString[ 1 ].Format = CLB_LEFT;
  699. ClbString[ 1 ].Length = wcslen( InterruptLevelString );
  700. ClbString[ 2 ].String = ( LPWSTR )InterruptAffinityString;
  701. ClbString[ 2 ].Format = CLB_LEFT;
  702. ClbString[ 2 ].Length = wcslen( InterruptAffinityString );
  703. if( Interrupt->IsInterruptLatched() ) {
  704. InterruptType = s_MsgIntLatched;
  705. } else {
  706. InterruptType = s_MsgIntLevelSensitive;
  707. }
  708. ClbString[ 3 ].String = ( LPWSTR )InterruptType->GetWSTR();
  709. ClbString[ 3 ].Format = CLB_LEFT;
  710. ClbString[ 3 ].Length = InterruptType->QueryChCount();
  711. ClbRow.Count = 4;
  712. ClbAddData( hDlg,
  713. IDC_FULL_RES_LIST_INTERRUPTS,
  714. &ClbRow );
  715. } else if( PartialDescriptor->IsDescriptorTypeMemory() ) {
  716. Memory = ( PCMEMORY_DESCRIPTOR )PartialDescriptor;
  717. if( ( ( ( PMEMORY_DESCRIPTOR )Memory )->GetStartAddress() )->HighPart != 0 ) {
  718. swprintf( MemoryAddressString,
  719. ( LPWSTR )L"%#08x%08x",
  720. ( ( ( PMEMORY_DESCRIPTOR )Memory )->GetStartAddress() )->HighPart,
  721. ( ( ( PMEMORY_DESCRIPTOR )Memory )->GetStartAddress() )->LowPart );
  722. } else {
  723. swprintf( MemoryAddressString,
  724. ( LPWSTR )L"%#08x",
  725. ( ( ( PMEMORY_DESCRIPTOR )Memory )->GetStartAddress() )->LowPart );
  726. }
  727. swprintf( MemoryLengthString,
  728. ( LPWSTR )L"%#x",
  729. Memory->GetLength() );
  730. ClbString[ 0 ].String = ( LPWSTR )MemoryAddressString;
  731. ClbString[ 0 ].Length = wcslen( MemoryAddressString );
  732. ClbString[ 0 ].Format = CLB_LEFT;
  733. ClbString[ 1 ].String = ( LPWSTR )MemoryLengthString;
  734. ClbString[ 1 ].Format = CLB_LEFT;
  735. ClbString[ 1 ].Length = wcslen( MemoryLengthString );
  736. if( Memory->IsMemoryReadWrite() ) {
  737. MemoryAccess = s_MsgMemReadWrite;
  738. } else if( Memory->IsMemoryReadOnly() ){
  739. MemoryAccess = s_MsgMemReadOnly;
  740. } else {
  741. MemoryAccess = s_MsgMemWriteOnly;
  742. }
  743. ClbString[ 2 ].String = ( LPWSTR )MemoryAccess->GetWSTR();
  744. ClbString[ 2 ].Format = CLB_LEFT;
  745. ClbString[ 2 ].Length = MemoryAccess->QueryChCount();
  746. ClbRow.Count = 3;
  747. ClbAddData( hDlg,
  748. IDC_FULL_RES_LIST_MEMORY,
  749. &ClbRow );
  750. } else if( PartialDescriptor->IsDescriptorTypeDma() ) {
  751. Dma = ( PDMA_DESCRIPTOR )PartialDescriptor;
  752. swprintf( DmaChannelString,
  753. ( LPWSTR )L"%d",
  754. Dma->GetChannel() );
  755. swprintf( DmaPortString,
  756. ( LPWSTR )L"%d",
  757. Dma->GetPort() );
  758. ClbString[ 0 ].String = ( LPWSTR )DmaChannelString;
  759. ClbString[ 0 ].Length = wcslen( DmaChannelString );
  760. ClbString[ 0 ].Format = CLB_LEFT;
  761. ClbString[ 1 ].String = ( LPWSTR )DmaPortString;
  762. ClbString[ 1 ].Format = CLB_LEFT;
  763. ClbString[ 1 ].Length = wcslen( DmaPortString );
  764. ClbRow.Count = 2;
  765. ClbAddData( hDlg,
  766. IDC_FULL_RES_LIST_DMA,
  767. &ClbRow );
  768. } else if( PartialDescriptor->IsDescriptorTypeDeviceSpecific() ) {
  769. DeviceSpecific = ( PDEVICE_SPECIFIC_DESCRIPTOR )PartialDescriptor;
  770. swprintf( Reserved1String,
  771. ( LPWSTR )L"0x%08x",
  772. DeviceSpecific->GetReserved1() );
  773. swprintf( Reserved2String,
  774. ( LPWSTR )L"0x%08x",
  775. DeviceSpecific->GetReserved1() );
  776. swprintf( DataSizeString,
  777. ( LPWSTR )L"%#x",
  778. DeviceSpecific->GetData( &AuxPointer ) );
  779. ClbString[ 0 ].String = ( LPWSTR )Reserved1String;
  780. ClbString[ 0 ].Length = wcslen( Reserved1String );
  781. ClbString[ 0 ].Format = CLB_LEFT;
  782. ClbString[ 1 ].String = ( LPWSTR )Reserved2String;
  783. ClbString[ 1 ].Format = CLB_LEFT;
  784. ClbString[ 1 ].Length = wcslen( Reserved2String );
  785. ClbString[ 2 ].String = ( LPWSTR )DataSizeString;
  786. ClbString[ 2 ].Length = wcslen( DataSizeString );
  787. ClbString[ 2 ].Format = CLB_LEFT;
  788. ClbRow.Count = 3;
  789. ClbAddData( hDlg,
  790. IDC_FULL_RES_LIST_DEVICE_SPECIFIC,
  791. &ClbRow );
  792. } else {
  793. DebugPrintTrace(( "REGEDT32: Unknown Descriptor \n\n" ));
  794. continue;
  795. }
  796. }
  797. DELETE( Iterator );
  798. //
  799. // Disble the Display button
  800. //
  801. // EnableWindow( GetDlgItem( hDlg, IDC_PUSH_DISPLAY_RESOURCES ), FALSE );
  802. return( TRUE );
  803. }
  804. case WM_COMPAREITEM:
  805. {
  806. LPCOMPAREITEMSTRUCT lpcis;
  807. LPCLB_ROW ClbRow1;
  808. LPCLB_ROW ClbRow2;
  809. LONG Compare;
  810. PCPARTIAL_DESCRIPTOR Descriptor1;
  811. PCPARTIAL_DESCRIPTOR Descriptor2;
  812. lpcis = ( LPCOMPAREITEMSTRUCT ) lParam;
  813. //
  814. // Extract the two rows to be compared.
  815. //
  816. ClbRow1 = ( LPCLB_ROW ) lpcis->itemData1;
  817. ClbRow2 = ( LPCLB_ROW ) lpcis->itemData2;
  818. Descriptor1 = ( PCPARTIAL_DESCRIPTOR ) ClbRow1->Data;
  819. Descriptor2 = ( PCPARTIAL_DESCRIPTOR ) ClbRow2->Data;
  820. //
  821. // Sort the Clbs. In the case of DMA and INTERRUPT, sort by channel
  822. // and vector respectively. For MEMORY and PORT sort by starting
  823. // physical address.
  824. //
  825. switch( lpcis->CtlID ) {
  826. case IDC_FULL_RES_LIST_DMA:
  827. //
  828. // For DMA, sort by channel and port
  829. //
  830. Compare = ( ( PCDMA_DESCRIPTOR )Descriptor1 )->GetChannel() -
  831. ( ( PCDMA_DESCRIPTOR )Descriptor2 )->GetChannel();
  832. if( Compare == 0 ) {
  833. Compare = ( ( PCDMA_DESCRIPTOR )Descriptor1 )->GetPort() -
  834. ( ( PCDMA_DESCRIPTOR )Descriptor2 )->GetPort();
  835. }
  836. break;
  837. case IDC_FULL_RES_LIST_INTERRUPTS:
  838. //
  839. // For INTERRUPT, sort by vector and level
  840. //
  841. Compare = ( ( PCINTERRUPT_DESCRIPTOR )Descriptor1 )->GetVector() -
  842. ( ( PCINTERRUPT_DESCRIPTOR )Descriptor2 )->GetVector();
  843. if( Compare == 0 ) {
  844. Compare = ( ( PCINTERRUPT_DESCRIPTOR )Descriptor1 )->GetLevel() -
  845. ( ( PCINTERRUPT_DESCRIPTOR )Descriptor2 )->GetLevel();
  846. }
  847. break;
  848. case IDC_FULL_RES_LIST_MEMORY:
  849. //
  850. // For MEMORY sort by physical address
  851. //
  852. Compare = ( ( ( PMEMORY_DESCRIPTOR )Descriptor1 )->GetStartAddress() )->HighPart -
  853. ( ( ( PMEMORY_DESCRIPTOR )Descriptor2 )->GetStartAddress() )->HighPart;
  854. if( Compare == 0 ) {
  855. Compare = ( ( ( PMEMORY_DESCRIPTOR )Descriptor1 )->GetStartAddress() )->LowPart -
  856. ( ( ( PMEMORY_DESCRIPTOR )Descriptor2 )->GetStartAddress() )->LowPart;
  857. }
  858. break;
  859. case IDC_FULL_RES_LIST_PORTS:
  860. //
  861. // For PORT sort by physical address
  862. //
  863. Compare = ( ( ( PPORT_DESCRIPTOR )Descriptor1 )->GetPhysicalAddress() )->HighPart -
  864. ( ( ( PPORT_DESCRIPTOR )Descriptor2 )->GetPhysicalAddress() )->HighPart;
  865. if( Compare == 0 ) {
  866. Compare = ( ( ( PPORT_DESCRIPTOR )Descriptor1 )->GetPhysicalAddress() )->LowPart -
  867. ( ( ( PPORT_DESCRIPTOR )Descriptor2 )->GetPhysicalAddress() )->LowPart;
  868. }
  869. break;
  870. }
  871. return Compare;
  872. }
  873. case WM_COMMAND:
  874. switch( LOWORD( wParam ) ) {
  875. case IDOK:
  876. case IDCANCEL:
  877. EndDialog( hDlg, TRUE );
  878. return( TRUE );
  879. case IDC_FULL_RES_LIST_DMA:
  880. switch( HIWORD( wParam )) {
  881. case LBN_SELCHANGE:
  882. {
  883. PCPARTIAL_DESCRIPTOR Descriptor;
  884. LastSelectedDevSpecific = NULL;
  885. //
  886. // Remove the selection from the other list boxes
  887. //
  888. SendDlgItemMessage( hDlg,
  889. IDC_FULL_RES_LIST_INTERRUPTS,
  890. LB_SETCURSEL,
  891. (WPARAM) -1,
  892. 0 );
  893. SendDlgItemMessage( hDlg,
  894. IDC_FULL_RES_LIST_MEMORY,
  895. LB_SETCURSEL,
  896. (WPARAM) -1,
  897. 0 );
  898. SendDlgItemMessage( hDlg,
  899. IDC_FULL_RES_LIST_PORTS,
  900. LB_SETCURSEL,
  901. (WPARAM) -1,
  902. 0 );
  903. SendDlgItemMessage( hDlg,
  904. IDC_FULL_RES_LIST_DEVICE_SPECIFIC,
  905. LB_SETCURSEL,
  906. (WPARAM) -1,
  907. 0 );
  908. //
  909. // Get the PARTIAL_DESCRIPTOR for the currently selected
  910. // resource and update the share disposition display.
  911. //
  912. Descriptor = ( PCPARTIAL_DESCRIPTOR )_GetSelectedItem( hDlg,
  913. LOWORD( wParam ) );
  914. if( Descriptor != NULL )
  915. {
  916. _UpdateShareDisplay( hDlg, Descriptor );
  917. }
  918. //
  919. // Disable the Data... button.
  920. //
  921. EnableWindow( GetDlgItem( hDlg, IDC_PUSH_DISPLAY_DATA ),
  922. FALSE );
  923. return( TRUE );
  924. }
  925. }
  926. break;
  927. case IDC_FULL_RES_LIST_INTERRUPTS:
  928. switch( HIWORD( wParam )) {
  929. case LBN_SELCHANGE:
  930. {
  931. PCPARTIAL_DESCRIPTOR Descriptor;
  932. LastSelectedDevSpecific = NULL;
  933. //
  934. // Remove the selection from the other list boxes
  935. //
  936. SendDlgItemMessage( hDlg,
  937. IDC_FULL_RES_LIST_DMA,
  938. LB_SETCURSEL,
  939. (WPARAM) -1,
  940. 0 );
  941. SendDlgItemMessage( hDlg,
  942. IDC_FULL_RES_LIST_MEMORY,
  943. LB_SETCURSEL,
  944. (WPARAM) -1,
  945. 0 );
  946. SendDlgItemMessage( hDlg,
  947. IDC_FULL_RES_LIST_PORTS,
  948. LB_SETCURSEL,
  949. (WPARAM) -1,
  950. 0 );
  951. SendDlgItemMessage( hDlg,
  952. IDC_FULL_RES_LIST_DEVICE_SPECIFIC,
  953. LB_SETCURSEL,
  954. (WPARAM) -1,
  955. 0 );
  956. //
  957. // Get the PARTIAL_DESCRIPTOR for the currently selected
  958. // resource and update the share disposition display.
  959. //
  960. Descriptor = ( PCPARTIAL_DESCRIPTOR )_GetSelectedItem( hDlg,
  961. LOWORD( wParam ) );
  962. if( Descriptor != NULL )
  963. {
  964. _UpdateShareDisplay( hDlg, Descriptor );
  965. }
  966. //
  967. // Disable the Data... button.
  968. //
  969. EnableWindow( GetDlgItem( hDlg, IDC_PUSH_DISPLAY_DATA ),
  970. FALSE );
  971. return( TRUE );
  972. }
  973. }
  974. break;
  975. case IDC_FULL_RES_LIST_MEMORY:
  976. switch( HIWORD( wParam )) {
  977. case LBN_SELCHANGE:
  978. {
  979. PCPARTIAL_DESCRIPTOR Descriptor;
  980. LastSelectedDevSpecific = NULL;
  981. //
  982. // Remove the selection from the other list boxes
  983. //
  984. SendDlgItemMessage( hDlg,
  985. IDC_FULL_RES_LIST_DMA,
  986. LB_SETCURSEL,
  987. (WPARAM) -1,
  988. 0 );
  989. SendDlgItemMessage( hDlg,
  990. IDC_FULL_RES_LIST_INTERRUPTS,
  991. LB_SETCURSEL,
  992. (WPARAM) -1,
  993. 0 );
  994. SendDlgItemMessage( hDlg,
  995. IDC_FULL_RES_LIST_PORTS,
  996. LB_SETCURSEL,
  997. (WPARAM) -1,
  998. 0 );
  999. SendDlgItemMessage( hDlg,
  1000. IDC_FULL_RES_LIST_DEVICE_SPECIFIC,
  1001. LB_SETCURSEL,
  1002. (WPARAM) -1,
  1003. 0 );
  1004. //
  1005. // Get the PARTIAL_DESCRIPTOR for the currently selected
  1006. // resource and update the share disposition display.
  1007. //
  1008. Descriptor = ( PCPARTIAL_DESCRIPTOR )_GetSelectedItem( hDlg,
  1009. LOWORD( wParam ) );
  1010. if( Descriptor != NULL )
  1011. {
  1012. _UpdateShareDisplay( hDlg, Descriptor );
  1013. }
  1014. //
  1015. // Disable the Data... button.
  1016. //
  1017. EnableWindow( GetDlgItem( hDlg, IDC_PUSH_DISPLAY_DATA ),
  1018. FALSE );
  1019. return( TRUE );
  1020. }
  1021. }
  1022. break;
  1023. case IDC_FULL_RES_LIST_PORTS:
  1024. switch( HIWORD( wParam )) {
  1025. case LBN_SELCHANGE:
  1026. {
  1027. PCPARTIAL_DESCRIPTOR Descriptor;
  1028. LastSelectedDevSpecific = NULL;
  1029. //
  1030. // Remove the selection from the other list boxes
  1031. //
  1032. SendDlgItemMessage( hDlg,
  1033. IDC_FULL_RES_LIST_DMA,
  1034. LB_SETCURSEL,
  1035. (WPARAM) -1,
  1036. 0 );
  1037. SendDlgItemMessage( hDlg,
  1038. IDC_FULL_RES_LIST_INTERRUPTS,
  1039. LB_SETCURSEL,
  1040. (WPARAM) -1,
  1041. 0 );
  1042. SendDlgItemMessage( hDlg,
  1043. IDC_FULL_RES_LIST_MEMORY,
  1044. LB_SETCURSEL,
  1045. (WPARAM) -1,
  1046. 0 );
  1047. SendDlgItemMessage( hDlg,
  1048. IDC_FULL_RES_LIST_DEVICE_SPECIFIC,
  1049. LB_SETCURSEL,
  1050. (WPARAM) -1,
  1051. 0 );
  1052. //
  1053. // Get the PARTIAL_DESCRIPTOR for the currently selected
  1054. // resource and update the share disposition display.
  1055. //
  1056. Descriptor = ( PCPARTIAL_DESCRIPTOR )_GetSelectedItem( hDlg,
  1057. LOWORD( wParam ) );
  1058. if( Descriptor != NULL )
  1059. {
  1060. _UpdateShareDisplay( hDlg, Descriptor );
  1061. }
  1062. //
  1063. // Disable the Data... button.
  1064. //
  1065. EnableWindow( GetDlgItem( hDlg, IDC_PUSH_DISPLAY_DATA ),
  1066. FALSE );
  1067. return( TRUE );
  1068. }
  1069. }
  1070. break;
  1071. case IDC_FULL_RES_LIST_DEVICE_SPECIFIC:
  1072. switch( HIWORD( wParam )) {
  1073. case LBN_SELCHANGE:
  1074. {
  1075. PCPARTIAL_DESCRIPTOR Descriptor;
  1076. PCBYTE Pointer;
  1077. //
  1078. // Remove the selection from the other list boxes
  1079. //
  1080. SendDlgItemMessage( hDlg,
  1081. IDC_FULL_RES_LIST_DMA,
  1082. LB_SETCURSEL,
  1083. (WPARAM) -1,
  1084. 0 );
  1085. SendDlgItemMessage( hDlg,
  1086. IDC_FULL_RES_LIST_INTERRUPTS,
  1087. LB_SETCURSEL,
  1088. (WPARAM) -1,
  1089. 0 );
  1090. SendDlgItemMessage( hDlg,
  1091. IDC_FULL_RES_LIST_MEMORY,
  1092. LB_SETCURSEL,
  1093. (WPARAM) -1,
  1094. 0 );
  1095. SendDlgItemMessage( hDlg,
  1096. IDC_FULL_RES_LIST_PORTS,
  1097. LB_SETCURSEL,
  1098. (WPARAM) -1,
  1099. 0 );
  1100. //
  1101. // Get the PARTIAL_DESCRIPTOR for the currently selected
  1102. // resource and update the share disposition display.
  1103. //
  1104. Descriptor = ( PCPARTIAL_DESCRIPTOR )_GetSelectedItem( hDlg,
  1105. LOWORD( wParam ) );
  1106. LastSelectedDevSpecific = ( PCDEVICE_SPECIFIC_DESCRIPTOR )Descriptor;
  1107. if( Descriptor != NULL )
  1108. {
  1109. _UpdateShareDisplay( hDlg, Descriptor );
  1110. }
  1111. //
  1112. // Enable the Data... button if necessary.
  1113. //
  1114. EnableWindow( GetDlgItem( hDlg, IDC_PUSH_DISPLAY_DATA ),
  1115. ( ( Descriptor != NULL ) &&
  1116. Descriptor->IsDescriptorTypeDeviceSpecific() &&
  1117. ( ( ( PCDEVICE_SPECIFIC_DESCRIPTOR )Descriptor )->GetData( &Pointer ) != 0 )
  1118. )
  1119. );
  1120. return( TRUE );
  1121. }
  1122. case LBN_DBLCLK:
  1123. {
  1124. //
  1125. // Simulate that the details button was pushed
  1126. //
  1127. SendMessage( hDlg,
  1128. WM_COMMAND,
  1129. MAKEWPARAM( IDC_PUSH_DISPLAY_DATA, BN_CLICKED ),
  1130. ( LPARAM ) GetDlgItem( hDlg, IDC_PUSH_DISPLAY_DATA ) );
  1131. return( TRUE ); // 0;
  1132. }
  1133. }
  1134. break;
  1135. case IDC_PUSH_DISPLAY_DATA:
  1136. {
  1137. //
  1138. // Display the device specific data
  1139. //
  1140. if( ( LastSelectedDevSpecific != NULL ) &&
  1141. ( ( Size = LastSelectedDevSpecific->GetData( &Pointer ) ) != 0 )
  1142. )
  1143. {
  1144. _DisplayBinaryData( hDlg, Pointer, Size);
  1145. }
  1146. return( TRUE );
  1147. }
  1148. break;
  1149. }
  1150. }
  1151. return( FALSE );
  1152. }
  1153. //------------------------------------------------------------------------------
  1154. // _DisplayRequirementsListDialogProc
  1155. //
  1156. // DESCRIPTION: The dialog procedure for displaying data of type
  1157. // REG_RESOURCE_REQUIREMENTS_LIST.
  1158. //
  1159. // PARAMETERS: hDlg - a handle to the dialog proceedure.
  1160. // dwMsg - the message passed from Windows.
  1161. // wParam - extra message dependent data.
  1162. // lParam - extra message dependent data.
  1163. //------------------------------------------------------------------------------
  1164. BOOL REGISTRY_DATA::_DisplayRequirementsListDialogProc(HWND hDlg, DWORD dwMsg,
  1165. WPARAM wParam, LPARAM lParam)
  1166. {
  1167. switch(dwMsg)
  1168. {
  1169. case WM_INITDIALOG:
  1170. {
  1171. LPCWSTR InterfaceString;
  1172. LPCWSTR DescriptorTypeString;
  1173. ULONG StringSize;
  1174. PCIO_REQUIREMENTS_LIST RequirementsList;
  1175. WCHAR BusNumberString[ MAX_LENGTH_DWORD_STRING ];
  1176. WCHAR SlotNumberString[ MAX_LENGTH_DWORD_STRING ];
  1177. PARRAY AlternativeLists;
  1178. PITERATOR AlternativeListsIterator;
  1179. ULONG AlternativeListNumber;
  1180. WCHAR AlternativeListNumberString[ MAX_LENGTH_DWORD_STRING ];
  1181. PCIO_DESCRIPTOR_LIST IoDescriptorList;
  1182. CLB_ROW ClbRow;
  1183. CLB_STRING ClbString[ ] = {
  1184. { NULL, 0, CLB_LEFT, NULL },
  1185. { NULL, 0, CLB_LEFT, NULL },
  1186. { NULL, 0, CLB_LEFT, NULL },
  1187. { NULL, 0, CLB_LEFT, NULL }
  1188. };
  1189. if( ( RequirementsList = ( PCIO_REQUIREMENTS_LIST )lParam ) == NULL ) {
  1190. EndDialog( hDlg, 0 );
  1191. return( TRUE );
  1192. }
  1193. //
  1194. // Write the interface type
  1195. //
  1196. switch( RequirementsList->GetInterfaceType() ) {
  1197. case Internal:
  1198. InterfaceString = s_MsgBusInternal->GetWSTR();
  1199. break;
  1200. case Isa:
  1201. InterfaceString = s_MsgBusIsa->GetWSTR();
  1202. break;
  1203. case Eisa:
  1204. InterfaceString = s_MsgBusEisa->GetWSTR();
  1205. break;
  1206. case MicroChannel:
  1207. InterfaceString = s_MsgBusMicroChannel->GetWSTR();
  1208. break;
  1209. case TurboChannel:
  1210. InterfaceString = s_MsgBusTurboChannel->GetWSTR();
  1211. break;
  1212. case PCIBus:
  1213. InterfaceString = s_MsgBusPCIBus->GetWSTR();
  1214. break;
  1215. case VMEBus:
  1216. InterfaceString = s_MsgBusVMEBus->GetWSTR();
  1217. break;
  1218. case NuBus:
  1219. InterfaceString = s_MsgBusNuBus->GetWSTR();
  1220. break;
  1221. case PCMCIABus:
  1222. InterfaceString = s_MsgBusPCMCIABus->GetWSTR();
  1223. break;
  1224. case CBus:
  1225. InterfaceString = s_MsgBusCBus->GetWSTR();
  1226. break;
  1227. case MPIBus:
  1228. InterfaceString = s_MsgBusMPIBus->GetWSTR();
  1229. break;
  1230. case MPSABus:
  1231. InterfaceString = s_MsgBusMPSABus->GetWSTR();
  1232. break;
  1233. default:
  1234. InterfaceString = s_MsgInvalid->GetWSTR();
  1235. break;
  1236. }
  1237. SendDlgItemMessage( hDlg,
  1238. IDC_IO_REQ_TEXT_INTERFACE_TYPE,
  1239. WM_SETTEXT,
  1240. 0,
  1241. ( LPARAM )InterfaceString );
  1242. //
  1243. // Write the bus number
  1244. //
  1245. swprintf( BusNumberString, ( LPWSTR )L"%d", RequirementsList->GetBusNumber() );
  1246. SendDlgItemMessage( hDlg,
  1247. IDC_IO_REQ_TEXT_BUS_NUMBER,
  1248. WM_SETTEXT,
  1249. 0,
  1250. ( LPARAM )BusNumberString );
  1251. //
  1252. // Write the slot number
  1253. //
  1254. swprintf( SlotNumberString, ( LPWSTR )L"%d", RequirementsList->GetSlotNumber() );
  1255. SendDlgItemMessage( hDlg,
  1256. IDC_IO_REQ_TEXT_SLOT_NUMBER,
  1257. WM_SETTEXT,
  1258. 0,
  1259. ( LPARAM )SlotNumberString );
  1260. //
  1261. // Write the entries in the column list box
  1262. //
  1263. if( ( ( AlternativeLists = RequirementsList->GetAlternativeLists() ) == NULL ) ||
  1264. ( ( AlternativeListsIterator = AlternativeLists->QueryIterator() ) == NULL ) ) {
  1265. EndDialog( hDlg, 0 );
  1266. return( TRUE );
  1267. }
  1268. AlternativeListNumber = 0;
  1269. while( ( IoDescriptorList = ( PCIO_DESCRIPTOR_LIST )AlternativeListsIterator->GetNext() ) != NULL ) {
  1270. PARRAY IoDescriptors;
  1271. PITERATOR IoDescriptorListIterator;
  1272. PCIO_DESCRIPTOR Descriptor;
  1273. ULONG SubListNumber;
  1274. WCHAR SubListNumberString[ MAX_LENGTH_DWORD_STRING ];
  1275. ULONG DescriptorNumber;
  1276. WCHAR DescriptorNumberString[ MAX_LENGTH_DWORD_STRING ];
  1277. if( ( ( IoDescriptors = ( PARRAY )IoDescriptorList->GetDescriptorsList() ) == NULL ) ||
  1278. ( ( IoDescriptorListIterator = IoDescriptors->QueryIterator() ) == NULL ) ) {
  1279. DELETE( AlternativeListsIterator );
  1280. EndDialog( hDlg, 0 );
  1281. return( TRUE );
  1282. }
  1283. AlternativeListNumber++;
  1284. swprintf( AlternativeListNumberString, ( LPWSTR )L"%d", AlternativeListNumber );
  1285. SubListNumber = 0;
  1286. while( ( Descriptor = ( PCIO_DESCRIPTOR )IoDescriptorListIterator->GetNext() ) != NULL ) {
  1287. if( ( !Descriptor->IsResourceOptionAlternative() ) ||
  1288. ( SubListNumber == 0 ) ) {
  1289. SubListNumber++;
  1290. DescriptorNumber = 0;
  1291. }
  1292. DescriptorNumber++;
  1293. swprintf( SubListNumberString, ( LPWSTR )L"%d", SubListNumber );
  1294. swprintf( DescriptorNumberString, ( LPWSTR )L"%d", DescriptorNumber );
  1295. if( Descriptor->IsDescriptorTypePort() ) {
  1296. DescriptorTypeString = s_MsgDevPort->GetWSTR();
  1297. StringSize = s_MsgDevPort->QueryChCount();
  1298. } else if( Descriptor->IsDescriptorTypeInterrupt() ) {
  1299. DescriptorTypeString = s_MsgDevInterrupt->GetWSTR();
  1300. StringSize = s_MsgDevInterrupt->QueryChCount();
  1301. } else if( Descriptor->IsDescriptorTypeMemory() ) {
  1302. DescriptorTypeString = s_MsgDevMemory->GetWSTR();
  1303. StringSize = s_MsgDevMemory->QueryChCount();
  1304. } else if( Descriptor->IsDescriptorTypeDma() ) {
  1305. DescriptorTypeString = s_MsgDevDma->GetWSTR();
  1306. StringSize = s_MsgDevDma->QueryChCount();
  1307. } else {
  1308. DescriptorTypeString = s_MsgInvalid->GetWSTR();
  1309. StringSize = s_MsgInvalid->QueryChCount();
  1310. }
  1311. ClbString[ 0 ].String = ( LPWSTR )AlternativeListNumberString;
  1312. ClbString[ 0 ].Length = wcslen( AlternativeListNumberString );
  1313. ClbString[ 0 ].Format = CLB_LEFT;
  1314. ClbString[ 1 ].String = ( LPWSTR )SubListNumberString;
  1315. ClbString[ 1 ].Format = CLB_LEFT;
  1316. ClbString[ 1 ].Length = wcslen( SubListNumberString );
  1317. ClbString[ 2 ].String = ( LPWSTR )DescriptorNumberString;
  1318. ClbString[ 2 ].Format = CLB_LEFT;
  1319. ClbString[ 2 ].Length = wcslen( DescriptorNumberString );
  1320. ClbString[ 3 ].String = ( LPWSTR )DescriptorTypeString;
  1321. ClbString[ 3 ].Format = CLB_LEFT;
  1322. ClbString[ 3 ].Length = StringSize;
  1323. ClbRow.Count = 4;
  1324. ClbRow.Strings = ClbString;
  1325. ClbRow.Data = ( PVOID )Descriptor;
  1326. ClbAddData( hDlg,
  1327. IDC_IO_LIST_ALTERNATIVE_LISTS,
  1328. &ClbRow );
  1329. }
  1330. DELETE( IoDescriptorListIterator );
  1331. }
  1332. DELETE( AlternativeListsIterator );
  1333. //
  1334. // Disble the Display button
  1335. //
  1336. EnableWindow( GetDlgItem( hDlg, IDC_IO_REQ_PUSH_DISPLAY_DEVICE ), FALSE );
  1337. return( TRUE );
  1338. }
  1339. case WM_COMMAND:
  1340. switch( LOWORD( wParam ) ) {
  1341. case IDOK:
  1342. case IDCANCEL:
  1343. EndDialog( hDlg, TRUE );
  1344. return( TRUE );
  1345. case IDC_IO_LIST_ALTERNATIVE_LISTS:
  1346. {
  1347. switch( HIWORD( wParam )) {
  1348. case LBN_SELCHANGE:
  1349. {
  1350. //
  1351. // Enable the display device details button
  1352. //
  1353. EnableWindow( GetDlgItem( hDlg, IDC_IO_REQ_PUSH_DISPLAY_DEVICE ),
  1354. TRUE );
  1355. return 0;
  1356. }
  1357. case LBN_DBLCLK:
  1358. {
  1359. //
  1360. // Simulate that the details button was pushed
  1361. //
  1362. SendMessage( hDlg,
  1363. WM_COMMAND,
  1364. MAKEWPARAM( IDC_IO_REQ_PUSH_DISPLAY_DEVICE, BN_CLICKED ),
  1365. ( LPARAM ) GetDlgItem( hDlg, IDC_IO_REQ_PUSH_DISPLAY_DEVICE ) );
  1366. return 0;
  1367. }
  1368. }
  1369. break;
  1370. }
  1371. case IDC_IO_REQ_PUSH_DISPLAY_DEVICE:
  1372. {
  1373. PCIO_DESCRIPTOR IoDescriptor;
  1374. IoDescriptor = ( PCIO_DESCRIPTOR )( _GetSelectedItem ( hDlg, IDC_IO_LIST_ALTERNATIVE_LISTS ) );
  1375. if( IoDescriptor != NULL )
  1376. {
  1377. _DisplayIoDescriptor( hDlg, IoDescriptor );
  1378. }
  1379. return( TRUE );
  1380. }
  1381. }
  1382. }
  1383. return( FALSE );
  1384. }
  1385. //------------------------------------------------------------------------------
  1386. // _DisplayIoPortDialogProc
  1387. //
  1388. // DESCRIPTION: The dialog proceedure for displaying an object of type IO_PORT.
  1389. //
  1390. // PARAMETERS: hDlg - a handle to the dialog proceedure.
  1391. // dwMsg - the message passed from Windows.
  1392. // wParam - extra message dependent data.
  1393. // lParam - extra message dependent data.
  1394. //------------------------------------------------------------------------------
  1395. BOOL
  1396. APIENTRY
  1397. REGISTRY_DATA::_DisplayIoPortDialogProc(HWND hDlg, DWORD dwMsg, WPARAM wParam, LPARAM lParam)
  1398. {
  1399. switch(dwMsg)
  1400. {
  1401. case WM_INITDIALOG:
  1402. {
  1403. PCIO_PORT_DESCRIPTOR Port;
  1404. PCWSTRING String;
  1405. WCHAR AddressString[ MAX_LENGTH_BIG_INT_STRING ];
  1406. if( ( Port = ( PCIO_PORT_DESCRIPTOR )lParam ) == NULL ) {
  1407. EndDialog( hDlg, 0 );
  1408. return( TRUE );
  1409. }
  1410. //
  1411. // Write the port type
  1412. //
  1413. if( Port->IsPortMemory() ) {
  1414. String = s_MsgPortMemory;
  1415. } else if( Port->IsPortIo() ){
  1416. String = s_MsgPortPort;
  1417. } else {
  1418. String = s_MsgInvalid;
  1419. }
  1420. SendDlgItemMessage( hDlg,
  1421. IDC_IO_TEXT_PORT_TYPE,
  1422. WM_SETTEXT,
  1423. 0,
  1424. ( LPARAM ) String->GetWSTR() );
  1425. //
  1426. // Write the length
  1427. //
  1428. swprintf( AddressString,
  1429. ( LPWSTR )L"%#x",
  1430. Port->GetLength() );
  1431. SendDlgItemMessage( hDlg,
  1432. IDC_IO_TEXT_PORT_LENGTH,
  1433. WM_SETTEXT,
  1434. 0,
  1435. ( LPARAM )AddressString );
  1436. //
  1437. // Write the alignment
  1438. //
  1439. swprintf( AddressString,
  1440. ( LPWSTR )L"%#x",
  1441. Port->GetAlignment() );
  1442. SendDlgItemMessage( hDlg,
  1443. IDC_IO_TEXT_PORT_ALIGNMENT,
  1444. WM_SETTEXT,
  1445. 0,
  1446. ( LPARAM )AddressString );
  1447. //
  1448. // Write the minimum address
  1449. //
  1450. if( ( ( ( PIO_PORT_DESCRIPTOR )Port )->GetMinimumAddress() )->HighPart != 0 ) {
  1451. swprintf( AddressString,
  1452. ( LPWSTR )L"0x%08x%08x",
  1453. ( ( ( PIO_PORT_DESCRIPTOR )Port )->GetMinimumAddress() )->HighPart,
  1454. ( ( ( PIO_PORT_DESCRIPTOR )Port )->GetMinimumAddress() )->LowPart );
  1455. } else {
  1456. swprintf( AddressString,
  1457. ( LPWSTR )L"0x%08x",
  1458. ( ( ( PIO_PORT_DESCRIPTOR )Port )->GetMinimumAddress() )->LowPart );
  1459. }
  1460. SendDlgItemMessage( hDlg,
  1461. IDC_IO_TEXT_PORT_MIN_ADDRESS,
  1462. WM_SETTEXT,
  1463. 0,
  1464. ( LPARAM )AddressString );
  1465. //
  1466. // Write the maximum address
  1467. //
  1468. if( ( ( ( PIO_PORT_DESCRIPTOR )Port )->GetMaximumAddress() )->HighPart != 0 ) {
  1469. swprintf( AddressString,
  1470. ( LPWSTR )L"0x%08x%08x",
  1471. ( ( ( PIO_PORT_DESCRIPTOR )Port )->GetMaximumAddress() )->HighPart,
  1472. ( ( ( PIO_PORT_DESCRIPTOR )Port )->GetMaximumAddress() )->LowPart );
  1473. } else {
  1474. swprintf( AddressString,
  1475. ( LPWSTR )L"0x%08x",
  1476. ( ( ( PIO_PORT_DESCRIPTOR )Port )->GetMaximumAddress() )->LowPart );
  1477. }
  1478. SendDlgItemMessage( hDlg,
  1479. IDC_IO_TEXT_PORT_MAX_ADDRESS,
  1480. WM_SETTEXT,
  1481. 0,
  1482. ( LPARAM )AddressString );
  1483. //
  1484. // Write share disposition
  1485. //
  1486. if( Port->IsResourceShareUndetermined() ) {
  1487. String = s_MsgShareUndetermined;
  1488. } else if( Port->IsResourceShareDeviceExclusive() ) {
  1489. String = s_MsgShareDeviceExclusive;
  1490. } else if( Port->IsResourceShareDriverExclusive() ) {
  1491. String = s_MsgShareDriverExclusive;
  1492. } else if( Port->IsResourceShareShared() ) {
  1493. String = s_MsgShareShared;
  1494. } else {
  1495. String = s_MsgInvalid;
  1496. }
  1497. SendDlgItemMessage( hDlg,
  1498. IDC_IO_TEXT_DISPOSITION,
  1499. WM_SETTEXT,
  1500. 0,
  1501. ( LPARAM )String->GetWSTR() );
  1502. //
  1503. // Set the Options
  1504. //
  1505. _UpdateOptionDisplay( hDlg, ( PCIO_DESCRIPTOR )Port );
  1506. return( TRUE );
  1507. }
  1508. case WM_COMMAND:
  1509. switch( LOWORD( wParam ) ) {
  1510. case IDOK:
  1511. case IDCANCEL:
  1512. EndDialog( hDlg, TRUE );
  1513. return( TRUE );
  1514. }
  1515. }
  1516. return( FALSE );
  1517. }
  1518. //------------------------------------------------------------------------------
  1519. // _DisplayIoMemoryDialogProc
  1520. //
  1521. // DESCRIPTION: The dialog proceedure for displaying an object of type IO_PORT.
  1522. //
  1523. // PARAMETERS: hDlg - a handle to the dialog proceedure.
  1524. // dwMsg - the message passed from Windows.
  1525. // wParam - extra message dependent data.
  1526. // lParam - extra message dependent data.
  1527. //------------------------------------------------------------------------------
  1528. BOOL REGISTRY_DATA::_DisplayIoMemoryDialogProc(HWND hDlg, DWORD dwMsg, WPARAM wParam, LPARAM lParam)
  1529. {
  1530. switch(dwMsg)
  1531. {
  1532. case WM_INITDIALOG:
  1533. {
  1534. PCIO_MEMORY_DESCRIPTOR Memory;
  1535. PCWSTRING String;
  1536. WCHAR AddressString[ MAX_LENGTH_BIG_INT_STRING ];
  1537. if( ( Memory = ( PCIO_MEMORY_DESCRIPTOR )lParam ) == NULL )
  1538. {
  1539. EndDialog( hDlg, 0 );
  1540. return( TRUE );
  1541. }
  1542. //
  1543. // Write the memory access
  1544. //
  1545. if( Memory->IsMemoryReadWrite() ) {
  1546. String = s_MsgMemReadWrite;
  1547. } else if( Memory->IsMemoryReadOnly() ){
  1548. String = s_MsgMemReadOnly;
  1549. } else if( Memory->IsMemoryWriteOnly() ){
  1550. String = s_MsgMemWriteOnly;
  1551. } else {
  1552. String = s_MsgInvalid;
  1553. }
  1554. SendDlgItemMessage( hDlg,
  1555. IDC_IO_TEXT_MEM_ACCESS,
  1556. WM_SETTEXT,
  1557. 0,
  1558. ( LPARAM ) String->GetWSTR() );
  1559. //
  1560. // Write the length
  1561. //
  1562. swprintf( AddressString,
  1563. ( LPWSTR )L"%#x",
  1564. Memory->GetLength() );
  1565. SendDlgItemMessage( hDlg,
  1566. IDC_IO_TEXT_MEM_LENGTH,
  1567. WM_SETTEXT,
  1568. 0,
  1569. ( LPARAM )AddressString );
  1570. //
  1571. // Write the alignment
  1572. //
  1573. swprintf( AddressString,
  1574. ( LPWSTR )L"%#x",
  1575. Memory->GetAlignment() );
  1576. SendDlgItemMessage( hDlg,
  1577. IDC_IO_TEXT_MEM_ALIGNMENT,
  1578. WM_SETTEXT,
  1579. 0,
  1580. ( LPARAM )AddressString );
  1581. //
  1582. // Write the minimum address
  1583. //
  1584. if( ( ( ( PIO_MEMORY_DESCRIPTOR )Memory )->GetMinimumAddress() )->HighPart != 0 ) {
  1585. swprintf( AddressString,
  1586. ( LPWSTR )L"0x%08x%08x",
  1587. ( ( ( PIO_MEMORY_DESCRIPTOR )Memory )->GetMinimumAddress() )->HighPart,
  1588. ( ( ( PIO_MEMORY_DESCRIPTOR )Memory )->GetMinimumAddress() )->LowPart );
  1589. } else {
  1590. swprintf( AddressString,
  1591. ( LPWSTR )L"0x%08x",
  1592. ( ( ( PIO_MEMORY_DESCRIPTOR )Memory )->GetMinimumAddress() )->LowPart );
  1593. }
  1594. SendDlgItemMessage( hDlg,
  1595. IDC_IO_TEXT_MEM_MIN_ADDRESS,
  1596. WM_SETTEXT,
  1597. 0,
  1598. ( LPARAM )AddressString );
  1599. //
  1600. // Write the maximum address
  1601. //
  1602. if( ( ( ( PIO_MEMORY_DESCRIPTOR )Memory )->GetMaximumAddress() )->HighPart != 0 ) {
  1603. swprintf( AddressString,
  1604. ( LPWSTR )L"0x%08x%08x",
  1605. ( ( ( PIO_MEMORY_DESCRIPTOR )Memory )->GetMaximumAddress() )->HighPart,
  1606. ( ( ( PIO_MEMORY_DESCRIPTOR )Memory )->GetMaximumAddress() )->LowPart );
  1607. } else {
  1608. swprintf( AddressString,
  1609. ( LPWSTR )L"0x%08x",
  1610. ( ( ( PIO_MEMORY_DESCRIPTOR )Memory )->GetMaximumAddress() )->LowPart );
  1611. }
  1612. SendDlgItemMessage( hDlg,
  1613. IDC_IO_TEXT_MEM_MAX_ADDRESS,
  1614. WM_SETTEXT,
  1615. 0,
  1616. ( LPARAM )AddressString );
  1617. //
  1618. // Write share disposition
  1619. //
  1620. if( Memory->IsResourceShareUndetermined() ) {
  1621. String = s_MsgShareUndetermined;
  1622. } else if( Memory->IsResourceShareDeviceExclusive() ) {
  1623. String = s_MsgShareDeviceExclusive;
  1624. } else if( Memory->IsResourceShareDriverExclusive() ) {
  1625. String = s_MsgShareDriverExclusive;
  1626. } else if( Memory->IsResourceShareShared() ) {
  1627. String = s_MsgShareShared;
  1628. } else {
  1629. String = s_MsgInvalid;
  1630. }
  1631. SendDlgItemMessage( hDlg,
  1632. IDC_IO_TEXT_DISPOSITION,
  1633. WM_SETTEXT,
  1634. 0,
  1635. ( LPARAM )String->GetWSTR() );
  1636. //
  1637. // Set the Options
  1638. //
  1639. _UpdateOptionDisplay( hDlg, ( PCIO_DESCRIPTOR )Memory );
  1640. return( TRUE );
  1641. }
  1642. case WM_COMMAND:
  1643. switch( LOWORD( wParam ) ) {
  1644. case IDOK:
  1645. case IDCANCEL:
  1646. EndDialog( hDlg, TRUE );
  1647. return( TRUE );
  1648. }
  1649. }
  1650. return( FALSE );
  1651. }
  1652. //------------------------------------------------------------------------------
  1653. // _DisplayIoInterruptDialogProc
  1654. //
  1655. // DESCRIPTION: The dialog proceedure for displaying an object of type IO_PORT.
  1656. //
  1657. // PARAMETERS: hDlg - a handle to the dialog proceedure.
  1658. // dwMsg - the message passed from Windows.
  1659. // wParam - extra message dependent data.
  1660. // lParam - extra message dependent data.
  1661. //------------------------------------------------------------------------------
  1662. BOOL REGISTRY_DATA::_DisplayIoInterruptDialogProc(HWND hDlg, DWORD dwMsg,
  1663. WPARAM wParam, LPARAM lParam)
  1664. {
  1665. switch( dwMsg )
  1666. {
  1667. case WM_INITDIALOG:
  1668. {
  1669. PCIO_INTERRUPT_DESCRIPTOR Interrupt;
  1670. PCWSTRING String;
  1671. WCHAR AddressString[ MAX_LENGTH_DWORD_STRING ];
  1672. if( ( Interrupt = ( PCIO_INTERRUPT_DESCRIPTOR )lParam ) == NULL )
  1673. {
  1674. EndDialog( hDlg, 0 );
  1675. return( TRUE );
  1676. }
  1677. //
  1678. // Write the interrupt type
  1679. //
  1680. if( Interrupt->IsInterruptLevelSensitive() )
  1681. {
  1682. String = s_MsgIntLevelSensitive;
  1683. }
  1684. else if( Interrupt->IsInterruptLatched() )
  1685. {
  1686. String = s_MsgIntLatched;
  1687. }
  1688. else
  1689. {
  1690. String = s_MsgInvalid;
  1691. }
  1692. SendDlgItemMessage( hDlg,
  1693. IDC_IO_TEXT_INT_TYPE,
  1694. WM_SETTEXT,
  1695. 0,
  1696. ( LPARAM ) String->GetWSTR() );
  1697. //
  1698. // Write the minimum vector
  1699. //
  1700. swprintf( AddressString,
  1701. ( LPWSTR )L"%#x",
  1702. Interrupt->GetMinimumVector() );
  1703. SendDlgItemMessage( hDlg,
  1704. IDC_IO_TEXT_INT_MIN_VECTOR,
  1705. WM_SETTEXT,
  1706. 0,
  1707. ( LPARAM )AddressString );
  1708. //
  1709. // Write the maximum vector
  1710. //
  1711. swprintf( AddressString,
  1712. ( LPWSTR )L"%#x",
  1713. Interrupt->GetMaximumVector() );
  1714. SendDlgItemMessage( hDlg,
  1715. IDC_IO_TEXT_INT_MAX_VECTOR,
  1716. WM_SETTEXT,
  1717. 0,
  1718. ( LPARAM )AddressString );
  1719. //
  1720. // Write share disposition
  1721. //
  1722. if( Interrupt->IsResourceShareUndetermined() )
  1723. {
  1724. String = s_MsgShareUndetermined;
  1725. }
  1726. else if( Interrupt->IsResourceShareDeviceExclusive() )
  1727. {
  1728. String = s_MsgShareDeviceExclusive;
  1729. }
  1730. else if( Interrupt->IsResourceShareDriverExclusive() )
  1731. {
  1732. String = s_MsgShareDriverExclusive;
  1733. }
  1734. else if( Interrupt->IsResourceShareShared() )
  1735. {
  1736. String = s_MsgShareShared;
  1737. } else
  1738. {
  1739. String = s_MsgInvalid;
  1740. }
  1741. SendDlgItemMessage( hDlg,
  1742. IDC_IO_TEXT_DISPOSITION,
  1743. WM_SETTEXT,
  1744. 0,
  1745. ( LPARAM )String->GetWSTR() );
  1746. //
  1747. // Set the Options
  1748. //
  1749. _UpdateOptionDisplay( hDlg, ( PCIO_DESCRIPTOR )Interrupt );
  1750. return( TRUE );
  1751. }
  1752. case WM_COMMAND:
  1753. switch( LOWORD( wParam ) )
  1754. {
  1755. case IDOK:
  1756. case IDCANCEL:
  1757. EndDialog( hDlg, TRUE );
  1758. return( TRUE );
  1759. }
  1760. }
  1761. return( FALSE );
  1762. }
  1763. //------------------------------------------------------------------------------
  1764. // _DisplayIoDmaDialogProc
  1765. //
  1766. // DESCRIPTION: The dialog proceedure for displaying an object of type IO_PORT.
  1767. //
  1768. // PARAMETERS: hDlg - a handle to the dialog proceedure.
  1769. // dwMsg - the message passed from Windows.
  1770. // wParam - extra message dependent data.
  1771. // lParam - extra message dependent data.
  1772. //------------------------------------------------------------------------------
  1773. BOOL REGISTRY_DATA::_DisplayIoDmaDialogProc(HWND hDlg,DWORD dwMsg, WPARAM wParam,
  1774. LPARAM lParam)
  1775. {
  1776. switch(dwMsg)
  1777. {
  1778. case WM_INITDIALOG:
  1779. {
  1780. PCIO_DMA_DESCRIPTOR Dma;
  1781. PCWSTRING String;
  1782. WCHAR AddressString[ MAX_LENGTH_DWORD_STRING ];
  1783. if( ( Dma = ( PCIO_DMA_DESCRIPTOR )lParam ) == NULL )
  1784. {
  1785. EndDialog( hDlg, 0 );
  1786. return( TRUE );
  1787. }
  1788. //
  1789. // Write the minimum channel
  1790. //
  1791. swprintf( AddressString,
  1792. ( LPWSTR )L"%#x",
  1793. Dma->GetMinimumChannel() );
  1794. SendDlgItemMessage( hDlg,
  1795. IDC_IO_TEXT_DMA_MIN_CHANNEL,
  1796. WM_SETTEXT,
  1797. 0,
  1798. ( LPARAM )AddressString );
  1799. //
  1800. // Write the maximum channel
  1801. //
  1802. swprintf( AddressString,
  1803. ( LPWSTR )L"%#x",
  1804. Dma->GetMaximumChannel() );
  1805. SendDlgItemMessage( hDlg,
  1806. IDC_IO_TEXT_DMA_MAX_CHANNEL,
  1807. WM_SETTEXT,
  1808. 0,
  1809. ( LPARAM )AddressString );
  1810. //
  1811. // Write share disposition
  1812. //
  1813. if( Dma->IsResourceShareUndetermined() ) {
  1814. String = s_MsgShareUndetermined;
  1815. } else if( Dma->IsResourceShareDeviceExclusive() ) {
  1816. String = s_MsgShareDeviceExclusive;
  1817. } else if( Dma->IsResourceShareDriverExclusive() ) {
  1818. String = s_MsgShareDriverExclusive;
  1819. } else if( Dma->IsResourceShareShared() ) {
  1820. String = s_MsgShareShared;
  1821. } else {
  1822. String = s_MsgInvalid;
  1823. }
  1824. SendDlgItemMessage( hDlg,
  1825. IDC_IO_TEXT_DISPOSITION,
  1826. WM_SETTEXT,
  1827. 0,
  1828. ( LPARAM )String->GetWSTR() );
  1829. //
  1830. // Set the Options
  1831. //
  1832. _UpdateOptionDisplay( hDlg, ( PCIO_DESCRIPTOR )Dma );
  1833. return( TRUE );
  1834. }
  1835. case WM_COMMAND:
  1836. switch( LOWORD( wParam ) ) {
  1837. case IDOK:
  1838. case IDCANCEL:
  1839. EndDialog( hDlg, TRUE );
  1840. return( TRUE );
  1841. }
  1842. }
  1843. return( FALSE );
  1844. }
  1845. //------------------------------------------------------------------------------
  1846. // _GetSelectedItem
  1847. //
  1848. // DESCRIPTION: Retrieve the object associated to the currently selected row in
  1849. // a Clb.
  1850. //
  1851. // PARAMETERS: hDlg - Supplies the handle for the dialog that contains the
  1852. // selected Clb.
  1853. // ClbId - Id of the Clb that contains the selected row.
  1854. //------------------------------------------------------------------------------
  1855. PVOID REGISTRY_DATA::_GetSelectedItem (HWND hDlg, ULONG ClbId)
  1856. {
  1857. LONG Index;
  1858. LPCLB_ROW ClbRow;
  1859. PVOID Descriptor;
  1860. // Get the index of the currently selected item.
  1861. Index = (LONG)SendDlgItemMessage(hDlg, ClbId, LB_GETCURSEL, 0, 0);
  1862. if( Index == LB_ERR )
  1863. {
  1864. return NULL;
  1865. }
  1866. // Get the CLB_ROW object for this row and extract the associated
  1867. // object.
  1868. ClbRow = ( LPCLB_ROW ) SendDlgItemMessage(hDlg, ClbId, LB_GETITEMDATA, (WPARAM) Index, 0);
  1869. if(( ClbRow == NULL ) || (( LONG_PTR ) ClbRow ) == LB_ERR )
  1870. {
  1871. return NULL;
  1872. }
  1873. Descriptor = ClbRow->Data;
  1874. if( Descriptor == NULL )
  1875. {
  1876. return NULL;
  1877. }
  1878. return Descriptor;
  1879. }
  1880. //------------------------------------------------------------------------------
  1881. // _UpdateShareDisplay
  1882. //
  1883. // DESCRIPTION: UpdateShareDisplay hilights the appropriate sharing disposition text in
  1884. // the supplied dialog based on the share disposition of the PARTIAL_DESCRIPTOR
  1885. // object supplied.
  1886. //
  1887. // PARAMETERS: hWnd - Supplies window handle for the dialog box where share
  1888. // display is being updated.
  1889. // pDescriptor - Supplies a pointer to a PARTIAL_DESCRIPTOR object whose
  1890. // share disposition will be displayed.
  1891. //------------------------------------------------------------------------------
  1892. VOID REGISTRY_DATA::_UpdateShareDisplay(HWND hDlg, PCPARTIAL_DESCRIPTOR pDescriptor)
  1893. {
  1894. if(pDescriptor)
  1895. {
  1896. EnableWindow( GetDlgItem( hDlg, IDC_FULL_RES_TEXT_UNDETERMINED ),
  1897. pDescriptor->IsResourceShareUndetermined() );
  1898. EnableWindow( GetDlgItem( hDlg, IDC_FULL_RES_TEXT_DEVICE_EXCLUSIVE ),
  1899. pDescriptor->IsResourceShareDeviceExclusive() );
  1900. EnableWindow( GetDlgItem( hDlg, IDC_FULL_RES_TEXT_DRIVER_EXCLUSIVE ),
  1901. pDescriptor->IsResourceShareDriverExclusive() );
  1902. EnableWindow( GetDlgItem( hDlg,IDC_FULL_RES_TEXT_SHARED ),
  1903. pDescriptor->IsResourceShareShared() );
  1904. }
  1905. }
  1906. //------------------------------------------------------------------------------
  1907. // _UpdateOptionDisplay
  1908. //
  1909. // DESCRIPTION: UpdateOptionDisplay highlights the appropriate Option text in
  1910. // the supplied IO_DESCRIPTOR dialog based on the Option of the
  1911. // IO_DESCRIPTOR object supplied.
  1912. //
  1913. // PARAMETERS: hWnd - Supplies window handle for the dialog box where share
  1914. // display is being updated.
  1915. // pDescriptor - Supplies a pointer to a PARTIAL_DESCRIPTOR object whose
  1916. // share disposition will be displayed.
  1917. //------------------------------------------------------------------------------
  1918. VOID REGISTRY_DATA::_UpdateOptionDisplay(HWND hDlg, PCIO_DESCRIPTOR pDescriptor)
  1919. {
  1920. if(pDescriptor)
  1921. {
  1922. EnableWindow( GetDlgItem( hDlg, IDC_IO_TEXT_OPTION_PREFERRED ),
  1923. pDescriptor->IsResourceOptionPreferred() );
  1924. EnableWindow( GetDlgItem( hDlg, IDC_IO_TEXT_OPTION_ALTERNATIVE ),
  1925. pDescriptor->IsResourceOptionAlternative() );
  1926. }
  1927. }
  1928. VOID DisplayBinaryData(HWND hWnd, LPEDITVALUEPARAM lpEditValueParam, DWORD dwValueType)
  1929. {
  1930. PBYTE pbValueData = lpEditValueParam->pValueData;
  1931. UINT cbValueData = lpEditValueParam->cbValueData;
  1932. REGISTRY_DATA::_DisplayBinaryData(hWnd, pbValueData, cbValueData,
  1933. TRUE, dwValueType);
  1934. }
  1935. //------------------------------------------------------------------------------
  1936. // _DisplayBinaryData
  1937. //
  1938. // DESCRIPTION: Display the contents of a buffer as binary data, in an hd-like
  1939. // format.
  1940. //
  1941. // PARAMETERS: hWnd - A handle to the owner window.
  1942. // Data - Pointer to the buffer that contains the data to be displayed.
  1943. // DataSize - Number of bytes in the buffer.
  1944. // DisplayValueType - A flag that indicates whether or not the value type of the
  1945. // data should be displayed as a binary number.
  1946. // ValueType - A number representing the data type. This parameter is ignored if
  1947. // DisplayValueTRype is FALSE.
  1948. //------------------------------------------------------------------------------
  1949. VOID REGISTRY_DATA::_DisplayBinaryData(HWND hWnd, PCBYTE Data, ULONG DataSize,
  1950. BOOL fDisplayValueType, DWORD dwValueType)
  1951. {
  1952. BUFFER_INFORMATION BufferInfo;
  1953. BufferInfo.Buffer = ( PBYTE )Data;
  1954. BufferInfo.BufferSize = DataSize;
  1955. BufferInfo.DisplayValueType = fDisplayValueType;
  1956. BufferInfo.ValueType = dwValueType;
  1957. DialogBoxParam(g_hInstance,
  1958. ( BufferInfo.DisplayValueType )? MAKEINTRESOURCE( IDD_DISPLAY_BINARY_DATA_VALUE_TYPE ) :
  1959. MAKEINTRESOURCE( IDD_DISPLAY_BINARY_DATA ),
  1960. hWnd,
  1961. ( DLGPROC )REGISTRY_DATA::_DisplayBinaryDataDialogProc,
  1962. ( LPARAM )&BufferInfo );
  1963. }
  1964. //------------------------------------------------------------------------------
  1965. // _DisplayBinaryDataDialogProc
  1966. //
  1967. // DESCRIPTION: This is the dialog procedure used in the dialog that displays
  1968. // the data in a value entry as binary data, using a format similar
  1969. // to the one used by the 'hd' utility.
  1970. //
  1971. // PARAMETERS: hDlg - a handle to the dialog proceedure.
  1972. // dwMsg - the message passed from Windows.
  1973. // wParam - extra message dependent data.
  1974. // lParam - extra message dependent data.
  1975. //------------------------------------------------------------------------------
  1976. BOOL REGISTRY_DATA::_DisplayBinaryDataDialogProc(HWND hDlg, DWORD dwMsg, WPARAM wParam,
  1977. LPARAM lParam)
  1978. {
  1979. STATIC PCBYTE Data;
  1980. STATIC ULONG Size;
  1981. STATIC ULONG CurrentFormat;
  1982. STATIC BOOL DisplayValueType;
  1983. STATIC ULONG ValueType;
  1984. switch( dwMsg )
  1985. {
  1986. case WM_INITDIALOG:
  1987. {
  1988. WCHAR AuxBuffer[16];
  1989. //
  1990. // Validate arguments and initialize static data
  1991. //
  1992. if( lParam == NULL ) {
  1993. EndDialog( hDlg, 0 );
  1994. return( TRUE );
  1995. }
  1996. Data = ( ( PBUFFER_INFORMATION )lParam )->Buffer;
  1997. Size = ( ( PBUFFER_INFORMATION )lParam )->BufferSize;
  1998. DisplayValueType = ( ( PBUFFER_INFORMATION )lParam )->DisplayValueType;
  1999. ValueType = ( ( PBUFFER_INFORMATION )lParam )->ValueType;
  2000. //
  2001. // Display value type as an hex number if necessary
  2002. //
  2003. if( DisplayValueType ) {
  2004. swprintf( AuxBuffer, ( LPWSTR )L"%#x", ValueType );
  2005. SendDlgItemMessage( hDlg,
  2006. IDT_VALUE_TYPE,
  2007. WM_SETTEXT,
  2008. 0,
  2009. ( LPARAM )AuxBuffer );
  2010. }
  2011. //
  2012. // Use fixed size font
  2013. //
  2014. SendDlgItemMessage( hDlg,
  2015. IDD_DISPLAY_DATA_BINARY,
  2016. WM_SETFONT,
  2017. ( WPARAM )GetStockObject( ANSI_FIXED_FONT ),
  2018. FALSE );
  2019. //
  2020. // Display the data in the listbox.
  2021. //
  2022. SendDlgItemMessage( hDlg,
  2023. IDC_BINARY_DATA_BYTE,
  2024. BM_SETCHECK,
  2025. ( WPARAM )TRUE,
  2026. 0 );
  2027. _DumpBinaryData( hDlg, Data, Size );
  2028. CurrentFormat = IDC_BINARY_DATA_BYTE;
  2029. return( TRUE );
  2030. }
  2031. case WM_COMMAND:
  2032. switch( LOWORD( wParam ) ) {
  2033. case IDCANCEL:
  2034. case IDOK:
  2035. EndDialog( hDlg, TRUE );
  2036. return( TRUE );
  2037. case IDC_BINARY_DATA_BYTE:
  2038. case IDC_BINARY_DATA_WORD:
  2039. case IDC_BINARY_DATA_DWORD:
  2040. switch( HIWORD( wParam ) ) {
  2041. case BN_CLICKED:
  2042. {
  2043. ULONG TopIndex;
  2044. ULONG CurrentIndex;
  2045. //
  2046. // Ignore massage if new format is already the current format
  2047. //
  2048. if( CurrentFormat == LOWORD( wParam ) ) {
  2049. return( FALSE );
  2050. }
  2051. //
  2052. // Save the position of current selection
  2053. //
  2054. TopIndex = (ULONG)SendDlgItemMessage( hDlg,
  2055. IDD_DISPLAY_DATA_BINARY,
  2056. LB_GETTOPINDEX,
  2057. 0,
  2058. 0 );
  2059. CurrentIndex = ( ULONG )SendDlgItemMessage( hDlg,
  2060. IDD_DISPLAY_DATA_BINARY,
  2061. LB_GETCURSEL,
  2062. 0,
  2063. 0 );
  2064. //
  2065. // Reset the listbox
  2066. //
  2067. SendDlgItemMessage( hDlg,
  2068. IDD_DISPLAY_DATA_BINARY,
  2069. LB_RESETCONTENT,
  2070. 0,
  2071. 0 );
  2072. //
  2073. // Display the data in the appropriate format
  2074. //
  2075. if( LOWORD( wParam ) == IDC_BINARY_DATA_BYTE ) {
  2076. _DumpBinaryData( hDlg, Data, Size );
  2077. CurrentFormat = IDC_BINARY_DATA_BYTE;
  2078. } else if( LOWORD( wParam ) == IDC_BINARY_DATA_WORD ) {
  2079. _DumpBinaryDataAsWords( hDlg, Data, Size );
  2080. CurrentFormat = IDC_BINARY_DATA_WORD;
  2081. } else {
  2082. _DumpBinaryDataAsDwords( hDlg, Data, Size );
  2083. CurrentFormat = IDC_BINARY_DATA_DWORD;
  2084. }
  2085. //
  2086. // Restore current selection
  2087. //
  2088. SendDlgItemMessage( hDlg,
  2089. IDD_DISPLAY_DATA_BINARY,
  2090. LB_SETTOPINDEX,
  2091. ( WPARAM )TopIndex,
  2092. 0 );
  2093. if( CurrentIndex != LB_ERR ) {
  2094. SendDlgItemMessage( hDlg,
  2095. IDD_DISPLAY_DATA_BINARY,
  2096. LB_SETCURSEL,
  2097. ( WPARAM )CurrentIndex,
  2098. 0 );
  2099. }
  2100. return( TRUE );
  2101. }
  2102. default:
  2103. break;
  2104. }
  2105. break;
  2106. default:
  2107. break;
  2108. }
  2109. break;
  2110. default:
  2111. break;
  2112. }
  2113. return( FALSE );
  2114. }
  2115. //------------------------------------------------------------------------------
  2116. // _DumpBinaryData
  2117. //
  2118. // DESCRIPTION: Display the contents of a buffer in a list box, as binary data, using
  2119. // an hd-like format.
  2120. //
  2121. // PARAMETERS: hDlg - a handle to the dialog proceedure.
  2122. // Data - Buffer that contains the binary data.
  2123. // Size - Number of bytes in the buffer.
  2124. //------------------------------------------------------------------------------
  2125. VOID REGISTRY_DATA::_DumpBinaryData(HWND hDlg, PCBYTE Data, ULONG Size)
  2126. {
  2127. WCHAR AuxData[80];
  2128. DWORD DataIndex;
  2129. DWORD DataIndex2;
  2130. WORD SeperatorChars;
  2131. ULONG Index;
  2132. if (( Data == NULL ) || ( Size == 0 ))
  2133. {
  2134. return;
  2135. }
  2136. //
  2137. // DataIndex2 tracks multiples of 16.
  2138. //
  2139. DataIndex2 = 0;
  2140. //
  2141. // Display rows of 16 bytes of data.
  2142. //
  2143. for(DataIndex = 0;
  2144. DataIndex < ( Size >> 4 );
  2145. DataIndex++,
  2146. DataIndex2 = DataIndex << 4 ) {
  2147. //
  2148. // The string that contains the format in the sprintf below
  2149. // cannot be broken because cfront on mips doesn't like it.
  2150. //
  2151. swprintf(AuxData,
  2152. (LPWSTR)L"%08x %02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x %02x %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",
  2153. DataIndex2,
  2154. Data[ DataIndex2 + 0 ],
  2155. Data[ DataIndex2 + 1 ],
  2156. Data[ DataIndex2 + 2 ],
  2157. Data[ DataIndex2 + 3 ],
  2158. Data[ DataIndex2 + 4 ],
  2159. Data[ DataIndex2 + 5 ],
  2160. Data[ DataIndex2 + 6 ],
  2161. Data[ DataIndex2 + 7 ],
  2162. Data[ DataIndex2 + 8 ],
  2163. Data[ DataIndex2 + 9 ],
  2164. Data[ DataIndex2 + 10 ],
  2165. Data[ DataIndex2 + 11 ],
  2166. Data[ DataIndex2 + 12 ],
  2167. Data[ DataIndex2 + 13 ],
  2168. Data[ DataIndex2 + 14 ],
  2169. Data[ DataIndex2 + 15 ],
  2170. iswprint( Data[ DataIndex2 + 0 ] )
  2171. ? Data[ DataIndex2 + 0 ] : ( WCHAR )'.',
  2172. iswprint( Data[ DataIndex2 + 1 ] )
  2173. ? Data[ DataIndex2 + 1 ] : ( WCHAR )'.',
  2174. iswprint( Data[ DataIndex2 + 2 ] )
  2175. ? Data[ DataIndex2 + 2 ] : ( WCHAR )'.',
  2176. iswprint( Data[ DataIndex2 + 3 ] )
  2177. ? Data[ DataIndex2 + 3 ] : ( WCHAR )'.',
  2178. iswprint( Data[ DataIndex2 + 4 ] )
  2179. ? Data[ DataIndex2 + 4 ] : ( WCHAR )'.',
  2180. iswprint( Data[ DataIndex2 + 5 ] )
  2181. ? Data[ DataIndex2 + 5 ] : ( WCHAR )'.',
  2182. iswprint( Data[ DataIndex2 + 6 ] )
  2183. ? Data[ DataIndex2 + 6 ] : ( WCHAR )'.',
  2184. iswprint( Data[ DataIndex2 + 7 ] )
  2185. ? Data[ DataIndex2 + 7 ] : ( WCHAR )'.',
  2186. iswprint( Data[ DataIndex2 + 8 ] )
  2187. ? Data[ DataIndex2 + 8 ] : ( WCHAR )'.',
  2188. iswprint( Data[ DataIndex2 + 9 ] )
  2189. ? Data[ DataIndex2 + 9 ] : ( WCHAR )'.',
  2190. iswprint( Data[ DataIndex2 + 10 ] )
  2191. ? Data[ DataIndex2 + 10 ] : ( WCHAR )'.',
  2192. iswprint( Data[ DataIndex2 + 11 ] )
  2193. ? Data[ DataIndex2 + 11 ] : ( WCHAR )'.',
  2194. iswprint( Data[ DataIndex2 + 12 ] )
  2195. ? Data[ DataIndex2 + 12 ] : ( WCHAR )'.',
  2196. iswprint( Data[ DataIndex2 + 13 ] )
  2197. ? Data[ DataIndex2 + 13 ] : ( WCHAR )'.',
  2198. iswprint( Data[ DataIndex2 + 14 ] )
  2199. ? Data[ DataIndex2 + 14 ] : ( WCHAR )'.',
  2200. iswprint( Data[ DataIndex2 + 15 ] )
  2201. ? Data[ DataIndex2 + 15 ] : ( WCHAR )'.'
  2202. );
  2203. SendDlgItemMessage( hDlg, IDD_DISPLAY_DATA_BINARY, LB_ADDSTRING, 0, (LONG_PTR)AuxData );
  2204. }
  2205. //
  2206. // If the data size is not an even multiple of 16
  2207. // then there is one additonal line of data to display.
  2208. //
  2209. if( Size % 16 != 0 ) {
  2210. //
  2211. // No seperator characters displayed so far.
  2212. //
  2213. SeperatorChars = 0;
  2214. Index = swprintf( AuxData, (LPWSTR)L"%08x ", DataIndex << 4 );
  2215. //
  2216. // Display the remaining data, one byte at a time in hex.
  2217. //
  2218. for( DataIndex = DataIndex2;
  2219. DataIndex < Size;
  2220. DataIndex++ ) {
  2221. Index += swprintf( &AuxData[ Index ], (LPWSTR)L"%02x ", Data[ DataIndex ] );
  2222. //
  2223. // If eight data values have been displayed, print
  2224. // the seperator.
  2225. //
  2226. if( DataIndex % 8 == 7 ) {
  2227. Index += swprintf( &AuxData[Index], (LPWSTR)L"%s", (LPWSTR)L"- " );
  2228. //
  2229. // Remember that two seperator characters were
  2230. // displayed.
  2231. //
  2232. SeperatorChars = 2;
  2233. }
  2234. }
  2235. //
  2236. // Fill with blanks to the printable characters position.
  2237. // That is position 63 less 8 spaces for the 'address',
  2238. // 3 blanks, 3 spaces for each value displayed, possibly
  2239. // two for the seperator plus two blanks at the end.
  2240. //
  2241. Index += swprintf( &AuxData[ Index ],
  2242. (LPWSTR)L"%*c",
  2243. 64
  2244. - ( 8 + 3
  2245. + (( DataIndex % 16 ) * 3 )
  2246. + SeperatorChars
  2247. + 2 ), ' ' );
  2248. //
  2249. // Display the remaining data, one byte at a time as
  2250. // printable characters.
  2251. //
  2252. for(
  2253. DataIndex = DataIndex2;
  2254. DataIndex < Size;
  2255. DataIndex++ ) {
  2256. Index += swprintf( ( AuxData + Index ),
  2257. (LPWSTR)L"%c",
  2258. iswprint( Data[ DataIndex ] )
  2259. ? Data[ DataIndex ] : ( WCHAR )'.'
  2260. );
  2261. }
  2262. SendDlgItemMessage( hDlg, IDD_DISPLAY_DATA_BINARY, LB_ADDSTRING, 0, (LONG_PTR)AuxData );
  2263. }
  2264. }
  2265. //------------------------------------------------------------------------------
  2266. // _DumpBinaryDataAsWords
  2267. //
  2268. // DESCRIPTION: Display the contents of a buffer in a list box, as binary data, using
  2269. // an hd-like format.
  2270. //
  2271. // PARAMETERS: hDlg - a handle to the dialog proceedure.
  2272. // Data - Buffer that contains the binary data.
  2273. // Size - Number of bytes in the buffer.
  2274. //------------------------------------------------------------------------------
  2275. VOID REGISTRY_DATA::_DumpBinaryDataAsWords(HWND hDlg, PCBYTE Data,ULONG Size)
  2276. {
  2277. ULONG Index;
  2278. WCHAR Buffer[ 80 ];
  2279. ULONG DataIndex;
  2280. ULONG LineNumber;
  2281. ULONG WholeLines;
  2282. if( ( Data == NULL ) ||
  2283. ( Size == 0 ) ) {
  2284. return;
  2285. }
  2286. //
  2287. // Display all rows that contain 4 DWORDs.
  2288. //
  2289. WholeLines = Size / 16;
  2290. DataIndex = 0;
  2291. for( LineNumber = 0;
  2292. LineNumber < WholeLines;
  2293. LineNumber++,
  2294. DataIndex += 16 ) {
  2295. //
  2296. // The string that contains the format in the sprintf below
  2297. // cannot be broken because cfront on mips doesn't like it.
  2298. //
  2299. swprintf( Buffer,
  2300. ( LPWSTR )L"%08x %04x %04x %04x %04x %04x %04x %04x %04x",
  2301. DataIndex,
  2302. *( ( PUSHORT )( &Data[ DataIndex + 0 ] ) ),
  2303. *( ( PUSHORT )( &Data[ DataIndex + 2 ] ) ),
  2304. *( ( PUSHORT )( &Data[ DataIndex + 4 ] ) ),
  2305. *( ( PUSHORT )( &Data[ DataIndex + 6 ] ) ),
  2306. *( ( PUSHORT )( &Data[ DataIndex + 8 ] ) ),
  2307. *( ( PUSHORT )( &Data[ DataIndex + 10 ] ) ),
  2308. *( ( PUSHORT )( &Data[ DataIndex + 12 ] ) ),
  2309. *( ( PUSHORT )( &Data[ DataIndex + 14 ] ) )
  2310. );
  2311. SendDlgItemMessage( hDlg, IDD_DISPLAY_DATA_BINARY, LB_ADDSTRING, 0, (LONG_PTR)Buffer );
  2312. }
  2313. //
  2314. // If the data size is not an even multiple of 16
  2315. // then there is one additonal line of data to display.
  2316. //
  2317. if( Size % 16 != 0 ) {
  2318. ULONG NumberOfWords;
  2319. ULONG Count;
  2320. //
  2321. // Determine the number of WORDs in the last line
  2322. //
  2323. NumberOfWords = ( Size % 16 ) / 2;
  2324. //
  2325. // Build the offset
  2326. //
  2327. Index = swprintf( Buffer, (LPWSTR)L"%08x ", DataIndex );
  2328. //
  2329. // Display the remaining words, one at a time in hex.
  2330. //
  2331. for( Count = 0;
  2332. Count < NumberOfWords;
  2333. Count++,
  2334. DataIndex += 2 ) {
  2335. Index += swprintf( &Buffer[ Index ], (LPWSTR)L"%04x ", *( ( PUSHORT )( &Data[ DataIndex ] ) ) );
  2336. }
  2337. //
  2338. // Display the remaining byte, if any
  2339. //
  2340. if( Size % 2 != 0 ) {
  2341. swprintf( &Buffer[ Index ], (LPWSTR)L"%02x ", Data[ DataIndex ] );
  2342. }
  2343. SendDlgItemMessage( hDlg, IDD_DISPLAY_DATA_BINARY, LB_ADDSTRING, 0, (LONG_PTR)Buffer );
  2344. }
  2345. }
  2346. //------------------------------------------------------------------------------
  2347. // _DumpBinaryDataAsDwords
  2348. //
  2349. // DESCRIPTION: Display the contents of a buffer in a list box, as DWORDs, using
  2350. // an hd-like format.
  2351. //
  2352. // PARAMETERS: hDlg - a handle to the dialog proceedure.
  2353. // Data - Buffer that contains the binary data.
  2354. // Size - Number of bytes in the buffer.
  2355. //------------------------------------------------------------------------------
  2356. VOID REGISTRY_DATA::_DumpBinaryDataAsDwords(HWND hDlg, PCBYTE Data, ULONG Size)
  2357. {
  2358. ULONG Index;
  2359. WCHAR Buffer[ 80 ];
  2360. ULONG DataIndex;
  2361. ULONG LineNumber;
  2362. ULONG WholeLines;
  2363. if( ( Data == NULL ) ||
  2364. ( Size == 0 ) ) {
  2365. return;
  2366. }
  2367. //
  2368. // Display all rows that contain 4 DWORDs.
  2369. //
  2370. WholeLines = Size / 16;
  2371. DataIndex = 0;
  2372. for( LineNumber = 0;
  2373. LineNumber < WholeLines;
  2374. LineNumber++,
  2375. DataIndex += 16 ) {
  2376. //
  2377. // The string that contains the format in the sprintf below
  2378. // cannot be broken because cfront on mips doesn't like it.
  2379. //
  2380. swprintf( Buffer,
  2381. ( LPWSTR )L"%08x %08x %08x %08x %08x",
  2382. DataIndex,
  2383. *( ( PULONG )( &Data[ DataIndex + 0 ] ) ),
  2384. *( ( PULONG )( &Data[ DataIndex + 4 ] ) ),
  2385. *( ( PULONG )( &Data[ DataIndex + 8 ] ) ),
  2386. *( ( PULONG )( &Data[ DataIndex + 12 ] ) )
  2387. );
  2388. SendDlgItemMessage( hDlg, IDD_DISPLAY_DATA_BINARY, LB_ADDSTRING, 0, (LONG_PTR)Buffer );
  2389. }
  2390. //
  2391. // If the data size is not an even multiple of 16
  2392. // then there is one additonal line of data to display.
  2393. //
  2394. if( Size % 16 != 0 ) {
  2395. ULONG NumberOfDwords;
  2396. ULONG Count;
  2397. //
  2398. // Build the offset
  2399. //
  2400. Index = swprintf( Buffer, (LPWSTR)L"%08x ", DataIndex );
  2401. //
  2402. // Determine the number of DWORDs in the last line
  2403. //
  2404. NumberOfDwords = ( Size % 16 ) / 4;
  2405. //
  2406. // Display the remaining dwords, one at a time, if any.
  2407. //
  2408. for( Count = 0;
  2409. Count < NumberOfDwords;
  2410. Count++,
  2411. DataIndex += 4 ) {
  2412. Index += swprintf( &Buffer[ Index ], (LPWSTR)L"%08x ", *( ( PULONG )( &Data[ DataIndex ] ) ) );
  2413. }
  2414. //
  2415. // Display the remaining word, if any
  2416. //
  2417. if( ( Size % 16 ) % 4 >= 2 ) {
  2418. Index += swprintf( &Buffer[ Index ], (LPWSTR)L"%04x ", *( ( PUSHORT )( &Data[ DataIndex ] ) ) );
  2419. DataIndex += 2;
  2420. }
  2421. //
  2422. // Display the remaining byte, if any
  2423. //
  2424. if( Size % 2 != 0 ) {
  2425. swprintf( &Buffer[ Index ], (LPWSTR)L"%02x ", Data[ DataIndex ] );
  2426. }
  2427. SendDlgItemMessage( hDlg, IDD_DISPLAY_DATA_BINARY, LB_ADDSTRING, 0, (LONG_PTR)Buffer );
  2428. }
  2429. }