ReactOS 0.4.17-dev-806-gffa4164
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 WINAPI SetupDiGetActualModelsSectionW (_In_ PINFCONTEXT Context, _In_opt_ PSP_ALTPLATFORM_INFO AlternatePlatformInfo, _Out_writes_opt_(InfSectionWithExtSize) PWSTR InfSectionWithExt, _In_ DWORD InfSectionWithExtSize, _Out_opt_ PDWORD RequiredSize, _Reserved_ PVOID Reserved)
 Returns the appropriate decorated INF Models section for a device.
 
BOOL WINAPI SetupDiGetActualModelsSectionA (_In_ PINFCONTEXT Context, _In_opt_ PSP_ALTPLATFORM_INFO AlternatePlatformInfo, _Out_writes_opt_(InfSectionWithExtSize) PSTR InfSectionWithExt, _In_ DWORD InfSectionWithExtSize, _Out_opt_ PDWORD RequiredSize, _Reserved_ PVOID Reserved)
 ANSI version of SetupDiGetActualModelsSectionW.
 
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)
 
BOOL WINAPI SetupDiGetCustomDevicePropertyA (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData, IN PCSTR CustomPropertyName, IN DWORD Flags, OUT PDWORD PropertyRegDataType OPTIONAL, OUT PBYTE PropertyBuffer, IN DWORD PropertyBufferSize, OUT PDWORD RequiredSize OPTIONAL)
 
BOOL WINAPI SetupDiGetCustomDevicePropertyW (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData, IN PCWSTR CustomPropertyName, IN DWORD Flags, OUT PDWORD PropertyRegDataType OPTIONAL, OUT PBYTE PropertyBuffer, IN DWORD PropertyBufferSize, OUT PDWORD RequiredSize OPTIONAL)
 

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

◆ COINSTALLER_PROC

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

Function Documentation

◆ CheckDeviceInstallParameters()

static BOOL CheckDeviceInstallParameters ( IN PSP_DEVINSTALL_PARAMS_W  DeviceInstallParams)
static

Definition at line 4788 of file devinst.c.

4790{
4791 DWORD SupportedFlags =
4792 DI_NOVCP | /* 0x00000008 */
4793 DI_DIDCOMPAT | /* 0x00000010 */
4794 DI_DIDCLASS | /* 0x00000020 */
4795 DI_NEEDRESTART | /* 0x00000080 */
4796 DI_NEEDREBOOT | /* 0x00000100 */
4797 DI_RESOURCEPAGE_ADDED | /* 0x00002000 */
4798 DI_PROPERTIES_CHANGE | /* 0x00004000 */
4799 DI_ENUMSINGLEINF | /* 0x00010000 */
4800 DI_DONOTCALLCONFIGMG | /* 0x00020000 */
4801 DI_CLASSINSTALLPARAMS | /* 0x00100000 */
4802 DI_NODI_DEFAULTACTION | /* 0x00200000 */
4803 DI_QUIETINSTALL | /* 0x00800000 */
4804 DI_NOFILECOPY | /* 0x01000000 */
4805 DI_DRIVERPAGE_ADDED; /* 0x04000000 */
4806 DWORD SupportedFlagsEx =
4807 DI_FLAGSEX_CI_FAILED | /* 0x00000004 */
4808 DI_FLAGSEX_DIDINFOLIST | /* 0x00000010 */
4809 DI_FLAGSEX_DIDCOMPATINFO | /* 0x00000020 */
4810 DI_FLAGSEX_ALLOWEXCLUDEDDRVS | /* 0x00000800 */
4811 DI_FLAGSEX_NO_DRVREG_MODIFY | /* 0x00008000 */
4812 DI_FLAGSEX_INSTALLEDDRIVER; /* 0x04000000 */
4813 BOOL ret = FALSE;
4814
4815 /* FIXME: add support for more flags */
4816
4817 /* FIXME: DI_CLASSINSTALLPARAMS flag is not correctly used.
4818 * It should be checked before accessing to other values
4819 * of the SP_DEVINSTALL_PARAMS structure */
4820
4821 if (DeviceInstallParams->Flags & ~SupportedFlags)
4822 {
4823 FIXME("Unknown Flags: 0x%08lx\n", DeviceInstallParams->Flags & ~SupportedFlags);
4825 }
4826 else if (DeviceInstallParams->FlagsEx & ~SupportedFlagsEx)
4827 {
4828 FIXME("Unknown FlagsEx: 0x%08lx\n", DeviceInstallParams->FlagsEx & ~SupportedFlagsEx);
4830 }
4831 else if ((DeviceInstallParams->Flags & DI_NOVCP)
4832 && (DeviceInstallParams->FileQueue == NULL || DeviceInstallParams->FileQueue == (HSPFILEQ)INVALID_HANDLE_VALUE))
4834 else
4835 {
4836 /* FIXME: check Reserved field */
4837 ret = TRUE;
4838 }
4839
4840 return ret;
4841}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
return ret
Definition: mutex.c:147
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DI_FLAGSEX_CI_FAILED
Definition: setupapi.h:81
#define DI_FLAGSEX_NO_DRVREG_MODIFY
Definition: setupapi.h:93
#define DI_NEEDRESTART
Definition: setupapi.h:55
#define DI_DIDCOMPAT
Definition: setupapi.h:52
#define DI_NODI_DEFAULTACTION
Definition: setupapi.h:69
#define DI_NOVCP
Definition: setupapi.h:51
#define DI_CLASSINSTALLPARAMS
Definition: setupapi.h:68
#define DI_QUIETINSTALL
Definition: setupapi.h:70
#define DI_RESOURCEPAGE_ADDED
Definition: setupapi.h:61
#define DI_FLAGSEX_DIDCOMPATINFO
Definition: setupapi.h:83
#define DI_ENUMSINGLEINF
Definition: setupapi.h:64
#define DI_DRIVERPAGE_ADDED
Definition: setupapi.h:73
#define DI_FLAGSEX_DIDINFOLIST
Definition: setupapi.h:82
#define DI_NEEDREBOOT
Definition: setupapi.h:56
#define DI_NOFILECOPY
Definition: setupapi.h:71
#define DI_PROPERTIES_CHANGE
Definition: setupapi.h:62
#define DI_FLAGSEX_ALLOWEXCLUDEDDRVS
Definition: setupapi.h:89
#define DI_DIDCLASS
Definition: setupapi.h:53
#define DI_DONOTCALLCONFIGMG
Definition: setupapi.h:65
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1448
#define ERROR_INVALID_FLAGS
Definition: winerror.h:907

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
359cleanup:
360 MyFree(Section);
361 return ret;
362}
#define ERR(fmt,...)
Definition: precomp.h:57
#define wcschr
Definition: compat.h:17
static void cleanup(void)
Definition: main.c:1335
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
#define EINVAL
Definition: errno.h:44
#define ERANGE
Definition: errno.h:55
#define errno
Definition: errno.h:120
#define ULONG_MAX
Definition: limits.h:31
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
LPWSTR WINAPI pSetupDuplicateString(LPCWSTR lpSrc)
Definition: misc.c:198
#define __FUNCTION__
Definition: types.h:116
ULONG MajorVersion
Definition: ros_glue.cpp:4
ULONG MinorVersion
Definition: ros_glue.cpp:5
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 debugstr_w
Definition: kernel32.h:32
#define PROCESSOR_ARCHITECTURE_IA64
Definition: ketypes.h:111
#define PROCESSOR_ARCHITECTURE_ALPHA
Definition: ketypes.h:107
#define PROCESSOR_ARCHITECTURE_UNKNOWN
Definition: ketypes.h:115
#define PROCESSOR_ARCHITECTURE_MIPS
Definition: ketypes.h:106
#define PROCESSOR_ARCHITECTURE_PPC
Definition: ketypes.h:108
#define PROCESSOR_ARCHITECTURE_AMD64
Definition: ketypes.h:114
#define PROCESSOR_ARCHITECTURE_INTEL
Definition: ketypes.h:105
#define VER_PLATFORM_WIN32_NT
Definition: rtltypes.h:246
#define VER_PLATFORM_WIN32_WINDOWS
Definition: rtltypes.h:245
#define UNICODE_NULL
short WCHAR
Definition: pedump.c:58
#define TRACE(s)
Definition: solgame.cpp:4
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint16_t * LPWSTR
Definition: typedefs.h:56
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define strlenW(s)
Definition: unicode.h:28
#define strtoulW(s1, s2, b)
Definition: unicode.h:41

Referenced by GetSectionCallback(), and SetupDiGetActualModelsSectionW().

◆ CreateDeviceInfo()

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

Definition at line 771 of file devinst.c.

776{
777 DWORD size;
778 CONFIGRET cr;
779 struct DeviceInfo *deviceInfo;
780
781 *pDeviceInfo = NULL;
782
783 size = FIELD_OFFSET(struct DeviceInfo, Data) + (strlenW(InstancePath) + 1) * sizeof(WCHAR);
784 deviceInfo = HeapAlloc(GetProcessHeap(), 0, size);
785 if (!deviceInfo)
786 {
788 return FALSE;
789 }
790 ZeroMemory(deviceInfo, size);
791
792 cr = CM_Locate_DevNode_ExW(&deviceInfo->dnDevInst, (DEVINSTID_W)InstancePath, CM_LOCATE_DEVNODE_PHANTOM, list->hMachine);
793 if (cr != CR_SUCCESS)
794 {
796 return FALSE;
797 }
798
799 deviceInfo->set = list;
800 deviceInfo->InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
801 strcpyW(deviceInfo->Data, InstancePath);
802 deviceInfo->instanceId = deviceInfo->Data;
803 deviceInfo->UniqueId = strrchrW(deviceInfo->Data, '\\');
804 deviceInfo->DeviceDescription = NULL;
805 memcpy(&deviceInfo->ClassGuid, pClassGuid, sizeof(GUID));
806 deviceInfo->CreationFlags = 0;
809
810 *pDeviceInfo = deviceInfo;
811 return TRUE;
812}
_Null_terminated_ WCHAR * DEVINSTID_W
Definition: cfgmgr32.h:80
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define CM_LOCATE_DEVNODE_PHANTOM
Definition: cfgmgr32.h:761
CONFIGRET WINAPI CM_Locate_DevNode_ExW(_Out_ PDEVINST pdnDevInst, _In_opt_ DEVINSTID_W pDeviceID, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:6077
Definition: list.h:37
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
DWORD GetErrorCodeFromCrCode(const IN CONFIGRET cr)
Definition: devinst.c:94
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
GLsizeiptr size
Definition: glext.h:5919
#define ZeroMemory
Definition: minwinbase.h:31
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define list
Definition: rosglue.h:35
struct _SP_DEVINSTALL_PARAMS_W SP_DEVINSTALL_PARAMS_W
PCWSTR DeviceDescription
LIST_ENTRY InterfaceListHead
WCHAR Data[ANYSIZE_ARRAY]
DEVINST dnDevInst
SP_DEVINSTALL_PARAMS_W InstallParams
LIST_ENTRY DriverListHead
struct DeviceInfoSet * set
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define strrchrW(s, c)
Definition: unicode.h:35
#define strcpyW(d, s)
Definition: unicode.h:29

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

◆ DestroyClassInstallParams()

static BOOL DestroyClassInstallParams ( struct ClassInstallParams installParams)
static

Definition at line 816 of file devinst.c.

817{
818 HeapFree(GetProcessHeap(), 0, installParams->PropChangeParams);
819 HeapFree(GetProcessHeap(), 0, installParams->AddPropertyPageData);
820 return TRUE;
821}
#define HeapFree(x, y, z)
Definition: compat.h:735
PSP_PROPCHANGE_PARAMS PropChangeParams
PSP_ADDPROPERTYPAGE_DATA AddPropertyPageData

Referenced by DestroyDeviceInfo(), and DestroyDeviceInfoSet().

◆ DestroyDeviceInfo()

static BOOL DestroyDeviceInfo ( struct DeviceInfo deviceInfo)
static

Definition at line 824 of file devinst.c.

825{
826 PLIST_ENTRY ListEntry;
827 struct DriverInfoElement *driverInfo;
828 struct DeviceInterface *deviceInterface;
829
830 while (!IsListEmpty(&deviceInfo->DriverListHead))
831 {
834 if (!DestroyDriverInfoElement(driverInfo))
835 return FALSE;
836 }
837 while (!IsListEmpty(&deviceInfo->InterfaceListHead))
838 {
840 deviceInterface = CONTAINING_RECORD(ListEntry, struct DeviceInterface, ListEntry);
841 if (!DestroyDeviceInterface(deviceInterface))
842 return FALSE;
843 }
845 if (deviceInfo->hmodDevicePropPageProvider)
847 return HeapFree(GetProcessHeap(), 0, deviceInfo);
848}
#define FreeLibrary(x)
Definition: compat.h:748
static BOOL DestroyClassInstallParams(struct ClassInstallParams *installParams)
Definition: devinst.c:816
BOOL DestroyDriverInfoElement(struct DriverInfoElement *driverInfo)
Definition: driver.c:94
BOOL DestroyDeviceInterface(struct DeviceInterface *deviceInterface)
Definition: interface.c:61
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
struct ClassInstallParams ClassInstallParams
HMODULE hmodDevicePropPageProvider
LIST_ENTRY ListEntry
Definition: typedefs.h:120
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

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

◆ DestroyDeviceInfoSet()

static BOOL DestroyDeviceInfoSet ( struct DeviceInfoSet list)
static

Definition at line 851 of file devinst.c.

852{
853 PLIST_ENTRY ListEntry;
854 struct DeviceInfo *deviceInfo;
855
856 while (!IsListEmpty(&list->ListHead))
857 {
858 ListEntry = RemoveHeadList(&list->ListHead);
859 deviceInfo = CONTAINING_RECORD(ListEntry, struct DeviceInfo, ListEntry);
860 if (!DestroyDeviceInfo(deviceInfo))
861 return FALSE;
862 }
863 if (list->HKLM != HKEY_LOCAL_MACHINE)
864 RegCloseKey(list->HKLM);
865 CM_Disconnect_Machine(list->hMachine);
866 DestroyClassInstallParams(&list->ClassInstallParams);
867 if (list->hmodClassPropPageProvider)
868 FreeLibrary(list->hmodClassPropPageProvider);
869 return HeapFree(GetProcessHeap(), 0, list);
870}
#define RegCloseKey(hKey)
Definition: registry.h:49
CONFIGRET WINAPI CM_Disconnect_Machine(_In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:1892
static BOOL DestroyDeviceInfo(struct DeviceInfo *deviceInfo)
Definition: devinst.c:824
LIST_ENTRY ListEntry
#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_INVALID_PROPERTY
Definition: cfgmgr32.h:899
#define CR_INVALID_DATA
Definition: cfgmgr32.h:877
#define CR_INVALID_DEVICE_ID
Definition: cfgmgr32.h:876
#define CR_OUT_OF_MEMORY
Definition: cfgmgr32.h:844
#define CR_FAILURE
Definition: cfgmgr32.h:865
#define CR_ACCESS_DENIED
Definition: cfgmgr32.h:897
#define CR_INVALID_MACHINENAME
Definition: cfgmgr32.h:893
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
#define CR_ALREADY_SUCH_DEVINST
Definition: cfgmgr32.h:862
#define CR_NO_SUCH_DEVNODE
Definition: cfgmgr32.h:857
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
#define CR_NO_SUCH_VALUE
Definition: cfgmgr32.h:883
#define CR_NO_SUCH_REGISTRY_KEY
Definition: cfgmgr32.h:892
#define CR_INVALID_DEVNODE
Definition: cfgmgr32.h:847
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define ERROR_DEVINST_ALREADY_EXISTS
Definition: setupapi.h:306
#define ERROR_GEN_FAILURE
Definition: winerror.h:256
#define ERROR_INVALID_COMPUTERNAME
Definition: winerror.h:1042

Referenced by CreateDeviceInfo(), ResetDevice(), SETUP_CreateDevicesList(), SetupDiBuildClassInfoListExW(), SetupDiCreateDeviceInfoListExW(), SetupDiCreateDeviceInfoW(), SetupDiGetClassRegistryPropertyA(), SetupDiGetClassRegistryPropertyW(), SetupDiGetCustomDevicePropertyA(), SetupDiGetCustomDevicePropertyW(), SetupDiRestartDevices(), SetupDiSetClassRegistryPropertyA(), SetupDiSetClassRegistryPropertyW(), 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
399bettersection:
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
407done:
408 return TRUE;
409}
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
_In_ PVOID Context
Definition: storport.h:2269

Referenced by SetupDiGetActualSectionToInstallExW().

◆ InfIsFromOEMLocation()

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

Definition at line 5600 of file devinst.c.

5603{
5604 PWCHAR last;
5605
5606 last = strrchrW(FullName, '\\');
5607 if (!last)
5608 {
5609 /* No directory specified */
5610 *IsOEMLocation = FALSE;
5611 }
5612 else
5613 {
5614 LPWSTR Windir;
5615 UINT ret;
5616
5617 Windir = MyMalloc((MAX_PATH + 1 + strlenW(InfDirectory)) * sizeof(WCHAR));
5618 if (!Windir)
5619 {
5621 return FALSE;
5622 }
5623
5625 if (ret == 0 || ret > MAX_PATH)
5626 {
5627 MyFree(Windir);
5629 return FALSE;
5630 }
5631 if (*Windir && Windir[strlenW(Windir) - 1] != '\\')
5632 strcatW(Windir, BackSlash);
5633 strcatW(Windir, InfDirectory);
5634
5635 if (strncmpiW(FullName, Windir, last - FullName) == 0)
5636 {
5637 /* The path is %SYSTEMROOT%\Inf */
5638 *IsOEMLocation = FALSE;
5639 }
5640 else
5641 {
5642 /* The file is in another place */
5643 *IsOEMLocation = TRUE;
5644 }
5645 MyFree(Windir);
5646 }
5647 return TRUE;
5648}
#define MAX_PATH
Definition: compat.h:34
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2316
static const WCHAR BackSlash[]
Definition: devinst.c:27
static const WCHAR InfDirectory[]
Definition: devinst.c:32
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
unsigned int UINT
Definition: sysinfo.c:13
static const LARGE_INTEGER *static const HANDLE const LARGE_INTEGER *static PSLIST_ENTRY PSLIST_ENTRY last
Definition: sync.c:64
uint16_t * PWCHAR
Definition: typedefs.h:56
#define strcatW(d, s)
Definition: unicode.h:30
_In_ PSTRING FullName
Definition: rtlfuncs.h:1665

Referenced by SetupDiInstallDevice().

◆ IntSetupDiRegisterDeviceInfo()

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

Definition at line 4303 of file devinst.c.

4306{
4308}
BOOL WINAPI SetupDiRegisterDeviceInfo(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Flags, PSP_DETSIG_CMPPROC CompareProc, PVOID CompareContext, PSP_DEVINFO_DATA DupDeviceInfoData)
Definition: devinst.c:1954
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1559

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

3654{
3655 BOOL ret = FALSE;
3656 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
3657 struct DeviceInfo *deviceInfo;
3658
3659 TRACE("%s(%p %p %d %p %d)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData, Property,
3661
3663 {
3665 return FALSE;
3666 }
3667 if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
3668 {
3670 return FALSE;
3671 }
3674 {
3676 return FALSE;
3677 }
3678
3679 deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
3680
3681 if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
3683 && PropertyMap[Property].nameA)
3684 {
3685 HKEY hKey;
3686 LONG l;
3687 hKey = SETUPDI_OpenDevKey(set->HKLM, deviceInfo, KEY_SET_VALUE);
3689 return FALSE;
3690 /* Write new data */
3691 if (isAnsi)
3692 {
3693 l = RegSetValueExA(
3694 hKey, PropertyMap[Property].nameA, 0,
3697 }
3698 else
3699 {
3700 l = RegSetValueExW(
3704 }
3705 if (!l)
3706 ret = TRUE;
3707 else
3708 SetLastError(l);
3710 }
3711 else
3712 {
3713 ERR("Property 0x%lx not implemented\n", Property);
3715 }
3716
3717 TRACE("Returning %d\n", ret);
3718 return ret;
3719}
static const WCHAR nameW[]
Definition: main.c:49
r l[0]
Definition: byte_order.h:168
Definition: _set.h:50
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4799
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:4882
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
HKEY SETUPDI_OpenDevKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:6130
static struct PropertyMapEntry PropertyMap[]
Definition: devinst.c:3387
FxAutoRegKey hKey
if(dx< 0)
Definition: linetemp.h:194
#define KEY_SET_VALUE
Definition: nt_native.h:1020
long LONG
Definition: pedump.c:60
_In_ DWORD _Out_opt_ PDWORD _In_ DWORD PropertyBufferSize
Definition: setupapi.h:1584
#define SETUP_DEVICE_INFO_SET_MAGIC
ULONG_PTR Reserved
Definition: setupapi.h:841
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
Definition: wdfdevice.h:4443

Referenced by SetupDiSetDeviceRegistryPropertyA(), and SetupDiSetDeviceRegistryPropertyW().

◆ IsDeviceInfoInDeviceInfoSet()

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

Definition at line 4979 of file devinst.c.

4982{
4983 PLIST_ENTRY ListEntry;
4984
4985 ListEntry = deviceInfoSet->ListHead.Flink;
4986 while (ListEntry != &deviceInfoSet->ListHead)
4987 {
4988 if (deviceInfo == CONTAINING_RECORD(ListEntry, struct DeviceInfo, ListEntry))
4989 return TRUE;
4990
4991 ListEntry = ListEntry->Flink;
4992 }
4993
4994 return FALSE;
4995}
LIST_ENTRY ListHead
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121

Referenced by SetupDiDeleteDeviceInfo().

◆ OpenHardwareProfileKey()

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

Definition at line 4924 of file devinst.c.

4928{
4929 HKEY hHWProfilesKey = NULL;
4930 HKEY hHWProfileKey = NULL;
4932 LONG rc;
4933
4934 rc = RegOpenKeyExW(HKLM,
4936 0,
4938 &hHWProfilesKey);
4939 if (rc != ERROR_SUCCESS)
4940 {
4941 SetLastError(rc);
4942 goto cleanup;
4943 }
4944 if (HwProfile == 0)
4945 {
4946 rc = RegOpenKeyExW(hHWProfilesKey,
4948 0,
4950 &hHWProfileKey);
4951 }
4952 else
4953 {
4954 WCHAR subKey[5];
4955 snprintfW(subKey, 4, InstanceKeyFormat, HwProfile);
4956 subKey[4] = '\0';
4957 rc = RegOpenKeyExW(hHWProfilesKey,
4958 subKey,
4959 0,
4961 &hHWProfileKey);
4962 }
4963 if (rc != ERROR_SUCCESS)
4964 {
4965 SetLastError(rc);
4966 goto cleanup;
4967 }
4968 ret = hHWProfileKey;
4969
4970cleanup:
4971 if (hHWProfilesKey != NULL)
4972 RegCloseKey(hHWProfilesKey);
4973 if (hHWProfileKey != NULL && hHWProfileKey != ret)
4974 RegCloseKey(hHWProfileKey);
4975 return ret;
4976}
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
static const WCHAR InstanceKeyFormat[]
Definition: devinst.c:33
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1021
#define READ_CONTROL
Definition: nt_native.h:58
static const WCHAR HKLM[]
Definition: reginf.c:58
#define REGSTR_KEY_CURRENT
Definition: regstr.h:493
#define REGSTR_PATH_HWPROFILES
Definition: regstr.h:482
#define snprintfW
Definition: unicode.h:60

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

◆ ResetDevice()

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

Definition at line 5309 of file devinst.c.

5312{
5313#ifndef __WINESRC__
5314 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
5315 struct DeviceInfo *deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
5316 CONFIGRET cr;
5317
5318 cr = CM_Enable_DevNode_Ex(deviceInfo->dnDevInst, 0, set->hMachine);
5319 if (cr != CR_SUCCESS)
5320 {
5322 return FALSE;
5323 }
5324
5325 return TRUE;
5326#else
5327 FIXME("Stub: ResetDevice(%p %p)\n", DeviceInfoSet, DeviceInfoData);
5328 return TRUE;
5329#endif
5330}
CONFIGRET WINAPI CM_Enable_DevNode_Ex(_In_ DEVINST dnDevInst, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:2012

Referenced by SetupDiChangeState(), and SetupDiInstallDevice().

◆ SETUP_CreateClassKey()

HKEY SETUP_CreateClassKey ( HINF  hInf)

Definition at line 3807 of file devinst.c.

3808{
3809 WCHAR FullBuffer[MAX_PATH];
3814
3815 /* Obtain the Class GUID for this class */
3817 hInf,
3818 Version,
3820 Buffer,
3821 sizeof(Buffer) / sizeof(WCHAR),
3822 &RequiredSize))
3823 {
3824 return INVALID_HANDLE_VALUE;
3825 }
3826
3827 /* Build the corresponding registry key name */
3828 lstrcpyW(FullBuffer, REGSTR_PATH_CLASS_NT);
3829 lstrcatW(FullBuffer, BackSlash);
3830 lstrcatW(FullBuffer, Buffer);
3831
3832 /* Obtain the Class name for this class */
3834 hInf,
3835 Version,
3837 Buffer,
3838 sizeof(Buffer) / sizeof(WCHAR),
3839 &RequiredSize))
3840 {
3841 return INVALID_HANDLE_VALUE;
3842 }
3843
3844 /* Try to open or create the registry key */
3845 TRACE("Opening class key %s\n", debugstr_w(FullBuffer));
3846#if 0 // I keep this for reference...
3848 FullBuffer,
3849 0,
3851 &hClassKey))
3852 {
3853 /* Use RegCreateKeyExW */
3854 }
3855#endif
3857 FullBuffer,
3858 0,
3859 NULL,
3862 NULL,
3863 &hClassKey,
3864 &Disposition))
3865 {
3866 ERR("RegCreateKeyExW(%s) failed\n", debugstr_w(FullBuffer));
3867 return INVALID_HANDLE_VALUE;
3868 }
3870 TRACE("The class key %s was successfully created\n", debugstr_w(FullBuffer));
3871 else
3872 TRACE("The class key %s was successfully opened\n", debugstr_w(FullBuffer));
3873
3874 TRACE( "setting value %s to %s\n", debugstr_w(REGSTR_VAL_CLASS), debugstr_w(Buffer) );
3877 0,
3878 REG_SZ,
3879 (LPBYTE)Buffer,
3880 RequiredSize * sizeof(WCHAR)))
3881 {
3884 FullBuffer);
3885 return INVALID_HANDLE_VALUE;
3886 }
3887
3888 return hClassKey;
3889}
HKEY hClassKey
Definition: umpnpmgr.c:45
Definition: bufpool.h:45
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:1096
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
#define lstrcpyW
Definition: compat.h:749
BOOL WINAPI SetupGetLineTextW(PINFCONTEXT context, HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1763
#define REG_SZ
Definition: layer.c:22
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1060
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1087
#define REGSTR_VAL_CLASSGUID
Definition: regstr.h:422
#define REGSTR_PATH_CLASS_NT
Definition: regstr.h:479
#define REGSTR_VAL_CLASS
Definition: regstr.h:291
unsigned char * LPBYTE
Definition: typedefs.h:53
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4445
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469

Referenced by SetupDiInstallClassExW().

◆ SETUPAPI_GetCurrentHwProfile()

static DWORD SETUPAPI_GetCurrentHwProfile ( IN HDEVINFO  DeviceInfoSet)
static

Definition at line 5262 of file devinst.c.

5264{
5265 HKEY hKey = NULL;
5266 DWORD dwRegType, dwLength;
5267 DWORD hwProfile;
5268 LONG rc;
5269 DWORD ret = (DWORD)-1;
5270
5273 0, /* Options */
5275 &hKey);
5276 if (rc != ERROR_SUCCESS)
5277 {
5278 SetLastError(rc);
5279 goto cleanup;
5280 }
5281
5282 dwLength = sizeof(DWORD);
5285 NULL,
5286 &dwRegType,
5287 (LPBYTE)&hwProfile, &dwLength);
5288 if (rc != ERROR_SUCCESS)
5289 {
5290 SetLastError(rc);
5291 goto cleanup;
5292 }
5293 else if (dwRegType != REG_DWORD || dwLength != sizeof(DWORD))
5294 {
5296 goto cleanup;
5297 }
5298
5299 ret = hwProfile;
5300
5301cleanup:
5302 if (hKey != NULL)
5304
5305 return ret;
5306}
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
static DWORD DWORD * dwLength
Definition: fusion.c:86
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define DWORD
Definition: nt_native.h:44
#define REGSTR_VAL_CURRENTCONFIG
Definition: regstr.h:466
#define REGSTR_PATH_IDCONFIGDB
Definition: regstr.h:41
#define REG_DWORD
Definition: sdbapi.c:615

Referenced by SetupDiChangeState().

◆ SETUPDI_CreateDevKey()

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

Definition at line 5960 of file devinst.c.

5961{
5962 HKEY enumKey, key = INVALID_HANDLE_VALUE;
5963 LONG l;
5964
5966 if (!l)
5967 {
5968 l = RegCreateKeyExW(enumKey, devInfo->instanceId, 0, NULL, REG_OPTION_NON_VOLATILE, samDesired, NULL, &key, NULL);
5969 RegCloseKey(enumKey);
5970 }
5971 if (l)
5972 SetLastError(l);
5973 return key;
5974}
#define REGSTR_PATH_SYSTEMENUM
Definition: regstr.h:483
static PMEMKEY RootKey
Definition: registry.c:55
Definition: copy.c:22

