ReactOS  0.4.15-dev-985-gd905dd5
hwresource.cpp File Reference
#include "precomp.h"
#include "properties.h"
#include "resource.h"
#include <pshpack4.h>
#include <poppack.h>
Include dependency graph for hwresource.cpp:

Go to the source code of this file.

Classes

struct  HARDWARE_RESOURCE_DATA
 
struct  _CM_PARTIAL_RESOURCE_DESCRIPTOR
 
struct  _CM_PARTIAL_RESOURCE_LIST
 
struct  _CM_FULL_RESOURCE_DESCRIPTOR
 
struct  _CM_RESOURCE_LIST
 

Macros

#define CmResourceTypeNull   0
 
#define CmResourceTypePort   1
 
#define CmResourceTypeInterrupt   2
 
#define CmResourceTypeMemory   3
 
#define CmResourceTypeDma   4
 
#define CmResourceTypeDeviceSpecific   5
 
#define CmResourceTypeBusNumber   6
 
#define CmResourceTypeNonArbitrated   128
 
#define CmResourceTypeConfigData   128
 
#define CmResourceTypeDevicePrivate   129
 
#define CmResourceTypePcCardConfig   130
 
#define CmResourceTypeMfCardConfig   131
 
#define CX_TYPECOLUMN_WIDTH   120
 

Typedefs

typedef struct HARDWARE_RESOURCE_DATAPHARDWARE_RESOURCE_DATA
 
typedef LARGE_INTEGER PHYSICAL_ADDRESS
 
typedef LARGE_INTEGERPPHYSICAL_ADDRESS
 
typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR CM_PARTIAL_RESOURCE_DESCRIPTOR
 
typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTORPCM_PARTIAL_RESOURCE_DESCRIPTOR
 
typedef struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
 
typedef struct _CM_PARTIAL_RESOURCE_LISTPCM_PARTIAL_RESOURCE_LIST
 
typedef enum _INTERFACE_TYPE INTERFACE_TYPE
 
typedef enum _INTERFACE_TYPEPINTERFACE_TYPE
 
typedef struct _CM_FULL_RESOURCE_DESCRIPTOR CM_FULL_RESOURCE_DESCRIPTOR
 
typedef struct _CM_FULL_RESOURCE_DESCRIPTORPCM_FULL_RESOURCE_DESCRIPTOR
 
typedef struct _CM_RESOURCE_LIST CM_RESOURCE_LIST
 
typedef struct _CM_RESOURCE_LISTPCM_RESOURCE_LIST
 

Enumerations

enum  _INTERFACE_TYPE {
  InterfaceTypeUndefined = -1, Internal, Isa, Eisa,
  MicroChannel, TurboChannel, PCIBus, VMEBus,
  NuBus, PCMCIABus, CBus, MPIBus,
  MPSABus, ProcessorInternal, InternalPowerBus, PNPISABus,
  PNPBus, Vmcs, MaximumInterfaceType, InterfaceTypeUndefined = -1,
  Internal, Isa, Eisa, MicroChannel,
  TurboChannel, PCIBus, VMEBus, NuBus,
  PCMCIABus, CBus, MPIBus, MPSABus,
  ProcessorInternal, InternalPowerBus, PNPISABus, PNPBus,
  Vmcs, MaximumInterfaceType, InterfaceTypeUndefined = -1, Internal,
  Isa, Eisa, MicroChannel, TurboChannel,
  PCIBus, VMEBus, NuBus, PCMCIABus,
  CBus, MPIBus, MPSABus, ProcessorInternal,
  InternalPowerBus, PNPISABus, PNPBus, Vmcs,
  MaximumInterfaceType
}
 

Functions

static VOID InitializeDevicesList (IN HWND hWndDevList)
 
VOID InsertListItem (IN HWND hWndDevList, IN INT ItemCount, IN LPWSTR ResourceType, IN LPWSTR ResourceDescription)
 
VOID AddResourceItems (IN PDEVADVPROP_INFO dap, IN HWND hWndDevList)
 
