ReactOS  0.4.11-dev-195-gef016bf
devinst.c File Reference
#include "setupapi_private.h"
Include dependency graph for devinst.c:

Go to the source code of this file.

Classes

struct  CoInstallerElement
 
struct  GetSectionCallbackInfo
 
struct  PropertyMapEntry
 

Macros

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

Typedefs

typedef IN HDEVINFO DeviceInfoSet
 
typedef IN HDEVINFO IN
PSP_DEVINFO_DATA
DeviceInfoData 
OPTIONAL
 
typedef IN OUT PSP_DEVINFO_DATA DeviceInfoData
 
typedef IN HDEVINFO IN
PSP_DEVINFO_DATA
DeviceInfoData IN OUT
PCOINSTALLER_CONTEXT_DATA 
Context
 

Functions

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

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

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

Typedef Documentation

Definition at line 49 of file devinst.c.

Definition at line 44 of file devinst.c.

Definition at line 44 of file devinst.c.

Function Documentation

typedef BOOL ( WINAPI DEFAULT_CLASS_INSTALL_PROC)
static BOOL CheckDeviceInstallParameters ( IN PSP_DEVINSTALL_PARAMS_W  DeviceInstallParams)
static

Definition at line 4633 of file devinst.c.

Referenced by SetupDiSetDeviceInstallParamsW().

4635 {
4636  DWORD SupportedFlags =
4637  DI_NOVCP | /* 0x00000008 */
4638  DI_DIDCOMPAT | /* 0x00000010 */
4639  DI_DIDCLASS | /* 0x00000020 */
4640  DI_NEEDRESTART | /* 0x00000080 */
4641  DI_NEEDREBOOT | /* 0x00000100 */
4642  DI_RESOURCEPAGE_ADDED | /* 0x00002000 */
4643  DI_PROPERTIES_CHANGE | /* 0x00004000 */
4644  DI_ENUMSINGLEINF | /* 0x00010000 */
4645  DI_DONOTCALLCONFIGMG | /* 0x00020000 */
4646  DI_CLASSINSTALLPARAMS | /* 0x00100000 */
4647  DI_NODI_DEFAULTACTION | /* 0x00200000 */
4648  DI_QUIETINSTALL | /* 0x00800000 */
4649  DI_NOFILECOPY | /* 0x01000000 */
4650  DI_DRIVERPAGE_ADDED; /* 0x04000000 */
4651  DWORD SupportedFlagsEx =
4652  DI_FLAGSEX_CI_FAILED | /* 0x00000004 */
4653  DI_FLAGSEX_DIDINFOLIST | /* 0x00000010 */
4654  DI_FLAGSEX_DIDCOMPATINFO | /* 0x00000020 */
4655  DI_FLAGSEX_ALLOWEXCLUDEDDRVS | /* 0x00000800 */
4656  DI_FLAGSEX_NO_DRVREG_MODIFY | /* 0x00008000 */
4657  DI_FLAGSEX_INSTALLEDDRIVER; /* 0x04000000 */
4658  BOOL ret = FALSE;
4659 
4660  /* FIXME: add support for more flags */
4661 
4662  /* FIXME: DI_CLASSINSTALLPARAMS flag is not correctly used.
4663  * It should be checked before accessing to other values
4664  * of the SP_DEVINSTALL_PARAMS structure */
4665 
4666  if (DeviceInstallParams->Flags & ~SupportedFlags)
4667  {
4668  FIXME("Unknown Flags: 0x%08lx\n", DeviceInstallParams->Flags & ~SupportedFlags);
4670  }
4671  else if (DeviceInstallParams->FlagsEx & ~SupportedFlagsEx)
4672  {
4673  FIXME("Unknown FlagsEx: 0x%08lx\n", DeviceInstallParams->FlagsEx & ~SupportedFlagsEx);
4675  }
4676  else if ((DeviceInstallParams->Flags & DI_NOVCP)
4677  && (DeviceInstallParams->FileQueue == NULL || DeviceInstallParams->FileQueue == (HSPFILEQ)INVALID_HANDLE_VALUE))
4679  else
4680  {
4681  /* FIXME: check Reserved field */
4682  ret = TRUE;
4683  }
4684 
4685  return ret;
4686 }
#define TRUE
Definition: types.h:120
#define DI_NEEDREBOOT
Definition: setupapi.h:54
PVOID HSPFILEQ
Definition: filequeue.h:52
#define DI_FLAGSEX_NO_DRVREG_MODIFY
Definition: setupapi.h:91
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define DI_FLAGSEX_ALLOWEXCLUDEDDRVS
Definition: setupapi.h:87
#define DI_DRIVERPAGE_ADDED
Definition: setupapi.h:71
DWORD DWORD
Definition: winlogon.h:84
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1091
#define DI_DIDCLASS
Definition: setupapi.h:51
#define FALSE
Definition: types.h:117
#define DI_DONOTCALLCONFIGMG
Definition: setupapi.h:63
#define DI_NOFILECOPY
Definition: setupapi.h:69
#define FIXME(fmt,...)
Definition: debug.h:110
#define DI_DIDCOMPAT
Definition: setupapi.h:50
#define DI_NOVCP
Definition: setupapi.h:49
smooth NULL
Definition: ftsmooth.c:416
#define DI_PROPERTIES_CHANGE
Definition: setupapi.h:60
unsigned int BOOL
Definition: ntddk_ex.h:94
#define DI_NODI_DEFAULTACTION
Definition: setupapi.h:67
#define SetLastError(x)
Definition: compat.h:409
#define DI_QUIETINSTALL
Definition: setupapi.h:68
#define DI_RESOURCEPAGE_ADDED
Definition: setupapi.h:59
#define DI_CLASSINSTALLPARAMS
Definition: setupapi.h:66
int ret
#define DI_FLAGSEX_DIDINFOLIST
Definition: setupapi.h:80
#define DI_FLAGSEX_DIDCOMPATINFO
Definition: setupapi.h:81
#define DI_FLAGSEX_CI_FAILED
Definition: setupapi.h:79
#define DI_ENUMSINGLEINF
Definition: setupapi.h:62
#define DI_NEEDRESTART
Definition: setupapi.h:53
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583
static BOOL CheckSectionValid ( IN LPCWSTR  SectionName,
IN PSP_ALTPLATFORM_INFO  PlatformInfo,
IN BYTE  ProductType,
IN WORD  SuiteMask,
OUT PDWORD  ScorePlatform,
OUT PDWORD  ScoreMajorVersion,
OUT PDWORD  ScoreMinorVersion,
OUT PDWORD  ScoreProductType,
OUT PDWORD  ScoreSuiteMask 
)
static

Definition at line 122 of file devinst.c.

Referenced by GetSectionCallback().

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

Definition at line 526 of file devinst.c.

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

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

Definition at line 571 of file devinst.c.

Referenced by DestroyDeviceInfo(), and DestroyDeviceInfoSet().

572 {
573  HeapFree(GetProcessHeap(), 0, installParams->PropChangeParams);
574  HeapFree(GetProcessHeap(), 0, installParams->AddPropertyPageData);
575  return TRUE;
576 }
#define TRUE
Definition: types.h:120
PSP_ADDPROPERTYPAGE_DATA AddPropertyPageData
#define GetProcessHeap()
Definition: compat.h:395
PSP_PROPCHANGE_PARAMS PropChangeParams
#define HeapFree(x, y, z)
Definition: compat.h:394
static BOOL DestroyDeviceInfo ( struct DeviceInfo deviceInfo)
static

Definition at line 579 of file devinst.c.

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

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

Definition at line 606 of file devinst.c.

Referenced by SetupDiDestroyDeviceInfoList().

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

Definition at line 92 of file devinst.c.

Referenced by CreateDeviceInfo(), ResetDevice(), SetupDiCreateDeviceInfoListExW(), and SetupDiCreateDeviceInfoW().

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

Definition at line 363 of file devinst.c.

Referenced by SetupDiGetActualSectionToInstallExW().

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

Definition at line 5407 of file devinst.c.

Referenced by SetupDiInstallDevice().

5410 {
5411  PWCHAR last;
5412 
5413  last = strrchrW(FullName, '\\');
5414  if (!last)
5415  {
5416  /* No directory specified */
5417  *IsOEMLocation = FALSE;
5418  }
5419  else
5420  {
5421  LPWSTR Windir;
5422  UINT ret;
5423 
5424  Windir = MyMalloc((MAX_PATH + 1 + strlenW(InfDirectory)) * sizeof(WCHAR));
5425  if (!Windir)
5426  {
5428  return FALSE;
5429  }
5430 
5431  ret = GetSystemWindowsDirectoryW(Windir, MAX_PATH);
5432  if (ret == 0 || ret > MAX_PATH)
5433  {
5434  MyFree(Windir);
5436  return FALSE;
5437  }
5438  if (*Windir && Windir[strlenW(Windir) - 1] != '\\')
5439  strcatW(Windir, BackSlash);
5440  strcatW(Windir, InfDirectory);
5441 
5442  if (strncmpiW(FullName, Windir, last - FullName) == 0)
5443  {
5444  /* The path is %SYSTEMROOT%\Inf */
5445  *IsOEMLocation = FALSE;
5446  }
5447  else
5448  {
5449  /* The file is in another place */
5450  *IsOEMLocation = TRUE;
5451  }
5452  MyFree(Windir);
5453  }
5454  return TRUE;
5455 }
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2396
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
POINT last
Definition: font.c:46
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
uint16_t * PWCHAR
Definition: typedefs.h:54
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
#define FALSE
Definition: types.h:117
static const WCHAR InfDirectory[]
Definition: devinst.c:30
#define MAX_PATH
Definition: compat.h:26
_In_ PSTRING FullName
Definition: rtlfuncs.h:1649
#define SetLastError(x)
Definition: compat.h:409
int ret
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
unsigned int UINT
Definition: ndis.h:50
static const WCHAR BackSlash[]
Definition: devinst.c:25
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
WCHAR * LPWSTR
Definition: xmlstorage.h:184
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
static BOOL WINAPI IntSetupDiRegisterDeviceInfo ( IN HDEVINFO  DeviceInfoSet,
IN OUT PSP_DEVINFO_DATA  DeviceInfoData 
)
static

Definition at line 4148 of file devinst.c.

Referenced by SetupDiCallClassInstaller().

4151 {
4153 }
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SetupDiRegisterDeviceInfo(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Flags, PSP_DETSIG_CMPPROC CompareProc, PVOID CompareContext, PSP_DEVINFO_DATA DupDeviceInfoData)
Definition: devinst.c:1849
IN OUT PSP_DEVINFO_DATA DeviceInfoData
Definition: devinst.c:49
BOOL WINAPI IntSetupDiSetDeviceRegistryPropertyAW ( HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData,
DWORD  Property,
const BYTE PropertyBuffer,
DWORD  PropertyBufferSize,
BOOL  isAnsi 
)

Definition at line 3496 of file devinst.c.

Referenced by SetupDiSetDeviceRegistryPropertyA(), and SetupDiSetDeviceRegistryPropertyW().

