ReactOS  0.4.15-dev-2535-gcf6c191
setupapi_private.h File Reference
#include <wchar.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <wingdi.h>
#include <winreg.h>
#include <winspool.h>
#include <wincon.h>
#include <commdlg.h>
#include <objbase.h>
#include <cfgmgr32.h>
#include <regstr.h>
#include <sddl.h>
#include <setupapi.h>
#include <softpub.h>
#include <mscat.h>
#include <lzexpand.h>
#include <shlobj.h>
#include <wine/unicode.h>
#include <ndk/rtlfuncs.h>
#include <wine/debug.h>
#include "resource.h"
Include dependency graph for setupapi_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  DeviceInterface
 
struct  InfFileDetails
 
struct  DriverInfoElement
 
struct  ClassInstallParams
 
struct  DeviceInfo
 
struct  DeviceInfoSet
 
struct  ClassImageList
 
struct  FileLog
 
struct  callback_WtoA_context
 

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define COBJMACROS
 
#define NTOS_MODE_USER
 
#define SETUP_DEVICE_INFO_SET_MAGIC   0xd00ff057
 
#define SETUP_CLASS_IMAGE_LIST_MAGIC   0xd00ff058
 
#define CMP_MAGIC   0x01234567
 
#define PSPGF_NO_BACKUP   0x0002
 
#define PSPGF_NONINTERACTIVE   0x0004
 
#define RC_STRING_MAX_SIZE   256
 
#define REG_INSTALLEDFILES   "System\\CurrentControlSet\\Control\\InstalledFiles"
 
#define REGPART_RENAME   "\\Rename"
 
#define REG_VERSIONCONFLICT   "Software\\Microsoft\\VersionConflictManager"
 
#define _S_IWRITE   0x0080
 
#define _S_IREAD   0x0100
 

Typedefs

typedef BOOL(* FIND_CALLBACK) (LPCWSTR SectionName, PVOID Context)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (setupapi)
 
static WCHARstrdupAtoW (const char *str)
 
const WCHARDIRID_get_string (int dirid)
 
const WCHARPARSER_get_inf_filename (HINF hinf) DECLSPEC_HIDDEN
 
WCHARPARSER_get_src_root (HINF hinf) DECLSPEC_HIDDEN
 
WCHARPARSER_get_dest_dir (INFCONTEXT *context) DECLSPEC_HIDDEN
 
UINT CALLBACK QUEUE_callback_WtoA (void *context, UINT notification, UINT_PTR, UINT_PTR)
 
DWORD GetErrorCodeFromCrCode (const IN CONFIGRET cr)
 
BOOL CreateDeviceInfo (IN struct DeviceInfoSet *list, IN LPCWSTR InstancePath, IN LPCGUID pClassGuid, OUT struct DeviceInfo **pDeviceInfo)
 
LONG SETUP_CreateDevicesList (IN OUT struct DeviceInfoSet *list, IN PCWSTR MachineName OPTIONAL, IN CONST GUID *Class OPTIONAL, IN PCWSTR Enumerator OPTIONAL)
 