static VOID UpdateDriverResourceDlg (IN HWND hwndDlg, IN PDEVADVPROP_INFO dap)
 
INT_PTR CALLBACK ResourcesProcDriverDlgProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
PVOID GetResourceList (LPWSTR pszDeviceID)
 

Macro Definition Documentation

◆ CmResourceTypeBusNumber

#define CmResourceTypeBusNumber   6

Definition at line 128 of file hwresource.cpp.

◆ CmResourceTypeConfigData

#define CmResourceTypeConfigData   128

Definition at line 130 of file hwresource.cpp.

◆ CmResourceTypeDevicePrivate

#define CmResourceTypeDevicePrivate   129

Definition at line 131 of file hwresource.cpp.

◆ CmResourceTypeDeviceSpecific

#define CmResourceTypeDeviceSpecific   5

Definition at line 127 of file hwresource.cpp.

◆ CmResourceTypeDma

#define CmResourceTypeDma   4

Definition at line 126 of file hwresource.cpp.

◆ CmResourceTypeInterrupt

#define CmResourceTypeInterrupt   2

Definition at line 124 of file hwresource.cpp.

◆ CmResourceTypeMemory

#define CmResourceTypeMemory   3

Definition at line 125 of file hwresource.cpp.

◆ CmResourceTypeMfCardConfig

#define CmResourceTypeMfCardConfig   131

Definition at line 133 of file hwresource.cpp.

◆ CmResourceTypeNonArbitrated

#define CmResourceTypeNonArbitrated   128

Definition at line 129 of file hwresource.cpp.

◆ CmResourceTypeNull

#define CmResourceTypeNull   0

Definition at line 122 of file hwresource.cpp.

◆ CmResourceTypePcCardConfig

#define CmResourceTypePcCardConfig   130

Definition at line 132 of file hwresource.cpp.

◆ CmResourceTypePort

#define CmResourceTypePort   1

Definition at line 123 of file hwresource.cpp.

◆ CX_TYPECOLUMN_WIDTH

#define CX_TYPECOLUMN_WIDTH   120

Definition at line 169 of file hwresource.cpp.

Typedef Documentation

◆ CM_FULL_RESOURCE_DESCRIPTOR

◆ CM_PARTIAL_RESOURCE_DESCRIPTOR

◆ CM_PARTIAL_RESOURCE_LIST

◆ CM_RESOURCE_LIST

◆ INTERFACE_TYPE

◆ PCM_FULL_RESOURCE_DESCRIPTOR

◆ PCM_PARTIAL_RESOURCE_DESCRIPTOR

◆ PCM_PARTIAL_RESOURCE_LIST

◆ PCM_RESOURCE_LIST

◆ PHARDWARE_RESOURCE_DATA

◆ PHYSICAL_ADDRESS

Definition at line 24 of file hwresource.cpp.

◆ PINTERFACE_TYPE

◆ PPHYSICAL_ADDRESS

Definition at line 24 of file hwresource.cpp.

Enumeration Type Documentation

◆ _INTERFACE_TYPE

Enumerator
InterfaceTypeUndefined 
Internal 
Isa 
Eisa 
MicroChannel 
TurboChannel 
PCIBus 
VMEBus 
NuBus 
PCMCIABus 
CBus 
MPIBus 
MPSABus 
ProcessorInternal 
InternalPowerBus 
PNPISABus 
PNPBus 
Vmcs 
MaximumInterfaceType 
InterfaceTypeUndefined 
Internal 
Isa 
Eisa 
MicroChannel 
TurboChannel 
PCIBus 
VMEBus 
NuBus 
PCMCIABus 
CBus 
MPIBus 
MPSABus 
ProcessorInternal 
InternalPowerBus 
PNPISABus 
PNPBus 
Vmcs 
MaximumInterfaceType 
InterfaceTypeUndefined 
Internal 
Isa 
Eisa 
MicroChannel 
TurboChannel 
PCIBus 
VMEBus 
NuBus 
PCMCIABus 
CBus 
MPIBus 
MPSABus 
ProcessorInternal 
InternalPowerBus 
PNPISABus 
PNPBus 
Vmcs 
MaximumInterfaceType 

