ReactOS  0.4.15-dev-5446-g3f3714b
devinst.c File Reference
#include "setupapi_private.h"
#include <pseh/pseh2.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 44 of file devinst.c.

◆ COINSTALLER_PROC

Definition at line 53 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 49 of file devinst.c.

Function Documentation

◆ CheckDeviceInstallParameters()

static BOOL CheckDeviceInstallParameters ( IN PSP_DEVINSTALL_PARAMS_W  DeviceInstallParams)
static

Definition at line 4499 of file devinst.c.

4501 {
4502  DWORD SupportedFlags =
4503  DI_NOVCP | /* 0x00000008 */
4504  DI_DIDCOMPAT | /* 0x00000010 */
4505  DI_DIDCLASS | /* 0x00000020 */
4506  DI_NEEDRESTART | /* 0x00000080 */
4507  DI_NEEDREBOOT | /* 0x00000100 */
4508  DI_RESOURCEPAGE_ADDED | /* 0x00002000 */
4509  DI_PROPERTIES_CHANGE | /* 0x00004000 */
4510  DI_ENUMSINGLEINF | /* 0x00010000 */
4511  DI_DONOTCALLCONFIGMG | /* 0x00020000 */
4512  DI_CLASSINSTALLPARAMS | /* 0x00100000 */
4513  DI_NODI_DEFAULTACTION | /* 0x00200000 */
4514  DI_QUIETINSTALL | /* 0x00800000 */
4515  DI_NOFILECOPY | /* 0x01000000 */
4516  DI_DRIVERPAGE_ADDED; /* 0x04000000 */
4517  DWORD SupportedFlagsEx =
4518  DI_FLAGSEX_CI_FAILED | /* 0x00000004 */
4519  DI_FLAGSEX_DIDINFOLIST | /* 0x00000010 */
4520  DI_FLAGSEX_DIDCOMPATINFO | /* 0x00000020 */
4521  DI_FLAGSEX_ALLOWEXCLUDEDDRVS | /* 0x00000800 */
4522  DI_FLAGSEX_NO_DRVREG_MODIFY | /* 0x00008000 */
4523  DI_FLAGSEX_INSTALLEDDRIVER; /* 0x04000000 */
4524  BOOL ret = FALSE;
4525 
4526  /* FIXME: add support for more flags */
4527 
4528  /* FIXME: DI_CLASSINSTALLPARAMS flag is not correctly used.
4529  * It should be checked before accessing to other values
4530  * of the SP_DEVINSTALL_PARAMS structure */
4531 
4532  if (DeviceInstallParams->Flags & ~SupportedFlags)
4533  {
4534  FIXME("Unknown Flags: 0x%08lx\n", DeviceInstallParams->Flags & ~SupportedFlags);
4536  }
4537  else if (DeviceInstallParams->FlagsEx & ~SupportedFlagsEx)
4538  {
4539  FIXME("Unknown FlagsEx: 0x%08lx\n", DeviceInstallParams->FlagsEx & ~SupportedFlagsEx);
4541  }
4542  else if ((DeviceInstallParams->Flags & DI_NOVCP)
4543  && (DeviceInstallParams->FileQueue == NULL || DeviceInstallParams->FileQueue == (HSPFILEQ)INVALID_HANDLE_VALUE))
4545  else
4546  {
4547  /* FIXME: check Reserved field */
4548  ret = TRUE;
4549  }
4550 
4551  return ret;
4552 }
#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:731
#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:752
#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 124 of file devinst.c.

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

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

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

◆ DestroyClassInstallParams()

static BOOL DestroyClassInstallParams ( struct ClassInstallParams installParams)
static

Definition at line 573 of file devinst.c.

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

Referenced by DestroyDeviceInfo(), and DestroyDeviceInfoSet().

◆ DestroyDeviceInfo()

static BOOL DestroyDeviceInfo ( struct DeviceInfo deviceInfo)
static

Definition at line 581 of file devinst.c.

582 {
584  struct DriverInfoElement *driverInfo;
585  struct DeviceInterface *deviceInterface;
586 
587  while (!IsListEmpty(&deviceInfo->DriverListHead))
588  {
589  ListEntry = RemoveHeadList(&deviceInfo->DriverListHead);
591  if (!DestroyDriverInfoElement(driverInfo))
592  return FALSE;
593  }
594  while (!IsListEmpty(&deviceInfo->InterfaceListHead))
595  {
597  deviceInterface = CONTAINING_RECORD(ListEntry, struct DeviceInterface, ListEntry);
598  if (!DestroyDeviceInterface(deviceInterface))
599  return FALSE;
600  }
602  if (deviceInfo->hmodDevicePropPageProvider)
604  return HeapFree(GetProcessHeap(), 0, deviceInfo);
605 }
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:573
#define FreeLibrary(x)
Definition: compat.h:748
#define GetProcessHeap()
Definition: compat.h:736
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:735

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

◆ DestroyDeviceInfoSet()

static BOOL DestroyDeviceInfoSet ( struct DeviceInfoSet list)
static

Definition at line 608 of file devinst.c.