Referenced by SetupDiChangeState(), and SetupDiCreateDevRegKeyW().

◆ SETUPDI_CreateDrvKey()

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

Definition at line 5976 of file devinst.c.

5977{
5979 LPWSTR lpGuidString = NULL;
5980 LPWSTR DriverKey = NULL; /* {GUID}\Index */
5981 LPWSTR pDeviceInstance; /* Points into DriverKey, on the Index field */
5982 DWORD Index; /* Index used in the DriverKey name */
5983 DWORD dwSize;
5985 DWORD rc;
5986 HKEY hHWProfileKey = INVALID_HANDLE_VALUE;
5987 HKEY hEnumKey = NULL;
5989 HKEY hDeviceKey = INVALID_HANDLE_VALUE;
5990 HKEY hKey = NULL;
5991
5992 /* Open device key, to read Driver value */
5993 hDeviceKey = SETUPDI_OpenDevKey(RootKey, devInfo, KEY_QUERY_VALUE | KEY_SET_VALUE);
5994 if (hDeviceKey == INVALID_HANDLE_VALUE)
5995 goto cleanup;
5996
5998 if (rc != ERROR_SUCCESS)
5999 {
6000 SetLastError(rc);
6001 goto cleanup;
6002 }
6003
6004 rc = RegQueryValueExW(hDeviceKey, REGSTR_VAL_DRIVER, NULL, NULL, NULL, &dwSize);
6005 if (rc != ERROR_SUCCESS)
6006 {
6007 /* Create a new driver key */
6008
6009 if (UuidToStringW(ClassGuid, &lpGuidString) != RPC_S_OK)
6010 goto cleanup;
6011
6012 /* The driver key is in \System\CurrentControlSet\Control\Class\{GUID}\Index */
6013 DriverKey = HeapAlloc(GetProcessHeap(), 0, (strlenW(lpGuidString) + 7) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
6014 if (!DriverKey)
6015 {
6017 goto cleanup;
6018 }
6019
6020 DriverKey[0] = '{';
6021 strcpyW(&DriverKey[1], lpGuidString);
6022 pDeviceInstance = &DriverKey[strlenW(DriverKey)];
6023 *pDeviceInstance++ = '}';
6024 *pDeviceInstance++ = '\\';
6025
6026 /* Try all values for Index between 0 and 9999 */
6027 Index = 0;
6028 while (Index <= 9999)
6029 {
6030 sprintfW(pDeviceInstance, InstanceKeyFormat, Index);
6032 DriverKey,
6033 0,
6034 NULL,
6036#if _WIN32_WINNT >= 0x502
6038#else
6040#endif
6041 NULL,
6042 &hKey,
6043 &Disposition);
6044 if (rc != ERROR_SUCCESS)
6045 {
6046 SetLastError(rc);
6047 goto cleanup;
6048 }
6050 break;
6052 hKey = NULL;
6053 Index++;
6054 }
6055
6056 if (Index > 9999)
6057 {
6058 /* Unable to create more than 9999 devices within the same class */
6060 goto cleanup;
6061 }
6062
6063 /* Write the new Driver value */
6064 rc = RegSetValueExW(hDeviceKey, REGSTR_VAL_DRIVER, 0, REG_SZ, (const BYTE *)DriverKey, (strlenW(DriverKey) + 1) * sizeof(WCHAR));
6065 if (rc != ERROR_SUCCESS)
6066 {
6067 SetLastError(rc);
6068 goto cleanup;
6069 }
6070 }
6071 else
6072 {
6073 /* Open the existing driver key */
6074
6075 DriverKey = HeapAlloc(GetProcessHeap(), 0, dwSize);
6076 if (!DriverKey)
6077 {
6079 goto cleanup;
6080 }
6081
6082 rc = RegQueryValueExW(hDeviceKey, REGSTR_VAL_DRIVER, NULL, NULL, (LPBYTE)DriverKey, &dwSize);
6083 if (rc != ERROR_SUCCESS)
6084 {
6085 SetLastError(rc);
6086 goto cleanup;
6087 }
6088
6090 DriverKey,
6091 0,
6092 NULL,
6094#if _WIN32_WINNT >= 0x502
6096#else
6098#endif
6099 NULL,
6100 &hKey,
6101 &Disposition);
6102 if (rc != ERROR_SUCCESS)
6103 {
6104 SetLastError(rc);
6105 goto cleanup;
6106 }
6107 }
6108
6109 key = hKey;
6110
6111cleanup:
6112 if (lpGuidString)
6113 RpcStringFreeW(&lpGuidString);
6114 HeapFree(GetProcessHeap(), 0, DriverKey);
6115 if (hHWProfileKey != INVALID_HANDLE_VALUE)
6116 RegCloseKey(hHWProfileKey);
6117 if (hEnumKey != NULL)
6119 if (hClassKey != NULL)
6121 if (hDeviceKey != INVALID_HANDLE_VALUE)
6122 RegCloseKey(hDeviceKey);
6123 if (hKey != NULL && hKey != key)
6125
6126 TRACE("Returning 0x%p\n", hKey);
6127 return hKey;
6128}
#define _WIN32_WINNT
Definition: precomp.h:14
static HANDLE hEnumKey
Definition: devinst.c:20
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
#define KEY_READ
Definition: nt_native.h:1026
#define KEY_WRITE
Definition: nt_native.h:1034
#define REGSTR_VAL_DRIVER
Definition: regstr.h:385
#define RPC_S_OK
Definition: rpcnterr.h:22
RPC_STATUS WINAPI UuidToStringW(UUID *Uuid, RPC_WSTR *StringUuid)
Definition: rpcrt4_main.c:573
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR *String)
Definition: rpcrt4_main.c:181
_In_ WDFCOLLECTION _In_ ULONG Index
#define sprintfW
Definition: unicode.h:58
unsigned char BYTE
Definition: xxhash.c:193

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

◆ SETUPDI_DeleteDevKey()

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

Definition at line 6307 of file devinst.c.

6308{
6309 FIXME("\n");
6310 return FALSE;
6311}

Referenced by SetupDiDeleteDevRegKey().

◆ SETUPDI_DeleteDrvKey()

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

Definition at line 6313 of file devinst.c.

6314{
6315 FIXME("\n");
6316 return FALSE;
6317}

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}
GUID guid
Definition: version.c:147
static WCHAR guidStr[]
Definition: asn.c:770
Definition: dsound.c:943

Referenced by SetupDiCreateDeviceInterfaceRegKeyW(), and SetupDiOpenClassRegKeyExW().

◆ SETUPDI_OpenDevKey()

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

Definition at line 6130 of file devinst.c.

6131{
6132 HKEY enumKey, key = INVALID_HANDLE_VALUE;
6133 LONG l;
6134
6136 if (!l)
6137 {
6138 l = RegOpenKeyExW(enumKey, devInfo->instanceId, 0, samDesired, &key);
6139 RegCloseKey(enumKey);
6140 }
6141 if (l)
6142 SetLastError(l);
6143 return key;
6144}

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

6147{
6148 LPWSTR DriverKey = NULL;
6149 DWORD dwLength = 0;
6150 DWORD dwRegType;
6151 DWORD rc;
6152 HKEY hEnumKey = NULL;
6153 HKEY hKey = NULL;
6155
6158 goto cleanup;
6159 /* Read the 'Driver' key */
6161 if (rc != ERROR_SUCCESS)
6162 {
6163 SetLastError(rc);
6164 goto cleanup;
6165 }
6166 else if (dwRegType != REG_SZ)
6167 {
6169 goto cleanup;
6170 }
6171 DriverKey = HeapAlloc(GetProcessHeap(), 0, dwLength);
6172 if (!DriverKey)
6173 {
6175 goto cleanup;
6176 }
6177 rc = RegQueryValueExW(hKey, REGSTR_VAL_DRIVER, NULL, &dwRegType, (LPBYTE)DriverKey, &dwLength);
6178 if (rc != ERROR_SUCCESS)
6179 {
6180 SetLastError(rc);
6181 goto cleanup;
6182 }
6184 hKey = NULL;
6185 /* Need to open the driver key */
6186 rc = RegOpenKeyExW(
6187 RootKey,
6189 0, /* Options */
6191 &hEnumKey);
6192 if (rc != ERROR_SUCCESS)
6193 {
6194 SetLastError(rc);
6195 goto cleanup;
6196 }
6197 rc = RegOpenKeyExW(
6198 hEnumKey,
6199 DriverKey,
6200 0, /* Options */
6201 samDesired,
6202 &hKey);
6203 if (rc != ERROR_SUCCESS)
6204 {
6205 SetLastError(rc);
6206 goto cleanup;
6207 }
6208 key = hKey;
6209
6210cleanup:
6211 if (hEnumKey != NULL)
6213 if (hKey != NULL && hKey != key)
6215 if (DriverKey)
6216 HeapFree(GetProcessHeap(), 0, DriverKey);
6217 return key;
6218}

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

