ReactOS  0.4.15-dev-5500-g82cf6c2
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:1670
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:5912
#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:736
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:752
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
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
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:736
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:752
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
WCHAR szData[ANYSIZE_ARRAY]
#define memset(x, y, z)
Definition: compat.h:39
#define HeapFree(x, y, z)
Definition: compat.h:735

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:736
#define InterlockedDecrement
Definition: armddk.h:52
#define HeapFree(x, y, z)
Definition: compat.h:735

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:736
#define HeapFree(x, y, z)
Definition: compat.h:735

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:736
VOID DereferenceInfFile(struct InfFileDetails *infFile)
Definition: driver.c:45
#define HeapFree(x, y, z)
Definition: compat.h:735

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:1040
#define FreeLibrary(x)
Definition: compat.h:748
#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:303
#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:1040
uint16_t * PWCHAR
Definition: typedefs.h:56
char * LPSTR
Definition: xmlstorage.h:182
#define LoadLibraryW(x)
Definition: compat.h:747
#define FreeLibrary(x)
Definition: compat.h:748
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:753
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:752
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:736
#define HeapFree(x, y, z)
Definition: compat.h:735

◆ 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:736
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:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define HeapReAlloc
Definition: compat.h:734
#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:736
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:736
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
#define L(x)
Definition: ntvdm.h:50
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)
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:570
#define SPFILENOTIFY_STARTQUEUE
Definition: fileqsup.h:22
PCSTR Target
Definition: setupapi.h:747
#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:569
#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:736
__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:750
PCSTR Source
Definition: setupapi.h:748
#define SPFILENOTIFY_ENDREGISTRATION
Definition: setupapi.h:571
unsigned int UINT
Definition: ndis.h:50
UINT Win32Error
Definition: setupapi.h:749
#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:735
#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:3480
#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:1040
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:736
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:3889
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:735
#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:582
#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:731
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1291
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:583
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:736
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:4120
__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:584
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:3356
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:3662
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:735
#define RegCloseKey(hKey)
Definition: registry.h:47
#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 5671 of file devinst.c.

5672 {
5673  HKEY enumKey, key = INVALID_HANDLE_VALUE;
5674  LONG l;
5675 
5677  if (!l)
5678  {
5679  l = RegCreateKeyExW(enumKey, devInfo->instanceId, 0, NULL, REG_OPTION_NON_VOLATILE, samDesired, NULL, &key, NULL);
5680  RegCloseKey(enumKey);
5681  }
5682  if (l)
5683  SetLastError(l);
5684  return key;
5685 }
static PMEMKEY RootKey
Definition: registry.c:55
#define REGSTR_PATH_SYSTEMENUM
Definition: regstr.h:483
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
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 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:752
HKEY key
Definition: reg.c:28
#define NULL
Definition: types.h:112
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define RegCloseKey(hKey)
Definition: registry.h:47
Definition: copy.c:22

Referenced by SetupDiChangeState(), and SetupDiCreateDevRegKeyW().

◆ SETUPDI_CreateDrvKey()

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

Definition at line 5687 of file devinst.c.

