ReactOS  0.4.15-dev-3297-g037c744
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 4495 of file devinst.c.

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

Referenced by SetupDiSetDeviceInstallParamsW().

◆ CheckSectionValid()

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

Definition at line 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:236
ULONG MinorVersion
Definition: ros_glue.cpp:5
ULONG MajorVersion
Definition: ros_glue.cpp:4
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define PROCESSOR_ARCHITECTURE_UNKNOWN
Definition: ketypes.h:115
#define TRUE
Definition: types.h:120
Definition: arc.h:39
int errno
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
#define PROCESSOR_ARCHITECTURE_MIPS
Definition: ketypes.h:106
#define PROCESSOR_ARCHITECTURE_IA64
Definition: ketypes.h:111
#define PROCESSOR_ARCHITECTURE_ALPHA
Definition: ketypes.h:107
LPWSTR WINAPI pSetupDuplicateString(LPCWSTR lpSrc)
Definition: misc.c:198
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PROCESSOR_ARCHITECTURE_AMD64
Definition: ketypes.h:114
#define ERANGE
Definition: acclib.h:92
int ret
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define PROCESSOR_ARCHITECTURE_INTEL
Definition: ketypes.h:105
#define ERR(fmt,...)
Definition: debug.h:110
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define PROCESSOR_ARCHITECTURE_PPC
Definition: ketypes.h:108
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define VER_PLATFORM_WIN32_WINDOWS
Definition: rtltypes.h:235
char * cleanup(char *str)
Definition: wpickclick.c:99
#define strtoulW(s1, s2, b)
Definition: unicode.h:41
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define __FUNCTION__
Definition: types.h:112
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
#define ULONG_MAX
Definition: limits.h:44

Referenced by GetSectionCallback().

◆ CreateDeviceInfo()

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

Definition at line 528 of file devinst.c.

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

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

◆ 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:595
PSP_PROPCHANGE_PARAMS PropChangeParams
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by DestroyDeviceInfo(), and DestroyDeviceInfoSet().

◆ DestroyDeviceInfo()

static BOOL DestroyDeviceInfo ( struct DeviceInfo deviceInfo)
static

Definition at line 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:607
#define GetProcessHeap()
Definition: compat.h:595
BOOL DestroyDriverInfoElement(struct DriverInfoElement *driverInfo)
Definition: driver.c:94
LIST_ENTRY DriverListHead
Definition: typedefs.h:119
LIST_ENTRY ListEntry
LIST_ENTRY ListEntry
struct ClassInstallParams ClassInstallParams
#define HeapFree(x, y, z)
Definition: compat.h:594

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

◆ DestroyDeviceInfoSet()

static BOOL DestroyDeviceInfoSet ( struct DeviceInfoSet list)
static

Definition at line 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:1858
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static BOOL DestroyClassInstallParams(struct ClassInstallParams *installParams)
Definition: devinst.c:573
#define FreeLibrary(x)
Definition: compat.h:607
#define GetProcessHeap()
Definition: compat.h:595
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:594
#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:1034

Referenced by SetupDiGetActualSectionToInstallExW().

◆ InfIsFromOEMLocation()

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

Definition at line 5307 of file devinst.c.

