ReactOS  0.4.13-dev-464-g6b95727
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)
 
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 380 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 526 of file devinst.c.

531 {
532  DWORD size;
533  CONFIGRET cr;
534  struct DeviceInfo *deviceInfo;
535 
536  *pDeviceInfo = NULL;
537 
538  size = FIELD_OFFSET(struct DeviceInfo, Data) + (strlenW(InstancePath) + 1) * sizeof(WCHAR);
539  deviceInfo = HeapAlloc(GetProcessHeap(), 0, size);
540  if (!deviceInfo)
541  {
543  return FALSE;
544  }
545  ZeroMemory(deviceInfo, size);
546 
547  cr = CM_Locate_DevNode_ExW(&deviceInfo->dnDevInst, (DEVINSTID_W)InstancePath, CM_LOCATE_DEVNODE_PHANTOM, list->hMachine);
548  if (cr != CR_SUCCESS)
549  {
551  return FALSE;
552  }
553 
554  deviceInfo->set = list;
555  deviceInfo->InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
556  strcpyW(deviceInfo->Data, InstancePath);
557  deviceInfo->instanceId = deviceInfo->Data;
558  deviceInfo->UniqueId = strrchrW(deviceInfo->Data, '\\');
559  deviceInfo->DeviceDescription = NULL;
560  memcpy(&deviceInfo->ClassGuid, pClassGuid, sizeof(GUID));
561  deviceInfo->CreationFlags = 0;
562  InitializeListHead(&deviceInfo->DriverListHead);
564 
565  *pDeviceInfo = deviceInfo;
566  return TRUE;
567 }
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
LIST_ENTRY InterfaceListHead
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ZeroMemory
Definition: winbase.h:1635
SP_DEVINSTALL_PARAMS_W InstallParams
_Null_terminated_ WCHAR * DEVINSTID_W
Definition: cfgmgr32.h:80
static DWORD GetErrorCodeFromCrCode(const IN CONFIGRET cr)
Definition: devinst.c:92
CONFIGRET WINAPI CM_Locate_DevNode_ExW(_Out_ PDEVINST pdnDevInst, _In_opt_ DEVINSTID_W pDeviceID, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:5686
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
PCWSTR DeviceDescription
WCHAR Data[ANYSIZE_ARRAY]
struct DeviceInfoSet * set
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
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:409
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:254
#define list
Definition: rosglue.h:35
#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_CreateDevicesListFromEnumerator(), 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:391
uint16_t * PWCHAR
Definition: typedefs.h:54
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
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:409
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:254
int details
Definition: msacm.c:1353
#define memset(x, y, z)
Definition: compat.h:39
#define HeapFree(x, y, z)
Definition: compat.h:394

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

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

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

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:111
#define DIRID_NULL
Definition: setupapi.h:185
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
smooth NULL
Definition: ftsmooth.c:416
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
#define MIN_CSIDL_DIRID
Definition: dirid.c:24
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:1059
smooth NULL
Definition: ftsmooth.c:416
#define FreeLibrary(x)
Definition: compat.h:405

Referenced by SetupDiCallClassInstaller().

◆ 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:91
#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:99
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
uint16_t * PWCHAR
Definition: typedefs.h:54
char * LPSTR
Definition: xmlstorage.h:182
#define LoadLibraryW(x)
Definition: compat.h:404
smooth NULL
Definition: ftsmooth.c:416
#define FreeLibrary(x)
Definition: compat.h:405
unsigned long DWORD
Definition: ntddk_ex.h:95
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:410
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 1696 of file install.c.

1697 {
1699  BOOL ret;
1700 
1702  context,
1703  index,
1704  NULL, 0,
1705  &RequiredSize);
1706  if (!ret)
1707  return FALSE;
1708  else if (RequiredSize == 0)
1709  {
1710  *value = NULL;
1711  return TRUE;
1712  }
1713 
1714  /* We got the needed size for the buffer */
1715  *value = MyMalloc(RequiredSize * sizeof(WCHAR));
1716  if (!*value)
1717  {
1719  return FALSE;
1720  }
1722  context,
1723  index,
1724  *value, RequiredSize, NULL);
1725  if (!ret)
1726  MyFree(*value);
1727 
1728  return ret;
1729 }
#define TRUE
Definition: types.h:120
Definition: http.c:6587
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
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:395
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ 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:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

◆ 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 }
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define HeapReAlloc
Definition: compat.h:393
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