3503 {
3504  BOOL ret = FALSE;
3505  struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
3506 
3507  TRACE("%p %p %d %p %d\n", DeviceInfoSet, DeviceInfoData, Property,
3508  PropertyBuffer, PropertyBufferSize);
3509 
3511  {
3513  return FALSE;
3514  }
3515  if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
3516  {
3518  return FALSE;
3519  }
3520  if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA)
3521  || !DeviceInfoData->Reserved)
3522  {
3524  return FALSE;
3525  }
3526  if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
3528  && PropertyMap[Property].nameA)
3529  {
3530  HKEY hKey;
3531  LONG l;
3533  if (hKey == INVALID_HANDLE_VALUE)
3534  return FALSE;
3535  /* Write new data */
3536  if (isAnsi)
3537  {
3538  l = RegSetValueExA(
3539  hKey, PropertyMap[Property].nameA, 0,
3540  PropertyMap[Property].regType, PropertyBuffer,
3542  }
3543  else
3544  {
3545  l = RegSetValueExW(
3546  hKey, PropertyMap[Property].nameW, 0,
3547  PropertyMap[Property].regType, PropertyBuffer,
3549  }
3550  if (!l)
3551  ret = TRUE;
3552  else
3553  SetLastError(l);
3554  RegCloseKey(hKey);
3555  }
3556  else
3557  {
3558  ERR("Property 0x%lx not implemented\n", Property);
3560  }
3561 
3562  TRACE("Returning %d\n", ret);
3563  return ret;
3564 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define SETUP_DEVICE_INFO_SET_MAGIC
_In_ DWORD _Out_opt_ PDWORD _In_ DWORD PropertyBufferSize
Definition: setupapi.h:1548
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
static struct PropertyMapEntry PropertyMap[]
Definition: devinst.c:3236
ULONG_PTR Reserved
Definition: setupapi.h:833
static const WCHAR nameW[]
Definition: main.c:46
r l[0]
Definition: byte_order.h:167
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4917
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
HANDLE HKEY
Definition: registry.h:24
#define DIREG_DEV
Definition: setupapi.h:181
#define SetLastError(x)
Definition: compat.h:409
int ret
HKEY WINAPI SetupDiOpenDevRegKey(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, REGSAM samDesired)
Definition: devinst.c:5848
#define ERR(fmt,...)
Definition: debug.h:109
#define DICS_FLAG_GLOBAL
Definition: setupapi.h:113
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4831
Definition: _set.h:46
static BOOL IsDeviceInfoInDeviceInfoSet ( struct DeviceInfoSet deviceInfoSet,
struct DeviceInfo deviceInfo 
)
static

Definition at line 4824 of file devinst.c.

Referenced by SetupDiDeleteDeviceInfo().

4827 {
4828  PLIST_ENTRY ListEntry;
4829 
4830  ListEntry = deviceInfoSet->ListHead.Flink;
4831  while (ListEntry != &deviceInfoSet->ListHead)
4832  {
4833  if (deviceInfo == CONTAINING_RECORD(ListEntry, struct DeviceInfo, ListEntry))
4834  return TRUE;
4835 
4836  ListEntry = ListEntry->Flink;
4837  }
4838 
4839  return FALSE;
4840 }
#define TRUE
Definition: types.h:120
LIST_ENTRY ListHead
#define FALSE
Definition: types.h:117
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
Definition: typedefs.h:117
static HKEY OpenHardwareProfileKey ( IN HKEY  HKLM,
IN DWORD  HwProfile,
IN DWORD  samDesired 
)
static

Definition at line 4769 of file devinst.c.

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

4773 {
4774  HKEY hHWProfilesKey = NULL;
4775  HKEY hHWProfileKey = NULL;
4777  LONG rc;
4778 
4779  rc = RegOpenKeyExW(HKLM,
4781  0,
4782  READ_CONTROL,
4783  &hHWProfilesKey);
4784  if (rc != ERROR_SUCCESS)
4785  {
4786  SetLastError(rc);
4787  goto cleanup;
4788  }
4789  if (HwProfile == 0)
4790  {
4791  rc = RegOpenKeyExW(hHWProfilesKey,
4793  0,
4795  &hHWProfileKey);
4796  }
4797  else
4798  {
4799  WCHAR subKey[5];
4800  snprintfW(subKey, 4, InstanceKeyFormat, HwProfile);
4801  subKey[4] = '\0';
4802  rc = RegOpenKeyExW(hHWProfilesKey,
4803  subKey,
4804  0,
4806  &hHWProfileKey);
4807  }
4808  if (rc != ERROR_SUCCESS)
4809  {
4810  SetLastError(rc);
4811  goto cleanup;
4812  }
4813  ret = hHWProfileKey;
4814 
4815 cleanup:
4816  if (hHWProfilesKey != NULL)
4817  RegCloseKey(hHWProfilesKey);
4818  if (hHWProfileKey != NULL && hHWProfileKey != ret)
4819  RegCloseKey(hHWProfileKey);
4820  return ret;
4821 }
#define snprintfW
Definition: unicode.h:60
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR InstanceKeyFormat[]
Definition: devinst.c:31
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define REGSTR_PATH_HWPROFILES
Definition: regstr.h:482
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR HKLM[]
Definition: reginf.c:54
HANDLE HKEY
Definition: registry.h:24
#define SetLastError(x)
Definition: compat.h:409
#define READ_CONTROL
Definition: nt_native.h:58
int ret
#define REGSTR_KEY_CURRENT
Definition: regstr.h:493
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
char * cleanup(char *str)
Definition: wpickclick.c:99
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
static BOOL ResetDevice ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA  DeviceInfoData 
)
static

Definition at line 5154 of file devinst.c.

5157 {
5158 #ifndef __WINESRC__
5159  struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
5160  struct DeviceInfo *deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
5161  CONFIGRET cr;
5162 
5163  cr = CM_Enable_DevNode_Ex(deviceInfo->dnDevInst, 0, set->hMachine);
5164  if (cr != CR_SUCCESS)
5165  {
5167  return FALSE;
5168  }
5169 
5170  return TRUE;
5171 #else
5172  FIXME("Stub: ResetDevice(%p %p)\n", DeviceInfoSet, DeviceInfoData);
5173  return TRUE;
5174 #endif
5175 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static DWORD GetErrorCodeFromCrCode(const IN CONFIGRET cr)
Definition: devinst.c:92
#define FIXME(fmt,...)
Definition: debug.h:110
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define SetLastError(x)
Definition: compat.h:409
DEVINST dnDevInst
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
IN OUT PSP_DEVINFO_DATA DeviceInfoData
Definition: devinst.c:49
Definition: _set.h:46
CONFIGRET WINAPI CM_Enable_DevNode_Ex(_In_ DEVINST dnDevInst, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:1750
HKEY SETUP_CreateClassKey ( HINF  hInf)

Definition at line 3652 of file devinst.c.

Referenced by SetupDiInstallClassExW().

3653 {
3654  WCHAR FullBuffer[MAX_PATH];
3657  HKEY hClassKey;
3659 
3660  /* Obtain the Class GUID for this class */
3661  if (!SetupGetLineTextW(NULL,
3662  hInf,
3663  Version,
3665  Buffer,
3666  sizeof(Buffer) / sizeof(WCHAR),
3667  &RequiredSize))
3668  {
3669  return INVALID_HANDLE_VALUE;
3670  }
3671 
3672  /* Build the corresponding registry key name */
3673  lstrcpyW(FullBuffer, REGSTR_PATH_CLASS_NT);
3674  lstrcatW(FullBuffer, BackSlash);
3675  lstrcatW(FullBuffer, Buffer);
3676 
3677  /* Obtain the Class name for this class */
3678  if (!SetupGetLineTextW(NULL,
3679  hInf,
3680  Version,
3682  Buffer,
3683  sizeof(Buffer) / sizeof(WCHAR),
3684  &RequiredSize))
3685  {
3686  return INVALID_HANDLE_VALUE;
3687  }
3688 
3689  /* Try to open or create the registry key */
3690  TRACE("Opening class key %s\n", debugstr_w(FullBuffer));
3691 #if 0 // I keep this for reference...
3693  FullBuffer,
3694  0,
3695  KEY_SET_VALUE,
3696  &hClassKey))
3697  {
3698  /* Use RegCreateKeyExW */
3699  }
3700 #endif
3702  FullBuffer,
3703  0,
3704  NULL,
3706  KEY_SET_VALUE,
3707  NULL,
3708  &hClassKey,
3709  &Disposition))
3710  {
3711  ERR("RegCreateKeyExW(%s) failed\n", debugstr_w(FullBuffer));
3712  return INVALID_HANDLE_VALUE;
3713  }
3714  if (Disposition == REG_CREATED_NEW_KEY)
3715  TRACE("The class key %s was successfully created\n", debugstr_w(FullBuffer));
3716  else
3717  TRACE("The class key %s was successfully opened\n", debugstr_w(FullBuffer));
3718 
3719  TRACE( "setting value %s to %s\n", debugstr_w(REGSTR_VAL_CLASS), debugstr_w(Buffer) );
3720  if (RegSetValueExW(hClassKey,
3722  0,
3723  REG_SZ,
3724  (LPBYTE)Buffer,
3725  RequiredSize * sizeof(WCHAR)))
3726  {
3727  RegCloseKey(hClassKey);
3729  FullBuffer);
3730  return INVALID_HANDLE_VALUE;
3731  }
3732 
3733  return hClassKey;
3734 }
#define REGSTR_VAL_CLASS
Definition: regstr.h:291
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:359
#define KEY_SET_VALUE
Definition: nt_native.h:1017
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char * LPBYTE
Definition: typedefs.h:52
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1240
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD DWORD
Definition: winlogon.h:84
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:50
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1094
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4917
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE HKEY
Definition: registry.h:24
#define MAX_PATH
Definition: compat.h:26
#define REGSTR_VAL_CLASSGUID
Definition: regstr.h:422
#define ERR(fmt,...)
Definition: debug.h:109
#define lstrcpyW
Definition: compat.h:406
static const WCHAR BackSlash[]
Definition: devinst.c:25
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
static HKEY hClassKey
Definition: umpnpmgr.c:66
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REGSTR_PATH_CLASS_NT
Definition: regstr.h:479
BOOL WINAPI SetupGetLineTextW(PINFCONTEXT context, HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1756
#define REG_SZ
Definition: layer.c:22
static DWORD SETUPAPI_GetCurrentHwProfile ( IN HDEVINFO  DeviceInfoSet)
static

Definition at line 5107 of file devinst.c.

Referenced by SetupDiChangeState().

5109 {
5110  HKEY hKey = NULL;
5111  DWORD dwRegType, dwLength;
5112  DWORD hwProfile;
5113  LONG rc;
5114  DWORD ret = (DWORD)-1;
5115 
5116  rc = RegOpenKeyExW(((struct DeviceInfoSet *)DeviceInfoSet)->HKLM,
5118  0, /* Options */
5120  &hKey);
5121  if (rc != ERROR_SUCCESS)
5122  {
5123  SetLastError(rc);
5124  goto cleanup;
5125  }
5126 
5127  dwLength = sizeof(DWORD);
5128  rc = RegQueryValueExW(hKey,
5130  NULL,
5131  &dwRegType,
5132  (LPBYTE)&hwProfile, &dwLength);
5133  if (rc != ERROR_SUCCESS)
5134  {
5135  SetLastError(rc);
5136  goto cleanup;
5137  }
5138  else if (dwRegType != REG_DWORD || dwLength != sizeof(DWORD))
5139  {
5141  goto cleanup;
5142  }
5143 
5144  ret = hwProfile;
5145 
5146 cleanup:
5147  if (hKey != NULL)
5148  RegCloseKey(hKey);
5149 
5150  return ret;
5151 }
static const GUID DWORD
Definition: devinst.c:39
#define ERROR_SUCCESS
Definition: deptool.c:10
unsigned char * LPBYTE
Definition: typedefs.h:52
DWORD DWORD
Definition: winlogon.h:84
#define REGSTR_VAL_CURRENTCONFIG
Definition: regstr.h:466
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR HKLM[]
Definition: reginf.c:54
#define REGSTR_PATH_IDCONFIGDB
Definition: regstr.h:41
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
static DWORD DWORD * dwLength
Definition: fusion.c:83
HANDLE HKEY
Definition: registry.h:24
#define SetLastError(x)
Definition: compat.h:409
int ret
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
#define REG_DWORD
Definition: sdbapi.c:539
static BOOL SETUPDI_DeleteDevKey ( HKEY  RootKey,
struct DeviceInfo devInfo 
)
static

Definition at line 5920 of file devinst.c.

Referenced by SetupDiDeleteDevRegKey().

5921 {
5922  FIXME("\n");
5923  return FALSE;
5924 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:110
static BOOL SETUPDI_DeleteDrvKey ( HKEY  RootKey,
struct DeviceInfo devInfo 
)
static

Definition at line 5926 of file devinst.c.

Referenced by SetupDiDeleteDevRegKey().

5927 {
5928  FIXME("\n");
5929  return FALSE;
5930 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:110
static void SETUPDI_GuidToString ( const GUID guid,
LPWSTR  guidStr 
)
static

Definition at line 79 of file devinst.c.

Referenced by SetupDiCreateDeviceInterfaceRegKeyW(), and SetupDiOpenClassRegKeyExW().

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

Definition at line 5755 of file devinst.c.

Referenced by SETUPDI_OpenDrvKey(), and SetupDiOpenDevRegKey().

5756 {
5757  HKEY enumKey, key = INVALID_HANDLE_VALUE;
5758  LONG l;
5759 
5761  if (!l)
5762  {
5763  l = RegOpenKeyExW(enumKey, devInfo->instanceId, 0, samDesired, &key);
5764  RegCloseKey(enumKey);
5765  }
5766  if (l)
5767  SetLastError(l);
5768  return key;
5769 }
static PMEMKEY RootKey
Definition: registry.c:40
#define REGSTR_PATH_SYSTEMENUM
Definition: regstr.h:483
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
r l[0]
Definition: byte_order.h:167
HANDLE HKEY
Definition: registry.h:24
#define SetLastError(x)
Definition: compat.h:409
#define READ_CONTROL
Definition: nt_native.h:58
HKEY key
Definition: reg.c:42
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
Definition: path.c:42
static HKEY SETUPDI_OpenDrvKey ( HKEY  RootKey,
struct DeviceInfo devInfo,
REGSAM  samDesired 
)
static

Definition at line 5771 of file devinst.c.

Referenced by SetupDiOpenDevRegKey().

5772 {
5773  LPWSTR DriverKey = NULL;
5774  DWORD dwLength = 0;
5775  DWORD dwRegType;
5776  DWORD rc;
5777  HKEY hEnumKey = NULL;
5778  HKEY hKey = NULL;
5780 
5781  hKey = SETUPDI_OpenDevKey(RootKey, devInfo, KEY_QUERY_VALUE);
5782  if (hKey == INVALID_HANDLE_VALUE)
5783  goto cleanup;
5784  /* Read the 'Driver' key */
5785  rc = RegQueryValueExW(hKey, REGSTR_VAL_DRIVER, NULL, &dwRegType, NULL, &dwLength);
5786  if (rc != ERROR_SUCCESS)
5787  {
5788  SetLastError(rc);
5789  goto cleanup;
5790  }
5791  else if (dwRegType != REG_SZ)
5792  {
5794  goto cleanup;
5795  }
5796  DriverKey = HeapAlloc(GetProcessHeap(), 0, dwLength);
5797  if (!DriverKey)
5798  {
5800  goto cleanup;
5801  }
5802  rc = RegQueryValueExW(hKey, REGSTR_VAL_DRIVER, NULL, &dwRegType, (LPBYTE)DriverKey, &dwLength);
5803  if (rc != ERROR_SUCCESS)
5804  {
5805  SetLastError(rc);
5806  goto cleanup;
5807  }
5808  RegCloseKey(hKey);
5809  hKey = NULL;
5810  /* Need to open the driver key */
5811  rc = RegOpenKeyExW(
5812  RootKey,
5814  0, /* Options */
5815  READ_CONTROL,
5816  &hEnumKey);
5817  if (rc != ERROR_SUCCESS)
5818  {
5819  SetLastError(rc);
5820  goto cleanup;
5821  }
5822  rc = RegOpenKeyExW(
5823  hEnumKey,
5824  DriverKey,
5825  0, /* Options */
5826  samDesired,
5827  &hKey);
5828  if (rc != ERROR_SUCCESS)
5829  {
5830  SetLastError(rc);
5831  goto cleanup;
5832  }
5833  key = hKey;
5834 
5835 cleanup:
5836  if (hEnumKey != NULL)
5837  RegCloseKey(hEnumKey);
5838  if (hKey != NULL && hKey != key)
5839  RegCloseKey(hKey);
5840  if (DriverKey)
5841  HeapFree(GetProcessHeap(), 0, DriverKey);
5842  return key;
5843 }
#define REGSTR_VAL_DRIVER
Definition: regstr.h:385
static PMEMKEY RootKey
Definition: registry.c:40
#define ERROR_SUCCESS
Definition: deptool.c:10
unsigned char * LPBYTE
Definition: typedefs.h:52
static HKEY SETUPDI_OpenDevKey(HKEY RootKey, struct DeviceInfo *devInfo, REGSAM samDesired)
Definition: devinst.c:5755
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD DWORD
Definition: winlogon.h:84
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
static HKEY hEnumKey
Definition: umpnpmgr.c:65
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
static DWORD DWORD * dwLength
Definition: fusion.c:83
HANDLE HKEY
Definition: registry.h:24
#define SetLastError(x)
Definition: compat.h:409
#define READ_CONTROL
Definition: nt_native.h:58
HKEY key
Definition: reg.c:42
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394
Definition: path.c:42
#define REGSTR_PATH_CLASS_NT
Definition: regstr.h:479
#define REG_SZ
Definition: layer.c:22
BOOL WINAPI SetupDiBuildClassInfoList ( DWORD  Flags,
LPGUID  ClassGuidList,
DWORD  ClassGuidListSize,
PDWORD  RequiredSize 
)

Definition at line 643 of file devinst.c.

Referenced by test_SetupDiBuildClassInfoList().

648 {
649  TRACE("\n");
650  return SetupDiBuildClassInfoListExW(Flags, ClassGuidList,
652  NULL, NULL);
653 }
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
smooth NULL
Definition: ftsmooth.c:416
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1276
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI SetupDiBuildClassInfoListExW(DWORD Flags, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:720
BOOL WINAPI SetupDiBuildClassInfoListExA ( DWORD  Flags,
LPGUID  ClassGuidList,
DWORD  ClassGuidListSize,
PDWORD  RequiredSize,
LPCSTR  MachineName,
PVOID  Reserved 
)

Definition at line 673 of file devinst.c.

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

Definition at line 720 of file devinst.c.

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

727 {
728  WCHAR szKeyName[40];
729  HKEY hClassesKey = INVALID_HANDLE_VALUE;
730  HKEY hClassKey;
731  DWORD dwLength;
732  DWORD dwIndex;
733  LONG lError;
734  DWORD dwGuidListIndex = 0;
735 
736  TRACE("0x%lx %p %lu %p %s %p\n", Flags, ClassGuidList,
738 
739  if (!RequiredSize)
740  {
742  return FALSE;
743  }
744  else if (!ClassGuidList && ClassGuidListSize > 0)
745  {
747  return FALSE;
748  }
749 
750  hClassesKey = SetupDiOpenClassRegKeyExW(NULL,
753  MachineName,
754  Reserved);
755  if (hClassesKey == INVALID_HANDLE_VALUE)
756  {
757  return FALSE;
758  }
759 
760  for (dwIndex = 0; ; dwIndex++)
761  {
762  dwLength = 40;
763  lError = RegEnumKeyExW(hClassesKey,
764  dwIndex,
765  szKeyName,
766  &dwLength,
767  NULL,
768  NULL,
769  NULL,
770  NULL);
771  TRACE("RegEnumKeyExW() returns %d\n", lError);
772  if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA)
773  {
774  TRACE("Key name: %s\n", debugstr_w(szKeyName));
775 
776  if (RegOpenKeyExW(hClassesKey,
777  szKeyName,
778  0,
780  &hClassKey))
781  {
782  RegCloseKey(hClassesKey);
783  return FALSE;
784  }
785 
786  if (!RegQueryValueExW(hClassKey,
788  NULL,
789  NULL,
790  NULL,
791  NULL))
792  {
793  TRACE("'NoUseClass' value found!\n");
794  RegCloseKey(hClassKey);
795  continue;
796  }
797 
798  if ((Flags & DIBCI_NOINSTALLCLASS) &&
799  (!RegQueryValueExW(hClassKey,
801  NULL,
802  NULL,
803  NULL,
804  NULL)))
805  {
806  TRACE("'NoInstallClass' value found!\n");
807  RegCloseKey(hClassKey);
808  continue;
809  }
810 
811  if ((Flags & DIBCI_NODISPLAYCLASS) &&
812  (!RegQueryValueExW(hClassKey,
814  NULL,
815  NULL,
816  NULL,
817  NULL)))
818  {
819  TRACE("'NoDisplayClass' value found!\n");
820  RegCloseKey(hClassKey);
821  continue;
822  }
823 
824  RegCloseKey(hClassKey);
825 
826  TRACE("Guid: %s\n", debugstr_w(szKeyName));
827  if (dwGuidListIndex < ClassGuidListSize)
828  {
829  if (szKeyName[0] == '{' && szKeyName[37] == '}')
830  {
831  szKeyName[37] = 0;
832  }
833  TRACE("Guid: %p\n", &szKeyName[1]);
834 
835  UuidFromStringW(&szKeyName[1],
836  &ClassGuidList[dwGuidListIndex]);
837  }
838 
839  dwGuidListIndex++;
840  }
841 
842  if (lError != ERROR_SUCCESS)
843  break;
844  }
845 
846  RegCloseKey(hClassesKey);
847 
848  if (RequiredSize != NULL)
849  *RequiredSize = dwGuidListIndex;
850 
851  if (ClassGuidListSize < dwGuidListIndex)
852  {
854  return FALSE;
855  }
856 
857  return TRUE;
858 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define REGSTR_VAL_NOUSECLASS
Definition: regstr.h:238
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
DWORD DWORD
Definition: winlogon.h:84
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
RPC_STATUS WINAPI UuidFromStringW(RPC_WSTR s, UUID *uuid)
Definition: rpcrt4_main.c:615
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define DIOCR_INSTALLER
Definition: setupapi.h:176
smooth NULL
Definition: ftsmooth.c:416
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1276
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
#define TRACE(s)
Definition: solgame.cpp:4
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
static DWORD DWORD * dwLength
Definition: fusion.c:83
HANDLE HKEY
Definition: registry.h:24
#define SetLastError(x)
Definition: compat.h:409
ULONG PVOID Reserved
Definition: ntimage.h:533
#define DIBCI_NODISPLAYCLASS
Definition: setupapi.h:109
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define DIBCI_NOINSTALLCLASS
Definition: setupapi.h:108
#define REGSTR_VAL_NOINSTALLCLASS
Definition: regstr.h:239
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define REGSTR_VAL_NODISPLAYCLASS
Definition: regstr.h:240
HKEY WINAPI SetupDiOpenClassRegKeyExW(const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:3796
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:2541
static HKEY hClassKey
Definition: umpnpmgr.c:66
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL WINAPI SetupDiCallClassInstaller ( DI_FUNCTION  InstallFunction,
HDEVINFO  DeviceInfoSet,
PSP_DEVINFO_DATA  DeviceInfoData 
)

Definition at line 4158 of file devinst.c.

Referenced by DisableNetworkAdapter(), CDeviceNode::EnableDevice(), EnableDevice(), EnumerateDrivers(), InstallCurrentDriver(), InstallSoftwareBusPnpEnumerator(), StartDevice(), CDeviceNode::UninstallDevice(), UpdateDevInfo(), and UpdateDriverDetailsDlg().

4162 {
4163  BOOL ret = FALSE;
4164 
4165  TRACE("%u %p %p\n", InstallFunction, DeviceInfoSet, DeviceInfoData);
4166 
4167  if (!DeviceInfoSet)
4173  else if (((struct DeviceInfoSet *)DeviceInfoSet)->HKLM != HKEY_LOCAL_MACHINE)
4175  else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
4177  else
4178  {
4180 #define CLASS_COINSTALLER 0x1
4181 #define DEVICE_COINSTALLER 0x2
4182 #define CLASS_INSTALLER 0x4
4183  UCHAR CanHandle = 0;
4184  DEFAULT_CLASS_INSTALL_PROC DefaultHandler = NULL;
4185 
4186  switch (InstallFunction)
4187  {
4190  break;
4193  break;
4194  case DIF_ALLOW_INSTALL:
4195  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4196  break;
4197  case DIF_DETECT:
4198  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4199  break;
4201  CanHandle = CLASS_INSTALLER;
4202  break;
4203  case DIF_INSTALLDEVICE:
4205  DefaultHandler = SetupDiInstallDevice;
4206  break;
4208  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4209  DefaultHandler = SetupDiInstallDriverFiles;
4210  break;
4211  case DIF_INSTALLINTERFACES:
4213  DefaultHandler = SetupDiInstallDeviceInterfaces;
4214  break;
4217  break;
4219  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4220  break;
4222  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4223  break;
4225  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4226  break;
4228  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4229  break;
4230  case DIF_POWERMESSAGEWAKE:
4232  break;
4233  case DIF_PROPERTYCHANGE:
4235  DefaultHandler = SetupDiChangeState;
4236  break;
4238  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4239  DefaultHandler = SetupDiRegisterCoDeviceInstallers;
4240  break;
4241  case DIF_REGISTERDEVICE:
4242  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4243  DefaultHandler = IntSetupDiRegisterDeviceInfo;
4244  break;
4245  case DIF_REMOVE:
4247  DefaultHandler = SetupDiRemoveDevice;
4248  break;
4250  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4251  DefaultHandler = SetupDiSelectBestCompatDrv;
4252  break;
4253  case DIF_SELECTDEVICE:
4254  CanHandle = CLASS_COINSTALLER | CLASS_INSTALLER;
4255  DefaultHandler = SetupDiSelectDevice;
4256  break;
4257  case DIF_TROUBLESHOOTER:
4259  break;
4260  case DIF_UNREMOVE:
4262  DefaultHandler = SetupDiUnremoveDevice;
4263  break;
4264  default:
4265  ERR("Install function %u not supported\n", InstallFunction);
4267  }
4268 
4269  InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
4270  if (!SetupDiGetDeviceInstallParamsW(DeviceInfoSet, DeviceInfoData, &InstallParams))
4271  /* Don't process this call, as a parameter is invalid */
4272  CanHandle = 0;
4273 
4274  if (CanHandle != 0)
4275  {
4276  LIST_ENTRY ClassCoInstallersListHead;
4277  LIST_ENTRY DeviceCoInstallersListHead;
4278  HMODULE ClassInstallerLibrary = NULL;
4279  CLASS_INSTALL_PROC ClassInstaller = NULL;
4282  HKEY hKey;
4283  DWORD dwRegType, dwLength;
4284  DWORD rc = NO_ERROR;
4285 
4286  InitializeListHead(&ClassCoInstallersListHead);
4287  InitializeListHead(&DeviceCoInstallersListHead);
4288 
4289  if (CanHandle & DEVICE_COINSTALLER)
4290  {
4292  if (hKey != INVALID_HANDLE_VALUE)
4293  {
4294  rc = RegQueryValueExW(hKey, REGSTR_VAL_COINSTALLERS_32, NULL, &dwRegType, NULL, &dwLength);
4295  if (rc == ERROR_SUCCESS && dwRegType == REG_MULTI_SZ)
4296  {
4297  LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
4298  if (KeyBuffer != NULL)
4299  {
4300  rc = RegQueryValueExW(hKey, REGSTR_VAL_COINSTALLERS_32, NULL, NULL, (LPBYTE)KeyBuffer, &dwLength);
4301  if (rc == ERROR_SUCCESS)
4302  {
4303  LPWSTR ptr;
4304  for (ptr = KeyBuffer; *ptr; ptr += strlenW(ptr) + 1)
4305  {
4306  /* Add coinstaller to DeviceCoInstallersListHead list */
4307  struct CoInstallerElement *coinstaller;
4308  TRACE("Got device coinstaller '%s'\n", debugstr_w(ptr));
4309  coinstaller = HeapAlloc(GetProcessHeap(), 0, sizeof(struct CoInstallerElement));
4310  if (!coinstaller)
4311  continue;
4312  ZeroMemory(coinstaller, sizeof(struct CoInstallerElement));
4313  if (GetFunctionPointer(ptr, &coinstaller->Module, (PVOID*)&coinstaller->Function) == ERROR_SUCCESS)
4314  InsertTailList(&DeviceCoInstallersListHead, &coinstaller->ListEntry);
4315  else
4316  HeapFree(GetProcessHeap(), 0, coinstaller);
4317  }
4318  }
4319  HeapFree(GetProcessHeap(), 0, KeyBuffer);
4320  }
4321  }
4322  RegCloseKey(hKey);
4323  }
4324  }
4325  if (CanHandle & CLASS_COINSTALLER)
4326  {
4327  rc = RegOpenKeyExW(
4330  0, /* Options */
4332  &hKey);
4333  if (rc == ERROR_SUCCESS)
4334  {
4335  WCHAR szGuidString[40];
4336  if (pSetupStringFromGuid(&DeviceInfoData->ClassGuid, szGuidString, ARRAYSIZE(szGuidString)) == ERROR_SUCCESS)
4337  {
4338  rc = RegQueryValueExW(hKey, szGuidString, NULL, &dwRegType, NULL, &dwLength);
4339  if (rc == ERROR_SUCCESS && dwRegType == REG_MULTI_SZ)
4340  {
4341  LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
4342  if (KeyBuffer != NULL)
4343  {
4344  rc = RegQueryValueExW(hKey, szGuidString, NULL, NULL, (LPBYTE)KeyBuffer, &dwLength);
4345  if (rc == ERROR_SUCCESS)
4346  {
4347  LPWSTR ptr;
4348  for (ptr = KeyBuffer; *ptr; ptr += strlenW(ptr) + 1)
4349  {
4350  /* Add coinstaller to ClassCoInstallersListHead list */
4351  struct CoInstallerElement *coinstaller;
4352  TRACE("Got class coinstaller '%s'\n", debugstr_w(ptr));
4353  coinstaller = HeapAlloc(GetProcessHeap(), 0, sizeof(struct CoInstallerElement));
4354  if (!coinstaller)
4355  continue;
4356  ZeroMemory(coinstaller, sizeof(struct CoInstallerElement));
4357  if (GetFunctionPointer(ptr, &coinstaller->Module, (PVOID*)&coinstaller->Function) == ERROR_SUCCESS)
4358  InsertTailList(&ClassCoInstallersListHead, &coinstaller->ListEntry);
4359  else
4360  HeapFree(GetProcessHeap(), 0, coinstaller);
4361  }
4362  }
4363  HeapFree(GetProcessHeap(), 0, KeyBuffer);
4364  }
4365  }
4366  }
4367  RegCloseKey(hKey);
4368  }
4369  }
4370  if ((CanHandle & CLASS_INSTALLER) && !(InstallParams.FlagsEx & DI_FLAGSEX_CI_FAILED))
4371  {
4372  hKey = SetupDiOpenClassRegKey(&DeviceInfoData->ClassGuid, KEY_QUERY_VALUE);
4373  if (hKey != INVALID_HANDLE_VALUE)
4374  {
4375  rc = RegQueryValueExW(hKey, REGSTR_VAL_INSTALLER_32, NULL, &dwRegType, NULL, &dwLength);
4376  if (rc == ERROR_SUCCESS && dwRegType == REG_SZ)
4377  {
4378  LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
4379  if (KeyBuffer != NULL)
4380  {
4381  rc = RegQueryValueExW(hKey, REGSTR_VAL_INSTALLER_32, NULL, NULL, (LPBYTE)KeyBuffer, &dwLength);
4382  if (rc == ERROR_SUCCESS)
4383  {
4384  /* Get ClassInstaller function pointer */
4385  TRACE("Got class installer '%s'\n", debugstr_w(KeyBuffer));
4386  if (GetFunctionPointer(KeyBuffer, &ClassInstallerLibrary, (PVOID*)&ClassInstaller) != ERROR_SUCCESS)
4387  {
4388  InstallParams.FlagsEx |= DI_FLAGSEX_CI_FAILED;
4389  SetupDiSetDeviceInstallParamsW(DeviceInfoSet, DeviceInfoData, &InstallParams);
4390  }
4391  }
4392  HeapFree(GetProcessHeap(), 0, KeyBuffer);
4393  }
4394  }
4395  RegCloseKey(hKey);
4396  }
4397  }
4398 
4399  /* Call Class co-installers */
4400  Context.PostProcessing = FALSE;
4401  rc = NO_ERROR;
4402  ListEntry = ClassCoInstallersListHead.Flink;
4403  while (rc == NO_ERROR && ListEntry != &ClassCoInstallersListHead)
4404  {
4405  struct CoInstallerElement *coinstaller;
4406  coinstaller = CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry);
4407  rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4408  coinstaller->PrivateData = Context.PrivateData;
4410  {
4411  coinstaller->DoPostProcessing = TRUE;
4412  rc = NO_ERROR;
4413  }
4414  ListEntry = ListEntry->Flink;
4415  }
4416 
4417  /* Call Device co-installers */
4418  ListEntry = DeviceCoInstallersListHead.Flink;
4419  while (rc == NO_ERROR && ListEntry != &DeviceCoInstallersListHead)
4420  {
4421  struct CoInstallerElement *coinstaller;
4422  coinstaller = CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry);
4423  rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4424  coinstaller->PrivateData = Context.PrivateData;
4426  {
4427  coinstaller->DoPostProcessing = TRUE;
4428  rc = NO_ERROR;
4429  }
4430  ListEntry = ListEntry->Flink;
4431  }
4432 
4433  /* Call Class installer */
4434  if (ClassInstaller)
4435  {
4436  rc = (*ClassInstaller)(InstallFunction, DeviceInfoSet, DeviceInfoData);
4437  FreeFunctionPointer(ClassInstallerLibrary, ClassInstaller);
4438  }
4439  else
4440  rc = ERROR_DI_DO_DEFAULT;
4441 
4442  /* Call default handler */
4443  if (rc == ERROR_DI_DO_DEFAULT)
4444  {
4445  if (DefaultHandler && !(InstallParams.Flags & DI_NODI_DEFAULTACTION))
4446  {
4447  if ((*DefaultHandler)(DeviceInfoSet, DeviceInfoData))
4448  rc = NO_ERROR;
4449  else
4450  rc = GetLastError();
4451  }
4452  else
4453  rc = NO_ERROR;
4454  }
4455 
4456  /* Call Class co-installers that required postprocessing */
4457  Context.PostProcessing = TRUE;
4458  ListEntry = ClassCoInstallersListHead.Flink;
4459  while (ListEntry != &ClassCoInstallersListHead)
4460  {
4461  struct CoInstallerElement *coinstaller;
4462  coinstaller = CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry);
4463  if (coinstaller->DoPostProcessing)
4464  {
4465  Context.InstallResult = rc;
4466  Context.PrivateData = coinstaller->PrivateData;
4467  rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4468  }
4469  FreeFunctionPointer(coinstaller->Module, coinstaller->Function);
4470  ListEntry = ListEntry->Flink;
4471  }
4472 
4473  /* Call Device co-installers that required postprocessing */
4474  ListEntry = DeviceCoInstallersListHead.Flink;
4475  while (ListEntry != &DeviceCoInstallersListHead)
4476  {
4477  struct CoInstallerElement *coinstaller;
4478  coinstaller = CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry);
4479  if (coinstaller->DoPostProcessing)
4480  {
4481  Context.InstallResult = rc;
4482  Context.PrivateData = coinstaller->PrivateData;
4483  rc = (*coinstaller->Function)(InstallFunction, DeviceInfoSet, DeviceInfoData, &Context);
4484  }
4485  FreeFunctionPointer(coinstaller->Module, coinstaller->Function);
4486  ListEntry = ListEntry->Flink;
4487  }
4488 
4489  /* Free allocated memory */
4490  while (!IsListEmpty(&ClassCoInstallersListHead))
4491  {
4492  ListEntry = RemoveHeadList(&ClassCoInstallersListHead);
4493  HeapFree(GetProcessHeap(), 0, CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry));
4494  }
4495  while (!IsListEmpty(&DeviceCoInstallersListHead))
4496  {
4497  ListEntry = RemoveHeadList(&DeviceCoInstallersListHead);
4498  HeapFree(GetProcessHeap(), 0, CONTAINING_RECORD(ListEntry, struct CoInstallerElement, ListEntry));
4499  }
4500 
4501  ret = (rc == NO_ERROR);
4502  }
4503  }
4504 
4505  TRACE("Returning %d\n", ret);
4506  return ret;
4507 }
DWORD *typedef PVOID
Definition: winlogon.h:61
#define DIF_SELECTDEVICE
Definition: setupapi.h:120
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL WINAPI SetupDiSelectBestCompatDrv(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
Definition: driver.c:2063
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI SetupDiSetDeviceInstallParamsW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
Definition: devinst.c:4692
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define DIF_ADDREMOTEPROPERTYPAGE_ADVANCED
Definition: setupapi.h:159
unsigned char * LPBYTE
Definition: typedefs.h:52
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
u32_t magic(void)
HMODULE Module
Definition: devinst.c:61
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
BOOL WINAPI SetupDiUnremoveDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: stubs.c:78
#define REGSTR_PATH_CODEVICEINSTALLERS
Definition: regstr.h:480
#define DIF_NEWDEVICEWIZARD_PREANALYZE
Definition: setupapi.h:147
LIST_ENTRY ListEntry
Definition: devinst.c:59
SP_DEVINSTALL_PARAMS_W InstallParams
#define DIF_PROPERTYCHANGE
Definition: setupapi.h:137
#define InsertTailList(ListHead, Entry)
#define NO_ERROR
Definition: dderror.h:5
#define DIF_UNREMOVE
Definition: setupapi.h:141
#define DIF_NEWDEVICEWIZARD_POSTANALYZE
Definition: setupapi.h:148
#define DIF_DESTROYPRIVATEDATA
Definition: setupapi.h:131
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define SETUP_DEVICE_INFO_SET_MAGIC
DWORD DWORD
Definition: winlogon.h:84
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
COINSTALLER_PROC Function
Definition: devinst.c:62
#define FALSE
Definition: types.h:117
BOOL DoPostProcessing
Definition: devinst.c:63
#define DIF_REGISTERDEVICE
Definition: setupapi.h:144
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define debugstr_w
Definition: kernel32.h:32
#define REGSTR_VAL_INSTALLER_32
Definition: regstr.h:487
BOOL WINAPI SetupDiInstallDevice(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5461
static PVOID ptr
Definition: dispmode.c:27
BOOL WINAPI SetupDiGetDeviceInstallParamsW(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, OUT PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
Definition: devinst.c:4585
static BOOL WINAPI IntSetupDiRegisterDeviceInfo(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:4148
#define DIF_REGISTER_COINSTALLERS
Definition: setupapi.h:153
smooth NULL
Definition: ftsmooth.c:416
#define DIF_ADDPROPERTYPAGE_ADVANCED
Definition: setupapi.h:154
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
#define DIF_NEWDEVICEWIZARD_FINISHINSTALL
Definition: setupapi.h:149
#define DIF_NEWDEVICEWIZARD_SELECT
Definition: setupapi.h:146
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
PVOID PrivateData
Definition: devinst.c:64
static const WCHAR HKLM[]
Definition: reginf.c:54
#define DIF_INSTALLDEVICE
Definition: setupapi.h:121
IN HDEVINFO IN PSP_DEVINFO_DATA DeviceInfoData IN OUT PCOINSTALLER_CONTEXT_DATA Context
Definition: devinst.c:53
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
#define DI_NODI_DEFAULTACTION
Definition: setupapi.h:67
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
static DWORD DWORD * dwLength
Definition: fusion.c:83
HANDLE HKEY
Definition: registry.h:24
DWORD FreeFunctionPointer(IN HMODULE ModulePointer, IN PVOID FunctionPointer)
Definition: misc.c:105
DWORD GetFunctionPointer(IN PWSTR InstallerName, OUT HMODULE *ModulePointer, OUT PVOID *FunctionPointer)
Definition: misc.c:44
PVOID HDEVINFO
Definition: setupapi.h:664
#define DIF_TROUBLESHOOTER
Definition: setupapi.h:157
#define SetLastError(x)
Definition: compat.h:409
DWORD WINAPI pSetupStringFromGuid(LPGUID lpGUID, PWSTR pString, DWORD dwStringLen)
Definition: misc.c:1754
BOOL WINAPI SetupDiRegisterCoDeviceInstallers(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5315
IN HDEVINFO DeviceInfoSet
Definition: devinst.c:44
unsigned char UCHAR
Definition: xmlstorage.h:181
int ret
#define DIF_POWERMESSAGEWAKE
Definition: setupapi.h:158
BOOL WINAPI SetupDiChangeState(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5189
HKEY WINAPI SetupDiOpenDevRegKey(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, REGSAM samDesired)
Definition: devinst.c:5848
Definition: typedefs.h:117
#define ERR(fmt,...)
Definition: debug.h:109
#define DIF_INSTALLINTERFACES
Definition: setupapi.h:151
#define DICS_FLAG_GLOBAL
Definition: setupapi.h:113
BOOL WINAPI SetupDiSelectDevice(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
Definition: devinst.c:5301
BOOL WINAPI SetupDiRemoveDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: stubs.c:64
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
BOOL WINAPI SetupDiInstallDeviceInterfaces(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: interface.c:414
#define DI_FLAGSEX_CI_FAILED
Definition: setupapi.h:79
HANDLE HMODULE
Definition: typedefs.h:75
#define DEVICE_COINSTALLER
struct _SP_DEVINSTALL_PARAMS_W SP_DEVINSTALL_PARAMS_W
LIST_ENTRY ListEntry
#define ERROR_DI_DO_DEFAULT
Definition: setupapi.h:305
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90
#define CLASS_INSTALLER
#define DIF_ALLOW_INSTALL
Definition: setupapi.h:143
#define DIF_REMOVE
Definition: setupapi.h:124
#define DIREG_DRV
Definition: setupapi.h:182
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define DIF_NEWDEVICEWIZARD_PRESELECT
Definition: setupapi.h:145
#define DIF_SELECTBESTCOMPATDRV
Definition: setupapi.h:142
IN OUT PSP_DEVINFO_DATA DeviceInfoData
Definition: devinst.c:49
#define DIF_DETECT
Definition: setupapi.h:134
#define ERROR_DI_POSTPROCESSING_REQUIRED
Definition: setupapi.h:329
BOOL WINAPI SetupDiInstallDriverFiles(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: driver.c:2099
#define DIF_INSTALLDEVICEFILES
Definition: setupapi.h:140
#define REGSTR_VAL_COINSTALLERS_32
Definition: regstr.h:484
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394
HKEY WINAPI SetupDiOpenClassRegKey(const GUID *ClassGuid, REGSAM samDesired)
Definition: devinst.c:3752
#define CLASS_COINSTALLER
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22
BOOL WINAPI SetupDiChangeState ( IN HDEVINFO  DeviceInfoSet,
IN OUT PSP_DEVINFO_DATA  DeviceInfoData 
)

Definition at line 5189 of file devinst.c.

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

5192 {
5193  PSP_PROPCHANGE_PARAMS PropChange;
5194  HKEY hKey = INVALID_HANDLE_VALUE;
5195  LPCWSTR RegistryValueName;
5196  DWORD dwConfigFlags, dwLength, dwRegType;
5197  LONG rc;
5198  BOOL ret = FALSE;
5199 
5200  TRACE("%p %p\n", DeviceInfoSet, DeviceInfoData);
5201 
5202  if (!DeviceInfoData)
5203  PropChange = ((struct DeviceInfoSet *)DeviceInfoSet)->ClassInstallParams.PropChangeParams;
5204  else
5205  PropChange = ((struct DeviceInfo *)DeviceInfoData->Reserved)->ClassInstallParams.PropChangeParams;
5206  if (!PropChange)
5207  {
5209  goto cleanup;
5210  }
5211 
5212  if (PropChange->Scope == DICS_FLAG_GLOBAL)
5213  RegistryValueName = REGSTR_VAL_CONFIGFLAGS;
5214  else
5215  RegistryValueName = REGSTR_VAL_CSCONFIGFLAGS;
5216 
5217  switch (PropChange->StateChange)
5218  {
5219  case DICS_ENABLE:
5220  case DICS_DISABLE:
5221  {
5222  /* Enable/disable device in registry */
5225  hKey = SetupDiCreateDevRegKeyW(DeviceInfoSet, DeviceInfoData, PropChange->Scope, PropChange->HwProfile, DIREG_DEV, NULL, NULL);
5226  if (hKey == INVALID_HANDLE_VALUE)
5227  break;
5228  dwLength = sizeof(DWORD);
5229  rc = RegQueryValueExW(
5230  hKey,
5231  RegistryValueName,
5232  NULL,
5233  &dwRegType,
5234  (LPBYTE)&dwConfigFlags, &dwLength);
5235  if (rc == ERROR_FILE_NOT_FOUND)
5236  dwConfigFlags = 0;
5237  else if (rc != ERROR_SUCCESS)
5238  {
5239  SetLastError(rc);
5240  goto cleanup;
5241  }
5242  else if (dwRegType != REG_DWORD || dwLength != sizeof(DWORD))
5243  {
5245  goto cleanup;
5246  }
5247  if (PropChange->StateChange == DICS_ENABLE)
5248  dwConfigFlags &= ~(PropChange->Scope == DICS_FLAG_GLOBAL ? CONFIGFLAG_DISABLED : CSCONFIGFLAG_DISABLED);
5249  else
5250  dwConfigFlags |= (PropChange->Scope == DICS_FLAG_GLOBAL ? CONFIGFLAG_DISABLED : CSCONFIGFLAG_DISABLED);
5251  rc = RegSetValueExW(
5252  hKey,
5253  RegistryValueName,
5254  0,
5255  REG_DWORD,
5256  (LPBYTE)&dwConfigFlags, sizeof(DWORD));
5257  if (rc != ERROR_SUCCESS)
5258  {
5259  SetLastError(rc);
5260  goto cleanup;
5261  }
5262 
5263  /* Enable/disable device if needed */
5264  if (PropChange->Scope == DICS_FLAG_GLOBAL
5265  || PropChange->HwProfile == 0
5267  {
5268  if (PropChange->StateChange == DICS_ENABLE)
5270  else
5272  }
5273  else
5274  ret = TRUE;
5275  break;
5276  }
5277  case DICS_PROPCHANGE:
5278  {
5280  break;
5281  }
5282  default:
5283  {
5284  ERR("Unknown StateChange 0x%lx\n", PropChange->StateChange);
5286  }
5287  }
5288 
5289 cleanup:
5290  if (hKey != INVALID_HANDLE_VALUE)
5291  RegCloseKey(hKey);
5292 
5293  TRACE("Returning %d\n", ret);
5294  return ret;
5295 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static const GUID DWORD
Definition: devinst.c:39
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
unsigned char * LPBYTE
Definition: typedefs.h:52
static DWORD SETUPAPI_GetCurrentHwProfile(IN HDEVINFO DeviceInfoSet)
Definition: devinst.c:5107
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define REGSTR_VAL_CONFIGFLAGS
Definition: regstr.h:388
#define CSCONFIGFLAG_DISABLED
Definition: regstr.h:401
#define DICS_ENABLE
Definition: setupapi.h:112
#define REGSTR_VAL_CSCONFIGFLAGS
Definition: regstr.h:389
DWORD DWORD
Definition: winlogon.h:84
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
#define DICS_DISABLE
Definition: setupapi.h:114
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
HKEY WINAPI SetupDiCreateDevRegKeyW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, HINF InfHandle, PCWSTR InfSectionName)
Definition: devinst.c:1405
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:4917
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CONFIGFLAG_DISABLED
Definition: regstr.h:390
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
static DWORD DWORD * dwLength
Definition: fusion.c:83
HANDLE HKEY
Definition: registry.h:24
#define DIREG_DEV
Definition: setupapi.h:181
BOOLEAN ResetDevice(IN LPCWSTR DeviceId)
Definition: devinst.c:19
#define SetLastError(x)
Definition: compat.h:409
int ret
HKEY WINAPI SetupDiOpenDevRegKey(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, REGSAM samDesired)
Definition: devinst.c:5848
#define ERR(fmt,...)
Definition: debug.h:109
#define DICS_FLAG_GLOBAL
Definition: setupapi.h:113
#define DICS_PROPCHANGE
Definition: setupapi.h:116
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90
char * cleanup(char *str)
Definition: wpickclick.c:99
IN OUT PSP_DEVINFO_DATA DeviceInfoData
Definition: devinst.c:49
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
#define REG_DWORD
Definition: sdbapi.c:539
static BOOL StopDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5177
BOOL WINAPI SetupDiClassGuidsFromNameA ( LPCSTR  ClassName,
LPGUID  ClassGuidList,
DWORD  ClassGuidListSize,
PDWORD  RequiredSize 
)

Definition at line 863 of file devinst.c.

Referenced by test_SetupDiClassGuidsFromNameA().

868 {
869  return SetupDiClassGuidsFromNameExA(ClassName, ClassGuidList,
871  NULL, NULL);
872 }
smooth NULL
Definition: ftsmooth.c:416
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1276
BOOL WINAPI SetupDiClassGuidsFromNameExA(LPCSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCSTR MachineName, PVOID Reserved)
Definition: devinst.c:891
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
BOOL WINAPI SetupDiClassGuidsFromNameExA ( LPCSTR  ClassName,
LPGUID  ClassGuidList,
DWORD  ClassGuidListSize,
PDWORD  RequiredSize,
LPCSTR  MachineName,
PVOID  Reserved 
)

Definition at line 891 of file devinst.c.

Referenced by SetupDiClassGuidsFromNameA().

898 {
899  LPWSTR ClassNameW = NULL;
900  LPWSTR MachineNameW = NULL;
901  BOOL bResult;
902 
903  TRACE("%s %p %lu %p %s %p\n", debugstr_a(ClassName), ClassGuidList,
905 
906  if (!ClassName)
907  {
909  return FALSE;
910  }
911 
912  ClassNameW = pSetupMultiByteToUnicode(ClassName, CP_ACP);
913  if (ClassNameW == NULL)
914  return FALSE;
915 
916  if (MachineName)
917  {
919  if (MachineNameW == NULL)
920  {
921  MyFree(ClassNameW);
922  return FALSE;
923  }
924  }
925 
926  bResult = SetupDiClassGuidsFromNameExW(ClassNameW, ClassGuidList,
928  MachineNameW, Reserved);
929 
930  MyFree(MachineNameW);
931  MyFree(ClassNameW);
932 
933  return bResult;
934 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CP_ACP
Definition: compat.h:99
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
#define FALSE
Definition: types.h:117
LPWSTR WINAPI pSetupMultiByteToUnicode(LPCSTR lpMultiByteStr, UINT uCodePage)
Definition: misc.c:281
smooth NULL
Definition: ftsmooth.c:416
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1276
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_a
Definition: kernel32.h:31
#define SetLastError(x)
Definition: compat.h:409
ULONG PVOID Reserved
Definition: ntimage.h:533
WCHAR * LPWSTR
Definition: xmlstorage.h:184
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
BOOL WINAPI SetupDiClassGuidsFromNameExW(LPCWSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:939
BOOL WINAPI SetupDiClassGuidsFromNameExW ( LPCWSTR  ClassName,
LPGUID  ClassGuidList,
DWORD  ClassGuidListSize,
PDWORD  RequiredSize,
LPCWSTR  MachineName,
PVOID  Reserved 
)

Definition at line 939 of file devinst.c.

Referenced by SetupDiClassGuidsFromNameExA(), and SetupDiClassGuidsFromNameW().

946 {
947  WCHAR szKeyName[40];
949  HKEY hClassesKey;
950  HKEY hClassKey;
951  DWORD dwLength;
952  DWORD dwIndex;
953  LONG lError;
954  DWORD dwGuidListIndex = 0;
955 
956  TRACE("%s %p %lu %p %s %p\n", debugstr_w(ClassName), ClassGuidList,
958 
959  if (!ClassName || !RequiredSize)
960  {
962  return FALSE;
963  }
964  if (!ClassGuidList && ClassGuidListSize > 0)
965  {
967  return FALSE;
968  }
969  *RequiredSize = 0;
970 
971  hClassesKey = SetupDiOpenClassRegKeyExW(NULL,
974  MachineName,
975  Reserved);
976  if (hClassesKey == INVALID_HANDLE_VALUE)
977  {
978  return FALSE;
979  }
980 
981  for (dwIndex = 0; ; dwIndex++)
982  {
983  dwLength = 40;
984  lError = RegEnumKeyExW(hClassesKey,
985  dwIndex,
986  szKeyName,
987  &dwLength,
988  NULL,
989  NULL,
990  NULL,
991  NULL);
992  TRACE("RegEnumKeyExW() returns %d\n", lError);
993  if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA)
994  {
995  TRACE("Key name: %p\n", szKeyName);
996 
997  if (RegOpenKeyExW(hClassesKey,
998  szKeyName,
999  0,
1001  &hClassKey))
1002  {
1003  RegCloseKey(hClassesKey);
1004  return FALSE;
1005  }
1006 
1007  dwLength = MAX_CLASS_NAME_LEN * sizeof(WCHAR);
1008  if (!RegQueryValueExW(hClassKey,
1010  NULL,
1011  NULL,
1012  (LPBYTE)szClassName,
1013  &dwLength))
1014  {
1015  TRACE("Class name: %p\n", szClassName);
1016 
1017  if (strcmpiW(szClassName, ClassName) == 0)
1018  {
1019  TRACE("Found matching class name\n");
1020 
1021  TRACE("Guid: %p\n", szKeyName);
1022  if (dwGuidListIndex < ClassGuidListSize)
1023  {
1024  if (szKeyName[0] == '{' && szKeyName[37] == '}')
1025  {
1026  szKeyName[37] = 0;
1027  }
1028  TRACE("Guid: %p\n", &szKeyName[1]);
1029 
1030  UuidFromStringW(&szKeyName[1],
1031  &ClassGuidList[dwGuidListIndex]);
1032  }
1033 
1034  dwGuidListIndex++;
1035  }
1036  }
1037 
1038  RegCloseKey(hClassKey);
1039  }
1040 
1041  if (lError != ERROR_SUCCESS)
1042  break;
1043  }
1044 
1045  RegCloseKey(hClassesKey);
1046 
1047  if (RequiredSize != NULL)
1048  *RequiredSize = dwGuidListIndex;
1049 
1050  if (ClassGuidListSize < dwGuidListIndex)
1051  {
1053  return FALSE;
1054  }
1055 
1056  return TRUE;
1057 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define REGSTR_VAL_CLASS
Definition: regstr.h:291
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char * LPBYTE
Definition: typedefs.h:52
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
#define WCHAR
Definition: msvc.h:43
DWORD DWORD
Definition: winlogon.h:84
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
RPC_STATUS WINAPI UuidFromStringW(RPC_WSTR s, UUID *uuid)
Definition: rpcrt4_main.c:615
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define DIOCR_INSTALLER
Definition: setupapi.h:176
smooth NULL
Definition: ftsmooth.c:416
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1276
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
#define TRACE(s)
Definition: solgame.cpp:4
static const WCHAR szClassName[]
Definition: clipbrd.c:11
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
static DWORD DWORD * dwLength
Definition: fusion.c:83
HANDLE HKEY
Definition: registry.h:24
#define SetLastError(x)
Definition: compat.h:409
ULONG PVOID Reserved
Definition: ntimage.h:533
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
HKEY WINAPI SetupDiOpenClassRegKeyExW(const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:3796
#define MAX_CLASS_NAME_LEN
Definition: cfgmgr32.h:52
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:2541
static HKEY hClassKey
Definition: umpnpmgr.c:66
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL WINAPI SetupDiClassGuidsFromNameW ( LPCWSTR  ClassName,
LPGUID  ClassGuidList,
DWORD  ClassGuidListSize,
PDWORD  RequiredSize 
)

Definition at line 877 of file devinst.c.

882 {
883  return SetupDiClassGuidsFromNameExW(ClassName, ClassGuidList,
885  NULL, NULL);
886 }
smooth NULL
Definition: ftsmooth.c:416
_In_ DWORD ClassGuidListSize
Definition: setupapi.h:1276
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
BOOL WINAPI SetupDiClassGuidsFromNameExW(LPCWSTR ClassName, LPGUID ClassGuidList, DWORD ClassGuidListSize, PDWORD RequiredSize, LPCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:939
BOOL WINAPI SetupDiClassNameFromGuidA ( const GUID ClassGuid,
PSTR  ClassName,
DWORD  ClassNameSize,
PDWORD  RequiredSize 
)

Definition at line 1062 of file devinst.c.

Referenced by test_SetupDiBuildClassInfoList(), and test_SetupDiClassNameFromGuidA().

1067 {
1068  return SetupDiClassNameFromGuidExA(ClassGuid, ClassName,
1069  ClassNameSize, RequiredSize,
1070  NULL, NULL);
1071 }
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
BOOL WINAPI SetupDiClassNameFromGuidExA(const GUID *ClassGuid, PSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize, PCSTR MachineName, PVOID Reserved)
Definition: devinst.c:1090
BOOL WINAPI SetupDiClassNameFromGuidExA ( const GUID ClassGuid,
PSTR  ClassName,
DWORD  ClassNameSize,
PDWORD  RequiredSize,
PCSTR  MachineName,
PVOID  Reserved 
)

Definition at line 1090 of file devinst.c.

Referenced by SetupDiClassNameFromGuidA().

1097 {
1098  WCHAR ClassNameW[MAX_CLASS_NAME_LEN];
1099  LPWSTR MachineNameW = NULL;
1100  BOOL ret;
1101 
1102  if (MachineName)
1103  MachineNameW = pSetupMultiByteToUnicode(MachineName, CP_ACP);
1104  ret = SetupDiClassNameFromGuidExW(ClassGuid, ClassNameW, MAX_CLASS_NAME_LEN,
1105  RequiredSize, MachineNameW, Reserved);
1106  if (ret)
1107  {
1108  int len = WideCharToMultiByte(CP_ACP, 0, ClassNameW, -1, ClassName,
1109  ClassNameSize, NULL, NULL);
1110  if (len == 0 || len > ClassNameSize)
1111  {
1113  ret = FALSE;
1114  }
1115  }
1116  MyFree(MachineNameW);
1117  return ret;
1118 }
#define WideCharToMultiByte
Definition: compat.h:101
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CP_ACP
Definition: compat.h:99
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
BOOL WINAPI SetupDiClassNameFromGuidExW(const GUID *ClassGuid, PWSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:1123
#define FALSE
Definition: types.h:117
LPWSTR WINAPI pSetupMultiByteToUnicode(LPCSTR lpMultiByteStr, UINT uCodePage)
Definition: misc.c:281
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SetLastError(x)
Definition: compat.h:409
ULONG PVOID Reserved
Definition: ntimage.h:533
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define MAX_CLASS_NAME_LEN
Definition: cfgmgr32.h:52
WCHAR * LPWSTR
Definition: xmlstorage.h:184
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL WINAPI SetupDiClassNameFromGuidExW ( const GUID ClassGuid,
PWSTR  ClassName,
DWORD  ClassNameSize,
PDWORD  RequiredSize,
PCWSTR  MachineName,
PVOID  Reserved 
)

Definition at line 1123 of file devinst.c.

Referenced by SetupDiClassNameFromGuidExA(), and SetupDiClassNameFromGuidW().

1130 {
1131  HKEY hKey;
1132  DWORD dwLength;
1133  DWORD dwRegType;
1134  LONG rc;
1135  PWSTR Buffer;
1136 
1137  TRACE("%s %p %lu %p %s %p\n", debugstr_guid(ClassGuid), ClassName,
1138  ClassNameSize, RequiredSize, debugstr_w(MachineName), Reserved);
1139 
1140  /* Make sure there's a GUID */
1141  if (ClassGuid == NULL)
1142  {
1143  SetLastError(ERROR_INVALID_CLASS); /* On Vista: ERROR_INVALID_USER_BUFFER */
1144  return FALSE;
1145  }
1146 
1147  /* Make sure there's a real buffer when there's a size */
1148  if ((ClassNameSize > 0) && (ClassName == NULL))
1149  {
1150  SetLastError(ERROR_INVALID_PARAMETER); /* On Vista: ERROR_INVALID_USER_BUFFER */
1151  return FALSE;
1152  }
1153 
1154  /* Open the key for the GUID */
1156 
1157  if (hKey == INVALID_HANDLE_VALUE)
1158  return FALSE;
1159 
1160  /* Retrieve the class name data and close the key */
1161  rc = QueryRegistryValue(hKey, REGSTR_VAL_CLASS, (LPBYTE *) &Buffer, &dwRegType, &dwLength);
1162  RegCloseKey(hKey);
1163 
1164  /* Make sure we got the data */
1165  if (rc != ERROR_SUCCESS)
1166  {
1167  SetLastError(rc);
1168  return FALSE;
1169  }
1170 
1171  /* Make sure the data is a string */
1172  if (dwRegType != REG_SZ)
1173  {
1174  MyFree(Buffer);
1176  return FALSE;
1177  }
1178 
1179  /* Determine the length of the class name */
1180  dwLength /= sizeof(WCHAR);
1181 
1182  if ((dwLength == 0) || (Buffer[dwLength - 1] != UNICODE_NULL))
1183  /* Count the null-terminator */
1184  dwLength++;
1185 
1186  /* Inform the caller about the class name */
1187  if ((ClassName != NULL) && (dwLength <= ClassNameSize))
1188  {
1189  memcpy(ClassName, Buffer, (dwLength - 1) * sizeof(WCHAR));
1190  ClassName[dwLength - 1] = UNICODE_NULL;
1191  }
1192 
1193  /* Inform the caller about the required size */
1194  if (RequiredSize != NULL)
1196 
1197  /* Clean up the buffer */
1198  MyFree(Buffer);
1199 
1200  /* Make sure the buffer was large enough */
1201  if ((ClassName == NULL) || (dwLength > ClassNameSize))
1202  {
1204  return FALSE;
1205  }
1206 
1207  return TRUE;
1208 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define REGSTR_VAL_CLASS
Definition: regstr.h:291
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char * LPBYTE
Definition: typedefs.h:52
PVOID *typedef PWSTR
Definition: winlogon.h:66
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
#define WCHAR
Definition: msvc.h:43
DWORD DWORD
Definition: winlogon.h:84
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define DIOCR_INSTALLER
Definition: setupapi.h:176
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
PVOID QueryRegistryValue(HANDLE RegHandle, PWCHAR ValueName, LPDWORD RegistryType, LPDWORD Length)
Definition: registry.c:67
#define TRACE(s)
Definition: solgame.cpp:4
static DWORD DWORD * dwLength
Definition: fusion.c:83
HANDLE HKEY
Definition: registry.h:24
#define SetLastError(x)
Definition: compat.h:409
ULONG PVOID Reserved
Definition: ntimage.h:533
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define ERROR_INVALID_CLASS
Definition: setupapi.h:297
HKEY WINAPI SetupDiOpenClassRegKeyExW(const GUID *ClassGuid, REGSAM samDesired, DWORD Flags, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:3796
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define REG_SZ
Definition: layer.c:22
BOOL WINAPI SetupDiClassNameFromGuidW ( const GUID ClassGuid,
PWSTR  ClassName,
DWORD  ClassNameSize,
PDWORD  RequiredSize 
)

Definition at line 1076 of file devinst.c.

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

1081 {
1082  return SetupDiClassNameFromGuidExW(ClassGuid, ClassName,
1083  ClassNameSize, RequiredSize,
1084  NULL, NULL);
1085 }
BOOL WINAPI SetupDiClassNameFromGuidExW(const GUID *ClassGuid, PWSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:1123
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
BOOL WINAPI SetupDiCreateDeviceInfoA ( HDEVINFO  DeviceInfoSet,
PCSTR  DeviceName,
CONST GUID ClassGuid,
PCSTR  DeviceDescription,
HWND  hwndParent,
DWORD  CreationFlags,
PSP_DEVINFO_DATA  DeviceInfoData 
)

Definition at line 1670 of file devinst.c.

1678 {
1679  BOOL ret;
1680  LPWSTR DeviceNameW = NULL;
1681  LPWSTR DeviceDescriptionW = NULL;
1682 
1683  TRACE("\n");
1684 
1685  if (DeviceName)
1686  {
1687  DeviceNameW = pSetupMultiByteToUnicode(DeviceName, CP_ACP);
1688  if (DeviceNameW == NULL) return FALSE;
1689  }
1690  if (DeviceDescription)
1691  {
1692  DeviceDescriptionW = pSetupMultiByteToUnicode(DeviceDescription, CP_ACP);
1693  if (DeviceDescriptionW == NULL)
1694  {
1695  MyFree(DeviceNameW);
1696  return FALSE;
1697  }
1698  }
1699 
1700  ret = SetupDiCreateDeviceInfoW(DeviceInfoSet, DeviceNameW, ClassGuid, DeviceDescriptionW,
1701  hwndParent, CreationFlags, DeviceInfoData);
1702 
1703  MyFree(DeviceNameW);
1704  MyFree(DeviceDescriptionW);
1705 
1706  return ret;
1707 }
#define CP_ACP
Definition: compat.h:99
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define FALSE
Definition: types.h:117
LPWSTR WINAPI pSetupMultiByteToUnicode(LPCSTR lpMultiByteStr, UINT uCodePage)
Definition: misc.c:281
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
_Must_inspect_result_ _In_ PDEVICE_DESCRIPTION DeviceDescription
Definition: iofuncs.h:1015
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
int ret
BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO DeviceInfoSet, PCWSTR DeviceName, CONST GUID *ClassGuid, PCWSTR DeviceDescription, HWND hwndParent, DWORD CreationFlags, PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:1712
WCHAR * LPWSTR
Definition: xmlstorage.h:184
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
HDEVINFO WINAPI SetupDiCreateDeviceInfoList ( const GUID ClassGuid,
HWND  hwndParent 
)

Definition at line 1214 of file devinst.c.

Referenced by InstallSoftwareBusPnpEnumerator(), and SetupDiInstallClassExW().

1216 {
1217  return SetupDiCreateDeviceInfoListExW(ClassGuid, hwndParent, NULL, NULL);
1218 }
HDEVINFO WINAPI SetupDiCreateDeviceInfoListExW(const GUID *ClassGuid, HWND hwndParent, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:1268
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
HDEVINFO WINAPI SetupDiCreateDeviceInfoListExA ( const GUID ClassGuid,
HWND  hwndParent,
PCSTR  MachineName,
PVOID  Reserved 
)

Definition at line 1224 of file devinst.c.

1228 {
1229  LPWSTR MachineNameW = NULL;
1230  HDEVINFO hDevInfo;
1231 
1232  TRACE("%s %p %s %p\n", debugstr_guid(ClassGuid), hwndParent,
1234 
1235  if (MachineName)
1236  {
1237  MachineNameW = pSetupMultiByteToUnicode(MachineName, CP_ACP);
1238  if (MachineNameW == NULL)
1239  return INVALID_HANDLE_VALUE;
1240  }
1241 
1242  hDevInfo = SetupDiCreateDeviceInfoListExW(ClassGuid, hwndParent,
1243  MachineNameW, Reserved);
1244 
1245  MyFree(MachineNameW);
1246 
1247  return hDevInfo;
1248 }
#define CP_ACP
Definition: compat.h:99
HDEVINFO WINAPI SetupDiCreateDeviceInfoListExW(const GUID *ClassGuid, HWND hwndParent, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:1268
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
LPWSTR WINAPI pSetupMultiByteToUnicode(LPCSTR lpMultiByteStr, UINT uCodePage)
Definition: misc.c:281
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
PVOID HDEVINFO
Definition: setupapi.h:664
ULONG PVOID Reserved
Definition: ntimage.h:533
WCHAR * LPWSTR
Definition: xmlstorage.h:184
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
HDEVINFO WINAPI SetupDiCreateDeviceInfoListExW ( const GUID ClassGuid,
HWND  hwndParent,
PCWSTR  MachineName,
PVOID  Reserved 
)

Definition at line 1268 of file devinst.c.

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

1272 {
1273  struct DeviceInfoSet *list = NULL;
1275  DWORD rc;
1276  CONFIGRET cr;
1278 
1279  TRACE("%s %p %s %p\n", debugstr_guid(ClassGuid), hwndParent,
1281 
1282  if (MachineName != NULL)
1283  {
1285  if (len >= SP_MAX_MACHINENAME_LENGTH - 4)
1286  {
1288  goto cleanup;
1289  }
1290  if(len > 0)
1291  size += (len + 3) * sizeof(WCHAR);
1292  else
1293  MachineName = NULL;
1294  }
1295 
1296  if (Reserved != NULL)
1297  {
1299  return INVALID_HANDLE_VALUE;
1300  }
1301 
1302  list = MyMalloc(size);
1303  if (!list)
1304  {
1306  return INVALID_HANDLE_VALUE;
1307  }
1308  ZeroMemory(list, FIELD_OFFSET(struct DeviceInfoSet, szData));
1309 
1311  memcpy(&list->ClassGuid,
1312  ClassGuid ? ClassGuid : &GUID_NULL,
1313  sizeof(list->ClassGuid));
1317  if (MachineName)
1318  {
1320  if (rc != ERROR_SUCCESS)
1321  {
1323  goto cleanup;
1324  }
1325 
1326  list->szData[0] = list->szData[1] = '\\';
1327  strcpyW(list->szData + 2, MachineName);
1328  list->MachineName = list->szData;
1329  }
1330  else
1331  {
1332  list->HKLM = HKEY_LOCAL_MACHINE;
1333  list->MachineName = NULL;
1334  }
1335  cr = CM_Connect_MachineW(list->MachineName, &list->hMachine);
1336  if (cr != CR_SUCCESS)
1337  {
1339  goto cleanup;
1340  }
1342  InitializeListHead(&list->ListHead);
1343 
1344  return (HDEVINFO)list;
1345 
1346 cleanup:
1347  if (ret == INVALID_HANDLE_VALUE)
1348  {
1349  if (list)
1350  {
1351  if (list->HKLM != NULL && list->HKLM != HKEY_LOCAL_MACHINE)
1352  RegCloseKey(list->HKLM);
1353  MyFree(list);
1354  }
1355  }
1356  return ret;
1357 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define SP_MAX_MACHINENAME_LENGTH
Definition: setupapi.h:27
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
LIST_ENTRY ListHead
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR szData[]
Definition: msipriv.h:1195
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
#define ZeroMemory
Definition: winbase.h:1635
SP_DEVINSTALL_PARAMS_W InstallParams
#define SETUP_DEVICE_INFO_SET_MAGIC
DWORD DWORD
Definition: winlogon.h:84
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
static DWORD GetErrorCodeFromCrCode(const IN CONFIGRET cr)
Definition: devinst.c:92
#define debugstr_w
Definition: kernel32.h:32
#define CR_SUCCESS
Definition: cfgmgr32.h:842
LONG WINAPI RegConnectRegistryW(LPCWSTR lpMachineName, HKEY hKey, PHKEY phkResult)
Definition: reg.c:872
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
CONFIGRET WINAPI CM_Connect_MachineW(_In_opt_ PCWSTR UNCServerName, _Out_ PHMACHINE phMachine)
Definition: cfgmgr.c:1166
LIST_ENTRY DriverListHead
PVOID HDEVINFO
Definition: setupapi.h:664
#define SetLastError(x)
Definition: compat.h:409
ULONG PVOID Reserved
Definition: ntimage.h:533
#define DI_CLASSINSTALLPARAMS
Definition: setupapi.h:66
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define GUID_NULL
Definition: ks.h:106
Definition: _list.h:228
GLenum GLsizei len
Definition: glext.h:6722
ULONG_PTR SIZE_T
Definition: typedefs.h:78
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
WCHAR szData[ANYSIZE_ARRAY]
struct _SP_DEVINSTALL_PARAMS_W SP_DEVINSTALL_PARAMS_W
#define ERROR_INVALID_MACHINENAME
Definition: setupapi.h:323
char * cleanup(char *str)
Definition: wpickclick.c:99
#define list
Definition: rosglue.h:35
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
BOOL WINAPI SetupDiCreateDeviceInfoW ( HDEVINFO  DeviceInfoSet,
PCWSTR  DeviceName,
CONST GUID ClassGuid,
PCWSTR  DeviceDescription,
HWND  hwndParent,
DWORD  CreationFlags,
PSP_DEVINFO_DATA  DeviceInfoData 
)

Definition at line 1712 of file devinst.c.

Referenced by SetupDiCreateDeviceInfoA().

1720 {
1721  struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
1722  struct DeviceInfo *deviceInfo = NULL;
1723  BOOL ret = FALSE;
1724  CONFIGRET cr;
1725  DEVINST RootDevInst;
1726  DEVINST DevInst;
1727  WCHAR GenInstanceId[MAX_DEVICE_ID_LEN];
1728 
1729  TRACE("%p %s %s %s %p %x %p\n", DeviceInfoSet, debugstr_w(DeviceName),
1731  hwndParent, CreationFlags, DeviceInfoData);
1732 
1733  if (!DeviceName)
1734  {
1736  return FALSE;
1737  }
1739  {
1741  return FALSE;
1742  }
1743  if (!ClassGuid)
1744  {
1746  return FALSE;
1747  }
1748  if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
1749  {
1751  return FALSE;
1752  }
1753  if (!IsEqualGUID(&set->ClassGuid, &GUID_NULL) &&
1754  !IsEqualGUID(ClassGuid, &set->ClassGuid))
1755  {
1757  return FALSE;
1758  }
1760  {
1761  TRACE("Unknown flags: 0x%08lx\n", CreationFlags & ~(DICD_GENERATE_ID | DICD_INHERIT_CLASSDRVS));
1763  return FALSE;
1764  }
1765 
1766  /* Get the root device instance */
1767  cr = CM_Locate_DevInst_ExW(&RootDevInst,
1768  NULL,
1770  set->hMachine);
1771  if (cr != CR_SUCCESS)
1772  {
1774  return FALSE;
1775  }
1776 
1777  /* Create the new device instance */
1778  cr = CM_Create_DevInst_ExW(&DevInst,
1780  RootDevInst,
1783  set->hMachine);
1784  if (cr != CR_SUCCESS)
1785  {
1787  return FALSE;
1788  }
1789 
1791  {
1792  /* Grab the actual instance ID that was created */
1793  cr = CM_Get_Device_ID_Ex(DevInst,
1794  GenInstanceId,
1796  0,
1797  set->hMachine);
1798  if (cr != CR_SUCCESS)
1799  {
1801  return FALSE;
1802  }
1803 
1804  DeviceName = GenInstanceId;
1805  TRACE("Using generated instance ID: %s\n", debugstr_w(DeviceName));
1806  }
1807 
1808  if (CreateDeviceInfo(set, DeviceName, ClassGuid, &deviceInfo))
1809  {
1810  InsertTailList(&set->ListHead, &deviceInfo->ListEntry);
1811 
1812  if (!DeviceInfoData)
1813  ret = TRUE;
1814  else
1815  {
1816  if (DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
1817  {
1819  }
1820  else
1821  {
1822  memcpy(&DeviceInfoData->ClassGuid, ClassGuid, sizeof(GUID));
1823  DeviceInfoData->DevInst = deviceInfo->dnDevInst;
1824  DeviceInfoData->Reserved = (ULONG_PTR)deviceInfo;
1825  ret = TRUE;
1826  }
1827  }
1828  }
1829 
1830  if (ret == FALSE)
1831  {
1832  if (deviceInfo != NULL)
1833  {
1834  /* Remove deviceInfo from List */
1835  RemoveEntryList(&deviceInfo->ListEntry);
1836 
1837  /* Destroy deviceInfo */
1838  DestroyDeviceInfo(deviceInfo);
1839  }
1840  }
1841 
1842  TRACE("Returning %d\n", ret);
1843  return ret;
1844 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define DICD_INHERIT_CLASSDRVS
Definition: setupapi.h:111
#define TRUE
Definition: types.h:120
LIST_ENTRY ListHead
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CM_Locate_DevInst_ExW
Definition: cfgmgr32.h:2395
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define INVALID_HANDLE_VAL