893{
894 TRACE("\n");
895 return SetupDiBuildClassInfoListExW(Flags, ClassGuidList,
897 NULL, NULL);
898}
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG Flags
Definition: dispmprt.h:245
BOOL WINAPI SetupDiBuildClassInfoListExW(DWORD Flags, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:965
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1284

Referenced by test_SetupDiBuildClassInfoList().

◆ SetupDiBuildClassInfoListExA()

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

Definition at line 918 of file devinst.c.

925{
926 LPWSTR MachineNameW = NULL;
927 BOOL bResult;
928
929 TRACE("%s(0x%lx %p %lu %p %s %p)\n", __FUNCTION__, Flags, ClassGuidList,
931
932 if (MachineName)
933 {
935 if (MachineNameW == NULL) return FALSE;
936 }
937
938 bResult = SetupDiBuildClassInfoListExW(Flags, ClassGuidList,
940 MachineNameW, Reserved);
941
942 MyFree(MachineNameW);
943
944 return bResult;
945}
#define CP_ACP
Definition: compat.h:109
LPWSTR WINAPI pSetupMultiByteToUnicode(LPCSTR lpMultiByteStr, UINT uCodePage)
Definition: misc.c:281
#define debugstr_a
Definition: kernel32.h:31
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1296
_Reserved_ PVOID Reserved
Definition: winddi.h:3974

◆ SetupDiBuildClassInfoListExW()

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

Definition at line 965 of file devinst.c.

972{
973 GUID CurrentClassGuid;
975 DWORD dwIndex;
976 DWORD dwGuidListIndex = 0;
977 HMACHINE hMachine = NULL;
978 CONFIGRET cr;
979
980 TRACE("%s(0x%lx %p %lu %p %s %p)\n", __FUNCTION__, Flags, ClassGuidList,
982
983 if (!RequiredSize)
984 {
986 return FALSE;
987 }
988 else if (!ClassGuidList && ClassGuidListSize > 0)
989 {
991 return FALSE;
992 }
993
994 if (MachineName)
995 {
996 cr = CM_Connect_MachineW(MachineName, &hMachine);
997 if (cr != CR_SUCCESS)
998 {
1000 return FALSE;
1001 }
1002 }
1003
1004 for (dwIndex = 0; ; dwIndex++)
1005 {
1006 cr = CM_Enumerate_Classes_Ex(dwIndex,
1007 &CurrentClassGuid,
1008 0,
1009 hMachine);
1010 if (cr == CR_SUCCESS)
1011 {
1012 TRACE("Guid: %s\n", debugstr_guid(&CurrentClassGuid));
1013 if (CM_Open_Class_Key_ExW(&CurrentClassGuid,
1014 NULL,
1017 &hClassKey,
1019 hMachine) != CR_SUCCESS)
1020 {
1022 if (hMachine)
1023 CM_Disconnect_Machine(hMachine);
1024 return FALSE;
1025 }
1026
1029 NULL,
1030 NULL,
1031 NULL,
1032 NULL))
1033 {
1034 TRACE("'NoUseClass' value found!\n");
1036 continue;
1037 }
1038
1039 if ((Flags & DIBCI_NOINSTALLCLASS) &&
1042 NULL,
1043 NULL,
1044 NULL,
1045 NULL)))
1046 {
1047 TRACE("'NoInstallClass' value found!\n");
1049 continue;
1050 }
1051
1052 if ((Flags & DIBCI_NODISPLAYCLASS) &&
1055 NULL,
1056 NULL,
1057 NULL,
1058 NULL)))
1059 {
1060 TRACE("'NoDisplayClass' value found!\n");
1062 continue;
1063 }
1064
1066
1067 if (dwGuidListIndex < ClassGuidListSize)
1068 {
1069 ClassGuidList[dwGuidListIndex] = CurrentClassGuid;
1070 }
1071
1072 dwGuidListIndex++;
1073 }
1074
1075 if (cr != ERROR_SUCCESS)
1076 break;
1077 }
1078
1079 if (hMachine)
1080 CM_Disconnect_Machine(hMachine);
1081
1082 if (RequiredSize != NULL)
1083 *RequiredSize = dwGuidListIndex;
1084
1085 if (ClassGuidListSize < dwGuidListIndex)
1086 {
1088 return FALSE;
1089 }
1090
1091 return TRUE;
1092}
#define CM_OPEN_CLASS_KEY_INSTALLER
Definition: cfgmgr32.h:772
#define RegDisposition_OpenExisting
Definition: cfgmgr32.h:610
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:6454
CONFIGRET WINAPI CM_Connect_MachineW(_In_opt_ PCWSTR UNCServerName, _Out_ PHMACHINE phMachine)
Definition: cfgmgr.c:1270
CONFIGRET WINAPI CM_Enumerate_Classes_Ex(_In_ ULONG ulClassIndex, _Out_ LPGUID ClassGuid, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:2094
#define debugstr_guid
Definition: kernel32.h:35
#define REGSTR_VAL_NOINSTALLCLASS
Definition: regstr.h:239
#define REGSTR_VAL_NODISPLAYCLASS
Definition: regstr.h:240
#define REGSTR_VAL_NOUSECLASS
Definition: regstr.h:238
#define DIBCI_NODISPLAYCLASS
Definition: setupapi.h:111
#define DIBCI_NOINSTALLCLASS
Definition: setupapi.h:110

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

◆ SetupDiCallClassInstaller()

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

Definition at line 4313 of file devinst.c.

4317{
4318 BOOL ret = FALSE;
4319
4320 TRACE("%s(%u %p %p)\n", __FUNCTION__, InstallFunction, DeviceInfoSet, DeviceInfoData);
4321
4322 if (!DeviceInfoSet)
4326 else if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
4328 else if (((struct DeviceInfoSet *)DeviceInfoSet)->HKLM != HKEY_LOCAL_MACHINE)
4330 else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
4332 else
4333 {
4334 SP_DEVINSTALL_PARAMS_W InstallParams;
4335#define CLASS_COINSTALLER 0x1
4336#define DEVICE_COINSTALLER 0x2
4337#define CLASS_INSTALLER 0x4
4338 UCHAR CanHandle = 0;
4340
4341 switch (InstallFunction)
4342 {
4345 break;
4348 break;
4349 case DIF_ALLOW_INSTALL:
4350 CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4351 break;
4352 case DIF_DETECT:
4353 CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4354 break;
4356 CanHandle = CLASS_INSTALLER;
4357 break;
4358 case DIF_INSTALLDEVICE:
4361 break;
4363 CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4365 break;
4369 break;
4372 break;
4374 CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4375 break;
4377 CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4378 break;
4380 CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4381 break;
4383 CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4384 break;
4387 break;
4388 case DIF_PROPERTYCHANGE:
4391 break;
4393 CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4395 break;
4396 case DIF_REGISTERDEVICE:
4397 CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4399 break;
4400 case DIF_REMOVE:
4403 break;
4405 CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4407 break;
4408 case DIF_SELECTDEVICE:
4409 CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4411 break;
4412 case DIF_TROUBLESHOOTER:
4414 break;
4415 case DIF_UNREMOVE:
4418 break;
4419 default:
4420 ERR("Install function %u not supported\n", InstallFunction);
4422 }
4423
4424 InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
4426 /* Don't process this call, as a parameter is invalid */
4427 CanHandle = 0;
4428
4429 if (CanHandle != 0)
4430 {
4431 LIST_ENTRY ClassCoInstallersListHead;
4432 LIST_ENTRY DeviceCoInstallersListHead;
4433 HMODULE ClassInstallerLibrary = NULL;
4434 CLASS_INSTALL_PROC ClassInstaller = NULL;
4436 PLIST_ENTRY ListEntry;
4437 HKEY hKey;
4438 DWORD dwRegType, dwLength;
4439 DWORD rc = NO_ERROR;
4440
4441 InitializeListHead(&ClassCoInstallersListHead);
4442 InitializeListHead(&DeviceCoInstallersListHead);
4443
4444 if (CanHandle & DEVICE_COINSTALLER)
4445 {
4448 {
4450 if (rc == ERROR_SUCCESS && dwRegType == REG_MULTI_SZ)
4451 {
4452 LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
4453 if (KeyBuffer != NULL)
4454 {
4456 if (rc == ERROR_SUCCESS)
4457 {
4458 LPWSTR ptr;
4459 for (ptr = KeyBuffer; *ptr; ptr += strlenW(ptr) + 1)
4460 {
4461 /* Add coinstaller to DeviceCoInstallersListHead list */
4462 struct CoInstallerElement *coinstaller;
4463 TRACE("Got device coinstaller '%s'\n", debugstr_w(ptr));
4464 coinstaller = HeapAlloc(GetProcessHeap(), 0, sizeof(struct CoInstallerElement));
4465 if (!coinstaller)
4466 continue;
4467 ZeroMemory(coinstaller, sizeof(struct CoInstallerElement));
4468 if (GetFunctionPointer(ptr, &coinstaller->Module, (PVOID*)&coinstaller->Function) == ERROR_SUCCESS)
4469 InsertTailList(&DeviceCoInstallersListHead, &coinstaller->ListEntry);
4470 else
4471 HeapFree(GetProcessHeap(), 0, coinstaller);
4472 }
4473 }
4474 HeapFree(GetProcessHeap(), 0, KeyBuffer);
4475 }
4476 }
4478 }
4479 }
4480 if (CanHandle & CLASS_COINSTALLER)
4481 {
4482 rc = RegOpenKeyExW(
4485 0, /* Options */
4487 &hKey);
4488 if (rc == ERROR_SUCCESS)
4489 {
4490 WCHAR szGuidString[40];
4491 if (pSetupStringFromGuid(&DeviceInfoData->ClassGuid, szGuidString, ARRAYSIZE(szGuidString)) == ERROR_SUCCESS)
4492 {
4493 rc = RegQueryValueExW(hKey, szGuidString, NULL, &dwRegType, NULL, &dwLength);
4494 if (rc == ERROR_SUCCESS && dwRegType == REG_MULTI_SZ)
4495 {
4496 LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
4497 if (KeyBuffer != NULL)
4498 {
4499 rc = RegQueryValueExW(hKey, szGuidString, NULL, NULL, (LPBYTE)KeyBuffer, &dwLength);
4500 if (rc == ERROR_SUCCESS)
4501 {
4502 LPWSTR ptr;
4503 for (ptr = KeyBuffer; *ptr; ptr += strlenW(ptr) + 1)
4504 {
4505 /* Add coinstaller to ClassCoInstallersListHead list */
4506 struct CoInstallerElement *coinstaller;
4507 TRACE("Got class coinstaller '%s'\n", debugstr_w(ptr));
4508 coinstaller = HeapAlloc(GetProcessHeap(), 0, sizeof(struct CoInstallerElement));
4509 if (!coinstaller)
4510 continue;
4511 ZeroMemory(coinstaller, sizeof(struct CoInstallerElement));
4512 if (GetFunctionPointer(ptr, &coinstaller->Module, (PVOID*)&coinstaller->Function) == ERROR_SUCCESS)
4513 InsertTailList(&ClassCoInstallersListHead, &coinstaller->ListEntry);
4514 else
4515 HeapFree(GetProcessHeap(), 0, coinstaller);
4516 }
4517 }
4518 HeapFree(GetProcessHeap(), 0, KeyBuffer);
4519 }
4520 }
4521 }
4523 }
4524 }
4525 if ((CanHandle & CLASS_INSTALLER) && !(InstallParams.FlagsEx & DI_FLAGSEX_CI_FAILED))
4526 {
4529 {
4531 if (rc == ERROR_SUCCESS && dwRegType == REG_SZ)
4532 {
4533 LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
4534 if (KeyBuffer != NULL)
4535 {
4537 if (rc == ERROR_SUCCESS)
4538 {
4539 /* Get ClassInstaller function pointer */
4540 TRACE("Got class installer '%s'\n", debugstr_w(KeyBuffer));
4541 if (GetFunctionPointer(KeyBuffer, &ClassInstallerLibrary, (PVOID*)&ClassInstaller) != ERROR_SUCCESS)
4542 {
4543 InstallParams.FlagsEx |= DI_FLAGSEX_CI_FAILED;
4545 }
4546 }
4547 HeapFree(GetProcessHeap(), 0, KeyBuffer);
4548 }
4549 }
4551 }
4552 }
4553
4554 /* Call Class co-installers */
4555 Context.PostProcessing = FALSE;
4556 rc = NO_ERROR;
4557 ListEntry = ClassCoInstallersListHead.Flink;
4558 while (rc == NO_ERROR && ListEntry != &ClassCoInstallersListHead)
4559 {
4560 struct CoInstallerElement *coinstaller;
4562 rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4563 coinstaller->PrivateData = Context.PrivateData;
4565 {
4566 coinstaller->DoPostProcessing = TRUE;
4567 rc = NO_ERROR;
4568 }
4570 }
4571
4572 /* Call Device co-installers */
4573 ListEntry = DeviceCoInstallersListHead.Flink;
4574 while (rc == NO_ERROR && ListEntry != &DeviceCoInstallersListHead)
4575 {
4576 struct CoInstallerElement *coinstaller;
4578 rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4579 coinstaller->PrivateData = Context.PrivateData;
4581 {
4582 coinstaller->DoPostProcessing = TRUE;
4583 rc = NO_ERROR;
4584 }
4586 }
4587
4588 /* Call Class installer */
4589 if (ClassInstaller)
4590 {
4591 rc = (*ClassInstaller)(InstallFunction, DeviceInfoSet, DeviceInfoData);
4592 FreeFunctionPointer(ClassInstallerLibrary, ClassInstaller);
4593 }
4594 else
4596
4597 /* Call default handler */
4598 if (rc == ERROR_DI_DO_DEFAULT)
4599 {
4600 if (DefaultHandler && !(InstallParams.Flags & DI_NODI_DEFAULTACTION))
4601 {
4603 rc = NO_ERROR;
4604 else
4605 rc = GetLastError();
4606 }
4607 else
4608 rc = NO_ERROR;
4609 }
4610
4611 /* Call Class co-installers that required postprocessing */
4612 Context.PostProcessing = TRUE;
4613 ListEntry = ClassCoInstallersListHead.Flink;
4614 while (ListEntry != &ClassCoInstallersListHead)
4615 {
4616 struct CoInstallerElement *coinstaller;
4618 if (coinstaller->DoPostProcessing)
4619 {
4620 Context.InstallResult = rc;
4621 Context.PrivateData = coinstaller->PrivateData;
4622 rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4623 }
4624 FreeFunctionPointer(coinstaller->Module, coinstaller->Function);
4626 }
4627
4628 /* Call Device co-installers that required postprocessing */
4629 ListEntry = DeviceCoInstallersListHead.Flink;
4630 while (ListEntry != &DeviceCoInstallersListHead)
4631 {
4632 struct CoInstallerElement *coinstaller;
4634 if (coinstaller->DoPostProcessing)
4635 {
4636 Context.InstallResult = rc;
4637 Context.PrivateData = coinstaller->PrivateData;
4638 rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4639 }
4640 FreeFunctionPointer(coinstaller->Module, coinstaller->Function);
4642 }
4643
4644 /* Free allocated memory */
4645 while (!IsListEmpty(&ClassCoInstallersListHead))
4646 {
4647 ListEntry = RemoveHeadList(&ClassCoInstallersListHead);
4649 }
4650 while (!IsListEmpty(&DeviceCoInstallersListHead))
4651 {
4652 ListEntry = RemoveHeadList(&DeviceCoInstallersListHead);
4654 }
4655
4656 ret = (rc == NO_ERROR);
4657 }
4658 }
4659
4660 TRACE("Returning %d\n", ret);
4661 return ret;
4662}
#define NO_ERROR
Definition: dderror.h:5
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define CLASS_COINSTALLER
BOOL WINAPI SetupDiRegisterCoDeviceInstallers(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5500
BOOL WINAPI SetupDiSetDeviceInstallParamsW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
Definition: devinst.c:4847
BOOL WINAPI SetupDiGetDeviceInstallParamsW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, OUT PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
Definition: devinst.c:4740
BOOL(WINAPI * DEFAULT_CLASS_INSTALL_PROC)(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:49
BOOL WINAPI SetupDiSelectDevice(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
Definition: devinst.c:5486
BOOL WINAPI SetupDiChangeState(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5360
BOOL WINAPI SetupDiInstallDevice(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5654
HKEY SETUPDI_OpenDrvKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:6146
#define CLASS_INSTALLER
static BOOL WINAPI IntSetupDiRegisterDeviceInfo(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:4303
DWORD(CALLBACK * CLASS_INSTALL_PROC)(IN DI_FUNCTION InstallFunction, IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
Definition: devinst.c:44
HKEY WINAPI SetupDiOpenClassRegKey(const GUID *ClassGuid, REGSAM samDesired)
Definition: devinst.c:3907
#define DEVICE_COINSTALLER
BOOL WINAPI SetupDiInstallDriverFiles(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: driver.c:1947
BOOL WINAPI SetupDiSelectBestCompatDrv(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
Definition: driver.c:1911
BOOL WINAPI SetupDiInstallDeviceInterfaces(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: interface.c:386
DWORD FreeFunctionPointer(IN HMODULE ModulePointer, IN PVOID FunctionPointer)
Definition: misc.c:105
DWORD WINAPI pSetupStringFromGuid(LPGUID lpGUID, PWSTR pString, DWORD dwStringLen)
Definition: misc.c:1775
DWORD GetFunctionPointer(IN PWSTR InstallerName, OUT HMODULE *ModulePointer, OUT PVOID *FunctionPointer)
Definition: misc.c:44
BOOL WINAPI SetupDiUnremoveDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: stubs.c:96
BOOL WINAPI SetupDiRemoveDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: stubs.c:82
#define InsertTailList(ListHead, Entry)
static PVOID ptr
Definition: dispmode.c:27
#define REG_MULTI_SZ
Definition: nt_native.h:1504
#define REGSTR_VAL_INSTALLER_32
Definition: regstr.h:487
#define REGSTR_VAL_COINSTALLERS_32
Definition: regstr.h:484
#define REGSTR_PATH_CODEVICEINSTALLERS
Definition: regstr.h:480
#define ERROR_DI_POSTPROCESSING_REQUIRED
Definition: setupapi.h:337
#define DIF_SELECTDEVICE
Definition: setupapi.h:123
#define DIF_NEWDEVICEWIZARD_PRESELECT
Definition: setupapi.h:148
#define DIF_REGISTERDEVICE
Definition: setupapi.h:147
#define DIF_REMOVE
Definition: setupapi.h:127
#define DIF_INSTALLDEVICEFILES
Definition: setupapi.h:143
#define DIF_ADDREMOTEPROPERTYPAGE_ADVANCED
Definition: setupapi.h:162
#define DIF_DETECT
Definition: setupapi.h:137
#define DIF_NEWDEVICEWIZARD_SELECT
Definition: setupapi.h:149
#define DIF_REGISTER_COINSTALLERS
Definition: setupapi.h:156
#define DIF_INSTALLINTERFACES
Definition: setupapi.h:154
#define ERROR_DI_DO_DEFAULT
Definition: setupapi.h:313
#define DIF_NEWDEVICEWIZARD_PREANALYZE
Definition: setupapi.h:150
#define DIF_UNREMOVE
Definition: setupapi.h:144
#define DIF_INSTALLDEVICE
Definition: setupapi.h:124
#define DIF_ALLOW_INSTALL
Definition: setupapi.h:146
#define DIF_DESTROYPRIVATEDATA
Definition: setupapi.h:134
#define DIF_SELECTBESTCOMPATDRV
Definition: setupapi.h:145
#define DIF_POWERMESSAGEWAKE
Definition: setupapi.h:161
#define DIF_PROPERTYCHANGE
Definition: setupapi.h:140
#define DIF_ADDPROPERTYPAGE_ADVANCED
Definition: setupapi.h:157
#define DIF_NEWDEVICEWIZARD_POSTANALYZE
Definition: setupapi.h:151
#define DIF_TROUBLESHOOTER
Definition: setupapi.h:160
#define DIF_NEWDEVICEWIZARD_FINISHINSTALL
Definition: setupapi.h:152
LIST_ENTRY ListEntry
Definition: devinst.c:61
HMODULE Module
Definition: devinst.c:63
BOOL DoPostProcessing
Definition: devinst.c:65
COINSTALLER_PROC Function
Definition: devinst.c:64
PVOID PrivateData
Definition: devinst.c:66
unsigned char UCHAR
Definition: typedefs.h:53
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

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

5363{
5364 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
5365 struct DeviceInfo *deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
5366 PSP_PROPCHANGE_PARAMS PropChange;
5368 LPCWSTR RegistryValueName;
5369 DWORD dwConfigFlags, dwLength, dwRegType;
5370 LONG rc;
5371 BOOL ret = FALSE;
5372
5374
5375 if (!DeviceInfoData)
5376 PropChange = ((struct DeviceInfoSet *)DeviceInfoSet)->ClassInstallParams.PropChangeParams;
5377 else
5378 PropChange = ((struct DeviceInfo *)DeviceInfoData->Reserved)->ClassInstallParams.PropChangeParams;
5379 if (!PropChange)
5380 {
5382 goto cleanup;
5383 }
5384
5385 if (PropChange->Scope == DICS_FLAG_GLOBAL)
5386 RegistryValueName = REGSTR_VAL_CONFIGFLAGS;
5387 else
5388 RegistryValueName = REGSTR_VAL_CSCONFIGFLAGS;
5389
5390 switch (PropChange->StateChange)
5391 {
5392 case DICS_ENABLE:
5393 case DICS_DISABLE:
5394 {
5395 if (PropChange->Scope == DICS_FLAG_GLOBAL)
5396 hRootKey = set->HKLM;
5397 else /* PropChange->Scope == DICS_FLAG_CONFIGSPECIFIC */
5398 {
5399 hRootKey = OpenHardwareProfileKey(set->HKLM, PropChange->HwProfile, KEY_CREATE_SUB_KEY);
5400 if (hRootKey == INVALID_HANDLE_VALUE)
5401 goto cleanup;
5402 }
5403
5404 /* Enable/disable device in registry */
5405 hKey = SETUPDI_OpenDrvKey(hRootKey, deviceInfo, KEY_QUERY_VALUE | KEY_SET_VALUE);
5407 hKey = SETUPDI_CreateDevKey(hRootKey, deviceInfo, KEY_QUERY_VALUE | KEY_SET_VALUE);
5409 break;
5410 dwLength = sizeof(DWORD);
5411 rc = RegQueryValueExW(
5412 hKey,
5413 RegistryValueName,
5414 NULL,
5415 &dwRegType,
5416 (LPBYTE)&dwConfigFlags, &dwLength);
5417 if (rc == ERROR_FILE_NOT_FOUND)
5418 dwConfigFlags = 0;
5419 else if (rc != ERROR_SUCCESS)
5420 {
5421 SetLastError(rc);
5422 goto cleanup;
5423 }
5424 else if (dwRegType != REG_DWORD || dwLength != sizeof(DWORD))
5425 {
5427 goto cleanup;
5428 }
5429 if (PropChange->StateChange == DICS_ENABLE)
5430 dwConfigFlags &= ~(PropChange->Scope == DICS_FLAG_GLOBAL ? CONFIGFLAG_DISABLED : CSCONFIGFLAG_DISABLED);
5431 else
5432 dwConfigFlags |= (PropChange->Scope == DICS_FLAG_GLOBAL ? CONFIGFLAG_DISABLED : CSCONFIGFLAG_DISABLED);
5433 rc = RegSetValueExW(
5434 hKey,
5435 RegistryValueName,
5436 0,
5437 REG_DWORD,
5438 (LPBYTE)&dwConfigFlags, sizeof(DWORD));
5439 if (rc != ERROR_SUCCESS)
5440 {
5441 SetLastError(rc);
5442 goto cleanup;
5443 }
5444
5445 /* Enable/disable device if needed */
5446 if (PropChange->Scope == DICS_FLAG_GLOBAL
5447 || PropChange->HwProfile == 0
5448 || PropChange->HwProfile == SETUPAPI_GetCurrentHwProfile(DeviceInfoSet))
5449 {
5450 if (PropChange->StateChange == DICS_ENABLE)
5452 else
5454 }
5455 else
5456 ret = TRUE;
5457 break;
5458 }
5459 case DICS_PROPCHANGE:
5460 {
5462 break;
5463 }
5464 default:
5465 {
5466 ERR("Unknown StateChange 0x%lx\n", PropChange->StateChange);
5468 }
5469 }
5470
5471cleanup:
5472 if (hRootKey != INVALID_HANDLE_VALUE && hRootKey != set->HKLM)
5473 RegCloseKey(hRootKey);
5474
5477
5478 TRACE("Returning %d\n", ret);
5479 return ret;
5480}
static HKEY OpenHardwareProfileKey(IN HKEY HKLM, IN DWORD HwProfile, IN DWORD samDesired)
Definition: devinst.c:4924
static BOOL ResetDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5309
static DWORD SETUPAPI_GetCurrentHwProfile(IN HDEVINFO DeviceInfoSet)
Definition: devinst.c:5262
HKEY SETUPDI_CreateDevKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5960
static BOOL StopDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5333
#define CSCONFIGFLAG_DISABLED
Definition: regstr.h:401
#define REGSTR_VAL_CSCONFIGFLAGS
Definition: regstr.h:389
#define REGSTR_VAL_CONFIGFLAGS
Definition: regstr.h:388
#define CONFIGFLAG_DISABLED
Definition: regstr.h:390
#define DICS_DISABLE
Definition: setupapi.h:116
#define DICS_PROPCHANGE
Definition: setupapi.h:118
#define DICS_ENABLE
Definition: setupapi.h:114
#define DICS_FLAG_GLOBAL
Definition: setupapi.h:115

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

◆ SetupDiClassGuidsFromNameA()

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

Definition at line 1097 of file devinst.c.

1102{
1103 return SetupDiClassGuidsFromNameExA(ClassName, ClassGuidList,
1105 NULL, NULL);
1106}
BOOL WINAPI SetupDiClassGuidsFromNameExA(LPCSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCSTR MachineName, PVOID Reserved)
Definition: devinst.c:1125

Referenced by test_SetupDiClassGuidsFromNameA().

◆ SetupDiClassGuidsFromNameExA()

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

Definition at line 1125 of file devinst.c.

1132{
1133 LPWSTR ClassNameW = NULL;
1134 LPWSTR MachineNameW = NULL;
1135 BOOL bResult;
1136
1137 TRACE("%s(%s %p %lu %p %s %p)\n", __FUNCTION__, debugstr_a(ClassName), ClassGuidList,
1139
1140 if (!ClassName)
1141 {
1143 return FALSE;
1144 }
1145
1146 ClassNameW = pSetupMultiByteToUnicode(ClassName, CP_ACP);
1147 if (ClassNameW == NULL)
1148 return FALSE;
1149
1150 if (MachineName)
1151 {
1153 if (MachineNameW == NULL)
1154 {
1155 MyFree(ClassNameW);
1156 return FALSE;
1157 }
1158 }
1159
1160 bResult = SetupDiClassGuidsFromNameExW(ClassNameW, ClassGuidList,
1162 MachineNameW, Reserved);
1163
1164 MyFree(MachineNameW);
1165 MyFree(ClassNameW);
1166
1167 return bResult;
1168}
BOOL WINAPI SetupDiClassGuidsFromNameExW(LPCWSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:1173

Referenced by SetupDiClassGuidsFromNameA().

◆ SetupDiClassGuidsFromNameExW()

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

Definition at line 1173 of file devinst.c.

1180{
1181 WCHAR szKeyName[40];
1183 HKEY hClassesKey;
1186 DWORD dwIndex;
1187 LONG lError;
1188 DWORD dwGuidListIndex = 0;
1189
1190 TRACE("%s(%s %p %lu %p %s %p)\n", __FUNCTION__, debugstr_w(ClassName), ClassGuidList,
1192
1193 if (!ClassName || !RequiredSize)
1194 {
1196 return FALSE;
1197 }
1198 if (!ClassGuidList && ClassGuidListSize > 0)
1199 {
1201 return FALSE;
1202 }
1203 *RequiredSize = 0;
1204
1205 hClassesKey = SetupDiOpenClassRegKeyExW(NULL,
1209 Reserved);
1210 if (hClassesKey == INVALID_HANDLE_VALUE)
1211 {
1212 return FALSE;
1213 }
1214
1215 for (dwIndex = 0; ; dwIndex++)
1216 {
1217 dwLength = 40;
1218 lError = RegEnumKeyExW(hClassesKey,
1219 dwIndex,
1220 szKeyName,
1221 &dwLength,
1222 NULL,
1223 NULL,
1224 NULL,
1225 NULL);
1226 TRACE("RegEnumKeyExW() returns %d\n", lError);
1227 if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA)
1228 {
1229 TRACE("Key name: %p\n", szKeyName);
1230
1231 if (RegOpenKeyExW(hClassesKey,
1232 szKeyName,
1233 0,
1235 &hClassKey))
1236 {
1237 RegCloseKey(hClassesKey);
1238 return FALSE;
1239 }
1240
1241 dwLength = MAX_CLASS_NAME_LEN * sizeof(WCHAR);
1244 NULL,
1245 NULL,
1247 &dwLength))
1248 {
1249 TRACE("Class name: %p\n", szClassName);
1250
1251 if (strcmpiW(szClassName, ClassName) == 0)
1252 {
1253 TRACE("Found matching class name\n");
1254
1255 TRACE("Guid: %p\n", szKeyName);
1256 if (dwGuidListIndex < ClassGuidListSize)
1257 {
1258 if (szKeyName[0] == '{' && szKeyName[37] == '}')
1259 {
1260 szKeyName[37] = 0;
1261 }
1262 TRACE("Guid: %p\n", &szKeyName[1]);
1263
1264 UuidFromStringW(&szKeyName[1],
1265 &ClassGuidList[dwGuidListIndex]);
1266 }
1267
1268 dwGuidListIndex++;
1269 }
1270 }
1271
1273 }
1274
1275 if (lError != ERROR_SUCCESS)
1276 break;
1277 }
1278
1279 RegCloseKey(hClassesKey);
1280
1281 if (RequiredSize != NULL)
1282 *RequiredSize = dwGuidListIndex;
1283
1284 if (ClassGuidListSize < dwGuidListIndex)
1285 {
1287 return FALSE;
1288 }
1289
1290 return TRUE;
1291}
#define MAX_CLASS_NAME_LEN
Definition: cfgmgr32.h:52
static const WCHAR szClassName[]
Definition: clipbrd.c:11
#define ERROR_MORE_DATA
Definition: dderror.h:13
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:2504
HKEY WINAPI SetupDiOpenClassRegKeyExW(const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:3951
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1022
RPC_STATUS WINAPI UuidFromStringW(RPC_WSTR s, UUID *uuid)
Definition: rpcrt4_main.c:655
#define DIOCR_INSTALLER
Definition: setupapi.h:179

Referenced by SetupDiClassGuidsFromNameExA(), and SetupDiClassGuidsFromNameW().

◆ SetupDiClassGuidsFromNameW()

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

Definition at line 1111 of file devinst.c.

1116{
1117 return SetupDiClassGuidsFromNameExW(ClassName, ClassGuidList,
1119 NULL, NULL);
1120}

◆ SetupDiClassNameFromGuidA()

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

Definition at line 1296 of file devinst.c.

1301{
1302 return SetupDiClassNameFromGuidExA(ClassGuid, ClassName,
1303 ClassNameSize, RequiredSize,
1304 NULL, NULL);
1305}
BOOL WINAPI SetupDiClassNameFromGuidExA(const GUID *ClassGuid, PSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize, PCSTR MachineName, PVOID Reserved)
Definition: devinst.c:1324

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

1331{
1332 WCHAR ClassNameW[MAX_CLASS_NAME_LEN];
1333 LPWSTR MachineNameW = NULL;
1334 BOOL ret;
1335
1336 if (MachineName)
1338 ret = SetupDiClassNameFromGuidExW(ClassGuid, ClassNameW, MAX_CLASS_NAME_LEN,
1339 RequiredSize, MachineNameW, Reserved);
1340 if (ret)
1341 {
1342 int len = WideCharToMultiByte(CP_ACP, 0, ClassNameW, -1, ClassName,
1343 ClassNameSize, NULL, NULL);
1344 if (len == 0 || len > ClassNameSize)
1345 {
1347 ret = FALSE;
1348 }
1349 }
1350 MyFree(MachineNameW);
1351 return ret;
1352}
#define WideCharToMultiByte
Definition: compat.h:111
BOOL WINAPI SetupDiClassNameFromGuidExW(const GUID *ClassGuid, PWSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:1357
GLenum GLsizei len
Definition: glext.h:6722

Referenced by SetupDiClassNameFromGuidA().

◆ SetupDiClassNameFromGuidExW()

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

Definition at line 1357 of file devinst.c.

1364{
1365 HKEY hKey;
1367 DWORD dwRegType;
1368 LONG rc;
1369 PWSTR Buffer;
1370
1371 TRACE("%s(%s %p %lu %p %s %p)\n", __FUNCTION__, debugstr_guid(ClassGuid), ClassName,
1372 ClassNameSize, RequiredSize, debugstr_w(MachineName), Reserved);
1373
1374 /* Make sure there's a GUID */
1375 if (ClassGuid == NULL)
1376 {
1377 SetLastError(ERROR_INVALID_CLASS); /* On Vista: ERROR_INVALID_USER_BUFFER */
1378 return FALSE;
1379 }
1380
1381 /* Make sure there's a real buffer when there's a size */
1382 if ((ClassNameSize > 0) && (ClassName == NULL))
1383 {
1384 SetLastError(ERROR_INVALID_PARAMETER); /* On Vista: ERROR_INVALID_USER_BUFFER */
1385 return FALSE;
1386 }
1387
1388 /* Open the key for the GUID */
1390
1392 return FALSE;
1393
1394 /* Retrieve the class name data and close the key */
1395 rc = QueryRegistryValue(hKey, REGSTR_VAL_CLASS, (LPBYTE *) &Buffer, &dwRegType, &dwLength);
1397
1398 /* Make sure we got the data */
1399 if (rc != ERROR_SUCCESS)
1400 {
1401 SetLastError(rc);
1402 return FALSE;
1403 }
1404
1405 /* Make sure the data is a string */
1406 if (dwRegType != REG_SZ)
1407 {
1408 MyFree(Buffer);
1410 return FALSE;
1411 }
1412
1413 /* Determine the length of the class name */
1414 dwLength /= sizeof(WCHAR);
1415
1416 if ((dwLength == 0) || (Buffer[dwLength - 1] != UNICODE_NULL))
1417 /* Count the null-terminator */
1418 dwLength++;
1419
1420 /* Inform the caller about the class name */
1421 if ((ClassName != NULL) && (dwLength <= ClassNameSize))
1422 {
1423 memcpy(ClassName, Buffer, (dwLength - 1) * sizeof(WCHAR));
1424 ClassName[dwLength - 1] = UNICODE_NULL;
1425 }
1426
1427 /* Inform the caller about the required size */
1428 if (RequiredSize != NULL)
1430
1431 /* Clean up the buffer */
1432 MyFree(Buffer);
1433
1434 /* Make sure the buffer was large enough */
1435 if ((ClassName == NULL) || (dwLength > ClassNameSize))
1436 {
1438 return FALSE;
1439 }
1440
1441 return TRUE;
1442}
PVOID QueryRegistryValue(HANDLE RegHandle, PWCHAR ValueName, LPDWORD RegistryType, LPDWORD Length)
Definition: registry.c:67
#define ERROR_INVALID_CLASS
Definition: setupapi.h:305
uint16_t * PWSTR
Definition: typedefs.h:56

Referenced by SetupDiClassNameFromGuidExA(), and SetupDiClassNameFromGuidW().

◆ SetupDiClassNameFromGuidW()

BOOL WINAPI SetupDiClassNameFromGuidW ( const GUID ClassGuid,
PWSTR  ClassName,
DWORD  ClassNameSize,
PDWORD  RequiredSize 
)

Definition at line 1310 of file devinst.c.

1315{
1316 return SetupDiClassNameFromGuidExW(ClassGuid, ClassName,
1317 ClassNameSize, RequiredSize,
1318 NULL, NULL);
1319}

Referenced by PARSER_GetInfClassW(), and CClassNode::SetupNode().

◆ SetupDiCreateDeviceInfoA()

BOOL WINAPI SetupDiCreateDeviceInfoA ( HDEVINFO  DeviceInfoSet,
PCSTR  DeviceName,
CONST GUID ClassGuid,
PCSTR  DeviceDescription,
HWND  hwndParent,
DWORD  CreationFlags,
PSP_DEVINFO_DATA  DeviceInfoData 
)

Definition at line 1771 of file devinst.c.

1779{
1780 BOOL ret;
1781 LPWSTR DeviceNameW = NULL;
1782 LPWSTR DeviceDescriptionW = NULL;
1783
1784 TRACE("\n");
1785
1786 if (DeviceName)
1787 {
1789 if (DeviceNameW == NULL) return FALSE;
1790 }
1792 {
1793 DeviceDescriptionW = pSetupMultiByteToUnicode(DeviceDescription, CP_ACP);
1794 if (DeviceDescriptionW == NULL)
1795 {
1796 MyFree(DeviceNameW);
1797 return FALSE;
1798 }
1799 }
1800
1801 ret = SetupDiCreateDeviceInfoW(DeviceInfoSet, DeviceNameW, ClassGuid, DeviceDescriptionW,
1802 hwndParent, CreationFlags, DeviceInfoData);
1803
1804 MyFree(DeviceNameW);
1805 MyFree(DeviceDescriptionW);
1806
1807 return ret;
1808}
static HWND hwndParent
Definition: cryptui.c:299
BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO DeviceInfoSet, PCWSTR DeviceName, CONST GUID *ClassGuid, PCWSTR DeviceDescription, HWND hwndParent, DWORD CreationFlags, PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:1813
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3281
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceDescription
Definition: wdfpdo.h:432

Referenced by test_device_iface(), test_device_iface_detail(), test_device_info(), test_device_interface_key(), test_device_key(), test_devnode(), test_get_device_instance_id(), test_register_device_iface(), test_register_device_info(), test_registry_property_a(), and test_registry_property_w().

◆ SetupDiCreateDeviceInfoList()

HDEVINFO WINAPI SetupDiCreateDeviceInfoList ( const GUID ClassGuid,
HWND  hwndParent 
)

Definition at line 1448 of file devinst.c.

1450{
1452}
HDEVINFO WINAPI SetupDiCreateDeviceInfoListExW(const GUID *ClassGuid, HWND hwndParent, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:1502

Referenced by InstallCompositeBattery(), InstallSoftwareBusPnpEnumerator(), SetupDiInstallClassExW(), test_device_iface(), test_device_iface_detail(), test_device_info(), test_device_key(), test_get_device_instance_id(), and test_register_device_info().

◆ SetupDiCreateDeviceInfoListExA()

HDEVINFO WINAPI SetupDiCreateDeviceInfoListExA ( const GUID ClassGuid,
HWND  hwndParent,
PCSTR  MachineName,
PVOID  Reserved 
)

Definition at line 1458 of file devinst.c.

1462{
1463 LPWSTR MachineNameW = NULL;
1464 HDEVINFO hDevInfo;
1465
1466 TRACE("%s(%s %p %s %p)\n", __FUNCTION__, debugstr_guid(ClassGuid), hwndParent,
1468
1469 if (MachineName)
1470 {
1472 if (MachineNameW == NULL)
1473 return INVALID_HANDLE_VALUE;
1474 }
1475
1476 hDevInfo = SetupDiCreateDeviceInfoListExW(ClassGuid, hwndParent,
1477 MachineNameW, Reserved);
1478
1479 MyFree(MachineNameW);
1480
1481 return hDevInfo;
1482}

◆ SetupDiCreateDeviceInfoListExW()

HDEVINFO WINAPI SetupDiCreateDeviceInfoListExW ( const GUID ClassGuid,
HWND  hwndParent,
PCWSTR  MachineName,
PVOID  Reserved 
)

Definition at line 1502 of file devinst.c.

1506{
1507 struct DeviceInfoSet *list = NULL;
1509 DWORD rc;
1510 CONFIGRET cr;
1512
1513 TRACE("%s(%s %p %s %p)\n", __FUNCTION__, debugstr_guid(ClassGuid), hwndParent,
1515
1516 if (MachineName != NULL)
1517 {
1519 if (len >= SP_MAX_MACHINENAME_LENGTH - 4)
1520 {
1522 goto cleanup;
1523 }
1524 if(len > 0)
1525 size += (len + 3) * sizeof(WCHAR);
1526 else
1527 MachineName = NULL;
1528 }
1529
1530 if (Reserved != NULL)
1531 {
1533 return INVALID_HANDLE_VALUE;
1534 }
1535
1536 list = MyMalloc(size);
1537 if (!list)
1538 {
1540 return INVALID_HANDLE_VALUE;
1541 }
1543
1545 memcpy(&list->ClassGuid,
1547 sizeof(list->ClassGuid));
1548 list->InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
1549 list->InstallParams.Flags |= DI_CLASSINSTALLPARAMS;
1550 list->InstallParams.hwndParent = hwndParent;
1551 if (MachineName)
1552 {
1554 if (rc != ERROR_SUCCESS)
1555 {
1557 goto cleanup;
1558 }
1559
1560 list->szData[0] = list->szData[1] = '\\';
1561 strcpyW(list->szData + 2, MachineName);
1562 list->MachineName = list->szData;
1563 }
1564 else
1565 {
1566 list->HKLM = HKEY_LOCAL_MACHINE;
1567 list->MachineName = NULL;
1568 }
1569 cr = CM_Connect_MachineW(list->MachineName, &list->hMachine);
1570 if (cr != CR_SUCCESS)
1571 {
1573 goto cleanup;
1574 }
1575 InitializeListHead(&list->DriverListHead);
1576 InitializeListHead(&list->ListHead);
1577
1578 return (HDEVINFO)list;
1579
1580cleanup:
1582 {
1583 if (list)
1584 {
1585 if (list->HKLM != NULL && list->HKLM != HKEY_LOCAL_MACHINE)
1586 RegCloseKey(list->HKLM);
1587 MyFree(list);
1588 }
1589 }
1590 return ret;
1591}
LONG WINAPI RegConnectRegistryW(LPCWSTR lpMachineName, HKEY hKey, PHKEY phkResult)
Definition: reg.c:874
#define GUID_NULL
Definition: ks.h:106
#define SP_MAX_MACHINENAME_LENGTH
Definition: setupapi.h:29
#define ERROR_INVALID_MACHINENAME
Definition: setupapi.h:331
WCHAR szData[ANYSIZE_ARRAY]
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by DevInstallW(), InstallDevInstEx(), CKsProxy::Load(), SetupDiCreateDeviceInfoList(), SetupDiCreateDeviceInfoListExA(), SetupDiGetClassDevsExW(), CDeviceNode::SetupNode(), and test_create_device_list_ex().

◆ SetupDiCreateDeviceInfoW()

BOOL WINAPI SetupDiCreateDeviceInfoW ( HDEVINFO  DeviceInfoSet,
PCWSTR  DeviceName,
CONST GUID ClassGuid,
PCWSTR  DeviceDescription,
HWND  hwndParent,
DWORD  CreationFlags,
PSP_DEVINFO_DATA  DeviceInfoData 
)

Definition at line 1813 of file devinst.c.

1821{
1822 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
1823 struct DeviceInfo *deviceInfo = NULL;
1824 BOOL ret = FALSE;
1825 CONFIGRET cr;
1826 DEVINST RootDevInst;
1827 DEVINST DevInst;
1828 WCHAR GenInstanceId[MAX_DEVICE_ID_LEN];
1829 DWORD dwFlags;
1830
1831 TRACE("%s(%p %s %s %s %p %x %p)\n", __FUNCTION__, DeviceInfoSet, debugstr_w(DeviceName),
1834
1835 if (!DeviceName)
1836 {
1838 return FALSE;
1839 }
1841 {
1843 return FALSE;
1844 }
1845 if (!ClassGuid)
1846 {
1848 return FALSE;
1849 }
1850 if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
1851 {
1853 return FALSE;
1854 }
1855 if (!IsEqualGUID(&set->ClassGuid, &GUID_NULL) &&
1856 !IsEqualGUID(ClassGuid, &set->ClassGuid))
1857 {
1859 return FALSE;
1860 }
1862 {
1863 TRACE("Unknown flags: 0x%08lx\n", CreationFlags & ~(DICD_GENERATE_ID | DICD_INHERIT_CLASSDRVS));
1865 return FALSE;
1866 }
1867
1868 /* Get the root device instance */
1869 cr = CM_Locate_DevInst_ExW(&RootDevInst,
1870 NULL,
1872 set->hMachine);
1873 if (cr != CR_SUCCESS)
1874 {
1876 return FALSE;
1877 }
1878
1882
1883 /* Create the new device instance */
1884 cr = CM_Create_DevInst_ExW(&DevInst,
1886 RootDevInst,
1887 dwFlags,
1888 set->hMachine);
1889 if (cr != CR_SUCCESS)
1890 {
1892 return FALSE;
1893 }
1894
1896 {
1897 /* Grab the actual instance ID that was created */
1898 cr = CM_Get_Device_ID_Ex(DevInst,
1899 GenInstanceId,
1901 0,
1902 set->hMachine);
1903 if (cr != CR_SUCCESS)
1904 {
1906 return FALSE;
1907 }
1908
1909 DeviceName = GenInstanceId;
1910 TRACE("Using generated instance ID: %s\n", debugstr_w(DeviceName));
1911 }
1912
1913 if (CreateDeviceInfo(set, DeviceName, ClassGuid, &deviceInfo))
1914 {
1915 InsertTailList(&set->ListHead, &deviceInfo->ListEntry);
1916
1917 if (!DeviceInfoData)
1918 ret = TRUE;
1919 else
1920 {
1921 if (DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
1922 {
1924 }
1925 else
1926 {
1928 DeviceInfoData->DevInst = deviceInfo->dnDevInst;
1929 DeviceInfoData->Reserved = (ULONG_PTR)deviceInfo;
1930 ret = TRUE;
1931 }
1932 }
1933 }
1934
1935 if (ret == FALSE)
1936 {
1937 if (deviceInfo != NULL)
1938 {
1939 /* Remove deviceInfo from List */
1940 RemoveEntryList(&deviceInfo->ListEntry);
1941
1942 /* Destroy deviceInfo */
1943 DestroyDeviceInfo(deviceInfo);
1944 }
1945 }
1946
1947 TRACE("Returning %d\n", ret);
1948 return ret;
1949}
#define CM_CREATE_DEVINST_GENERATE_ID
Definition: cfgmgr32.h:629
#define CM_CREATE_DEVINST_PHANTOM
Definition: cfgmgr32.h:628
DWORD DEVINST
Definition: cfgmgr32.h:76
#define CM_Locate_DevInst_ExW
Definition: cfgmgr32.h:2395
#define CM_LOCATE_DEVINST_NORMAL
Definition: cfgmgr32.h:766
#define CM_Create_DevInst_ExW
Definition: cfgmgr32.h:1117
DEVINSTID_A DEVINSTID
Definition: cfgmgr32.h:87
#define CM_Get_Device_ID_Ex
Definition: cfgmgr32.h:1566
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:40
BOOL CreateDeviceInfo(IN struct DeviceInfoSet *list, IN LPCWSTR InstancePath, IN LPCGUID pClassGuid, OUT struct DeviceInfo **pDeviceInfo)
Definition: devinst.c:771
#define ULONG_PTR
Definition: config.h:101
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define ERROR_INVALID_DEVINST_NAME
Definition: setupapi.h:304
#define ERROR_CLASS_MISMATCH
Definition: setupapi.h:300
#define DICD_GENERATE_ID
Definition: setupapi.h:112
#define DICD_INHERIT_CLASSDRVS
Definition: setupapi.h:113
#define ERROR_INVALID_DATA
Definition: winerror.h:238

Referenced by InstallCompositeBattery(), InstallSoftwareBusPnpEnumerator(), and SetupDiCreateDeviceInfoA().

◆ SetupDiCreateDeviceInterfaceA()

BOOL WINAPI SetupDiCreateDeviceInterfaceA ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
const GUID InterfaceClassGuid,
PCSTR  ReferenceString,
DWORD  CreationFlags,
PSP_DEVICE_INTERFACE_DATA  DeviceInterfaceData 
)

Definition at line 2744 of file devinst.c.

2751{
2752 BOOL ret;
2753 LPWSTR ReferenceStringW = NULL;
2754
2755 TRACE("%s(%p %p %s %s %08x %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData,
2757 CreationFlags, DeviceInterfaceData);
2758
2759 if (ReferenceString)
2760 {
2761 ReferenceStringW = pSetupMultiByteToUnicode(ReferenceString, CP_ACP);
2762 if (ReferenceStringW == NULL) return FALSE;
2763 }
2764
2766 InterfaceClassGuid, ReferenceStringW, CreationFlags,
2767 DeviceInterfaceData);
2768
2769 MyFree(ReferenceStringW);
2770
2771 return ret;
2772}
BOOL WINAPI SetupDiCreateDeviceInterfaceW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, const GUID *InterfaceClassGuid, PCWSTR ReferenceString, DWORD CreationFlags, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
Definition: devinst.c:2777
_Must_inspect_result_ _In_ WDFDEVICE _In_ CONST GUID _In_opt_ PCUNICODE_STRING ReferenceString
Definition: wdfdevice.h:3636
_In_ CONST GUID * InterfaceClassGuid
Definition: iofuncs.h:1136

Referenced by test_device_iface(), test_device_iface_detail(), test_device_interface_key(), and test_register_device_iface().

◆ SetupDiCreateDeviceInterfaceRegKeyA()

HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyA ( HDEVINFO  DeviceInfoSet,
PSP_DEVICE_INTERFACE_DATA  DeviceInterfaceData,
DWORD  Reserved,
REGSAM  samDesired,
HINF  InfHandle,
PCSTR  InfSectionName 
)

Definition at line 2822 of file devinst.c.

2829{
2830 HKEY key;
2831 PWSTR InfSectionNameW = NULL;
2832
2833 TRACE("%s(%p %p %d %08x %p %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInterfaceData, Reserved,
2834 samDesired, InfHandle, InfSectionName);
2835 if (InfHandle)
2836 {
2837 if (!InfSectionName)
2838 {
2840 return INVALID_HANDLE_VALUE;
2841 }
2842 InfSectionNameW = pSetupMultiByteToUnicode(InfSectionName, CP_ACP);
2843 if (!InfSectionNameW)
2844 return INVALID_HANDLE_VALUE;
2845 }
2847 DeviceInterfaceData, Reserved, samDesired, InfHandle,
2848 InfSectionNameW);
2849 MyFree(InfSectionNameW);
2850 return key;
2851}
HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW(HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DWORD Reserved, REGSAM samDesired, HINF InfHandle, PCWSTR InfSectionName)
Definition: devinst.c:2856

Referenced by test_device_interface_key().

◆ SetupDiCreateDeviceInterfaceRegKeyW()

HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW ( HDEVINFO  DeviceInfoSet,
PSP_DEVICE_INTERFACE_DATA  DeviceInterfaceData,
DWORD  Reserved,
REGSAM  samDesired,
HINF  InfHandle,
PCWSTR  InfSectionName 
)

Definition at line 2856 of file devinst.c.

2863{
2864 HKEY hKey, hDevKey, hRefKey, hDevParamKey;
2866 DWORD Length, RefLength, Index;
2867 LONG rc;
2868 WCHAR bracedGuidString[39];
2869 struct DeviceInterface *DevItf;
2870 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
2871
2872 TRACE("%s(%p %p %d %08x %p %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInterfaceData, Reserved,
2873 samDesired, InfHandle, InfSectionName);
2874
2877 {
2879 return INVALID_HANDLE_VALUE;
2880 }
2881 if (!DeviceInterfaceData ||
2882 DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA) ||
2883 !DeviceInterfaceData->Reserved)
2884 {
2886 return INVALID_HANDLE_VALUE;
2887 }
2888 if (InfHandle && !InfSectionName)
2889 {
2891 return INVALID_HANDLE_VALUE;
2892 }
2893
2894 hKey = SetupDiOpenClassRegKeyExW(&DeviceInterfaceData->InterfaceClassGuid, samDesired, DIOCR_INTERFACE, NULL, NULL);
2896 {
2899 {
2901 return INVALID_HANDLE_VALUE;
2902 }
2903 SETUPDI_GuidToString(&DeviceInterfaceData->InterfaceClassGuid, bracedGuidString);
2904
2905 if (RegCreateKeyExW(hKey, bracedGuidString, 0, NULL, 0, samDesired, NULL, &hDevKey, NULL) != ERROR_SUCCESS)
2906 {
2908 return INVALID_HANDLE_VALUE;
2909 }
2911 hKey = hDevKey;
2912 }
2913
2914 DevItf = (struct DeviceInterface *)DeviceInterfaceData->Reserved;
2915
2916 Length = (wcslen(DevItf->SymbolicLink)+1) * sizeof(WCHAR);
2918 if (!SymbolicLink)
2919 {
2922 return INVALID_HANDLE_VALUE;
2923 }
2924
2926
2927 /* Enumerate all characters in symbolic link */
2928 Index = 0;
2929 while (SymbolicLink[Index])
2930 {
2931 /* Check for a start position of reference string */
2932 if (SymbolicLink[Index] == L'}' && SymbolicLink[Index + 1] == L'\\')
2933 {
2934 /* Found it */
2935 SymbolicLink[Index + 1] = L'#';
2936 break;
2937 }
2938 /* Replace all '\' backslashes by '#' pounds in symbolic link */
2939 if (SymbolicLink[Index] == L'\\')
2940 {
2941 SymbolicLink[Index] = L'#';
2942 }
2943 Index++;
2944 }
2945
2946 /* Create reference string */
2947 RefLength = Length - Index * sizeof(WCHAR);
2948 ReferenceString = HeapAlloc(GetProcessHeap(), 0, RefLength);
2949 if (!ReferenceString)
2950 {
2953 return INVALID_HANDLE_VALUE;
2954 }
2955
2957
2958 /* Null-terminate symbolic link at the beginning of the reference part,
2959 * as we don't need a ref part in key name. */
2961
2962 /* Create device instance key */
2963 rc = RegCreateKeyExW(hKey, SymbolicLink, 0, NULL, 0, samDesired, NULL, &hDevKey, NULL);
2966 if (rc != ERROR_SUCCESS)
2967 {
2969 SetLastError(rc);
2970 return INVALID_HANDLE_VALUE;
2971 }
2972
2973 /* Create reference key */
2974 rc = RegCreateKeyExW(hDevKey, ReferenceString, 0, NULL, 0, samDesired, NULL, &hRefKey, NULL);
2976 RegCloseKey(hDevKey);
2977 if (rc != ERROR_SUCCESS)
2978 {
2979 SetLastError(rc);
2980 return INVALID_HANDLE_VALUE;
2981 }
2982
2983 /* Create/open "Device Parameters" subkey */
2984 rc = RegCreateKeyExW(hRefKey, L"Device Parameters", 0, NULL, 0, samDesired, NULL, &hDevParamKey, NULL);
2985 RegCloseKey(hRefKey);
2986 if (rc == ERROR_SUCCESS)
2987 {
2988 if (InfHandle && InfSectionName)
2989 {
2990 if (!SetupInstallFromInfSectionW(NULL /*FIXME */,
2991 InfHandle,
2992 InfSectionName,
2995 SPINST_UNREGSVR | SPINST_PROFILEITEMS | SPINST_COPYINF,
2996 hDevParamKey,
2997 NULL,
2998 0,
2999 set->SelectedDevice->InstallParams.InstallMsgHandler,
3000 set->SelectedDevice->InstallParams.InstallMsgHandlerContext,
3002 NULL))
3003 {
3004 RegCloseKey(hDevParamKey);
3005 return INVALID_HANDLE_VALUE;
3006 }
3007 }
3008 }
3009
3010 SetLastError(rc);
3011 return hDevParamKey;
3012}
static void SETUPDI_GuidToString(const GUID *guid, LPWSTR guidStr)
Definition: devinst.c:81
BOOL WINAPI SetupInstallFromInfSectionW(HWND owner, HINF hinf, PCWSTR section, UINT flags, HKEY key_root, PCWSTR src_root, UINT copy_flags, PSP_FILE_CALLBACK_W callback, PVOID context, HDEVINFO devinfo, PSP_DEVINFO_DATA devinfo_data)
Definition: install.c:1330
static const WCHAR SymbolicLink[]
Definition: interface.c:31
#define L(x)
Definition: resources.c:13
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
wcscpy
#define SPINST_BITREG
Definition: setupapi.h:596
#define SPINST_UNREGSVR
Definition: setupapi.h:598
#define SPINST_PROFILEITEMS
Definition: setupapi.h:599
#define SPINST_INI2REG
Definition: setupapi.h:594
#define SPINST_REGSVR
Definition: setupapi.h:597
#define DIOCR_INTERFACE
Definition: setupapi.h:180
#define SPINST_INIFILES
Definition: setupapi.h:592
#define SPINST_REGISTRY
Definition: setupapi.h:593
#define SPINST_FILES
Definition: setupapi.h:595
WCHAR SymbolicLink[ANYSIZE_ARRAY]

Referenced by InstallOneInterface(), InstallSoftwareDeviceInterfaceInf(), and SetupDiCreateDeviceInterfaceRegKeyA().

◆ SetupDiCreateDeviceInterfaceW()

BOOL WINAPI SetupDiCreateDeviceInterfaceW ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
const GUID InterfaceClassGuid,
PCWSTR  ReferenceString,
DWORD  CreationFlags,
PSP_DEVICE_INTERFACE_DATA  DeviceInterfaceData 
)

Definition at line 2777 of file devinst.c.

2784{
2785 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
2786 TRACE("%s(%p %p %s %s %08x %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData,
2788 CreationFlags, DeviceInterfaceData);
2789
2791 {
2793 return FALSE;
2794 }
2795 if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
2796 {
2798 return FALSE;
2799 }
2802 {
2804 return FALSE;
2805 }
2806 if (!InterfaceClassGuid)
2807 {
2809 return FALSE;
2810 }
2811
2812 FIXME("%p %p %s %s %08x %p\n", DeviceInfoSet, DeviceInfoData,
2814 CreationFlags, DeviceInterfaceData);
2816 return FALSE;
2817}

Referenced by SetupDiCreateDeviceInterfaceA().

◆ SetupDiCreateDevRegKeyA()

HKEY WINAPI SetupDiCreateDevRegKeyA ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
DWORD  Scope,
DWORD  HwProfile,
DWORD  KeyType,
HINF  InfHandle,
PCSTR  InfSectionName 
)

Definition at line 1596 of file devinst.c.

1604{
1605 PWSTR InfSectionNameW = NULL;
1606 HKEY key;
1607
1608 TRACE("%s(%p %p %d %d %d %p %s)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData, Scope,
1609 HwProfile, KeyType, InfHandle, debugstr_a(InfSectionName));
1610
1611 if (InfHandle)
1612 {
1613 if (!InfSectionName)
1614 {
1616 return INVALID_HANDLE_VALUE;
1617 }
1618 else
1619 {
1620 InfSectionNameW = pSetupMultiByteToUnicode(InfSectionName, CP_ACP);
1621 if (InfSectionNameW == NULL) return INVALID_HANDLE_VALUE;
1622 }
1623 }
1625 HwProfile, KeyType, InfHandle, InfSectionNameW);
1626 MyFree(InfSectionNameW);
1627 return key;
1628}
HKEY WINAPI SetupDiCreateDevRegKeyW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, HINF InfHandle, PCWSTR InfSectionName)
Definition: devinst.c:1639

◆ SetupDiCreateDevRegKeyW()

HKEY WINAPI SetupDiCreateDevRegKeyW ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
DWORD  Scope,
DWORD  HwProfile,
DWORD  KeyType,
HINF  InfHandle,
PCWSTR  InfSectionName 
)

Definition at line 1639 of file devinst.c.

1647{
1648 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
1649 struct DeviceInfo *deviceInfo;
1651 DWORD rc;
1652 HKEY hHWProfileKey = INVALID_HANDLE_VALUE;
1653 HKEY hKey = NULL;
1654 HKEY RootKey;
1655
1656 TRACE("%s(%p %p %lu %lu %lu %p %s)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData, Scope,
1657 HwProfile, KeyType, InfHandle, debugstr_w(InfSectionName));
1658
1660 {
1662 return INVALID_HANDLE_VALUE;
1663 }
1664 if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
1665 {
1667 return INVALID_HANDLE_VALUE;
1668 }
1671 {
1673 return INVALID_HANDLE_VALUE;
1674 }
1675 if (Scope != DICS_FLAG_GLOBAL && Scope != DICS_FLAG_CONFIGSPECIFIC)
1676 {
1678 return INVALID_HANDLE_VALUE;
1679 }
1680 if (KeyType != DIREG_DEV && KeyType != DIREG_DRV)
1681 {
1683 return INVALID_HANDLE_VALUE;
1684 }
1685 if (InfHandle && !InfSectionName)
1686 {
1688 return INVALID_HANDLE_VALUE;
1689 }
1690 if (!InfHandle && InfSectionName)
1691 {
1693 return INVALID_HANDLE_VALUE;
1694 }
1695
1696 deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
1697
1698 if (Scope == DICS_FLAG_GLOBAL)
1699 RootKey = set->HKLM;
1700 else /* Scope == DICS_FLAG_CONFIGSPECIFIC */
1701 {
1702 hHWProfileKey = OpenHardwareProfileKey(set->HKLM, HwProfile, KEY_CREATE_SUB_KEY);
1703 if (hHWProfileKey == INVALID_HANDLE_VALUE)
1704 goto cleanup;
1705 RootKey = hHWProfileKey;
1706 }
1707
1708 if (KeyType == DIREG_DEV)
1709 {
1710#if _WIN32_WINNT >= 0x502
1712#else
1714#endif
1716 goto cleanup;
1717
1718 if (Scope == DICS_FLAG_GLOBAL)
1719 {
1720 HKEY hTempKey = hKey;
1721
1722 rc = RegCreateKeyExW(hTempKey,
1723 L"Device Parameters",
1724 0,
1725 NULL,
1727#if _WIN32_WINNT >= 0x502
1729#else
1731#endif
1732 NULL,
1733 &hKey,
1734 NULL);
1735 if (rc == ERROR_SUCCESS)
1736 RegCloseKey(hTempKey);
1737 }
1738 }
1739 else /* KeyType == DIREG_DRV */
1740 {
1741#if _WIN32_WINNT >= 0x502
1743#else
1745#endif
1747 goto cleanup;
1748 }
1749
1750 /* Do installation of the specified section */
1751 if (InfHandle)
1752 {
1753 FIXME("Need to install section %s in file %p\n",
1754 debugstr_w(InfSectionName), InfHandle);
1755 }
1756 key = hKey;
1757
1758cleanup:
1759 if (hHWProfileKey != INVALID_HANDLE_VALUE)
1760 RegCloseKey(hHWProfileKey);
1761 if (hKey != NULL && hKey != key)
1763
1764 TRACE("Returning 0x%p\n", key);
1765 return key;
1766}
HKEY SETUPDI_CreateDrvKey(HKEY RootKey, struct DeviceInfo *devInfo, UUID *ClassGuid, REGSAM samDesired)
Definition: devinst.c:5976
#define DIREG_DEV
Definition: setupapi.h:184
#define DIREG_DRV
Definition: setupapi.h:185
#define DICS_FLAG_CONFIGSPECIFIC
Definition: setupapi.h:117

Referenced by GetPortType(), InstallDeviceData(), InstallNetDevice(), InstallParallelPort(), InstallSerialPort(), SetupDiCreateDevRegKeyA(), and test_device_key().

◆ SetupDiDeleteDeviceInfo()

BOOL WINAPI SetupDiDeleteDeviceInfo ( _In_ HDEVINFO  DeviceInfoSet,
_In_ PSP_DEVINFO_DATA  DeviceInfoData 
)

Definition at line 5001 of file devinst.c.

5004{
5005 struct DeviceInfoSet *deviceInfoSet;
5006 BOOL ret = FALSE;
5007
5009
5010 if (!DeviceInfoSet)
5012 else if ((deviceInfoSet = (struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
5016 else if (!IsDeviceInfoInDeviceInfoSet(deviceInfoSet, (struct DeviceInfo *)DeviceInfoData->Reserved))
5018 else
5019 {
5020 struct DeviceInfo *deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
5021 RemoveEntryList(&deviceInfo->ListEntry);
5022 DestroyDeviceInfo(deviceInfo);
5023 ret = TRUE;
5024 }
5025
5026 return ret;
5027}
static BOOL IsDeviceInfoInDeviceInfoSet(struct DeviceInfoSet *deviceInfoSet, struct DeviceInfo *deviceInfo)
Definition: devinst.c:4979

Referenced by InstallCompositeBattery(), test_device_info(), and test_register_device_info().

◆ SetupDiDeleteDeviceInterfaceRegKey()

BOOL WINAPI SetupDiDeleteDeviceInterfaceRegKey ( HDEVINFO  DeviceInfoSet,
PSP_DEVICE_INTERFACE_DATA  DeviceInterfaceData,
DWORD  Reserved 
)

Definition at line 3017 of file devinst.c.

3021{
3022 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
3023 BOOL ret = FALSE;
3024
3025 TRACE("%s(%p %p %d)\n", __FUNCTION__, DeviceInfoSet, DeviceInterfaceData, Reserved);
3026
3029 {
3031 return FALSE;
3032 }
3033 if (!DeviceInterfaceData ||
3034 DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA) ||
3035 !DeviceInterfaceData->Reserved)
3036 {
3038 return FALSE;
3039 }
3040
3041 FIXME("%p %p %d\n", DeviceInfoSet, DeviceInterfaceData, Reserved);
3043 return ret;
3044}

Referenced by test_device_interface_key().

◆ SetupDiDeleteDevRegKey()

BOOL WINAPI SetupDiDeleteDevRegKey ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
DWORD  Scope,
DWORD  HwProfile,
DWORD  KeyType 
)

Definition at line 6322 of file devinst.c.

6328{
6329 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
6330 struct DeviceInfo *devInfo;
6331 BOOL ret = FALSE;
6332 HKEY RootKey;
6333
6334 TRACE("%s(%p %p %d %d %d)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData, Scope, HwProfile,
6335 KeyType);
6336
6338 {
6340 return FALSE;
6341 }
6342 if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
6343 {
6345 return FALSE;
6346 }
6349 {
6351 return FALSE;
6352 }
6353 if (Scope != DICS_FLAG_GLOBAL && Scope != DICS_FLAG_CONFIGSPECIFIC)
6354 {
6356 return FALSE;
6357 }
6358 if (KeyType != DIREG_DEV && KeyType != DIREG_DRV && KeyType != DIREG_BOTH)
6359 {
6361 return FALSE;
6362 }
6363 devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
6364 if (devInfo->set != set)
6365 {
6367 return FALSE;
6368 }
6369 if (Scope != DICS_FLAG_GLOBAL)
6370 {
6371 RootKey = OpenHardwareProfileKey(set->HKLM, HwProfile, 0);
6373 return FALSE;
6374 }
6375 else
6376 RootKey = set->HKLM;
6377 switch (KeyType)
6378 {
6379 case DIREG_DEV:
6380 ret = SETUPDI_DeleteDevKey(RootKey, devInfo);
6381 break;
6382 case DIREG_DRV:
6383 ret = SETUPDI_DeleteDrvKey(RootKey, devInfo);
6384 break;
6385 case DIREG_BOTH:
6386 ret = SETUPDI_DeleteDevKey(RootKey, devInfo);
6387 if (ret)
6388 ret = SETUPDI_DeleteDrvKey(RootKey, devInfo);
6389 break;
6390 default:
6391 WARN("unknown KeyType %d\n", KeyType);
6392 }
6393 if (RootKey != set->HKLM)
6395 return ret;
6396}
#define WARN(fmt,...)
Definition: precomp.h:61
static BOOL SETUPDI_DeleteDrvKey(HKEY RootKey, struct DeviceInfo *devInfo)
Definition: devinst.c:6313
static BOOL SETUPDI_DeleteDevKey(HKEY RootKey, struct DeviceInfo *devInfo)
Definition: devinst.c:6307
#define DIREG_BOTH
Definition: setupapi.h:186

◆ SetupDiDestroyDeviceInfoList()

BOOL WINAPI SetupDiDestroyDeviceInfoList ( HDEVINFO  devinfo)

Definition at line 3182 of file devinst.c.

3183{
3184 BOOL ret = FALSE;
3185
3186 TRACE("%s(%p)\n", __FUNCTION__, devinfo);
3187 if (devinfo && devinfo != INVALID_HANDLE_VALUE)
3188 {
3189 struct DeviceInfoSet *list = (struct DeviceInfoSet *)devinfo;
3190
3191 if (list->magic == SETUP_DEVICE_INFO_SET_MAGIC)
3192 {
3194 }
3195 }
3196
3197 if (ret == FALSE)
3199
3200 return ret;
3201}
static BOOL DestroyDeviceInfoSet(struct DeviceInfoSet *list)
Definition: devinst.c:851

Referenced by BluetoothFindRadioClose(), check_device_path(), CDeviceNode::Cleanup(), cleanUp(), CloseDeviceList(), DeviceAdvancedPropertiesW(), DeviceProblemWizardW(), DevicePropertiesExW(), DevInstallW(), CNetConnection::Disconnect(), DisplayDeviceAdvancedProperties(), DisplayPageSetDeviceDetails(), CNetConnectionManager::EnumerateINetConnections(), EnumerateNetworkAdapter(), EnumHotpluggedDevices(), fill_pnpentity(), find_devices(), FreeDevicesList(), get_device(), getDeviceInfo(), getDeviceInterfaceDetail(), InitHardWareTypesPage(), InitProbeListPage(), InstallCompositeBattery(), InstallDevInstEx(), InstallSoftwareBusPnpEnumerator(), InstallSoftwareDeviceInterface(), InstallSoftwareDeviceInterfaceInf(), IsSoftwareBusPnpEnumeratorInstalled(), KsOpenDefaultDevice(), CKsProxy::Load(), PowerMeterInfo_UpdateBatteryStats(), ProcessExistingDevices(), CDeviceView::RefreshDeviceList(), run_for_each_device(), SetDeviceDetails(), SetupDiGetClassDevsExW(), SetupDiInstallClassExW(), test_create_device_list_ex(), test_D3DKMTOpenAdapterFromDeviceName_deviface(), test_device_iface(), test_device_iface_detail(), test_device_info(), test_device_interface_key(), test_device_key(), test_devnode(), test_get_device_instance_id(), test_gpu_device_properties_guid(), test_register_device_iface(), test_register_device_info(), test_registry_property_a(), test_registry_property_w(), test_SetupDiGetClassDevsA(), test_SetupDiGetClassDevsExW(), TestKs(), testSetupDiGetClassDevsA(), UpdateDevInfo(), UpdateDriverForPlugAndPlayDevicesW(), WdmAudInitUserModeMixer(), and WdmAudOpenSoundDeviceByLegacy().

◆ SetupDiEnumDeviceInfo()

BOOL WINAPI SetupDiEnumDeviceInfo ( HDEVINFO  devinfo,
DWORD  index,
PSP_DEVINFO_DATA  info 
)

Definition at line 2030 of file devinst.c.

2034{
2035 BOOL ret = FALSE;
2036
2037 TRACE("%s(%p %d %p)\n", __FUNCTION__, devinfo, index, info);
2038
2039 if(info==NULL)
2040 {
2042 return FALSE;
2043 }
2044 if (devinfo && devinfo != INVALID_HANDLE_VALUE)
2045 {
2046 struct DeviceInfoSet *list = (struct DeviceInfoSet *)devinfo;
2047 if (list->magic == SETUP_DEVICE_INFO_SET_MAGIC)
2048 {
2049 if (info->cbSize != sizeof(SP_DEVINFO_DATA))
2051 else
2052 {
2053 PLIST_ENTRY ItemList = list->ListHead.Flink;
2054 while (ItemList != &list->ListHead && index-- > 0)
2055 ItemList = ItemList->Flink;
2056 if (ItemList == &list->ListHead)
2058 else
2059 {
2060 struct DeviceInfo *DevInfo = CONTAINING_RECORD(ItemList, struct DeviceInfo, ListEntry);
2061 memcpy(&info->ClassGuid,
2062 &DevInfo->ClassGuid,
2063 sizeof(GUID));
2064 info->DevInst = DevInfo->dnDevInst;
2065 info->Reserved = (ULONG_PTR)DevInfo;
2066 ret = TRUE;
2067 }
2068 }
2069 }
2070 else
2072 }
2073 else
2075 return ret;
2076}
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
GLuint index
Definition: glext.h:6031

Referenced by BuildDevicesList(), check_device_info_(), DisplayPageSetDeviceDetails(), CNetConnectionManager::EnumerateINetConnections(), EnumerateNetworkAdapter(), EnumHotpluggedDevices(), fill_pnpentity(), FindNetworkAdapter(), getDeviceInfo(), InitProbeListPage(), CDeviceView::ListDevicesByType(), pCDevSettings_GetDeviceInstanceId(), CDeviceView::RefreshDeviceList(), SetDeviceDetails(), test_device_info(), test_register_device_info(), test_SetupDiGetClassDevsExW(), testSetupDiGetClassDevsA(), and UpdateDriverForPlugAndPlayDevicesW().

◆ SetupDiEnumDeviceInterfaces()

BOOL WINAPI SetupDiEnumDeviceInterfaces ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
CONST GUID InterfaceClassGuid,
DWORD  MemberIndex,
PSP_DEVICE_INTERFACE_DATA  DeviceInterfaceData 
)

Definition at line 3069 of file devinst.c.

3075{
3076 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
3077 BOOL ret = FALSE;
3078
3079 TRACE("%s(%p, %p, %s, %d, %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData,
3080 debugstr_guid(InterfaceClassGuid), MemberIndex, DeviceInterfaceData);
3081
3084 {
3086 return FALSE;
3087 }
3090 {
3092 return FALSE;
3093 }
3094 if (!DeviceInterfaceData ||
3095 DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA))
3096 {
3098 return FALSE;
3099 }
3100 if (DeviceInfoData)
3101 {
3102 struct DeviceInfo *devInfo =
3104 BOOL found = FALSE;
3105 PLIST_ENTRY InterfaceListEntry = devInfo->InterfaceListHead.Flink;
3106 while (InterfaceListEntry != &devInfo->InterfaceListHead && !found)
3107 {
3108 struct DeviceInterface *DevItf = CONTAINING_RECORD(InterfaceListEntry, struct DeviceInterface, ListEntry);
3110 {
3111 InterfaceListEntry = InterfaceListEntry->Flink;
3112 continue;
3113 }
3114 if (MemberIndex-- == 0)
3115 {
3116 /* return this item */
3117 memcpy(&DeviceInterfaceData->InterfaceClassGuid,
3118 &DevItf->InterfaceClassGuid,
3119 sizeof(GUID));
3120 DeviceInterfaceData->Flags = DevItf->Flags;
3121 DeviceInterfaceData->Reserved = (ULONG_PTR)DevItf;
3122 found = TRUE;
3123 ret = TRUE;
3124 }
3125 InterfaceListEntry = InterfaceListEntry->Flink;
3126 }
3127 if (!found)
3129 }
3130 else
3131 {
3132 BOOL found = FALSE;
3133 PLIST_ENTRY ItemList = set->ListHead.Flink;
3134 while (ItemList != &set->ListHead && !found)
3135 {
3136 PLIST_ENTRY InterfaceListEntry;
3137 struct DeviceInfo *devInfo =
3138 CONTAINING_RECORD(ItemList, struct DeviceInfo, ListEntry);
3139 InterfaceListEntry = devInfo->InterfaceListHead.Flink;
3140 while (InterfaceListEntry != &devInfo->InterfaceListHead && !found)
3141 {
3142 struct DeviceInterface *DevItf = CONTAINING_RECORD(InterfaceListEntry, struct DeviceInterface, ListEntry);
3144 {
3145 InterfaceListEntry = InterfaceListEntry->Flink;
3146 continue;
3147 }
3148 if (MemberIndex-- == 0)
3149 {
3150 /* return this item */
3151 memcpy(&DeviceInterfaceData->InterfaceClassGuid,
3152 &DevItf->InterfaceClassGuid,
3153 sizeof(GUID));
3154 DeviceInterfaceData->Flags = DevItf->Flags;
3155 DeviceInterfaceData->Reserved = (ULONG_PTR)DevItf;
3156 found = TRUE;
3157 ret = TRUE;
3158 }
3159 InterfaceListEntry = InterfaceListEntry->Flink;
3160 }
3161 ItemList = ItemList->Flink;
3162
3163 }
3164 if (!found)
3166 }
3167 return ret;
3168}
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

Referenced by BluetoothFindNextRadio(), check_device_iface_(), check_device_path(), Enum(), find_devices(), get_device(), getDeviceInterfaceDetail(), GetDeviceListInterfaces(), InstallSoftwareDeviceInterface(), InstallSoftwareDeviceInterfaceInf(), IsSoftwareBusPnpEnumeratorInstalled(), KsOpenDefaultDevice(), PowerMeterInfo_UpdateBatteryStats(), ProcessExistingDevices(), run_for_each_device(), test_D3DKMTOpenAdapterFromDeviceName_deviface(), test_device_iface(), test_gpu_device_properties_guid(), test_register_device_iface(), TestKs(), and WdmAudOpenSoundDeviceByLegacy().

◆ SetupDiGetActualModelsSectionA()

BOOL WINAPI SetupDiGetActualModelsSectionA ( _In_ PINFCONTEXT  Context,
_In_opt_ PSP_ALTPLATFORM_INFO  AlternatePlatformInfo,
_Out_writes_opt_(InfSectionWithExtSize) PSTR  InfSectionWithExt,
_In_ DWORD  InfSectionWithExtSize,
_Out_opt_ PDWORD  RequiredSize,
_Reserved_ PVOID  Reserved 
)

ANSI version of SetupDiGetActualModelsSectionW.

Parameters
[in]ContextINFCONTEXT pointing to a manufacturer ID line.
[in]AlternatePlatformInfoAlternate platform information, or NULL for using the current platform.
[out]InfSectionWithExtOptional buffer that receives the decorated Models section name.
[in]InfSectionWithExtSizeSize of InfSectionWithExt in characters.
[out]RequiredSizeReceives the required buffer size in characters (including NUL).
[in]ReservedMust be NULL.
Returns
TRUE on success, FALSE on failure.

Definition at line 725 of file devinst.c.

732{
733 PWSTR Buffer = NULL;
734 DWORD Required = 0;
735 BOOL ret;
736
737 if (InfSectionWithExtSize > 0)
738 {
739 Buffer = HeapAlloc(GetProcessHeap(), 0, InfSectionWithExtSize * sizeof(WCHAR));
740 if (!Buffer)
741 {
743 return FALSE;
744 }
745 }
746
747 ret = SetupDiGetActualModelsSectionW(Context, AlternatePlatformInfo,
748 Buffer, InfSectionWithExtSize,
750
752 Required = 0;
753
754 if (RequiredSize)
756
757 if (ret && Buffer && InfSectionWithExt)
758 {
760 InfSectionWithExt, InfSectionWithExtSize,
761 NULL, NULL);
762 }
763
764 if (Buffer)
766
767 return ret;
768}
BOOL WINAPI SetupDiGetActualModelsSectionW(_In_ PINFCONTEXT Context, _In_opt_ PSP_ALTPLATFORM_INFO AlternatePlatformInfo, _Out_writes_opt_(InfSectionWithExtSize) PWSTR InfSectionWithExt, _In_ DWORD InfSectionWithExtSize, _Out_opt_ PDWORD RequiredSize, _Reserved_ PVOID Reserved)
Returns the appropriate decorated INF Models section for a device.
Definition: devinst.c:552
_In_ PMEMORY_AREA _In_ PVOID _In_ BOOLEAN _Inout_ PMM_REQUIRED_RESOURCES Required
Definition: newmm.h:210

Referenced by test_SetupDiGetActualModelsSectionA().

◆ SetupDiGetActualModelsSectionW()

BOOL WINAPI SetupDiGetActualModelsSectionW ( _In_ PINFCONTEXT  Context,
_In_opt_ PSP_ALTPLATFORM_INFO  AlternatePlatformInfo,
_Out_writes_opt_(InfSectionWithExtSize) PWSTR  InfSectionWithExt,
_In_ DWORD  InfSectionWithExtSize,
_Out_opt_ PDWORD  RequiredSize,
_Reserved_ PVOID  Reserved 
)

Returns the appropriate decorated INF Models section for a device.

Parameters
[in]ContextINFCONTEXT pointing to a manufacturer ID line.
[in]AlternatePlatformInfoAlternate platform information, or NULL for using the current platform.
[out]InfSectionWithExtOptional buffer that receives the decorated Models section name.
[in]InfSectionWithExtSizeSize of InfSectionWithExt in characters.
[out]RequiredSizeReceives the required buffer size in characters (including NUL).
[in]ReservedMust be NULL.
Returns
TRUE on success, FALSE on failure.

Definition at line 552 of file devinst.c.

559{
560 static SP_ALTPLATFORM_INFO CurrentPlatform = { 0 };
561 static BYTE CurrentProductType = 0;
562 static WORD CurrentSuiteMask = 0;
563
564 PSP_ALTPLATFORM_INFO pPlatformInfo;
565 BYTE ProductType;
566 WORD SuiteMask;
567 WCHAR ModelsSection[LINE_LEN + 1];
568 WCHAR BestSection[LINE_LEN + 1];
569 DWORD BestScore1 = ULONG_MAX, BestScore2 = ULONG_MAX;
570 DWORD BestScore3 = ULONG_MAX, BestScore4 = ULONG_MAX, BestScore5 = ULONG_MAX;
571 DWORD FieldCount, i, dwFullLength;
572
573 TRACE("%s(%p %p %p %lu %p %p)\n", __FUNCTION__, Context,
574 AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize,
576
577 if (!Context)
578 {
580 return FALSE;
581 }
582
583 if (AlternatePlatformInfo &&
584 AlternatePlatformInfo->cbSize != sizeof(SP_ALTPLATFORM_INFO))
585 {
587 return FALSE;
588 }
589
590 /* Resolve platform */
591 if (AlternatePlatformInfo)
592 {
593 pPlatformInfo = AlternatePlatformInfo;
594 ProductType = 0;
595 SuiteMask = 0;
596 }
597 else
598 {
599 if (CurrentPlatform.cbSize != sizeof(CurrentPlatform))
600 {
601 SYSTEM_INFO SystemInfo;
602 GetSystemInfo(&SystemInfo);
603 CurrentPlatform.cbSize = sizeof(CurrentPlatform);
604 CurrentPlatform.Platform = OsVersionInfo.dwPlatformId;
605 CurrentPlatform.MajorVersion = OsVersionInfo.dwMajorVersion;
606 CurrentPlatform.MinorVersion = OsVersionInfo.dwMinorVersion;
607 CurrentPlatform.ProcessorArchitecture = SystemInfo.wProcessorArchitecture;
608 CurrentPlatform.Reserved = 0;
609 CurrentProductType = OsVersionInfo.wProductType;
610 CurrentSuiteMask = OsVersionInfo.wSuiteMask;
611 }
612 pPlatformInfo = &CurrentPlatform;
613 ProductType = CurrentProductType;
614 SuiteMask = CurrentSuiteMask;
615 }
616
617 /* Field 1: models-section-name */
618 if (!SetupGetStringFieldW(Context, 1, ModelsSection, ARRAYSIZE(ModelsSection), NULL) &&
619 !SetupGetStringFieldW(Context, 0, ModelsSection, ARRAYSIZE(ModelsSection), NULL))
620 {
622 return FALSE;
623 }
624
625 strcpyW(BestSection, ModelsSection);
626 FieldCount = SetupGetFieldCount(Context);
627
628 /* Fields 2..N are the TargetOSVersion decorations */
629 for (i = 2; i <= FieldCount; i++)
630 {
631 WCHAR Candidate[LINE_LEN + 2]; /* +1 for possible leading '.' and +1 for NUL */
632 DWORD Score1, Score2, Score3, Score4, Score5;
633 DWORD DecLen;
634
635 if (!SetupGetStringFieldW(Context, i, Candidate, ARRAYSIZE(Candidate) - 1, NULL))
636 continue;
637
638 if (!Candidate[0])
639 continue;
640
641 /* CheckSectionValid expects a leading dot */
642 if (Candidate[0] != '.')
643 {
644 memmove(Candidate + 1, Candidate, (lstrlenW(Candidate) + 1) * sizeof(WCHAR));
645 Candidate[0] = '.';
646 }
647
648 if (!CheckSectionValid(Candidate, pPlatformInfo, ProductType, SuiteMask,
649 &Score1, &Score2, &Score3, &Score4, &Score5))
650 {
651 continue;
652 }
653
654 /* Lower scores are better */
655 if (Score1 > BestScore1) continue;
656 if (Score1 < BestScore1) goto better;
657 if (Score2 > BestScore2) continue;
658 if (Score2 < BestScore2) goto better;
659 if (Score3 > BestScore3) continue;
660 if (Score3 < BestScore3) goto better;
661 if (Score4 > BestScore4) continue;
662 if (Score4 < BestScore4) goto better;
663 if (Score5 > BestScore5) continue;
664 if (Score5 < BestScore5) goto better;
665 continue;
666
667better:
668 DecLen = lstrlenW(Candidate);
669 if (lstrlenW(ModelsSection) + DecLen >= ARRAYSIZE(BestSection))
670 continue;
671
672 strcpyW(BestSection, ModelsSection);
673 strcatW(BestSection, Candidate);
674 BestScore1 = Score1;
675 BestScore2 = Score2;
676 BestScore3 = Score3;
677 BestScore4 = Score4;
678 BestScore5 = Score5;
679 }
680
681 dwFullLength = lstrlenW(BestSection);
682 if (RequiredSize)
683 *RequiredSize = dwFullLength + 1;
684
685 if (InfSectionWithExtSize > 0)
686 {
687 if (InfSectionWithExtSize < dwFullLength + 1)
688 {
690 return FALSE;
691 }
692 strcpyW(InfSectionWithExt, BestSection);
693 }
694
695 TRACE("Returning section %s\n", debugstr_w(BestSection));
696 return TRUE;
697}
#define lstrlenW
Definition: compat.h:750
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
unsigned short WORD
Definition: ntddk_ex.h:93
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define LINE_LEN
Definition: setupapi.h:22
OSVERSIONINFOEXW OsVersionInfo
Definition: setupcab.c:33
ULONG dwMajorVersion
Definition: rtltypes.h:270
ULONG dwMinorVersion
Definition: rtltypes.h:271
ULONG dwPlatformId
Definition: rtltypes.h:273
UCHAR wProductType
Definition: rtltypes.h:278
USHORT wSuiteMask
Definition: rtltypes.h:277
WORD wProcessorArchitecture
Definition: winbase.h:894
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:186
ULONG WINAPI SetupGetFieldCount(IN PINFCONTEXT Context)
Definition: infsupp.c:93

Referenced by SetupDiGetActualModelsSectionA(), and test_SetupDiGetActualModelsSectionW().

◆ SetupDiGetActualSectionToInstallA()

BOOL WINAPI SetupDiGetActualSectionToInstallA ( HINF  InfHandle,
PCSTR  InfSectionName,
PSTR  InfSectionWithExt,
DWORD  InfSectionWithExtSize,
PDWORD  RequiredSize,
PSTR Extension 
)

Definition at line 2207 of file devinst.c.

2214{
2215 return SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName,
2216 NULL, InfSectionWithExt, InfSectionWithExtSize, RequiredSize,
2217 Extension, NULL);
2218}
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)
Definition: devinst.c:2240
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092

◆ SetupDiGetActualSectionToInstallExA()

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 
)

Definition at line 2240 of file devinst.c.

2249{
2250 LPWSTR InfSectionNameW = NULL;
2251 LPWSTR InfSectionWithExtW = NULL;
2252 PWSTR ExtensionW;
2253 BOOL bResult = FALSE;
2254
2255 TRACE("%s()\n", __FUNCTION__);
2256
2257 if (InfSectionName)
2258 {
2259 InfSectionNameW = pSetupMultiByteToUnicode(InfSectionName, CP_ACP);
2260 if (InfSectionNameW == NULL)
2261 goto cleanup;
2262 }
2263 if (InfSectionWithExt)
2264 {
2265 InfSectionWithExtW = MyMalloc(InfSectionWithExtSize * sizeof(WCHAR));
2266 if (InfSectionWithExtW == NULL)
2267 goto cleanup;
2268 }
2269
2271 InfHandle, InfSectionNameW, AlternatePlatformInfo,
2272 InfSectionWithExt ? InfSectionWithExtW : NULL,
2273 InfSectionWithExtSize,
2275 Extension ? &ExtensionW : NULL,
2276 Reserved);
2277
2278 if (bResult && InfSectionWithExt)
2279 {
2280 bResult = WideCharToMultiByte(CP_ACP, 0, InfSectionWithExtW, -1, InfSectionWithExt,
2281 InfSectionWithExtSize, NULL, NULL) != 0;
2282 }
2283 if (bResult && Extension)
2284 {
2285 if (ExtensionW == NULL)
2286 *Extension = NULL;
2287 else
2288 *Extension = &InfSectionWithExt[ExtensionW - InfSectionWithExtW];
2289 }
2290
2291cleanup:
2292 MyFree(InfSectionNameW);
2293 MyFree(InfSectionWithExtW);
2294
2295 return bResult;
2296}
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)
Definition: devinst.c:415

Referenced by SetupDiGetActualSectionToInstallA().

◆ SetupDiGetActualSectionToInstallExW()

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 
)

Definition at line 415 of file devinst.c.

424{
425 BOOL ret = FALSE;
426
427 TRACE("%s(%p %s %p %p %lu %p %p %p)\n", __FUNCTION__, InfHandle, debugstr_w(InfSectionName),
428 AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize,
430
431 if (!InfHandle || InfHandle == (HINF)INVALID_HANDLE_VALUE)
433 else if (!InfSectionName)
435 else if (AlternatePlatformInfo && AlternatePlatformInfo->cbSize != sizeof(SP_ALTPLATFORM_INFO))
437 else if (Reserved != NULL)
439 else
440 {
441 static SP_ALTPLATFORM_INFO CurrentPlatform = { 0, };
442 static BYTE CurrentProductType = 0;
443 static WORD CurrentSuiteMask = 0;
444 PSP_ALTPLATFORM_INFO pPlatformInfo = &CurrentPlatform;
445 struct GetSectionCallbackInfo CallbackInfo;
446 DWORD dwFullLength;
449
450 /* Fill platform info if needed */
451 if (AlternatePlatformInfo)
452 {
453 pPlatformInfo = AlternatePlatformInfo;
454 ProductType = 0;
455 SuiteMask = 0;
456 }
457 else
458 {
459 if (CurrentPlatform.cbSize != sizeof(SP_ALTPLATFORM_INFO))
460 {
461 /* That's the first time we go here. We need to fill in the structure */
462 SYSTEM_INFO SystemInfo;
463 GetSystemInfo(&SystemInfo);
464 CurrentPlatform.cbSize = sizeof(SP_ALTPLATFORM_INFO);
465 CurrentPlatform.Platform = OsVersionInfo.dwPlatformId;
466 CurrentPlatform.MajorVersion = OsVersionInfo.dwMajorVersion;
467 CurrentPlatform.MinorVersion = OsVersionInfo.dwMinorVersion;
468 CurrentPlatform.ProcessorArchitecture = SystemInfo.wProcessorArchitecture;
469 CurrentPlatform.Reserved = 0;
470 CurrentProductType = OsVersionInfo.wProductType;
471 CurrentSuiteMask = OsVersionInfo.wSuiteMask;
472 }
473 ProductType = CurrentProductType;
474 SuiteMask = CurrentSuiteMask;
475 }
476
477 CallbackInfo.PlatformInfo = pPlatformInfo;
478 CallbackInfo.ProductType = ProductType;
479 CallbackInfo.SuiteMask = SuiteMask;
480 CallbackInfo.PrefixLength = strlenW(InfSectionName);
481 CallbackInfo.BestScore1 = ULONG_MAX;
482 CallbackInfo.BestScore2 = ULONG_MAX;
483 CallbackInfo.BestScore3 = ULONG_MAX;
484 CallbackInfo.BestScore4 = ULONG_MAX;
485 CallbackInfo.BestScore5 = ULONG_MAX;
486 strcpyW(CallbackInfo.BestSection, InfSectionName);
487 TRACE("EnumerateSectionsStartingWith(InfSectionName = %S)\n", InfSectionName);
489 InfHandle,
490 InfSectionName,
492 &CallbackInfo))
493 {
495 goto done;
496 }
497 TRACE("CallbackInfo.BestSection = %S\n", CallbackInfo.BestSection);
498
499 dwFullLength = lstrlenW(CallbackInfo.BestSection);
500 if (RequiredSize != NULL)
501 *RequiredSize = dwFullLength + 1;
502
503 if (InfSectionWithExtSize > 0)
504 {
505 if (InfSectionWithExtSize < dwFullLength + 1)
506 {
508 goto done;
509 }
510 strcpyW(InfSectionWithExt, CallbackInfo.BestSection);
511 if (Extension)
512 {
513 DWORD dwLength = lstrlenW(InfSectionName);
514 *Extension = (dwLength == dwFullLength) ? NULL : &InfSectionWithExt[dwLength];
515 }
516 }
517
518 ret = TRUE;
519 }
520
521done:
522 TRACE("Returning %d\n", ret);
523 return ret;
524}
static BOOL GetSectionCallback(IN LPCWSTR SectionName, IN PVOID Context)
Definition: devinst.c:365
BOOL EnumerateSectionsStartingWith(IN HINF hInf, IN LPCWSTR pStr, IN FIND_CALLBACK Callback, IN PVOID Context)
Definition: parser.c:2411
SP_ALTPLATFORM_INFO_V1 SP_ALTPLATFORM_INFO
Definition: setupapi.h:733

Referenced by SetupDiGetActualSectionToInstallExA(), and SetupDiGetActualSectionToInstallW().

◆ SetupDiGetActualSectionToInstallW()

BOOL WINAPI SetupDiGetActualSectionToInstallW ( HINF  InfHandle,
PCWSTR  InfSectionName,
PWSTR  InfSectionWithExt,
DWORD  InfSectionWithExtSize,
PDWORD  RequiredSize,
PWSTR Extension 
)

◆ SetupDiGetClassDescriptionA()

BOOL WINAPI SetupDiGetClassDescriptionA ( const GUID ClassGuid,
PSTR  ClassDescription,
DWORD  ClassDescriptionSize,
PDWORD  RequiredSize 
)

Definition at line 2301 of file devinst.c.

2306{
2307 return SetupDiGetClassDescriptionExA(ClassGuid, ClassDescription,
2308 ClassDescriptionSize,
2310}
BOOL WINAPI SetupDiGetClassDescriptionExA(const GUID *ClassGuid, PSTR ClassDescription, DWORD ClassDescriptionSize, PDWORD RequiredSize, PCSTR MachineName, PVOID Reserved)
Definition: devinst.c:2329

Referenced by test_SetupDiGetClassDescriptionA().

◆ SetupDiGetClassDescriptionExA()

BOOL WINAPI SetupDiGetClassDescriptionExA ( const GUID ClassGuid,
PSTR  ClassDescription,
DWORD  ClassDescriptionSize,
PDWORD  RequiredSize,
PCSTR  MachineName,
PVOID  Reserved 
)

Definition at line 2329 of file devinst.c.

2336{
2337 PWCHAR ClassDescriptionW = NULL;
2338 LPWSTR MachineNameW = NULL;
2339 BOOL ret = FALSE;
2340
2341 TRACE("%s(%s %p %lu %p %s %p)\n", __FUNCTION__, debugstr_guid(ClassGuid), ClassDescription,
2342 ClassDescriptionSize, RequiredSize, debugstr_a(MachineName), Reserved);
2343
2344 if (ClassDescriptionSize > 0)
2345 {
2346 ClassDescriptionW = MyMalloc(ClassDescriptionSize * sizeof(WCHAR));
2347 if (!ClassDescriptionW)
2348 {
2350 goto cleanup;
2351 }
2352 }
2353
2354 if (MachineName)
2355 {
2357 if (!MachineNameW)
2358 {
2360 goto cleanup;
2361 }
2362 }
2363
2364 ret = SetupDiGetClassDescriptionExW(ClassGuid, ClassDescriptionW,
2365 ClassDescriptionSize * sizeof(WCHAR), RequiredSize, MachineNameW, Reserved);
2366 if (ret)
2367 {
2368 DWORD len = (DWORD)WideCharToMultiByte(CP_ACP, 0, ClassDescriptionW, -1, ClassDescription,
2369 ClassDescriptionSize, NULL, NULL);
2370 if (len == 0 || len > ClassDescriptionSize)
2371 {
2373 ret = FALSE;
2374 }
2375 }
2376
2377cleanup:
2378 MyFree(ClassDescriptionW);
2379 MyFree(MachineNameW);
2380 return ret;
2381}
BOOL WINAPI SetupDiGetClassDescriptionExW(const GUID *ClassGuid, PWSTR ClassDescription, DWORD ClassDescriptionSize, PDWORD RequiredSize, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:2386

Referenced by SetupDiGetClassDescriptionA().

◆ SetupDiGetClassDescriptionExW()

BOOL WINAPI SetupDiGetClassDescriptionExW ( const GUID ClassGuid,
PWSTR  ClassDescription,
DWORD  ClassDescriptionSize,
PDWORD  RequiredSize,
PCWSTR  MachineName,
PVOID  Reserved 
)

Definition at line 2386 of file devinst.c.

2393{
2394 HKEY hKey;
2396 DWORD dwRegType;
2397 LONG rc;
2398 PWSTR Buffer;
2399
2400 TRACE("%s(%s %p %lu %p %s %p)\n", __FUNCTION__, debugstr_guid(ClassGuid), ClassDescription,
2401 ClassDescriptionSize, RequiredSize, debugstr_w(MachineName), Reserved);
2402
2403 /* Make sure there's a GUID */
2404 if (!ClassGuid)
2405 {
2407 return FALSE;
2408 }
2409
2410 /* Make sure there's a real buffer when there's a size */
2411 if (!ClassDescription && ClassDescriptionSize > 0)
2412 {
2414 return FALSE;
2415 }
2416
2417 /* Open the key for the GUID */
2418 hKey = SetupDiOpenClassRegKeyExW(ClassGuid,
2422 Reserved);
2424 return FALSE;
2425
2426 /* Retrieve the class description data and close the key */
2427 rc = QueryRegistryValue(hKey, NULL, (LPBYTE *) &Buffer, &dwRegType, &dwLength);
2429
2430 /* Make sure we got the data */
2431 if (rc != ERROR_SUCCESS)
2432 {
2433 SetLastError(rc);
2434 return FALSE;
2435 }
2436
2437 /* Make sure the data is a string */
2438 if (dwRegType != REG_SZ)
2439 {
2440 MyFree(Buffer);
2442 return FALSE;
2443 }
2444
2445 /* Determine the length of the class description */
2446 dwLength /= sizeof(WCHAR);
2447
2448 /* Count the null-terminator if none is present */
2449 if ((dwLength == 0) || (Buffer[dwLength - 1] != UNICODE_NULL))
2450 dwLength++;
2451
2452 /* Inform the caller about the class description */
2453 if ((ClassDescription != NULL) && (dwLength <= ClassDescriptionSize))
2454 {
2455 memcpy(ClassDescription, Buffer, (dwLength - 1) * sizeof(WCHAR));
2456 ClassDescription[dwLength - 1] = UNICODE_NULL;
2457 }
2458
2459 /* Inform the caller about the required size */
2460 if (RequiredSize != NULL)
2462
2463 /* Clean up the buffer */
2464 MyFree(Buffer);
2465
2466 /* Make sure the buffer was large enough */
2467 if ((ClassDescription == NULL) || (dwLength > ClassDescriptionSize))
2468 {
2470 return FALSE;
2471 }
2472
2473 return TRUE;
2474}

Referenced by SetupDiGetClassDescriptionExA(), and SetupDiGetClassDescriptionW().

◆ SetupDiGetClassDescriptionW()

BOOL WINAPI SetupDiGetClassDescriptionW ( const GUID ClassGuid,
PWSTR  ClassDescription,
DWORD  ClassDescriptionSize,
PDWORD  RequiredSize 
)

Definition at line 2315 of file devinst.c.

2320{
2321 return SetupDiGetClassDescriptionExW(ClassGuid, ClassDescription,
2322 ClassDescriptionSize,
2324}

◆ SetupDiGetClassDevsA()

HDEVINFO WINAPI SetupDiGetClassDevsA ( CONST GUID class,
LPCSTR  enumstr,
HWND  parent,
DWORD  flags 
)

Definition at line 2479 of file devinst.c.

2484{
2485 return SetupDiGetClassDevsExA(class, enumstr, parent,
2486 flags, NULL, NULL, NULL);
2487}
HDEVINFO WINAPI SetupDiGetClassDevsExA(const GUID *class, PCSTR enumstr, HWND parent, DWORD flags, HDEVINFO deviceset, PCSTR machine, PVOID reserved)
Definition: devinst.c:2492
r parent
Definition: btrfs.c:3010
GLbitfield flags
Definition: glext.h:7161

Referenced by test_device_interface_key(), test_devnode(), test_register_device_iface(), test_register_device_info(), test_registry_property_a(), test_registry_property_w(), and testSetupDiGetClassDevsA().

◆ SetupDiGetClassDevsExA()

HDEVINFO WINAPI SetupDiGetClassDevsExA ( const GUID class,
PCSTR  enumstr,
HWND  parent,
DWORD  flags,
HDEVINFO  deviceset,
PCSTR  machine,
PVOID  reserved 
)

Definition at line 2492 of file devinst.c.

2500{
2501 HDEVINFO ret;
2502 LPWSTR enumstrW = NULL, machineW = NULL;
2503
2504 if (enumstr)
2505 {
2506 enumstrW = pSetupMultiByteToUnicode(enumstr, CP_ACP);
2507 if (!enumstrW)
2508 {
2510 goto end;
2511 }
2512 }
2513 if (machine)
2514 {
2516 if (!machineW)
2517 {
2518 MyFree(enumstrW);
2520 goto end;
2521 }
2522 }
2523 ret = SetupDiGetClassDevsExW(class, enumstrW, parent, flags, deviceset,
2525 MyFree(enumstrW);
2527
2528end:
2529 return ret;
2530}
HDEVINFO WINAPI SetupDiGetClassDevsExW(CONST GUID *class, PCWSTR enumstr, HWND parent, DWORD flags, HDEVINFO deviceset, PCWSTR machine, PVOID reserved)
Definition: devinst.c:2548
r reserved
Definition: btrfs.c:3006
GLuint GLuint end
Definition: gl.h:1545
static const WCHAR machineW[]
Definition: profile.c:105
static const char machine[]
Definition: profile.c:104

Referenced by SetupDiGetClassDevsA().

◆ SetupDiGetClassDevsExW()

HDEVINFO WINAPI SetupDiGetClassDevsExW ( CONST GUID class,
PCWSTR  enumstr,
HWND  parent,
DWORD  flags,
HDEVINFO  deviceset,
PCWSTR  machine,
PVOID  reserved 
)

Definition at line 2548 of file devinst.c.

2556{
2557 HDEVINFO hDeviceInfo = INVALID_HANDLE_VALUE;
2558 struct DeviceInfoSet *list;
2559 CONST GUID *pClassGuid;
2560 LONG rc;
2562
2563 TRACE("%s(%s %s %p 0x%08x %p %s %p)\n", __FUNCTION__, debugstr_guid(class),
2564 debugstr_w(enumstr), parent, flags, deviceset, debugstr_w(machine),
2565 reserved);
2566
2567 if (!(flags & DIGCF_ALLCLASSES) && !class)
2568 {
2570 return INVALID_HANDLE_VALUE;
2571 }
2572
2573 /* Create the deviceset if not set */
2574 if (deviceset)
2575 {
2576 list = (struct DeviceInfoSet *)deviceset;
2577 if (list->magic != SETUP_DEVICE_INFO_SET_MAGIC)
2578 {
2580 goto cleanup;
2581 }
2582 hDeviceInfo = deviceset;
2583 }
2584 else
2585 {
2586 hDeviceInfo = SetupDiCreateDeviceInfoListExW(
2588 NULL, machine, NULL);
2589 if (hDeviceInfo == INVALID_HANDLE_VALUE)
2590 goto cleanup;
2591 list = (struct DeviceInfoSet *)hDeviceInfo;
2592 }
2593
2594 if (flags & DIGCF_PROFILE)
2595 FIXME(": flag DIGCF_PROFILE ignored\n");
2596
2598 {
2599 if (!class)
2600 {
2602 goto cleanup;
2603 }
2604 rc = SETUP_CreateInterfaceList(list, machine, class, enumstr, flags & DIGCF_PRESENT);
2605 }
2606 else
2607 {
2608 /* Determine which class(es) should be included in the deviceset */
2609 if (flags & DIGCF_ALLCLASSES)
2610 {
2611 /* The caller wants all classes. Check if
2612 * the deviceset limits us to one class */
2613 if (IsEqualIID(&list->ClassGuid, &GUID_NULL))
2614 pClassGuid = NULL;
2615 else
2616 pClassGuid = &list->ClassGuid;
2617 }
2618 else if (class)
2619 {
2620 /* The caller wants one class. Check if it matches deviceset class */
2621 if (IsEqualIID(&list->ClassGuid, class)
2622 || IsEqualIID(&list->ClassGuid, &GUID_NULL))
2623 {
2624 pClassGuid = class;
2625 }
2626 else
2627 {
2629 goto cleanup;
2630 }
2631 }
2632 else if (!IsEqualIID(&list->ClassGuid, &GUID_NULL))
2633 {
2634 /* No class specified. Try to use the one of the deviceset */
2635 if (IsEqualIID(&list->ClassGuid, &GUID_NULL))
2636 pClassGuid = &list->ClassGuid;
2637 else
2638 {
2640 goto cleanup;
2641 }
2642 }
2643 else
2644 {
2646 goto cleanup;
2647 }
2648 rc = SETUP_CreateDevicesList(list, machine, pClassGuid, enumstr);
2649 }
2650 if (rc != ERROR_SUCCESS)
2651 {
2652 SetLastError(rc);
2653 goto cleanup;
2654 }
2655 set = hDeviceInfo;
2656
2657cleanup:
2658 if (!deviceset && hDeviceInfo != INVALID_HANDLE_VALUE && hDeviceInfo != set)
2659 SetupDiDestroyDeviceInfoList(hDeviceInfo);
2660 return set;
2661}
LONG SETUP_CreateDevicesList(IN OUT struct DeviceInfoSet *list, IN PCWSTR MachineName OPTIONAL, IN CONST GUID *Class OPTIONAL, IN PCWSTR Enumerator OPTIONAL)
Definition: devclass.c:121
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:3182
LONG SETUP_CreateInterfaceList(struct DeviceInfoSet *list, PCWSTR MachineName, CONST GUID *InterfaceGuid, PCWSTR DeviceInstanceW, BOOL OnlyPresentInterfaces)
Definition: interface.c:68
#define CONST
Definition: pedump.c:81
#define DIGCF_DEVICEINTERFACE
Definition: setupapi.h:177
#define DIGCF_ALLCLASSES
Definition: setupapi.h:175
#define DIGCF_PROFILE
Definition: setupapi.h:176
#define DIGCF_PRESENT
Definition: setupapi.h:174

Referenced by ProcessExistingDevices(), SetupDiGetClassDevsExA(), SetupDiGetClassDevsW(), and test_SetupDiGetClassDevsExW().

◆ SetupDiGetClassDevsW()

◆ SetupDiGetCustomDevicePropertyA()

BOOL WINAPI SetupDiGetCustomDevicePropertyA ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA  DeviceInfoData,
IN PCSTR  CustomPropertyName,
IN DWORD  Flags,
OUT PDWORD PropertyRegDataType  OPTIONAL,
OUT PBYTE  PropertyBuffer,
IN DWORD  PropertyBufferSize,
OUT PDWORD RequiredSize  OPTIONAL 
)

Definition at line 6448 of file devinst.c.

6457{
6458 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
6459 struct DeviceInfo *deviceInfo;
6460 DWORD ConfigFlags = 0, PropertySize;
6461 CONFIGRET cr;
6462
6463 TRACE("%s(%p %p %s 0x%lx %p %p %lu %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData,
6465
6467 {
6469 return FALSE;
6470 }
6471 if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
6472 {
6474 return FALSE;
6475 }
6478 {
6480 return FALSE;
6481 }
6483 {
6485 return FALSE;
6486 }
6487
6488 deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
6489 if (deviceInfo->set != set)
6490 {
6492 return FALSE;
6493 }
6494
6496 {
6497 ConfigFlags |= CM_CUSTOMDEVPROP_MERGE_MULTISZ;
6498 }
6499
6500 PropertySize = PropertyBufferSize;
6502 CustomPropertyName,
6505 &PropertySize,
6506 ConfigFlags,
6507 set->hMachine);
6508 if ((cr == CR_SUCCESS) || (cr == CR_BUFFER_SMALL))
6509 {
6510 if (RequiredSize)
6511 *RequiredSize = PropertySize;
6512 }
6513
6514 if (cr != CR_SUCCESS)
6515 {
6517 return FALSE;
6518 }
6519
6520 return TRUE;
6521}
#define CM_Get_DevInst_Custom_Property_ExA
Definition: cfgmgr32.h:1788
#define CM_CUSTOMDEVPROP_MERGE_MULTISZ
Definition: cfgmgr32.h:835
_In_ DWORD _Out_opt_ PDWORD PropertyRegDataType
Definition: setupapi.h:1582
#define DICUSTOMDEVPROP_MERGE_MULTISZ
Definition: setupapi.h:122

◆ SetupDiGetCustomDevicePropertyW()

BOOL WINAPI SetupDiGetCustomDevicePropertyW ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA  DeviceInfoData,
IN PCWSTR  CustomPropertyName,
IN DWORD  Flags,
OUT PDWORD PropertyRegDataType  OPTIONAL,
OUT PBYTE  PropertyBuffer,
IN DWORD  PropertyBufferSize,
OUT PDWORD RequiredSize  OPTIONAL 
)

Definition at line 6528 of file devinst.c.

6537{
6538 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
6539 struct DeviceInfo *deviceInfo;
6540 DWORD ConfigFlags = 0, PropertySize;
6541 CONFIGRET cr;
6542
6543 TRACE("%s(%p %p %s 0x%lx %p %p %lu %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData,
6545
6547 {
6549 return FALSE;
6550 }
6551 if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
6552 {
6554 return FALSE;
6555 }
6558 {
6560 return FALSE;
6561 }
6563 {
6565 return FALSE;
6566 }
6567
6568 deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
6569 if (deviceInfo->set != set)
6570 {
6572 return FALSE;
6573 }
6574
6576 {
6577 ConfigFlags |= CM_CUSTOMDEVPROP_MERGE_MULTISZ;
6578 }
6579
6580 PropertySize = PropertyBufferSize;
6582 CustomPropertyName,
6585 &PropertySize,
6586 ConfigFlags,
6587 set->hMachine);
6588 if ((cr == CR_SUCCESS) || (cr == CR_BUFFER_SMALL))
6589 {
6590 if (RequiredSize)
6591 *RequiredSize = PropertySize;
6592 }
6593
6594 if (cr != CR_SUCCESS)
6595 {
6597 return FALSE;
6598 }
6599
6600 return TRUE;
6601}
#define CM_Get_DevInst_Custom_Property_ExW
Definition: cfgmgr32.h:1787

◆ SetupDiGetDeviceInfoListClass()

BOOL WINAPI SetupDiGetDeviceInfoListClass ( IN HDEVINFO  DeviceInfoSet,
OUT LPGUID  ClassGuid 
)

Definition at line 4710 of file devinst.c.

4713{
4714 struct DeviceInfoSet *list;
4715 BOOL ret = FALSE;
4716
4717 TRACE("%s(%p %p)\n", __FUNCTION__, DeviceInfoSet, ClassGuid);
4718
4719 if (!DeviceInfoSet)
4723 else if (IsEqualIID(&list->ClassGuid, &GUID_NULL))
4725 else
4726 {
4727 *ClassGuid = list->ClassGuid;
4728
4729 ret = TRUE;
4730 }
4731
4732 TRACE("Returning %d\n", ret);
4733 return ret;
4734}
#define ERROR_NO_ASSOCIATED_CLASS
Definition: setupapi.h:299

◆ SetupDiGetDeviceInfoListDetailA()

BOOL WINAPI SetupDiGetDeviceInfoListDetailA ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_LIST_DETAIL_DATA_A  DevInfoData 
)

Definition at line 2666 of file devinst.c.

2669{
2670 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
2671
2672 TRACE("%s(%p %p)\n", __FUNCTION__, DeviceInfoSet, DevInfoData);
2673
2675 {
2677 return FALSE;
2678 }
2679 if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
2680 {
2682 return FALSE;
2683 }
2684 if (!DevInfoData ||
2685 DevInfoData->cbSize != sizeof(SP_DEVINFO_LIST_DETAIL_DATA_A))
2686 {
2688 return FALSE;
2689 }
2690 memcpy(&DevInfoData->ClassGuid, &set->ClassGuid, sizeof(GUID));
2691 DevInfoData->RemoteMachineHandle = set->hMachine;
2692 if (set->MachineName)
2693 {
2694 FIXME("Stub\n");
2696 return FALSE;
2697 }
2698 else
2699 DevInfoData->RemoteMachineName[0] = 0;
2700
2701 return TRUE;
2702}
CHAR RemoteMachineName[SP_MAX_MACHINENAME_LENGTH]
Definition: setupapi.h:870

◆ SetupDiGetDeviceInfoListDetailW()

BOOL WINAPI SetupDiGetDeviceInfoListDetailW ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_LIST_DETAIL_DATA_W  DevInfoData 
)

Definition at line 2707 of file devinst.c.

2710{
2711 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
2712
2713 TRACE("%s(%p %p)\n", __FUNCTION__, DeviceInfoSet, DevInfoData);
2714
2716 {
2718 return FALSE;
2719 }
2720 if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
2721 {
2723 return FALSE;
2724 }
2725 if (!DevInfoData ||
2726 DevInfoData->cbSize != sizeof(SP_DEVINFO_LIST_DETAIL_DATA_W))
2727 {
2729 return FALSE;
2730 }
2731 memcpy(&DevInfoData->ClassGuid, &set->ClassGuid, sizeof(GUID));
2732 DevInfoData->RemoteMachineHandle = set->hMachine;
2733 if (set->MachineName)
2734 strcpyW(DevInfoData->RemoteMachineName, set->MachineName + 2);
2735 else
2736 DevInfoData->RemoteMachineName[0] = 0;
2737
2738 return TRUE;
2739}
WCHAR RemoteMachineName[SP_MAX_MACHINENAME_LENGTH]
Definition: setupapi.h:876

◆ SetupDiGetDeviceInstallParamsA()

BOOL WINAPI SetupDiGetDeviceInstallParamsA ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
PSP_DEVINSTALL_PARAMS_A  DeviceInstallParams 
)

Definition at line 4667 of file devinst.c.

4671{
4672 SP_DEVINSTALL_PARAMS_W deviceInstallParamsW;
4673 BOOL ret = FALSE;
4674
4676
4679 else if (DeviceInstallParams->cbSize != sizeof(SP_DEVINSTALL_PARAMS_A))
4681 else
4682 {
4683 deviceInstallParamsW.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
4685
4686 if (ret)
4687 {
4688 /* Do W->A conversion */
4689 memcpy(
4691 &deviceInstallParamsW,
4693 if (WideCharToMultiByte(CP_ACP, 0, deviceInstallParamsW.DriverPath, -1,
4694 DeviceInstallParams->DriverPath, MAX_PATH, NULL, NULL) == 0)
4695 {
4696 DeviceInstallParams->DriverPath[0] = '\0';
4697 ret = FALSE;
4698 }
4699 }
4700 }
4701
4702 TRACE("Returning %d\n", ret);
4703 return ret;
4704}
WCHAR DriverPath[MAX_PATH]
Definition: setupapi.h:903

◆ SetupDiGetDeviceInstallParamsW()

BOOL WINAPI SetupDiGetDeviceInstallParamsW ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData  OPTIONAL,
OUT PSP_DEVINSTALL_PARAMS_W  DeviceInstallParams 
)

Definition at line 4740 of file devinst.c.

4744{
4745 struct DeviceInfoSet *list;
4746 BOOL ret = FALSE;
4747
4749
4750 if (!DeviceInfoSet)
4754 else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
4756 else if (!DeviceInstallParams)
4758 else if (DeviceInstallParams->cbSize != sizeof(SP_DEVINSTALL_PARAMS_W))
4760 else
4761 {
4763
4764 if (DeviceInfoData)
4765 Source = &((struct DeviceInfo *)DeviceInfoData->Reserved)->InstallParams;
4766 else
4767 Source = &list->InstallParams;
4768
4769 ret = TRUE;
4770
4771 _SEH2_TRY
4772 {
4774 }
4776 {
4778 ret = FALSE;
4779 }
4780 _SEH2_END;
4781 }
4782
4783 TRACE("Returning %d\n", ret);
4784 return ret;
4785}
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:204
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_END
Definition: pseh2_64.h:194
#define _SEH2_TRY
Definition: pseh2_64.h:93
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)