609 {
611  struct DeviceInfo *deviceInfo;
612 
613  while (!IsListEmpty(&list->ListHead))
614  {
615  ListEntry = RemoveHeadList(&list->ListHead);
616  deviceInfo = CONTAINING_RECORD(ListEntry, struct DeviceInfo, ListEntry);
617  if (!DestroyDeviceInfo(deviceInfo))
618  return FALSE;
619  }
620  if (list->HKLM != HKEY_LOCAL_MACHINE)
621  RegCloseKey(list->HKLM);
622  CM_Disconnect_Machine(list->hMachine);
623  DestroyClassInstallParams(&list->ClassInstallParams);
624  if (list->hmodClassPropPageProvider)
625  FreeLibrary(list->hmodClassPropPageProvider);
626  return HeapFree(GetProcessHeap(), 0, list);
627 }
CONFIGRET WINAPI CM_Disconnect_Machine(_In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:1863
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#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:573
#define FreeLibrary(x)
Definition: compat.h:748
#define GetProcessHeap()
Definition: compat.h:736
static BOOL DestroyDeviceInfo(struct DeviceInfo *deviceInfo)
Definition: devinst.c:581
Definition: _list.h:228
Definition: typedefs.h:119
LIST_ENTRY ListEntry
LIST_ENTRY ListEntry
#define HeapFree(x, y, z)
Definition: compat.h:735
#define RegCloseKey(hKey)
Definition: registry.h:47
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by SetupDiDestroyDeviceInfoList().

◆ GetErrorCodeFromCrCode()

DWORD GetErrorCodeFromCrCode ( const IN CONFIGRET  cr)

Definition at line 94 of file devinst.c.

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

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

◆ GetSectionCallback()

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

Definition at line 365 of file devinst.c.

368 {
370  DWORD Score1, Score2, Score3, Score4, Score5;
371  BOOL ret;
372 
373  if (SectionName[info->PrefixLength] != '.')
374  return TRUE;
375 
377  &SectionName[info->PrefixLength],
378  info->PlatformInfo,
379  info->ProductType,
380  info->SuiteMask,
381  &Score1, &Score2, &Score3, &Score4, &Score5);
382  if (!ret)
383  {
384  TRACE("Section %s not compatible\n", debugstr_w(SectionName));
385  return TRUE;
386  }
387  if (Score1 > info->BestScore1) goto done;
388  if (Score1 < info->BestScore1) goto bettersection;
389  if (Score2 > info->BestScore2) goto done;
390  if (Score2 < info->BestScore2) goto bettersection;
391  if (Score3 > info->BestScore3) goto done;
392  if (Score3 < info->BestScore3) goto bettersection;
393  if (Score4 > info->BestScore4) goto done;
394  if (Score4 < info->BestScore4) goto bettersection;
395  if (Score5 > info->BestScore5) goto done;
396  if (Score5 < info->BestScore5) goto bettersection;
397  goto done;
398 
399 bettersection:
400  strcpyW(info->BestSection, SectionName);
401  info->BestScore1 = Score1;
402  info->BestScore2 = Score2;
403  info->BestScore3 = Score3;
404  info->BestScore4 = Score4;
405  info->BestScore5 = Score5;
406 
407 done:
408  return TRUE;
409 }
#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:124
int ret
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
struct tagContext Context
Definition: acpixf.h:1038

Referenced by SetupDiGetActualSectionToInstallExW().

◆ InfIsFromOEMLocation()

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

Definition at line 5311 of file devinst.c.

5314 {
5315  PWCHAR last;
5316 
5317  last = strrchrW(FullName, '\\');
5318  if (!last)
5319  {
5320  /* No directory specified */
5321  *IsOEMLocation = FALSE;
5322  }
5323  else
5324  {
5325  LPWSTR Windir;
5326  UINT ret;
5327 
5328  Windir = MyMalloc((MAX_PATH + 1 + strlenW(InfDirectory)) * sizeof(WCHAR));
5329  if (!Windir)
5330  {
5332  return FALSE;
5333  }
5334 
5336  if (ret == 0 || ret > MAX_PATH)
5337  {
5338  MyFree(Windir);
5340  return FALSE;
5341  }
5342  if (*Windir && Windir[strlenW(Windir) - 1] != '\\')
5343  strcatW(Windir, BackSlash);
5344  strcatW(Windir, InfDirectory);
5345 
5346  if (strncmpiW(FullName, Windir, last - FullName) == 0)
5347  {
5348  /* The path is %SYSTEMROOT%\Inf */
5349  *IsOEMLocation = FALSE;
5350  }
5351  else
5352  {
5353  /* The file is in another place */
5354  *IsOEMLocation = TRUE;
5355  }
5356  MyFree(Windir);
5357  }
5358  return TRUE;
5359 }
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2397
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:32
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
_In_ PSTRING FullName
Definition: rtlfuncs.h:1648
#define SetLastError(x)
Definition: compat.h:752
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:27
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 4014 of file devinst.c.

4017 {
4019 }
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1528
BOOL WINAPI SetupDiRegisterDeviceInfo(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Flags, PSP_DETSIG_CMPPROC CompareProc, PVOID CompareContext, PSP_DEVINFO_DATA DupDeviceInfoData)
Definition: devinst.c:1711
#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 3358 of file devinst.c.

