ReactOS 0.4.15-dev-7931-gfd331f1
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 ()
 
virtual bool SetupNode ()=0
 
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}
@ ClassNode
Definition: Node.h:8
Definition: Node.h:13
GUID m_ClassGuid
Definition: Node.h:19
SP_CLASSIMAGELIST_DATA ImageListData
Definition: hdwwiz.c:34
#define CopyMemory
Definition: winbase.h:1710

◆ ~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];
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)
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
160
161 // If the number is negative, make it positive
162 if (ResourceId < 0)
164
165 // Load the string from the dll
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}
INT ResourceId
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
HMODULE hModule
Definition: animate.c:44
#define wcschr
Definition: compat.h:17
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
unsigned long DWORD
Definition: ntddk_ex.h:95
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
static PVOID ptr
Definition: dispmode.c:27
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
convenient loading of string resources
Definition: globals.h:304
int32_t INT
Definition: typedefs.h:58
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:342
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
#define ERROR_INVALID_DATA
Definition: winerror.h:116
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by SetupNode().

◆ SetupNode()

bool CClassNode::SetupNode ( )
virtual

Implements CNode.

Definition at line 31 of file ClassNode.cpp.

32{
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);
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
92 {
93 // Use the class name as the description
99 }
100
101 // Get the image index for this class
104 &m_ClassImage);
105
106 return true;
107}
Type
Definition: Type.h:7
#define VOID
Definition: acefi.h:82
#define RegCloseKey(hKey)
Definition: registry.h:49
DWORD ConvertResourceDescriptorToString(_Inout_z_ LPWSTR ResourceDescriptor, _In_ DWORD ResourceDescriptorSize)
Definition: ClassNode.cpp:111
INT m_ClassImage
Definition: Node.h:20
PSP_CLASSIMAGELIST_DATA m_ImageListData
Definition: Node.h:16
WCHAR m_DisplayName[DISPLAY_NAME_LEN]
Definition: Node.h:18
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
BOOL WINAPI SetupDiGetClassImageIndex(IN PSP_CLASSIMAGELIST_DATA ClassImageListData, IN CONST GUID *ClassGuid, OUT PINT ImageIndex)
Definition: devclass.c:277
BOOL WINAPI SetupDiClassNameFromGuidW(const GUID *ClassGuid, PWSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize)
Definition: devinst.c:1067
HKEY WINAPI SetupDiOpenClassRegKeyExW(const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:3662
@ Success
Definition: eventcreate.c:712
FxAutoRegKey hKey
#define REG_SZ
Definition: layer.c:22
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define DIOCR_INSTALLER
Definition: setupapi.h:176
#define _countof(array)
Definition: sndvol32.h:68
unsigned char * LPBYTE
Definition: typedefs.h:53
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4439

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