Referenced by BatteryClassInstall(), DisplayDeviceAdvancedProperties(), EnumerateDrivers(), CDeviceNode::GetFlags(), InstallNetDevice(), CDeviceNode::RemoveFlags(), SearchDriver(), CDeviceNode::SetFlags(), SetupDiBuildDriverInfoList(), SetupDiCallClassInstaller(), SetupDiDestroyDriverInfoList(), SetupDiGetDeviceInstallParamsA(), SetupDiGetDriverInstallParamsW(), SetupDiGetSelectedDriverW(), SetupDiInstallClassExW(), SetupDiInstallDevice(), SetupDiInstallDeviceInterfaces(), SetupDiInstallDriverFiles(), SetupDiRegisterCoDeviceInstallers(), SetupDiSetClassInstallParamsW(), SetupInstallFromInfSectionW(), UpdateDevInfo(), and WriteParameterArray().

◆ SetupDiGetDeviceInstanceIdA()

BOOL WINAPI SetupDiGetDeviceInstanceIdA ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
PSTR  DeviceInstanceId,
DWORD  DeviceInstanceIdSize,
PDWORD  RequiredSize 
)

Definition at line 2081 of file devinst.c.

2087{
2088 BOOL ret = FALSE;
2089 DWORD size;
2090 PWSTR instanceId;
2091
2092 TRACE("%s(%p %p %p %d %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData, DeviceInstanceId,
2093 DeviceInstanceIdSize, RequiredSize);
2094
2095 if (!DeviceInstanceId && DeviceInstanceIdSize > 0)
2096 {
2098 return FALSE;
2099 }
2100
2103 NULL,
2104 0,
2105 &size);
2107 return FALSE;
2108 instanceId = MyMalloc(size * sizeof(WCHAR));
2109 if (instanceId)
2110 {
2113 instanceId,
2114 size,
2115 &size);
2116 if (ret)
2117 {
2118 int len = WideCharToMultiByte(CP_ACP, 0, instanceId, -1,
2119 DeviceInstanceId,
2120 DeviceInstanceIdSize, NULL, NULL);
2121
2122 if (!len)
2123 ret = FALSE;
2124 else
2125 {
2126 if (len > DeviceInstanceIdSize)
2127 {
2129 ret = FALSE;
2130 }
2131 if (RequiredSize)
2132 *RequiredSize = len;
2133 }
2134 }
2135 MyFree(instanceId);
2136 }
2137 else
2138 {
2139 if (RequiredSize)
2140 *RequiredSize = size;
2142 ret = FALSE;
2143 }
2144 return ret;
2145}
BOOL WINAPI SetupDiGetDeviceInstanceIdW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PWSTR DeviceInstanceId, DWORD DeviceInstanceIdSize, PDWORD RequiredSize)
Definition: devinst.c:2150

