2 * PROJECT: ReactOS devmgr.dll
3 * FILE: dll/win32/devmgr/hwresource.c
4 * PURPOSE: ReactOS Device Manager
5 * PROGRAMMER: Johannes Anderwald <johannes.anderwald@reactos.org>
19 }HARDWARE_RESOURCE_DATA
, *PHARDWARE_RESOURCE_DATA
;
21 /* Physical Addresses are always treated as 64-bit wide */
22 typedef LARGE_INTEGER PHYSICAL_ADDRESS
, *PPHYSICAL_ADDRESS
;
25 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR
{
27 UCHAR ShareDisposition
;
31 PHYSICAL_ADDRESS Start
;
35 PHYSICAL_ADDRESS Start
;
39 #if defined(NT_PROCESSOR_GROUPS)
48 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
50 _ANONYMOUS_UNION
union {
52 #if defined(NT_PROCESSOR_GROUPS)
62 #if defined(NT_PROCESSOR_GROUPS)
75 PHYSICAL_ADDRESS Start
;
96 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
98 PHYSICAL_ADDRESS Start
;
102 PHYSICAL_ADDRESS Start
;
106 PHYSICAL_ADDRESS Start
;
111 } CM_PARTIAL_RESOURCE_DESCRIPTOR
, *PCM_PARTIAL_RESOURCE_DESCRIPTOR
;
113 typedef struct _CM_PARTIAL_RESOURCE_LIST
{
117 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors
[1];
118 } CM_PARTIAL_RESOURCE_LIST
, *PCM_PARTIAL_RESOURCE_LIST
;
120 #define CmResourceTypeNull 0
121 #define CmResourceTypePort 1
122 #define CmResourceTypeInterrupt 2
123 #define CmResourceTypeMemory 3
124 #define CmResourceTypeDma 4
125 #define CmResourceTypeDeviceSpecific 5
126 #define CmResourceTypeBusNumber 6
127 #define CmResourceTypeNonArbitrated 128
128 #define CmResourceTypeConfigData 128
129 #define CmResourceTypeDevicePrivate 129
130 #define CmResourceTypePcCardConfig 130
131 #define CmResourceTypeMfCardConfig 131
133 typedef enum _INTERFACE_TYPE
{
134 InterfaceTypeUndefined
= -1,
153 } INTERFACE_TYPE
, *PINTERFACE_TYPE
;
155 typedef struct _CM_FULL_RESOURCE_DESCRIPTOR
{
156 INTERFACE_TYPE InterfaceType
;
158 CM_PARTIAL_RESOURCE_LIST PartialResourceList
;
159 } CM_FULL_RESOURCE_DESCRIPTOR
, *PCM_FULL_RESOURCE_DESCRIPTOR
;
161 typedef struct _CM_RESOURCE_LIST
{
163 CM_FULL_RESOURCE_DESCRIPTOR List
[1];
164 } CM_RESOURCE_LIST
, *PCM_RESOURCE_LIST
;
167 #define CX_TYPECOLUMN_WIDTH 120
170 InitializeDevicesList(
175 WCHAR szColName
[255];
178 /* set the list view style */
179 (void)ListView_SetExtendedListViewStyle(hWndDevList
,
180 LVS_EX_FULLROWSELECT
);
182 GetClientRect(hWndDevList
,
185 /* add the list view columns */
186 lvc
.mask
= LVCF_TEXT
| LVCF_WIDTH
;
187 lvc
.fmt
= LVCFMT_LEFT
;
188 lvc
.pszText
= szColName
;
190 if (LoadString(hDllInstance
,
193 sizeof(szColName
) / sizeof(szColName
[0])))
195 lvc
.cx
= CX_TYPECOLUMN_WIDTH
;
196 (void)ListView_InsertColumn(hWndDevList
,
200 if (LoadString(hDllInstance
,
203 sizeof(szColName
) / sizeof(szColName
[0])))
205 lvc
.cx
= rcClient
.right
- CX_TYPECOLUMN_WIDTH
-
206 GetSystemMetrics(SM_CXVSCROLL
);
208 (void)ListView_InsertColumn(hWndDevList
,
218 IN LPWSTR ResourceType
,
219 IN LPWSTR ResourceDescription
)
224 li
.mask
= LVIF_STATE
| LVIF_TEXT
;
225 li
.iItem
= ItemCount
;
226 li
.pszText
= ResourceType
;
227 //li.iImage = ClassDevInfo->ImageIndex;
228 iItem
= ListView_InsertItem(hWndDevList
, &li
);
235 li
.pszText
= ResourceDescription
;
236 (void)ListView_SetItem(hWndDevList
, &li
);
242 IN PDEVADVPROP_INFO dap
,
250 PCM_RESOURCE_LIST ResourceList
;
252 ULONG ItemCount
= 0, Index
;
254 wsprintf(szBuffer
, L
"SYSTEM\\CurrentControlSet\\Enum\\%s\\LogConf", dap
->szDeviceID
);
255 Result
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szBuffer
, 0, KEY_READ
, &hKey
);
256 if (Result
!= ERROR_SUCCESS
)
258 /* failed to open device instance log conf dir */
262 dwSize
= sizeof(szData
);
263 Result
= RegQueryValueExW(hKey
, L
"BootConfig", NULL
, NULL
, szData
, &dwSize
);
266 if (Result
!= ERROR_SUCCESS
)
268 /* failed to query resources */
272 ResourceList
= (PCM_RESOURCE_LIST
)szData
;
274 for (Index
= 0; Index
< ResourceList
->List
[0].PartialResourceList
.Count
; Index
++)
276 PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor
= &ResourceList
->List
[0].PartialResourceList
.PartialDescriptors
[Index
];
277 if (Descriptor
->Type
== CmResourceTypeInterrupt
)
279 if (LoadString(hDllInstance
, IDS_RESOURCE_INTERRUPT
, szBuffer
, sizeof(szBuffer
) / sizeof(szBuffer
[0])))
281 wsprintf(szDetail
, L
"0x%08x(%d)", Descriptor
->u
.Interrupt
.Level
, Descriptor
->u
.Interrupt
.Vector
);
282 InsertListItem(hWndDevList
, ItemCount
, szBuffer
, szDetail
);
286 else if (Descriptor
->Type
== CmResourceTypePort
)
288 if (LoadString(hDllInstance
, IDS_RESOURCE_PORT
, szBuffer
, sizeof(szBuffer
) / sizeof(szBuffer
[0])))
290 wsprintf(szDetail
, L
"%08lx - %08lx", Descriptor
->u
.Port
.Start
.LowPart
, Descriptor
->u
.Port
.Start
.LowPart
+ Descriptor
->u
.Port
.Length
- 1);
291 InsertListItem(hWndDevList
, ItemCount
, szBuffer
, szDetail
);
295 else if (Descriptor
->Type
== CmResourceTypeMemory
)
297 if (LoadString(hDllInstance
, IDS_RESOURCE_MEMORY_RANGE
, szBuffer
, sizeof(szBuffer
) / sizeof(szBuffer
[0])))
299 wsprintf(szDetail
, L
"%08I64x - %08I64x", Descriptor
->u
.Memory
.Start
.QuadPart
, Descriptor
->u
.Memory
.Start
.QuadPart
+ Descriptor
->u
.Memory
.Length
- 1);
300 InsertListItem(hWndDevList
, ItemCount
, szBuffer
, szDetail
);
304 else if (Descriptor
->Type
== CmResourceTypeDma
)
306 if (LoadString(hDllInstance
, IDS_RESOURCE_DMA
, szBuffer
, sizeof(szBuffer
) / sizeof(szBuffer
[0])))
308 wsprintf(szDetail
, L
"%08ld", Descriptor
->u
.Dma
.Channel
);
309 InsertListItem(hWndDevList
, ItemCount
, szBuffer
, szDetail
);
318 UpdateDriverResourceDlg(IN HWND hwndDlg
,
319 IN PDEVADVPROP_INFO dap
)
321 /* set the device image */
322 SendDlgItemMessage(hwndDlg
,
325 (WPARAM
)dap
->hDevIcon
,
328 /* set the device name edit control text */
329 SetDlgItemText(hwndDlg
,
336 ResourcesProcDriverDlgProc(IN HWND hwndDlg
,
341 PDEVADVPROP_INFO hpd
;
345 hpd
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
348 if (hpd
!= NULL
|| uMsg
== WM_INITDIALOG
)
355 hWndDevList
= GetDlgItem(hwndDlg
, IDC_DRIVERRESOURCES
);
356 InitializeDevicesList(hWndDevList
);
358 hpd
= (PDEVADVPROP_INFO
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
361 SetWindowLongPtr(hwndDlg
,
365 SetWindowLongPtr(hwndDlg
,
369 UpdateDriverResourceDlg(hwndDlg
, hpd
);
370 AddResourceItems(hpd
, hWndDevList
);