3365 {
3366  BOOL ret = FALSE;
3367  struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
3368  struct DeviceInfo *deviceInfo;
3369 
3370  TRACE("%s(%p %p %d %p %d)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData, Property,
3372 
3374  {
3376  return FALSE;
3377  }
3378  if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
3379  {
3381  return FALSE;
3382  }
3384  || !DeviceInfoData->Reserved)
3385  {
3387  return FALSE;
3388  }
3389 
3390  deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
3391 
3392  if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
3394  && PropertyMap[Property].nameA)
3395  {
3396  HKEY hKey;
3397  LONG l;
3398  hKey = SETUPDI_OpenDevKey(set->HKLM, deviceInfo, KEY_SET_VALUE);
3399  if (hKey == INVALID_HANDLE_VALUE)
3400  return FALSE;
3401  /* Write new data */
3402  if (isAnsi)
3403  {
3404  l = RegSetValueExA(
3405  hKey, PropertyMap[Property].nameA, 0,
3408  }
3409  else
3410  {
3411  l = RegSetValueExW(
3415  }
3416  if (!l)
3417  ret = TRUE;
3418  else
3419  SetLastError(l);
3420  RegCloseKey(hKey);
3421  }
3422  else
3423  {
3424  ERR("Property 0x%lx not implemented\n", Property);
3426  }
3427 
3428  TRACE("Returning %d\n", ret);
3429  return ret;
3430 }
HKEY SETUPDI_OpenDevKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5841
#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:731
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:1553
#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:3098
ULONG_PTR Reserved
Definition: setupapi.h:838
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:4899
#define TRACE(s)
Definition: solgame.cpp:4
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1528
#define SetLastError(x)
Definition: compat.h:752
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:4816
Definition: _set.h:46
#define __FUNCTION__
Definition: types.h:112
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by SetupDiSetDeviceRegistryPropertyA(), and SetupDiSetDeviceRegistryPropertyW().

◆ IsDeviceInfoInDeviceInfoSet()

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

Definition at line 4690 of file devinst.c.

4693 {
4695 
4696  ListEntry = deviceInfoSet->ListHead.Flink;
4697  while (ListEntry != &deviceInfoSet->ListHead)
4698  {
4699  if (deviceInfo == CONTAINING_RECORD(ListEntry, struct DeviceInfo, ListEntry))
4700  return TRUE;
4701 
4703  }
4704 
4705  return FALSE;
4706 }
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 4635 of file devinst.c.

4639 {
4640  HKEY hHWProfilesKey = NULL;
4641  HKEY hHWProfileKey = NULL;
4643  LONG rc;
4644 
4645  rc = RegOpenKeyExW(HKLM,
4647  0,
4648  READ_CONTROL,
4649  &hHWProfilesKey);
4650  if (rc != ERROR_SUCCESS)
4651  {
4652  SetLastError(rc);
4653  goto cleanup;
4654  }
4655  if (HwProfile == 0)
4656  {
4657  rc = RegOpenKeyExW(hHWProfilesKey,
4659  0,
4661  &hHWProfileKey);
4662  }
4663  else
4664  {
4665  WCHAR subKey[5];
4666  snprintfW(subKey, 4, InstanceKeyFormat, HwProfile);
4667  subKey[4] = '\0';
4668  rc = RegOpenKeyExW(hHWProfilesKey,
4669  subKey,
4670  0,
4672  &hHWProfileKey);
4673  }
4674  if (rc != ERROR_SUCCESS)
4675  {
4676  SetLastError(rc);
4677  goto cleanup;
4678  }
4679  ret = hHWProfileKey;
4680 
4681 cleanup:
4682  if (hHWProfilesKey != NULL)
4683  RegCloseKey(hHWProfilesKey);
4684  if (hHWProfileKey != NULL && hHWProfileKey != ret)
4685  RegCloseKey(hHWProfileKey);
4686  return ret;
4687 }
#define snprintfW
Definition: unicode.h:60
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR InstanceKeyFormat[]
Definition: devinst.c:33
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define REGSTR_PATH_HWPROFILES
Definition: regstr.h:482
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:752
#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:3356
char * cleanup(char *str)
Definition: wpickclick.c:99
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define RegCloseKey(hKey)
Definition: registry.h:47

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

◆ ResetDevice()

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

Definition at line 5020 of file devinst.c.

5023 {
5024 #ifndef __WINESRC__
5025  struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
5026  struct DeviceInfo *deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
5027  CONFIGRET cr;
5028 
5029  cr = CM_Enable_DevNode_Ex(deviceInfo->dnDevInst, 0, set->hMachine);
5030  if (cr != CR_SUCCESS)
5031  {
5033  return FALSE;
5034  }
5035 
5036  return TRUE;
5037 #else
5038  FIXME("Stub: ResetDevice(%p %p)\n", DeviceInfoSet, DeviceInfoData);
5039  return TRUE;
5040 #endif
5041 }
#define TRUE
Definition: types.h:120
DWORD GetErrorCodeFromCrCode(const IN CONFIGRET cr)
Definition: devinst.c:94
#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:838
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1528
#define SetLastError(x)
Definition: compat.h:752
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:1927

Referenced by SetupDiChangeState(), and SetupDiInstallDevice().

◆ SETUP_CreateClassKey()

HKEY SETUP_CreateClassKey ( HINF  hInf)

Definition at line 3518 of file devinst.c.

3519 {
3520  WCHAR FullBuffer[MAX_PATH];
3523  HKEY hClassKey;
3525 
3526  /* Obtain the Class GUID for this class */
3527  if (!SetupGetLineTextW(NULL,
3528  hInf,
3529  Version,
3531  Buffer,
3532  sizeof(Buffer) / sizeof(WCHAR),
3533  &RequiredSize))
3534  {
3535  return INVALID_HANDLE_VALUE;
3536  }
3537 
3538  /* Build the corresponding registry key name */
3539  lstrcpyW(FullBuffer, REGSTR_PATH_CLASS_NT);
3540  lstrcatW(FullBuffer, BackSlash);
3541  lstrcatW(FullBuffer, Buffer);
3542 
3543  /* Obtain the Class name for this class */
3544  if (!SetupGetLineTextW(NULL,
3545  hInf,
3546  Version,
3548  Buffer,
3549  sizeof(Buffer) / sizeof(WCHAR),
3550  &RequiredSize))
3551  {
3552  return INVALID_HANDLE_VALUE;
3553  }
3554 
3555  /* Try to open or create the registry key */
3556  TRACE("Opening class key %s\n", debugstr_w(FullBuffer));
3557 #if 0 // I keep this for reference...
3559  FullBuffer,
3560  0,
3561  KEY_SET_VALUE,
3562  &hClassKey))
3563  {
3564  /* Use RegCreateKeyExW */
3565  }
3566 #endif
3568  FullBuffer,
3569  0,
3570  NULL,
3572  KEY_SET_VALUE,
3573  NULL,
3574  &hClassKey,
3575  &Disposition))
3576  {
3577  ERR("RegCreateKeyExW(%s) failed\n", debugstr_w(FullBuffer));
3578  return INVALID_HANDLE_VALUE;
3579  }
3581  TRACE("The class key %s was successfully created\n", debugstr_w(FullBuffer));
3582  else
3583  TRACE("The class key %s was successfully opened\n", debugstr_w(FullBuffer));
3584 
3585  TRACE( "setting value %s to %s\n", debugstr_w(REGSTR_VAL_CLASS), debugstr_w(Buffer) );
3588  0,
3589  REG_SZ,
3590  (LPBYTE)Buffer,
3591  RequiredSize * sizeof(WCHAR)))
3592  {
3595  FullBuffer);
3596  return INVALID_HANDLE_VALUE;
3597  }
3598 
3599  return hClassKey;
3600 }
#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:731
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:50
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
unsigned char * LPBYTE
Definition: typedefs.h:53
#define 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:4899
#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:749
#define NULL
Definition: types.h:112
static const WCHAR BackSlash[]
Definition: devinst.c:27
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
_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 RegCloseKey(hKey)
Definition: registry.h:47
#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 4973 of file devinst.c.

