ReactOS 0.4.17-dev-470-gf9e3448
interface.c File Reference
#include "setupapi_private.h"
Include dependency graph for interface.c:

Go to the source code of this file.

Functions

static BOOL CreateDeviceInterface (IN struct DeviceInfo *deviceInfo, IN LPCWSTR SymbolicLink, IN LPCGUID pInterfaceGuid, OUT struct DeviceInterface **pDeviceInterface)
 
BOOL DestroyDeviceInterface (struct DeviceInterface *deviceInterface)
 
LONG SETUP_CreateInterfaceList (struct DeviceInfoSet *list, PCWSTR MachineName, CONST GUID *InterfaceGuid, PCWSTR DeviceInstanceW, BOOL OnlyPresentInterfaces)
 
static LPWSTR CreateSymbolicLink (IN LPGUID InterfaceGuid, IN LPCWSTR ReferenceString, IN struct DeviceInfo *devInfo)
 
static BOOL InstallOneInterface (IN LPGUID InterfaceGuid, IN LPCWSTR ReferenceString, IN LPCWSTR InterfaceSection, IN UINT InterfaceFlags, IN HINF hInf, IN HDEVINFO DeviceInfoSet, IN struct DeviceInfo *devInfo)
 
BOOL WINAPI SetupDiInstallDeviceInterfaces (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
 
HKEY WINAPI SetupDiOpenDeviceInterfaceRegKey (IN HDEVINFO DeviceInfoSet, IN PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, IN DWORD Reserved, IN REGSAM samDesired)
 
BOOL WINAPI SetupDiDeleteDeviceInterfaceData (HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
 

Variables

static const WCHAR AddInterface [] = {'A','d','d','I','n','t','e','r','f','a','c','e',0}
 
static const WCHAR ClassGUID [] = {'C','l','a','s','s','G','U','I','D',0}
 
static const WCHAR Control [] = {'C','o','n','t','r','o','l',0}
 
static const WCHAR DeviceInstance [] = {'D','e','v','i','c','e','I','n','s','t','a','n','c','e',0}
 
static const WCHAR DotInterfaces [] = {'.','I','n','t','e','r','f','a','c','e','s',0}
 
static const WCHAR Linked [] = {'L','i','n','k','e','d',0}
 
static const WCHAR SymbolicLink [] = {'S','y','m','b','o','l','i','c','L','i','n','k',0}
 

Function Documentation

◆ CreateDeviceInterface()

static BOOL CreateDeviceInterface ( IN struct DeviceInfo deviceInfo,
IN LPCWSTR  SymbolicLink,
IN LPCGUID  pInterfaceGuid,
OUT struct DeviceInterface **  pDeviceInterface 
)
static

Definition at line 34 of file interface.c.

39{
40 struct DeviceInterface *deviceInterface;
41
43
44 deviceInterface = HeapAlloc(GetProcessHeap(), 0,
46 if (!deviceInterface)
47 {
49 return FALSE;
50 }
51 deviceInterface->DeviceInfo = deviceInfo;
52 strcpyW(deviceInterface->SymbolicLink, SymbolicLink);
53 deviceInterface->Flags = 0; /* Flags will be updated later */
54 memcpy(&deviceInterface->InterfaceClassGuid, pInterfaceGuid, sizeof(GUID));
55
56 *pDeviceInterface = deviceInterface;
57 return TRUE;
58}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
static const WCHAR SymbolicLink[]
Definition: interface.c:31
FxDeviceInterface * pDeviceInterface
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
short WCHAR
Definition: pedump.c:58
struct DeviceInfo * DeviceInfo
WCHAR SymbolicLink[ANYSIZE_ARRAY]
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define strlenW(s)
Definition: unicode.h:28
#define strcpyW(d, s)
Definition: unicode.h:29

Referenced by InstallOneInterface(), and SETUP_CreateInterfaceList().

◆ CreateSymbolicLink()

static LPWSTR CreateSymbolicLink ( IN LPGUID  InterfaceGuid,
IN LPCWSTR  ReferenceString,
IN struct DeviceInfo devInfo 
)
static

Definition at line 299 of file interface.c.

303{
304 SIZE_T ActualLength, Length;
307
308 Length = 4 + // "\\\\?\\"
309 wcslen(devInfo->instanceId) +
310 1 + (MAX_GUID_STRING_LEN - 1) + 1 + // "#{GUID}\\"
312 1; // UNICODE_NULL
313
315 if (!SymbolicLink)
316 return NULL;
317
319
320 ActualLength = swprintf(SymbolicLink,
321 Length,
322 L"\\\\?\\%s#%s\\%s",
323 devInfo->instanceId,
326 ASSERT(ActualLength == Length - 1);
327
328 return SymbolicLink;
329}
#define MAX_GUID_STRING_LEN
Definition: apphelp.c:29
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
DWORD WINAPI pSetupStringFromGuid(LPGUID lpGUID, PWSTR pString, DWORD dwStringLen)
Definition: misc.c:1775
#define swprintf
Definition: precomp.h:40
#define L(x)
Definition: resources.c:13
#define ASSERT(a)
Definition: mode.c:44
static PWSTR GuidString
Definition: apphelp.c:93
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
uint16_t * LPWSTR
Definition: typedefs.h:56
ULONG_PTR SIZE_T
Definition: typedefs.h:80
_Must_inspect_result_ _In_ WDFDEVICE _In_ CONST GUID _In_opt_ PCUNICODE_STRING ReferenceString
Definition: wdfdevice.h:3636
static const GUID InterfaceGuid
Definition: wlanapi.c:25

Referenced by cmd_mklink(), and InstallOneInterface().

◆ DestroyDeviceInterface()

BOOL DestroyDeviceInterface ( struct DeviceInterface deviceInterface)

Definition at line 61 of file interface.c.

63{
64 return HeapFree(GetProcessHeap(), 0, deviceInterface);
65}
#define HeapFree(x, y, z)
Definition: compat.h:735

Referenced by DestroyDeviceInfo(), and SETUP_CreateInterfaceList().

◆ InstallOneInterface()

static BOOL InstallOneInterface ( IN LPGUID  InterfaceGuid,
IN LPCWSTR  ReferenceString,
IN LPCWSTR  InterfaceSection,
IN UINT  InterfaceFlags,
IN HINF  hInf,
IN HDEVINFO  DeviceInfoSet,
IN struct DeviceInfo devInfo 
)
static

Definition at line 332 of file interface.c.

340{
341 HKEY hKey;
342 LPWSTR Path;
343 SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;
344 struct DeviceInterface *DevItf = NULL;
345
346 if (InterfaceFlags != 0)
347 {
349 return FALSE;
350 }
351
352 TRACE("Need to InstallOneInterface(%s %s %s %u) hInf %p DeviceInfoSet %p devInfo %p instanceId %s\n", debugstr_guid(InterfaceGuid),
353 debugstr_w(ReferenceString), debugstr_w(InterfaceSection), InterfaceFlags, hInf, DeviceInfoSet, devInfo, debugstr_w(devInfo->instanceId));
354
355
357 if (!Path)
358 return FALSE;
359
360 CreateDeviceInterface(devInfo, Path, InterfaceGuid, &DevItf);
362 if (!DevItf)
363 {
364 return FALSE;
365 }
366
367 memcpy(&DeviceInterfaceData.InterfaceClassGuid, &DevItf->InterfaceClassGuid, sizeof(GUID));
368 DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
369 DeviceInterfaceData.Flags = DevItf->Flags;
370 DeviceInterfaceData.Reserved = (ULONG_PTR)DevItf;
371
373 HeapFree(GetProcessHeap(), 0, DevItf);
375 {
376 return FALSE;
377 }
378
379 return SetupInstallFromInfSectionW(NULL, /* FIXME */ hInf, InterfaceSection, SPINST_REGISTRY, hKey, NULL, 0, NULL, NULL, NULL, NULL);
380}
PRTL_UNICODE_STRING_BUFFER Path
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW(HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DWORD Reserved, REGSAM samDesired, HINF InfHandle, PCWSTR InfSectionName)
Definition: devinst.c:2613
BOOL WINAPI SetupInstallFromInfSectionW(HWND owner, HINF hinf, PCWSTR section, UINT flags, HKEY key_root, PCWSTR src_root, UINT copy_flags, PSP_FILE_CALLBACK_W callback, PVOID context, HDEVINFO devinfo, PSP_DEVINFO_DATA devinfo_data)
Definition: install.c:1330
static BOOL CreateDeviceInterface(IN struct DeviceInfo *deviceInfo, IN LPCWSTR SymbolicLink, IN LPCGUID pInterfaceGuid, OUT struct DeviceInterface **pDeviceInterface)
Definition: interface.c:34
static LPWSTR CreateSymbolicLink(IN LPGUID InterfaceGuid, IN LPCWSTR ReferenceString, IN struct DeviceInfo *devInfo)
Definition: interface.c:299
#define ULONG_PTR
Definition: config.h:101
FxAutoRegKey hKey
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
#define SPINST_REGISTRY
Definition: setupapi.h:593
struct _SP_DEVICE_INTERFACE_DATA SP_DEVICE_INTERFACE_DATA
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by SetupDiInstallDeviceInterfaces().

◆ SETUP_CreateInterfaceList()

LONG SETUP_CreateInterfaceList ( struct DeviceInfoSet list,
PCWSTR  MachineName,
CONST GUID InterfaceGuid,
PCWSTR  DeviceInstanceW,
BOOL  OnlyPresentInterfaces 
)

Definition at line 68 of file interface.c.

74{
75 HKEY hInterfaceKey; /* HKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses\{GUID} */
76 HKEY hDeviceInstanceKey; /* HKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses\{GUID}\##?#{InstancePath} */
77 HKEY hReferenceKey; /* HKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses\{GUID}\##?#{InstancePath}\#{ReferenceString} */
78 HKEY hControlKey; /* HKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses\{GUID}\##?#{InstancePath}\#{ReferenceString}\Control */
79 HKEY hEnumKey; /* HKLM\SYSTEM\CurrentControlSet\Enum */
80 HKEY hKey; /* HKLM\SYSTEM\CurrentControlSet\Enum\{Instance\Path} */
81 LONG rc;
82 WCHAR KeyBuffer[max(MAX_PATH, MAX_GUID_STRING_LEN) + 1];
83 PWSTR pSymbolicLink = NULL;
84 PWSTR InstancePath = NULL;
85 DWORD i, j;
86 DWORD dwLength, dwInstancePathLength;
87 DWORD dwRegType;
88 DWORD LinkedValue;
89 GUID ClassGuid;
90 struct DeviceInfo *deviceInfo;
91
92 hInterfaceKey = INVALID_HANDLE_VALUE;
93 hDeviceInstanceKey = NULL;
94 hReferenceKey = NULL;
95
96 /* Open registry key related to this interface */
98 if (hInterfaceKey == INVALID_HANDLE_VALUE)
99 {
100 /* Key doesn't exist. Let's keep it empty */
101 rc = ERROR_SUCCESS;
102 goto cleanup;
103 }
104
105 /* Enumerate sub keys of hInterfaceKey */
106 i = 0;
107 while (TRUE)
108 {
109 dwLength = sizeof(KeyBuffer) / sizeof(KeyBuffer[0]);
110 rc = RegEnumKeyExW(hInterfaceKey, i, KeyBuffer, &dwLength, NULL, NULL, NULL, NULL);
111 if (rc == ERROR_NO_MORE_ITEMS)
112 break;
113 if (rc != ERROR_SUCCESS)
114 goto cleanup;
115 i++;
116
117 /* Open sub key */
118 if (hDeviceInstanceKey != NULL)
119 RegCloseKey(hDeviceInstanceKey);
120 rc = RegOpenKeyExW(hInterfaceKey, KeyBuffer, 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &hDeviceInstanceKey);
121 if (rc != ERROR_SUCCESS)
122 goto cleanup;
123
124 /* Read DeviceInstance */
125 rc = RegQueryValueExW(hDeviceInstanceKey, DeviceInstance, NULL, &dwRegType, NULL, &dwInstancePathLength);
126 if (rc != ERROR_SUCCESS)
127 goto cleanup;
128 if (dwRegType != REG_SZ)
129 {
131 goto cleanup;
132 }
133 HeapFree(GetProcessHeap(), 0, InstancePath);
134 InstancePath = HeapAlloc(GetProcessHeap(), 0, dwInstancePathLength + sizeof(WCHAR));
135 if (!InstancePath)
136 {
138 goto cleanup;
139 }
140 rc = RegQueryValueExW(hDeviceInstanceKey, DeviceInstance, NULL, NULL, (LPBYTE)InstancePath, &dwInstancePathLength);
141 if (rc != ERROR_SUCCESS)
142 goto cleanup;
143 InstancePath[dwInstancePathLength / sizeof(WCHAR)] = '\0';
144 TRACE("DeviceInstance %s\n", debugstr_w(InstancePath));
145
146 if (DeviceInstanceW)
147 {
148 /* Check if device enumerator is not the right one */
149 if (strcmpW(DeviceInstanceW, InstancePath) != 0)
150 continue;
151 }
152
153 /* Find class GUID associated to the device instance */
154 rc = RegOpenKeyExW(
155 list->HKLM,
157 0, /* Options */
159 &hEnumKey);
160 if (rc != ERROR_SUCCESS)
161 goto cleanup;
162 rc = RegOpenKeyExW(
163 hEnumKey,
164 InstancePath,
165 0, /* Options */
167 &hKey);
169 if (rc != ERROR_SUCCESS)
170 goto cleanup;
171 dwLength = sizeof(KeyBuffer) - sizeof(WCHAR);
172 rc = RegQueryValueExW(hKey, ClassGUID, NULL, NULL, (LPBYTE)KeyBuffer, &dwLength);
174 if (rc != ERROR_SUCCESS)
175 goto cleanup;
176 KeyBuffer[dwLength / sizeof(WCHAR)] = '\0';
177 KeyBuffer[37] = '\0'; /* Replace the } by a NULL character */
178 if (UuidFromStringW(&KeyBuffer[1], &ClassGuid) != RPC_S_OK)
179 {
181 goto cleanup;
182 }
183 TRACE("ClassGUID %s\n", debugstr_guid(&ClassGuid));
184
185 /* If current device doesn't match the list GUID (if any), skip this entry */
186 if (!IsEqualIID(&list->ClassGuid, &GUID_NULL) && !IsEqualIID(&list->ClassGuid, &ClassGuid))
187 continue;
188
189 /* Enumerate subkeys of hDeviceInstanceKey (ie "#ReferenceString" in IoRegisterDeviceInterface). Skip entries that don't start with '#' */
190 j = 0;
191 while (TRUE)
192 {
193 struct DeviceInterface *interfaceInfo;
194
195 dwLength = sizeof(KeyBuffer) / sizeof(KeyBuffer[0]);
196 rc = RegEnumKeyExW(hDeviceInstanceKey, j, KeyBuffer, &dwLength, NULL, NULL, NULL, NULL);
197 if (rc == ERROR_NO_MORE_ITEMS)
198 break;
199 if (rc != ERROR_SUCCESS)
200 goto cleanup;
201 j++;
202 if (KeyBuffer[0] != '#')
203 /* This entry doesn't represent an interesting entry */
204 continue;
205
206 /* Open sub key */
207 if (hReferenceKey != NULL)
208 RegCloseKey(hReferenceKey);
209 rc = RegOpenKeyExW(hDeviceInstanceKey, KeyBuffer, 0, KEY_QUERY_VALUE, &hReferenceKey);
210 if (rc != ERROR_SUCCESS)
211 goto cleanup;
212
213 /* Read SymbolicLink value */
214 rc = RegQueryValueExW(hReferenceKey, SymbolicLink, NULL, &dwRegType, NULL, &dwLength);
215 if (rc != ERROR_SUCCESS)
216 {
217 /* Skip device interface with invalid reference value (i.e. interface not actually available for this device) */
218 RegCloseKey(hReferenceKey);
219 continue;
220 }
221 if (dwRegType != REG_SZ)
222 {
224 goto cleanup;
225 }
226
227 /* We have found a device */
228 /* Step 1. Create a device info element */
229 if (!CreateDeviceInfo(list, InstancePath, &ClassGuid, &deviceInfo))
230 {
231 rc = GetLastError();
232 goto cleanup;
233 }
234 TRACE("Adding device %s to list\n", debugstr_w(InstancePath));
235 InsertTailList(&list->ListHead, &deviceInfo->ListEntry);
236
237 /* Step 2. Create an interface list for this element */
238 HeapFree(GetProcessHeap(), 0, pSymbolicLink);
239 pSymbolicLink = HeapAlloc(GetProcessHeap(), 0, dwLength + sizeof(WCHAR));
240 if (!pSymbolicLink)
241 {
243 goto cleanup;
244 }
245 rc = RegQueryValueExW(hReferenceKey, SymbolicLink, NULL, NULL, (LPBYTE)pSymbolicLink, &dwLength);
246 pSymbolicLink[dwLength / sizeof(WCHAR)] = '\0';
247 if (rc != ERROR_SUCCESS)
248 goto cleanup;
249 if (!CreateDeviceInterface(deviceInfo, pSymbolicLink, InterfaceGuid, &interfaceInfo))
250 {
251 rc = GetLastError();
252 goto cleanup;
253 }
254
255 /* Step 3. Update flags */
256 if (KeyBuffer[1] == '\0')
257 interfaceInfo->Flags |= SPINT_DEFAULT;
258 rc = RegOpenKeyExW(hReferenceKey, Control, 0, KEY_QUERY_VALUE, &hControlKey);
259 if (rc != ERROR_SUCCESS)
260 {
261#if 0
262 if (OnlyPresentInterfaces)
263 {
264 DestroyDeviceInterface(interfaceInfo);
265 continue;
266 }
267 else
268 interfaceInfo->Flags |= SPINT_REMOVED;
269#endif
270 }
271 else
272 {
273 dwLength = sizeof(DWORD);
274 if (RegQueryValueExW(hControlKey, Linked, NULL, &dwRegType, (LPBYTE)&LinkedValue, &dwLength) == ERROR_SUCCESS
275 && dwRegType == REG_DWORD && LinkedValue)
276 interfaceInfo->Flags |= SPINT_ACTIVE;
277 RegCloseKey(hControlKey);
278 }
279
280 TRACE("Adding interface %s to list\n", debugstr_w(pSymbolicLink));
281 InsertTailList(&deviceInfo->InterfaceListHead, &interfaceInfo->ListEntry);
282 }
283 }
284 rc = ERROR_SUCCESS;
285
286cleanup:
287 if (hReferenceKey != NULL)
288 RegCloseKey(hReferenceKey);
289 if (hDeviceInstanceKey != NULL)
290 RegCloseKey(hDeviceInstanceKey);
291 if (hInterfaceKey != INVALID_HANDLE_VALUE)
292 RegCloseKey(hInterfaceKey);
293 HeapFree(GetProcessHeap(), 0, InstancePath);
294 HeapFree(GetProcessHeap(), 0, pSymbolicLink);
295 return rc;
296}
HKEY hEnumKey
Definition: umpnpmgr.c:44
#define RegCloseKey(hKey)
Definition: registry.h:49
Definition: list.h:37
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
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 ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define MAX_PATH
Definition: compat.h:34
static DWORD DWORD * dwLength
Definition: fusion.c:86
static void cleanup(void)
Definition: main.c:1335
HKEY WINAPI SetupDiOpenClassRegKeyExW(const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:3708
BOOL CreateDeviceInfo(IN struct DeviceInfoSet *list, IN LPCWSTR InstancePath, IN LPCGUID pClassGuid, OUT struct DeviceInfo **pDeviceInfo)
Definition: devinst.c:528
BOOL DestroyDeviceInterface(struct DeviceInterface *deviceInterface)
Definition: interface.c:61
static const WCHAR ClassGUID[]
Definition: interface.c:26
static const WCHAR Linked[]
Definition: interface.c:30
static const WCHAR DeviceInstance[]
Definition: interface.c:28
#define InsertTailList(ListHead, Entry)
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define GUID_NULL
Definition: ks.h:106
#define REG_SZ
Definition: layer.c:22
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1022
#define READ_CONTROL
Definition: nt_native.h:58
#define DWORD
Definition: nt_native.h:44
long LONG
Definition: pedump.c:60
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REGSTR_PATH_SYSTEMENUM
Definition: regstr.h:483
#define RPC_S_OK
Definition: rpcnterr.h:22
RPC_STATUS WINAPI UuidFromStringW(RPC_WSTR s, UUID *uuid)
Definition: rpcrt4_main.c:655
#define REG_DWORD
Definition: sdbapi.c:615
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1296
#define DIOCR_INTERFACE
Definition: setupapi.h:180
#define SPINT_REMOVED
Definition: setupapi.h:587
#define SPINT_DEFAULT
Definition: setupapi.h:586
#define SPINT_ACTIVE
Definition: setupapi.h:585
LIST_ENTRY InterfaceListHead
LIST_ENTRY ListEntry
LIST_ENTRY ListEntry
#define max(a, b)
Definition: svc.c:63
uint16_t * PWSTR
Definition: typedefs.h:56
unsigned char * LPBYTE
Definition: typedefs.h:53
_In_ WDF_WMI_PROVIDER_CONTROL Control
Definition: wdfwmi.h:166
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define strcmpW(s1, s2)
Definition: unicode.h:38
#define ERROR_GEN_FAILURE
Definition: winerror.h:256

Referenced by SetupDiGetClassDevsExW().

◆ SetupDiDeleteDeviceInterfaceData()

BOOL WINAPI SetupDiDeleteDeviceInterfaceData ( HDEVINFO  DeviceInfoSet,
PSP_DEVICE_INTERFACE_DATA  DeviceInterfaceData 
)

Definition at line 608 of file interface.c.

611{
612 FIXME("SetupDiDeleteDeviceInterfaceData(%p %p) stub\n",
613 DeviceInfoSet, DeviceInterfaceData);
614 return TRUE;
615}
#define FIXME(fmt,...)
Definition: precomp.h:53

Referenced by test_device_iface(), and test_register_device_iface().

◆ SetupDiInstallDeviceInterfaces()

BOOL WINAPI SetupDiInstallDeviceInterfaces ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA  DeviceInfoData 
)

Definition at line 386 of file interface.c.

389{
390 struct DeviceInfoSet *list = NULL;
391 BOOL ret = FALSE;
392
394
395 if (!DeviceInfoSet)
401 else if (!DeviceInfoData)
403 else if (DeviceInfoData && DeviceInfoData->Reserved == 0)
405 else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
407 else
408 {
409 struct DeviceInfo *devInfo;
410 struct DriverInfoElement *SelectedDriver = NULL;
411 SP_DEVINSTALL_PARAMS_W InstallParams;
412 WCHAR SectionName[MAX_PATH];
413 DWORD SectionNameLength = 0;
414 INFCONTEXT ContextInterface;
415 LPWSTR InterfaceGuidString = NULL;
417 LPWSTR InterfaceSection = NULL;
418 INT InterfaceFlags;
420 BOOL Result;
421
422 devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
423
426 if (!Result)
427 goto cleanup;
428
429 SelectedDriver = (struct DriverInfoElement *)InstallParams.ClassInstallReserved;
430 if (SelectedDriver == NULL)
431 {
433 ret = FALSE;
434 goto cleanup;
435 }
436
437 /* Get .Interfaces section name */
439 SelectedDriver->InfFileDetails->hInf,
440 SelectedDriver->Details.SectionName,
441 SectionName, MAX_PATH, &SectionNameLength, NULL);
442 if (!Result || SectionNameLength > MAX_PATH - strlenW(DotInterfaces) - 1)
443 goto cleanup;
444 strcatW(SectionName, DotInterfaces);
445
446 ret = TRUE;
448 SelectedDriver->InfFileDetails->hInf,
449 SectionName,
451 &ContextInterface);
452 while (ret && Result)
453 {
454 ret = GetStringField(&ContextInterface, 1, &InterfaceGuidString);
455 if (!ret)
456 goto cleanup;
457 else if (strlenW(InterfaceGuidString) != MAX_GUID_STRING_LEN - 1)
458 {
460 ret = FALSE;
461 goto cleanup;
462 }
463
464 InterfaceGuidString[MAX_GUID_STRING_LEN - 2] = '\0'; /* Replace the } by a NULL character */
465 if (UuidFromStringW(&InterfaceGuidString[1], &InterfaceGuid) != RPC_S_OK)
466 {
467 /* Bad GUID, skip the entry */
469 ret = FALSE;
470 goto cleanup;
471 }
472
473 ret = GetStringField(&ContextInterface, 2, &ReferenceString);
474 if (!ret)
475 goto cleanup;
476
477 ret = GetStringField(&ContextInterface, 3, &InterfaceSection);
478 if (!ret)
479 {
480 /* ReferenceString is optional */
481 InterfaceSection = ReferenceString;
483 }
484
486 &ContextInterface,
487 (ReferenceString ? 4 : 3), /* Field index */
488 &InterfaceFlags);
489 if (!ret)
490 {
492 {
493 /* The field may be empty. Ignore the error */
494 InterfaceFlags = 0;
495 ret = TRUE;
496 }
497 else
498 goto cleanup;
499 }
500
501 /* Install Interface */
502 ret = InstallOneInterface(&InterfaceGuid, ReferenceString, InterfaceSection, InterfaceFlags, SelectedDriver->InfFileDetails->hInf, DeviceInfoSet, devInfo);
503
504cleanup:
505 MyFree(InterfaceGuidString);
506 if (ReferenceString)
508 MyFree(InterfaceSection);
509 InterfaceGuidString = ReferenceString = InterfaceSection = NULL;
510 Result = SetupFindNextMatchLineW(&ContextInterface, AddInterface, &ContextInterface);
511 }
512 }
513
514 TRACE("Returning %d\n", ret);
515 return ret;
516}
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
BOOL WINAPI SetupDiGetDeviceInstallParamsW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, OUT PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
Definition: devinst.c:4497
BOOL WINAPI SetupDiGetActualSectionToInstallW(HINF InfHandle, PCWSTR InfSectionName, PWSTR InfSectionWithExt, DWORD InfSectionWithExtSize, PDWORD RequiredSize, PWSTR *Extension)
Definition: devinst.c:1980
BOOL GetStringField(PINFCONTEXT context, DWORD index, PWSTR *value)
Definition: install.c:1738
static const WCHAR AddInterface[]
Definition: interface.c:25
static const WCHAR DotInterfaces[]
Definition: interface.c:29
static BOOL InstallOneInterface(IN LPGUID InterfaceGuid, IN LPCWSTR ReferenceString, IN LPCWSTR InterfaceSection, IN UINT InterfaceFlags, IN HINF hInf, IN HDEVINFO DeviceInfoSet, IN struct DeviceInfo *devInfo)
Definition: interface.c:332
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
BOOL WINAPI SetupFindNextMatchLineW(PINFCONTEXT context_in, PCWSTR key, PINFCONTEXT context_out)
Definition: parser.c:1701
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
if(dx< 0)
Definition: linetemp.h:194
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1531
#define ERROR_NO_DRIVER_SELECTED
Definition: setupapi.h:302
#define SETUP_DEVICE_INFO_SET_MAGIC
SP_DEVINSTALL_PARAMS_W InstallParams
struct InfFileDetails * InfFileDetails
SP_DRVINFO_DETAIL_DATA_W Details
ULONG_PTR Reserved
Definition: setupapi.h:841
ULONG_PTR ClassInstallReserved
Definition: setupapi.h:901
WCHAR SectionName[LINE_LEN]
Definition: setupapi.h:1079
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:56
BOOL WINAPI SetupGetIntField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT INT *IntegerValue)
Definition: infsupp.c:148
#define strcatW(d, s)
Definition: unicode.h:30
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1448
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by SetupDiCallClassInstaller().