Definition at line 135 of file hwresource.cpp.

Function Documentation

◆ AddResourceItems()

VOID AddResourceItems ( IN PDEVADVPROP_INFO  dap,
IN HWND  hWndDevList 
)

Definition at line 243 of file hwresource.cpp.

246 {
247  WCHAR szBuffer[100];
248  WCHAR szDetail[100];
250  ULONG ItemCount = 0, Index;
251 
252  ResourceList = (PCM_RESOURCE_LIST)dap->pResourceList;
253 
254  for (Index = 0; Index < ResourceList->List[0].PartialResourceList.Count; Index++)
255  {
256  PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[Index];
257  if (Descriptor->Type == CmResourceTypeInterrupt)
258  {
259  if (LoadString(hDllInstance, IDS_RESOURCE_INTERRUPT, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0])))
260  {
261  wsprintf(szDetail, L"0x%08x (%d)", Descriptor->u.Interrupt.Level, Descriptor->u.Interrupt.Vector);
262  InsertListItem(hWndDevList, ItemCount, szBuffer, szDetail);
263  ItemCount++;
264  }
265  }
266  else if (Descriptor->Type == CmResourceTypePort)
267  {
268  if (LoadString(hDllInstance, IDS_RESOURCE_PORT, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0])))
269  {
270  wsprintf(szDetail, L"%08lx - %08lx", Descriptor->u.Port.Start.LowPart, Descriptor->u.Port.Start.LowPart + Descriptor->u.Port.Length - 1);
271  InsertListItem(hWndDevList, ItemCount, szBuffer, szDetail);
272  ItemCount++;
273  }
274  }
275  else if (Descriptor->Type == CmResourceTypeMemory)
276  {
277  if (LoadString(hDllInstance, IDS_RESOURCE_MEMORY_RANGE, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0])))
278  {
279  wsprintf(szDetail, L"%08I64x - %08I64x", Descriptor->u.Memory.Start.QuadPart, Descriptor->u.Memory.Start.QuadPart + Descriptor->u.Memory.Length - 1);
280  InsertListItem(hWndDevList, ItemCount, szBuffer, szDetail);
281  ItemCount++;
282  }
283  }
284  else if (Descriptor->Type == CmResourceTypeDma)
285  {
286  if (LoadString(hDllInstance, IDS_RESOURCE_DMA, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0])))
287  {
288  wsprintf(szDetail, L"%08ld", Descriptor->u.Dma.Channel);
289  InsertListItem(hWndDevList, ItemCount, szBuffer, szDetail);
290  ItemCount++;
291  }
292  }
293  }
294 }
struct _CM_RESOURCE_LIST * PCM_RESOURCE_LIST
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define IDS_RESOURCE_MEMORY_RANGE
Definition: resource.h:126
static HINSTANCE hDllInstance
Definition: clb.c:30
VOID InsertListItem(IN HWND hWndDevList, IN INT ItemCount, IN LPWSTR ResourceType, IN LPWSTR ResourceDescription)
Definition: hwresource.cpp:217
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const UCHAR Index[8]
Definition: usbohci.c:18
#define for
Definition: utility.h:88
#define IDS_RESOURCE_INTERRUPT
Definition: resource.h:127
static const WCHAR L[]
Definition: oid.c:1250
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define IDS_RESOURCE_PORT
Definition: resource.h:129
unsigned int ULONG
Definition: retypes.h:1
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
#define IDS_RESOURCE_DMA
Definition: resource.h:128
#define wsprintf
Definition: winuser.h:5840
#define LoadString
Definition: winuser.h:5794
#define CmResourceTypeDma
Definition: hwresource.cpp:126
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PVOID * Descriptor
Definition: classpnp.h:1159

Referenced by ResourcesProcDriverDlgProc().

