ReactOS  0.4.15-dev-2355-gaf9df93
devinst.c File Reference
#include "setupapi_private.h"
Include dependency graph for devinst.c:

Go to the source code of this file.

Classes

struct  CoInstallerElement
 
struct  GetSectionCallbackInfo
 
struct  PropertyMapEntry
 

Macros

#define CLASS_COINSTALLER   0x1
 
#define DEVICE_COINSTALLER   0x2
 
#define CLASS_INSTALLER   0x4
 

Typedefs

typedef DWORD(CALLBACKCLASS_INSTALL_PROC) (IN DI_FUNCTION InstallFunction, IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
 
typedef BOOL(WINAPIDEFAULT_CLASS_INSTALL_PROC) (IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
 
typedef DWORD(CALLBACKCOINSTALLER_PROC) (IN DI_FUNCTION InstallFunction, IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN OUT PCOINSTALLER_CONTEXT_DATA Context)
 

Functions

static void SETUPDI_GuidToString (const GUID *guid, LPWSTR guidStr)
 
DWORD GetErrorCodeFromCrCode (const IN CONFIGRET cr)
 
static BOOL CheckSectionValid (IN LPCWSTR SectionName, IN PSP_ALTPLATFORM_INFO PlatformInfo, IN BYTE ProductType, IN WORD SuiteMask, OUT PDWORD ScorePlatform, OUT PDWORD ScoreMajorVersion, OUT PDWORD ScoreMinorVersion, OUT PDWORD ScoreProductType, OUT PDWORD ScoreSuiteMask)
 
static BOOL GetSectionCallback (IN LPCWSTR SectionName, IN PVOID Context)
 
BOOL WINAPI SetupDiGetActualSectionToInstallExW (IN HINF InfHandle, IN PCWSTR InfSectionName, IN PSP_ALTPLATFORM_INFO AlternatePlatformInfo OPTIONAL, OUT PWSTR InfSectionWithExt OPTIONAL, IN DWORD InfSectionWithExtSize, OUT PDWORD RequiredSize OPTIONAL, OUT PWSTR *Extension OPTIONAL, IN PVOID Reserved)
 
BOOL CreateDeviceInfo (IN struct DeviceInfoSet *list, IN LPCWSTR InstancePath, IN LPCGUID pClassGuid, OUT struct DeviceInfo **pDeviceInfo)
 
static BOOL DestroyClassInstallParams (struct ClassInstallParams *installParams)
 
static BOOL DestroyDeviceInfo (struct DeviceInfo *deviceInfo)
 
static BOOL DestroyDeviceInfoSet (struct DeviceInfoSet *list)
 
BOOL WINAPI SetupDiBuildClassInfoList (DWORD Flags, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize)
 
BOOL WINAPI SetupDiBuildClassInfoListExA (DWORD Flags, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCSTR MachineName, PVOID Reserved)
 
BOOL WINAPI SetupDiBuildClassInfoListExW (DWORD Flags, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCWSTR MachineName, PVOID Reserved)
 
BOOL WINAPI SetupDiClassGuidsFromNameA (LPCSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize)
 
BOOL WINAPI SetupDiClassGuidsFromNameW (LPCWSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize)
 
BOOL WINAPI SetupDiClassGuidsFromNameExA (LPCSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCSTR MachineName, PVOID Reserved)
 
BOOL WINAPI SetupDiClassGuidsFromNameExW (LPCWSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCWSTR MachineName, PVOID Reserved)
 
BOOL WINAPI SetupDiClassNameFromGuidA (const GUID *ClassGuid, PSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize)
 
BOOL WINAPI SetupDiClassNameFromGuidW (const GUID *ClassGuid, PWSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize)
 
BOOL WINAPI SetupDiClassNameFromGuidExA (const GUID *ClassGuid, PSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize, PCSTR MachineName, PVOID Reserved)
 
BOOL WINAPI SetupDiClassNameFromGuidExW (const GUID *ClassGuid, PWSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize, PCWSTR MachineName, PVOID Reserved)
 
HDEVINFO WINAPI SetupDiCreateDeviceInfoList (const GUID *ClassGuid, HWND hwndParent)
 
HDEVINFO WINAPI SetupDiCreateDeviceInfoListExA (const GUID *ClassGuid, HWND hwndParent, PCSTR MachineName, PVOID Reserved)
 
HDEVINFO WINAPI SetupDiCreateDeviceInfoListExW (const GUID *ClassGuid, HWND hwndParent, PCWSTR MachineName, PVOID Reserved)
 
HKEY WINAPI SetupDiCreateDevRegKeyA (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, HINF InfHandle, PCSTR InfSectionName)
 
static HKEY OpenHardwareProfileKey (IN HKEY HKLM, IN DWORD HwProfile, IN DWORD samDesired)
 
HKEY WINAPI SetupDiCreateDevRegKeyW (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, HINF InfHandle, PCWSTR InfSectionName)
 
BOOL WINAPI SetupDiCreateDeviceInfoA (HDEVINFO DeviceInfoSet, PCSTR DeviceName, CONST GUID *ClassGuid, PCSTR DeviceDescription, HWND hwndParent, DWORD CreationFlags, PSP_DEVINFO_DATA DeviceInfoData)
 
BOOL WINAPI SetupDiCreateDeviceInfoW (HDEVINFO DeviceInfoSet, PCWSTR DeviceName, CONST GUID *ClassGuid, PCWSTR DeviceDescription, HWND hwndParent, DWORD CreationFlags, PSP_DEVINFO_DATA DeviceInfoData)
 
BOOL WINAPI SetupDiRegisterDeviceInfo (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Flags, PSP_DETSIG_CMPPROC CompareProc, PVOID CompareContext, PSP_DEVINFO_DATA DupDeviceInfoData)
 
BOOL WINAPI SetupDiEnumDeviceInfo (HDEVINFO devinfo, DWORD index, PSP_DEVINFO_DATA info)
 
BOOL WINAPI SetupDiGetDeviceInstanceIdA (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSTR DeviceInstanceId, DWORD DeviceInstanceIdSize, PDWORD RequiredSize)
 
BOOL WINAPI SetupDiGetDeviceInstanceIdW (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PWSTR DeviceInstanceId, DWORD DeviceInstanceIdSize, PDWORD RequiredSize)
 
BOOL WINAPI SetupDiGetActualSectionToInstallA (HINF InfHandle, PCSTR InfSectionName, PSTR InfSectionWithExt, DWORD InfSectionWithExtSize, PDWORD RequiredSize, PSTR *Extension)
 
BOOL WINAPI SetupDiGetActualSectionToInstallW (HINF InfHandle, PCWSTR InfSectionName, PWSTR InfSectionWithExt, DWORD InfSectionWithExtSize, PDWORD RequiredSize, PWSTR *Extension)
 
BOOL WINAPI SetupDiGetActualSectionToInstallExA (IN HINF InfHandle, IN PCSTR InfSectionName, IN PSP_ALTPLATFORM_INFO AlternatePlatformInfo OPTIONAL, OUT PSTR InfSectionWithExt OPTIONAL, IN DWORD InfSectionWithExtSize, OUT PDWORD RequiredSize OPTIONAL, OUT PSTR *Extension OPTIONAL, IN PVOID Reserved)
 
BOOL WINAPI SetupDiGetClassDescriptionA (const GUID *ClassGuid, PSTR ClassDescription, DWORD ClassDescriptionSize, PDWORD RequiredSize)
 
BOOL WINAPI SetupDiGetClassDescriptionW (const GUID *ClassGuid, PWSTR ClassDescription, DWORD ClassDescriptionSize, PDWORD RequiredSize)
 
BOOL WINAPI SetupDiGetClassDescriptionExA (const GUID *ClassGuid, PSTR ClassDescription, DWORD ClassDescriptionSize, PDWORD RequiredSize, PCSTR MachineName, PVOID Reserved)
 
BOOL WINAPI SetupDiGetClassDescriptionExW (const GUID *ClassGuid, PWSTR ClassDescription, DWORD ClassDescriptionSize, PDWORD RequiredSize, PCWSTR MachineName, PVOID Reserved)
 
HDEVINFO WINAPI SetupDiGetClassDevsA (CONST GUID *class, LPCSTR enumstr, HWND parent, DWORD flags)
 
HDEVINFO WINAPI SetupDiGetClassDevsExA (const GUID *class, PCSTR enumstr, HWND parent, DWORD flags, HDEVINFO deviceset, PCSTR machine, PVOID reserved)
 
HDEVINFO WINAPI SetupDiGetClassDevsW (CONST GUID *class, LPCWSTR enumstr, HWND parent, DWORD flags)
 
HDEVINFO WINAPI SetupDiGetClassDevsExW (CONST GUID *class, PCWSTR enumstr, HWND parent, DWORD flags, HDEVINFO deviceset, PCWSTR machine, PVOID reserved)
 
BOOL WINAPI SetupDiGetDeviceInfoListDetailA (HDEVINFO DeviceInfoSet, PSP_DEVINFO_LIST_DETAIL_DATA_A DevInfoData)
 
BOOL WINAPI SetupDiGetDeviceInfoListDetailW (HDEVINFO DeviceInfoSet, PSP_DEVINFO_LIST_DETAIL_DATA_W DevInfoData)
 
BOOL WINAPI SetupDiCreateDeviceInterfaceA (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, const GUID *InterfaceClassGuid, PCSTR ReferenceString, DWORD CreationFlags, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
 
BOOL WINAPI SetupDiCreateDeviceInterfaceW (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, const GUID *InterfaceClassGuid, PCWSTR ReferenceString, DWORD CreationFlags, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
 
HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyA (HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DWORD Reserved, REGSAM samDesired, HINF InfHandle, PCSTR InfSectionName)
 
HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW (HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DWORD Reserved, REGSAM samDesired, HINF InfHandle, PCWSTR InfSectionName)
 
BOOL WINAPI SetupDiDeleteDeviceInterfaceRegKey (HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DWORD Reserved)
 
BOOL WINAPI SetupDiEnumDeviceInterfaces (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, CONST GUID *InterfaceClassGuid, DWORD MemberIndex, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
 
BOOL WINAPI SetupDiDestroyDeviceInfoList (HDEVINFO devinfo)
 
BOOL WINAPI SetupDiGetDeviceInterfaceDetailA (HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, PSP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetailData, DWORD DeviceInterfaceDetailDataSize, PDWORD RequiredSize, PSP_DEVINFO_DATA DeviceInfoData)
 
BOOL WINAPI SetupDiGetDeviceInterfaceDetailW (HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailData, DWORD DeviceInterfaceDetailDataSize, PDWORD RequiredSize, PSP_DEVINFO_DATA DeviceInfoData)
 
BOOL WINAPI SetupDiGetDeviceRegistryPropertyA (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize)
 
BOOL WINAPI SetupDiGetDeviceRegistryPropertyW (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize)
 
BOOL WINAPI IntSetupDiSetDeviceRegistryPropertyAW (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, const BYTE *PropertyBuffer, DWORD PropertyBufferSize, BOOL isAnsi)
 
BOOL WINAPI SetupDiSetDeviceRegistryPropertyA (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, const BYTE *PropertyBuffer, DWORD PropertyBufferSize)
 
BOOL WINAPI SetupDiSetDeviceRegistryPropertyW (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, const BYTE *PropertyBuffer, DWORD PropertyBufferSize)
 
BOOL WINAPI SetupDiInstallClassA (HWND hwndParent, PCSTR InfFileName, DWORD Flags, HSPFILEQ FileQueue)
 
BOOL WINAPI SetupDiInstallClassExA (IN HWND hwndParent OPTIONAL, IN PCSTR InfFileName OPTIONAL, IN DWORD Flags, IN HSPFILEQ FileQueue OPTIONAL, IN CONST GUID *InterfaceClassGuid OPTIONAL, IN PVOID Reserved1, IN PVOID Reserved2)
 
HKEY SETUP_CreateClassKey (HINF hInf)
 
BOOL WINAPI SetupDiInstallClassW (HWND hwndParent, PCWSTR InfFileName, DWORD Flags, HSPFILEQ FileQueue)
 
HKEY WINAPI SetupDiOpenClassRegKey (const GUID *ClassGuid, REGSAM samDesired)
 
HKEY WINAPI SetupDiOpenClassRegKeyExA (const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCSTR MachineName, PVOID Reserved)
 
HKEY WINAPI SetupDiOpenClassRegKeyExW (const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCWSTR MachineName, PVOID Reserved)
 
BOOL WINAPI SetupDiOpenDeviceInterfaceW (HDEVINFO DeviceInfoSet, PCWSTR DevicePath, DWORD OpenFlags, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
 
BOOL WINAPI SetupDiOpenDeviceInterfaceA (HDEVINFO DeviceInfoSet, PCSTR DevicePath, DWORD OpenFlags, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
 
BOOL WINAPI SetupDiSetClassInstallParamsA (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_CLASSINSTALL_HEADER ClassInstallParams, DWORD ClassInstallParamsSize)
 
static BOOL WINAPI IntSetupDiRegisterDeviceInfo (IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
 
BOOL WINAPI SetupDiCallClassInstaller (DI_FUNCTION InstallFunction, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData)
 
BOOL WINAPI SetupDiGetDeviceInstallParamsA (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DEVINSTALL_PARAMS_A DeviceInstallParams)
 
BOOL WINAPI SetupDiGetDeviceInfoListClass (IN HDEVINFO DeviceInfoSet, OUT LPGUID ClassGuid)
 
BOOL WINAPI SetupDiGetDeviceInstallParamsW (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, OUT PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
 
static BOOL CheckDeviceInstallParameters (IN PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
 
BOOL WINAPI SetupDiSetDeviceInstallParamsW (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
 
BOOL WINAPI SetupDiSetDeviceInstallParamsA (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PSP_DEVINSTALL_PARAMS_A DeviceInstallParams)
 
static BOOL IsDeviceInfoInDeviceInfoSet (struct DeviceInfoSet *deviceInfoSet, struct DeviceInfo *deviceInfo)
 
BOOL WINAPI SetupDiDeleteDeviceInfo (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
 
BOOL WINAPI SetupDiOpenDeviceInfoA (IN HDEVINFO DeviceInfoSet, IN PCSTR DeviceInstanceId, IN HWND hwndParent OPTIONAL, IN DWORD OpenFlags, OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
 
BOOL WINAPI SetupDiOpenDeviceInfoW (IN HDEVINFO DeviceInfoSet, IN PCWSTR DeviceInstanceId, IN HWND hwndParent OPTIONAL, IN DWORD OpenFlags, OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
 
BOOL WINAPI SetupDiGetSelectedDevice (IN HDEVINFO DeviceInfoSet, OUT PSP_DEVINFO_DATA DeviceInfoData)
 
BOOL WINAPI SetupDiSetSelectedDevice (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
 
static DWORD SETUPAPI_GetCurrentHwProfile (IN HDEVINFO DeviceInfoSet)
 
static BOOL ResetDevice (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
 
static BOOL StopDevice (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
 
BOOL WINAPI SetupDiChangeState (IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
 
BOOL WINAPI SetupDiSelectDevice (IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
 
BOOL WINAPI SetupDiRegisterCoDeviceInstallers (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
 
static BOOL InfIsFromOEMLocation (IN PCWSTR FullName, OUT LPBOOL IsOEMLocation)
 
BOOL WINAPI SetupDiInstallDevice (IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
 
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)
 
HKEY WINAPI SetupDiOpenDevRegKey (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, REGSAM samDesired)
 
static BOOL SETUPDI_DeleteDevKey (HKEY RootKey, struct DeviceInfo *devInfo)
 
static BOOL SETUPDI_DeleteDrvKey (HKEY RootKey, struct DeviceInfo *devInfo)
 
BOOL WINAPI SetupDiDeleteDevRegKey (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType)
 
BOOL WINAPI SetupDiRestartDevices (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData)
 

Variables

static const WCHAR BackSlash [] = {'\\',0}
 
static const WCHAR DateFormat [] = {'%','u','-','%','u','-','%','u',0}
 
static const WCHAR DotCoInstallers [] = {'.','C','o','I','n','s','t','a','l','l','e','r','s',0}
 
static const WCHAR DotHW [] = {'.','H','W',0}
 
static const WCHAR DotServices [] = {'.','S','e','r','v','i','c','e','s',0}
 
static const WCHAR InfDirectory [] = {'i','n','f','\\',0}
 
static const WCHAR InstanceKeyFormat [] = {'%','0','4','l','u',0}
 
static const WCHAR Version [] = {'V','e','r','s','i','o','n',0}
 
static const WCHAR VersionFormat [] = {'%','u','.','%','u','.','%','u','.','%','u',0}
 
static const WCHAR REGSTR_DRIVER_DATE [] = {'D','r','i','v','e','r','D','a','t','e',0}
 
static const WCHAR REGSTR_DRIVER_DATE_DATA [] = {'D','r','i','v','e','r','D','a','t','e','D','a','t','a',0}
 
static const WCHAR REGSTR_DRIVER_VERSION [] = {'D','r','i','v','e','r','V','e','r','s','i','o','n',0}
 
static const WCHAR REGSTR_SECURITY [] = {'S','e','c','u','r','i','t','y',0}
 
static const WCHAR REGSTR_UI_NUMBER_DESC_FORMAT [] = {'U','I','N','u','m','b','e','r','D','e','s','c','F','o','r','m','a','t',0}
 
static struct PropertyMapEntry PropertyMap []
 

Macro Definition Documentation

◆ CLASS_COINSTALLER

#define CLASS_COINSTALLER   0x1

◆ CLASS_INSTALLER

#define CLASS_INSTALLER   0x4

◆ DEVICE_COINSTALLER

#define DEVICE_COINSTALLER   0x2

Typedef Documentation

◆ CLASS_INSTALL_PROC

typedef DWORD(CALLBACK* CLASS_INSTALL_PROC) (IN DI_FUNCTION InstallFunction, IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)

Definition at line 42 of file devinst.c.

◆ COINSTALLER_PROC

Definition at line 51 of file devinst.c.

◆ DEFAULT_CLASS_INSTALL_PROC

typedef BOOL(WINAPI* DEFAULT_CLASS_INSTALL_PROC) (IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)

Definition at line 47 of file devinst.c.

Function Documentation

◆ CheckDeviceInstallParameters()

static BOOL CheckDeviceInstallParameters ( IN PSP_DEVINSTALL_PARAMS_W  DeviceInstallParams)
static

Definition at line 4493 of file devinst.c.

4495 {
4496  DWORD SupportedFlags =
4497  DI_NOVCP | /* 0x00000008 */
4498  DI_DIDCOMPAT | /* 0x00000010 */
4499  DI_DIDCLASS | /* 0x00000020 */
4500  DI_NEEDRESTART | /* 0x00000080 */
4501  DI_NEEDREBOOT | /* 0x00000100 */
4502  DI_RESOURCEPAGE_ADDED | /* 0x00002000 */
4503  DI_PROPERTIES_CHANGE | /* 0x00004000 */
4504  DI_ENUMSINGLEINF | /* 0x00010000 */
4505  DI_DONOTCALLCONFIGMG | /* 0x00020000 */
4506  DI_CLASSINSTALLPARAMS | /* 0x00100000 */
4507  DI_NODI_DEFAULTACTION | /* 0x00200000 */
4508  DI_QUIETINSTALL | /* 0x00800000 */
4509  DI_NOFILECOPY | /* 0x01000000 */
4510  DI_DRIVERPAGE_ADDED; /* 0x04000000 */
4511  DWORD SupportedFlagsEx =
4512  DI_FLAGSEX_CI_FAILED | /* 0x00000004 */
4513  DI_FLAGSEX_DIDINFOLIST | /* 0x00000010 */
4514  DI_FLAGSEX_DIDCOMPATINFO | /* 0x00000020 */
4515  DI_FLAGSEX_ALLOWEXCLUDEDDRVS | /* 0x00000800 */
4516  DI_FLAGSEX_NO_DRVREG_MODIFY | /* 0x00008000 */
4517  DI_FLAGSEX_INSTALLEDDRIVER; /* 0x04000000 */
4518  BOOL ret = FALSE;
4519 
4520  /* FIXME: add support for more flags */
4521 
4522  /* FIXME: DI_CLASSINSTALLPARAMS flag is not correctly used.
4523  * It should be checked before accessing to other values
4524  * of the SP_DEVINSTALL_PARAMS structure */
4525 
4526  if (DeviceInstallParams->Flags & ~SupportedFlags)
4527  {
4528  FIXME("Unknown Flags: 0x%08lx\n", DeviceInstallParams->Flags & ~SupportedFlags);
4530  }
4531  else if (DeviceInstallParams->FlagsEx & ~SupportedFlagsEx)
4532  {
4533  FIXME("Unknown FlagsEx: 0x%08lx\n", DeviceInstallParams->FlagsEx & ~SupportedFlagsEx);
4535  }
4536  else if ((DeviceInstallParams->Flags & DI_NOVCP)
4537  && (DeviceInstallParams->FileQueue == NULL || DeviceInstallParams->FileQueue == (HSPFILEQ)INVALID_HANDLE_VALUE))
4539  else
4540  {
4541  /* FIXME: check Reserved field */
4542  ret = TRUE;
4543  }
4544 
4545  return ret;
4546 }
#define DI_NEEDREBOOT
Definition: setupapi.h:54
#define TRUE
Definition: types.h:120
#define DI_FLAGSEX_NO_DRVREG_MODIFY
Definition: setupapi.h:91
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define DI_FLAGSEX_ALLOWEXCLUDEDDRVS
Definition: setupapi.h:87
#define DI_DRIVERPAGE_ADDED
Definition: setupapi.h:71
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1091
#define DI_DIDCLASS
Definition: setupapi.h:51
#define FALSE
Definition: types.h:117
#define DI_DONOTCALLCONFIGMG
Definition: setupapi.h:63
unsigned int BOOL
Definition: ntddk_ex.h:94
#define DI_NOFILECOPY
Definition: setupapi.h:69
#define FIXME(fmt,...)
Definition: debug.h:111
#define DI_DIDCOMPAT
Definition: setupapi.h:50
#define DI_NOVCP
Definition: setupapi.h:49
#define DI_PROPERTIES_CHANGE
Definition: setupapi.h:60
#define DI_NODI_DEFAULTACTION
Definition: setupapi.h:67
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define DI_QUIETINSTALL
Definition: setupapi.h:68
#define DI_RESOURCEPAGE_ADDED
Definition: setupapi.h:59
#define DI_CLASSINSTALLPARAMS
Definition: setupapi.h:66
int ret
#define DI_FLAGSEX_DIDINFOLIST
Definition: setupapi.h:80
#define DI_FLAGSEX_DIDCOMPATINFO
Definition: setupapi.h:81
#define DI_FLAGSEX_CI_FAILED
Definition: setupapi.h:79
#define NULL
Definition: types.h:112
#define DI_ENUMSINGLEINF
Definition: setupapi.h:62
#define DI_NEEDRESTART
Definition: setupapi.h:53
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583

Referenced by SetupDiSetDeviceInstallParamsW().

◆ CheckSectionValid()

static BOOL CheckSectionValid ( IN LPCWSTR  SectionName,
IN PSP_ALTPLATFORM_INFO  PlatformInfo,
IN BYTE  ProductType,
IN WORD  SuiteMask,
OUT PDWORD  ScorePlatform,
OUT PDWORD  ScoreMajorVersion,
OUT PDWORD  ScoreMinorVersion,
OUT PDWORD  ScoreProductType,
OUT PDWORD  ScoreSuiteMask 
)
static

Definition at line 122 of file devinst.c.

132 {
133  LPWSTR Section = NULL;
134  //LPCWSTR pExtensionPlatform;
135  LPCWSTR pExtensionArchitecture;
136  LPWSTR Fields[6];
137  DWORD i;
138  BOOL ret = FALSE;
139 
140  //static const WCHAR ExtensionPlatformNone[] = {'.',0};
141  static const WCHAR ExtensionPlatformNT[] = {'.','N','T',0};
142  static const WCHAR ExtensionPlatformWindows[] = {'.','W','i','n',0};
143 
144  static const WCHAR ExtensionArchitectureNone[] = {0};
145  static const WCHAR ExtensionArchitecturealpha[] = {'a','l','p','h','a',0};
146  static const WCHAR ExtensionArchitectureamd64[] = {'A','M','D','6','4',0};
147  static const WCHAR ExtensionArchitectureia64[] = {'I','A','6','4',0};
148  static const WCHAR ExtensionArchitecturemips[] = {'m','i','p','s',0};
149  static const WCHAR ExtensionArchitectureppc[] = {'p','p','c',0};
150  static const WCHAR ExtensionArchitecturex86[] = {'x','8','6',0};
151 
152  TRACE("%s(%s %p 0x%x 0x%x)\n",
153  __FUNCTION__, debugstr_w(SectionName), PlatformInfo, ProductType, SuiteMask);
154 
155  *ScorePlatform = *ScoreMajorVersion = *ScoreMinorVersion = *ScoreProductType = *ScoreSuiteMask = 0;
156 
157  Section = pSetupDuplicateString(SectionName);
158  if (!Section)
159  {
160  TRACE("pSetupDuplicateString() failed\n");
161  goto cleanup;
162  }
163 
164  /* Set various extensions values */
165  switch (PlatformInfo->Platform)
166  {
168  //pExtensionPlatform = ExtensionPlatformWindows;
169  break;
171  //pExtensionPlatform = ExtensionPlatformNT;
172  break;
173  default:
174  ERR("Unknown platform 0x%lx\n", PlatformInfo->Platform);
175  //pExtensionPlatform = ExtensionPlatformNone;
176  break;
177  }
178  switch (PlatformInfo->ProcessorArchitecture)
179  {
181  pExtensionArchitecture = ExtensionArchitecturealpha;
182  break;
184  pExtensionArchitecture = ExtensionArchitectureamd64;
185  break;
187  pExtensionArchitecture = ExtensionArchitectureia64;
188  break;
190  pExtensionArchitecture = ExtensionArchitecturex86;
191  break;
193  pExtensionArchitecture = ExtensionArchitecturemips;
194  break;
196  pExtensionArchitecture = ExtensionArchitectureppc;
197  break;
198  default:
199  ERR("Unknown processor architecture 0x%x\n", PlatformInfo->ProcessorArchitecture);
201  pExtensionArchitecture = ExtensionArchitectureNone;
202  break;
203  }
204 
205  /*
206  * Field[0] Platform
207  * Field[1] Architecture
208  * Field[2] Major version
209  * Field[3] Minor version
210  * Field[4] Product type
211  * Field[5] Suite mask
212  * Remark: these fields may be NULL if the information is not provided
213  */
214  Fields[0] = Section;
215  if (Fields[0] == NULL)
216  {
217  TRACE("No extension found\n");
218  *ScorePlatform = *ScoreMajorVersion = *ScoreMinorVersion = *ScoreProductType = *ScoreSuiteMask = ULONG_MAX;
219  ret = TRUE;
220  goto cleanup;
221  }
222  Fields[1] = Fields[0] + 1;
223  Fields[2] = Fields[3] = Fields[4] = Fields[5] = NULL;
224  for (i = 2; Fields[i - 1] != NULL && i < 6; i++)
225  {
226  Fields[i] = wcschr(Fields[i - 1], '.');
227  if (Fields[i])
228  {
229  Fields[i]++;
230  *(Fields[i] - 1) = UNICODE_NULL;
231  }
232  }
233  /* Take care of first 2 fields */
234  if (strncmpiW(Fields[0], ExtensionPlatformWindows, strlenW(ExtensionPlatformWindows)) == 0)
235  {
236  if (PlatformInfo->Platform != VER_PLATFORM_WIN32_WINDOWS)
237  {
238  TRACE("Mismatch on platform field\n");
239  goto cleanup;
240  }
241  Fields[1] += wcslen(ExtensionPlatformWindows) - 1;
242  }
243  else if (strncmpiW(Fields[0], ExtensionPlatformNT, strlenW(ExtensionPlatformNT)) == 0)
244  {
245  if (PlatformInfo->Platform != VER_PLATFORM_WIN32_NT)
246  {
247  TRACE("Mismatch on platform field\n");
248  goto cleanup;
249  }
250  Fields[1] += wcslen(ExtensionPlatformNT) - 1;
251  }
252  else
253  {
254  /* No platform specified */
255  *ScorePlatform |= 0x02;
256  }
257  if (strcmpiW(Fields[1], ExtensionArchitectureNone) == 0)
258  {
259  /* No architecture specified */
260  *ScorePlatform |= 0x01;
261  }
262  else if (strcmpiW(Fields[1], pExtensionArchitecture) != 0)
263  {
264  TRACE("Mismatch on architecture field ('%s' and '%s')\n",
265  debugstr_w(Fields[1]), debugstr_w(pExtensionArchitecture));
266  goto cleanup;
267  }
268 
269  /* Check if informations are matching */
270  if (Fields[2] && *Fields[2])
271  {
273  MajorVersion = strtoulW(Fields[2], NULL, 0);
274  if ((MajorVersion == 0 || MajorVersion == ULONG_MAX) &&
275  (errno == ERANGE || errno == EINVAL))
276  {
277  TRACE("Wrong MajorVersion ('%s')\n", debugstr_w(Fields[2]));
278  goto cleanup;
279  }
280  if (Fields[3] && *Fields[3])
281  {
282  MinorVersion = strtoulW(Fields[3], NULL, 0);
283  if ((MinorVersion == 0 || MinorVersion == ULONG_MAX) &&
284  (errno == ERANGE || errno == EINVAL))
285  {
286  TRACE("Wrong MinorVersion ('%s')\n", debugstr_w(Fields[3]));
287  goto cleanup;
288  }
289  }
290  if (PlatformInfo->MajorVersion < MajorVersion ||
291  (PlatformInfo->MajorVersion == MajorVersion && PlatformInfo->MinorVersion < MinorVersion))
292  {
293  TRACE("Mismatch on version field (%lu.%lu and %lu.%lu)\n",
294  MajorVersion, MinorVersion, PlatformInfo->MajorVersion, PlatformInfo->MinorVersion);
295  goto cleanup;
296  }
297  *ScoreMajorVersion = MajorVersion - PlatformInfo->MajorVersion;
298  if (MajorVersion == PlatformInfo->MajorVersion)
299  *ScoreMinorVersion = MinorVersion - PlatformInfo->MinorVersion;
300  else
301  *ScoreMinorVersion = MinorVersion;
302  }
303  else if (Fields[3] && *Fields[3])
304  {
305  TRACE("Minor version found without major version\n");
306  goto cleanup;
307  }
308  else
309  {
310  *ScoreMajorVersion = PlatformInfo->MajorVersion;
311  *ScoreMinorVersion = PlatformInfo->MinorVersion;
312  }
313 
314  if (Fields[4] && *Fields[4])
315  {
316  DWORD CurrentProductType;
317  CurrentProductType = strtoulW(Fields[4], NULL, 0);
318  if ((CurrentProductType == 0 || CurrentProductType == ULONG_MAX) &&
319  (errno == ERANGE || errno == EINVAL))
320  {
321  TRACE("Wrong Product type ('%s')\n", debugstr_w(Fields[4]));
322  goto cleanup;
323  }
324  if (CurrentProductType != ProductType)
325  {
326  TRACE("Mismatch on product type (0x%08lx and 0x%08x)\n",
327  CurrentProductType, ProductType);
328  goto cleanup;
329  }
330  }
331  else
332  *ScoreProductType = 1;
333 
334  if (Fields[5] && *Fields[5])
335  {
336  DWORD CurrentSuiteMask;
337  CurrentSuiteMask = strtoulW(Fields[5], NULL, 0);
338  if ((CurrentSuiteMask == 0 || CurrentSuiteMask == ULONG_MAX) &&
339  (errno == ERANGE || errno == EINVAL))
340  {
341  TRACE("Wrong Suite mask ('%s')\n", debugstr_w(Fields[5]));
342  goto cleanup;
343  }
344  if ((CurrentSuiteMask & ~SuiteMask) != 0)
345  {
346  TRACE("Mismatch on suite mask (0x%08lx and 0x%08x)\n",
347  CurrentSuiteMask, SuiteMask);
348  goto cleanup;
349  }
350  *ScoreSuiteMask = SuiteMask & ~CurrentSuiteMask;
351  }
352  else
353  *ScoreSuiteMask = SuiteMask;
354 
355  ret = TRUE;
356 
357 cleanup:
358  MyFree(Section);
359  return ret;
360 }
#define VER_PLATFORM_WIN32_NT
Definition: rtltypes.h:236
ULONG MinorVersion
Definition: ros_glue.cpp:5
ULONG MajorVersion
Definition: ros_glue.cpp:4
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define PROCESSOR_ARCHITECTURE_UNKNOWN
Definition: ketypes.h:115
#define TRUE
Definition: types.h:120
Definition: arc.h:39
int errno
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
#define PROCESSOR_ARCHITECTURE_MIPS
Definition: ketypes.h:106
#define PROCESSOR_ARCHITECTURE_IA64
Definition: ketypes.h:111
#define PROCESSOR_ARCHITECTURE_ALPHA
Definition: ketypes.h:107
LPWSTR WINAPI pSetupDuplicateString(LPCWSTR lpSrc)
Definition: misc.c:198
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PROCESSOR_ARCHITECTURE_AMD64
Definition: ketypes.h:114
#define ERANGE
Definition: acclib.h:92
int ret
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define PROCESSOR_ARCHITECTURE_INTEL
Definition: ketypes.h:105
#define ERR(fmt,...)
Definition: debug.h:110
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 PROCESSOR_ARCHITECTURE_PPC
Definition: ketypes.h:108
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define VER_PLATFORM_WIN32_WINDOWS
Definition: rtltypes.h:235
char * cleanup(char *str)
Definition: wpickclick.c:99
#define strtoulW(s1, s2, b)
Definition: unicode.h:41
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define __FUNCTION__
Definition: types.h:112
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
#define ULONG_MAX
Definition: limits.h:44

Referenced by GetSectionCallback().

◆ 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 }
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:92
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ZeroMemory
Definition: winbase.h:1664
SP_DEVINSTALL_PARAMS_W InstallParams
_Null_terminated_ WCHAR * DEVINSTID_W
Definition: cfgmgr32.h:80
#define FALSE
Definition: types.h:117
CONFIGRET WINAPI CM_Locate_DevNode_ExW(_Out_ PDEVINST pdnDevInst, _In_opt_ DEVINSTID_W pDeviceID, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:5905
#define CR_SUCCESS
Definition: cfgmgr32.h:842
PCWSTR DeviceDescription
WCHAR Data[ANYSIZE_ARRAY]
struct DeviceInfoSet * set
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
LIST_ENTRY DriverListHead
DEVINST dnDevInst
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: _list.h:228
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define list
Definition: rosglue.h:35
#define NULL
Definition: types.h:112
#define CM_LOCATE_DEVNODE_PHANTOM
Definition: cfgmgr32.h:761
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
struct _SP_DEVINSTALL_PARAMS_W SP_DEVINSTALL_PARAMS_W

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

◆ DestroyClassInstallParams()

static BOOL DestroyClassInstallParams ( struct ClassInstallParams installParams)
static

Definition at line 571 of file devinst.c.

572 {
573  HeapFree(GetProcessHeap(), 0, installParams->PropChangeParams);
574  HeapFree(GetProcessHeap(), 0, installParams->AddPropertyPageData);
575  return TRUE;
576 }
#define TRUE
Definition: types.h:120
PSP_ADDPROPERTYPAGE_DATA AddPropertyPageData
#define GetProcessHeap()
Definition: compat.h:595
PSP_PROPCHANGE_PARAMS PropChangeParams
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by DestroyDeviceInfo(), and DestroyDeviceInfoSet().

◆ DestroyDeviceInfo()

static BOOL DestroyDeviceInfo ( struct DeviceInfo deviceInfo)
static

Definition at line 579 of file devinst.c.

580 {
582  struct DriverInfoElement *driverInfo;
583  struct DeviceInterface *deviceInterface;
584 
585  while (!IsListEmpty(&deviceInfo->DriverListHead))
586  {
587  ListEntry = RemoveHeadList(&deviceInfo->DriverListHead);
589  if (!DestroyDriverInfoElement(driverInfo))
590  return FALSE;
591  }
592  while (!IsListEmpty(&deviceInfo->InterfaceListHead))
593  {
595  deviceInterface = CONTAINING_RECORD(ListEntry, struct DeviceInterface, ListEntry);
596  if (!DestroyDeviceInterface(deviceInterface))
597  return FALSE;
598  }
600  if (deviceInfo->hmodDevicePropPageProvider)
602  return HeapFree(GetProcessHeap(), 0, deviceInfo);
603 }
LIST_ENTRY InterfaceListHead
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define FALSE
Definition: types.h:117
BOOL DestroyDeviceInterface(struct DeviceInterface *deviceInterface)
Definition: interface.c:61
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
HMODULE hmodDevicePropPageProvider
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static BOOL DestroyClassInstallParams(struct ClassInstallParams *installParams)
Definition: devinst.c:571
#define FreeLibrary(x)
Definition: compat.h:607
#define GetProcessHeap()
Definition: compat.h:595
BOOL DestroyDriverInfoElement(struct DriverInfoElement *driverInfo)
Definition: driver.c:94
LIST_ENTRY DriverListHead
Definition: typedefs.h:119
LIST_ENTRY ListEntry
LIST_ENTRY ListEntry
struct ClassInstallParams ClassInstallParams
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by DestroyDeviceInfoSet(), SetupDiCreateDeviceInfoW(), and SetupDiDeleteDeviceInfo().

◆ DestroyDeviceInfoSet()

static BOOL DestroyDeviceInfoSet ( struct DeviceInfoSet list)
static

Definition at line 606 of file devinst.c.

607 {
609  struct DeviceInfo *deviceInfo;
610 
611  while (!IsListEmpty(&list->ListHead))
612  {
613  ListEntry = RemoveHeadList(&list->ListHead);
614  deviceInfo = CONTAINING_RECORD(ListEntry, struct DeviceInfo, ListEntry);
615  if (!DestroyDeviceInfo(deviceInfo))
616  return FALSE;
617  }
618  if (list->HKLM != HKEY_LOCAL_MACHINE)
619  RegCloseKey(list->HKLM);
620  CM_Disconnect_Machine(list->hMachine);
621  DestroyClassInstallParams(&list->ClassInstallParams);
622  if (list->hmodClassPropPageProvider)
623  FreeLibrary(list->hmodClassPropPageProvider);
624  return HeapFree(GetProcessHeap(), 0, list);
625 }
CONFIGRET WINAPI CM_Disconnect_Machine(_In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:1856
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static BOOL DestroyClassInstallParams(struct ClassInstallParams *installParams)
Definition: devinst.c:571
#define FreeLibrary(x)
Definition: compat.h:607
#define GetProcessHeap()
Definition: compat.h:595
static BOOL DestroyDeviceInfo(struct DeviceInfo *deviceInfo)
Definition: devinst.c:579
Definition: _list.h:228
Definition: typedefs.h:119
LIST_ENTRY ListEntry
LIST_ENTRY ListEntry
#define HeapFree(x, y, z)
Definition: compat.h:594
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by SetupDiDestroyDeviceInfoList().

◆ GetErrorCodeFromCrCode()

DWORD GetErrorCodeFromCrCode ( const IN CONFIGRET  cr)

Definition at line 92 of file devinst.c.

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

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

◆ GetSectionCallback()

static BOOL GetSectionCallback ( IN LPCWSTR  SectionName,
IN PVOID  Context 
)
static

Definition at line 363 of file devinst.c.

366 {
368  DWORD Score1, Score2, Score3, Score4, Score5;
369  BOOL ret;
370 
371  if (SectionName[info->PrefixLength] != '.')
372  return TRUE;
373 
375  &SectionName[info->PrefixLength],
376  info->PlatformInfo,
377  info->ProductType,
378  info->SuiteMask,
379  &Score1, &Score2, &Score3, &Score4, &Score5);
380  if (!ret)
381  {
382  TRACE("Section %s not compatible\n", debugstr_w(SectionName));
383  return TRUE;
384  }
385  if (Score1 > info->BestScore1) goto done;
386  if (Score1 < info->BestScore1) goto bettersection;
387  if (Score2 > info->BestScore2) goto done;
388  if (Score2 < info->BestScore2) goto bettersection;
389  if (Score3 > info->BestScore3) goto done;
390  if (Score3 < info->BestScore3) goto bettersection;
391  if (Score4 > info->BestScore4) goto done;
392  if (Score4 < info->BestScore4) goto bettersection;
393  if (Score5 > info->BestScore5) goto done;
394  if (Score5 < info->BestScore5) goto bettersection;
395  goto done;
396 
397 bettersection:
398  strcpyW(info->BestSection, SectionName);
399  info->BestScore1 = Score1;
400  info->BestScore2 = Score2;
401  info->BestScore3 = Score3;
402  info->BestScore4 = Score4;
403  info->BestScore5 = Score5;
404 
405 done:
406  return TRUE;
407 }
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL CheckSectionValid(IN LPCWSTR SectionName, IN PSP_ALTPLATFORM_INFO PlatformInfo, IN BYTE ProductType, IN WORD SuiteMask, OUT PDWORD ScorePlatform, OUT PDWORD ScoreMajorVersion, OUT PDWORD ScoreMinorVersion, OUT PDWORD ScoreProductType, OUT PDWORD ScoreSuiteMask)
Definition: devinst.c:122
int ret
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
struct tagContext Context
Definition: acpixf.h:1034

Referenced by SetupDiGetActualSectionToInstallExW().

◆ InfIsFromOEMLocation()

static BOOL InfIsFromOEMLocation ( IN PCWSTR  FullName,
OUT LPBOOL  IsOEMLocation 
)
static

Definition at line 5305 of file devinst.c.

5308 {
5309  PWCHAR last;
5310 
5311  last = strrchrW(FullName, '\\');
5312  if (!last)
5313  {
5314  /* No directory specified */
5315  *IsOEMLocation = FALSE;
5316  }
5317  else
5318  {
5319  LPWSTR Windir;
5320  UINT ret;
5321 
5322  Windir = MyMalloc((MAX_PATH + 1 + strlenW(InfDirectory)) * sizeof(WCHAR));
5323  if (!Windir)
5324  {
5326  return FALSE;
5327  }
5328 
5330  if (ret == 0 || ret > MAX_PATH)
5331  {
5332  MyFree(Windir);
5334  return FALSE;
5335  }
5336  if (*Windir && Windir[strlenW(Windir) - 1] != '\\')
5337  strcatW(Windir, BackSlash);
5338  strcatW(Windir, InfDirectory);
5339 
5340  if (strncmpiW(FullName, Windir, last - FullName) == 0)
5341  {
5342  /* The path is %SYSTEMROOT%\Inf */
5343  *IsOEMLocation = FALSE;
5344  }
5345  else
5346  {
5347  /* The file is in another place */
5348  *IsOEMLocation = TRUE;
5349  }
5350  MyFree(Windir);
5351  }
5352  return TRUE;
5353 }
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2396
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
POINT last
Definition: font.c:46
#define TRUE
Definition: types.h:120
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
uint16_t * PWCHAR
Definition: typedefs.h:56
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
#define FALSE
Definition: types.h:117
static const WCHAR InfDirectory[]
Definition: devinst.c:30
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
_In_ PSTRING FullName
Definition: rtlfuncs.h:1649
#define SetLastError(x)
Definition: compat.h:611
int ret
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
unsigned int UINT
Definition: ndis.h:50
static const WCHAR BackSlash[]
Definition: devinst.c:25
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
WCHAR * LPWSTR
Definition: xmlstorage.h:184
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128

Referenced by SetupDiInstallDevice().

◆ IntSetupDiRegisterDeviceInfo()

static BOOL WINAPI IntSetupDiRegisterDeviceInfo ( IN HDEVINFO  DeviceInfoSet,
IN OUT PSP_DEVINFO_DATA  DeviceInfoData 
)
static

Definition at line 4008 of file devinst.c.

4011 {
4013 }
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1523
BOOL WINAPI SetupDiRegisterDeviceInfo(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Flags, PSP_DETSIG_CMPPROC CompareProc, PVOID CompareContext, PSP_DEVINFO_DATA DupDeviceInfoData)
Definition: devinst.c:1705
#define NULL
Definition: types.h:112

Referenced by SetupDiCallClassInstaller().

◆ IntSetupDiSetDeviceRegistryPropertyAW()

BOOL WINAPI IntSetupDiSetDeviceRegistryPropertyAW ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
DWORD  Property,
const BYTE PropertyBuffer,
DWORD  PropertyBufferSize,
BOOL  isAnsi 
)

Definition at line 3352 of file devinst.c.

3359 {
3360  BOOL ret = FALSE;
3361  struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
3362  struct DeviceInfo *deviceInfo;
3363 
3364  TRACE("%s(%p %p %d %p %d)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData, Property,
3366 
3368  {
3370  return FALSE;
3371  }
3372  if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
3373  {
3375  return FALSE;
3376  }
3378  || !DeviceInfoData->Reserved)
3379  {
3381  return FALSE;
3382  }
3383 
3384  deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
3385 
3386  if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
3388  && PropertyMap[Property].nameA)
3389  {
3390  HKEY hKey;
3391  LONG l;
3392  hKey = SETUPDI_OpenDevKey(set->HKLM, deviceInfo, KEY_SET_VALUE);
3393  if (hKey == INVALID_HANDLE_VALUE)
3394  return FALSE;
3395  /* Write new data */
3396  if (isAnsi)
3397  {
3398  l = RegSetValueExA(
3399  hKey, PropertyMap[Property].nameA, 0,
3402  }
3403  else
3404  {
3405  l = RegSetValueExW(
3409  }
3410  if (!l)
3411  ret = TRUE;
3412  else
3413  SetLastError(l);
3414  RegCloseKey(hKey);
3415  }
3416  else
3417  {
3418  ERR("Property 0x%lx not implemented\n", Property);
3420  }
3421 
3422  TRACE("Returning %d\n", ret);
3423  return ret;
3424 }
HKEY SETUPDI_OpenDevKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5835
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define SETUP_DEVICE_INFO_SET_MAGIC
_In_ DWORD _Out_opt_ PDWORD _In_ DWORD PropertyBufferSize
Definition: setupapi.h:1548
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
static struct PropertyMapEntry PropertyMap[]
Definition: devinst.c:3092
ULONG_PTR Reserved
Definition: setupapi.h:833
static const WCHAR nameW[]
Definition: main.c:46
r l[0]
Definition: byte_order.h:167
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
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1523
#define SetLastError(x)
Definition: compat.h:611
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
Definition: wdfdevice.h:4431
#define ERR(fmt,...)
Definition: debug.h:110
FxAutoRegKey hKey
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
Definition: _set.h:46
#define __FUNCTION__
Definition: types.h:112

Referenced by SetupDiSetDeviceRegistryPropertyA(), and SetupDiSetDeviceRegistryPropertyW().

◆ IsDeviceInfoInDeviceInfoSet()

static BOOL IsDeviceInfoInDeviceInfoSet ( struct DeviceInfoSet deviceInfoSet,
struct DeviceInfo deviceInfo 
)
static

Definition at line 4684 of file devinst.c.

4687 {
4689 
4690  ListEntry = deviceInfoSet->ListHead.Flink;
4691  while (ListEntry != &deviceInfoSet->ListHead)
4692  {
4693  if (deviceInfo == CONTAINING_RECORD(ListEntry, struct DeviceInfo, ListEntry))
4694  return TRUE;
4695 
4697  }
4698 
4699  return FALSE;
4700 }
LIST_ENTRY ListHead
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
Definition: typedefs.h:119
LIST_ENTRY ListEntry

Referenced by SetupDiDeleteDeviceInfo().

◆ OpenHardwareProfileKey()

static HKEY OpenHardwareProfileKey ( IN HKEY  HKLM,
IN DWORD  HwProfile,
IN DWORD  samDesired 
)
static

Definition at line 4629 of file devinst.c.

4633 {
4634  HKEY hHWProfilesKey = NULL;
4635  HKEY hHWProfileKey = NULL;
4637  LONG rc;
4638 
4639  rc = RegOpenKeyExW(HKLM,
4641  0,
4642  READ_CONTROL,
4643  &hHWProfilesKey);
4644  if (rc != ERROR_SUCCESS)
4645  {
4646  SetLastError(rc);
4647  goto cleanup;
4648  }
4649  if (HwProfile == 0)
4650  {
4651  rc = RegOpenKeyExW(hHWProfilesKey,
4653  0,
4655  &hHWProfileKey);
4656  }
4657  else
4658  {
4659  WCHAR subKey[5];
4660  snprintfW(subKey, 4, InstanceKeyFormat, HwProfile);
4661  subKey[4] = '\0';
4662  rc = RegOpenKeyExW(hHWProfilesKey,
4663  subKey,
4664  0,
4666  &hHWProfileKey);
4667  }
4668  if (rc != ERROR_SUCCESS)
4669  {
4670  SetLastError(rc);
4671  goto cleanup;
4672  }
4673  ret = hHWProfileKey;
4674 
4675 cleanup:
4676  if (hHWProfilesKey != NULL)
4677  RegCloseKey(hHWProfilesKey);
4678  if (hHWProfileKey != NULL && hHWProfileKey != ret)
4679  RegCloseKey(hHWProfileKey);
4680  return ret;
4681 }
#define snprintfW
Definition: unicode.h:60
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR InstanceKeyFormat[]
Definition: devinst.c:31
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define REGSTR_PATH_HWPROFILES
Definition: regstr.h:482
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
static const WCHAR HKLM[]
Definition: reginf.c:58
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:611
#define READ_CONTROL
Definition: nt_native.h:58
int ret
#define REGSTR_KEY_CURRENT
Definition: regstr.h:493
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
char * cleanup(char *str)
Definition: wpickclick.c:99
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018

Referenced by SetupDiChangeState(), SetupDiCreateDevRegKeyW(), SetupDiDeleteDevRegKey(), and SetupDiOpenDevRegKey().

◆ ResetDevice()

static BOOL ResetDevice ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA  DeviceInfoData 
)
static

Definition at line 5014 of file devinst.c.

5017 {
5018 #ifndef __WINESRC__
5019  struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
5020  struct DeviceInfo *deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
5021  CONFIGRET cr;
5022 
5023  cr = CM_Enable_DevNode_Ex(deviceInfo->dnDevInst, 0, set->hMachine);
5024  if (cr != CR_SUCCESS)
5025  {
5027  return FALSE;
5028  }
5029 
5030  return TRUE;
5031 #else
5032  FIXME("Stub: ResetDevice(%p %p)\n", DeviceInfoSet, DeviceInfoData);
5033  return TRUE;
5034 #endif
5035 }
#define TRUE
Definition: types.h:120
DWORD GetErrorCodeFromCrCode(const IN CONFIGRET cr)
Definition: devinst.c:92
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
#define CR_SUCCESS
Definition: cfgmgr32.h:842
ULONG_PTR Reserved
Definition: setupapi.h:833
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1523
#define SetLastError(x)
Definition: compat.h:611
DEVINST dnDevInst
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
Definition: _set.h:46
CONFIGRET WINAPI CM_Enable_DevNode_Ex(_In_ DEVINST dnDevInst, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:1920

Referenced by SetupDiChangeState(), and SetupDiInstallDevice().

◆ SETUP_CreateClassKey()

HKEY SETUP_CreateClassKey ( HINF  hInf)

Definition at line 3512 of file devinst.c.

3513 {
3514  WCHAR FullBuffer[MAX_PATH];
3517  HKEY hClassKey;
3519 
3520  /* Obtain the Class GUID for this class */
3521  if (!SetupGetLineTextW(NULL,
3522  hInf,
3523  Version,
3525  Buffer,
3526  sizeof(Buffer) / sizeof(WCHAR),
3527  &RequiredSize))
3528  {
3529  return INVALID_HANDLE_VALUE;
3530  }
3531 
3532  /* Build the corresponding registry key name */
3533  lstrcpyW(FullBuffer, REGSTR_PATH_CLASS_NT);
3534  lstrcatW(FullBuffer, BackSlash);
3535  lstrcatW(FullBuffer, Buffer);
3536 
3537  /* Obtain the Class name for this class */
3538  if (!SetupGetLineTextW(NULL,
3539  hInf,
3540  Version,
3542  Buffer,
3543  sizeof(Buffer) / sizeof(WCHAR),
3544  &RequiredSize))
3545  {
3546  return INVALID_HANDLE_VALUE;
3547  }
3548 
3549  /* Try to open or create the registry key */
3550  TRACE("Opening class key %s\n", debugstr_w(FullBuffer));
3551 #if 0 // I keep this for reference...
3553  FullBuffer,
3554  0,
3555  KEY_SET_VALUE,
3556  &hClassKey))
3557  {
3558  /* Use RegCreateKeyExW */
3559  }
3560 #endif
3562  FullBuffer,
3563  0,
3564  NULL,
3566  KEY_SET_VALUE,
3567  NULL,
3568  &hClassKey,
3569  &Disposition))
3570  {
3571  ERR("RegCreateKeyExW(%s) failed\n", debugstr_w(FullBuffer));
3572  return INVALID_HANDLE_VALUE;
3573  }
3575  TRACE("The class key %s was successfully created\n", debugstr_w(FullBuffer));
3576  else
3577  TRACE("The class key %s was successfully opened\n", debugstr_w(FullBuffer));
3578 
3579  TRACE( "setting value %s to %s\n", debugstr_w(REGSTR_VAL_CLASS), debugstr_w(Buffer) );
3582  0,
3583  REG_SZ,
3584  (LPBYTE)Buffer,
3585  RequiredSize * sizeof(WCHAR)))
3586  {
3589  FullBuffer);
3590  return INVALID_HANDLE_VALUE;
3591  }
3592 
3593  return hClassKey;
3594 }
#define REGSTR_VAL_CLASS
Definition: regstr.h:291
#define KEY_SET_VALUE
Definition: nt_native.h:1017
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:50
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define debugstr_w
Definition: kernel32.h:32
HKEY hClassKey
Definition: umpnpmgr.c:45
Definition: bufpool.h:45
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define REGSTR_VAL_CLASSGUID
Definition: regstr.h:422
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:361
#define ERR(fmt,...)
Definition: debug.h:110
#define lstrcpyW
Definition: compat.h:608
#define NULL
Definition: types.h:112
static const WCHAR BackSlash[]
Definition: devinst.c:25
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REGSTR_PATH_CLASS_NT
Definition: regstr.h:479
BOOL WINAPI SetupGetLineTextW(PINFCONTEXT context, HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1756
#define REG_SZ
Definition: layer.c:22

Referenced by SetupDiInstallClassExW().

◆ SETUPAPI_GetCurrentHwProfile()

static DWORD SETUPAPI_GetCurrentHwProfile ( IN HDEVINFO  DeviceInfoSet)
static

Definition at line 4967 of file devinst.c.

4969 {
4970  HKEY hKey = NULL;
4971  DWORD dwRegType, dwLength;
4972  DWORD hwProfile;
4973  LONG rc;
4974  DWORD ret = (DWORD)-1;
4975 
4976  rc = RegOpenKeyExW(((struct DeviceInfoSet *)DeviceInfoSet)->HKLM,
4978  0, /* Options */
4980  &hKey);
4981  if (rc != ERROR_SUCCESS)
4982  {
4983  SetLastError(rc);
4984  goto cleanup;
4985  }
4986 
4987  dwLength = sizeof(DWORD);
4988  rc = RegQueryValueExW(hKey,
4990  NULL,
4991  &dwRegType,
4992  (LPBYTE)&hwProfile, &dwLength);
4993  if (rc != ERROR_SUCCESS)
4994  {
4995  SetLastError(rc);
4996  goto cleanup;
4997  }
4998  else if (dwRegType != REG_DWORD || dwLength != sizeof(DWORD))
4999  {
5001  goto cleanup;
5002  }
5003 
5004  ret = hwProfile;
5005 
5006 cleanup:
5007  if (hKey != NULL)
5008  RegCloseKey(hKey);
5009 
5010  return ret;
5011 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define DWORD
Definition: nt_native.h:44
#define REGSTR_VAL_CURRENTCONFIG
Definition: regstr.h:466
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
long LONG
Definition: pedump.c:60
static const WCHAR HKLM[]
Definition: reginf.c:58
#define REGSTR_PATH_IDCONFIGDB
Definition: regstr.h:41
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
static DWORD DWORD * dwLength
Definition: fusion.c:85
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
int ret
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by SetupDiChangeState().

◆ SETUPDI_CreateDevKey()

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

Definition at line 5665 of file devinst.c.

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

Referenced by SetupDiChangeState(), and SetupDiCreateDevRegKeyW().

◆ SETUPDI_CreateDrvKey()

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

Definition at line 5681 of file devinst.c.

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

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

◆ SETUPDI_DeleteDevKey()

static BOOL SETUPDI_DeleteDevKey ( HKEY  RootKey,
struct DeviceInfo devInfo 
)
static

Definition at line 6012 of file devinst.c.

6013 {
6014  FIXME("\n");
6015  return FALSE;
6016 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

Referenced by SetupDiDeleteDevRegKey().

◆ SETUPDI_DeleteDrvKey()

static BOOL SETUPDI_DeleteDrvKey ( HKEY  RootKey,
struct DeviceInfo devInfo 
)
static

Definition at line 6018 of file devinst.c.

6019 {
6020  FIXME("\n");
6021  return FALSE;
6022 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

Referenced by SetupDiDeleteDevRegKey().

◆ SETUPDI_GuidToString()

static void SETUPDI_GuidToString ( const GUID guid,
LPWSTR  guidStr 
)
static

Definition at line 79 of file devinst.c.

80 {
81  static const WCHAR fmt[] = {'{','%','0','8','X','-','%','0','4','X','-',
82  '%','0','4','X','-','%','0','2','X','%','0','2','X','-','%','0','2',
83  'X','%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','%',
84  '0','2','X','}',0};
85 
86  sprintfW(guidStr, fmt, guid->Data1, guid->Data2, guid->Data3,
87  guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
88  guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
89 }
static WCHAR guidStr[]
Definition: asn.c:531
static GUID guid
Definition: devinst.c:41
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define sprintfW
Definition: unicode.h:58
Definition: dsound.c:943

Referenced by SetupDiCreateDeviceInterfaceRegKeyW(), and SetupDiOpenClassRegKeyExW().

◆ SETUPDI_OpenDevKey()

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

Definition at line 5835 of file devinst.c.

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

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

◆ SETUPDI_OpenDrvKey()

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

Definition at line 5851 of file devinst.c.

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

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

◆ SetupDiBuildClassInfoList()

BOOL WINAPI SetupDiBuildClassInfoList ( DWORD  Flags,
LPGUID  ClassGuidList,
DWORD  ClassGuidListSize,
PDWORD  RequiredSize 
)

Definition at line 643 of file devinst.c.

648 {
649  TRACE("\n");
650  return SetupDiBuildClassInfoListExW(Flags, ClassGuidList,
652  NULL, NULL);
653 }
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1276
#define TRACE(s)
Definition: solgame.cpp:4
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
BOOL WINAPI SetupDiBuildClassInfoListExW(DWORD Flags, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:720
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431

Referenced by test_SetupDiBuildClassInfoList().

◆ SetupDiBuildClassInfoListExA()

BOOL WINAPI SetupDiBuildClassInfoListExA ( DWORD  Flags,
LPGUID  ClassGuidList,
DWORD  ClassGuidListSize,
PDWORD  RequiredSize,
LPCSTR  MachineName,
PVOID  Reserved 
)

Definition at line 673 of file devinst.c.

680 {
681  LPWSTR MachineNameW = NULL;
682  BOOL bResult;
683 
684  TRACE("%s(0x%lx %p %lu %p %s %p)\n", __FUNCTION__, Flags, ClassGuidList,
686 
687  if (MachineName)
688  {
690  if (MachineNameW == NULL) return FALSE;
691  }
692 
693  bResult = SetupDiBuildClassInfoListExW(Flags, ClassGuidList,
695  MachineNameW, Reserved);
696 
697  MyFree(MachineNameW);
698 
699  return bResult;
700 }
#define CP_ACP
Definition: compat.h:109
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
#define FALSE
Definition: types.h:117
LPWSTR WINAPI pSetupMultiByteToUnicode(LPCSTR lpMultiByteStr, UINT uCodePage)
Definition: misc.c:281
unsigned int BOOL
Definition: ntddk_ex.h:94
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1276
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
#define TRACE(s)
Definition: solgame.cpp:4
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define debugstr_a
Definition: kernel32.h:31
BOOL WINAPI SetupDiBuildClassInfoListExW(DWORD Flags, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:720
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define __FUNCTION__
Definition: types.h:112
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128

◆ SetupDiBuildClassInfoListExW()

BOOL WINAPI SetupDiBuildClassInfoListExW ( DWORD  Flags,
LPGUID  ClassGuidList,
DWORD  ClassGuidListSize,
PDWORD  RequiredSize,
LPCWSTR  MachineName,
PVOID  Reserved 
)

Definition at line 720 of file devinst.c.

727 {
728  GUID CurrentClassGuid;
729  HKEY hClassKey;
730  DWORD dwIndex;
731  DWORD dwGuidListIndex = 0;
732  HMACHINE hMachine = NULL;
733  CONFIGRET cr;
734 
735  TRACE("%s(0x%lx %p %lu %p %s %p)\n", __FUNCTION__, Flags, ClassGuidList,
737 
738  if (!RequiredSize)
739  {
741  return FALSE;
742  }
743  else if (!ClassGuidList && ClassGuidListSize > 0)
744  {
746  return FALSE;
747  }
748 
749  if (MachineName)
750  {
751  cr = CM_Connect_MachineW(MachineName, &hMachine);
752  if (cr != CR_SUCCESS)
753  {
755  return FALSE;
756  }
757  }
758 
759  for (dwIndex = 0; ; dwIndex++)
760  {
761  cr = CM_Enumerate_Classes_Ex(dwIndex,
762  &CurrentClassGuid,
763  0,
764  hMachine);
765  if (cr == CR_SUCCESS)
766  {
767  TRACE("Guid: %s\n", debugstr_guid(&CurrentClassGuid));
768  if (CM_Open_Class_Key_ExW(&CurrentClassGuid,
769  NULL,
772  &hClassKey,
774  hMachine) != CR_SUCCESS)
775  {
777  if (hMachine)
778  CM_Disconnect_Machine(hMachine);
779  return FALSE;
780  }
781 
784  NULL,
785  NULL,
786  NULL,
787  NULL))
788  {
789  TRACE("'NoUseClass' value found!\n");
791  continue;
792  }
793 
794  if ((Flags & DIBCI_NOINSTALLCLASS) &&
797  NULL,
798  NULL,
799  NULL,
800  NULL)))
801  {
802  TRACE("'NoInstallClass' value found!\n");
804  continue;
805  }
806 
807  if ((Flags & DIBCI_NODISPLAYCLASS) &&
810  NULL,
811  NULL,
812  NULL,
813  NULL)))
814  {
815  TRACE("'NoDisplayClass' value found!\n");
817  continue;
818  }
819 
821 
822  if (dwGuidListIndex < ClassGuidListSize)
823  {
824  ClassGuidList[dwGuidListIndex] = CurrentClassGuid;
825  }
826 
827  dwGuidListIndex++;
828  }
829 
830  if (cr != ERROR_SUCCESS)
831  break;
832  }
833 
834  if (hMachine)
835  CM_Disconnect_Machine(hMachine);
836 
837  if (RequiredSize != NULL)
838  *RequiredSize = dwGuidListIndex;
839 
840  if (ClassGuidListSize < dwGuidListIndex)
841  {
843  return FALSE;
844  }
845 
846  return TRUE;
847 }
#define CM_OPEN_CLASS_KEY_INSTALLER
Definition: cfgmgr32.h:772
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
CONFIGRET WINAPI CM_Open_Class_Key_ExW(_In_opt_ LPGUID pClassGuid, _In_opt_ LPCWSTR pszClassName, _In_ REGSAM samDesired, _In_ REGDISPOSITION Disposition, _Out_ PHKEY phkClass, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:6284
#define REGSTR_VAL_NOUSECLASS
Definition: regstr.h:238
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
CONFIGRET WINAPI CM_Disconnect_Machine(_In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:1856
DWORD GetErrorCodeFromCrCode(const IN CONFIGRET cr)
Definition: devinst.c:92
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
CONFIGRET WINAPI CM_Enumerate_Classes_Ex(_In_ ULONG ulClassIndex, _Out_ LPGUID ClassGuid, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:2002
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
#define debugstr_w
Definition: kernel32.h:32
#define CR_SUCCESS
Definition: cfgmgr32.h:842
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1276
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
HKEY hClassKey
Definition: umpnpmgr.c:45
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
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
CONFIGRET WINAPI CM_Connect_MachineW(_In_opt_ PCWSTR UNCServerName, _Out_ PHMACHINE phMachine)
Definition: cfgmgr.c:1234
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define DIBCI_NODISPLAYCLASS
Definition: setupapi.h:109
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define DIBCI_NOINSTALLCLASS
Definition: setupapi.h:108
#define NULL
Definition: types.h:112
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define REGSTR_VAL_NOINSTALLCLASS
Definition: regstr.h:239
#define REGSTR_VAL_NODISPLAYCLASS
Definition: regstr.h:240
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
#define __FUNCTION__
Definition: types.h:112
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define RegDisposition_OpenExisting
Definition: cfgmgr32.h:610

Referenced by SetupDiBuildClassInfoList(), SetupDiBuildClassInfoListExA(), and SetupDiGetClassImageListExW().

◆ SetupDiCallClassInstaller()

BOOL WINAPI SetupDiCallClassInstaller ( DI_FUNCTION  InstallFunction,
HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData 
)

Definition at line 4018 of file devinst.c.

4022 {
4023  BOOL ret = FALSE;
4024 
4025  TRACE("%s(%u %p %p)\n", __FUNCTION__, InstallFunction, DeviceInfoSet, DeviceInfoData);
4026 
4027  if (!DeviceInfoSet)
4033  else if (((struct DeviceInfoSet *)DeviceInfoSet)->HKLM != HKEY_LOCAL_MACHINE)
4035  else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
4037  else
4038  {
4040 #define CLASS_COINSTALLER 0x1
4041 #define DEVICE_COINSTALLER 0x2
4042 #define CLASS_INSTALLER 0x4
4043  UCHAR CanHandle = 0;
4045 
4046  switch (InstallFunction)
4047  {
4050  break;
4053  break;
4054  case DIF_ALLOW_INSTALL:
4055  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4056  break;
4057  case DIF_DETECT:
4058  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4059  break;
4061  CanHandle = CLASS_INSTALLER;
4062  break;
4063  case DIF_INSTALLDEVICE:
4066  break;
4068  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4070  break;
4071  case DIF_INSTALLINTERFACES:
4074  break;
4077  break;
4079  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4080  break;
4082  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4083  break;
4085  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4086  break;
4088  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4089  break;
4090  case DIF_POWERMESSAGEWAKE:
4092  break;
4093  case DIF_PROPERTYCHANGE:
4096  break;
4098  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4100  break;
4101  case DIF_REGISTERDEVICE:
4102  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4104  break;
4105  case DIF_REMOVE:
4108  break;
4110  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4112  break;
4113  case DIF_SELECTDEVICE:
4114  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4116  break;
4117  case DIF_TROUBLESHOOTER:
4119  break;
4120  case DIF_UNREMOVE:
4123  break;
4124  default:
4125  ERR("Install function %u not supported\n", InstallFunction);
4127  }
4128 
4131  /* Don't process this call, as a parameter is invalid */
4132  CanHandle = 0;
4133 
4134  if (CanHandle != 0)
4135  {
4136  LIST_ENTRY ClassCoInstallersListHead;
4137  LIST_ENTRY DeviceCoInstallersListHead;
4138  HMODULE ClassInstallerLibrary = NULL;
4139  CLASS_INSTALL_PROC ClassInstaller = NULL;
4142  HKEY hKey;
4143  DWORD dwRegType, dwLength;
4144  DWORD rc = NO_ERROR;
4145 
4146  InitializeListHead(&ClassCoInstallersListHead);
4147  InitializeListHead(&DeviceCoInstallersListHead);
4148 
4149  if (CanHandle & DEVICE_COINSTALLER)
4150  {
4152  if (hKey != INVALID_HANDLE_VALUE)
4153  {
4155  if (rc == ERROR_SUCCESS && dwRegType == REG_MULTI_SZ)
4156  {
4157  LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
4158  if (KeyBuffer != NULL)
4159  {
4161  if (rc == ERROR_SUCCESS)
4162  {
4163  LPWSTR ptr;
4164  for (ptr = KeyBuffer; *ptr; ptr += strlenW(ptr) + 1)
4165  {
4166  /* Add coinstaller to DeviceCoInstallersListHead list */
4167  struct CoInstallerElement *coinstaller;
4168  TRACE("Got device coinstaller '%s'\n", debugstr_w(ptr));
4169  coinstaller = HeapAlloc(GetProcessHeap(), 0, sizeof(struct CoInstallerElement));
4170  if (!coinstaller)
4171  continue;
4172  ZeroMemory(coinstaller, sizeof(struct CoInstallerElement));
4173  if (GetFunctionPointer(ptr, &coinstaller->Module, (PVOID*)&coinstaller->Function) == ERROR_SUCCESS)
4174  InsertTailList(&DeviceCoInstallersListHead, &coinstaller->ListEntry);
4175  else
4176  HeapFree(GetProcessHeap(), 0, coinstaller);
4177  }
4178  }
4179  HeapFree(GetProcessHeap(), 0, KeyBuffer);
4180  }
4181  }
4182  RegCloseKey(hKey);
4183  }
4184  }
4185  if (CanHandle & CLASS_COINSTALLER)
4186  {
4187  rc = RegOpenKeyExW(
4190  0, /* Options */
4192  &hKey);
4193  if (rc == ERROR_SUCCESS)
4194  {
4195  WCHAR szGuidString[40];
4196  if (pSetupStringFromGuid(&DeviceInfoData->ClassGuid, szGuidString, ARRAYSIZE(szGuidString)) == ERROR_SUCCESS)
4197  {
4198  rc = RegQueryValueExW(hKey, szGuidString, NULL, &dwRegType, NULL, &dwLength);
4199  if (rc == ERROR_SUCCESS && dwRegType == REG_MULTI_SZ)
4200  {
4201  LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
4202  if (KeyBuffer != NULL)
4203  {
4204  rc = RegQueryValueExW(hKey, szGuidString, NULL, NULL, (LPBYTE)KeyBuffer, &dwLength);
4205  if (rc == ERROR_SUCCESS)
4206  {
4207  LPWSTR ptr;
4208  for (ptr = KeyBuffer; *ptr; ptr += strlenW(ptr) + 1)
4209  {
4210  /* Add coinstaller to ClassCoInstallersListHead list */
4211  struct CoInstallerElement *coinstaller;
4212  TRACE("Got class coinstaller '%s'\n", debugstr_w(ptr));
4213  coinstaller = HeapAlloc(GetProcessHeap(), 0, sizeof(struct CoInstallerElement));
4214  if (!coinstaller)
4215  continue;
4216  ZeroMemory(coinstaller, sizeof(struct CoInstallerElement));
4217  if (GetFunctionPointer(ptr, &coinstaller->Module, (PVOID*)&coinstaller->Function) == ERROR_SUCCESS)
4218  InsertTailList(&ClassCoInstallersListHead, &coinstaller->ListEntry);
4219  else
4220  HeapFree(GetProcessHeap(), 0, coinstaller);
4221  }
4222  }
4223  HeapFree(GetProcessHeap(), 0, KeyBuffer);
4224  }
4225  }
4226  }
4227  RegCloseKey(hKey);
4228  }
4229  }
4230  if ((CanHandle & CLASS_INSTALLER) && !(InstallParams.FlagsEx & DI_FLAGSEX_CI_FAILED))
4231  {
4233  if (hKey != INVALID_HANDLE_VALUE)
4234  {
4236  if (rc == ERROR_SUCCESS && dwRegType == REG_SZ)
4237  {
4238  LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
4239  if (KeyBuffer != NULL)
4240  {
4242  if (rc == ERROR_SUCCESS)
4243  {
4244  /* Get ClassInstaller function pointer */
4245  TRACE("Got class installer '%s'\n", debugstr_w(KeyBuffer));
4246  if (GetFunctionPointer(KeyBuffer, &ClassInstallerLibrary, (PVOID*)&ClassInstaller) != ERROR_SUCCESS)
4247  {
4248  InstallParams.FlagsEx |= DI_FLAGSEX_CI_FAILED;
4250  }
4251  }
4252  HeapFree(GetProcessHeap(), 0, KeyBuffer);
4253  }
4254  }
4255  RegCloseKey(hKey);
4256  }
4257  }
4258 
4259  /* Call Class co-installers */
4260  Context.PostProcessing = FALSE;
4261  rc = NO_ERROR;
4262  ListEntry = ClassCoInstallersListHead.Flink;
4263  while (rc == NO_ERROR && ListEntry != &ClassCoInstallersListHead)
4264  {
4265  struct CoInstallerElement *coinstaller;
4266  coinstaller = CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry);
4267  rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4268  coinstaller->PrivateData = Context.PrivateData;
4270  {
4271  coinstaller->DoPostProcessing = TRUE;
4272  rc = NO_ERROR;
4273  }
4275  }
4276 
4277  /* Call Device co-installers */
4278  ListEntry = DeviceCoInstallersListHead.Flink;
4279  while (rc == NO_ERROR && ListEntry != &DeviceCoInstallersListHead)
4280  {
4281  struct CoInstallerElement *coinstaller;
4282  coinstaller = CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry);
4283  rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4284  coinstaller->PrivateData = Context.PrivateData;
4286  {
4287  coinstaller->DoPostProcessing = TRUE;
4288  rc = NO_ERROR;
4289  }
4291  }
4292 
4293  /* Call Class installer */
4294  if (ClassInstaller)
4295  {
4296  rc = (*ClassInstaller)(InstallFunction, DeviceInfoSet, DeviceInfoData);
4297  FreeFunctionPointer(ClassInstallerLibrary, ClassInstaller);
4298  }
4299  else
4300  rc = ERROR_DI_DO_DEFAULT;
4301 
4302  /* Call default handler */
4303  if (rc == ERROR_DI_DO_DEFAULT)
4304  {
4305  if (DefaultHandler && !(InstallParams.Flags & DI_NODI_DEFAULTACTION))
4306  {
4308  rc = NO_ERROR;
4309  else
4310  rc = GetLastError();
4311  }
4312  else
4313  rc = NO_ERROR;
4314  }
4315 
4316  /* Call Class co-installers that required postprocessing */
4317  Context.PostProcessing = TRUE;
4318  ListEntry = ClassCoInstallersListHead.Flink;
4319  while (ListEntry != &ClassCoInstallersListHead)
4320  {
4321  struct CoInstallerElement *coinstaller;
4322  coinstaller = CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry);
4323  if (coinstaller->DoPostProcessing)
4324  {
4325  Context.InstallResult = rc;
4326  Context.PrivateData = coinstaller->PrivateData;
4327  rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4328  }
4329  FreeFunctionPointer(coinstaller->Module, coinstaller->Function);
4331  }
4332 
4333  /* Call Device co-installers that required postprocessing */
4334  ListEntry = DeviceCoInstallersListHead.Flink;
4335  while (ListEntry != &DeviceCoInstallersListHead)
4336  {
4337  struct CoInstallerElement *coinstaller;
4338  coinstaller = CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry);
4339  if (coinstaller->DoPostProcessing)
4340  {
4341  Context.InstallResult = rc;
4342  Context.PrivateData = coinstaller->PrivateData;
4343  rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4344  }
4345  FreeFunctionPointer(coinstaller->Module, coinstaller->Function);
4347  }
4348 
4349  /* Free allocated memory */
4350  while (!IsListEmpty(&ClassCoInstallersListHead))
4351  {
4352  ListEntry = RemoveHeadList(&ClassCoInstallersListHead);
4354  }
4355  while (!IsListEmpty(&DeviceCoInstallersListHead))
4356  {
4357  ListEntry = RemoveHeadList(&DeviceCoInstallersListHead);
4359  }
4360 
4361  ret = (rc == NO_ERROR);
4362  }
4363  }
4364 
4365  TRACE("Returning %d\n", ret);
4366  return ret;
4367 }
#define DIF_SELECTDEVICE
Definition: setupapi.h:120
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
BOOL WINAPI SetupDiSelectBestCompatDrv(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
Definition: driver.c:2057
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI SetupDiSetDeviceInstallParamsW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
Definition: devinst.c:4552
#define TRUE
Definition: types.h:120
#define DIF_ADDREMOTEPROPERTYPAGE_ADVANCED
Definition: setupapi.h:159
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
u32_t magic(void)
HMODULE Module
Definition: devinst.c:61
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ZeroMemory
Definition: winbase.h:1664
BOOL WINAPI SetupDiUnremoveDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: stubs.c:96
#define REGSTR_PATH_CODEVICEINSTALLERS
Definition: regstr.h:480
#define DIF_NEWDEVICEWIZARD_PREANALYZE
Definition: setupapi.h:147
LIST_ENTRY ListEntry
Definition: devinst.c:59
SP_DEVINSTALL_PARAMS_W InstallParams
#define DIF_PROPERTYCHANGE
Definition: setupapi.h:137
#define InsertTailList(ListHead, Entry)
#define NO_ERROR
Definition: dderror.h:5
#define DIF_UNREMOVE
Definition: setupapi.h:141
#define DIF_NEWDEVICEWIZARD_POSTANALYZE
Definition: setupapi.h:148
#define DIF_DESTROYPRIVATEDATA
Definition: setupapi.h:131
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define SETUP_DEVICE_INFO_SET_MAGIC
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
COINSTALLER_PROC Function
Definition: devinst.c:62
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL DoPostProcessing
Definition: devinst.c:63
#define DIF_REGISTERDEVICE
Definition: setupapi.h:144
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define debugstr_w
Definition: kernel32.h:32
#define REGSTR_VAL_INSTALLER_32
Definition: regstr.h:487
BOOL WINAPI SetupDiInstallDevice(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5359
static PVOID ptr
Definition: dispmode.c:27
BOOL WINAPI SetupDiGetDeviceInstallParamsW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, OUT PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
Definition: devinst.c:4445
static BOOL WINAPI IntSetupDiRegisterDeviceInfo(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:4008
#define DIF_REGISTER_COINSTALLERS
Definition: setupapi.h:153
#define DIF_ADDPROPERTYPAGE_ADVANCED
Definition: setupapi.h:154
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
#define DIF_NEWDEVICEWIZARD_FINISHINSTALL
Definition: setupapi.h:149
#define DIF_NEWDEVICEWIZARD_SELECT
Definition: setupapi.h:146
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
ULONG_PTR Reserved
Definition: setupapi.h:833
PVOID PrivateData
Definition: devinst.c:64
static const WCHAR HKLM[]
Definition: reginf.c:58
#define DIF_INSTALLDEVICE
Definition: setupapi.h:121
DWORD(CALLBACK * CLASS_INSTALL_PROC)(IN DI_FUNCTION InstallFunction, IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
Definition: devinst.c:42
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TRACE(s)
Definition: solgame.cpp:4
#define DI_NODI_DEFAULTACTION
Definition: setupapi.h:67
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:85
DWORD FreeFunctionPointer(IN HMODULE ModulePointer, IN PVOID FunctionPointer)
Definition: misc.c:105
DWORD GetFunctionPointer(IN PWSTR InstallerName, OUT HMODULE *ModulePointer, OUT PVOID *FunctionPointer)
Definition: misc.c:44
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1523
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DIF_TROUBLESHOOTER
Definition: setupapi.h:157
#define SetLastError(x)
Definition: compat.h:611
DWORD WINAPI pSetupStringFromGuid(LPGUID lpGUID, PWSTR pString, DWORD dwStringLen)
Definition: misc.c:1775
BOOL WINAPI SetupDiRegisterCoDeviceInstallers(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5205
unsigned char UCHAR
Definition: xmlstorage.h:181
int ret
BOOL(WINAPI * DEFAULT_CLASS_INSTALL_PROC)(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:47
#define DIF_POWERMESSAGEWAKE
Definition: setupapi.h:158
BOOL WINAPI SetupDiChangeState(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5065
Definition: typedefs.h:119
HKEY SETUPDI_OpenDrvKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5851
#define ERR(fmt,...)
Definition: debug.h:110
#define DIF_INSTALLINTERFACES
Definition: setupapi.h:151
BOOL WINAPI SetupDiSelectDevice(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
Definition: devinst.c:5191
FxAutoRegKey hKey
BOOL WINAPI SetupDiRemoveDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: stubs.c:82
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
BOOL WINAPI SetupDiInstallDeviceInterfaces(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: interface.c:414
#define DI_FLAGSEX_CI_FAILED
Definition: setupapi.h:79
#define NULL
Definition: types.h:112
#define DEVICE_COINSTALLER
struct _SP_DEVINSTALL_PARAMS_W SP_DEVINSTALL_PARAMS_W
LIST_ENTRY ListEntry
#define ERROR_DI_DO_DEFAULT
Definition: setupapi.h:305
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
#define CLASS_INSTALLER
struct tagContext Context
Definition: acpixf.h:1034
#define DIF_ALLOW_INSTALL
Definition: setupapi.h:143
#define DIF_REMOVE
Definition: setupapi.h:124
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define DIF_NEWDEVICEWIZARD_PRESELECT
Definition: setupapi.h:145
#define DIF_SELECTBESTCOMPATDRV
Definition: setupapi.h:142
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define DIF_DETECT
Definition: setupapi.h:134
#define ERROR_DI_POSTPROCESSING_REQUIRED
Definition: setupapi.h:329
BOOL WINAPI SetupDiInstallDriverFiles(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: driver.c:2093
#define DIF_INSTALLDEVICEFILES
Definition: setupapi.h:140
#define REGSTR_VAL_COINSTALLERS_32
Definition: regstr.h:484
#define __FUNCTION__
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:594
HKEY WINAPI SetupDiOpenClassRegKey(const GUID *ClassGuid, REGSAM samDesired)
Definition: devinst.c:3612
#define CLASS_COINSTALLER
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by CNetConnection::Disconnect(), DisplayDeviceAdvancedProperties(), CDeviceNode::EnableDevice(), EnableDevice(), EnumerateDrivers(), InstallCurrentDriver(), InstallSoftwareBusPnpEnumerator(), SETUP_CallInstaller(), StartDevice(), CDeviceNode::UninstallDevice(), UninstallDriver(), UpdateDevInfo(), UpdateDriverDetailsDlg(), and WritePortSettings().

◆ SetupDiChangeState()

BOOL WINAPI SetupDiChangeState ( IN HDEVINFO  DeviceInfoSet,
IN OUT PSP_DEVINFO_DATA  DeviceInfoData 
)

Definition at line 5065 of file devinst.c.

5068 {
5069  struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
5070  struct DeviceInfo *deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
5071  PSP_PROPCHANGE_PARAMS PropChange;
5073  LPCWSTR RegistryValueName;
5074  DWORD dwConfigFlags, dwLength, dwRegType;
5075  LONG rc;
5076  BOOL ret = FALSE;
5077 
5078  TRACE("%s(%p %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData);
5079 
5080  if (!DeviceInfoData)
5081  PropChange = ((struct DeviceInfoSet *)DeviceInfoSet)->ClassInstallParams.PropChangeParams;
5082  else
5083  PropChange = ((struct DeviceInfo *)DeviceInfoData->Reserved)->ClassInstallParams.PropChangeParams;
5084  if (!PropChange)
5085  {
5087  goto cleanup;
5088  }
5089 
5090  if (PropChange->Scope == DICS_FLAG_GLOBAL)
5091  RegistryValueName = REGSTR_VAL_CONFIGFLAGS;
5092  else
5093  RegistryValueName = REGSTR_VAL_CSCONFIGFLAGS;
5094 
5095  switch (PropChange->StateChange)
5096  {
5097  case DICS_ENABLE:
5098  case DICS_DISABLE:
5099  {
5100  if (PropChange->Scope == DICS_FLAG_GLOBAL)
5101  hRootKey = set->HKLM;
5102  else /* PropChange->Scope == DICS_FLAG_CONFIGSPECIFIC */
5103  {
5104  hRootKey = OpenHardwareProfileKey(set->HKLM, PropChange->HwProfile, KEY_CREATE_SUB_KEY);
5105  if (hRootKey == INVALID_HANDLE_VALUE)
5106  goto cleanup;
5107  }
5108 
5109  /* Enable/disable device in registry */
5110  hKey = SETUPDI_OpenDrvKey(hRootKey, deviceInfo, KEY_QUERY_VALUE | KEY_SET_VALUE);
5112  hKey = SETUPDI_CreateDevKey(hRootKey, deviceInfo, KEY_QUERY_VALUE | KEY_SET_VALUE);
5113  if (hKey == INVALID_HANDLE_VALUE)
5114  break;
5115  dwLength = sizeof(DWORD);
5116  rc = RegQueryValueExW(
5117  hKey,
5118  RegistryValueName,
5119  NULL,
5120  &dwRegType,
5121  (LPBYTE)&dwConfigFlags, &dwLength);
5122  if (rc == ERROR_FILE_NOT_FOUND)
5123  dwConfigFlags = 0;
5124  else if (rc != ERROR_SUCCESS)
5125  {
5126  SetLastError(rc);
5127  goto cleanup;
5128  }
5129  else if (dwRegType != REG_DWORD || dwLength != sizeof(DWORD))
5130  {
5132  goto cleanup;
5133  }
5134  if (PropChange->StateChange == DICS_ENABLE)
5135  dwConfigFlags &= ~(PropChange->Scope == DICS_FLAG_GLOBAL ? CONFIGFLAG_DISABLED : CSCONFIGFLAG_DISABLED);
5136  else
5137  dwConfigFlags |= (PropChange->Scope == DICS_FLAG_GLOBAL ? CONFIGFLAG_DISABLED : CSCONFIGFLAG_DISABLED);
5138  rc = RegSetValueExW(
5139  hKey,
5140  RegistryValueName,
5141  0,
5142  REG_DWORD,
5143  (LPBYTE)&dwConfigFlags, sizeof(DWORD));
5144  if (rc != ERROR_SUCCESS)
5145  {
5146  SetLastError(rc);
5147  goto cleanup;
5148  }
5149 
5150  /* Enable/disable device if needed */
5151  if (PropChange->Scope == DICS_FLAG_GLOBAL
5152  || PropChange->HwProfile == 0
5153  || PropChange->HwProfile == SETUPAPI_GetCurrentHwProfile(DeviceInfoSet))
5154  {
5155  if (PropChange->StateChange == DICS_ENABLE)
5157  else
5159  }
5160  else
5161  ret = TRUE;
5162  break;
5163  }
5164  case DICS_PROPCHANGE:
5165  {
5167  break;
5168  }
5169  default:
5170  {
5171  ERR("Unknown StateChange 0x%lx\n", PropChange->StateChange);
5173  }
5174  }
5175 
5176 cleanup:
5177  if (hRootKey != INVALID_HANDLE_VALUE && hRootKey != set->HKLM)
5178  RegCloseKey(hRootKey);
5179 
5180  if (hKey != INVALID_HANDLE_VALUE)
5181  RegCloseKey(hKey);
5182 
5183  TRACE("Returning %d\n", ret);
5184  return ret;
5185 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TRUE
Definition: types.h:120
static DWORD SETUPAPI_GetCurrentHwProfile(IN HDEVINFO DeviceInfoSet)
Definition: devinst.c:4967
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define REGSTR_VAL_CONFIGFLAGS
Definition: regstr.h:388
#define CSCONFIGFLAG_DISABLED
Definition: regstr.h:401
#define DICS_ENABLE
Definition: setupapi.h:112
#define DWORD
Definition: nt_native.h:44
#define REGSTR_VAL_CSCONFIGFLAGS
Definition: regstr.h:389
HKEY SETUPDI_CreateDevKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5665
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define DICS_DISABLE
Definition: setupapi.h:114
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
ULONG_PTR Reserved
Definition: setupapi.h:833
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 CONFIGFLAG_DISABLED
Definition: regstr.h:390
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
static DWORD DWORD * dwLength
Definition: fusion.c:85
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1523
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
static HKEY OpenHardwareProfileKey(IN HKEY HKLM, IN DWORD HwProfile, IN DWORD samDesired)
Definition: devinst.c:4629
int ret
HKEY SETUPDI_OpenDrvKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5851
#define ERR(fmt,...)
Definition: debug.h:110
#define DICS_FLAG_GLOBAL
Definition: setupapi.h:113
#define DICS_PROPCHANGE
Definition: setupapi.h:116
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
Definition: _set.h:46
#define __FUNCTION__
Definition: types.h:112
#define REG_DWORD
Definition: sdbapi.c:596
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
static BOOL StopDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5038
static BOOL ResetDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5014

Referenced by CDeviceNode::EnableDevice(), and SetupDiCallClassInstaller().

◆ SetupDiClassGuidsFromNameA()

BOOL WINAPI SetupDiClassGuidsFromNameA ( LPCSTR  ClassName,
LPGUID  ClassGuidList,
DWORD  ClassGuidListSize,
PDWORD  RequiredSize 
)

Definition at line 852 of file devinst.c.

857 {
858  return SetupDiClassGuidsFromNameExA(ClassName, ClassGuidList,
860  NULL, NULL);
861 }
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1276
BOOL WINAPI SetupDiClassGuidsFromNameExA(LPCSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCSTR MachineName, PVOID Reserved)
Definition: devinst.c:880
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431

Referenced by test_SetupDiClassGuidsFromNameA().

◆ SetupDiClassGuidsFromNameExA()

BOOL WINAPI SetupDiClassGuidsFromNameExA ( LPCSTR  ClassName,
LPGUID  ClassGuidList,
DWORD  ClassGuidListSize,
PDWORD  RequiredSize,
LPCSTR  MachineName,
PVOID  Reserved 
)

Definition at line 880 of file devinst.c.

887 {
888  LPWSTR ClassNameW = NULL;
889  LPWSTR MachineNameW = NULL;
890  BOOL bResult;
891 
892  TRACE("%s(%s %p %lu %p %s %p)\n", __FUNCTION__, debugstr_a(ClassName), ClassGuidList,
894 
895  if (!ClassName)
896  {
898  return FALSE;
899  }
900 
901  ClassNameW = pSetupMultiByteToUnicode(ClassName, CP_ACP);
902  if (ClassNameW == NULL)
903  return FALSE;
904 
905  if (MachineName)
906  {
908  if (MachineNameW == NULL)
909  {
910  MyFree(ClassNameW);
911  return FALSE;
912  }
913  }
914 
915  bResult = SetupDiClassGuidsFromNameExW(ClassNameW, ClassGuidList,
917  MachineNameW, Reserved);
918 
919  MyFree(MachineNameW);
920  MyFree(ClassNameW);
921 
922  return bResult;
923 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:109
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
#define FALSE
Definition: types.h:117
LPWSTR WINAPI pSetupMultiByteToUnicode(LPCSTR lpMultiByteStr, UINT uCodePage)
Definition: misc.c:281
unsigned int BOOL
Definition: ntddk_ex.h:94
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1276
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define SetLastError(x)
Definition: compat.h:611
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define __FUNCTION__
Definition: types.h:112
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
BOOL WINAPI SetupDiClassGuidsFromNameExW(LPCWSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:928

Referenced by SetupDiClassGuidsFromNameA().

◆ SetupDiClassGuidsFromNameExW()

BOOL WINAPI SetupDiClassGuidsFromNameExW ( LPCWSTR  ClassName,
LPGUID  ClassGuidList,
DWORD  ClassGuidListSize,
PDWORD  RequiredSize,
LPCWSTR  MachineName,
PVOID  Reserved 
)

Definition at line 928 of file devinst.c.

935 {
936  WCHAR szKeyName[40];
938  HKEY hClassesKey;
939  HKEY hClassKey;
940  DWORD dwLength;
941  DWORD dwIndex;
942  LONG lError;
943  DWORD dwGuidListIndex = 0;
944 
945  TRACE("%s(%s %p %lu %p %s %p)\n", __FUNCTION__, debugstr_w(ClassName), ClassGuidList,
947 
948  if (!ClassName || !RequiredSize)
949  {
951  return FALSE;
952  }
953  if (!ClassGuidList && ClassGuidListSize > 0)
954  {
956  return FALSE;
957  }
958  *RequiredSize = 0;
959 
960  hClassesKey = SetupDiOpenClassRegKeyExW(NULL,
963  MachineName,
964  Reserved);
965  if (hClassesKey == INVALID_HANDLE_VALUE)
966  {
967  return FALSE;
968  }
969 
970  for (dwIndex = 0; ; dwIndex++)
971  {
972  dwLength = 40;
973  lError = RegEnumKeyExW(hClassesKey,
974  dwIndex,
975  szKeyName,
976  &dwLength,
977  NULL,
978  NULL,
979  NULL,
980  NULL);
981  TRACE("RegEnumKeyExW() returns %d\n", lError);
982  if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA)
983  {
984  TRACE("Key name: %p\n", szKeyName);
985 
986  if (RegOpenKeyExW(hClassesKey,
987  szKeyName,
988  0,
990  &hClassKey))
991  {
992  RegCloseKey(hClassesKey);
993  return FALSE;
994  }
995 
996  dwLength = MAX_CLASS_NAME_LEN * sizeof(WCHAR);
999  NULL,
1000  NULL,
1002  &dwLength))
1003  {
1004  TRACE("Class name: %p\n", szClassName);
1005 
1006  if (strcmpiW(szClassName, ClassName) == 0)
1007  {
1008  TRACE("Found matching class name\n");
1009 
1010  TRACE("Guid: %p\n", szKeyName);
1011  if (dwGuidListIndex < ClassGuidListSize)
1012  {
1013  if (szKeyName[0] == '{' && szKeyName[37] == '}')
1014  {
1015  szKeyName[37] = 0;
1016  }
1017  TRACE("Guid: %p\n", &szKeyName[1]);
1018 
1019  UuidFromStringW(&szKeyName[1],
1020  &ClassGuidList[dwGuidListIndex]);
1021  }
1022 
1023  dwGuidListIndex++;
1024  }
1025  }
1026 
1028  }
1029 
1030  if (lError != ERROR_SUCCESS)
1031  break;
1032  }
1033 
1034  RegCloseKey(hClassesKey);
1035 
1036  if (RequiredSize != NULL)
1037  *RequiredSize = dwGuidListIndex;
1038 
1039  if (ClassGuidListSize < dwGuidListIndex)
1040  {
1042  return FALSE;
1043  }
1044 
1045  return TRUE;
1046 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define REGSTR_VAL_CLASS
Definition: regstr.h:291
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
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
#define DIOCR_INSTALLER
Definition: setupapi.h:176
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1276
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
HKEY hClassKey
Definition: umpnpmgr.c:45
#define TRACE(s)
Definition: solgame.cpp:4
static const WCHAR szClassName[]
Definition: clipbrd.c:11
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:85
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
HKEY WINAPI SetupDiOpenClassRegKeyExW(const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:3656
#define MAX_CLASS_NAME_LEN
Definition: cfgmgr32.h:52
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
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 __FUNCTION__
Definition: types.h:112
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by SetupDiClassGuidsFromNameExA(), and SetupDiClassGuidsFromNameW().

◆ SetupDiClassGuidsFromNameW()

BOOL WINAPI SetupDiClassGuidsFromNameW ( LPCWSTR  ClassName,
LPGUID  ClassGuidList,
DWORD  ClassGuidListSize,
PDWORD  RequiredSize 
)

Definition at line 866 of file devinst.c.

871 {
872  return SetupDiClassGuidsFromNameExW(ClassName, ClassGuidList,
874  NULL, NULL);
875 }
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1276
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
BOOL WINAPI SetupDiClassGuidsFromNameExW(LPCWSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:928

◆ SetupDiClassNameFromGuidA()

BOOL WINAPI SetupDiClassNameFromGuidA ( const GUID ClassGuid,
PSTR  ClassName,
DWORD  ClassNameSize,
PDWORD  RequiredSize 
)

Definition at line 1051 of file devinst.c.

1056 {
1057  return SetupDiClassNameFromGuidExA(ClassGuid, ClassName,
1058  ClassNameSize, RequiredSize,
1059  NULL, NULL);
1060 }
BOOL WINAPI SetupDiClassNameFromGuidExA(const GUID *ClassGuid, PSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize, PCSTR MachineName, PVOID Reserved)
Definition: devinst.c:1079
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431

Referenced by test_SetupDiBuildClassInfoList(), and test_SetupDiClassNameFromGuidA().

◆ SetupDiClassNameFromGuidExA()

BOOL WINAPI SetupDiClassNameFromGuidExA ( const GUID ClassGuid,
PSTR  ClassName,
DWORD  ClassNameSize,
PDWORD  RequiredSize,
PCSTR  MachineName,
PVOID  Reserved 
)

Definition at line 1079 of file devinst.c.

1086 {
1087  WCHAR ClassNameW[MAX_CLASS_NAME_LEN];
1088  LPWSTR MachineNameW = NULL;
1089  BOOL ret;
1090 
1091  if (MachineName)
1092  MachineNameW = pSetupMultiByteToUnicode(MachineName, CP_ACP);
1094  RequiredSize, MachineNameW, Reserved);
1095  if (ret)
1096  {
1097  int len = WideCharToMultiByte(CP_ACP, 0, ClassNameW, -1, ClassName,
1098  ClassNameSize, NULL, NULL);
1099  if (len == 0 || len > ClassNameSize)
1100  {
1102  ret = FALSE;
1103  }
1104  }
1105  MyFree(MachineNameW);
1106  return ret;
1107 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
BOOL WINAPI SetupDiClassNameFromGuidExW(const GUID *ClassGuid, PWSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:1112
#define FALSE
Definition: types.h:117
LPWSTR WINAPI pSetupMultiByteToUnicode(LPCSTR lpMultiByteStr, UINT uCodePage)
Definition: misc.c:281
unsigned int BOOL
Definition: ntddk_ex.h:94
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:611
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define NULL
Definition: types.h:112
#define MAX_CLASS_NAME_LEN
Definition: cfgmgr32.h:52
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
WCHAR * LPWSTR
Definition: xmlstorage.h:184
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by SetupDiClassNameFromGuidA().

◆ SetupDiClassNameFromGuidExW()

BOOL WINAPI SetupDiClassNameFromGuidExW ( const GUID ClassGuid,
PWSTR  ClassName,
DWORD  ClassNameSize,
PDWORD  RequiredSize,
PCWSTR  MachineName,
PVOID  Reserved 
)

Definition at line 1112 of file devinst.c.

1119 {
1120  HKEY hKey;
1121  DWORD dwLength;
1122  DWORD dwRegType;
1123  LONG rc;
1124  PWSTR Buffer;
1125 
1126  TRACE("%s(%s %p %lu %p %s %p)\n", __FUNCTION__, debugstr_guid(ClassGuid), ClassName,
1127  ClassNameSize, RequiredSize, debugstr_w(MachineName), Reserved);
1128 
1129  /* Make sure there's a GUID */
1130  if (ClassGuid == NULL)
1131  {
1132  SetLastError(ERROR_INVALID_CLASS); /* On Vista: ERROR_INVALID_USER_BUFFER */
1133  return FALSE;
1134  }
1135 
1136  /* Make sure there's a real buffer when there's a size */
1137  if ((ClassNameSize > 0) && (ClassName == NULL))
1138  {
1139  SetLastError(ERROR_INVALID_PARAMETER); /* On Vista: ERROR_INVALID_USER_BUFFER */
1140  return FALSE;
1141  }
1142 
1143  /* Open the key for the GUID */
1145 
1146  if (hKey == INVALID_HANDLE_VALUE)
1147  return FALSE;
1148 
1149  /* Retrieve the class name data and close the key */
1150  rc = QueryRegistryValue(hKey, REGSTR_VAL_CLASS, (LPBYTE *) &Buffer, &dwRegType, &dwLength);
1151  RegCloseKey(hKey);
1152 
1153  /* Make sure we got the data */
1154  if (rc != ERROR_SUCCESS)
1155  {
1156  SetLastError(rc);
1157  return FALSE;
1158  }
1159 
1160  /* Make sure the data is a string */
1161  if (dwRegType != REG_SZ)
1162  {
1163  MyFree(Buffer);
1165  return FALSE;
1166  }
1167 
1168  /* Determine the length of the class name */
1169  dwLength /= sizeof(WCHAR);
1170 
1171  if ((dwLength == 0) || (Buffer[dwLength - 1] != UNICODE_NULL))
1172  /* Count the null-terminator */
1173  dwLength++;
1174 
1175  /* Inform the caller about the class name */
1176  if ((ClassName != NULL) && (dwLength <= ClassNameSize))
1177  {
1178  memcpy(ClassName, Buffer, (dwLength - 1) * sizeof(WCHAR));
1179  ClassName[dwLength - 1] = UNICODE_NULL;
1180  }
1181 
1182  /* Inform the caller about the required size */
1183  if (RequiredSize != NULL)
1185 
1186  /* Clean up the buffer */
1187  MyFree(Buffer);
1188 
1189  /* Make sure the buffer was large enough */
1190  if ((ClassName == NULL) || (dwLength > ClassNameSize))
1191  {
1193  return FALSE;
1194  }
1195 
1196  return TRUE;
1197 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define REGSTR_VAL_CLASS
Definition: regstr.h:291
#define ERROR_SUCCESS
Definition: deptool.c:10
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define DIOCR_INSTALLER
Definition: setupapi.h:176
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
Definition: bufpool.h:45
#define debugstr_guid
Definition: kernel32.h:35
PVOID QueryRegistryValue(HANDLE RegHandle, PWCHAR ValueName, LPDWORD RegistryType, LPDWORD Length)
Definition: registry.c:67
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:85
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define ERROR_INVALID_CLASS
Definition: setupapi.h:297
#define NULL
Definition: types.h:112
HKEY WINAPI SetupDiOpenClassRegKeyExW(const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:3656
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431