5688 {
5690  LPWSTR lpGuidString = NULL;
5691  LPWSTR DriverKey = NULL; /* {GUID}\Index */
5692  LPWSTR pDeviceInstance; /* Points into DriverKey, on the Index field */
5693  DWORD Index; /* Index used in the DriverKey name */
5694  DWORD dwSize;
5696  DWORD rc;
5697  HKEY hHWProfileKey = INVALID_HANDLE_VALUE;
5698  HKEY hEnumKey = NULL;
5699  HKEY hClassKey = NULL;
5700  HKEY hDeviceKey = INVALID_HANDLE_VALUE;
5701  HKEY hKey = NULL;
5702 
5703  /* Open device key, to read Driver value */
5704  hDeviceKey = SETUPDI_OpenDevKey(RootKey, devInfo, KEY_QUERY_VALUE | KEY_SET_VALUE);
5705  if (hDeviceKey == INVALID_HANDLE_VALUE)
5706  goto cleanup;
5707 
5709  if (rc != ERROR_SUCCESS)
5710  {
5711  SetLastError(rc);
5712  goto cleanup;
5713  }
5714 
5715  rc = RegQueryValueExW(hDeviceKey, REGSTR_VAL_DRIVER, NULL, NULL, NULL, &dwSize);
5716  if (rc != ERROR_SUCCESS)
5717  {
5718  /* Create a new driver key */
5719 
5720  if (UuidToStringW(ClassGuid, &lpGuidString) != RPC_S_OK)
5721  goto cleanup;
5722 
5723  /* The driver key is in \System\CurrentControlSet\Control\Class\{GUID}\Index */
5724  DriverKey = HeapAlloc(GetProcessHeap(), 0, (strlenW(lpGuidString) + 7) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
5725  if (!DriverKey)
5726  {
5728  goto cleanup;
5729  }
5730 
5731  DriverKey[0] = '{';
5732  strcpyW(&DriverKey[1], lpGuidString);
5733  pDeviceInstance = &DriverKey[strlenW(DriverKey)];
5734  *pDeviceInstance++ = '}';
5735  *pDeviceInstance++ = '\\';
5736 
5737  /* Try all values for Index between 0 and 9999 */
5738  Index = 0;
5739  while (Index <= 9999)
5740  {
5741  sprintfW(pDeviceInstance, InstanceKeyFormat, Index);
5743  DriverKey,
5744  0,
5745  NULL,
5747 #if _WIN32_WINNT >= 0x502
5748  KEY_READ | KEY_WRITE,
5749 #else
5751 #endif
5752  NULL,
5753  &hKey,
5754  &Disposition);
5755  if (rc != ERROR_SUCCESS)
5756  {
5757  SetLastError(rc);
5758  goto cleanup;
5759  }
5761  break;
5762  RegCloseKey(hKey);
5763  hKey = NULL;
5764  Index++;
5765  }
5766 
5767  if (Index > 9999)
5768  {
5769  /* Unable to create more than 9999 devices within the same class */
5771  goto cleanup;
5772  }
5773 
5774  /* Write the new Driver value */
5775  rc = RegSetValueExW(hDeviceKey, REGSTR_VAL_DRIVER, 0, REG_SZ, (const BYTE *)DriverKey, (strlenW(DriverKey) + 1) * sizeof(WCHAR));
5776  if (rc != ERROR_SUCCESS)
5777  {
5778  SetLastError(rc);
5779  goto cleanup;
5780  }
5781  }
5782  else
5783  {
5784  /* Open the existing driver key */
5785 
5786  DriverKey = HeapAlloc(GetProcessHeap(), 0, dwSize);
5787  if (!DriverKey)
5788  {
5790  goto cleanup;
5791  }
5792 
5793  rc = RegQueryValueExW(hDeviceKey, REGSTR_VAL_DRIVER, NULL, NULL, (LPBYTE)DriverKey, &dwSize);
5794  if (rc != ERROR_SUCCESS)
5795  {
5796  SetLastError(rc);
5797  goto cleanup;
5798  }
5799 
5801  DriverKey,
5802  0,
5803  NULL,
5805 #if _WIN32_WINNT >= 0x502
5806  KEY_READ | KEY_WRITE,
5807 #else
5809 #endif
5810  NULL,
5811  &hKey,
5812  &Disposition);
5813  if (rc != ERROR_SUCCESS)
5814  {
5815  SetLastError(rc);
5816  goto cleanup;
5817  }
5818  }
5819 
5820  key = hKey;
5821 
5822 cleanup:
5823  if (lpGuidString)
5824  RpcStringFreeW(&lpGuidString);
5825  HeapFree(GetProcessHeap(), 0, DriverKey);
5826  if (hHWProfileKey != INVALID_HANDLE_VALUE)
5827  RegCloseKey(hHWProfileKey);
5828  if (hEnumKey != NULL)
5830  if (hClassKey != NULL)
5832  if (hDeviceKey != INVALID_HANDLE_VALUE)
5833  RegCloseKey(hDeviceKey);
5834  if (hKey != NULL && hKey != key)
5835  RegCloseKey(hKey);
5836 
5837  TRACE("Returning 0x%p\n", hKey);
5838  return hKey;
5839 }
HKEY SETUPDI_OpenDevKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5841
#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:731
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
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:4899
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:736
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:4120
__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:752
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:3356
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:735
#define RegCloseKey(hKey)
Definition: registry.h:47
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: copy.c:22
#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 5841 of file devinst.c.