◆ GetResourceList()

PVOID GetResourceList ( LPWSTR  pszDeviceID)

Definition at line 357 of file hwresource.cpp.

359 {
360  WCHAR szBuffer[100];
361  PCM_RESOURCE_LIST pResourceList = NULL;
362  HKEY hKey = NULL;
363  DWORD dwError, dwSize;
364 
365  wsprintf(szBuffer, L"SYSTEM\\CurrentControlSet\\Enum\\%s\\LogConf", pszDeviceID);
366  dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szBuffer, 0, KEY_READ, &hKey);
367  if (dwError != ERROR_SUCCESS)
368  {
369  /* failed to open device instance log conf dir */
370  return NULL;
371  }
372 
373  dwSize = 0;
374  RegQueryValueExW(hKey, L"BootConfig", NULL, NULL, NULL, &dwSize);
375  if (dwSize == 0)
376  goto done;
377 
378  pResourceList = static_cast<PCM_RESOURCE_LIST>(HeapAlloc(GetProcessHeap(), 0, dwSize));
379  if (pResourceList == NULL)
380  goto done;
381 
382  dwError = RegQueryValueExW(hKey, L"BootConfig", NULL, NULL, (LPBYTE)pResourceList, &dwSize);
383  if (dwError != ERROR_SUCCESS)
384  {
385  HeapFree(GetProcessHeap(), 0, pResourceList);
386  pResourceList = NULL;
387  }
388 
389 done:
390  if (hKey != NULL)
391  RegCloseKey(hKey);
392 
393  return (PVOID)pResourceList;
394 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define wsprintf
Definition: winuser.h:5840
#define HeapFree(x, y, z)
Definition: compat.h:483
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by UpdateDevInfo().

◆ InitializeDevicesList()

static VOID InitializeDevicesList ( IN HWND  hWndDevList)
static

Definition at line 172 of file hwresource.cpp.

174 {
175  LVCOLUMN lvc;
176  RECT rcClient;
177  WCHAR szColName[255];
178  int iCol = 0;
179 
180  /* set the list view style */
183 
184  GetClientRect(hWndDevList,
185  &rcClient);
186 
187  /* add the list view columns */
188  lvc.mask = LVCF_TEXT | LVCF_WIDTH;
189  lvc.fmt = LVCFMT_LEFT;
190  lvc.pszText = szColName;
191 
194  szColName,
195  sizeof(szColName) / sizeof(szColName[0])))
196  {
197  lvc.cx = CX_TYPECOLUMN_WIDTH;
198  (void)ListView_InsertColumn(hWndDevList,
199  iCol++,
200  &lvc);
201  }
204  szColName,
205  sizeof(szColName) / sizeof(szColName[0])))
206  {
207  lvc.cx = rcClient.right - CX_TYPECOLUMN_WIDTH -
209 
210  (void)ListView_InsertColumn(hWndDevList,
211  iCol++,
212  &lvc);
213  }
214 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define LVCF_WIDTH
Definition: commctrl.h:2583
#define LVCF_TEXT
Definition: commctrl.h:2584
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2730
#define LVCFMT_LEFT
Definition: commctrl.h:2594
LONG right
Definition: windef.h:308
#define LVCOLUMN
Definition: commctrl.h:2577
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2632
static HINSTANCE hDllInstance
Definition: clb.c:30
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CX_TYPECOLUMN_WIDTH
Definition: hwresource.cpp:169
int WINAPI GetSystemMetrics(_In_ int)
#define ListView_SetExtendedListViewStyle(hwndLV, dw)
Definition: commctrl.h:2721
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SM_CXVSCROLL
Definition: winuser.h:951
#define IDS_RESOURCE_COLUMN
Definition: resource.h:124
#define LoadString
Definition: winuser.h:5794
#define IDS_SETTING_COLUMN
Definition: resource.h:125

Referenced by ResourcesProcDriverDlgProc().

◆ InsertListItem()