HKEY SETUPDI_CreateDevKey (HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
 
HKEY SETUPDI_CreateDrvKey (HKEY RootKey, struct DeviceInfo *devInfo, UUID *ClassGuid, REGSAM samDesired)
 
HKEY SETUPDI_OpenDevKey (HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
 
HKEY SETUPDI_OpenDrvKey (HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
 
struct InfFileDetailsCreateInfFileDetails (IN LPCWSTR FullInfFileName)
 
VOID DereferenceInfFile (struct InfFileDetails *infFile)
 
BOOL DestroyDriverInfoElement (struct DriverInfoElement *driverInfo)
 
BOOL GetStringField (PINFCONTEXT context, DWORD index, PWSTR *value)
 
BOOL DestroyDeviceInterface (struct DeviceInterface *deviceInterface)
 
LONG SETUP_CreateInterfaceList (struct DeviceInfoSet *list, PCWSTR MachineName, CONST GUID *InterfaceGuid, PCWSTR DeviceInstanceW, BOOL OnlyPresentInterfaces)
 
DWORD GetFunctionPointer (IN PWSTR InstallerName, OUT HMODULE *ModulePointer, OUT PVOID *FunctionPointer)
 
DWORD FreeFunctionPointer (IN HMODULE ModulePointer, IN PVOID FunctionPointer)
 
DWORD WINAPI pSetupStringFromGuid (LPGUID lpGUID, PWSTR pString, DWORD dwStringLen)
 
DWORD WINAPI CaptureAndConvertAnsiArg (LPCSTR pSrc, LPWSTR *pDst)
 
VOID WINAPI MyFree (LPVOID lpMem)
 
LPVOID WINAPI MyMalloc (DWORD dwSize)
 
LPVOID WINAPI MyRealloc (LPVOID lpSrc, DWORD dwSize)
 
LPWSTR WINAPI DuplicateString (LPCWSTR lpSrc)
 
BOOL WINAPI IsUserAdmin (VOID)
 
LPWSTR WINAPI MultiByteToUnicode (LPCSTR lpMultiByteStr, UINT uCodePage)
 
LPSTR WINAPI UnicodeToMultiByte (LPCWSTR lpUnicodeStr, UINT uCodePage)
 
BOOL EnumerateSectionsStartingWith (HINF hInf, LPCWSTR pStr, FIND_CALLBACK Callback, PVOID Context)
 

Variables

HINSTANCE hInstance
 
OSVERSIONINFOEXW OsVersionInfo
 
DWORD GlobalSetupFlags
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 26 of file setupapi_private.h.

◆ _S_IREAD

#define _S_IREAD   0x0100

Definition at line 297 of file setupapi_private.h.

◆ _S_IWRITE

#define _S_IWRITE   0x0080

Definition at line 296 of file setupapi_private.h.

◆ CMP_MAGIC

#define CMP_MAGIC   0x01234567

Definition at line 66 of file setupapi_private.h.

◆ COBJMACROS

#define COBJMACROS

Definition at line 29 of file setupapi_private.h.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 27 of file setupapi_private.h.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 51 of file setupapi_private.h.

◆ PSPGF_NO_BACKUP

#define PSPGF_NO_BACKUP   0x0002

Definition at line 256 of file setupapi_private.h.

◆ PSPGF_NONINTERACTIVE

#define PSPGF_NONINTERACTIVE   0x0004

Definition at line 257 of file setupapi_private.h.

◆ RC_STRING_MAX_SIZE

#define RC_STRING_MAX_SIZE   256

Definition at line 259 of file setupapi_private.h.

◆ REG_INSTALLEDFILES

#define REG_INSTALLEDFILES   "System\\CurrentControlSet\\Control\\InstalledFiles"

Definition at line 261 of file setupapi_private.h.

◆ REG_VERSIONCONFLICT

#define REG_VERSIONCONFLICT   "Software\\Microsoft\\VersionConflictManager"

Definition at line 263 of file setupapi_private.h.

◆ REGPART_RENAME

#define REGPART_RENAME   "\\Rename"

Definition at line 262 of file setupapi_private.h.

◆ SETUP_CLASS_IMAGE_LIST_MAGIC

#define SETUP_CLASS_IMAGE_LIST_MAGIC   0xd00ff058

Definition at line 64 of file setupapi_private.h.

◆ SETUP_DEVICE_INFO_SET_MAGIC

#define SETUP_DEVICE_INFO_SET_MAGIC   0xd00ff057

Definition at line 63 of file setupapi_private.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 25 of file setupapi_private.h.

Typedef Documentation

◆ FIND_CALLBACK

typedef BOOL(* FIND_CALLBACK) (LPCWSTR SectionName, PVOID Context)

Definition at line 383 of file setupapi_private.h.

Function Documentation

◆ CaptureAndConvertAnsiArg()

DWORD WINAPI CaptureAndConvertAnsiArg ( LPCSTR  pSrc,
LPWSTR pDst 
)

◆ CreateDeviceInfo()

BOOL CreateDeviceInfo ( IN struct DeviceInfoSet list,
IN LPCWSTR  InstancePath,
IN LPCGUID  pClassGuid,
OUT struct DeviceInfo **  pDeviceInfo 
)

Definition at line 528 of file devinst.c.

533 {
534  DWORD size;
535  CONFIGRET cr;
536  struct DeviceInfo *deviceInfo;
537 
538  *pDeviceInfo = NULL;
539 
540  size = FIELD_OFFSET(struct DeviceInfo, Data) + (strlenW(InstancePath) + 1) * sizeof(WCHAR);
541  deviceInfo = HeapAlloc(GetProcessHeap(), 0, size);
542  if (!deviceInfo)
543  {
545  return FALSE;
546  }
547  ZeroMemory(deviceInfo, size);
548 
549  cr = CM_Locate_DevNode_ExW(&deviceInfo->dnDevInst, (DEVINSTID_W)InstancePath, CM_LOCATE_DEVNODE_PHANTOM, list->hMachine);
550  if (cr != CR_SUCCESS)
551  {
553  return FALSE;
554  }
555 
556  deviceInfo->set = list;
557  deviceInfo->InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
558  strcpyW(deviceInfo->Data, InstancePath);
559  deviceInfo->instanceId = deviceInfo->Data;
560  deviceInfo->UniqueId = strrchrW(deviceInfo->Data, '\\');
561  deviceInfo->DeviceDescription = NULL;
562  memcpy(&deviceInfo->ClassGuid, pClassGuid, sizeof(GUID));
563  deviceInfo->CreationFlags = 0;
564  InitializeListHead(&deviceInfo->DriverListHead);
566 
567  *pDeviceInfo = deviceInfo;
568  return TRUE;
569 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define TRUE
Definition: types.h:120
LIST_ENTRY InterfaceListHead
DWORD GetErrorCodeFromCrCode(const IN CONFIGRET cr)
Definition: devinst.c:94
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ZeroMemory
Definition: winbase.h:1664
SP_DEVINSTALL_PARAMS_W InstallParams
_Null_terminated_ WCHAR * DEVINSTID_W
Definition: cfgmgr32.h:80
#define FALSE
Definition: types.h:117
CONFIGRET WINAPI CM_Locate_DevNode_ExW(_Out_ PDEVINST pdnDevInst, _In_opt_ DEVINSTID_W pDeviceID, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:5907
#define CR_SUCCESS
Definition: cfgmgr32.h:842
PCWSTR DeviceDescription
WCHAR Data[ANYSIZE_ARRAY]
struct DeviceInfoSet * set
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
LIST_ENTRY DriverListHead
DEVINST dnDevInst
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: _list.h:228
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define list
Definition: rosglue.h:35
#define NULL
Definition: types.h:112
#define CM_LOCATE_DEVNODE_PHANTOM
Definition: cfgmgr32.h:761
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
struct _SP_DEVINSTALL_PARAMS_W SP_DEVINSTALL_PARAMS_W

Referenced by SETUP_CreateDevicesList(), SETUP_CreateInterfaceList(), SetupDiCreateDeviceInfoW(), SetupDiOpenDeviceInfoW(), and SetupDiOpenDeviceInterfaceW().

◆ CreateInfFileDetails()

struct InfFileDetails* CreateInfFileDetails ( IN LPCWSTR  FullInfFileName)

Definition at line 55 of file driver.c.

57 {
58  struct InfFileDetails *details;
59  PWCHAR last;
60  DWORD Needed;
61 
62  Needed = FIELD_OFFSET(struct InfFileDetails, szData)
63  + strlenW(FullInfFileName) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
64 
65  details = HeapAlloc(GetProcessHeap(), 0, Needed);
66  if (!details)
67  {
69  return NULL;
70  }
71 
72  memset(details, 0, Needed);
73  strcpyW(details->szData, FullInfFileName);
74  last = strrchrW(details->szData, '\\');
75  if (last)
76  {
77  details->DirectoryName = details->szData;
78  details->FileName = last + 1;
79  *last = '\0';
80  }
81  else
82  details->FileName = details->szData;
84  details->hInf = SetupOpenInfFileW(FullInfFileName, NULL, INF_STYLE_WIN4, NULL);
85  if (details->hInf == INVALID_HANDLE_VALUE)
86  {
88  return NULL;
89  }
90  return details;
91 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define INF_STYLE_WIN4
Definition: infsupp.h:41
POINT last
Definition: font.c:46
static const WCHAR szData[]
Definition: msipriv.h:1195
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
uint16_t * PWCHAR
Definition: typedefs.h:56
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
#define UNICODE_NULL
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static VOID ReferenceInfFile(struct InfFileDetails *infFile)
Definition: driver.c:39
#define SetLastError(x)
Definition: compat.h:611
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NULL
Definition: types.h:112
int details
Definition: msacm.c:1365
#define memset(x, y, z)
Definition: compat.h:39
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by SetupDiBuildDriverInfoList(), and SetupDiInstallDevice().

◆ DereferenceInfFile()

VOID DereferenceInfFile ( struct InfFileDetails infFile)

Definition at line 45 of file driver.c.

46 {
47  if (InterlockedDecrement(&infFile->References) == 0)
48  {
49  SetupCloseInfFile(infFile->hInf);
50  HeapFree(GetProcessHeap(), 0, infFile);
51  }
52 }
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:43
#define GetProcessHeap()
Definition: compat.h:595
#define InterlockedDecrement
Definition: armddk.h:52
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by DestroyDriverInfoElement(), SetupDiBuildDriverInfoList(), and SetupDiInstallDevice().

◆ DestroyDeviceInterface()

BOOL DestroyDeviceInterface ( struct DeviceInterface deviceInterface)

Definition at line 61 of file interface.c.

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

Referenced by DestroyDeviceInfo(), and SETUP_CreateInterfaceList().

◆ DestroyDriverInfoElement()

BOOL DestroyDriverInfoElement ( struct DriverInfoElement driverInfo)

Definition at line 94 of file driver.c.

95 {
97  HeapFree(GetProcessHeap(), 0, driverInfo->MatchingId);
98  HeapFree(GetProcessHeap(), 0, driverInfo);
99  return TRUE;
100 }
#define TRUE
Definition: types.h:120
struct InfFileDetails * InfFileDetails
#define GetProcessHeap()
Definition: compat.h:595
VOID DereferenceInfFile(struct InfFileDetails *infFile)
Definition: driver.c:45
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by DestroyDeviceInfo(), and SetupDiDestroyDriverInfoList().

◆ DIRID_get_string()

const WCHAR* DIRID_get_string ( int  dirid)

Definition at line 159 of file dirid.c.

160 {
161  int i;
162 
163  if (dirid == DIRID_ABSOLUTE || dirid == DIRID_ABSOLUTE_16BIT) dirid = DIRID_NULL;
164 
165  if (dirid >= DIRID_USER)
166  {
167  for (i = 0; i < nb_user_dirids; i++)
168  if (user_dirids[i].id == dirid) return user_dirids[i].str;
169  WARN("user id %d not found\n", dirid );
170  return NULL;
171  }
172  else if (dirid >= MIN_CSIDL_DIRID)
173  {
174  if (dirid > MAX_CSIDL_DIRID) return get_unknown_dirid();
175  dirid -= MIN_CSIDL_DIRID;
176  if (!csidl_dirids[dirid]) csidl_dirids[dirid] = get_csidl_dir( dirid );
177  return csidl_dirids[dirid];
178  }
179  else
180  {
181  if (dirid > MAX_SYSTEM_DIRID) return get_unknown_dirid();
182  if (!system_dirids[dirid]) system_dirids[dirid] = create_system_dirid( dirid );
183  return system_dirids[dirid];
184  }
185 }
static struct user_dirid * user_dirids
Definition: dirid.c:35
#define MAX_CSIDL_DIRID
Definition: dirid.c:25
#define WARN(fmt,...)
Definition: debug.h:112
#define DIRID_NULL
Definition: setupapi.h:185
static const WCHAR * get_unknown_dirid(void)
Definition: dirid.c:40
static const WCHAR * system_dirids[MAX_SYSTEM_DIRID+1]
Definition: dirid.c:36
#define DIRID_USER
Definition: setupapi.h:217
static const WCHAR * get_csidl_dir(DWORD csidl)
Definition: dirid.c:143
static int nb_user_dirids
Definition: dirid.c:33
#define MAX_SYSTEM_DIRID
Definition: dirid.c:23
#define DIRID_ABSOLUTE
Definition: setupapi.h:184
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
#define MIN_CSIDL_DIRID
Definition: dirid.c:24
#define NULL
Definition: types.h:112
static const WCHAR * create_system_dirid(int dirid)
Definition: dirid.c:58
#define DIRID_ABSOLUTE_16BIT
Definition: setupapi.h:218
static const WCHAR * csidl_dirids[MAX_CSIDL_DIRID-MIN_CSIDL_DIRID+1]
Definition: dirid.c:37

Referenced by Concatenate(), and get_dirid_subst().

◆ DuplicateString()

LPWSTR WINAPI DuplicateString ( LPCWSTR  lpSrc)

◆ EnumerateSectionsStartingWith()

BOOL EnumerateSectionsStartingWith ( HINF  hInf,
LPCWSTR  pStr,
FIND_CALLBACK  Callback,
PVOID  Context 
)

◆ FreeFunctionPointer()

DWORD FreeFunctionPointer ( IN HMODULE  ModulePointer,
IN PVOID  FunctionPointer 
)

Definition at line 105 of file misc.c.

108 {
109  if (ModulePointer == NULL)
110  return ERROR_SUCCESS;
111  if (FreeLibrary(ModulePointer))
112  return ERROR_SUCCESS;
113  else
114  return GetLastError();
115 }
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define FreeLibrary(x)
Definition: compat.h:607
#define NULL
Definition: types.h:112

Referenced by SetupDiCallClassInstaller().

◆ GetErrorCodeFromCrCode()

DWORD GetErrorCodeFromCrCode ( const IN CONFIGRET  cr)

Definition at line 94 of file devinst.c.

95 {
96  switch (cr)
97  {
101  case CR_FAILURE: return ERROR_GEN_FAILURE;
115  case CR_SUCCESS: return ERROR_SUCCESS;
116  default: return ERROR_GEN_FAILURE;
117  }
118 
119  /* Does not happen */
120 }
#define CR_NO_SUCH_REGISTRY_KEY
Definition: cfgmgr32.h:892
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define CR_NO_SUCH_VALUE
Definition: cfgmgr32.h:883
#define CR_ALREADY_SUCH_DEVINST
Definition: cfgmgr32.h:862
#define CR_ACCESS_DENIED
Definition: cfgmgr32.h:897
#define CR_INVALID_DEVICE_ID
Definition: cfgmgr32.h:876
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1091
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define ERROR_INVALID_COMPUTERNAME
Definition: winerror.h:713
#define CR_INVALID_PROPERTY
Definition: cfgmgr32.h:899
#define CR_OUT_OF_MEMORY
Definition: cfgmgr32.h:844
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
#define CR_FAILURE
Definition: cfgmgr32.h:865
#define CR_INVALID_DATA
Definition: cfgmgr32.h:877
#define CR_INVALID_DEVNODE
Definition: cfgmgr32.h:847
#define CR_INVALID_MACHINENAME
Definition: cfgmgr32.h:893
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define ERROR_DEVINST_ALREADY_EXISTS
Definition: setupapi.h:298
#define CR_NO_SUCH_DEVNODE
Definition: cfgmgr32.h:857
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by CreateDeviceInfo(), ResetDevice(), SETUP_CreateDevicesList(), SetupDiBuildClassInfoListExW(), SetupDiCreateDeviceInfoListExW(), SetupDiCreateDeviceInfoW(), SetupDiRestartDevices(), and StopDevice().

◆ GetFunctionPointer()

DWORD GetFunctionPointer ( IN PWSTR  InstallerName,
OUT HMODULE ModulePointer,
OUT PVOID FunctionPointer 
)

Definition at line 44 of file misc.c.

48 {
50  LPSTR FunctionNameA = NULL;
51  PWCHAR Comma;
52  DWORD rc;
53 
54  *ModulePointer = NULL;
55  *FunctionPointer = NULL;
56 
57  Comma = strchrW(InstallerName, ',');
58  if (!Comma)
59  {
61  goto cleanup;
62  }
63 
64  /* Load library */
65  *Comma = '\0';
66  hModule = LoadLibraryW(InstallerName);
67  *Comma = ',';
68  if (!hModule)
69  {
70  rc = GetLastError();
71  goto cleanup;
72  }
73 
74  /* Skip comma spaces */
75  while (*Comma == ',' || isspaceW(*Comma))
76  Comma++;
77 
78  /* W->A conversion for function name */
79  FunctionNameA = pSetupUnicodeToMultiByte(Comma, CP_ACP);
80  if (!FunctionNameA)
81  {
82  rc = GetLastError();
83  goto cleanup;
84  }
85 
86  /* Search function */
87  *FunctionPointer = GetProcAddress(hModule, FunctionNameA);
88  if (!*FunctionPointer)
89  {
90  rc = GetLastError();
91  goto cleanup;
92  }
93 
94  *ModulePointer = hModule;
95  rc = ERROR_SUCCESS;
96 
97 cleanup:
98  if (rc != ERROR_SUCCESS && hModule)
100  MyFree(FunctionNameA);
101  return rc;
102 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define CP_ACP
Definition: compat.h:109
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
uint16_t * PWCHAR
Definition: typedefs.h:56
char * LPSTR
Definition: xmlstorage.h:182
#define LoadLibraryW(x)
Definition: compat.h:606
#define FreeLibrary(x)
Definition: compat.h:607
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NULL
Definition: types.h:112
LPSTR WINAPI pSetupUnicodeToMultiByte(LPCWSTR lpUnicodeStr, UINT uCodePage)
Definition: misc.c:327
char * cleanup(char *str)
Definition: wpickclick.c:99
#define GetProcAddress(x, y)
Definition: compat.h:612
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
HMODULE hModule
Definition: animate.c:44

Referenced by SetupDiCallClassInstaller(), and SetupDiGetClassDevPropertySheetsW().

◆ GetStringField()

BOOL GetStringField ( PINFCONTEXT  context,
DWORD  index,
PWSTR value 
)

Definition at line 1700 of file install.c.

1701 {
1703  BOOL ret;
1704 
1706  context,
1707  index,
1708  NULL, 0,
1709  &RequiredSize);
1710  if (!ret)
1711  return FALSE;
1712  else if (RequiredSize == 0)
1713  {
1714  *value = NULL;
1715  return TRUE;
1716  }
1717 
1718  /* We got the needed size for the buffer */
1719  *value = MyMalloc(RequiredSize * sizeof(WCHAR));
1720  if (!*value)
1721  {
1723  return FALSE;
1724  }
1726  context,
1727  index,
1728  *value, RequiredSize, NULL);
1729  if (!ret)
1730  MyFree(*value);
1731 
1732  return ret;
1733 }
Definition: pdh_main.c:93
Definition: http.c:7251
#define TRUE
Definition: types.h:120
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint index
Definition: glext.h:6031
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
int ret
#define NULL
Definition: types.h:112
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:184

Referenced by profile_items_callback(), SetupDiInstallDeviceInterfaces(), and SetupInstallServicesFromInfSectionExW().

◆ IsUserAdmin()

BOOL WINAPI IsUserAdmin ( VOID  )

◆ MultiByteToUnicode()

LPWSTR WINAPI MultiByteToUnicode ( LPCSTR  lpMultiByteStr,
UINT  uCodePage 
)

◆ MyFree()

VOID WINAPI MyFree ( LPVOID  lpMem)

Definition at line 128 of file misc.c.

129 {
130  TRACE("%p\n", lpMem);
131  HeapFree(GetProcessHeap(), 0, lpMem);
132 }
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
#define HeapFree(x, y, z)
Definition: compat.h:594

◆ MyMalloc()

LPVOID WINAPI MyMalloc ( DWORD  dwSize)

Definition at line 147 of file misc.c.

148 {
149  TRACE("%lu\n", dwSize);
150  return HeapAlloc(GetProcessHeap(), 0, dwSize);
151 }
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

◆ MyRealloc()

LPVOID WINAPI MyRealloc ( LPVOID  lpSrc,
DWORD  dwSize 
)

Definition at line 172 of file misc.c.

173 {
174  TRACE("%p %lu\n", lpSrc, dwSize);
175 
176  if (lpSrc == NULL)
177  return HeapAlloc(GetProcessHeap(), 0, dwSize);
178 
179  return HeapReAlloc(GetProcessHeap(), 0, lpSrc, dwSize);
180 }
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define HeapReAlloc
Definition: compat.h:593
#define NULL
Definition: types.h:112
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

◆ PARSER_get_dest_dir()

WCHAR* PARSER_get_dest_dir ( INFCONTEXT context)

Definition at line 1116 of file parser.c.

1117 {
1118  const WCHAR *dir;
1119  WCHAR *ptr, *ret;
1120  INT dirid;
1121  unsigned int len1;
1122  DWORD len2;
1123 
1124  if (!SetupGetIntField( context, 1, &dirid )) return NULL;
1125  if (!(dir = get_dirid_subst( context->Inf, dirid, &len1 ))) return NULL;
1126  if (!SetupGetStringFieldW( context, 2, NULL, 0, &len2 )) len2 = 0;
1127  if (!(ret = HeapAlloc( GetProcessHeap(), 0, (len1+len2+1) * sizeof(WCHAR) ))) return NULL;
1128  memcpy( ret, dir, len1 * sizeof(WCHAR) );
1129  ptr = ret + len1;
1130  if (len2 && ptr > ret && ptr[-1] != '\\') *ptr++ = '\\';
1131  if (!SetupGetStringFieldW( context, 2, ptr, len2, NULL )) *ptr = 0;
1132  return ret;
1133 }
Definition: http.c:7251
BOOL WINAPI SetupGetStringFieldW(PINFCONTEXT context, DWORD index, PWSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1902
int32_t INT
Definition: typedefs.h:58
static const WCHAR * get_dirid_subst(const struct inf_file *file, int dirid, unsigned int *len)
Definition: parser.c:296
static PVOID ptr
Definition: dispmode.c:27
unsigned int dir
Definition: maze.c:112
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define NULL
Definition: types.h:112
BOOL WINAPI SetupGetIntField(PINFCONTEXT context, DWORD index, PINT result)
Definition: parser.c:1933

Referenced by get_destination_dir(), register_dlls_callback(), and SetupGetTargetPathW().

◆ PARSER_get_inf_filename()

const WCHAR* PARSER_get_inf_filename ( HINF  hinf)

Definition at line 1084 of file parser.c.

1085 {
1086  struct inf_file *file = hinf;
1087  return file->filename;
1088 }
Definition: inf.c:48
Definition: fci.c:126

Referenced by fill_inf_info().

◆ PARSER_get_src_root()

WCHAR* PARSER_get_src_root ( HINF  hinf)

Definition at line 1096 of file parser.c.

1097 {
1098  unsigned int len;
1099  const WCHAR *dir = get_inf_dir( hinf, &len );
1100  WCHAR *ret = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) );
1101  if (ret)
1102  {
1103  memcpy( ret, dir, len * sizeof(WCHAR) );
1104  ret[len] = 0;
1105  }
1106  return ret;
1107 }
unsigned int dir
Definition: maze.c:112
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR * get_inf_dir(const struct inf_file *file, unsigned int *len)
Definition: parser.c:168
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722

Referenced by get_src_file_info().

◆ pSetupStringFromGuid()

DWORD WINAPI pSetupStringFromGuid ( LPGUID  lpGUID,
PWSTR  pString,
DWORD  dwStringLen 
)

Definition at line 1775 of file misc.c.

1776 {
1778  RPC_WSTR rpcBuffer;
1779  WCHAR szBuffer[39];
1780 
1781  if (dwStringLen < 39)
1782  {
1784  }
1785 
1786  Status = UuidToStringW(lpGUID, &rpcBuffer);
1787  if (Status != RPC_S_OK)
1788  {
1789  return Status;
1790  }
1791 
1792  wcscpy(szBuffer, L"{");
1793  wcscat(szBuffer, rpcBuffer);
1794  wcscat(szBuffer, L"}");
1795 
1796  wcscpy(pString, szBuffer);
1797 
1798  RpcStringFreeW(&rpcBuffer);
1799  return NO_ERROR;
1800 }
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR *String)
Definition: rpcrt4_main.c:174
unsigned short * RPC_WSTR
Definition: rpcdce.h:46
#define NO_ERROR
Definition: dderror.h:5
long RPC_STATUS
Definition: rpc.h:52
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
RPC_STATUS WINAPI UuidToStringW(UUID *Uuid, RPC_WSTR *StringUuid)
Definition: rpcrt4_main.c:538
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
FxString * pString
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define RPC_S_OK
Definition: rpcnterr.h:22
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ QUEUE_callback_WtoA()

UINT CALLBACK QUEUE_callback_WtoA ( void context,
UINT  notification,
UINT_PTR  ,
UINT_PTR   
)

Definition at line 187 of file queue.c.

189 {
190  struct callback_WtoA_context *callback_ctx = context;
191  char buffer[MAX_PATH];
192  UINT ret;
193  UINT_PTR old_param2 = param2;
194 
195  switch(notification)
196  {
198  param2 = (UINT_PTR)&buffer;
199  /* fall through */
209  {
210  FILEPATHS_W *pathsW = (FILEPATHS_W *)param1;
211  FILEPATHS_A pathsA;
212 
213  pathsA.Source = strdupWtoA( pathsW->Source );
214  pathsA.Target = strdupWtoA( pathsW->Target );
215  pathsA.Win32Error = pathsW->Win32Error;
216  pathsA.Flags = pathsW->Flags;
217  ret = callback_ctx->orig_handler( callback_ctx->orig_context, notification,
218  (UINT_PTR)&pathsA, param2 );
219  HeapFree( GetProcessHeap(), 0, (void *)pathsA.Source );
220  HeapFree( GetProcessHeap(), 0, (void *)pathsA.Target );
221  }
223  MultiByteToWideChar( CP_ACP, 0, buffer, -1, (WCHAR *)old_param2, MAX_PATH );
224  break;
225 
228  {
231 
232  statusA.cbSize = sizeof(statusA);
233  statusA.FileName = strdupWtoA( statusW->FileName );
234  statusA.Win32Error = statusW->Win32Error;
235  statusA.FailureCode = statusW->FailureCode;
236  ret = callback_ctx->orig_handler( callback_ctx->orig_context, notification,
237  (UINT_PTR)&statusA, param2 );
238  HeapFree( GetProcessHeap(), 0, (LPSTR)statusA.FileName );
239  }
240  break;
241 
243  {
244  LPWSTR targetW = (LPWSTR)param1;
245  LPSTR target = strdupWtoA( targetW );
246 
247  ret = callback_ctx->orig_handler( callback_ctx->orig_context, notification,
248  (UINT_PTR)target, param2 );
249  HeapFree( GetProcessHeap(), 0, target );
250  }
251  break;
252 
254  FIXME("mapping for %d not implemented\n",notification);
259  default:
260  ret = callback_ctx->orig_handler( callback_ctx->orig_context, notification, param1, param2 );
261  break;
262  }
263  return ret;
264 }
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
PSP_FILE_CALLBACK_A orig_handler
#define SPFILENOTIFY_QUEUESCAN
Definition: fileqsup.h:40
#define SPFILENOTIFY_STARTREGISTRATION
Definition: setupapi.h:565
#define SPFILENOTIFY_STARTQUEUE
Definition: fileqsup.h:22
PCSTR Target
Definition: setupapi.h:742
#define CP_ACP
Definition: compat.h:109
static char * strdupWtoA(const WCHAR *str)
Definition: queue.c:77
#define SPFILENOTIFY_ENDCOPY
Definition: fileqsup.h:36
UINT Win32Error
Definition: fileqsup.h:62
#define SPFILENOTIFY_QUEUESCAN_EX
Definition: setupapi.h:564
#define SPFILENOTIFY_STARTRENAME
Definition: fileqsup.h:31
GLuint buffer
Definition: glext.h:5915
char * LPSTR
Definition: xmlstorage.h:182
#define SPFILENOTIFY_ENDRENAME
Definition: fileqsup.h:32
#define SPFILENOTIFY_STARTSUBQUEUE
Definition: fileqsup.h:24
#define SPFILENOTIFY_ENDSUBQUEUE
Definition: fileqsup.h:25
#define SPFILENOTIFY_RENAMEERROR
Definition: fileqsup.h:33
#define SPFILENOTIFY_ENDDELETE
Definition: fileqsup.h:28
#define FIXME(fmt,...)
Definition: debug.h:111
#define SPFILENOTIFY_STARTCOPY
Definition: fileqsup.h:35
#define SPFILENOTIFY_STARTDELETE
Definition: fileqsup.h:27
#define GetProcessHeap()
Definition: compat.h:595
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define SPFILENOTIFY_COPYERROR
Definition: fileqsup.h:37
_In_opt_ PVOID _In_ ULONG _In_ PVOID context
Definition: wdfdriver.h:113
int ret
PCWSTR Source
Definition: fileqsup.h:61
DWORD Flags
Definition: setupapi.h:745
PCSTR Source
Definition: setupapi.h:743
#define SPFILENOTIFY_ENDREGISTRATION
Definition: setupapi.h:566
unsigned int UINT
Definition: ndis.h:50
UINT Win32Error
Definition: setupapi.h:744
#define MultiByteToWideChar
Definition: compat.h:110
PCWSTR Target
Definition: fileqsup.h:60
#define SPFILENOTIFY_DELETEERROR
Definition: fileqsup.h:29
#define SPFILENOTIFY_ENDQUEUE
Definition: fileqsup.h:23
ULONG Flags
Definition: fileqsup.h:63
GLenum target
Definition: glext.h:7315
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:594
#define SPFILENOTIFY_NEEDMEDIA
Definition: fileqsup.h:39

Referenced by SetupCommitFileQueueA(), SetupInstallFileA(), SetupInstallFromInfSectionA(), and SetupScanFileQueueA().

◆ SETUP_CreateDevicesList()

LONG SETUP_CreateDevicesList ( IN OUT struct DeviceInfoSet list,
IN PCWSTR MachineName  OPTIONAL,
IN CONST GUID *Class  OPTIONAL,
IN PCWSTR Enumerator  OPTIONAL 
)

Definition at line 121 of file devclass.c.

126 {
127  PWCHAR Buffer = NULL;
128  DWORD BufferLength = 4096;
129  PCWSTR InstancePath;
130  struct DeviceInfo *deviceInfo;
131  WCHAR ClassGuidBuffer[MAX_GUID_STRING_LEN];
132  DWORD ClassGuidBufferSize;
133  GUID ClassGuid;
135  CONFIGRET cr;
136 
138  if (!Buffer)
140 
141  do
142  {
143  cr = CM_Get_Device_ID_List_ExW(Enumerator,
144  Buffer,
145  BufferLength / sizeof(WCHAR),
147  list->hMachine);
148  if (cr == CR_BUFFER_SMALL)
149  {
150  if (Buffer)
152  BufferLength *= 2;
154  if (!Buffer)
156  }
157  else if (cr != CR_SUCCESS)
158  {
159  TRACE("CM_Get_Device_ID_List_ExW() failed with status 0x%x\n", cr);
160  if (Buffer)
162  return GetErrorCodeFromCrCode(cr);
163  }
164  }
165  while (cr != CR_SUCCESS);
166 
167  for (InstancePath = Buffer; *InstancePath != UNICODE_NULL; InstancePath += wcslen(InstancePath) + 1)
168  {
169  /* Check that device really exists */
170  TRACE("Checking %S\n", InstancePath);
172  (DEVINSTID_W)InstancePath,
174  list->hMachine);
175  if (cr != CR_SUCCESS)
176  {
177  ERR("CM_Locate_DevNode_ExW('%S') failed with status 0x%x\n", InstancePath, cr);
178  continue;
179  }
180 
181  /* Retrieve GUID of this device */
182  ClassGuidBufferSize = sizeof(ClassGuidBuffer);
185  NULL,
186  ClassGuidBuffer,
187  &ClassGuidBufferSize,
188  0,
189  list->hMachine);
190  if (cr == CR_SUCCESS)
191  {
192  ClassGuidBuffer[MAX_GUID_STRING_LEN - 2] = '\0'; /* Replace the } by a NULL character */
193  if (UuidFromStringW(&ClassGuidBuffer[1], &ClassGuid) != RPC_S_OK)
194  {
195  /* Bad GUID, skip the entry */
196  ERR("Invalid ClassGUID '%S' for device %S\n", ClassGuidBuffer, InstancePath);
197  continue;
198  }
199  }
200  else
201  {
202  TRACE("Using default class GUID_NULL for device %S\n", InstancePath);
203  memcpy(&ClassGuid, &GUID_NULL, sizeof(GUID));
204  }
205 
206  if (Class && !IsEqualIID(&ClassGuid, Class))
207  {
208  TRACE("Skipping %S due to wrong class GUID\n", InstancePath);
209  continue;
210  }
211 
212  /* Good! Create a device info element */
213  if (!CreateDeviceInfo(list, InstancePath, &ClassGuid, &deviceInfo))
214  {
215  ERR("Failed to create info for %S\n", InstancePath);
217  return GetLastError();
218  }
219 
220  TRACE("Adding device %s to list\n", debugstr_w(InstancePath));
221  InsertTailList(&list->ListHead, &deviceInfo->ListEntry);
222  }
223 
225  return ERROR_SUCCESS;
226 }
const uint16_t * PCWSTR
Definition: typedefs.h:57
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
CONFIGRET WINAPI CM_Get_DevNode_Registry_Property_ExW(_In_ DEVINST dnDevInst, _In_ ULONG ulProperty, _Out_opt_ PULONG pulRegDataType, _Out_writes_bytes_opt_(*pulLength) PVOID Buffer, _Inout_ PULONG pulLength, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:3475
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CM_GETIDLIST_FILTER_NONE
Definition: cfgmgr32.h:654
DWORD GetErrorCodeFromCrCode(const IN CONFIGRET cr)
Definition: devinst.c:94
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
uint16_t * PWCHAR
Definition: typedefs.h:56
#define InsertTailList(ListHead, Entry)
_Null_terminated_ WCHAR * DEVINSTID_W
Definition: cfgmgr32.h:80
BOOL CreateDeviceInfo(IN struct DeviceInfoSet *list, IN LPCWSTR InstancePath, IN LPCGUID pClassGuid, OUT struct DeviceInfo **pDeviceInfo)
Definition: devinst.c:528
#define UNICODE_NULL
RPC_STATUS WINAPI UuidFromStringW(RPC_WSTR s, UUID *uuid)
Definition: rpcrt4_main.c:612
#define debugstr_w
Definition: kernel32.h:32
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define CM_DRP_CLASSGUID
Definition: cfgmgr32.h:684
Definition: bufpool.h:45
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_GUID_STRING_LEN
Definition: apphelp.c:29
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CM_Locate_DevNode_Ex
Definition: cfgmgr32.h:2405
DEVINST dnDevInst
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define GUID_NULL
Definition: ks.h:106
Definition: _list.h:228
#define ERR(fmt,...)
Definition: debug.h:110
CONFIGRET WINAPI CM_Get_Device_ID_List_ExW(_In_ PCWSTR pszFilter, _Out_writes_(BufferLen) PWCHAR Buffer, _In_ ULONG BufferLen, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:3884
DWORD DEVINST
Definition: cfgmgr32.h:76
#define NULL
Definition: types.h:112
#define CM_GETIDLIST_FILTER_ENUMERATOR
Definition: cfgmgr32.h:655
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
LIST_ENTRY ListEntry
#define CM_LOCATE_DEVNODE_NORMAL
Definition: cfgmgr32.h:760
#define HeapFree(x, y, z)
Definition: compat.h:594
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by SetupDiGetClassDevsExW().

◆ 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;
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  {
130  rc = ERROR_GEN_FAILURE;
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 */
158  READ_CONTROL,
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);
173  RegCloseKey(hKey);
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  {
180  rc = ERROR_GEN_FAILURE;
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  goto cleanup;
217  if (dwRegType != REG_SZ)
218  {
219  rc = ERROR_GEN_FAILURE;
220  goto cleanup;
221  }
222 
223  /* We have found a device */
224  /* Step 1. Create a device info element */
225  if (!CreateDeviceInfo(list, InstancePath, &ClassGuid, &deviceInfo))
226  {
227  rc = GetLastError();
228  goto cleanup;
229  }
230  TRACE("Adding device %s to list\n", debugstr_w(InstancePath));
231  InsertTailList(&list->ListHead, &deviceInfo->ListEntry);
232 
233  /* Step 2. Create an interface list for this element */
234  HeapFree(GetProcessHeap(), 0, pSymbolicLink);
235  pSymbolicLink = HeapAlloc(GetProcessHeap(), 0, dwLength + sizeof(WCHAR));
236  if (!pSymbolicLink)
237  {
239  goto cleanup;
240  }
241  rc = RegQueryValueExW(hReferenceKey, SymbolicLink, NULL, NULL, (LPBYTE)pSymbolicLink, &dwLength);
242  pSymbolicLink[dwLength / sizeof(WCHAR)] = '\0';
243  if (rc != ERROR_SUCCESS)
244  goto cleanup;
245  if (!CreateDeviceInterface(deviceInfo, pSymbolicLink, InterfaceGuid, &interfaceInfo))
246  {
247  rc = GetLastError();
248  goto cleanup;
249  }
250 
251  /* Step 3. Update flags */
252  if (KeyBuffer[1] == '\0')
253  interfaceInfo->Flags |= SPINT_DEFAULT;
254  rc = RegOpenKeyExW(hReferenceKey, Control, 0, KEY_QUERY_VALUE, &hControlKey);
255  if (rc != ERROR_SUCCESS)
256  {
257 #if 0
258  if (OnlyPresentInterfaces)
259  {
260  DestroyDeviceInterface(interfaceInfo);
261  continue;
262  }
263  else
264  interfaceInfo->Flags |= SPINT_REMOVED;
265 #endif
266  }
267  else
268  {
269  dwLength = sizeof(DWORD);
270  if (RegQueryValueExW(hControlKey, Linked, NULL, &dwRegType, (LPBYTE)&LinkedValue, &dwLength) == ERROR_SUCCESS
271  && dwRegType == REG_DWORD && LinkedValue)
272  interfaceInfo->Flags |= SPINT_ACTIVE;
273  RegCloseKey(hControlKey);
274  }
275 
276  TRACE("Adding interface %s to list\n", debugstr_w(pSymbolicLink));
277  InsertTailList(&deviceInfo->InterfaceListHead, &interfaceInfo->ListEntry);
278  }
279  }
280  rc = ERROR_SUCCESS;
281 
282 cleanup:
283  if (hReferenceKey != NULL)
284  RegCloseKey(hReferenceKey);
285  if (hDeviceInstanceKey != NULL)
286  RegCloseKey(hDeviceInstanceKey);
287  if (hInterfaceKey != INVALID_HANDLE_VALUE)
288  RegCloseKey(hInterfaceKey);
289  HeapFree(GetProcessHeap(), 0, InstancePath);
290  HeapFree(GetProcessHeap(), 0, pSymbolicLink);
291  return rc;
292 }
static BOOL CreateDeviceInterface(IN struct DeviceInfo *deviceInfo, IN LPCWSTR SymbolicLink, IN LPCGUID pInterfaceGuid, OUT struct DeviceInterface **pDeviceInterface)
Definition: interface.c:34
#define max(a, b)
Definition: svc.c:63
#define SPINT_ACTIVE
Definition: setupapi.h:577
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
LIST_ENTRY InterfaceListHead
#define REGSTR_PATH_SYSTEMENUM
Definition: regstr.h:483
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
static const WCHAR DeviceInstance[]
Definition: interface.c:28
#define InsertTailList(ListHead, Entry)
#define DWORD
Definition: nt_native.h:44
BOOL CreateDeviceInfo(IN struct DeviceInfoSet *list, IN LPCWSTR InstancePath, IN LPCGUID pClassGuid, OUT struct DeviceInfo **pDeviceInfo)
Definition: devinst.c:528
#define SPINT_DEFAULT
Definition: setupapi.h:578
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
RPC_STATUS WINAPI UuidFromStringW(RPC_WSTR s, UUID *uuid)
Definition: rpcrt4_main.c:612
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
_In_ WDF_WMI_PROVIDER_CONTROL Control
Definition: wdfwmi.h:166
BOOL DestroyDeviceInterface(struct DeviceInterface *deviceInterface)
Definition: interface.c:61
#define debugstr_guid
Definition: kernel32.h:35
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 TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
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
static DWORD DWORD * dwLength
Definition: fusion.c:85
#define MAX_GUID_STRING_LEN
Definition: apphelp.c:29
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
#define READ_CONTROL
Definition: nt_native.h:58
static const GUID InterfaceGuid
Definition: wlanapi.c:25
#define GUID_NULL
Definition: ks.h:106
Definition: _list.h:228
#define DIOCR_INTERFACE
Definition: setupapi.h:177
#define SPINT_REMOVED
Definition: setupapi.h:579
LIST_ENTRY ListEntry
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
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
LIST_ENTRY ListEntry
static const WCHAR Linked[]
Definition: interface.c:30
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
char * cleanup(char *str)
Definition: wpickclick.c:99
HKEY WINAPI SetupDiOpenClassRegKeyExW(const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:3658
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:2527
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
static const WCHAR ClassGUID[]
Definition: interface.c:26
#define REG_DWORD
Definition: sdbapi.c:596
#define HeapFree(x, y, z)
Definition: compat.h:594
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
static const WCHAR SymbolicLink[]
Definition: interface.c:31
#define RPC_S_OK
Definition: rpcnterr.h:22
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define REG_SZ
Definition: layer.c:22

Referenced by SetupDiGetClassDevsExW().

◆ SETUPDI_CreateDevKey()

HKEY SETUPDI_CreateDevKey ( HKEY  RootKey,
struct DeviceInfo devInfo,
REGSAM  samDesired 
)

Definition at line 5667 of file devinst.c.

5668 {
5669  HKEY enumKey, key = INVALID_HANDLE_VALUE;
5670  LONG l;
5671 
5673  if (!l)
5674  {
5675  l = RegCreateKeyExW(enumKey, devInfo->instanceId, 0, NULL, REG_OPTION_NON_VOLATILE, samDesired, NULL, &key, NULL);
5676  RegCloseKey(enumKey);
5677  }
5678  if (l)
5679  SetLastError(l);
5680  return key;
5681 }
static PMEMKEY RootKey
Definition: registry.c:55
#define REGSTR_PATH_SYSTEMENUM
Definition: regstr.h:483
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
r l[0]
Definition: byte_order.h:167
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define SetLastError(x)
Definition: compat.h:611
HKEY key
Definition: reg.c:42
#define NULL
Definition: types.h:112
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
Definition: path.c:41

Referenced by SetupDiChangeState(), and SetupDiCreateDevRegKeyW().

◆ SETUPDI_CreateDrvKey()

HKEY SETUPDI_CreateDrvKey ( HKEY  RootKey,
struct DeviceInfo devInfo,
UUID ClassGuid,
REGSAM  samDesired 
)

Definition at line 5683 of file devinst.c.

5684 {
5686  LPWSTR lpGuidString = NULL;
5687  LPWSTR DriverKey = NULL; /* {GUID}\Index */
5688  LPWSTR pDeviceInstance; /* Points into DriverKey, on the Index field */
5689  DWORD Index; /* Index used in the DriverKey name */
5690  DWORD dwSize;
5692  DWORD rc;
5693  HKEY hHWProfileKey = INVALID_HANDLE_VALUE;
5694  HKEY hEnumKey = NULL;
5695  HKEY hClassKey = NULL;
5696  HKEY hDeviceKey = INVALID_HANDLE_VALUE;
5697  HKEY hKey = NULL;
5698 
5699  /* Open device key, to read Driver value */
5700  hDeviceKey = SETUPDI_OpenDevKey(RootKey, devInfo, KEY_QUERY_VALUE | KEY_SET_VALUE);
5701  if (hDeviceKey == INVALID_HANDLE_VALUE)
5702  goto cleanup;
5703 
5705  if (rc != ERROR_SUCCESS)
5706  {
5707  SetLastError(rc);
5708  goto cleanup;
5709  }
5710 
5711  rc = RegQueryValueExW(hDeviceKey, REGSTR_VAL_DRIVER, NULL, NULL, NULL, &dwSize);
5712  if (rc != ERROR_SUCCESS)
5713  {
5714  /* Create a new driver key */
5715 
5716  if (UuidToStringW(ClassGuid, &lpGuidString) != RPC_S_OK)
5717  goto cleanup;
5718 
5719  /* The driver key is in \System\CurrentControlSet\Control\Class\{GUID}\Index */
5720  DriverKey = HeapAlloc(GetProcessHeap(), 0, (strlenW(lpGuidString) + 7) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
5721  if (!DriverKey)
5722  {
5724  goto cleanup;
5725  }
5726 
5727  DriverKey[0] = '{';
5728  strcpyW(&DriverKey[1], lpGuidString);
5729  pDeviceInstance = &DriverKey[strlenW(DriverKey)];
5730  *pDeviceInstance++ = '}';
5731  *pDeviceInstance++ = '\\';
5732 
5733  /* Try all values for Index between 0 and 9999 */
5734  Index = 0;
5735  while (Index <= 9999)
5736  {
5737  sprintfW(pDeviceInstance, InstanceKeyFormat, Index);
5739  DriverKey,
5740  0,
5741  NULL,
5743 #if _WIN32_WINNT >= 0x502
5744  KEY_READ | KEY_WRITE,
5745 #else
5747 #endif
5748  NULL,
5749  &hKey,
5750  &Disposition);
5751  if (rc != ERROR_SUCCESS)
5752  {
5753  SetLastError(rc);
5754  goto cleanup;
5755  }
5757  break;
5758  RegCloseKey(hKey);
5759  hKey = NULL;
5760  Index++;
5761  }
5762 
5763  if (Index > 9999)
5764  {
5765  /* Unable to create more than 9999 devices within the same class */
5767  goto cleanup;
5768  }
5769 
5770  /* Write the new Driver value */
5771  rc = RegSetValueExW(hDeviceKey, REGSTR_VAL_DRIVER, 0, REG_SZ, (const BYTE *)DriverKey, (strlenW(DriverKey) + 1) * sizeof(WCHAR));
5772  if (rc != ERROR_SUCCESS)
5773  {
5774  SetLastError(rc);
5775  goto cleanup;
5776  }
5777  }
5778  else
5779  {
5780  /* Open the existing driver key */
5781 
5782  DriverKey = HeapAlloc(GetProcessHeap(), 0, dwSize);
5783  if (!DriverKey)
5784  {
5786  goto cleanup;
5787  }
5788 
5789  rc = RegQueryValueExW(hDeviceKey, REGSTR_VAL_DRIVER, NULL, NULL, (LPBYTE)DriverKey, &dwSize);
5790  if (rc != ERROR_SUCCESS)
5791  {
5792  SetLastError(rc);
5793  goto cleanup;
5794  }
5795 
5797  DriverKey,
5798  0,
5799  NULL,
5801 #if _WIN32_WINNT >= 0x502
5802  KEY_READ | KEY_WRITE,
5803 #else
5805 #endif
5806  NULL,
5807  &hKey,
5808  &Disposition);
5809  if (rc != ERROR_SUCCESS)
5810  {
5811  SetLastError(rc);
5812  goto cleanup;
5813  }
5814  }
5815 
5816  key = hKey;
5817 
5818 cleanup:
5819  if (lpGuidString)
5820  RpcStringFreeW(&lpGuidString);
5821  HeapFree(GetProcessHeap(), 0, DriverKey);
5822  if (hHWProfileKey != INVALID_HANDLE_VALUE)
5823  RegCloseKey(hHWProfileKey);
5824  if (hEnumKey != NULL)
5826  if (hClassKey != NULL)
5828  if (hDeviceKey != INVALID_HANDLE_VALUE)
5829  RegCloseKey(hDeviceKey);
5830  if (hKey != NULL && hKey != key)
5831  RegCloseKey(hKey);
5832 
5833  TRACE("Returning 0x%p\n", hKey);
5834  return hKey;
5835 }
HKEY SETUPDI_OpenDevKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5837
#define _WIN32_WINNT
Definition: precomp.h:14
#define REGSTR_VAL_DRIVER
Definition: regstr.h:385
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static PMEMKEY RootKey
Definition: registry.c:55
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR *String)
Definition: rpcrt4_main.c:174
static const WCHAR InstanceKeyFormat[]
Definition: devinst.c:33
#define KEY_READ
Definition: nt_native.h:1023
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
static HANDLE hEnumKey
Definition: devinst.c:20
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:50
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define UNICODE_NULL
HKEY hClassKey
Definition: umpnpmgr.c:45
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
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
_In_ WDFCOLLECTION _In_ ULONG Index
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
RPC_STATUS WINAPI UuidToStringW(UUID *Uuid, RPC_WSTR *StringUuid)
Definition: rpcrt4_main.c:538
unsigned char BYTE
Definition: xxhash.c:193
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
FxAutoRegKey hKey
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define sprintfW
Definition: unicode.h:58
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define HeapFree(x, y, z)
Definition: compat.h:594
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: path.c:41
#define REGSTR_PATH_CLASS_NT
Definition: regstr.h:479
#define REG_SZ
Definition: layer.c:22