4975 {
4976  HKEY hKey = NULL;
4977  DWORD dwRegType, dwLength;
4978  DWORD hwProfile;
4979  LONG rc;
4980  DWORD ret = (DWORD)-1;
4981 
4982  rc = RegOpenKeyExW(((struct DeviceInfoSet *)DeviceInfoSet)->HKLM,
4984  0, /* Options */
4986  &hKey);
4987  if (rc != ERROR_SUCCESS)
4988  {
4989  SetLastError(rc);
4990  goto cleanup;
4991  }
4992 
4993  dwLength = sizeof(DWORD);
4994  rc = RegQueryValueExW(hKey,
4996  NULL,
4997  &dwRegType,
4998  (LPBYTE)&hwProfile, &dwLength);
4999  if (rc != ERROR_SUCCESS)
5000  {
5001  SetLastError(rc);
5002  goto cleanup;
5003  }
5004  else if (dwRegType != REG_DWORD || dwLength != sizeof(DWORD))
5005  {
5007  goto cleanup;
5008  }
5009 
5010  ret = hwProfile;
5011 
5012 cleanup:
5013  if (hKey != NULL)
5014  RegCloseKey(hKey);
5015 
5016  return ret;
5017 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define DWORD
Definition: nt_native.h:44
#define REGSTR_VAL_CURRENTCONFIG
Definition: regstr.h:466
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:4120
static DWORD DWORD * dwLength
Definition: fusion.c:85
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:752
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:3356
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
#define REG_DWORD
Definition: sdbapi.c:596
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by SetupDiChangeState().

◆ SETUPDI_CreateDevKey()

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

Definition at line 5671 of file devinst.c.

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

Referenced by SetupDiChangeState(), and SetupDiCreateDevRegKeyW().

◆ SETUPDI_CreateDrvKey()

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

Definition at line 5687 of file devinst.c.

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

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

◆ SETUPDI_DeleteDevKey()

static BOOL SETUPDI_DeleteDevKey ( 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_DeleteDrvKey()

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

Definition at line 6024 of file devinst.c.

6025 {
6026  FIXME("\n");
6027  return FALSE;
6028 }
#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 81 of file devinst.c.

82 {
83  static const WCHAR fmt[] = {'{','%','0','8','X','-','%','0','4','X','-',
84  '%','0','4','X','-','%','0','2','X','%','0','2','X','-','%','0','2',
85  'X','%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','%',
86  '0','2','X','}',0};
87 
88  sprintfW(guidStr, fmt, guid->Data1, guid->Data2, guid->Data3,
89  guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
90  guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
91 }
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 5841 of file devinst.c.

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

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

◆ SETUPDI_OpenDrvKey()

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

Definition at line 5857 of file devinst.c.

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

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

◆ SetupDiBuildClassInfoList()

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

Definition at line 645 of file devinst.c.

650 {
651  TRACE("\n");
652  return SetupDiBuildClassInfoListExW(Flags, ClassGuidList,
654  NULL, NULL);
655 }
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1281
#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:722
#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 675 of file devinst.c.

682 {
683  LPWSTR MachineNameW = NULL;
684  BOOL bResult;
685 
686  TRACE("%s(0x%lx %p %lu %p %s %p)\n", __FUNCTION__, Flags, ClassGuidList,
688 
689  if (MachineName)
690  {
692  if (MachineNameW == NULL) return FALSE;
693  }
694 
695  bResult = SetupDiBuildClassInfoListExW(Flags, ClassGuidList,
697  MachineNameW, Reserved);
698 
699  MyFree(MachineNameW);
700 
701  return bResult;
702 }
#define CP_ACP
Definition: compat.h:109
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1291
#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:1281
_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:722
#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 722 of file devinst.c.

729 {
730  GUID CurrentClassGuid;
731  HKEY hClassKey;
732  DWORD dwIndex;
733  DWORD dwGuidListIndex = 0;
734  HMACHINE hMachine = NULL;
735  CONFIGRET cr;
736 
737  TRACE("%s(0x%lx %p %lu %p %s %p)\n", __FUNCTION__, Flags, ClassGuidList,
739 
740  if (!RequiredSize)
741  {
743  return FALSE;
744  }
745  else if (!ClassGuidList && ClassGuidListSize > 0)
746  {
748  return FALSE;
749  }
750 
751  if (MachineName)
752  {
753  cr = CM_Connect_MachineW(MachineName, &hMachine);
754  if (cr != CR_SUCCESS)
755  {
757  return FALSE;
758  }
759  }
760 
761  for (dwIndex = 0; ; dwIndex++)
762  {
763  cr = CM_Enumerate_Classes_Ex(dwIndex,
764  &CurrentClassGuid,
765  0,
766  hMachine);
767  if (cr == CR_SUCCESS)
768  {
769  TRACE("Guid: %s\n", debugstr_guid(&CurrentClassGuid));
770  if (CM_Open_Class_Key_ExW(&CurrentClassGuid,
771  NULL,
774  &hClassKey,
776  hMachine) != CR_SUCCESS)
777  {
779  if (hMachine)
780  CM_Disconnect_Machine(hMachine);
781  return FALSE;
782  }
783 
786  NULL,
787  NULL,
788  NULL,
789  NULL))
790  {
791  TRACE("'NoUseClass' value found!\n");
793  continue;
794  }
795 
796  if ((Flags & DIBCI_NOINSTALLCLASS) &&
799  NULL,
800  NULL,
801  NULL,
802  NULL)))
803  {
804  TRACE("'NoInstallClass' value found!\n");
806  continue;
807  }
808 
809  if ((Flags & DIBCI_NODISPLAYCLASS) &&
812  NULL,
813  NULL,
814  NULL,
815  NULL)))
816  {
817  TRACE("'NoDisplayClass' value found!\n");
819  continue;
820  }
821 
823 
824  if (dwGuidListIndex < ClassGuidListSize)
825  {
826  ClassGuidList[dwGuidListIndex] = CurrentClassGuid;
827  }
828 
829  dwGuidListIndex++;
830  }
831 
832  if (cr != ERROR_SUCCESS)
833  break;
834  }
835 
836  if (hMachine)
837  CM_Disconnect_Machine(hMachine);
838 
839  if (RequiredSize != NULL)
840  *RequiredSize = dwGuidListIndex;
841 
842  if (ClassGuidListSize < dwGuidListIndex)
843  {
845  return FALSE;
846  }
847 
848  return TRUE;
849 }
#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:6289
#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:1863
DWORD GetErrorCodeFromCrCode(const IN CONFIGRET cr)
Definition: devinst.c:94
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1291
CONFIGRET WINAPI CM_Enumerate_Classes_Ex(_In_ ULONG ulClassIndex, _Out_ LPGUID ClassGuid, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:2009
#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:1281
_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:4120
CONFIGRET WINAPI CM_Connect_MachineW(_In_opt_ PCWSTR UNCServerName, _Out_ PHMACHINE phMachine)
Definition: cfgmgr.c:1241
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:752
#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 RegCloseKey(hKey)
Definition: registry.h:47
#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 4024 of file devinst.c.

4028 {
4029  BOOL ret = FALSE;
4030 
4031  TRACE("%s(%u %p %p)\n", __FUNCTION__, InstallFunction, DeviceInfoSet, DeviceInfoData);
4032 
4033  if (!DeviceInfoSet)
4039  else if (((struct DeviceInfoSet *)DeviceInfoSet)->HKLM != HKEY_LOCAL_MACHINE)
4041  else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
4043  else
4044  {
4046 #define CLASS_COINSTALLER 0x1
4047 #define DEVICE_COINSTALLER 0x2
4048 #define CLASS_INSTALLER 0x4
4049  UCHAR CanHandle = 0;
4051 
4052  switch (InstallFunction)
4053  {
4056  break;
4059  break;
4060  case DIF_ALLOW_INSTALL:
4061  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4062  break;
4063  case DIF_DETECT:
4064  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4065  break;
4067  CanHandle = CLASS_INSTALLER;
4068  break;
4069  case DIF_INSTALLDEVICE:
4072  break;
4074  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4076  break;
4077  case DIF_INSTALLINTERFACES:
4080  break;
4083  break;
4085  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4086  break;
4088  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4089  break;
4091  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4092  break;
4094  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4095  break;
4096  case DIF_POWERMESSAGEWAKE:
4098  break;
4099  case DIF_PROPERTYCHANGE:
4102  break;
4104  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4106  break;
4107  case DIF_REGISTERDEVICE:
4108  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4110  break;
4111  case DIF_REMOVE:
4114  break;
4116  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4118  break;
4119  case DIF_SELECTDEVICE:
4120  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4122  break;
4123  case DIF_TROUBLESHOOTER:
4125  break;
4126  case DIF_UNREMOVE:
4129  break;
4130  default:
4131  ERR("Install function %u not supported\n", InstallFunction);
4133  }
4134 
4137  /* Don't process this call, as a parameter is invalid */
4138  CanHandle = 0;
4139 
4140  if (CanHandle != 0)
4141  {
4142  LIST_ENTRY ClassCoInstallersListHead;
4143  LIST_ENTRY DeviceCoInstallersListHead;
4144  HMODULE ClassInstallerLibrary = NULL;
4145  CLASS_INSTALL_PROC ClassInstaller = NULL;
4148  HKEY hKey;
4149  DWORD dwRegType, dwLength;
4150  DWORD rc = NO_ERROR;
4151 
4152  InitializeListHead(&ClassCoInstallersListHead);
4153  InitializeListHead(&DeviceCoInstallersListHead);
4154 
4155  if (CanHandle & DEVICE_COINSTALLER)
4156  {
4158  if (hKey != INVALID_HANDLE_VALUE)
4159  {
4161  if (rc == ERROR_SUCCESS && dwRegType == REG_MULTI_SZ)
4162  {
4163  LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
4164  if (KeyBuffer != NULL)
4165  {
4167  if (rc == ERROR_SUCCESS)
4168  {
4169  LPWSTR ptr;
4170  for (ptr = KeyBuffer; *ptr; ptr += strlenW(ptr) + 1)
4171  {
4172  /* Add coinstaller to DeviceCoInstallersListHead list */
4173  struct CoInstallerElement *coinstaller;
4174  TRACE("Got device coinstaller '%s'\n", debugstr_w(ptr));
4175  coinstaller = HeapAlloc(GetProcessHeap(), 0, sizeof(struct CoInstallerElement));
4176  if (!coinstaller)
4177  continue;
4178  ZeroMemory(coinstaller, sizeof(struct CoInstallerElement));
4179  if (GetFunctionPointer(ptr, &coinstaller->Module, (PVOID*)&coinstaller->Function) == ERROR_SUCCESS)
4180  InsertTailList(&DeviceCoInstallersListHead, &coinstaller->ListEntry);
4181  else
4182  HeapFree(GetProcessHeap(), 0, coinstaller);
4183  }
4184  }
4185  HeapFree(GetProcessHeap(), 0, KeyBuffer);
4186  }
4187  }
4188  RegCloseKey(hKey);
4189  }
4190  }
4191  if (CanHandle & CLASS_COINSTALLER)
4192  {
4193  rc = RegOpenKeyExW(
4196  0, /* Options */
4198  &hKey);
4199  if (rc == ERROR_SUCCESS)
4200  {
4201  WCHAR szGuidString[40];
4202  if (pSetupStringFromGuid(&DeviceInfoData->ClassGuid, szGuidString, ARRAYSIZE(szGuidString)) == ERROR_SUCCESS)
4203  {
4204  rc = RegQueryValueExW(hKey, szGuidString, NULL, &dwRegType, NULL, &dwLength);
4205  if (rc == ERROR_SUCCESS && dwRegType == REG_MULTI_SZ)
4206  {
4207  LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
4208  if (KeyBuffer != NULL)
4209  {
4210  rc = RegQueryValueExW(hKey, szGuidString, NULL, NULL, (LPBYTE)KeyBuffer, &dwLength);
4211  if (rc == ERROR_SUCCESS)
4212  {
4213  LPWSTR ptr;
4214  for (ptr = KeyBuffer; *ptr; ptr += strlenW(ptr) + 1)
4215  {
4216  /* Add coinstaller to ClassCoInstallersListHead list */
4217  struct CoInstallerElement *coinstaller;
4218  TRACE("Got class coinstaller '%s'\n", debugstr_w(ptr));
4219  coinstaller = HeapAlloc(GetProcessHeap(), 0, sizeof(struct CoInstallerElement));
4220  if (!coinstaller)
4221  continue;
4222  ZeroMemory(coinstaller, sizeof(struct CoInstallerElement));
4223  if (GetFunctionPointer(ptr, &coinstaller->Module, (PVOID*)&coinstaller->Function) == ERROR_SUCCESS)
4224  InsertTailList(&ClassCoInstallersListHead, &coinstaller->ListEntry);
4225  else
4226  HeapFree(GetProcessHeap(), 0, coinstaller);
4227  }
4228  }
4229  HeapFree(GetProcessHeap(), 0, KeyBuffer);
4230  }
4231  }
4232  }
4233  RegCloseKey(hKey);
4234  }
4235  }
4236  if ((CanHandle & CLASS_INSTALLER) && !(InstallParams.FlagsEx & DI_FLAGSEX_CI_FAILED))
4237  {
4239  if (hKey != INVALID_HANDLE_VALUE)
4240  {
4242  if (rc == ERROR_SUCCESS && dwRegType == REG_SZ)
4243  {
4244  LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
4245  if (KeyBuffer != NULL)
4246  {
4248  if (rc == ERROR_SUCCESS)
4249  {
4250  /* Get ClassInstaller function pointer */
4251  TRACE("Got class installer '%s'\n", debugstr_w(KeyBuffer));
4252  if (GetFunctionPointer(KeyBuffer, &ClassInstallerLibrary, (PVOID*)&ClassInstaller) != ERROR_SUCCESS)
4253  {
4254  InstallParams.FlagsEx |= DI_FLAGSEX_CI_FAILED;
4256  }
4257  }
4258  HeapFree(GetProcessHeap(), 0, KeyBuffer);
4259  }
4260  }
4261  RegCloseKey(hKey);
4262  }
4263  }
4264 
4265  /* Call Class co-installers */
4266  Context.PostProcessing = FALSE;
4267  rc = NO_ERROR;
4268  ListEntry = ClassCoInstallersListHead.Flink;
4269  while (rc == NO_ERROR && ListEntry != &ClassCoInstallersListHead)
4270  {
4271  struct CoInstallerElement *coinstaller;
4272  coinstaller = CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry);
4273  rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4274  coinstaller->PrivateData = Context.PrivateData;
4276  {
4277  coinstaller->DoPostProcessing = TRUE;
4278  rc = NO_ERROR;
4279  }
4281  }
4282 
4283  /* Call Device co-installers */
4284  ListEntry = DeviceCoInstallersListHead.Flink;
4285  while (rc == NO_ERROR && ListEntry != &DeviceCoInstallersListHead)
4286  {
4287  struct CoInstallerElement *coinstaller;
4288  coinstaller = CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry);
4289  rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4290  coinstaller->PrivateData = Context.PrivateData;
4292  {
4293  coinstaller->DoPostProcessing = TRUE;
4294  rc = NO_ERROR;
4295  }
4297  }
4298 
4299  /* Call Class installer */
4300  if (ClassInstaller)
4301  {
4302  rc = (*ClassInstaller)(InstallFunction, DeviceInfoSet, DeviceInfoData);
4303  FreeFunctionPointer(ClassInstallerLibrary, ClassInstaller);
4304  }
4305  else
4306  rc = ERROR_DI_DO_DEFAULT;
4307 
4308  /* Call default handler */
4309  if (rc == ERROR_DI_DO_DEFAULT)
4310  {
4311  if (DefaultHandler && !(InstallParams.Flags & DI_NODI_DEFAULTACTION))
4312  {
4314  rc = NO_ERROR;
4315  else
4316  rc = GetLastError();
4317  }
4318  else
4319  rc = NO_ERROR;
4320  }
4321 
4322  /* Call Class co-installers that required postprocessing */
4323  Context.PostProcessing = TRUE;
4324  ListEntry = ClassCoInstallersListHead.Flink;
4325  while (ListEntry != &ClassCoInstallersListHead)
4326  {
4327  struct CoInstallerElement *coinstaller;
4328  coinstaller = CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry);
4329  if (coinstaller->DoPostProcessing)
4330  {
4331  Context.InstallResult = rc;
4332  Context.PrivateData = coinstaller->PrivateData;
4333  rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4334  }
4335  FreeFunctionPointer(coinstaller->Module, coinstaller->Function);
4337  }
4338 
4339  /* Call Device co-installers that required postprocessing */
4340  ListEntry = DeviceCoInstallersListHead.Flink;
4341  while (ListEntry != &DeviceCoInstallersListHead)
4342  {
4343  struct CoInstallerElement *coinstaller;
4344  coinstaller = CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry);
4345  if (coinstaller->DoPostProcessing)
4346  {
4347  Context.InstallResult = rc;
4348  Context.PrivateData = coinstaller->PrivateData;
4349  rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4350  }
4351  FreeFunctionPointer(coinstaller->Module, coinstaller->Function);
4353  }
4354 
4355  /* Free allocated memory */
4356  while (!IsListEmpty(&ClassCoInstallersListHead))
4357  {
4358  ListEntry = RemoveHeadList(&ClassCoInstallersListHead);
4360  }
4361  while (!IsListEmpty(&DeviceCoInstallersListHead))
4362  {
4363  ListEntry = RemoveHeadList(&DeviceCoInstallersListHead);
4365  }
4366 
4367  ret = (rc == NO_ERROR);
4368  }
4369  }
4370 
4371  TRACE("Returning %d\n", ret);
4372  return ret;
4373 }
#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:4558
#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:63
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define ZeroMemory
Definition: winbase.h:1670
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:61
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
COINSTALLER_PROC Function
Definition: devinst.c:64
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:65
#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:5365
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:4451
static BOOL WINAPI IntSetupDiRegisterDeviceInfo(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:4014
#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:838
PVOID PrivateData
Definition: devinst.c:66
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:44
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:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:85
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:1528
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DIF_TROUBLESHOOTER
Definition: setupapi.h:157
#define SetLastError(x)
Definition: compat.h:752
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:5211
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:49
#define DIF_POWERMESSAGEWAKE
Definition: setupapi.h:158
BOOL WINAPI SetupDiChangeState(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5071
Definition: typedefs.h:119
HKEY SETUPDI_OpenDrvKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5857
#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:5197
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:310
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
#define CLASS_INSTALLER
struct tagContext Context
Definition: acpixf.h:1038
#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:3356
#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:334
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:735
HKEY WINAPI SetupDiOpenClassRegKey(const GUID *ClassGuid, REGSAM samDesired)
Definition: devinst.c:3618
#define RegCloseKey(hKey)
Definition: registry.h:47
#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 5071 of file devinst.c.

5074 {
5075  struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
5076  struct DeviceInfo *deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
5077  PSP_PROPCHANGE_PARAMS PropChange;
5079  LPCWSTR RegistryValueName;
5080  DWORD dwConfigFlags, dwLength, dwRegType;
5081  LONG rc;
5082  BOOL ret = FALSE;
5083 
5084  TRACE("%s(%p %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData);
5085 
5086  if (!DeviceInfoData)
5087  PropChange = ((struct DeviceInfoSet *)DeviceInfoSet)->ClassInstallParams.PropChangeParams;
5088  else
5089  PropChange = ((struct DeviceInfo *)DeviceInfoData->Reserved)->ClassInstallParams.PropChangeParams;
5090  if (!PropChange)
5091  {
5093  goto cleanup;
5094  }
5095 
5096  if (PropChange->Scope == DICS_FLAG_GLOBAL)
5097  RegistryValueName = REGSTR_VAL_CONFIGFLAGS;
5098  else
5099  RegistryValueName = REGSTR_VAL_CSCONFIGFLAGS;
5100 
5101  switch (PropChange->StateChange)
5102  {
5103  case DICS_ENABLE:
5104  case DICS_DISABLE:
5105  {
5106  if (PropChange->Scope == DICS_FLAG_GLOBAL)
5107  hRootKey = set->HKLM;
5108  else /* PropChange->Scope == DICS_FLAG_CONFIGSPECIFIC */
5109  {
5110  hRootKey = OpenHardwareProfileKey(set->HKLM, PropChange->HwProfile, KEY_CREATE_SUB_KEY);
5111  if (hRootKey == INVALID_HANDLE_VALUE)
5112  goto cleanup;
5113  }
5114 
5115  /* Enable/disable device in registry */
5116  hKey = SETUPDI_OpenDrvKey(hRootKey, deviceInfo, KEY_QUERY_VALUE | KEY_SET_VALUE);
5118  hKey = SETUPDI_CreateDevKey(hRootKey, deviceInfo, KEY_QUERY_VALUE | KEY_SET_VALUE);
5119  if (hKey == INVALID_HANDLE_VALUE)
5120  break;
5121  dwLength = sizeof(DWORD);
5122  rc = RegQueryValueExW(
5123  hKey,
5124  RegistryValueName,
5125  NULL,
5126  &dwRegType,
5127  (LPBYTE)&dwConfigFlags, &dwLength);
5128  if (rc == ERROR_FILE_NOT_FOUND)
5129  dwConfigFlags = 0;
5130  else if (rc != ERROR_SUCCESS)
5131  {
5132  SetLastError(rc);
5133  goto cleanup;
5134  }
5135  else if (dwRegType != REG_DWORD || dwLength != sizeof(DWORD))
5136  {
5138  goto cleanup;
5139  }
5140  if (PropChange->StateChange == DICS_ENABLE)
5141  dwConfigFlags &= ~(PropChange->Scope == DICS_FLAG_GLOBAL ? CONFIGFLAG_DISABLED : CSCONFIGFLAG_DISABLED);
5142  else
5143  dwConfigFlags |= (PropChange->Scope == DICS_FLAG_GLOBAL ? CONFIGFLAG_DISABLED : CSCONFIGFLAG_DISABLED);
5144  rc = RegSetValueExW(
5145  hKey,
5146  RegistryValueName,
5147  0,
5148  REG_DWORD,
5149  (LPBYTE)&dwConfigFlags, sizeof(DWORD));
5150  if (rc != ERROR_SUCCESS)
5151  {
5152  SetLastError(rc);
5153  goto cleanup;
5154  }
5155 
5156  /* Enable/disable device if needed */
5157  if (PropChange->Scope == DICS_FLAG_GLOBAL
5158  || PropChange->HwProfile == 0
5159  || PropChange->HwProfile == SETUPAPI_GetCurrentHwProfile(DeviceInfoSet))
5160  {
5161  if (PropChange->StateChange == DICS_ENABLE)
5163  else
5165  }
5166  else
5167  ret = TRUE;
5168  break;
5169  }
5170  case DICS_PROPCHANGE:
5171  {
5173  break;
5174  }
5175  default:
5176  {
5177  ERR("Unknown StateChange 0x%lx\n", PropChange->StateChange);
5179  }
5180  }
5181 
5182 cleanup:
5183  if (hRootKey != INVALID_HANDLE_VALUE && hRootKey != set->HKLM)
5184  RegCloseKey(hRootKey);
5185 
5186  if (hKey != INVALID_HANDLE_VALUE)
5187  RegCloseKey(hKey);
5188 
5189  TRACE("Returning %d\n", ret);
5190  return ret;
5191 }
#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:4973
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#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:5671
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:838
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4899
#define TRACE(s)
Definition: solgame.cpp:4
#define 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:4120
static DWORD DWORD * dwLength
Definition: fusion.c:85
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1528
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:752
static HKEY OpenHardwareProfileKey(IN HKEY HKLM, IN DWORD HwProfile, IN DWORD samDesired)
Definition: devinst.c:4635
int ret
HKEY SETUPDI_OpenDrvKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5857
#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
#define RegCloseKey(hKey)
Definition: registry.h:47
static BOOL StopDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5044
static BOOL ResetDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5020

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

◆ SetupDiClassGuidsFromNameA()

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

Definition at line 854 of file devinst.c.

859 {
860  return SetupDiClassGuidsFromNameExA(ClassName, ClassGuidList,
862  NULL, NULL);
863 }
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1281
BOOL WINAPI SetupDiClassGuidsFromNameExA(LPCSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCSTR MachineName, PVOID Reserved)
Definition: devinst.c:882
#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 882 of file devinst.c.

889 {
890  LPWSTR ClassNameW = NULL;
891  LPWSTR MachineNameW = NULL;
892  BOOL bResult;
893 
894  TRACE("%s(%s %p %lu %p %s %p)\n", __FUNCTION__, debugstr_a(ClassName), ClassGuidList,
896 
897  if (!ClassName)
898  {
900  return FALSE;
901  }
902 
903  ClassNameW = pSetupMultiByteToUnicode(ClassName, CP_ACP);
904  if (ClassNameW == NULL)
905  return FALSE;
906 
907  if (MachineName)
908  {
910  if (MachineNameW == NULL)
911  {
912  MyFree(ClassNameW);
913  return FALSE;
914  }
915  }
916 
917  bResult = SetupDiClassGuidsFromNameExW(ClassNameW, ClassGuidList,
919  MachineNameW, Reserved);
920 
921  MyFree(MachineNameW);
922  MyFree(ClassNameW);
923 
924  return bResult;
925 }
#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:1291
#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:1281
_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:752
#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:930

Referenced by SetupDiClassGuidsFromNameA().

◆ SetupDiClassGuidsFromNameExW()

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

Definition at line 930 of file devinst.c.

937 {
938  WCHAR szKeyName[40];
940  HKEY hClassesKey;
941  HKEY hClassKey;
942  DWORD dwLength;
943  DWORD dwIndex;
944  LONG lError;
945  DWORD dwGuidListIndex = 0;
946 
947  TRACE("%s(%s %p %lu %p %s %p)\n", __FUNCTION__, debugstr_w(ClassName), ClassGuidList,
949 
950  if (!ClassName || !RequiredSize)
951  {
953  return FALSE;
954  }
955  if (!ClassGuidList && ClassGuidListSize > 0)
956  {
958  return FALSE;
959  }
960  *RequiredSize = 0;
961 
962  hClassesKey = SetupDiOpenClassRegKeyExW(NULL,
965  MachineName,
966  Reserved);
967  if (hClassesKey == INVALID_HANDLE_VALUE)
968  {
969  return FALSE;
970  }
971 
972  for (dwIndex = 0; ; dwIndex++)
973  {
974  dwLength = 40;
975  lError = RegEnumKeyExW(hClassesKey,
976  dwIndex,
977  szKeyName,
978  &dwLength,
979  NULL,
980  NULL,
981  NULL,
982  NULL);
983  TRACE("RegEnumKeyExW() returns %d\n", lError);
984  if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA)
985  {
986  TRACE("Key name: %p\n", szKeyName);
987 
988  if (RegOpenKeyExW(hClassesKey,
989  szKeyName,
990  0,
992  &hClassKey))
993  {
994  RegCloseKey(hClassesKey);
995  return FALSE;
996  }
997 
998  dwLength = MAX_CLASS_NAME_LEN * sizeof(WCHAR);
1001  NULL,
1002  NULL,
1004  &dwLength))
1005  {
1006  TRACE("Class name: %p\n", szClassName);
1007 
1008  if (strcmpiW(szClassName, ClassName) == 0)
1009  {
1010  TRACE("Found matching class name\n");
1011 
1012  TRACE("Guid: %p\n", szKeyName);
1013  if (dwGuidListIndex < ClassGuidListSize)
1014  {
1015  if (szKeyName[0] == '{' && szKeyName[37] == '}')
1016  {
1017  szKeyName[37] = 0;
1018  }
1019  TRACE("Guid: %p\n", &szKeyName[1]);
1020 
1021  UuidFromStringW(&szKeyName[1],
1022  &ClassGuidList[dwGuidListIndex]);
1023  }
1024 
1025  dwGuidListIndex++;
1026  }
1027  }
1028 
1030  }
1031 
1032  if (lError != ERROR_SUCCESS)
1033  break;
1034  }
1035 
1036  RegCloseKey(hClassesKey);
1037 
1038  if (RequiredSize != NULL)
1039  *RequiredSize = dwGuidListIndex;
1040 
1041  if (ClassGuidListSize < dwGuidListIndex)
1042  {
1044  return FALSE;
1045  }
1046 
1047  return TRUE;
1048 }
#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:731
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1291
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:1281
_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:4120
__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:752
#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:3356
HKEY WINAPI SetupDiOpenClassRegKeyExW(const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:3662
#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 RegCloseKey(hKey)
Definition: registry.h:47
#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 868 of file devinst.c.

873 {
874  return SetupDiClassGuidsFromNameExW(ClassName, ClassGuidList,
876  NULL, NULL);
877 }
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1281
#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:930

◆ SetupDiClassNameFromGuidA()

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

Definition at line 1053 of file devinst.c.

1058 {
1059  return SetupDiClassNameFromGuidExA(ClassGuid, ClassName,
1060  ClassNameSize, RequiredSize,
1061  NULL, NULL);
1062 }
BOOL WINAPI SetupDiClassNameFromGuidExA(const GUID *ClassGuid, PSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize, PCSTR MachineName, PVOID Reserved)
Definition: devinst.c:1081
#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 1081 of file devinst.c.

1088 {
1089  WCHAR ClassNameW[MAX_CLASS_NAME_LEN];
1090  LPWSTR MachineNameW = NULL;
1091  BOOL ret;
1092 
1093  if (MachineName)
1094  MachineNameW = pSetupMultiByteToUnicode(MachineName, CP_ACP);
1096  RequiredSize, MachineNameW, Reserved);
1097  if (ret)
1098  {
1099  int len = WideCharToMultiByte(CP_ACP, 0, ClassNameW, -1, ClassName,
1100  ClassNameSize, NULL, NULL);
1101  if (len == 0 || len > ClassNameSize)
1102  {
1104  ret = FALSE;
1105  }
1106  }
1107  MyFree(MachineNameW);
1108  return ret;
1109 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1291
BOOL WINAPI SetupDiClassNameFromGuidExW(const GUID *ClassGuid, PWSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:1114
#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:752
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 1114 of file devinst.c.

1121 {
1122  HKEY hKey;
1123  DWORD dwLength;
1124  DWORD dwRegType;
1125  LONG rc;
1126  PWSTR Buffer;
1127 
1128  TRACE("%s(%s %p %lu %p %s %p)\n", __FUNCTION__, debugstr_guid(ClassGuid), ClassName,
1129  ClassNameSize, RequiredSize, debugstr_w(MachineName), Reserved);
1130 
1131  /* Make sure there's a GUID */
1132  if (ClassGuid == NULL)
1133  {
1134  SetLastError(ERROR_INVALID_CLASS); /* On Vista: ERROR_INVALID_USER_BUFFER */
1135  return FALSE;
1136  }
1137 
1138  /* Make sure there's a real buffer when there's a size */
1139  if ((ClassNameSize > 0) && (ClassName == NULL))
1140  {
1141  SetLastError(ERROR_INVALID_PARAMETER); /* On Vista: ERROR_INVALID_USER_BUFFER */
1142  return FALSE;
1143  }
1144 
1145  /* Open the key for the GUID */
1147 
1148  if (hKey == INVALID_HANDLE_VALUE)
1149  return FALSE;
1150 
1151  /* Retrieve the class name data and close the key */
1152  rc = QueryRegistryValue(hKey, REGSTR_VAL_CLASS, (LPBYTE *) &Buffer, &dwRegType, &dwLength);
1153  RegCloseKey(hKey);
1154 
1155  /* Make sure we got the data */
1156  if (rc != ERROR_SUCCESS)
1157  {
1158  SetLastError(rc);
1159  return FALSE;
1160  }
1161 
1162  /* Make sure the data is a string */
1163  if (dwRegType != REG_SZ)
1164  {
1165  MyFree(Buffer);
1167  return FALSE;
1168  }
1169 
1170  /* Determine the length of the class name */
1171  dwLength /= sizeof(WCHAR);
1172 
1173  if ((dwLength == 0) || (Buffer[dwLength - 1] != UNICODE_NULL))
1174  /* Count the null-terminator */
1175  dwLength++;
1176 
1177  /* Inform the caller about the class name */
1178  if ((ClassName != NULL) && (dwLength <= ClassNameSize))
1179  {
1180  memcpy(ClassName, Buffer, (dwLength - 1) * sizeof(WCHAR));
1181  ClassName[dwLength - 1] = UNICODE_NULL;
1182  }
1183 
1184  /* Inform the caller about the required size */
1185  if (RequiredSize != NULL)
1187 
1188  /* Clean up the buffer */
1189  MyFree(Buffer);
1190 
1191  /* Make sure the buffer was large enough */
1192  if ((ClassName == NULL) || (dwLength > ClassNameSize))
1193  {
1195  return FALSE;
1196  }
1197 
1198  return TRUE;
1199 }
#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:731
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1291
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:752
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878