ReactOS  0.4.15-dev-1384-g878186b
CClassNode Class Reference

#include <ClassNode.h>

Inheritance diagram for CClassNode:
Collaboration diagram for CClassNode:

Public Member Functions

 CClassNode (_In_ LPGUID ClassGuid, _In_ PSP_CLASSIMAGELIST_DATA ImageListData)
 
 ~CClassNode ()
 
virtual bool SetupNode ()
 
- Public Member Functions inherited from CNode
 CNode (_In_ NodeType Type, _In_ PSP_CLASSIMAGELIST_DATA ImageListData)
 
 CNode (_In_ const CNode &Node)
 
virtual ~CNode ()
 
NodeType GetNodeType ()
 
LPGUID GetClassGuid ()
 
LPWSTR GetDisplayName ()
 
INT GetClassImage ()
 
LPWSTR GetDeviceId ()
 
bool HasProperties ()
 

Private Member Functions

DWORD ConvertResourceDescriptorToString (_Inout_z_ LPWSTR ResourceDescriptor, _In_ DWORD ResourceDescriptorSize)
 

Additional Inherited Members

- Protected Attributes inherited from CNode
NodeType m_NodeType
 
PSP_CLASSIMAGELIST_DATA m_ImageListData
 
LPWSTR m_DeviceId
 
WCHAR m_DisplayName [DISPLAY_NAME_LEN]
 
GUID m_ClassGuid
 
INT m_ClassImage
 

Detailed Description

Definition at line 4 of file ClassNode.h.

Constructor & Destructor Documentation

◆ CClassNode()

CClassNode::CClassNode ( _In_ LPGUID  ClassGuid,
_In_ PSP_CLASSIMAGELIST_DATA  ImageListData 
)

Definition at line 15 of file ClassNode.cpp.

18  :
20 {
21  CopyMemory(&m_ClassGuid, ClassGuid, sizeof(GUID));
22 }
CNode(_In_ NodeType Type, _In_ PSP_CLASSIMAGELIST_DATA ImageListData)
Definition: Node.cpp:17
Definition: Node.h:8
#define CopyMemory
Definition: winbase.h:1646
GUID m_ClassGuid
Definition: Node.h:19
SP_CLASSIMAGELIST_DATA ImageListData
Definition: hdwwiz.c:34

◆ ~CClassNode()

CClassNode::~CClassNode ( )

Definition at line 25 of file ClassNode.cpp.

26 {
27 }

Member Function Documentation

◆ ConvertResourceDescriptorToString()

DWORD CClassNode::ConvertResourceDescriptorToString ( _Inout_z_ LPWSTR  ResourceDescriptor,
_In_ DWORD  ResourceDescriptorSize 
)
private

Definition at line 111 of file ClassNode.cpp.