Referenced by check_device_info_(), test_device_info(), and test_get_device_instance_id().

◆ SetupDiGetDeviceInstanceIdW()

BOOL WINAPI SetupDiGetDeviceInstanceIdW ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
PWSTR  DeviceInstanceId,
DWORD  DeviceInstanceIdSize,
PDWORD  RequiredSize 
)

Definition at line 2150 of file devinst.c.

2156{
2157 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
2158 struct DeviceInfo *devInfo;
2159
2160 TRACE("%s(%p %p %p %d %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData, DeviceInstanceId,
2161 DeviceInstanceIdSize, RequiredSize);
2162
2164 {
2166 return FALSE;
2167 }
2168 if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
2169 {
2171 return FALSE;
2172 }
2175 {
2177 return FALSE;
2178 }
2179 devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
2180 if (!DeviceInstanceId && DeviceInstanceIdSize > 0)
2181 {
2183 return FALSE;
2184 }
2185 if (DeviceInstanceId && DeviceInstanceIdSize == 0)
2186 {
2188 return FALSE;
2189 }
2190 TRACE("instance ID: %s\n", debugstr_w(devInfo->instanceId));
2191 if (DeviceInstanceIdSize < lstrlenW(devInfo->instanceId) + 1)
2192 {
2194 if (RequiredSize)
2195 *RequiredSize = lstrlenW(devInfo->instanceId) + 1;
2196 return FALSE;
2197 }
2198 lstrcpyW(DeviceInstanceId, devInfo->instanceId);
2199 if (RequiredSize)
2200 *RequiredSize = lstrlenW(devInfo->instanceId) + 1;
2201 return TRUE;
2202}