5310 {
5311  PWCHAR last;
5312 
5313  last = strrchrW(FullName, '\\');
5314  if (!last)
5315  {
5316  /* No directory specified */
5317  *IsOEMLocation = FALSE;
5318  }
5319  else
5320  {
5321  LPWSTR Windir;
5322  UINT ret;
5323 
5324  Windir = MyMalloc((MAX_PATH + 1 + strlenW(InfDirectory)) * sizeof(WCHAR));
5325  if (!Windir)
5326  {
5328  return FALSE;
5329  }
5330 
5332  if (ret == 0 || ret > MAX_PATH)
5333  {
5334  MyFree(Windir);
5336  return FALSE;
5337  }
5338  if (*Windir && Windir[strlenW(Windir) - 1] != '\\')
5339  strcatW(Windir, BackSlash);
5340  strcatW(Windir, InfDirectory);
5341 
5342  if (strncmpiW(FullName, Windir, last - FullName) == 0)
5343  {
5344  /* The path is %SYSTEMROOT%\Inf */
5345  *IsOEMLocation = FALSE;
5346  }
5347  else
5348  {
5349  /* The file is in another place */
5350  *IsOEMLocation = TRUE;
5351  }
5352  MyFree(Windir);
5353  }
5354  return TRUE;
5355 }
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2396
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
POINT last
Definition: font.c:46
#define TRUE
Definition: types.h:120
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
uint16_t * PWCHAR
Definition: typedefs.h:56
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
#define FALSE
Definition: types.h:117
static const WCHAR InfDirectory[]
Definition: devinst.c: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:611
int ret
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
unsigned int UINT
Definition: ndis.h:50
static const WCHAR BackSlash[]
Definition: devinst.c: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 4010 of file devinst.c.

4013 {
4015 }
_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:1707
#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 3354 of file devinst.c.

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

Referenced by SetupDiSetDeviceRegistryPropertyA(), and SetupDiSetDeviceRegistryPropertyW().

◆ IsDeviceInfoInDeviceInfoSet()

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

Definition at line 4686 of file devinst.c.

4689 {
4691 
4692  ListEntry = deviceInfoSet->ListHead.Flink;
4693  while (ListEntry != &deviceInfoSet->ListHead)
4694  {
4695  if (deviceInfo == CONTAINING_RECORD(ListEntry, struct DeviceInfo, ListEntry))
4696  return TRUE;
4697 
4699  }
4700 
4701  return FALSE;
4702 }
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 4631 of file devinst.c.

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

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

◆ ResetDevice()

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

Definition at line 5016 of file devinst.c.