◆ SetupDiOpenDeviceInterfaceRegKey()

HKEY WINAPI SetupDiOpenDeviceInterfaceRegKey ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVICE_INTERFACE_DATA  DeviceInterfaceData,
IN DWORD  Reserved,
IN REGSAM  samDesired 
)

Definition at line 519 of file interface.c.

521{
522 HKEY hKey = INVALID_HANDLE_VALUE, hDevKey;
523 struct DeviceInfoSet * list;
524
525 TRACE("%p %p %p 0x%08x 0x%08x)\n", DeviceInfoSet, DeviceInterfaceData, Reserved, samDesired);
526
527 if (!DeviceInfoSet)
533 else if (!DeviceInterfaceData)
535 else if (DeviceInterfaceData && DeviceInterfaceData->Reserved == 0)
537 else if (DeviceInterfaceData && DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA))
539 else
540 {
541 struct DeviceInterface *DevItf;
542 LPWSTR Path, Guid, Slash;
544 DevItf = (struct DeviceInterface *)DeviceInterfaceData->Reserved;
545
546 Length = wcslen(DevItf->SymbolicLink);
547
548 Path = HeapAlloc(GetProcessHeap(), 0, (Length+2) * sizeof(WCHAR));
549 if (!Path)
550 {
553 }
554
555 wcscpy(Path, DevItf->SymbolicLink);
556
557 Guid = wcsrchr(Path, '}');
558 Slash = wcsrchr(Path, '\\');
559 if (!Guid || !Slash)
560 {
564 }
565
566 if ((ULONG_PTR)Slash > (ULONG_PTR)Guid)
567 {
568 /* Create an extra slash */
569 memmove(Slash+1, Slash, (wcslen(Slash) + 1) * sizeof(WCHAR));
570 Slash[1] = L'#';
571 }
572
573 Guid = Path;
574 while((ULONG_PTR)Guid < (ULONG_PTR)Slash)
575 {
576 if (*Guid == L'\\')
577 *Guid = L'#';
578
579 Guid++;
580 }
581
582 hKey = SetupDiOpenClassRegKeyExW(&DeviceInterfaceData->InterfaceClassGuid, samDesired, DIOCR_INTERFACE, NULL, NULL);
584 {
585 if (RegOpenKeyExW(hKey, Path, 0, samDesired, &hDevKey) == ERROR_SUCCESS)
586 {
588 hKey = hDevKey;
589 }
590 else
591 {
594 }
595 }
596
598 }
599
600 return hKey;
601}
#define wcsrchr
Definition: compat.h:16
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define list
Definition: rosglue.h:35
wcscpy
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762
_Reserved_ PVOID Reserved
Definition: winddi.h:3974

Referenced by Enum().

Variable Documentation

◆ AddInterface

const WCHAR AddInterface[] = {'A','d','d','I','n','t','e','r','f','a','c','e',0}
static

Definition at line 25 of file interface.c.

Referenced by SetupDiInstallDeviceInterfaces().

◆ ClassGUID

const WCHAR ClassGUID[] = {'C','l','a','s','s','G','U','I','D',0}
static

Definition at line 26 of file interface.c.

Referenced by SETUP_CreateInterfaceList().

◆ Control

const WCHAR Control[] = {'C','o','n','t','r','o','l',0}
static

Definition at line 27 of file interface.c.

◆ DeviceInstance

◆ DotInterfaces

const WCHAR DotInterfaces[] = {'.','I','n','t','e','r','f','a','c','e','s',0}
static

Definition at line 29 of file interface.c.

Referenced by SetupDiInstallDeviceInterfaces().

◆ Linked

const WCHAR Linked[] = {'L','i','n','k','e','d',0}
static

◆ SymbolicLink