Referenced by fill_pnpentity(), GetBootResourceList(), InstallNetDevice(), SetupDiGetDeviceInstanceIdA(), and UpdateDriverForPlugAndPlayDevicesW().

◆ SetupDiGetDeviceInterfaceDetailA()

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 
)

Definition at line 3206 of file devinst.c.

3213{
3214 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
3215 PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailDataW = NULL;
3216 DWORD sizeW = 0, bytesNeeded;
3217 BOOL ret = FALSE;
3218
3219 TRACE("%s(%p, %p, %p, %d, %p, %p)\n", __FUNCTION__, DeviceInfoSet,
3220 DeviceInterfaceData, DeviceInterfaceDetailData,
3221 DeviceInterfaceDetailDataSize, RequiredSize, DeviceInfoData);
3222
3225 {
3227 return FALSE;
3228 }
3229 if (!DeviceInterfaceData ||
3230 DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA) ||
3231 !DeviceInterfaceData->Reserved)
3232 {
3234 return FALSE;
3235 }
3236 if (DeviceInterfaceDetailData && (DeviceInterfaceDetailData->cbSize != sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A)))
3237 {
3239 return FALSE;
3240 }
3241
3242 if((DeviceInterfaceDetailDataSize != 0) &&
3243 (DeviceInterfaceDetailDataSize < (FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath) + sizeof(CHAR))))
3244 {
3246 return FALSE;
3247 }
3248
3249 if (!DeviceInterfaceDetailData && DeviceInterfaceDetailDataSize)
3250 {
3252 return FALSE;
3253 }
3254
3255
3256 if (DeviceInterfaceDetailData != NULL)
3257 {
3259 + (DeviceInterfaceDetailDataSize - FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath)) * sizeof(WCHAR);
3260 DeviceInterfaceDetailDataW = (PSP_DEVICE_INTERFACE_DETAIL_DATA_W)MyMalloc(sizeW);
3261 if (!DeviceInterfaceDetailDataW)
3262 {
3264 }
3265 DeviceInterfaceDetailDataW->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W);
3266 }
3267 if (!DeviceInterfaceDetailData || (DeviceInterfaceDetailData && DeviceInterfaceDetailDataW))
3268 {
3271 DeviceInterfaceData,
3272 DeviceInterfaceDetailDataW,
3273 sizeW,
3274 &sizeW,
3278 if (RequiredSize)
3279 *RequiredSize = bytesNeeded;
3280 if (ret && DeviceInterfaceDetailData && DeviceInterfaceDetailDataSize >= bytesNeeded)
3281 {
3283 CP_ACP, 0,
3284 DeviceInterfaceDetailDataW->DevicePath, -1,
3285 DeviceInterfaceDetailData->DevicePath, DeviceInterfaceDetailDataSize - FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath),
3286 NULL, NULL))
3287 {
3288 ret = FALSE;
3289 }
3290 }
3291 }
3292 MyFree(DeviceInterfaceDetailDataW);
3293
3294 return ret;
3295}
static const WCHAR sizeW[]
Definition: editor.c:79
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)
Definition: devinst.c:3300
_In_ PIOMMU_DEVICE_PATH DevicePath
Definition: haltypes.h:1823
char CHAR
Definition: pedump.c:57
struct _SP_DEVICE_INTERFACE_DETAIL_DATA_W SP_DEVICE_INTERFACE_DETAIL_DATA_W
struct _SP_DEVICE_INTERFACE_DETAIL_DATA_W * PSP_DEVICE_INTERFACE_DETAIL_DATA_W
CHAR DevicePath[ANYSIZE_ARRAY]
Definition: setupapi.h:854
WCHAR DevicePath[ANYSIZE_ARRAY]
Definition: setupapi.h:858

Referenced by check_device_iface_(), test_device_iface(), and test_device_iface_detail().

◆ SetupDiGetDeviceInterfaceDetailW()

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 
)

Definition at line 3300 of file devinst.c.

3307{
3308 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
3309 BOOL ret = FALSE;
3310
3311 TRACE("%s(%p, %p, %p, %d, %p, %p)\n", __FUNCTION__, DeviceInfoSet,
3312 DeviceInterfaceData, DeviceInterfaceDetailData,
3313 DeviceInterfaceDetailDataSize, RequiredSize, DeviceInfoData);
3314
3317 {
3319 return FALSE;
3320 }
3321 if (!DeviceInterfaceData ||
3322 DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA) ||
3323 !DeviceInterfaceData->Reserved)
3324 {
3326 return FALSE;
3327 }
3328 if (DeviceInterfaceDetailData && DeviceInterfaceDetailData->cbSize != sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W))
3329 {
3331 return FALSE;
3332 }
3333 if (!DeviceInterfaceDetailData && DeviceInterfaceDetailDataSize)
3334 {
3336 return FALSE;
3337 }
3339 {
3341 return FALSE;
3342 }
3343 if ((DeviceInterfaceDetailData != NULL)
3344 && (DeviceInterfaceDetailDataSize < (FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_W, DevicePath)) + sizeof(WCHAR)))
3345 {
3347 return FALSE;
3348 }
3349 else
3350 {
3351 struct DeviceInterface *deviceInterface = (struct DeviceInterface *)DeviceInterfaceData->Reserved;
3352 LPCWSTR devName = deviceInterface->SymbolicLink;
3353 DWORD sizeRequired = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W) +
3354 (lstrlenW(devName) + 1) * sizeof(WCHAR);
3355
3356 if (sizeRequired > DeviceInterfaceDetailDataSize)
3357 {
3359 if (RequiredSize)
3360 *RequiredSize = sizeRequired;
3361 }
3362 else
3363 {
3364 strcpyW(DeviceInterfaceDetailData->DevicePath, devName);
3365 TRACE("DevicePath is %s\n", debugstr_w(DeviceInterfaceDetailData->DevicePath));
3366 if (DeviceInfoData)
3367 {
3369 &deviceInterface->DeviceInfo->ClassGuid,
3370 sizeof(GUID));
3371 DeviceInfoData->DevInst = deviceInterface->DeviceInfo->dnDevInst;
3372 DeviceInfoData->Reserved = (ULONG_PTR)deviceInterface->DeviceInfo;
3373 }
3374 ret = TRUE;
3375 }
3376 }
3377 return ret;
3378}
struct DeviceInfo * DeviceInfo

Referenced by BluetoothFindNextRadio(), check_device_path(), Enum(), find_devices(), get_device(), GetDeviceListInterfaces(), InstallSoftwareDeviceInterface(), IsSoftwareBusPnpEnumeratorInstalled(), KsOpenDefaultDevice(), ProcessExistingDevices(), run_for_each_device(), SetupDiGetDeviceInterfaceDetailA(), test_D3DKMTOpenAdapterFromDeviceName_deviface(), test_device_iface_detail(), test_gpu_device_properties_guid(), and WdmAudOpenSoundDeviceByLegacy().

◆ SetupDiGetDeviceRegistryPropertyA()

BOOL WINAPI SetupDiGetDeviceRegistryPropertyA ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
DWORD  Property,
PDWORD  PropertyRegDataType,
PBYTE  PropertyBuffer,
DWORD  PropertyBufferSize,
PDWORD  RequiredSize 
)

Definition at line 3428 of file devinst.c.

3436{
3437 BOOL ret;
3438 BOOL bIsStringProperty;
3439 DWORD RegType;
3440 DWORD RequiredSizeA, RequiredSizeW;
3441 DWORD PropertyBufferSizeW = 0;
3442 PBYTE PropertyBufferW = NULL;
3443
3444 TRACE("%s(%p %p %d %p %p %d %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData,
3446 RequiredSize);
3447
3448 if (PropertyBufferSize != 0)
3449 {
3450 PropertyBufferSizeW = PropertyBufferSize * 2;
3451 PropertyBufferW = HeapAlloc(GetProcessHeap(), 0, PropertyBufferSizeW);
3452 if (!PropertyBufferW)
3453 {
3455 return FALSE;
3456 }
3457 }
3458
3461 Property,
3462 &RegType,
3463 PropertyBufferW,
3464 PropertyBufferSizeW,
3465 &RequiredSizeW);
3466
3468 {
3469 bIsStringProperty = (RegType == REG_SZ || RegType == REG_MULTI_SZ || RegType == REG_EXPAND_SZ);
3470
3471 if (bIsStringProperty)
3472 RequiredSizeA = RequiredSizeW / sizeof(WCHAR);
3473 else
3474 RequiredSizeA = RequiredSizeW;
3475 if (RequiredSize)
3476 *RequiredSize = RequiredSizeA;
3478 *PropertyRegDataType = RegType;
3479 }
3480
3481 if (!ret)
3482 {
3483 HeapFree(GetProcessHeap(), 0, PropertyBufferW);
3484 return ret;
3485 }
3486
3487 if (RequiredSizeA <= PropertyBufferSize)
3488 {
3489 if (bIsStringProperty && PropertyBufferSize > 0)
3490 {
3491 if (WideCharToMultiByte(CP_ACP, 0, (LPWSTR)PropertyBufferW, RequiredSizeW / sizeof(WCHAR), (LPSTR)PropertyBuffer, PropertyBufferSize, NULL, NULL) == 0)
3492 {
3493 /* Last error is already set by WideCharToMultiByte */
3494 ret = FALSE;
3495 }
3496 }
3497 else
3498 memcpy(PropertyBuffer, PropertyBufferW, RequiredSizeA);
3499 }
3500 else
3501 {
3503 ret = FALSE;
3504 }
3505
3506 HeapFree(GetProcessHeap(), 0, PropertyBufferW);
3507 return ret;
3508}
BOOL WINAPI SetupDiGetDeviceRegistryPropertyW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize)
Definition: devinst.c:3513
#define REG_EXPAND_SZ
Definition: nt_native.h:1497
BYTE * PBYTE
Definition: pedump.c:66
char * LPSTR
Definition: typedefs.h:51

Referenced by test_registry_property_a().

◆ SetupDiGetDeviceRegistryPropertyW()

BOOL WINAPI SetupDiGetDeviceRegistryPropertyW ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
DWORD  Property,
PDWORD  PropertyRegDataType,
PBYTE  PropertyBuffer,
DWORD  PropertyBufferSize,
PDWORD  RequiredSize 
)

Definition at line 3513 of file devinst.c.

3521{
3522 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
3523 struct DeviceInfo *devInfo;
3524 CONFIGRET cr;
3525 LONG lError = ERROR_SUCCESS;
3526 DWORD size;
3527
3528 TRACE("%s(%p %p %d %p %p %d %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData,
3530 RequiredSize);
3531
3533 {
3535 return FALSE;
3536 }
3537 if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
3538 {
3540 return FALSE;
3541 }
3544 {
3546 return FALSE;
3547 }
3548
3550 {
3552 return FALSE;
3553 }
3554
3555 devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
3556
3557 if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
3559 {
3560 HKEY hKey;
3562 hKey = SETUPDI_OpenDevKey(set->HKLM, devInfo, KEY_QUERY_VALUE);
3564 return FALSE;
3568
3569 if (RequiredSize)
3570 *RequiredSize = size;
3571
3572 switch (lError)
3573 {
3574 case ERROR_SUCCESS:
3575 if (PropertyBuffer == NULL && size != 0)
3577 break;
3578 case ERROR_MORE_DATA:
3580 break;
3581 default:
3582 break;
3583 }
3584 }
3586 {
3587 size = (strlenW(devInfo->Data) + 1) * sizeof(WCHAR);
3588
3591 if (RequiredSize)
3592 *RequiredSize = size;
3593 if (PropertyBufferSize >= size)
3594 {
3595 strcpyW((LPWSTR)PropertyBuffer, devInfo->Data);
3596 }
3597 else
3599 }
3600 else
3601 {
3603
3608 &size,
3609 0,
3610 set->hMachine);
3611 if ((cr == CR_SUCCESS) || (cr == CR_BUFFER_SMALL))
3612 {
3613 if (RequiredSize)
3614 *RequiredSize = size;
3615 }
3616
3617 if (cr != CR_SUCCESS)
3618 {
3619 switch (cr)
3620 {
3621 case CR_INVALID_DEVINST:
3622 lError = ERROR_NO_SUCH_DEVINST;
3623 break;
3624
3627 break;
3628
3629 case CR_BUFFER_SMALL:
3631 break;
3632
3633 default :
3634 lError = ERROR_INVALID_DATA;
3635 break;
3636 }
3637 }
3638 }
3639
3640 SetLastError(lError);
3641 return (lError == ERROR_SUCCESS);
3642}
#define CR_INVALID_DEVINST
Definition: cfgmgr32.h:848
#define CM_DRP_DEVICEDESC
Definition: cfgmgr32.h:676
CONFIGRET WINAPI CM_Get_DevNode_Registry_Property_ExW(_In_ DEVINST dnDevInst, _In_ ULONG ulProperty, _Out_opt_ PULONG pulRegDataType, _Out_writes_bytes_opt_(*pulLength) PVOID Buffer, _Inout_ PULONG pulLength, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:3572
#define SPDRP_MAXIMUM_PROPERTY
Definition: setupapi.h:545
#define SPDRP_DEVICEDESC
Definition: setupapi.h:510
#define ERROR_INVALID_REG_PROPERTY
Definition: setupapi.h:308
#define ERROR_NO_SUCH_DEVINST
Definition: setupapi.h:310
#define SPDRP_PHYSICAL_DEVICE_OBJECT_NAME
Definition: setupapi.h:524

Referenced by CriticalDeviceCoInstaller(), DevInstallW(), DisplayPageSetDeviceDetails(), CNetConnectionManager::EnumerateINetConnections(), EnumerateNetworkAdapter(), FindNetworkAdapter(), GetHardwareAndCompatibleIDsLists(), InstallDevInstEx(), InstallParallelPort(), InstallSerialPort(), SetDeviceDetails(), SetupDiGetDeviceRegistryPropertyA(), SetupDiInstallDevice(), StorageCoInstaller(), test_registry_property_w(), and UpdateDriverForPlugAndPlayDevicesW().

◆ SetupDiGetSelectedDevice()

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

Definition at line 5192 of file devinst.c.

5195{
5196 struct DeviceInfoSet *list;
5197 BOOL ret = FALSE;
5198
5200
5201 if (!DeviceInfoSet)
5205 else if (list->SelectedDevice == NULL)
5207 else if (!DeviceInfoData)
5209 else if (DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
5211 else
5212 {
5214 &list->SelectedDevice->ClassGuid,
5215 sizeof(GUID));
5216 DeviceInfoData->DevInst = list->SelectedDevice->dnDevInst;
5217 DeviceInfoData->Reserved = (ULONG_PTR)list->SelectedDevice;
5218 ret = TRUE;
5219 }
5220
5221 TRACE("Returning %d\n", ret);
5222 return ret;
5223}
#define ERROR_NO_DEVICE_SELECTED
Definition: setupapi.h:316

◆ SetupDiInstallClassA()

BOOL WINAPI SetupDiInstallClassA ( HWND  hwndParent,
PCSTR  InfFileName,
DWORD  Flags,
HSPFILEQ  FileQueue 
)

Definition at line 3759 of file devinst.c.

3764{
3765 return SetupDiInstallClassExA(hwndParent, InfFileName, Flags, FileQueue, NULL, NULL, NULL);
3766}
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)
Definition: devinst.c:3772