◆ 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:6587
BOOL WINAPI SetupGetStringFieldW(PINFCONTEXT context, DWORD index, PWSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1902
int32_t INT
Definition: typedefs.h:56
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
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
#define GetProcessHeap()
Definition: compat.h:395
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
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:395
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:177
unsigned short * RPC_WSTR
Definition: rpcdce.h:46
#define NO_ERROR
Definition: dderror.h:5
long RPC_STATUS
Definition: rpc.h:52
__wchar_t WCHAR
Definition: xmlstorage.h:180
RPC_STATUS WINAPI UuidToStringW(UUID *Uuid, RPC_WSTR *StringUuid)
Definition: rpcrt4_main.c:541
_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
Status
Definition: gdiplustypes.h:24
_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
Definition: http.c:6587
#define SPFILENOTIFY_STARTQUEUE
Definition: fileqsup.h:22
PCSTR Target
Definition: setupapi.h:742
#define CP_ACP
Definition: compat.h:99
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:110
#define SPFILENOTIFY_STARTCOPY
Definition: fileqsup.h:35
#define SPFILENOTIFY_STARTDELETE
Definition: fileqsup.h:27
#define GetProcessHeap()
Definition: compat.h:395
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define SPFILENOTIFY_COPYERROR
Definition: fileqsup.h:37
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:100
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:394
#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 254 of file devclass.c.

259 {
261  HKEY hEnumKey = NULL;
262  HKEY hEnumeratorKey = NULL;
263  WCHAR KeyBuffer[MAX_PATH];
264  DWORD i;
265  DWORD dwLength;
266  DWORD rc;
267 
268  if (Class && IsEqualIID(Class, &GUID_NULL))
269  Class = NULL;
270 
271  /* Open Enum key (if applicable) */
272  if (MachineName != NULL)
273  {
275  if (rc != ERROR_SUCCESS)
276  goto cleanup;
277  }
278 
279  rc = RegOpenKeyExW(
280  HKLM,
282  0,
284  &hEnumKey);
285  if (rc != ERROR_SUCCESS)
286  goto cleanup;
287 
288  /* If enumerator is provided, call directly SETUP_CreateDevicesListFromEnumerator.
289  * Else, enumerate all enumerators and call SETUP_CreateDevicesListFromEnumerator
290  * for each one.
291  */
292  if (Enumerator)
293  {
294  rc = RegOpenKeyExW(
295  hEnumKey,
296  Enumerator,
297  0,
299  &hEnumeratorKey);
300  if (rc != ERROR_SUCCESS)
301  {
302  if (rc == ERROR_FILE_NOT_FOUND)
303  rc = ERROR_INVALID_DATA;
304  goto cleanup;
305  }
306  rc = SETUP_CreateDevicesListFromEnumerator(list, Class, Enumerator, hEnumeratorKey);
307  }
308  else
309  {
310  /* Enumerate enumerators */
311  i = 0;
312  while (TRUE)
313  {
314  dwLength = sizeof(KeyBuffer) / sizeof(KeyBuffer[0]);
315  rc = RegEnumKeyExW(hEnumKey, i, KeyBuffer, &dwLength, NULL, NULL, NULL, NULL);
316  if (rc == ERROR_NO_MORE_ITEMS)
317  break;
318  else if (rc != ERROR_SUCCESS)
319  goto cleanup;
320  i++;
321 
322  /* Open sub key */
323  if (hEnumeratorKey != NULL)
324  RegCloseKey(hEnumeratorKey);
325  rc = RegOpenKeyExW(hEnumKey, KeyBuffer, 0, KEY_ENUMERATE_SUB_KEYS, &hEnumeratorKey);
326  if (rc != ERROR_SUCCESS)
327  goto cleanup;
328 
329  /* Call SETUP_CreateDevicesListFromEnumerator */
330  rc = SETUP_CreateDevicesListFromEnumerator(list, Class, KeyBuffer, hEnumeratorKey);
331  if (rc != ERROR_SUCCESS)
332  goto cleanup;
333  }
334  rc = ERROR_SUCCESS;
335  }
336 
337 cleanup:
338  if (HKLM != HKEY_LOCAL_MACHINE)
339  RegCloseKey(HKLM);
340  if (hEnumKey != NULL)
342  if (hEnumeratorKey != NULL)
343  RegCloseKey(hEnumeratorKey);
344  return rc;
345 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
#define REGSTR_PATH_SYSTEMENUM
Definition: regstr.h:483
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
LONG WINAPI RegConnectRegistryW(LPCWSTR lpMachineName, HKEY hKey, PHKEY phkResult)
Definition: reg.c:869
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static const WCHAR HKLM[]
Definition: reginf.c:58
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:83
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
#define GUID_NULL
Definition: ks.h:106
Definition: _list.h:228
#define ERROR_INVALID_DATA
Definition: winerror.h:116
static LONG SETUP_CreateDevicesListFromEnumerator(IN OUT struct DeviceInfoSet *list, IN CONST GUID *pClassGuid OPTIONAL, IN LPCWSTR Enumerator, IN HKEY hEnumeratorKey)
Definition: devclass.c:134
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
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 IsEqualIID(riid1, riid2)
Definition: guiddef.h:90
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019

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;
89  GUID ClassGuid;
90  struct DeviceInfo *deviceInfo;
91 
92  hInterfaceKey = INVALID_HANDLE_VALUE;
93  hDeviceInstanceKey = NULL;
94  hReferenceKey = NULL;
95 
96  /* Open registry key related to this interface */
98  if (hInterfaceKey == INVALID_HANDLE_VALUE)
99  {
100  /* Key doesn't exist. Let's keep it empty */
101  rc = ERROR_SUCCESS;
102  goto cleanup;
103  }
104 
105  /* Enumerate sub keys of hInterfaceKey */
106  i = 0;
107  while (TRUE)
108  {
109  dwLength = sizeof(KeyBuffer) / sizeof(KeyBuffer[0]);
110  rc = RegEnumKeyExW(hInterfaceKey, i, KeyBuffer, &dwLength, NULL, NULL, NULL, NULL);
111  if (rc == ERROR_NO_MORE_ITEMS)
112  break;
113  if (rc != ERROR_SUCCESS)
114  goto cleanup;
115  i++;
116 
117  /* Open sub key */
118  if (hDeviceInstanceKey != NULL)
119  RegCloseKey(hDeviceInstanceKey);
120  rc = RegOpenKeyExW(hInterfaceKey, KeyBuffer, 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &hDeviceInstanceKey);
121  if (rc != ERROR_SUCCESS)
122  goto cleanup;
123 
124  /* Read DeviceInstance */
125  rc = RegQueryValueExW(hDeviceInstanceKey, DeviceInstance, NULL, &dwRegType, NULL, &dwInstancePathLength);
126  if (rc != ERROR_SUCCESS)
127  goto cleanup;
128  if (dwRegType != REG_SZ)
129  {
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 TRUE
Definition: types.h:120
#define SPINT_ACTIVE
Definition: setupapi.h:577
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
uint16_t * PWSTR
Definition: typedefs.h:54
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:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
_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:526
#define SPINT_DEFAULT
Definition: setupapi.h:578
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
RPC_STATUS WINAPI UuidFromStringW(RPC_WSTR s, UUID *uuid)
Definition: rpcrt4_main.c:615
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
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:395
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:83
#define MAX_GUID_STRING_LEN
Definition: apphelp.c:29
#define MAX_PATH
Definition: compat.h:26
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
static const WCHAR Control[]
Definition: interface.c:27
#define SPINT_REMOVED
Definition: setupapi.h:579
LIST_ENTRY ListEntry
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
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:3667
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:394
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90
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 5656 of file devinst.c.

5657 {
5658  HKEY enumKey, key = INVALID_HANDLE_VALUE;
5659  LONG l;
5660 
5662  if (!l)
5663  {
5664  l = RegCreateKeyExW(enumKey, devInfo->instanceId, 0, NULL, REG_OPTION_NON_VOLATILE, samDesired, NULL, &key, NULL);
5665  RegCloseKey(enumKey);
5666  }
5667  if (l)
5668  SetLastError(l);
5669  return key;
5670 }
static PMEMKEY RootKey
Definition: registry.c:55
#define REGSTR_PATH_SYSTEMENUM
Definition: regstr.h:483
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
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
smooth NULL
Definition: ftsmooth.c:416
r l[0]
Definition: byte_order.h:167
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define SetLastError(x)
Definition: compat.h:409
HKEY key
Definition: reg.c:42
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
Definition: path.c:42

Referenced by SetupDiChangeState(), and SetupDiCreateDevRegKeyW().

◆ SETUPDI_CreateDrvKey()

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

Definition at line 5672 of file devinst.c.

5673 {
5675  LPWSTR lpGuidString = NULL;
5676  LPWSTR DriverKey = NULL; /* {GUID}\Index */
5677  LPWSTR pDeviceInstance; /* Points into DriverKey, on the Index field */
5678  DWORD Index; /* Index used in the DriverKey name */
5679  DWORD dwSize;
5681  DWORD rc;
5682  HKEY hHWProfileKey = INVALID_HANDLE_VALUE;
5683  HKEY hEnumKey = NULL;
5684  HKEY hClassKey = NULL;
5685  HKEY hDeviceKey = INVALID_HANDLE_VALUE;
5686  HKEY hKey = NULL;
5687 
5688  /* Open device key, to read Driver value */
5689  hDeviceKey = SETUPDI_OpenDevKey(RootKey, devInfo, KEY_QUERY_VALUE | KEY_SET_VALUE);
5690  if (hDeviceKey == INVALID_HANDLE_VALUE)
5691  goto cleanup;
5692 
5694  if (rc != ERROR_SUCCESS)
5695  {
5696  SetLastError(rc);
5697  goto cleanup;
5698  }
5699 
5700  rc = RegQueryValueExW(hDeviceKey, REGSTR_VAL_DRIVER, NULL, NULL, NULL, &dwSize);
5701  if (rc != ERROR_SUCCESS)
5702  {
5703  /* Create a new driver key */
5704 
5705  if (UuidToStringW(ClassGuid, &lpGuidString) != RPC_S_OK)
5706  goto cleanup;
5707 
5708  /* The driver key is in \System\CurrentControlSet\Control\Class\{GUID}\Index */
5709  DriverKey = HeapAlloc(GetProcessHeap(), 0, (strlenW(lpGuidString) + 7) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
5710  if (!DriverKey)
5711  {
5713  goto cleanup;
5714  }
5715 
5716  DriverKey[0] = '{';
5717  strcpyW(&DriverKey[1], lpGuidString);
5718  pDeviceInstance = &DriverKey[strlenW(DriverKey)];
5719  *pDeviceInstance++ = '}';
5720  *pDeviceInstance++ = '\\';
5721 
5722  /* Try all values for Index between 0 and 9999 */
5723  Index = 0;
5724  while (Index <= 9999)
5725  {
5726  sprintfW(pDeviceInstance, InstanceKeyFormat, Index);
5728  DriverKey,
5729  0,
5730  NULL,
5732 #if _WIN32_WINNT >= 0x502
5733  KEY_READ | KEY_WRITE,
5734 #else
5736 #endif
5737  NULL,
5738  &hKey,
5739  &Disposition);
5740  if (rc != ERROR_SUCCESS)
5741  {
5742  SetLastError(rc);
5743  goto cleanup;
5744  }
5746  break;
5747  RegCloseKey(hKey);
5748  hKey = NULL;
5749  Index++;
5750  }
5751 
5752  if (Index > 9999)
5753  {
5754  /* Unable to create more than 9999 devices within the same class */
5756  goto cleanup;
5757  }
5758 
5759  /* Write the new Driver value */
5760  rc = RegSetValueExW(hDeviceKey, REGSTR_VAL_DRIVER, 0, REG_SZ, (const BYTE *)DriverKey, (strlenW(DriverKey) + 1) * sizeof(WCHAR));
5761  if (rc != ERROR_SUCCESS)
5762  {
5763  SetLastError(rc);
5764  goto cleanup;
5765  }
5766  }
5767  else
5768  {
5769  /* Open the existing driver key */
5770 
5771  DriverKey = HeapAlloc(GetProcessHeap(), 0, dwSize);
5772  if (!DriverKey)
5773  {
5775  goto cleanup;
5776  }
5777 
5778  rc = RegQueryValueExW(hDeviceKey, REGSTR_VAL_DRIVER, NULL, NULL, (LPBYTE)DriverKey, &dwSize);
5779  if (rc != ERROR_SUCCESS)
5780  {
5781  SetLastError(rc);
5782  goto cleanup;
5783  }
5784 
5786  DriverKey,
5787  0,
5788  NULL,
5790 #if _WIN32_WINNT >= 0x502
5791  KEY_READ | KEY_WRITE,
5792 #else
5794 #endif
5795  NULL,
5796  &hKey,
5797  &Disposition);
5798  if (rc != ERROR_SUCCESS)
5799  {
5800  SetLastError(rc);
5801  goto cleanup;
5802  }
5803  }
5804 
5805  key = hKey;
5806 
5807 cleanup:
5808  if (lpGuidString)
5809  RpcStringFreeW(&lpGuidString);
5810  HeapFree(GetProcessHeap(), 0, DriverKey);
5811  if (hHWProfileKey != INVALID_HANDLE_VALUE)
5812  RegCloseKey(hHWProfileKey);
5813  if (hEnumKey != NULL)
5815  if (hClassKey != NULL)
5817  if (hDeviceKey != INVALID_HANDLE_VALUE)
5818  RegCloseKey(hDeviceKey);
5819  if (hKey != NULL && hKey != key)
5820  RegCloseKey(hKey);
5821 
5822  TRACE("Returning 0x%p\n", hKey);
5823  return hKey;
5824 }
HKEY SETUPDI_OpenDevKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5826
#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:177
static const WCHAR InstanceKeyFormat[]
Definition: devinst.c:31
#define KEY_READ
Definition: nt_native.h:1023
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
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:52
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
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:395
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 const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
RPC_STATUS WINAPI UuidToStringW(UUID *Uuid, RPC_WSTR *StringUuid)
Definition: rpcrt4_main.c:541
unsigned char BYTE
Definition: mem.h:68
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define sprintfW
Definition: unicode.h:58
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:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: path.c:42
#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 5826 of file devinst.c.

5827 {
5828  HKEY enumKey, key = INVALID_HANDLE_VALUE;
5829  LONG l;
5830 
5832  if (!l)
5833  {
5834  l = RegOpenKeyExW(enumKey, devInfo->instanceId, 0, samDesired, &key);
5835  RegCloseKey(enumKey);
5836  }
5837  if (l)
5838  SetLastError(l);
5839  return key;
5840 }
static PMEMKEY RootKey
Definition: registry.c:55
#define REGSTR_PATH_SYSTEMENUM
Definition: regstr.h:483
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
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:409
#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:42

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

5843 {
5844  LPWSTR DriverKey = NULL;
5845  DWORD dwLength = 0;
5846  DWORD dwRegType;
5847  DWORD rc;
5848  HKEY hEnumKey = NULL;
5849  HKEY hKey = NULL;
5851 
5852  hKey = SETUPDI_OpenDevKey(RootKey, devInfo, KEY_QUERY_VALUE);
5853  if (hKey == INVALID_HANDLE_VALUE)
5854  goto cleanup;
5855  /* Read the 'Driver' key */
5856  rc = RegQueryValueExW(hKey, REGSTR_VAL_DRIVER, NULL, &dwRegType, NULL, &dwLength);
5857  if (rc != ERROR_SUCCESS)
5858  {
5859  SetLastError(rc);
5860  goto cleanup;
5861  }
5862  else if (dwRegType != REG_SZ)
5863  {
5865  goto cleanup;
5866  }
5867  DriverKey = HeapAlloc(GetProcessHeap(), 0, dwLength);
5868  if (!DriverKey)
5869  {
5871  goto cleanup;
5872  }
5873  rc = RegQueryValueExW(hKey, REGSTR_VAL_DRIVER, NULL, &dwRegType, (LPBYTE)DriverKey, &dwLength);
5874  if (rc != ERROR_SUCCESS)
5875  {
5876  SetLastError(rc);
5877  goto cleanup;
5878  }
5879  RegCloseKey(hKey);
5880  hKey = NULL;
5881  /* Need to open the driver key */
5882  rc = RegOpenKeyExW(
5883  RootKey,
5885  0, /* Options */
5886  READ_CONTROL,
5887  &hEnumKey);
5888  if (rc != ERROR_SUCCESS)
5889  {
5890  SetLastError(rc);
5891  goto cleanup;
5892  }
5893  rc = RegOpenKeyExW(
5894  hEnumKey,
5895  DriverKey,
5896  0, /* Options */
5897  samDesired,
5898  &hKey);
5899  if (rc != ERROR_SUCCESS)
5900  {
5901  SetLastError(rc);
5902  goto cleanup;
5903  }
5904  key = hKey;
5905 
5906 cleanup:
5907  if (hEnumKey != NULL)
5909  if (hKey != NULL && hKey != key)
5910  RegCloseKey(hKey);
5911  if (DriverKey)
5912  HeapFree(GetProcessHeap(), 0, DriverKey);
5913  return key;
5914 }
HKEY SETUPDI_OpenDevKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5826
#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:391
static HANDLE hEnumKey
Definition: devinst.c:20
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
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:83
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define READ_CONTROL
Definition: nt_native.h:58
HKEY key
Definition: reg.c:42
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
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:394
Definition: path.c:42
#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:99
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
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 MultiByteToWideChar
Definition: compat.h:100

◆ 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().