5842 {
5843  HKEY enumKey, key = INVALID_HANDLE_VALUE;
5844  LONG l;
5845 
5847  if (!l)
5848  {
5849  l = RegOpenKeyExW(enumKey, devInfo->instanceId, 0, samDesired, &key);
5850  RegCloseKey(enumKey);
5851  }
5852  if (l)
5853  SetLastError(l);
5854  return key;
5855 }
static PMEMKEY RootKey
Definition: registry.c:55
#define REGSTR_PATH_SYSTEMENUM
Definition: regstr.h:483
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
long LONG
Definition: pedump.c:60
r l[0]
Definition: byte_order.h:167
#define SetLastError(x)
Definition: compat.h:752
#define READ_CONTROL
Definition: nt_native.h:58
HKEY key
Definition: reg.c:28
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define RegCloseKey(hKey)
Definition: registry.h:47
Definition: copy.c:22

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 5857 of file devinst.c.

5858 {
5859  LPWSTR DriverKey = NULL;
5860  DWORD dwLength = 0;
5861  DWORD dwRegType;
5862  DWORD rc;
5863  HKEY hEnumKey = NULL;
5864  HKEY hKey = NULL;
5866 
5868  if (hKey == INVALID_HANDLE_VALUE)
5869  goto cleanup;
5870  /* Read the 'Driver' key */
5871  rc = RegQueryValueExW(hKey, REGSTR_VAL_DRIVER, NULL, &dwRegType, NULL, &dwLength);
5872  if (rc != ERROR_SUCCESS)
5873  {
5874  SetLastError(rc);
5875  goto cleanup;
5876  }
5877  else if (dwRegType != REG_SZ)
5878  {
5880  goto cleanup;
5881  }
5882  DriverKey = HeapAlloc(GetProcessHeap(), 0, dwLength);
5883  if (!DriverKey)
5884  {
5886  goto cleanup;
5887  }
5888  rc = RegQueryValueExW(hKey, REGSTR_VAL_DRIVER, NULL, &dwRegType, (LPBYTE)DriverKey, &dwLength);
5889  if (rc != ERROR_SUCCESS)
5890  {
5891  SetLastError(rc);
5892  goto cleanup;
5893  }
5894  RegCloseKey(hKey);
5895  hKey = NULL;
5896  /* Need to open the driver key */
5897  rc = RegOpenKeyExW(
5898  RootKey,
5900  0, /* Options */
5901  READ_CONTROL,
5902  &hEnumKey);
5903  if (rc != ERROR_SUCCESS)
5904  {
5905  SetLastError(rc);
5906  goto cleanup;
5907  }
5908  rc = RegOpenKeyExW(
5909  hEnumKey,
5910  DriverKey,
5911  0, /* Options */
5912  samDesired,
5913  &hKey);
5914  if (rc != ERROR_SUCCESS)
5915  {
5916  SetLastError(rc);
5917  goto cleanup;
5918  }
5919  key = hKey;
5920 
5921 cleanup:
5922  if (hEnumKey != NULL)
5924  if (hKey != NULL && hKey != key)
5925  RegCloseKey(hKey);
5926  if (DriverKey)
5927  HeapFree(GetProcessHeap(), 0, DriverKey);
5928  return key;
5929 }
HKEY SETUPDI_OpenDevKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5841
#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:731
static HANDLE hEnumKey
Definition: devinst.c:20
unsigned char * LPBYTE
Definition: typedefs.h:53
#define GetProcessHeap()
Definition: compat.h:736
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:4120
static DWORD DWORD * dwLength
Definition: fusion.c:85
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:752
#define READ_CONTROL
Definition: nt_native.h:58
HKEY key
Definition: reg.c:28
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:3356
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:735
#define RegCloseKey(hKey)
Definition: registry.h:47
Definition: copy.c:22
#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:736
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 19 of file charmap.c.

◆ OsVersionInfo

OSVERSIONINFOEXW OsVersionInfo

Definition at line 33 of file setupcab.c.

Referenced by DllMain(), and SetupDiGetActualSectionToInstallExW().