Referenced by test_install_class().

◆ SetupDiInstallClassExA()

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 
)

Definition at line 3772 of file devinst.c.

3780{
3781 PWSTR InfFileNameW = NULL;
3782 BOOL Result;
3783
3784 if (!InfFileName)
3785 {
3787 return FALSE;
3788 }
3789 else
3790 {
3791 InfFileNameW = pSetupMultiByteToUnicode(InfFileName, CP_ACP);
3792 if (InfFileNameW == NULL)
3793 {
3795 return FALSE;
3796 }
3797 }
3798
3801
3802 MyFree(InfFileNameW);
3803
3804 return Result;
3805}
BOOL WINAPI SetupDiInstallClassExW(IN HWND hwndParent OPTIONAL, IN PCWSTR InfFileName OPTIONAL, IN DWORD Flags, IN HSPFILEQ FileQueue OPTIONAL, IN CONST GUID *InterfaceClassGuid OPTIONAL, IN PVOID Reserved1, IN PVOID Reserved2)
Definition: devclass.c:708
@ Reserved2
Definition: sacdrv.h:1470
@ Reserved1
Definition: sacdrv.h:1464
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by SetupDiInstallClassA(), and test_SetupDiInstallClassExA().

◆ SetupDiInstallClassW()

BOOL WINAPI SetupDiInstallClassW ( HWND  hwndParent,
PCWSTR  InfFileName,
DWORD  Flags,
HSPFILEQ  FileQueue 
)

Definition at line 3894 of file devinst.c.

3899{
3900 return SetupDiInstallClassExW(hwndParent, InfFileName, Flags, FileQueue, NULL, NULL, NULL);
3901}

Referenced by InstallSysSetupInfDevices().

◆ SetupDiInstallDevice()

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

Definition at line 5654 of file devinst.c.

5657{
5658 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
5659 struct DeviceInfo *deviceInfo;
5661 struct DriverInfoElement *SelectedDriver;
5663 WCHAR SectionName[MAX_PATH];
5664 WCHAR Buffer[32];
5665 DWORD SectionNameLength = 0;
5666 BOOL Result = FALSE;
5667 ULONG DoAction;
5669 LPWSTR pSectionName = NULL;
5670 WCHAR ClassName[MAX_CLASS_NAME_LEN];
5672 LPWSTR lpGuidString = NULL, lpFullGuidString = NULL;
5673 BOOL RebootRequired = FALSE;
5675 BOOL NeedtoCopyFile;
5676 LARGE_INTEGER fullVersion;
5677 LONG rc;
5678 PVOID Context = NULL;
5679 BOOL ret = FALSE; /* Return value */
5680
5682
5683 if (!DeviceInfoSet)
5687 else if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
5689 else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
5691 else
5692 Result = TRUE;
5693
5694 if (!Result)
5695 {
5696 /* One parameter is bad */
5697 goto cleanup;
5698 }
5699
5700 InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
5702 if (!Result)
5703 goto cleanup;
5704
5705 if (InstallParams.FlagsEx & DI_FLAGSEX_SETFAILEDINSTALL)
5706 {
5707 /* Set FAILEDINSTALL in ConfigFlags registry value */
5708 DWORD ConfigFlags, regType;
5713 &regType,
5714 (PBYTE)&ConfigFlags,
5715 sizeof(ConfigFlags),
5716 NULL);
5717 if (!Result || regType != REG_DWORD)
5718 {
5720 goto cleanup;
5721 }
5722 ConfigFlags |= CONFIGFLAG_FAILEDINSTALL;
5727 (PBYTE)&ConfigFlags,
5728 sizeof(ConfigFlags));
5729 if (!Result)
5730 {
5732 goto cleanup;
5733 }
5734
5735 ret = TRUE;
5736 goto cleanup;
5737 }
5738
5739 SelectedDriver = (struct DriverInfoElement *)InstallParams.ClassInstallReserved;
5740 if (SelectedDriver == NULL)
5741 {
5743 goto cleanup;
5744 }
5745
5746 FileTimeToSystemTime(&SelectedDriver->Info.DriverDate, &DriverDate);
5747
5749 SelectedDriver->InfFileDetails->hInf,
5750 SelectedDriver->Details.SectionName,
5751 SectionName, MAX_PATH, &SectionNameLength, NULL);
5752 if (!Result || SectionNameLength > MAX_PATH - strlenW(DotServices))
5753 goto cleanup;
5754 pSectionName = &SectionName[strlenW(SectionName)];
5755
5756 /* Get information from [Version] section */
5758 goto cleanup;
5759 /* Format ClassGuid to a string */
5760 if (UuidToStringW((UUID*)&ClassGuid, &lpGuidString) != RPC_S_OK)
5761 goto cleanup;
5762 RequiredSize = lstrlenW(lpGuidString);
5763 lpFullGuidString = HeapAlloc(GetProcessHeap(), 0, (RequiredSize + 3) * sizeof(WCHAR));
5764 if (!lpFullGuidString)
5765 {
5767 goto cleanup;
5768 }
5769 lpFullGuidString[0] = '{';
5770 memcpy(&lpFullGuidString[1], lpGuidString, RequiredSize * sizeof(WCHAR));
5771 lpFullGuidString[RequiredSize + 1] = '}';
5772 lpFullGuidString[RequiredSize + 2] = '\0';
5773
5774 /* Copy .inf file to Inf\ directory (if needed) */
5775 Result = InfIsFromOEMLocation(SelectedDriver->Details.InfFileName, &NeedtoCopyFile);
5776 if (!Result)
5777 goto cleanup;
5778 if (NeedtoCopyFile)
5779 {
5780 WCHAR NewFileName[MAX_PATH];
5781 struct InfFileDetails *newInfFileDetails;
5783 SelectedDriver->Details.InfFileName,
5784 NULL,
5785 SPOST_NONE,
5787 NewFileName, MAX_PATH,
5788 NULL,
5789 NULL);
5791 goto cleanup;
5792 /* Create a new struct InfFileDetails, and set it to
5793 * SelectedDriver->InfFileDetails, to release use of
5794 * current InfFile */
5795 newInfFileDetails = CreateInfFileDetails(NewFileName);
5796 if (!newInfFileDetails)
5797 goto cleanup;
5798 DereferenceInfFile(SelectedDriver->InfFileDetails);
5799 SelectedDriver->InfFileDetails = newInfFileDetails;
5800 strcpyW(SelectedDriver->Details.InfFileName, NewFileName);
5801 }
5802
5803 deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
5804
5805 /* Open/Create driver key information */
5806#if _WIN32_WINNT >= 0x502
5807 hKey = SETUPDI_OpenDrvKey(set->HKLM, deviceInfo, KEY_READ | KEY_WRITE);
5808#else
5809 hKey = SETUPDI_OpenDrvKey(set->HKLM, deviceInfo, KEY_ALL_ACCESS);
5810#endif
5812#if _WIN32_WINNT >= 0x502
5814#else
5816#endif
5818 goto cleanup;
5819
5820 /* Install main section */
5821 DoAction = 0;
5823 DoAction |= SPINST_REGISTRY;
5825 {
5826 DoAction |= SPINST_FILES;
5828 if (!Context)
5829 goto cleanup;
5830 }
5831 *pSectionName = '\0';
5833 SelectedDriver->InfFileDetails->hInf, SectionName,
5834 DoAction, hKey, SelectedDriver->InfFileDetails->DirectoryName, SP_COPY_NEWER,
5837 if (!Result)
5838 goto cleanup;
5841
5842 /* Write information to driver key */
5843 *pSectionName = UNICODE_NULL;
5844 memcpy(&fullVersion, &SelectedDriver->Info.DriverVersion, sizeof(LARGE_INTEGER));
5845 TRACE("Write information to driver key\n");
5846 TRACE("DriverDate : '%u-%u-%u'\n", DriverDate.wMonth, DriverDate.wDay, DriverDate.wYear);
5847 TRACE("DriverDesc : '%s'\n", debugstr_w(SelectedDriver->Info.Description));
5848 TRACE("DriverVersion : '%ld.%ld.%lu.%ld'\n", fullVersion.HighPart >> 16, fullVersion.HighPart & 0xffff, fullVersion.LowPart >> 16, fullVersion.LowPart & 0xffff);
5849 TRACE("InfPath : '%s'\n", debugstr_w(SelectedDriver->InfFileDetails->FileName));
5850 TRACE("InfSection : '%s'\n", debugstr_w(SelectedDriver->Details.SectionName));
5851 TRACE("InfSectionExt : '%s'\n", debugstr_w(&SectionName[strlenW(SelectedDriver->Details.SectionName)]));
5852 TRACE("MatchingDeviceId: '%s'\n", debugstr_w(SelectedDriver->MatchingId));
5853 TRACE("ProviderName : '%s'\n", debugstr_w(SelectedDriver->Info.ProviderName));
5854 sprintfW(Buffer, DateFormat, DriverDate.wMonth, DriverDate.wDay, DriverDate.wYear);
5855 rc = RegSetValueExW(hKey, REGSTR_DRIVER_DATE, 0, REG_SZ, (const BYTE *)Buffer, (strlenW(Buffer) + 1) * sizeof(WCHAR));
5856 if (rc == ERROR_SUCCESS)
5857 rc = RegSetValueExW(hKey, REGSTR_DRIVER_DATE_DATA, 0, REG_BINARY, (const BYTE *)&SelectedDriver->Info.DriverDate, sizeof(FILETIME));
5858 if (rc == ERROR_SUCCESS)
5859 rc = RegSetValueExW(hKey, REGSTR_VAL_DRVDESC, 0, REG_SZ, (const BYTE *)SelectedDriver->Info.Description, (strlenW(SelectedDriver->Info.Description) + 1) * sizeof(WCHAR));
5860 if (rc == ERROR_SUCCESS)
5861 {
5862 sprintfW(Buffer, VersionFormat, fullVersion.HighPart >> 16, fullVersion.HighPart & 0xffff, fullVersion.LowPart >> 16, fullVersion.LowPart & 0xffff);
5863 rc = RegSetValueExW(hKey, REGSTR_DRIVER_VERSION, 0, REG_SZ, (const BYTE *)Buffer, (strlenW(Buffer) + 1) * sizeof(WCHAR));
5864 }
5865 if (rc == ERROR_SUCCESS)
5866 rc = RegSetValueExW(hKey, REGSTR_VAL_INFPATH, 0, REG_SZ, (const BYTE *)SelectedDriver->InfFileDetails->FileName, (strlenW(SelectedDriver->InfFileDetails->FileName) + 1) * sizeof(WCHAR));
5867 if (rc == ERROR_SUCCESS)
5868 rc = RegSetValueExW(hKey, REGSTR_VAL_INFSECTION, 0, REG_SZ, (const BYTE *)SelectedDriver->Details.SectionName, (strlenW(SelectedDriver->Details.SectionName) + 1) * sizeof(WCHAR));
5869 if (rc == ERROR_SUCCESS)
5870 rc = RegSetValueExW(hKey, REGSTR_VAL_INFSECTIONEXT, 0, REG_SZ, (const BYTE *)&SectionName[strlenW(SelectedDriver->Details.SectionName)], (strlenW(SectionName) - strlenW(SelectedDriver->Details.SectionName) + 1) * sizeof(WCHAR));
5871 if (rc == ERROR_SUCCESS)
5872 rc = RegSetValueExW(hKey, REGSTR_VAL_MATCHINGDEVID, 0, REG_SZ, (const BYTE *)SelectedDriver->MatchingId, (strlenW(SelectedDriver->MatchingId) + 1) * sizeof(WCHAR));
5873 if (rc == ERROR_SUCCESS)
5874 rc = RegSetValueExW(hKey, REGSTR_VAL_PROVIDER_NAME, 0, REG_SZ, (const BYTE *)SelectedDriver->Info.ProviderName, (strlenW(SelectedDriver->Info.ProviderName) + 1) * sizeof(WCHAR));
5875 if (rc != ERROR_SUCCESS)
5876 {
5877 SetLastError(rc);
5878 goto cleanup;
5879 }
5882
5883 /* FIXME: Process .LogConfigOverride section */
5884
5885 /* Install .Services section */
5886 strcpyW(pSectionName, DotServices);
5888 SelectedDriver->InfFileDetails->hInf,
5889 SectionName,
5890 0,
5893 NULL,
5894 NULL);
5895 if (!Result)
5896 {
5898 goto cleanup;
5900 }
5902 RebootRequired = TRUE;
5903
5904 /* Open device registry key */
5907 goto cleanup;
5908
5909 /* Install .HW section */
5910 DoAction = 0;
5912 DoAction |= SPINST_REGISTRY;
5913 strcpyW(pSectionName, DotHW);
5915 SelectedDriver->InfFileDetails->hInf, SectionName,
5916 DoAction, hKey, NULL, 0,
5917 NULL, NULL,
5919 if (!Result)
5920 goto cleanup;
5921
5922 /* Write information to enum key */
5923 TRACE("Write information to enum key\n");
5924 TRACE("Class : '%s'\n", debugstr_w(ClassName));
5925 TRACE("ClassGUID : '%s'\n", debugstr_w(lpFullGuidString));
5926 TRACE("DeviceDesc : '%s'\n", debugstr_w(SelectedDriver->Info.Description));
5927 TRACE("Mfg : '%s'\n", debugstr_w(SelectedDriver->Info.MfgName));
5928 rc = RegSetValueExW(hKey, REGSTR_VAL_CLASS, 0, REG_SZ, (const BYTE *)ClassName, (strlenW(ClassName) + 1) * sizeof(WCHAR));
5929 if (rc == ERROR_SUCCESS)
5930 rc = RegSetValueExW(hKey, REGSTR_VAL_CLASSGUID, 0, REG_SZ, (const BYTE *)lpFullGuidString, (strlenW(lpFullGuidString) + 1) * sizeof(WCHAR));
5931 if (rc == ERROR_SUCCESS)
5932 rc = RegSetValueExW(hKey, REGSTR_VAL_DEVDESC, 0, REG_SZ, (const BYTE *)SelectedDriver->Info.Description, (strlenW(SelectedDriver->Info.Description) + 1) * sizeof(WCHAR));
5933 if (rc == ERROR_SUCCESS)
5934 rc = RegSetValueExW(hKey, REGSTR_VAL_MFG, 0, REG_SZ, (const BYTE *)SelectedDriver->Info.MfgName, (strlenW(SelectedDriver->Info.MfgName) + 1) * sizeof(WCHAR));
5935 if (rc != ERROR_SUCCESS)
5936 {
5937 SetLastError(rc);
5938 goto cleanup;
5939 }
5940
5941 /* Start the device */
5942 if (!RebootRequired && !(InstallParams.Flags & (DI_NEEDRESTART | DI_NEEDREBOOT | DI_DONOTCALLCONFIGMG)))
5944 else
5945 ret = TRUE;
5946
5947cleanup:
5948 /* End of installation */
5951 if (lpGuidString)
5952 RpcStringFreeW(&lpGuidString);
5953 HeapFree(GetProcessHeap(), 0, lpFullGuidString);
5954 if (Context)
5956 TRACE("Returning %d\n", ret);
5957 return ret;
5958}
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:183
static BOOL InfIsFromOEMLocation(IN PCWSTR FullName, OUT LPBOOL IsOEMLocation)
Definition: devinst.c:5600
static const WCHAR DateFormat[]
Definition: devinst.c:28
static const WCHAR DotServices[]
Definition: devinst.c:31
static const WCHAR REGSTR_DRIVER_VERSION[]
Definition: devinst.c:39
BOOL WINAPI SetupDiGetActualSectionToInstallW(HINF InfHandle, PCWSTR InfSectionName, PWSTR InfSectionWithExt, DWORD InfSectionWithExtSize, PDWORD RequiredSize, PWSTR *Extension)
Definition: devinst.c:2223
static const WCHAR REGSTR_DRIVER_DATE[]
Definition: devinst.c:37
BOOL WINAPI SetupDiSetDeviceRegistryPropertyW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, const BYTE *PropertyBuffer, DWORD PropertyBufferSize)
Definition: devinst.c:3741
static const WCHAR VersionFormat[]
Definition: devinst.c:35
static const WCHAR REGSTR_DRIVER_DATE_DATA[]
Definition: devinst.c:38
static const WCHAR DotHW[]
Definition: devinst.c:30
struct InfFileDetails * CreateInfFileDetails(IN LPCWSTR FullInfFileName)
Definition: driver.c:55
VOID DereferenceInfFile(struct InfFileDetails *infFile)
Definition: driver.c:45
BOOL WINAPI SetupCopyOEMInfW(IN PCWSTR SourceInfFileName, IN PCWSTR OEMSourceMediaLocation, IN DWORD OEMSourceMediaType, IN DWORD CopyStyle, OUT PWSTR DestinationInfFileName OPTIONAL, IN DWORD DestinationInfFileNameSize, OUT PDWORD RequiredSize OPTIONAL, OUT PWSTR *DestinationInfFileNameComponent OPTIONAL)
Definition: install.c:2375
BOOL WINAPI SetupInstallServicesFromInfSectionExW(_In_ HINF InfHandle, _In_ PCWSTR SectionName, _In_ DWORD Flags, _In_opt_ HDEVINFO DeviceInfoSet, _In_opt_ PSP_DEVINFO_DATA DeviceInfoData, _Reserved_ PVOID Reserved1, _Reserved_ PVOID Reserved2)
Definition: install.c:2118
BOOL WINAPI SetupDiGetINFClassW(IN PCWSTR InfName, OUT LPGUID ClassGuid, OUT PWSTR ClassName, IN DWORD ClassNameSize, OUT PDWORD RequiredSize OPTIONAL)
Definition: parser.c:2334
UINT WINAPI SetupDefaultQueueCallbackW(PVOID context, UINT notification, UINT_PTR param1, UINT_PTR param2)
Definition: queue.c:1729
void WINAPI SetupTermDefaultQueueCallback(PVOID context)
Definition: queue.c:1656
PVOID WINAPI SetupInitDefaultQueueCallback(HWND owner)
Definition: queue.c:1629
#define REG_BINARY
Definition: nt_native.h:1499
#define REGSTR_VAL_DRVDESC
Definition: regstr.h:428
#define REGSTR_VAL_INFPATH
Definition: regstr.h:439
#define REGSTR_VAL_DEVDESC
Definition: regstr.h:292
#define REGSTR_VAL_INFSECTIONEXT
Definition: regstr.h:441
#define CONFIGFLAG_FAILEDINSTALL
Definition: regstr.h:396
#define REGSTR_VAL_MATCHINGDEVID
Definition: regstr.h:442
#define REGSTR_VAL_INFSECTION
Definition: regstr.h:440
#define REGSTR_VAL_PROVIDER_NAME
Definition: regstr.h:540
#define REGSTR_VAL_MFG
Definition: regstr.h:306
#define SP_COPY_NOOVERWRITE
Definition: setupapi.h:483
#define SPOST_NONE
Definition: setupapi.h:612
#define DI_FLAGSEX_SETFAILEDINSTALL
Definition: setupapi.h:85
#define ERROR_SECTION_NOT_FOUND
Definition: setupapi.h:296
#define ERROR_NO_DRIVER_SELECTED
Definition: setupapi.h:302
#define SPDRP_CONFIGFLAGS
Definition: setupapi.h:520
#define SP_COPY_NEWER
Definition: setupapi.h:481
struct InfFileDetails * InfFileDetails
SP_DRVINFO_DETAIL_DATA_W Details
SP_DRVINFO_DATA_V2_W Info
ULARGE_INTEGER DriverDate
ULONG_PTR ClassInstallReserved
Definition: setupapi.h:901
WCHAR ProviderName[LINE_LEN]
Definition: setupapi.h:1021
WCHAR MfgName[LINE_LEN]
Definition: setupapi.h:1020
DWORDLONG DriverVersion
Definition: setupapi.h:1023
WCHAR Description[LINE_LEN]
Definition: setupapi.h:1019
WCHAR SectionName[LINE_LEN]
Definition: setupapi.h:1079
WCHAR InfFileName[MAX_PATH]
Definition: setupapi.h:1080
uint32_t ULONG
Definition: typedefs.h:59
ULONG LowPart
Definition: typedefs.h:106
#define ERROR_FILE_EXISTS
Definition: winerror.h:287
#define ERROR_SUCCESS_REBOOT_REQUIRED
Definition: winerror.h:1580

Referenced by DisplayClassInstaller(), InstallCompositeBattery(), InstallNetDevice(), InstallParallelPort(), InstallSerialPort(), and SetupDiCallClassInstaller().

◆ SetupDiOpenClassRegKey()

HKEY WINAPI SetupDiOpenClassRegKey ( const GUID ClassGuid,
REGSAM  samDesired 
)

Definition at line 3907 of file devinst.c.