Referenced by SetupDiCreateDevRegKeyW(), SetupDiInstallDevice(), and SetupDiRegisterCoDeviceInstallers().

◆ SETUPDI_OpenDevKey()

HKEY SETUPDI_OpenDevKey ( HKEY  RootKey,
struct DeviceInfo devInfo,
REGSAM  samDesired 
)

Definition at line 5837 of file devinst.c.

5838 {
5839  HKEY enumKey, key = INVALID_HANDLE_VALUE;
5840  LONG l;
5841 
5843  if (!l)
5844  {
5845  l = RegOpenKeyExW(enumKey, devInfo->instanceId, 0, samDesired, &key);
5846  RegCloseKey(enumKey);
5847  }
5848  if (l)
5849  SetLastError(l);
5850  return key;
5851 }
static PMEMKEY RootKey
Definition: registry.c:55
#define REGSTR_PATH_SYSTEMENUM
Definition: regstr.h:483
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
r l[0]
Definition: byte_order.h:167
#define SetLastError(x)
Definition: compat.h:611
#define READ_CONTROL
Definition: nt_native.h:58
HKEY key
Definition: reg.c:42
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
Definition: path.c:41

Referenced by IntSetupDiSetDeviceRegistryPropertyAW(), SETUPDI_CreateDrvKey(), SETUPDI_OpenDrvKey(), SetupDiGetDeviceRegistryPropertyW(), SetupDiInstallDevice(), and SetupDiOpenDevRegKey().