VOID InsertListItem ( IN HWND  hWndDevList,
IN INT  ItemCount,
IN LPWSTR  ResourceType,
IN LPWSTR  ResourceDescription 
)

Definition at line 217 of file hwresource.cpp.

222 {
223  INT iItem;
224  LVITEM li = {0};
225 
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);
231 
232  if (iItem != -1)
233  {
234  li.mask = LVIF_TEXT;
235  li.iItem = iItem;
236  li.iSubItem = 1;
237  li.pszText = ResourceDescription;
238  (void)ListView_SetItem(hWndDevList, &li);
239  }
240 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define ListView_SetItem(hwnd, pitem)
Definition: commctrl.h:2397
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2404
int32_t INT
Definition: typedefs.h:58
#define LVIF_TEXT
Definition: commctrl.h:2305
#define LVITEM
Definition: commctrl.h:2371
#define LVIF_STATE
Definition: commctrl.h:2308

Referenced by AddResourceItems().

◆ ResourcesProcDriverDlgProc()

INT_PTR CALLBACK ResourcesProcDriverDlgProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)

Definition at line 316 of file hwresource.cpp.

320 {
321  PDEVADVPROP_INFO hpd;
322  HWND hWndDevList;
323  INT_PTR Ret = FALSE;
324 
326 
327  if (hpd != NULL || uMsg == WM_INITDIALOG)
328  {
329  switch (uMsg)
330  {
331  case WM_INITDIALOG:
332  {
333  /* init list */
334  hWndDevList = GetDlgItem(hwndDlg, IDC_DRIVERRESOURCES);
335  InitializeDevicesList(hWndDevList);
336 
338  if (hpd != NULL)
339  {
340  SetWindowLongPtr(hwndDlg, DWLP_USER, (DWORD_PTR)hpd);
341 
342  UpdateDriverResourceDlg(hwndDlg, hpd);
343  AddResourceItems(hpd, hWndDevList);
344  }
345 
346  Ret = TRUE;
347  break;
348  }
349  }
350  }
351 
352  return Ret;
353 }
struct _DEVADVPROP_INFO * PDEVADVPROP_INFO
#define TRUE
Definition: types.h:120
int32_t INT_PTR
Definition: typedefs.h:64
#define SetWindowLongPtr
Definition: treelist.c:70
static VOID InitializeDevicesList(IN HWND hWndDevList)
Definition: hwresource.cpp:172
#define FALSE
Definition: types.h:117
#define IDC_DRIVERRESOURCES
Definition: resource.h:253
#define LPPROPSHEETPAGE
Definition: prsht.h:390
smooth NULL
Definition: ftsmooth.c:416
VOID AddResourceItems(IN PDEVADVPROP_INFO dap, IN HWND hWndDevList)
Definition: hwresource.cpp:243
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
static VOID UpdateDriverResourceDlg(IN HWND hwndDlg, IN PDEVADVPROP_INFO dap)
Definition: hwresource.cpp:298
#define DWLP_USER
Definition: winuser.h:866
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define GetWindowLongPtr
Definition: treelist.c:73
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139

Referenced by UpdateDevInfo().

◆ UpdateDriverResourceDlg()

static VOID UpdateDriverResourceDlg ( IN HWND  hwndDlg,
IN PDEVADVPROP_INFO  dap 
)
static

Definition at line 298 of file hwresource.cpp.

300 {
301  /* set the device image */
302  SendDlgItemMessage(hwndDlg,
303  IDC_DEVICON,
304  STM_SETICON,
305  (WPARAM)dap->hDevIcon,
306  0);
307 
308  /* set the device name edit control text */
309  SetDlgItemText(hwndDlg,
310  IDC_DEVNAME,
311  dap->szDevName);
312 }
#define STM_SETICON
Definition: winuser.h:2074
#define IDC_DEVICON
Definition: resource.h:223
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5817
#define IDC_DEVNAME
Definition: resource.h:224
#define SetDlgItemText
Definition: winuser.h:5824

Referenced by ResourcesProcDriverDlgProc().