5019 {
5020 #ifndef __WINESRC__
5021  struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
5022  struct DeviceInfo *deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
5023  CONFIGRET cr;
5024 
5025  cr = CM_Enable_DevNode_Ex(deviceInfo->dnDevInst, 0, set->hMachine);
5026  if (cr != CR_SUCCESS)
5027  {
5029  return FALSE;
5030  }
5031 
5032  return TRUE;
5033 #else
5034  FIXME("Stub: ResetDevice(%p %p)\n", DeviceInfoSet, DeviceInfoData);
5035  return TRUE;
5036 #endif
5037 }
#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:611
DEVINST dnDevInst
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
Definition: _set.h:46
CONFIGRET WINAPI CM_Enable_DevNode_Ex(_In_ DEVINST dnDevInst, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:1922

Referenced by SetupDiChangeState(), and SetupDiInstallDevice().

◆ SETUP_CreateClassKey()

HKEY SETUP_CreateClassKey ( HINF  hInf)

Definition at line 3514 of file devinst.c.

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

Referenced by SetupDiInstallClassExW().

◆ SETUPAPI_GetCurrentHwProfile()

static DWORD SETUPAPI_GetCurrentHwProfile ( IN HDEVINFO  DeviceInfoSet)
static

Definition at line 4969 of file devinst.c.

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

Referenced by SetupDiChangeState().

◆ SETUPDI_CreateDevKey()

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

Definition at line 5667 of file devinst.c.

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

Referenced by SetupDiChangeState(), and SetupDiCreateDevRegKeyW().

◆ SETUPDI_CreateDrvKey()

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

Definition at line 5683 of file devinst.c.

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

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

◆ SETUPDI_DeleteDevKey()

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

Definition at line 6014 of file devinst.c.

6015 {
6016  FIXME("\n");
6017  return FALSE;
6018 }
#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 6020 of file devinst.c.

6021 {
6022  FIXME("\n");
6023  return FALSE;
6024 }
#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 5837 of file devinst.c.

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

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

◆ SETUPDI_OpenDrvKey()

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

Definition at line 5853 of file devinst.c.

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

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

◆ 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:6286
#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:1858
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:2004
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
#define debugstr_w
Definition: kernel32.h:32
#define CR_SUCCESS
Definition: cfgmgr32.h:842
_In_ DWORD ClassGuidListSize
Definition: setupapi.h: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:4116
CONFIGRET WINAPI CM_Connect_MachineW(_In_opt_ PCWSTR UNCServerName, _Out_ PHMACHINE phMachine)
Definition: cfgmgr.c:1236
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define DIBCI_NODISPLAYCLASS
Definition: setupapi.h:109
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define DIBCI_NOINSTALLCLASS
Definition: setupapi.h:108
#define NULL
Definition: types.h:112
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define REGSTR_VAL_NOINSTALLCLASS
Definition: regstr.h:239
#define REGSTR_VAL_NODISPLAYCLASS
Definition: regstr.h:240
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
#define __FUNCTION__
Definition: types.h:112
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define RegDisposition_OpenExisting
Definition: cfgmgr32.h:610

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

◆ SetupDiCallClassInstaller()

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

Definition at line 4020 of file devinst.c.

4024 {
4025  BOOL ret = FALSE;
4026 
4027  TRACE("%s(%u %p %p)\n", __FUNCTION__, InstallFunction, DeviceInfoSet, DeviceInfoData);
4028 
4029  if (!DeviceInfoSet)
4035  else if (((struct DeviceInfoSet *)DeviceInfoSet)->HKLM != HKEY_LOCAL_MACHINE)
4037  else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
4039  else
4040  {
4042 #define CLASS_COINSTALLER 0x1
4043 #define DEVICE_COINSTALLER 0x2
4044 #define CLASS_INSTALLER 0x4
4045  UCHAR CanHandle = 0;
4047 
4048  switch (InstallFunction)
4049  {
4052  break;
4055  break;
4056  case DIF_ALLOW_INSTALL:
4057  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4058  break;
4059  case DIF_DETECT:
4060  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4061  break;
4063  CanHandle = CLASS_INSTALLER;
4064  break;
4065  case DIF_INSTALLDEVICE:
4068  break;
4070  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4072  break;
4073  case DIF_INSTALLINTERFACES:
4076  break;
4079  break;
4081  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4082  break;
4084  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4085  break;
4087  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4088  break;
4090  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4091  break;
4092  case DIF_POWERMESSAGEWAKE:
4094  break;
4095  case DIF_PROPERTYCHANGE:
4098  break;
4100  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4102  break;
4103  case DIF_REGISTERDEVICE:
4104  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4106  break;
4107  case DIF_REMOVE:
4110  break;
4112  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4114  break;
4115  case DIF_SELECTDEVICE:
4116  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4118  break;
4119  case DIF_TROUBLESHOOTER:
4121  break;
4122  case DIF_UNREMOVE:
4125  break;
4126  default:
4127  ERR("Install function %u not supported\n", InstallFunction);
4129  }
4130 
4133  /* Don't process this call, as a parameter is invalid */
4134  CanHandle = 0;
4135 
4136  if (CanHandle != 0)
4137  {
4138  LIST_ENTRY ClassCoInstallersListHead;
4139  LIST_ENTRY DeviceCoInstallersListHead;
4140  HMODULE ClassInstallerLibrary = NULL;
4141  CLASS_INSTALL_PROC ClassInstaller = NULL;
4144  HKEY hKey;
4145  DWORD dwRegType, dwLength;
4146  DWORD rc = NO_ERROR;
4147 
4148  InitializeListHead(&ClassCoInstallersListHead);
4149  InitializeListHead(&DeviceCoInstallersListHead);
4150 
4151  if (CanHandle & DEVICE_COINSTALLER)
4152  {
4154  if (hKey != INVALID_HANDLE_VALUE)
4155  {
4157  if (rc == ERROR_SUCCESS && dwRegType == REG_MULTI_SZ)
4158  {
4159  LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
4160  if (KeyBuffer != NULL)
4161  {
4163  if (rc == ERROR_SUCCESS)
4164  {
4165  LPWSTR ptr;
4166  for (ptr = KeyBuffer; *ptr; ptr += strlenW(ptr) + 1)
4167  {
4168  /* Add coinstaller to DeviceCoInstallersListHead list */
4169  struct CoInstallerElement *coinstaller;
4170  TRACE("Got device coinstaller '%s'\n", debugstr_w(ptr));
4171  coinstaller = HeapAlloc(GetProcessHeap(), 0, sizeof(struct CoInstallerElement));
4172  if (!coinstaller)
4173  continue;
4174  ZeroMemory(coinstaller, sizeof(struct CoInstallerElement));
4175  if (GetFunctionPointer(ptr, &coinstaller->Module, (PVOID*)&coinstaller->Function) == ERROR_SUCCESS)
4176  InsertTailList(&DeviceCoInstallersListHead, &coinstaller->ListEntry);
4177  else
4178  HeapFree(GetProcessHeap(), 0, coinstaller);
4179  }
4180  }
4181  HeapFree(GetProcessHeap(), 0, KeyBuffer);
4182  }
4183  }
4184  RegCloseKey(hKey);
4185  }
4186  }
4187  if (CanHandle & CLASS_COINSTALLER)
4188  {
4189  rc = RegOpenKeyExW(
4192  0, /* Options */
4194  &hKey);
4195  if (rc == ERROR_SUCCESS)
4196  {
4197  WCHAR szGuidString[40];
4198  if (pSetupStringFromGuid(&DeviceInfoData->ClassGuid, szGuidString, ARRAYSIZE(szGuidString)) == ERROR_SUCCESS)
4199  {
4200  rc = RegQueryValueExW(hKey, szGuidString, NULL, &dwRegType, NULL, &dwLength);
4201  if (rc == ERROR_SUCCESS && dwRegType == REG_MULTI_SZ)
4202  {
4203  LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
4204  if (KeyBuffer != NULL)
4205  {
4206  rc = RegQueryValueExW(hKey, szGuidString, NULL, NULL, (LPBYTE)KeyBuffer, &dwLength);
4207  if (rc == ERROR_SUCCESS)
4208  {
4209  LPWSTR ptr;
4210  for (ptr = KeyBuffer; *ptr; ptr += strlenW(ptr) + 1)
4211  {
4212  /* Add coinstaller to ClassCoInstallersListHead list */
4213  struct CoInstallerElement *coinstaller;
4214  TRACE("Got class coinstaller '%s'\n", debugstr_w(ptr));
4215  coinstaller = HeapAlloc(GetProcessHeap(), 0, sizeof(struct CoInstallerElement));
4216  if (!coinstaller)
4217  continue;
4218  ZeroMemory(coinstaller, sizeof(struct CoInstallerElement));
4219  if (GetFunctionPointer(ptr, &coinstaller->Module, (PVOID*)&coinstaller->Function) == ERROR_SUCCESS)
4220  InsertTailList(&ClassCoInstallersListHead, &coinstaller->ListEntry);
4221  else
4222  HeapFree(GetProcessHeap(), 0, coinstaller);
4223  }
4224  }
4225  HeapFree(GetProcessHeap(), 0, KeyBuffer);
4226  }
4227  }
4228  }
4229  RegCloseKey(hKey);
4230  }
4231  }
4232  if ((CanHandle & CLASS_INSTALLER) && !(InstallParams.FlagsEx & DI_FLAGSEX_CI_FAILED))
4233  {
4235  if (hKey != INVALID_HANDLE_VALUE)
4236  {
4238  if (rc == ERROR_SUCCESS && dwRegType == REG_SZ)
4239  {
4240  LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
4241  if (KeyBuffer != NULL)
4242  {
4244  if (rc == ERROR_SUCCESS)
4245  {
4246  /* Get ClassInstaller function pointer */
4247  TRACE("Got class installer '%s'\n", debugstr_w(KeyBuffer));
4248  if (GetFunctionPointer(KeyBuffer, &ClassInstallerLibrary, (PVOID*)&ClassInstaller) != ERROR_SUCCESS)
4249  {
4250  InstallParams.FlagsEx |= DI_FLAGSEX_CI_FAILED;
4252  }
4253  }
4254  HeapFree(GetProcessHeap(), 0, KeyBuffer);
4255  }
4256  }
4257  RegCloseKey(hKey);
4258  }
4259  }
4260 
4261  /* Call Class co-installers */
4262  Context.PostProcessing = FALSE;
4263  rc = NO_ERROR;
4264  ListEntry = ClassCoInstallersListHead.Flink;
4265  while (rc == NO_ERROR && ListEntry != &ClassCoInstallersListHead)
4266  {
4267  struct CoInstallerElement *coinstaller;
4268  coinstaller = CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry);
4269  rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4270  coinstaller->PrivateData = Context.PrivateData;
4272  {
4273  coinstaller->DoPostProcessing = TRUE;
4274  rc = NO_ERROR;
4275  }
4277  }
4278 
4279  /* Call Device co-installers */
4280  ListEntry = DeviceCoInstallersListHead.Flink;
4281  while (rc == NO_ERROR && ListEntry != &DeviceCoInstallersListHead)
4282  {
4283  struct CoInstallerElement *coinstaller;
4284  coinstaller = CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry);
4285  rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4286  coinstaller->PrivateData = Context.PrivateData;
4288  {
4289  coinstaller->DoPostProcessing = TRUE;
4290  rc = NO_ERROR;
4291  }
4293  }
4294 
4295  /* Call Class installer */
4296  if (ClassInstaller)
4297  {
4298  rc = (*ClassInstaller)(InstallFunction, DeviceInfoSet, DeviceInfoData);
4299  FreeFunctionPointer(ClassInstallerLibrary, ClassInstaller);
4300  }
4301  else
4302  rc = ERROR_DI_DO_DEFAULT;
4303 
4304  /* Call default handler */
4305  if (rc == ERROR_DI_DO_DEFAULT)
4306  {
4307  if (DefaultHandler && !(InstallParams.Flags & DI_NODI_DEFAULTACTION))
4308  {
4310  rc = NO_ERROR;
4311  else
4312  rc = GetLastError();
4313  }
4314  else
4315  rc = NO_ERROR;
4316  }
4317 
4318  /* Call Class co-installers that required postprocessing */
4319  Context.PostProcessing = TRUE;
4320  ListEntry = ClassCoInstallersListHead.Flink;
4321  while (ListEntry != &ClassCoInstallersListHead)
4322  {
4323  struct CoInstallerElement *coinstaller;
4324  coinstaller = CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry);
4325  if (coinstaller->DoPostProcessing)
4326  {
4327  Context.InstallResult = rc;
4328  Context.PrivateData = coinstaller->PrivateData;
4329  rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4330  }
4331  FreeFunctionPointer(coinstaller->Module, coinstaller->Function);
4333  }
4334 
4335  /* Call Device co-installers that required postprocessing */
4336  ListEntry = DeviceCoInstallersListHead.Flink;
4337  while (ListEntry != &DeviceCoInstallersListHead)
4338  {
4339  struct CoInstallerElement *coinstaller;
4340  coinstaller = CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry);
4341  if (coinstaller->DoPostProcessing)
4342  {
4343  Context.InstallResult = rc;
4344  Context.PrivateData = coinstaller->PrivateData;
4345  rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4346  }
4347  FreeFunctionPointer(coinstaller->Module, coinstaller->Function);
4349  }
4350 
4351  /* Free allocated memory */
4352  while (!IsListEmpty(&ClassCoInstallersListHead))
4353  {
4354  ListEntry = RemoveHeadList(&ClassCoInstallersListHead);
4356  }
4357  while (!IsListEmpty(&DeviceCoInstallersListHead))
4358  {
4359  ListEntry = RemoveHeadList(&DeviceCoInstallersListHead);
4361  }
4362 
4363  ret = (rc == NO_ERROR);
4364  }
4365  }
4366 
4367  TRACE("Returning %d\n", ret);
4368  return ret;
4369 }
#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:4554
#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:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define ZeroMemory
Definition: winbase.h:1664
BOOL WINAPI SetupDiUnremoveDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: stubs.c:96
#define REGSTR_PATH_CODEVICEINSTALLERS
Definition: regstr.h:480
#define DIF_NEWDEVICEWIZARD_PREANALYZE
Definition: setupapi.h:147
LIST_ENTRY ListEntry
Definition: devinst.c: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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
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:5361
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:4447
static BOOL WINAPI IntSetupDiRegisterDeviceInfo(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:4010
#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:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:85
DWORD FreeFunctionPointer(IN HMODULE ModulePointer, IN PVOID FunctionPointer)
Definition: misc.c:105
DWORD GetFunctionPointer(IN PWSTR InstallerName, OUT HMODULE *ModulePointer, OUT PVOID *FunctionPointer)
Definition: misc.c:44
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1528
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DIF_TROUBLESHOOTER
Definition: setupapi.h:157
#define SetLastError(x)
Definition: compat.h:611
DWORD WINAPI pSetupStringFromGuid(LPGUID lpGUID, PWSTR pString, DWORD dwStringLen)
Definition: misc.c:1775
BOOL WINAPI SetupDiRegisterCoDeviceInstallers(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5207
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:5067
Definition: typedefs.h:119
HKEY SETUPDI_OpenDrvKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5853
#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:5193
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:1034
#define DIF_ALLOW_INSTALL
Definition: setupapi.h:143
#define DIF_REMOVE
Definition: setupapi.h:124
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define DIF_NEWDEVICEWIZARD_PRESELECT
Definition: setupapi.h:145
#define DIF_SELECTBESTCOMPATDRV
Definition: setupapi.h:142
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define DIF_DETECT
Definition: setupapi.h:134
#define ERROR_DI_POSTPROCESSING_REQUIRED
Definition: setupapi.h: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:594
HKEY WINAPI SetupDiOpenClassRegKey(const GUID *ClassGuid, REGSAM samDesired)
Definition: devinst.c:3614
#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 5067 of file devinst.c.

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

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:611
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define __FUNCTION__
Definition: types.h:112
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
BOOL WINAPI SetupDiClassGuidsFromNameExW(LPCWSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCWSTR MachineName, PVOID Reserved)
Definition: devinst.c: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:590
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1291
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
RPC_STATUS WINAPI UuidFromStringW(RPC_WSTR s, UUID *uuid)
Definition: rpcrt4_main.c:612
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define DIOCR_INSTALLER
Definition: setupapi.h:176
_In_ DWORD ClassGuidListSize
Definition: setupapi.h: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:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:85
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
HKEY WINAPI SetupDiOpenClassRegKeyExW(const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:3658
#define MAX_CLASS_NAME_LEN
Definition: cfgmgr32.h:52
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527
#define __FUNCTION__
Definition: types.h:112
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by SetupDiClassGuidsFromNameExA(), and SetupDiClassGuidsFromNameW().

◆ SetupDiClassGuidsFromNameW()

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

Definition at line 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:611
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define NULL
Definition: types.h:112
#define MAX_CLASS_NAME_LEN
Definition: cfgmgr32.h:52
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
WCHAR * LPWSTR
Definition: xmlstorage.h:184
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by SetupDiClassNameFromGuidA().

◆ SetupDiClassNameFromGuidExW()

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

Definition at line 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:590
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1291
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define DIOCR_INSTALLER
Definition: setupapi.h:176
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
Definition: bufpool.h:45
#define debugstr_guid
Definition: kernel32.h:35
PVOID QueryRegistryValue(HANDLE RegHandle, PWCHAR ValueName, LPDWORD RegistryType, LPDWORD Length)
Definition: registry.c:67
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:85
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define ERROR_INVALID_CLASS
Definition: setupapi.h:302
#define NULL
Definition: types.h:112
HKEY WINAPI SetupDiOpenClassRegKeyExW(const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:3658
_Must_inspect_result_