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>
21 }HARDWARE_RESOURCE_DATA
, *PHARDWARE_RESOURCE_DATA
;
23 /* Physical Addresses are always treated as 64-bit wide */
24 typedef LARGE_INTEGER PHYSICAL_ADDRESS
, *PPHYSICAL_ADDRESS
;
27 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR
{
29 UCHAR ShareDisposition
;
33 PHYSICAL_ADDRESS Start
;
37 PHYSICAL_ADDRESS Start
;
41 #if defined(NT_PROCESSOR_GROUPS)
50 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
52 _ANONYMOUS_UNION
union {
54 #if defined(NT_PROCESSOR_GROUPS)
64 #if defined(NT_PROCESSOR_GROUPS)
77 PHYSICAL_ADDRESS Start
;
98 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
100 PHYSICAL_ADDRESS Start
;
104 PHYSICAL_ADDRESS Start
;
108 PHYSICAL_ADDRESS Start
;
113 } CM_PARTIAL_RESOURCE_DESCRIPTOR
, *PCM_PARTIAL_RESOURCE_DESCRIPTOR
;
115 typedef struct _CM_PARTIAL_RESOURCE_LIST
{
119 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors
[1];
120 } CM_PARTIAL_RESOURCE_LIST
, *PCM_PARTIAL_RESOURCE_LIST
;
122 #define CmResourceTypeNull 0
123 #define CmResourceTypePort 1
124 #define CmResourceTypeInterrupt 2
125 #define CmResourceTypeMemory 3
126 #define CmResourceTypeDma 4
127 #define CmResourceTypeDeviceSpecific 5
128 #define CmResourceTypeBusNumber 6
129 #define CmResourceTypeNonArbitrated 128
130 #define CmResourceTypeConfigData 128
131 #define CmResourceTypeDevicePrivate 129
132 #define CmResourceTypePcCardConfig 130
133 #define CmResourceTypeMfCardConfig 131
135 typedef enum _INTERFACE_TYPE
{
136 InterfaceTypeUndefined
= -1,
155 } INTERFACE_TYPE
, *PINTERFACE_TYPE
;
157 typedef struct _CM_FULL_RESOURCE_DESCRIPTOR
{
158 INTERFACE_TYPE InterfaceType
;
160 CM_PARTIAL_RESOURCE_LIST PartialResourceList
;
161 } CM_FULL_RESOURCE_DESCRIPTOR
, *PCM_FULL_RESOURCE_DESCRIPTOR
;
163 typedef struct _CM_RESOURCE_LIST
{
165 CM_FULL_RESOURCE_DESCRIPTOR List
[1];
166 } CM_RESOURCE_LIST
, *PCM_RESOURCE_LIST
;
169 #define CX_TYPECOLUMN_WIDTH 120
172 InitializeDevicesList(
177 WCHAR szColName
[255];
180 /* set the list view style */
181 (void)ListView_SetExtendedListViewStyle(hWndDevList
,
182 LVS_EX_FULLROWSELECT
);
184 GetClientRect(hWndDevList
,
187 /* add the list view columns */
188 lvc
.mask
= LVCF_TEXT
| LVCF_WIDTH
;
189 lvc
.fmt
= LVCFMT_LEFT
;
190 lvc
.pszText
= szColName
;
192 if (LoadString(hDllInstance
,
195 sizeof(szColName
) / sizeof(szColName
[0])))
197 lvc
.cx
= CX_TYPECOLUMN_WIDTH
;
198 (void)ListView_InsertColumn(hWndDevList
,
202 if (LoadString(hDllInstance
,
205 sizeof(szColName
) / sizeof(szColName
[0])))
207 lvc
.cx
= rcClient
.right
- CX_TYPECOLUMN_WIDTH
-
208 GetSystemMetrics(SM_CXVSCROLL
);
210 (void)ListView_InsertColumn(hWndDevList
,
220 IN LPWSTR ResourceType
,
221 IN LPWSTR ResourceDescription
)
226 li
.mask
= LVIF_STATE
| LVIF_TEXT
;
227 li
.iItem
= ItemCount
;
228 li
.pszText
= ResourceType
;
229 //li.iImage = ClassDevInfo->ImageIndex;
230 iItem
= ListView_InsertItem(hWndDevList
, &li
);
237 li
.pszText
= ResourceDescription
;
238 (void)ListView_SetItem(hWndDevList
, &li
);
244 IN PDEVADVPROP_INFO dap
,
252 PCM_RESOURCE_LIST ResourceList
;
254 ULONG ItemCount
= 0, Index
;
256 wsprintf(szBuffer
, L
"SYSTEM\\CurrentControlSet\\Enum\\%s\\LogConf", dap
->szDeviceID
);
257 Result
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szBuffer
, 0, KEY_READ
, &hKey
);
258 if (Result
!= ERROR_SUCCESS
)
260 /* failed to open device instance log conf dir */
264 dwSize
= sizeof(szData
);
265 Result
= RegQueryValueExW(hKey
, L
"BootConfig", NULL
, NULL
, szData
, &dwSize
);
268 if (Result
!= ERROR_SUCCESS
)
270 /* failed to query resources */
274 ResourceList
= (PCM_RESOURCE_LIST
)szData
;
276 for (Index
= 0; Index
< ResourceList
->List
[0].PartialResourceList
.Count
; Index
++)
278 PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor
= &ResourceList
->List
[0].PartialResourceList
.PartialDescriptors
[Index
];
279 if (Descriptor
->Type
== CmResourceTypeInterrupt
)
281 if (LoadString(hDllInstance
, IDS_RESOURCE_INTERRUPT
, szBuffer
, sizeof(szBuffer
) / sizeof(szBuffer
[0])))
283 wsprintf(szDetail
, L
"0x%08x(%d)", Descriptor
->u
.Interrupt
.Level
, Descriptor
->u
.Interrupt
.Vector
);
284 InsertListItem(hWndDevList
, ItemCount
, szBuffer
, szDetail
);
288 else if (Descriptor
->Type
== CmResourceTypePort
)
290 if (LoadString(hDllInstance
, IDS_RESOURCE_PORT
, szBuffer
, sizeof(szBuffer
) / sizeof(szBuffer
[0])))
292 wsprintf(szDetail
, L
"%08lx - %08lx", Descriptor
->u
.Port
.Start
.LowPart
, Descriptor
->u
.Port
.Start
.LowPart
+ Descriptor
->u
.Port
.Length
- 1);
293 InsertListItem(hWndDevList
, ItemCount
, szBuffer
, szDetail
);
297 else if (Descriptor
->Type
== CmResourceTypeMemory
)
299 if (LoadString(hDllInstance
, IDS_RESOURCE_MEMORY_RANGE
, szBuffer
, sizeof(szBuffer
) / sizeof(szBuffer
[0])))
301 wsprintf(szDetail
, L
"%08I64x - %08I64x", Descriptor
->u
.Memory
.Start
.QuadPart
, Descriptor
->u
.Memory
.Start
.QuadPart
+ Descriptor
->u
.Memory
.Length
- 1);
302 InsertListItem(hWndDevList
, ItemCount
, szBuffer
, szDetail
);
306 else if (Descriptor
->Type
== CmResourceTypeDma
)
308 if (LoadString(hDllInstance
, IDS_RESOURCE_DMA
, szBuffer
, sizeof(szBuffer
) / sizeof(szBuffer
[0])))
310 wsprintf(szDetail
, L
"%08ld", Descriptor
->u
.Dma
.Channel
);
311 InsertListItem(hWndDevList
, ItemCount
, szBuffer
, szDetail
);
320 UpdateDriverResourceDlg(IN HWND hwndDlg
,
321 IN PDEVADVPROP_INFO dap
)
323 /* set the device image */
324 SendDlgItemMessage(hwndDlg
,
327 (WPARAM
)dap
->hDevIcon
,
330 /* set the device name edit control text */
331 SetDlgItemText(hwndDlg
,
338 ResourcesProcDriverDlgProc(IN HWND hwndDlg
,
343 PDEVADVPROP_INFO hpd
;
347 hpd
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
350 if (hpd
!= NULL
|| uMsg
== WM_INITDIALOG
)
357 hWndDevList
= GetDlgItem(hwndDlg
, IDC_DRIVERRESOURCES
);
358 InitializeDevicesList(hWndDevList
);
360 hpd
= (PDEVADVPROP_INFO
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
363 SetWindowLongPtr(hwndDlg
,
367 SetWindowLongPtr(hwndDlg
,
371 UpdateDriverResourceDlg(hwndDlg
, hpd
);
372 AddResourceItems(hpd
, hWndDevList
);