3910{
3911 return SetupDiOpenClassRegKeyExW(ClassGuid, samDesired,
3913}

Referenced by DisplayClassProperties(), SETUP_GetClassIconInfo(), SetupDiCallClassInstaller(), START_TEST(), and test_open_class_key().

◆ SetupDiOpenClassRegKeyExA()

HKEY WINAPI SetupDiOpenClassRegKeyExA ( const GUID ClassGuid,
REGSAM  samDesired,
DWORD  Flags,
PCSTR  MachineName,
PVOID  Reserved 
)

Definition at line 3919 of file devinst.c.

3925{
3926 PWSTR MachineNameW = NULL;
3927 HKEY hKey;
3928
3929 TRACE("%s(%s 0x%lx 0x%lx %s %p)\n", __FUNCTION__, debugstr_guid(ClassGuid), samDesired,
3931
3932 if (MachineName)
3933 {
3935 if (MachineNameW == NULL)
3936 return INVALID_HANDLE_VALUE;
3937 }
3938
3939 hKey = SetupDiOpenClassRegKeyExW(ClassGuid, samDesired,
3940 Flags, MachineNameW, Reserved);
3941
3942 MyFree(MachineNameW);
3943
3944 return hKey;
3945}

Referenced by test_open_class_key(), and test_SetupDiOpenClassRegKeyExA().

◆ SetupDiOpenClassRegKeyExW()

HKEY WINAPI SetupDiOpenClassRegKeyExW ( const GUID ClassGuid,
REGSAM  samDesired,
DWORD  Flags,
PCWSTR  MachineName,
PVOID  Reserved 
)

Definition at line 3951 of file devinst.c.

3957{
3958 HKEY HKLM;
3959 HKEY hClassesKey;
3960 HKEY key;
3961 LPCWSTR lpKeyName;
3962 LONG l;
3963
3964 TRACE("%s(%s 0x%lx 0x%lx %s %p)\n", __FUNCTION__, debugstr_guid(ClassGuid), samDesired,
3966
3967 if (MachineName != NULL)
3968 {
3970 if (l != ERROR_SUCCESS)
3971 {
3972 SetLastError(l);
3973 return INVALID_HANDLE_VALUE;
3974 }
3975 }
3976 else
3978
3979 if (Flags == DIOCR_INSTALLER)
3980 {
3981 lpKeyName = REGSTR_PATH_CLASS_NT;
3982 }
3983 else if (Flags == DIOCR_INTERFACE)
3984 {
3985 lpKeyName = REGSTR_PATH_DEVICE_CLASSES;
3986 }
3987 else
3988 {
3989 ERR("Invalid Flags parameter!\n");
3992 return INVALID_HANDLE_VALUE;
3993 }
3994
3995 if (!ClassGuid)
3996 {
3997 if ((l = RegOpenKeyExW(HKLM,
3998 lpKeyName,
3999 0,
4000 samDesired,
4001 &hClassesKey)))
4002 {
4004 hClassesKey = INVALID_HANDLE_VALUE;
4005 }
4006 if (MachineName != NULL)
4008 key = hClassesKey;
4009 }
4010 else
4011 {
4012 WCHAR bracedGuidString[39];
4013
4014 SETUPDI_GuidToString(ClassGuid, bracedGuidString);
4015
4016 if (!(l = RegOpenKeyExW(HKLM,
4017 lpKeyName,
4018 0,
4019 samDesired,
4020 &hClassesKey)))
4021 {
4022 if (MachineName != NULL)
4024
4025 if ((l = RegOpenKeyExW(hClassesKey,
4026 bracedGuidString,
4027 0,
4028 samDesired,
4029 &key)))
4030 {
4031 SetLastError(l);
4033 }
4034 RegCloseKey(hClassesKey);
4035 }
4036 else
4037 {
4039 SetLastError(l);
4041 }
4042 }
4043
4044 return key;
4045}
#define REGSTR_PATH_DEVICE_CLASSES
Definition: regstr.h:481

Referenced by SETUP_CreateInterfaceList(), SetupDiClassGuidsFromNameExW(), SetupDiClassNameFromGuidExW(), SetupDiCreateDeviceInterfaceRegKeyW(), SetupDiGetClassDescriptionExW(), SetupDiGetClassDevPropertySheetsW(), SetupDiInstallClassExW(), SetupDiOpenClassRegKey(), SetupDiOpenClassRegKeyExA(), SetupDiOpenDeviceInterfaceRegKey(), SetupDiOpenDeviceInterfaceW(), and CClassNode::SetupNode().

◆ SetupDiOpenDeviceInfoA()

BOOL WINAPI SetupDiOpenDeviceInfoA ( IN HDEVINFO  DeviceInfoSet,
IN PCSTR  DeviceInstanceId,
IN HWND hwndParent  OPTIONAL,
IN DWORD  OpenFlags,
OUT PSP_DEVINFO_DATA DeviceInfoData  OPTIONAL 
)

Definition at line 5034 of file devinst.c.

5040{
5041 LPWSTR DeviceInstanceIdW = NULL;
5042 BOOL bResult;
5043
5044 TRACE("%s(%p %s %p %lx %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInstanceId, hwndParent, OpenFlags, DeviceInfoData);
5045
5046 DeviceInstanceIdW = pSetupMultiByteToUnicode(DeviceInstanceId, CP_ACP);
5047 if (DeviceInstanceIdW == NULL)
5048 return FALSE;
5049
5051 DeviceInstanceIdW, hwndParent, OpenFlags, DeviceInfoData);
5052
5053 MyFree(DeviceInstanceIdW);
5054
5055 return bResult;
5056}
BOOL WINAPI SetupDiOpenDeviceInfoW(IN HDEVINFO DeviceInfoSet, IN PCWSTR DeviceInstanceId, IN HWND hwndParent OPTIONAL, IN DWORD OpenFlags, OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
Definition: devinst.c:5063

◆ SetupDiOpenDeviceInfoW()

BOOL WINAPI SetupDiOpenDeviceInfoW ( IN HDEVINFO  DeviceInfoSet,
IN PCWSTR  DeviceInstanceId,
IN HWND hwndParent  OPTIONAL,
IN DWORD  OpenFlags,
OUT PSP_DEVINFO_DATA DeviceInfoData  OPTIONAL 
)

Definition at line 5063 of file devinst.c.

5069{
5070 struct DeviceInfoSet *list;
5072 DWORD rc, dwSize;
5073 BOOL ret = FALSE;
5074
5075 TRACE("%s(%p %s %p %lx %p)\n", __FUNCTION__,
5076 DeviceInfoSet, debugstr_w(DeviceInstanceId),
5077 hwndParent, OpenFlags, DeviceInfoData);
5078
5079 if (OpenFlags & DIOD_CANCEL_REMOVE)
5080 FIXME("DIOD_CANCEL_REMOVE flag not implemented\n");
5081
5082 if (!DeviceInfoSet)
5086 else if (!DeviceInstanceId)
5088 else if (OpenFlags & ~(DIOD_CANCEL_REMOVE | DIOD_INHERIT_CLASSDRVS))
5089 {
5090 TRACE("Unknown flags: 0x%08lx\n", OpenFlags & ~(DIOD_CANCEL_REMOVE | DIOD_INHERIT_CLASSDRVS));
5092 }
5093 else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
5095 else
5096 {
5097 struct DeviceInfo *deviceInfo = NULL;
5098 /* Search if device already exists in DeviceInfoSet.
5099 * If yes, return the existing element
5100 * If no, create a new element using information in registry
5101 */
5102 PLIST_ENTRY ItemList = list->ListHead.Flink;
5103 while (ItemList != &list->ListHead)
5104 {
5105 deviceInfo = CONTAINING_RECORD(ItemList, struct DeviceInfo, ListEntry);
5106 if (!wcscmp(deviceInfo->instanceId, DeviceInstanceId))
5107 break;
5108 deviceInfo = NULL;
5109 ItemList = ItemList->Flink;
5110 }
5111
5112 if (deviceInfo)
5113 {
5114 /* good one found */
5115 ret = TRUE;
5116 }
5117 else
5118 {
5120 WCHAR szClassGuid[MAX_GUID_STRING_LEN];
5121
5122 /* Open supposed registry key */
5123 rc = RegOpenKeyExW(
5124 list->HKLM,
5126 0, /* Options */
5128 &hEnumKey);
5129 if (rc != ERROR_SUCCESS)
5130 {
5131 SetLastError(rc);
5132 goto cleanup;
5133 }
5134 rc = RegOpenKeyExW(
5135 hEnumKey,
5136 DeviceInstanceId,
5137 0, /* Options */
5139 &hKey);
5141 if (rc != ERROR_SUCCESS)
5142 {
5143 if (rc == ERROR_FILE_NOT_FOUND)
5145 SetLastError(rc);
5146 goto cleanup;
5147 }
5148
5150 dwSize = MAX_GUID_STRING_LEN * sizeof(WCHAR);
5151
5154 NULL,
5155 NULL,
5156 (LPBYTE)szClassGuid,
5157 &dwSize) == ERROR_SUCCESS)
5158 {
5159 szClassGuid[MAX_GUID_STRING_LEN - 2] = UNICODE_NULL;
5160
5161 /* Convert a string to a ClassGuid */
5162 UuidFromStringW(&szClassGuid[1], &ClassGUID);
5163 }
5164
5165 if (!CreateDeviceInfo(list, DeviceInstanceId, &ClassGUID, &deviceInfo))
5166 goto cleanup;
5167
5168 InsertTailList(&list->ListHead, &deviceInfo->ListEntry);
5169
5170 ret = TRUE;
5171 }
5172
5173 if (ret && deviceInfo && DeviceInfoData)
5174 {
5175 memcpy(&DeviceInfoData->ClassGuid, &deviceInfo->ClassGuid, sizeof(GUID));
5176 DeviceInfoData->DevInst = deviceInfo->dnDevInst;
5177 DeviceInfoData->Reserved = (ULONG_PTR)deviceInfo;
5178 }
5179 }
5180
5181cleanup:
5182 if (hKey != NULL)
5184 return ret;
5185}
#define MAX_GUID_STRING_LEN
Definition: apphelp.c:29
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
static const WCHAR ClassGUID[]
Definition: devclass.c:30
#define DIOD_INHERIT_CLASSDRVS
Definition: setupapi.h:182
#define DIOD_CANCEL_REMOVE
Definition: setupapi.h:183

Referenced by DevInstallW(), InstallDevInstEx(), SetupDiOpenDeviceInfoA(), and CDeviceNode::SetupNode().

◆ SetupDiOpenDeviceInterfaceA()

BOOL WINAPI SetupDiOpenDeviceInterfaceA ( HDEVINFO  DeviceInfoSet,
PCSTR  DevicePath,
DWORD  OpenFlags,
PSP_DEVICE_INTERFACE_DATA  DeviceInterfaceData 
)

Definition at line 4265 of file devinst.c.

4270{
4271 LPWSTR DevicePathW = NULL;
4272 BOOL bResult;
4273
4274 TRACE("%s(%p %s %08lx %p)\n", __FUNCTION__, DeviceInfoSet, debugstr_a(DevicePath), OpenFlags, DeviceInterfaceData);
4275
4277 if (DevicePathW == NULL)
4278 return FALSE;
4279
4281 DevicePathW, OpenFlags, DeviceInterfaceData);
4282
4283 MyFree(DevicePathW);
4284
4285 return bResult;
4286}
BOOL WINAPI SetupDiOpenDeviceInterfaceW(HDEVINFO DeviceInfoSet, PCWSTR DevicePath, DWORD OpenFlags, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
Definition: devinst.c:4050

◆ SetupDiOpenDeviceInterfaceW()

BOOL WINAPI SetupDiOpenDeviceInterfaceW ( HDEVINFO  DeviceInfoSet,
PCWSTR  DevicePath,
DWORD  OpenFlags,
PSP_DEVICE_INTERFACE_DATA  DeviceInterfaceData 
)

Definition at line 4050 of file devinst.c.

4055{
4056 struct DeviceInfoSet * list;
4057 PCWSTR pEnd;
4058 DWORD dwLength, dwError, dwIndex, dwKeyName, dwSubIndex;
4059 CLSID ClassId;
4060 WCHAR Buffer[MAX_PATH + 1];
4061 WCHAR SymBuffer[MAX_PATH + 1];
4062 WCHAR InstancePath[MAX_PATH + 1];
4063 HKEY hKey, hDevKey, hSymKey;
4064 struct DeviceInfo * deviceInfo;
4065 struct DeviceInterface *deviceInterface;
4066 BOOL Ret;
4067 PLIST_ENTRY ItemList;
4068 PLIST_ENTRY InterfaceListEntry;
4069
4070 TRACE("%s(%p %s %08x %p)\n", __FUNCTION__,
4071 DeviceInfoSet, debugstr_w(DevicePath), OpenFlags, DeviceInterfaceData);
4072
4073
4074 if (DeviceInterfaceData && DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA))
4075 {
4077 return FALSE;
4078 }
4079
4081 {
4083 return FALSE;
4084 }
4085
4086 list = (struct DeviceInfoSet * )DeviceInfoSet;
4087
4089 if (dwLength < 39)
4090 {
4091 /* path must be at least a guid length + L'\0' */
4093 return FALSE;
4094 }
4095
4096 if (DevicePath[0] != L'\\' ||
4097 DevicePath[1] != L'\\' ||
4098 (DevicePath[2] != L'?' && DevicePath[2] != L'.') ||
4099 DevicePath[3] != L'\\')
4100 {
4101 /* invalid formatted path */
4103 return FALSE;
4104 }
4105
4106 /* check for reference strings */
4107 pEnd = wcschr(&DevicePath[4], L'\\');
4108 if (!pEnd)
4109 {
4110 /* no reference string */
4111 pEnd = DevicePath + dwLength;
4112 }
4113
4114 /* copy guid */
4115 wcscpy(Buffer, pEnd - 37);
4116 Buffer[36] = L'\0';
4117
4118 dwError = UuidFromStringW(Buffer, &ClassId);
4119 if (dwError != NOERROR)
4120 {
4121 /* invalid formatted path */
4123 return FALSE;
4124 }
4125
4126 hKey = SetupDiOpenClassRegKeyExW(&ClassId, KEY_READ, DIOCR_INTERFACE, list->MachineName, NULL);
4127
4129 {
4130 /* invalid device class */
4131 return FALSE;
4132 }
4133
4134 ItemList = list->ListHead.Flink;
4135 while (ItemList != &list->ListHead)
4136 {
4137 deviceInfo = CONTAINING_RECORD(ItemList, struct DeviceInfo, ListEntry);
4138 InterfaceListEntry = deviceInfo->InterfaceListHead.Flink;
4139 while (InterfaceListEntry != &deviceInfo->InterfaceListHead)
4140 {
4141 deviceInterface = CONTAINING_RECORD(InterfaceListEntry, struct DeviceInterface, ListEntry);
4142 if (!IsEqualIID(&deviceInterface->InterfaceClassGuid, &ClassId))
4143 {
4144 InterfaceListEntry = InterfaceListEntry->Flink;
4145 continue;
4146 }
4147
4148 if (!wcsicmp(deviceInterface->SymbolicLink, DevicePath))
4149 {
4150 if (DeviceInterfaceData)
4151 {
4152 DeviceInterfaceData->Reserved = (ULONG_PTR)deviceInterface;
4153 DeviceInterfaceData->Flags = deviceInterface->Flags;
4154 CopyMemory(&DeviceInterfaceData->InterfaceClassGuid, &ClassId, sizeof(GUID));
4155 }
4156
4157 return TRUE;
4158 }
4159
4160 }
4161 }
4162
4163
4164 dwIndex = 0;
4165 do
4166 {
4167 Buffer[0] = 0;
4168 dwKeyName = sizeof(Buffer) / sizeof(WCHAR);
4169 dwError = RegEnumKeyExW(hKey, dwIndex, Buffer, &dwKeyName, NULL, NULL, NULL, NULL);
4170
4171 if (dwError != ERROR_SUCCESS)
4172 break;
4173
4174 if (RegOpenKeyExW(hKey, Buffer, 0, KEY_READ, &hDevKey) != ERROR_SUCCESS)
4175 break;
4176
4177 dwSubIndex = 0;
4178 InstancePath[0] = 0;
4179 dwKeyName = sizeof(InstancePath);
4180
4181 dwError = RegQueryValueExW(hDevKey, L"DeviceInstance", NULL, NULL, (LPBYTE)InstancePath, &dwKeyName);
4182
4183 while(TRUE)
4184 {
4185 Buffer[0] = 0;
4186 dwKeyName = sizeof(Buffer) / sizeof(WCHAR);
4187 dwError = RegEnumKeyExW(hDevKey, dwSubIndex, Buffer, &dwKeyName, NULL, NULL, NULL, NULL);
4188
4189 if (dwError != ERROR_SUCCESS)
4190 break;
4191
4192 dwError = RegOpenKeyExW(hDevKey, Buffer, 0, KEY_READ, &hSymKey);
4193 if (dwError != ERROR_SUCCESS)
4194 break;
4195
4196 /* query for symbolic link */
4197 dwKeyName = sizeof(SymBuffer);
4198 SymBuffer[0] = L'\0';
4199 dwError = RegQueryValueExW(hSymKey, L"SymbolicLink", NULL, NULL, (LPBYTE)SymBuffer, &dwKeyName);
4200
4201 if (dwError != ERROR_SUCCESS)
4202 {
4203 RegCloseKey(hSymKey);
4204 break;
4205 }
4206
4207 if (!wcsicmp(SymBuffer, DevicePath))
4208 {
4209 Ret = CreateDeviceInfo(list, InstancePath, &ClassId, &deviceInfo);
4210 RegCloseKey(hSymKey);
4211 RegCloseKey(hDevKey);
4213
4214 if (Ret)
4215 {
4216 deviceInterface = HeapAlloc(GetProcessHeap(), 0, sizeof(struct DeviceInterface) + (wcslen(SymBuffer) + 1) * sizeof(WCHAR));
4217 if (deviceInterface)
4218 {
4219
4220 CopyMemory(&deviceInterface->InterfaceClassGuid, &ClassId, sizeof(GUID));
4221 deviceInterface->DeviceInfo = deviceInfo;
4222 deviceInterface->Flags = SPINT_ACTIVE; //FIXME
4223
4224 wcscpy(deviceInterface->SymbolicLink, SymBuffer);
4225
4226 InsertTailList(&deviceInfo->InterfaceListHead, &deviceInterface->ListEntry);
4227 InsertTailList(&list->ListHead, &deviceInfo->ListEntry);
4228
4229
4230 if (DeviceInterfaceData)
4231 {
4232 DeviceInterfaceData->Reserved = (ULONG_PTR)deviceInterface;
4233 DeviceInterfaceData->Flags = deviceInterface->Flags;
4234 CopyMemory(&DeviceInterfaceData->InterfaceClassGuid, &ClassId, sizeof(GUID));
4235 }
4236 else
4237 {
4238 Ret = FALSE;
4240 }
4241 }
4242 }
4243 else
4244 {
4245 HeapFree(GetProcessHeap(), 0, deviceInfo);
4246 Ret = FALSE;
4247 }
4248 return Ret;
4249 }
4250 RegCloseKey(hSymKey);
4251 dwSubIndex++;
4252 }
4253
4254 RegCloseKey(hDevKey);
4255 dwIndex++;
4256 } while(TRUE);
4257
4259 return FALSE;
4260}
#define wcsicmp
Definition: compat.h:15
#define CopyMemory
Definition: minwinbase.h:29
#define SPINT_ACTIVE
Definition: setupapi.h:585
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define ERROR_BAD_PATHNAME
Definition: winerror.h:355
#define NOERROR
Definition: winerror.h:3448

Referenced by CKsProxy::Load(), and SetupDiOpenDeviceInterfaceA().

◆ SetupDiOpenDevRegKey()

HKEY WINAPI SetupDiOpenDevRegKey ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
DWORD  Scope,
DWORD  HwProfile,
DWORD  KeyType,
REGSAM  samDesired 
)

Definition at line 6223 of file devinst.c.

6230{
6232 struct DeviceInfo *devInfo;
6234 HKEY RootKey;
6235
6236 TRACE("%s(%p %p %d %d %d %x)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData,
6237 Scope, HwProfile, KeyType, samDesired);
6238
6240 {
6242 return INVALID_HANDLE_VALUE;
6243 }
6244 if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
6245 {
6247 return INVALID_HANDLE_VALUE;
6248 }
6251 {
6253 return INVALID_HANDLE_VALUE;
6254 }
6255 if (Scope != DICS_FLAG_GLOBAL && Scope != DICS_FLAG_CONFIGSPECIFIC)
6256 {
6258 return INVALID_HANDLE_VALUE;
6259 }
6260 if (KeyType != DIREG_DEV && KeyType != DIREG_DRV)
6261 {
6263 return INVALID_HANDLE_VALUE;
6264 }
6265 devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
6266 if (devInfo->set != set)
6267 {
6269 return INVALID_HANDLE_VALUE;
6270 }
6271 if (Scope != DICS_FLAG_GLOBAL)
6272 {
6273 RootKey = OpenHardwareProfileKey(set->HKLM, HwProfile, 0);
6275 return INVALID_HANDLE_VALUE;
6276 }
6277 else
6278 RootKey = set->HKLM;
6279 switch (KeyType)
6280 {
6281 case DIREG_DEV:
6282 key = SETUPDI_OpenDevKey(RootKey, devInfo, samDesired);
6283 if (Scope == DICS_FLAG_GLOBAL)
6284 {
6285 LONG rc;
6286 HKEY hTempKey = key;
6287 rc = RegOpenKeyExW(hTempKey,
6288 L"Device Parameters",
6289 0,
6290 samDesired,
6291 &key);
6292 if (rc == ERROR_SUCCESS)
6293 RegCloseKey(hTempKey);
6294 }
6295 break;
6296 case DIREG_DRV:
6297 key = SETUPDI_OpenDrvKey(RootKey, devInfo, samDesired);
6298 break;
6299 default:
6300 WARN("unknown KeyType %d\n", KeyType);
6301 }
6302 if (RootKey != set->HKLM)
6304 return key;
6305}

Referenced by BuildParameterArray(), ChangePortNumber(), CriticalDeviceCoInstaller(), DisplayClassInstaller(), DisplayDeviceCoinstallers(), DisplayMatchingDeviceId(), FindCurrentDriver(), GetDeviceLocationString(), GetDriverDateString(), GetDriverProviderString(), GetDriverVersionString(), InstallNetDevice(), OpenDeviceKey(), PS2MousePropPageProvider(), ReadPortSettings(), RemovePort(), test_device_key(), WriteParameterArray(), and WritePortSettings().

◆ SetupDiRegisterCoDeviceInstallers()

BOOL WINAPI SetupDiRegisterCoDeviceInstallers ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA  DeviceInfoData 
)

Definition at line 5500 of file devinst.c.

5503{
5504 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
5505 struct DeviceInfo *deviceInfo;
5506 BOOL ret = FALSE; /* Return value */
5507
5509
5510 if (!DeviceInfoSet)
5514 else if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
5516 else if (!DeviceInfoData)
5518 else if (DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
5520 else
5521 {
5523 struct DriverInfoElement *SelectedDriver;
5524 BOOL Result;
5525 DWORD DoAction;
5526 WCHAR SectionName[MAX_PATH];
5527 DWORD SectionNameLength = 0;
5529 PVOID Context = NULL;
5530
5531 InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
5533 if (!Result)
5534 goto cleanup;
5535
5536 SelectedDriver = (struct DriverInfoElement *)InstallParams.ClassInstallReserved;
5537 if (SelectedDriver == NULL)
5538 {
5540 goto cleanup;
5541 }
5542
5543 /* Get .CoInstallers section name */
5545 SelectedDriver->InfFileDetails->hInf,
5546 SelectedDriver->Details.SectionName,
5547 SectionName, MAX_PATH, &SectionNameLength, NULL);
5548 if (!Result || SectionNameLength > MAX_PATH - strlenW(DotCoInstallers) - 1)
5549 goto cleanup;
5550 lstrcatW(SectionName, DotCoInstallers);
5551
5552 deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
5553
5554 /* Open/Create driver key information */
5555#if _WIN32_WINNT >= 0x502
5556 hKey = SETUPDI_OpenDrvKey(set->HKLM, deviceInfo, KEY_READ | KEY_WRITE);
5557#else
5558 hKey = SETUPDI_OpenDrvKey(set->HKLM, deviceInfo, KEY_ALL_ACCESS);
5559#endif
5561#if _WIN32_WINNT >= 0x502
5563#else
5565#endif
5567 goto cleanup;
5568
5569 /* Install .CoInstallers section */
5570 DoAction = SPINST_REGISTRY;
5572 {
5573 DoAction |= SPINST_FILES;
5575 if (!Context)
5576 goto cleanup;
5577 }
5579 SelectedDriver->InfFileDetails->hInf, SectionName,
5580 DoAction, hKey, SelectedDriver->InfFileDetails->DirectoryName, SP_COPY_NEWER,
5583 if (!Result)
5584 goto cleanup;
5585
5586 ret = TRUE;
5587
5588cleanup:
5589 if (Context)
5593 }
5594
5595 TRACE("Returning %d\n", ret);
5596 return ret;
5597}
static const WCHAR DotCoInstallers[]
Definition: devinst.c:29

Referenced by SetupDiCallClassInstaller().

◆ SetupDiRegisterDeviceInfo()

BOOL WINAPI SetupDiRegisterDeviceInfo ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
DWORD  Flags,
PSP_DETSIG_CMPPROC  CompareProc,
PVOID  CompareContext,
PSP_DEVINFO_DATA  DupDeviceInfoData 
)

Definition at line 1954 of file devinst.c.

1961{
1962 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
1963 WCHAR DevInstId[MAX_DEVICE_ID_LEN];
1964 DEVINST ParentDevInst;
1965 CONFIGRET cr;
1966 DWORD dwError = ERROR_SUCCESS;
1967
1968 TRACE("%s(%p %p %08x %p %p %p)\n", __FUNCTION__, DeviceInfoSet, DeviceInfoData, Flags,
1969 CompareProc, CompareContext, DupDeviceInfoData);
1970
1972 {
1974 return FALSE;
1975 }
1976 if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
1977 {
1979 return FALSE;
1980 }
1983 {
1985 return FALSE;
1986 }
1987
1988 if (Flags & ~SPRDI_FIND_DUPS)
1989 {
1990 TRACE("Unknown flags: 0x%08lx\n", Flags & ~SPRDI_FIND_DUPS);
1992 return FALSE;
1993 }
1994
1995 if (Flags & SPRDI_FIND_DUPS)
1996 {
1997 FIXME("Unimplemented codepath!\n");
1998 }
1999
2001 DevInstId,
2003 0,
2004 set->hMachine);
2005
2006 CM_Get_Parent_Ex(&ParentDevInst,
2008 0,
2009 set->hMachine);
2010
2012 DevInstId,
2013 ParentDevInst,
2015 set->hMachine);
2016 if (cr != CR_SUCCESS &&
2018 {
2019 dwError = ERROR_NO_SUCH_DEVINST;
2020 }
2021
2022 SetLastError(dwError);
2023
2024 return (dwError == ERROR_SUCCESS);
2025}
#define CM_Create_DevInst_Ex
Definition: cfgmgr32.h:1128
#define CM_CREATE_DEVINST_DO_NOT_INSTALL
Definition: cfgmgr32.h:630
#define CM_CREATE_DEVINST_NORMAL
Definition: cfgmgr32.h:626
CONFIGRET WINAPI CM_Get_Parent_Ex(_Out_ PDEVINST pdnDevInst, _In_ DEVINST dnDevInst, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:5480
#define SPRDI_FIND_DUPS
Definition: setupapi.h:626

Referenced by InstallCompositeBattery(), IntSetupDiRegisterDeviceInfo(), test_device_key(), test_register_device_iface(), and test_register_device_info().

◆ SetupDiRestartDevices()

BOOL WINAPI SetupDiRestartDevices ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData 
)

Definition at line 6403 of file devinst.c.

6406{
6407 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
6408 struct DeviceInfo *devInfo;
6409 CONFIGRET cr;
6410
6412
6414 {
6416 return FALSE;
6417 }
6418 if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
6419 {
6421 return FALSE;
6422 }
6423
6426 {
6428 return FALSE;
6429 }
6430
6431 devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
6432
6433 cr = CM_Enable_DevNode_Ex(devInfo->dnDevInst, 0, set->hMachine);
6434 if (cr != CR_SUCCESS)
6435 {
6437 return FALSE;
6438 }
6439
6440 return TRUE;
6441}

Referenced by InstallNetDevice().

◆ SetupDiSelectDevice()

BOOL WINAPI SetupDiSelectDevice ( IN HDEVINFO  DeviceInfoSet,
IN OUT PSP_DEVINFO_DATA DeviceInfoData  OPTIONAL 
)

Definition at line 5486 of file devinst.c.

5489{
5490 FIXME("%p %p\n", DeviceInfoSet, DeviceInfoData);
5492 return FALSE;
5493}

Referenced by SetupDiCallClassInstaller().

◆ SetupDiSetClassInstallParamsA()

BOOL WINAPI SetupDiSetClassInstallParamsA ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
PSP_CLASSINSTALL_HEADER  ClassInstallParams,
DWORD  ClassInstallParamsSize 
)

Definition at line 4291 of file devinst.c.

4296{
4297 FIXME("%p %p %x %u\n",DeviceInfoSet, DeviceInfoData,
4298 ClassInstallParams->InstallFunction, ClassInstallParamsSize);
4299 return FALSE;
4300}
_In_opt_ PSP_DEVINFO_DATA _In_ DWORD ClassInstallParamsSize
Definition: setupapi.h:1561

◆ SetupDiSetDeviceInstallParamsA()

BOOL WINAPI SetupDiSetDeviceInstallParamsA ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
PSP_DEVINSTALL_PARAMS_A  DeviceInstallParams 
)

Definition at line 4887 of file devinst.c.

4891{
4892 SP_DEVINSTALL_PARAMS_W deviceInstallParamsW;
4893 int len = 0;
4894 BOOL ret = FALSE;
4895
4897
4900 else if (DeviceInstallParams->cbSize < sizeof(SP_DEVINSTALL_PARAMS_A))
4902 else
4903 {
4904 memcpy(&deviceInstallParamsW, DeviceInstallParams, FIELD_OFFSET(SP_DEVINSTALL_PARAMS_A, DriverPath));
4905 deviceInstallParamsW.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
4906 len = MultiByteToWideChar(CP_ACP, 0, DeviceInstallParams->DriverPath, -1, NULL, 0);
4907 if (!len)
4908 {
4909 ERR("DrivePath is NULL\n");
4910 ret = FALSE;
4911 }
4912 else
4913 {
4914 MultiByteToWideChar(CP_ACP, 0, DeviceInstallParams->DriverPath, -1, deviceInstallParamsW.DriverPath, len);
4916 }
4917 }
4918
4919 TRACE("Returning %d\n", ret);
4920 return ret;
4921}
#define MultiByteToWideChar
Definition: compat.h:110

◆ SetupDiSetDeviceInstallParamsW()

BOOL WINAPI SetupDiSetDeviceInstallParamsW ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData  OPTIONAL,
IN PSP_DEVINSTALL_PARAMS_W  DeviceInstallParams 
)

Definition at line 4847 of file devinst.c.

4851{
4852 struct DeviceInfoSet *list;
4853 BOOL ret = FALSE;
4854
4856
4857 if (!DeviceInfoSet)
4861 else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
4863 else if (!DeviceInstallParams)
4865 else if (DeviceInstallParams->cbSize != sizeof(SP_DEVINSTALL_PARAMS_W))
4868 {
4870
4871 if (DeviceInfoData)
4872 Destination = &((struct DeviceInfo *)DeviceInfoData->Reserved)->InstallParams;
4873 else
4874 Destination = &list->InstallParams;
4876 ret = TRUE;
4877 }
4878
4879 TRACE("Returning %d\n", ret);
4880 return ret;
4881}
static BOOL CheckDeviceInstallParameters(IN PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
Definition: devinst.c:4788
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3051

Referenced by DisplayDeviceAdvancedProperties(), EnumerateDrivers(), InstallNetDevice(), CDeviceNode::RemoveFlags(), SearchDriver(), CDeviceNode::SetFlags(), SetupDiBuildDriverInfoList(), SetupDiCallClassInstaller(), SetupDiDestroyDriverInfoList(), SetupDiInstallClassExW(), SetupDiInstallDevice(), SetupDiInstallDriverFiles(), SetupDiSetClassInstallParamsW(), SetupDiSetDeviceInstallParamsA(), and WriteParameterArray().

◆ SetupDiSetDeviceRegistryPropertyA()

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

Definition at line 3723 of file devinst.c.

3729{
3732 Property,
3735 TRUE);
3736}
BOOL WINAPI IntSetupDiSetDeviceRegistryPropertyAW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, const BYTE *PropertyBuffer, DWORD PropertyBufferSize, BOOL isAnsi)
Definition: devinst.c:3647

Referenced by test_registry_property_a().

◆ SetupDiSetDeviceRegistryPropertyW()

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

◆ SetupDiSetSelectedDevice()

BOOL WINAPI SetupDiSetSelectedDevice ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA  DeviceInfoData 
)

Definition at line 5230 of file devinst.c.

5233{
5234 struct DeviceInfoSet *list;
5235 BOOL ret = FALSE;
5236
5238
5239 if (!DeviceInfoSet)
5243 else if (!DeviceInfoData)
5245 else if (DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
5247 else if (DeviceInfoData->Reserved == 0)
5249 else
5250 {
5251 list->SelectedDevice = (struct DeviceInfo *)DeviceInfoData->Reserved;
5252 ret = TRUE;
5253 }
5254
5255 TRACE("Returning %d\n", ret);
5256 return ret;
5257}

◆ StopDevice()

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

Definition at line 5333 of file devinst.c.

5336{
5337#ifndef __WINESRC__
5338 struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
5339 struct DeviceInfo *deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
5340 CONFIGRET cr;
5341
5342 cr = CM_Disable_DevNode_Ex(deviceInfo->dnDevInst, 0, set->hMachine);
5343 if (cr != CR_SUCCESS)
5344 {
5346 return FALSE;
5347 }
5348
5349 return TRUE;
5350#else
5351 FIXME("Stub: StopDevice(%p %p)\n", DeviceInfoSet, DeviceInfoData);
5352 return TRUE;
5353#endif
5354}
CONFIGRET WINAPI CM_Disable_DevNode_Ex(_In_ DEVINST dnDevInst, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:1826

Referenced by SetupDiChangeState().

Variable Documentation

◆ BackSlash

const WCHAR BackSlash[] = {'\\',0}
static

Definition at line 27 of file devinst.c.

Referenced by InfIsFromOEMLocation(), and SETUP_CreateClassKey().

◆ DateFormat

const WCHAR DateFormat[] = {'%','u','-','%','u','-','%','u',0}
static

Definition at line 28 of file devinst.c.

Referenced by SetupDiInstallDevice().

◆ DotCoInstallers

const WCHAR DotCoInstallers[] = {'.','C','o','I','n','s','t','a','l','l','e','r','s',0}
static

Definition at line 29 of file devinst.c.

Referenced by SetupDiRegisterCoDeviceInstallers().

◆ DotHW

const WCHAR DotHW[] = {'.','H','W',0}
static

Definition at line 30 of file devinst.c.

Referenced by SetupDiInstallDevice().

◆ DotServices

const WCHAR DotServices[] = {'.','S','e','r','v','i','c','e','s',0}
static

Definition at line 31 of file devinst.c.

Referenced by SetupDiInstallDevice().

◆ InfDirectory

const WCHAR InfDirectory[] = {'i','n','f','\\',0}
static

Definition at line 32 of file devinst.c.

Referenced by InfIsFromOEMLocation().

◆ InstanceKeyFormat

const WCHAR InstanceKeyFormat[] = {'%','0','4','l','u',0}
static

Definition at line 33 of file devinst.c.

Referenced by OpenHardwareProfileKey(), and SETUPDI_CreateDrvKey().

◆ PropertyMap

struct PropertyMapEntry PropertyMap[]
static

◆ REGSTR_DRIVER_DATE

const WCHAR REGSTR_DRIVER_DATE[] = {'D','r','i','v','e','r','D','a','t','e',0}
static

Definition at line 37 of file devinst.c.

Referenced by SetupDiInstallDevice().

◆ REGSTR_DRIVER_DATE_DATA

const WCHAR REGSTR_DRIVER_DATE_DATA[] = {'D','r','i','v','e','r','D','a','t','e','D','a','t','a',0}
static

Definition at line 38 of file devinst.c.

Referenced by SetupDiInstallDevice().

◆ REGSTR_DRIVER_VERSION

const WCHAR REGSTR_DRIVER_VERSION[] = {'D','r','i','v','e','r','V','e','r','s','i','o','n',0}
static

Definition at line 39 of file devinst.c.

Referenced by SetupDiInstallDevice().

◆ REGSTR_SECURITY

const WCHAR REGSTR_SECURITY[] = {'S','e','c','u','r','i','t','y',0}
static

Definition at line 40 of file devinst.c.

◆ REGSTR_UI_NUMBER_DESC_FORMAT

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

Definition at line 41 of file devinst.c.

◆ Version

const WCHAR Version[] = {'V','e','r','s','i','o','n',0}
static

Definition at line 34 of file devinst.c.

◆ VersionFormat

const WCHAR VersionFormat[] = {'%','u','.','%','u','.','%','u','.','%','u',0}
static

Definition at line 35 of file devinst.c.

Referenced by SetupDiInstallDevice().