115 {
116  WCHAR ModulePath[MAX_PATH];
117  WCHAR ResString[256];
118  INT ResourceId;
120  LPWSTR ptr;
121  DWORD Size;
122  DWORD dwError;
123 
124  // First check for a semi colon */
125  ptr = wcschr(ResourceDescriptor, L';');
126  if (ptr)
127  {
128  // This must be an inf based descriptor, the desc is after the semi colon
129  StringCbCopyW(ResourceDescriptor, ResourceDescriptorSize, ++ptr);
130  dwError = ERROR_SUCCESS;
131  }
132  else
133  {
134  // This must be a dll resource based descriptor. Find the comma
135  ptr = wcschr(ResourceDescriptor, L',');
136  if (ptr == NULL)
137  return ERROR_INVALID_DATA;
138 
139  // Terminate the string where the comma was
140  *ptr = UNICODE_NULL;
141 
142  // Expand any environment strings
143  Size = ExpandEnvironmentStringsW(&ResourceDescriptor[1], ModulePath, MAX_PATH);
144  if (Size > MAX_PATH)
145  return ERROR_BUFFER_OVERFLOW;
146  if (Size == 0)
147  return GetLastError();
148 
149  // Put the comma back and move past it
150  *ptr = L',';
151  ptr++;
152 
153  // Load the dll
155  if (hModule == NULL)
156  return GetLastError();
157 
158  // Convert the resource id to a number
159  ResourceId = _wtoi(ptr);
160 
161  // If the number is negative, make it positive
162  if (ResourceId < 0)
163  ResourceId = -ResourceId;
164 
165  // Load the string from the dll
166  if (LoadStringW(hModule, ResourceId, ResString, 256))
167  {
168  StringCbCopyW(ResourceDescriptor, ResourceDescriptorSize, ResString);
169  dwError = ERROR_SUCCESS;
170  }
171  else
172  {
173  dwError = GetLastError();
174  }
175 
176  // Free the library
178  }
179 
180  return dwError;
181 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:58
#define UNICODE_NULL
static PVOID ptr
Definition: dispmode.c:27
#define FreeLibrary(x)
Definition: compat.h:607
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define ERROR_INVALID_DATA
Definition: winerror.h:116
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338
#define NULL
Definition: types.h:112
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
convenient loading of string resources
Definition: globals.h:303
WCHAR * LPWSTR
Definition: xmlstorage.h:184
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
HMODULE hModule
Definition: animate.c:44

Referenced by SetupNode().

◆ SetupNode()

bool CClassNode::SetupNode ( )
virtual

Implements CNode.

Definition at line 31 of file ClassNode.cpp.

32 {
34  DWORD Success;
35  HKEY hKey;
36 
37  // Open the registry key for this class
41  NULL,
42  0);
44  {
45  // Lookup the class description (win7+)
46  Size = sizeof(m_DisplayName);
48  L"ClassDesc",
49  NULL,
50  &Type,
52  &Size);
53  if (Success == ERROR_SUCCESS)
54  {
55  if (Type != REG_SZ)
56  {
58  }
59  // Check if the string starts with an @
60  else if (m_DisplayName[0] == L'@')
61  {
62  // The description is located in a module resource
64  }
65  }
66  else if (Success == ERROR_FILE_NOT_FOUND)
67  {
68  // WinXP stores the description in the default value
69  Size = sizeof(m_DisplayName);
71  NULL,
72  NULL,
73  &Type,
75  &Size);
76  if (Success == ERROR_SUCCESS && Type != REG_SZ)
77  {
79  }
80  }
81 
82  // Close the registry key
84  }
85  else
86  {
88  }
89 
90  // Check if we failed to get the class description
91  if (Success != ERROR_SUCCESS)
92  {
93  // Use the class name as the description
98  &RequiredSize);
99  }
100 
101  // Get the image index for this class
103  &m_ClassGuid,
104  &m_ClassImage);
105 
106  return true;
107 }
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define ERROR_SUCCESS
Definition: deptool.c:10
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
BOOL WINAPI SetupDiClassNameFromGuidW(const GUID *ClassGuid, PWSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize)
Definition: devinst.c:1076
INT m_ClassImage
Definition: Node.h:20
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define DIOCR_INSTALLER
Definition: setupapi.h:176
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
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
#define _countof(array)
Definition: sndvol32.h:68
Type
Definition: Type.h:6
GUID m_ClassGuid
Definition: Node.h:19
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI SetupDiGetClassImageIndex(IN PSP_CLASSIMAGELIST_DATA ClassImageListData, IN CONST GUID *ClassGuid, OUT PINT ImageIndex)
Definition: devclass.c:396
DWORD ConvertResourceDescriptorToString(_Inout_z_ LPWSTR ResourceDescriptor, _In_ DWORD ResourceDescriptorSize)
Definition: ClassNode.cpp:111
static const WCHAR L[]
Definition: oid.c:1250
#define VOID
Definition: acefi.h:82
PSP_CLASSIMAGELIST_DATA m_ImageListData
Definition: Node.h:16
#define ERROR_INVALID_DATA
Definition: winerror.h:116
FxAutoRegKey hKey
WCHAR m_DisplayName[DISPLAY_NAME_LEN]
Definition: Node.h:18
#define NULL
Definition: types.h:112
HKEY WINAPI SetupDiOpenClassRegKeyExW(const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:3667
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
#define REG_SZ
Definition: layer.c:22

The documentation for this class was generated from the following files: