ReactOS  0.4.14-dev-52-g6116262
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:1633
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 104 of file ClassNode.cpp.

108 {
109  WCHAR ModulePath[MAX_PATH];
110  WCHAR ResString[256];
111  INT ResourceId;
113  LPWSTR ptr;
114  DWORD Size;
115  DWORD dwError;
116 
117  // First check for a semi colon */
118  ptr = wcschr(ResourceDescriptor, L';');
119  if (ptr)
120  {
121  // This must be an inf based descriptor, the desc is after the semi colon
122  StringCbCopyW(ResourceDescriptor, ResourceDescriptorSize, ++ptr);
123  dwError = ERROR_SUCCESS;
124  }
125  else
126  {
127  // This must be a dll resource based descriptor. Find the comma
128  ptr = wcschr(ResourceDescriptor, L',');
129  if (ptr == NULL)
130  return ERROR_INVALID_DATA;
131 
132  // Terminate the string where the comma was
133  *ptr = UNICODE_NULL;
134 
135  // Expand any environment strings
136  Size = ExpandEnvironmentStringsW(&ResourceDescriptor[1], ModulePath, MAX_PATH);
137  if (Size > MAX_PATH)
138  return ERROR_BUFFER_OVERFLOW;
139  if (Size == 0)
140  return GetLastError();
141 
142  // Put the comma back and move past it
143  *ptr = L',';
144  ptr++;
145 
146  // Load the dll
148  if (hModule == NULL)
149  return GetLastError();
150 
151  // Convert the resource id to a number
152  ResourceId = _wtoi(ptr);
153 
154  // If the number is negative, make it positive
155  if (ResourceId < 0)
156  ResourceId = -ResourceId;
157 
158  // Load the string from the dll
159  if (LoadStringW(hModule, ResourceId, ResString, 256))
160  {
161  StringCbCopyW(ResourceDescriptor, ResourceDescriptorSize, ResString);
162  dwError = ERROR_SUCCESS;
163  }
164  else
165  {
166  dwError = GetLastError();
167  }
168 
169  // Free the library
171  }
172 
173  return dwError;
174 }
#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)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
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:56
#define UNICODE_NULL
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
#define FreeLibrary(x)
Definition: compat.h:405
_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:26
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define ERROR_INVALID_DATA
Definition: winerror.h:116
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338
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);
43  if (hKey != INVALID_HANDLE_VALUE)
44  {
46  Type = REG_SZ;
47 
48  // Lookup the class description (win7+)
50  L"ClassDesc",
51  NULL,
52  &Type,
54  &Size);
55  if (Success == ERROR_SUCCESS)
56  {
57  // Check if the string starts with an @
58  if (m_DisplayName[0] == L'@')
59  {
60  // The description is located in a module resource
62  }
63  }
64  else if (Success == ERROR_FILE_NOT_FOUND)
65  {
66  // WinXP stores the description in the default value
68  NULL,
69  NULL,
70  &Type,
72  &Size);
73  }
74 
75  // Close the registry key
76  RegCloseKey(hKey);
77  }
78  else
79  {
81  }
82 
83  // Check if we failed to get the class description
84  if (Success != ERROR_SUCCESS)
85  {
86  // Use the class name as the description
91  &RequiredSize);
92  }
93 
94  // Get the image index for this class
96  &m_ClassGuid,
97  &m_ClassImage);
98 
99  return true;
100 }
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
Type
Definition: Type.h:6
#define ERROR_SUCCESS
Definition: deptool.c:10
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
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:52
#define DIOCR_INSTALLER
Definition: setupapi.h:176
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
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
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:104
static const WCHAR L[]
Definition: oid.c:1250
#define VOID
Definition: acefi.h:82
PSP_CLASSIMAGELIST_DATA m_ImageListData
Definition: Node.h:16
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
WCHAR m_DisplayName[DISPLAY_NAME_LEN]
Definition: Node.h:18
HKEY WINAPI SetupDiOpenClassRegKeyExW(const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:3667
#define DISPLAY_NAME_LEN
Definition: hotplug.cpp:16
#define REG_SZ
Definition: layer.c:22

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