◆ SETUPDI_OpenDrvKey()

HKEY SETUPDI_OpenDrvKey ( HKEY  RootKey,
struct DeviceInfo devInfo,
REGSAM  samDesired 
)

Definition at line 5853 of file devinst.c.

5854 {
5855  LPWSTR DriverKey = NULL;
5856  DWORD dwLength = 0;
5857  DWORD dwRegType;
5858  DWORD rc;
5859  HKEY hEnumKey = NULL;
5860  HKEY hKey = NULL;
5862 
5864  if (hKey == INVALID_HANDLE_VALUE)
5865  goto cleanup;
5866  /* Read the 'Driver' key */
5867  rc = RegQueryValueExW(hKey, REGSTR_VAL_DRIVER, NULL, &dwRegType, NULL, &dwLength);
5868  if (rc != ERROR_SUCCESS)
5869  {
5870  SetLastError(rc);
5871  goto cleanup;
5872  }
5873  else if (dwRegType != REG_SZ)
5874  {
5876  goto cleanup;
5877  }
5878  DriverKey = HeapAlloc(GetProcessHeap(), 0, dwLength);
5879  if (!DriverKey)
5880  {
5882  goto cleanup;
5883  }
5884  rc = RegQueryValueExW(hKey, REGSTR_VAL_DRIVER, NULL, &dwRegType, (LPBYTE)DriverKey, &dwLength);
5885  if (rc != ERROR_SUCCESS)
5886  {
5887  SetLastError(rc);
5888  goto cleanup;
5889  }
5890  RegCloseKey(hKey);
5891  hKey = NULL;
5892  /* Need to open the driver key */
5893  rc = RegOpenKeyExW(
5894  RootKey,
5896  0, /* Options */
5897  READ_CONTROL,
5898  &hEnumKey);
5899  if (rc != ERROR_SUCCESS)
5900  {
5901  SetLastError(rc);
5902  goto cleanup;
5903  }
5904  rc = RegOpenKeyExW(
5905  hEnumKey,
5906  DriverKey,
5907  0, /* Options */
5908  samDesired,
5909  &hKey);
5910  if (rc != ERROR_SUCCESS)
5911  {
5912  SetLastError(rc);
5913  goto cleanup;
5914  }
5915  key = hKey;
5916 
5917 cleanup:
5918  if (hEnumKey != NULL)
5920  if (hKey != NULL && hKey != key)
5921  RegCloseKey(hKey);
5922  if (DriverKey)
5923  HeapFree(GetProcessHeap(), 0, DriverKey);
5924  return key;
5925 }
HKEY SETUPDI_OpenDevKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5837
#define REGSTR_VAL_DRIVER
Definition: regstr.h:385
static PMEMKEY RootKey
Definition: registry.c:55
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
static HANDLE hEnumKey
Definition: devinst.c:20
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define GetProcessHeap()
Definition: compat.h:595
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
static DWORD DWORD * dwLength
Definition: fusion.c:85
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define READ_CONTROL
Definition: nt_native.h:58
HKEY key
Definition: reg.c:42
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:594
Definition: path.c:41
#define REGSTR_PATH_CLASS_NT
Definition: regstr.h:479
#define REG_SZ
Definition: layer.c:22

Referenced by SetupDiBuildDriverInfoList(), SetupDiCallClassInstaller(), SetupDiChangeState(), SetupDiGetClassDevPropertySheetsW(), SetupDiInstallDevice(), SetupDiOpenDevRegKey(), and SetupDiRegisterCoDeviceInstallers().

◆ strdupAtoW()

static WCHAR* strdupAtoW ( const char str)
inlinestatic

Definition at line 265 of file setupapi_private.h.

266 {
267  WCHAR *ret = NULL;
268  if (str)
269  {
270  DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
271  if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
272  MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
273  }
274  return ret;
275 }
#define CP_ACP
Definition: compat.h:109
const WCHAR * str
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110

◆ UnicodeToMultiByte()

LPSTR WINAPI UnicodeToMultiByte ( LPCWSTR  lpUnicodeStr,
UINT  uCodePage 
)

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( setupapi  )

Variable Documentation

◆ GlobalSetupFlags

◆ hInstance

HINSTANCE hInstance

Definition at line 20 of file charmap.c.

◆ OsVersionInfo

OSVERSIONINFOEXW OsVersionInfo

Definition at line 33 of file setupcab.c.

Referenced by DllMain(), and SetupDiGetActualSectionToInstallExW().