Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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