2000-12-13 22:31:37 +01:00
|
|
|
/*
|
|
|
|
* SetupAPI device installer
|
|
|
|
*
|
2003-09-08 21:38:45 +02:00
|
|
|
* Copyright 2000 Andreas Mohr for CodeWeavers
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-12-13 22:31:37 +01:00
|
|
|
*/
|
|
|
|
|
2004-12-02 19:09:53 +01:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2000-12-13 22:31:37 +01:00
|
|
|
#include "windef.h"
|
2001-07-25 02:43:29 +02:00
|
|
|
#include "winbase.h"
|
2004-12-02 19:09:53 +01:00
|
|
|
#include "winnt.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "winternl.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winnls.h"
|
2002-05-29 00:39:14 +02:00
|
|
|
#include "setupapi.h"
|
2003-09-11 04:58:46 +02:00
|
|
|
#include "wine/debug.h"
|
2007-09-22 02:04:09 +02:00
|
|
|
#include "wine/list.h"
|
2004-12-02 19:09:53 +01:00
|
|
|
#include "wine/unicode.h"
|
2006-10-13 23:05:01 +02:00
|
|
|
#include "cfgmgr32.h"
|
2005-03-01 12:44:27 +01:00
|
|
|
#include "winioctl.h"
|
2004-12-02 19:09:53 +01:00
|
|
|
#include "rpc.h"
|
|
|
|
#include "rpcdce.h"
|
2003-09-11 04:58:46 +02:00
|
|
|
|
2005-02-03 14:34:50 +01:00
|
|
|
#include "setupapi_private.h"
|
|
|
|
|
2000-12-13 22:31:37 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
|
2000-12-13 22:31:37 +01:00
|
|
|
|
2004-12-02 19:09:53 +01:00
|
|
|
/* Unicode constants */
|
2010-10-04 18:16:25 +02:00
|
|
|
static const WCHAR Chicago[] = {'$','C','h','i','c','a','g','o','$',0};
|
2004-12-02 19:09:53 +01:00
|
|
|
static const WCHAR ClassGUID[] = {'C','l','a','s','s','G','U','I','D',0};
|
|
|
|
static const WCHAR Class[] = {'C','l','a','s','s',0};
|
|
|
|
static const WCHAR ClassInstall32[] = {'C','l','a','s','s','I','n','s','t','a','l','l','3','2',0};
|
|
|
|
static const WCHAR NoDisplayClass[] = {'N','o','D','i','s','p','l','a','y','C','l','a','s','s',0};
|
2007-09-18 18:50:50 +02:00
|
|
|
static const WCHAR NoInstallClass[] = {'N','o','I','n','s','t','a','l','l','C','l','a','s','s',0};
|
2004-12-02 19:09:53 +01:00
|
|
|
static const WCHAR NoUseClass[] = {'N','o','U','s','e','C','l','a','s','s',0};
|
|
|
|
static const WCHAR NtExtension[] = {'.','N','T',0};
|
|
|
|
static const WCHAR NtPlatformExtension[] = {'.','N','T','x','8','6',0};
|
2010-10-04 18:16:25 +02:00
|
|
|
static const WCHAR Signature[] = {'S','i','g','n','a','t','u','r','e',0};
|
2004-12-02 19:09:53 +01:00
|
|
|
static const WCHAR Version[] = {'V','e','r','s','i','o','n',0};
|
|
|
|
static const WCHAR WinExtension[] = {'.','W','i','n',0};
|
2013-12-17 21:42:00 +01:00
|
|
|
static const WCHAR WindowsNT[] = {'$','W','i','n','d','o','w','s',' ','N','T','$',0};
|
2004-12-02 19:09:53 +01:00
|
|
|
|
|
|
|
/* Registry key and value names */
|
|
|
|
static const WCHAR ControlClass[] = {'S','y','s','t','e','m','\\',
|
|
|
|
'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
|
|
|
|
'C','o','n','t','r','o','l','\\',
|
|
|
|
'C','l','a','s','s',0};
|
|
|
|
|
|
|
|
static const WCHAR DeviceClasses[] = {'S','y','s','t','e','m','\\',
|
|
|
|
'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
|
|
|
|
'C','o','n','t','r','o','l','\\',
|
|
|
|
'D','e','v','i','c','e','C','l','a','s','s','e','s',0};
|
2007-09-20 18:10:10 +02:00
|
|
|
static const WCHAR Enum[] = {'S','y','s','t','e','m','\\',
|
|
|
|
'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
|
|
|
|
'E','n','u','m',0};
|
|
|
|
static const WCHAR DeviceDesc[] = {'D','e','v','i','c','e','D','e','s','c',0};
|
2007-09-20 18:16:45 +02:00
|
|
|
static const WCHAR DeviceInstance[] = {'D','e','v','i','c','e','I','n','s','t','a','n','c','e',0};
|
2007-09-20 18:10:10 +02:00
|
|
|
static const WCHAR HardwareId[] = {'H','a','r','d','w','a','r','e','I','D',0};
|
|
|
|
static const WCHAR CompatibleIDs[] = {'C','o','m','p','a','t','i','b','l','e','I','d','s',0};
|
|
|
|
static const WCHAR Service[] = {'S','e','r','v','i','c','e',0};
|
|
|
|
static const WCHAR Driver[] = {'D','r','i','v','e','r',0};
|
|
|
|
static const WCHAR ConfigFlags[] = {'C','o','n','f','i','g','F','l','a','g','s',0};
|
|
|
|
static const WCHAR Mfg[] = {'M','f','g',0};
|
|
|
|
static const WCHAR FriendlyName[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
|
|
|
|
static const WCHAR LocationInformation[] = {'L','o','c','a','t','i','o','n','I','n','f','o','r','m','a','t','i','o','n',0};
|
|
|
|
static const WCHAR Capabilities[] = {'C','a','p','a','b','i','l','i','t','i','e','s',0};
|
|
|
|
static const WCHAR UINumber[] = {'U','I','N','u','m','b','e','r',0};
|
|
|
|
static const WCHAR UpperFilters[] = {'U','p','p','e','r','F','i','l','t','e','r','s',0};
|
|
|
|
static const WCHAR LowerFilters[] = {'L','o','w','e','r','F','i','l','t','e','r','s',0};
|
2007-09-20 18:14:53 +02:00
|
|
|
static const WCHAR Phantom[] = {'P','h','a','n','t','o','m',0};
|
2007-09-21 20:37:09 +02:00
|
|
|
static const WCHAR SymbolicLink[] = {'S','y','m','b','o','l','i','c','L','i','n','k',0};
|
2004-12-02 19:09:53 +01:00
|
|
|
|
2006-06-13 19:13:32 +02:00
|
|
|
/* is used to identify if a DeviceInfoSet pointer is
|
|
|
|
valid or not */
|
|
|
|
#define SETUP_DEVICE_INFO_SET_MAGIC 0xd00ff056
|
|
|
|
|
|
|
|
struct DeviceInfoSet
|
|
|
|
{
|
|
|
|
DWORD magic; /* if is equal to SETUP_DEVICE_INFO_SET_MAGIC struct is okay */
|
|
|
|
GUID ClassGuid;
|
|
|
|
HWND hwndParent;
|
2007-09-20 02:46:29 +02:00
|
|
|
DWORD cDevices;
|
2008-04-03 17:19:40 +02:00
|
|
|
struct list devices;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DeviceInstance
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
SP_DEVINFO_DATA data;
|
2006-06-13 19:13:32 +02:00
|
|
|
};
|
2006-06-09 07:25:31 +02:00
|
|
|
|
2007-09-21 20:36:12 +02:00
|
|
|
/* Pointed to by SP_DEVICE_INTERFACE_DATA's Reserved member */
|
|
|
|
struct InterfaceInfo
|
|
|
|
{
|
2007-09-22 02:06:18 +02:00
|
|
|
LPWSTR referenceString;
|
|
|
|
LPWSTR symbolicLink;
|
|
|
|
PSP_DEVINFO_DATA device;
|
2007-09-21 20:36:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* A device may have multiple instances of the same interface, so this holds
|
|
|
|
* each instance belonging to a particular interface.
|
|
|
|
*/
|
|
|
|
struct InterfaceInstances
|
|
|
|
{
|
|
|
|
GUID guid;
|
|
|
|
DWORD cInstances;
|
|
|
|
DWORD cInstancesAllocated;
|
|
|
|
SP_DEVICE_INTERFACE_DATA *instances;
|
2007-09-22 02:04:09 +02:00
|
|
|
struct list entry;
|
2007-09-21 20:36:12 +02:00
|
|
|
};
|
|
|
|
|
2007-09-20 18:09:18 +02:00
|
|
|
/* Pointed to by SP_DEVINFO_DATA's Reserved member */
|
|
|
|
struct DeviceInfo
|
|
|
|
{
|
2007-09-22 02:07:37 +02:00
|
|
|
struct DeviceInfoSet *set;
|
|
|
|
HKEY key;
|
|
|
|
BOOL phantom;
|
2007-10-11 22:25:29 +02:00
|
|
|
DWORD devId;
|
2007-09-22 02:07:37 +02:00
|
|
|
LPWSTR instanceId;
|
|
|
|
struct list interfaces;
|
2007-09-20 18:09:18 +02:00
|
|
|
};
|
|
|
|
|
2007-09-21 20:56:45 +02:00
|
|
|
static void SETUPDI_GuidToString(const GUID *guid, LPWSTR guidStr)
|
|
|
|
{
|
|
|
|
static const WCHAR fmt[] = {'{','%','0','8','X','-','%','0','4','X','-',
|
|
|
|
'%','0','4','X','-','%','0','2','X','%','0','2','X','-','%','0','2',
|
|
|
|
'X','%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','%',
|
|
|
|
'0','2','X','}',0};
|
|
|
|
|
|
|
|
sprintfW(guidStr, fmt, guid->Data1, guid->Data2, guid->Data3,
|
|
|
|
guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
|
|
|
|
guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
|
|
|
|
}
|
|
|
|
|
2007-09-21 20:36:12 +02:00
|
|
|
static void SETUPDI_FreeInterfaceInstances(struct InterfaceInstances *instances)
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
for (i = 0; i < instances->cInstances; i++)
|
|
|
|
{
|
|
|
|
struct InterfaceInfo *ifaceInfo =
|
|
|
|
(struct InterfaceInfo *)instances->instances[i].Reserved;
|
|
|
|
|
2007-09-22 02:08:51 +02:00
|
|
|
if (ifaceInfo->device && ifaceInfo->device->Reserved)
|
|
|
|
{
|
|
|
|
struct DeviceInfo *devInfo =
|
|
|
|
(struct DeviceInfo *)ifaceInfo->device->Reserved;
|
|
|
|
|
|
|
|
if (devInfo->phantom)
|
|
|
|
SetupDiDeleteDeviceInterfaceRegKey(devInfo->set,
|
|
|
|
&instances->instances[i], 0);
|
|
|
|
}
|
2007-09-21 20:36:12 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, ifaceInfo->referenceString);
|
2007-09-21 20:37:09 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, ifaceInfo->symbolicLink);
|
2007-11-05 18:52:16 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, ifaceInfo);
|
2007-09-21 20:36:12 +02:00
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, instances->instances);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finds the interface with interface class InterfaceClassGuid in the device.
|
2007-09-22 02:04:09 +02:00
|
|
|
* Returns TRUE if found, and updates *interface to point to device's
|
|
|
|
* interfaces member where the given interface was found.
|
2007-09-21 20:36:12 +02:00
|
|
|
* Returns FALSE if not found.
|
|
|
|
*/
|
|
|
|
static BOOL SETUPDI_FindInterface(const struct DeviceInfo *devInfo,
|
2009-02-09 13:04:55 +01:00
|
|
|
const GUID *InterfaceClassGuid, struct InterfaceInstances **iface_ret)
|
2007-09-21 20:36:12 +02:00
|
|
|
{
|
|
|
|
BOOL found = FALSE;
|
2007-09-22 02:04:09 +02:00
|
|
|
struct InterfaceInstances *iface;
|
2007-09-21 20:36:12 +02:00
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_guid(InterfaceClassGuid));
|
|
|
|
|
2007-09-22 02:04:09 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(iface, &devInfo->interfaces, struct InterfaceInstances,
|
|
|
|
entry)
|
2007-09-21 20:36:12 +02:00
|
|
|
{
|
2007-09-22 02:04:09 +02:00
|
|
|
if (IsEqualGUID(&iface->guid, InterfaceClassGuid))
|
2007-09-21 20:36:12 +02:00
|
|
|
{
|
2009-02-09 13:04:55 +01:00
|
|
|
*iface_ret = iface;
|
2007-09-21 20:36:12 +02:00
|
|
|
found = TRUE;
|
2007-09-22 02:04:09 +02:00
|
|
|
break;
|
2007-09-21 20:36:12 +02:00
|
|
|
}
|
|
|
|
}
|
2009-02-09 13:04:55 +01:00
|
|
|
TRACE("returning %d (%p)\n", found, found ? *iface_ret : NULL);
|
2007-09-21 20:36:12 +02:00
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finds the interface instance with reference string ReferenceString in the
|
|
|
|
* interface instance map. Returns TRUE if found, and updates instanceIndex to
|
|
|
|
* the index of the interface instance's instances member
|
|
|
|
* where the given instance was found. Returns FALSE if not found.
|
|
|
|
*/
|
|
|
|
static BOOL SETUPDI_FindInterfaceInstance(
|
|
|
|
const struct InterfaceInstances *instances,
|
|
|
|
LPCWSTR ReferenceString, DWORD *instanceIndex)
|
|
|
|
{
|
|
|
|
BOOL found = FALSE;
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(ReferenceString));
|
|
|
|
|
|
|
|
for (i = 0; !found && i < instances->cInstances; i++)
|
|
|
|
{
|
|
|
|
SP_DEVICE_INTERFACE_DATA *ifaceData = &instances->instances[i];
|
|
|
|
struct InterfaceInfo *ifaceInfo =
|
|
|
|
(struct InterfaceInfo *)ifaceData->Reserved;
|
|
|
|
|
|
|
|
if (!ReferenceString && !ifaceInfo->referenceString)
|
|
|
|
{
|
|
|
|
*instanceIndex = i;
|
|
|
|
found = TRUE;
|
|
|
|
}
|
|
|
|
else if (ReferenceString && ifaceInfo->referenceString &&
|
|
|
|
!lstrcmpiW(ifaceInfo->referenceString, ReferenceString))
|
|
|
|
{
|
|
|
|
*instanceIndex = i;
|
|
|
|
found = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("returning %d (%d)\n", found, found ? *instanceIndex : 0);
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2007-09-21 20:56:45 +02:00
|
|
|
static LPWSTR SETUPDI_CreateSymbolicLinkPath(LPCWSTR instanceId,
|
|
|
|
const GUID *InterfaceClassGuid, LPCWSTR ReferenceString)
|
|
|
|
{
|
|
|
|
static const WCHAR fmt[] = {'\\','\\','?','\\','%','s','#','%','s',0};
|
|
|
|
WCHAR guidStr[39];
|
|
|
|
DWORD len;
|
|
|
|
LPWSTR ret;
|
|
|
|
|
|
|
|
SETUPDI_GuidToString(InterfaceClassGuid, guidStr);
|
|
|
|
/* omit length of format specifiers, but include NULL terminator: */
|
|
|
|
len = lstrlenW(fmt) - 4 + 1;
|
|
|
|
len += lstrlenW(instanceId) + lstrlenW(guidStr);
|
2008-04-01 13:24:50 +02:00
|
|
|
if (ReferenceString && *ReferenceString)
|
2007-09-21 20:56:45 +02:00
|
|
|
{
|
|
|
|
/* space for a hash between string and reference string: */
|
|
|
|
len += lstrlenW(ReferenceString) + 1;
|
|
|
|
}
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
int printed = sprintfW(ret, fmt, instanceId, guidStr);
|
|
|
|
LPWSTR ptr;
|
|
|
|
|
|
|
|
/* replace '\\' with '#' after the "\\\\?\\" beginning */
|
|
|
|
for (ptr = strchrW(ret + 4, '\\'); ptr; ptr = strchrW(ptr + 1, '\\'))
|
|
|
|
*ptr = '#';
|
2008-04-01 13:24:50 +02:00
|
|
|
if (ReferenceString && *ReferenceString)
|
2007-09-21 20:56:45 +02:00
|
|
|
{
|
2008-04-01 13:24:50 +02:00
|
|
|
ret[printed] = '\\';
|
|
|
|
lstrcpyW(ret + printed + 1, ReferenceString);
|
2007-09-21 20:56:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-09-21 20:36:12 +02:00
|
|
|
/* Adds an interface with the given interface class and reference string to
|
|
|
|
* the device, if it doesn't already exist in the device. If iface is not
|
|
|
|
* NULL, returns a pointer to the newly added (or already existing) interface.
|
|
|
|
*/
|
2007-09-22 02:06:18 +02:00
|
|
|
static BOOL SETUPDI_AddInterfaceInstance(PSP_DEVINFO_DATA DeviceInfoData,
|
2007-09-21 20:36:12 +02:00
|
|
|
const GUID *InterfaceClassGuid, LPCWSTR ReferenceString,
|
|
|
|
SP_DEVICE_INTERFACE_DATA **ifaceData)
|
|
|
|
{
|
2007-09-22 02:06:18 +02:00
|
|
|
struct DeviceInfo *devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
2007-09-21 20:36:12 +02:00
|
|
|
BOOL newInterface = FALSE, ret;
|
|
|
|
struct InterfaceInstances *iface = NULL;
|
|
|
|
|
|
|
|
TRACE("%p %s %s %p\n", devInfo, debugstr_guid(InterfaceClassGuid),
|
|
|
|
debugstr_w(ReferenceString), iface);
|
|
|
|
|
2007-09-22 02:04:09 +02:00
|
|
|
if (!(ret = SETUPDI_FindInterface(devInfo, InterfaceClassGuid, &iface)))
|
2007-09-21 20:36:12 +02:00
|
|
|
{
|
2007-09-22 02:04:09 +02:00
|
|
|
iface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(struct InterfaceInstances));
|
|
|
|
if (iface)
|
2007-09-21 20:36:12 +02:00
|
|
|
{
|
2007-09-22 02:04:09 +02:00
|
|
|
list_add_tail(&devInfo->interfaces, &iface->entry);
|
|
|
|
newInterface = TRUE;
|
2007-09-21 20:36:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (iface)
|
|
|
|
{
|
|
|
|
DWORD instanceIndex = 0;
|
|
|
|
|
|
|
|
if (!(ret = SETUPDI_FindInterfaceInstance(iface, ReferenceString,
|
|
|
|
&instanceIndex)))
|
|
|
|
{
|
|
|
|
SP_DEVICE_INTERFACE_DATA *instance = NULL;
|
|
|
|
|
|
|
|
if (!iface->cInstancesAllocated)
|
|
|
|
{
|
|
|
|
iface->instances = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
sizeof(SP_DEVICE_INTERFACE_DATA));
|
|
|
|
if (iface->instances)
|
|
|
|
instance = &iface->instances[iface->cInstancesAllocated++];
|
|
|
|
}
|
|
|
|
else if (iface->cInstances == iface->cInstancesAllocated)
|
|
|
|
{
|
|
|
|
iface->instances = HeapReAlloc(GetProcessHeap(), 0,
|
|
|
|
iface->instances,
|
|
|
|
(iface->cInstancesAllocated + 1) *
|
|
|
|
sizeof(SP_DEVICE_INTERFACE_DATA));
|
|
|
|
if (iface->instances)
|
|
|
|
instance = &iface->instances[iface->cInstancesAllocated++];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
instance = &iface->instances[iface->cInstances];
|
|
|
|
if (instance)
|
|
|
|
{
|
|
|
|
struct InterfaceInfo *ifaceInfo = HeapAlloc(GetProcessHeap(),
|
|
|
|
0, sizeof(struct InterfaceInfo));
|
|
|
|
|
|
|
|
if (ifaceInfo)
|
|
|
|
{
|
|
|
|
ret = TRUE;
|
2007-09-22 02:06:18 +02:00
|
|
|
ifaceInfo->device = DeviceInfoData;
|
2007-09-21 20:56:45 +02:00
|
|
|
ifaceInfo->symbolicLink = SETUPDI_CreateSymbolicLinkPath(
|
|
|
|
devInfo->instanceId, InterfaceClassGuid,
|
|
|
|
ReferenceString);
|
2007-09-21 20:36:12 +02:00
|
|
|
if (ReferenceString)
|
|
|
|
{
|
|
|
|
ifaceInfo->referenceString =
|
|
|
|
HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
(lstrlenW(ReferenceString) + 1) *
|
|
|
|
sizeof(WCHAR));
|
|
|
|
if (ifaceInfo->referenceString)
|
|
|
|
lstrcpyW(ifaceInfo->referenceString,
|
|
|
|
ReferenceString);
|
|
|
|
else
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ifaceInfo->referenceString = NULL;
|
|
|
|
if (ret)
|
|
|
|
{
|
2007-09-22 02:08:01 +02:00
|
|
|
HKEY key;
|
|
|
|
|
2007-09-21 20:36:12 +02:00
|
|
|
iface->cInstances++;
|
|
|
|
instance->cbSize =
|
|
|
|
sizeof(SP_DEVICE_INTERFACE_DATA);
|
2008-03-16 00:25:45 +01:00
|
|
|
instance->InterfaceClassGuid = *InterfaceClassGuid;
|
2007-09-21 20:36:12 +02:00
|
|
|
instance->Flags = SPINT_ACTIVE; /* FIXME */
|
|
|
|
instance->Reserved = (ULONG_PTR)ifaceInfo;
|
|
|
|
if (newInterface)
|
2008-03-16 00:25:45 +01:00
|
|
|
iface->guid = *InterfaceClassGuid;
|
2007-09-22 02:08:01 +02:00
|
|
|
key = SetupDiCreateDeviceInterfaceRegKeyW(devInfo->set,
|
|
|
|
instance, 0, KEY_WRITE, NULL, NULL);
|
|
|
|
if (key != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
RegSetValueExW(key, SymbolicLink, 0, REG_SZ,
|
|
|
|
(BYTE *)ifaceInfo->symbolicLink,
|
|
|
|
lstrlenW(ifaceInfo->symbolicLink) *
|
|
|
|
sizeof(WCHAR));
|
|
|
|
RegCloseKey(key);
|
|
|
|
}
|
2007-09-21 20:36:12 +02:00
|
|
|
if (ifaceData)
|
|
|
|
*ifaceData = instance;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
HeapFree(GetProcessHeap(), 0, ifaceInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ifaceData)
|
2007-09-22 02:04:09 +02:00
|
|
|
*ifaceData = &iface->instances[instanceIndex];
|
2007-09-21 20:36:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = FALSE;
|
|
|
|
TRACE("returning %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-09-21 20:37:09 +02:00
|
|
|
static BOOL SETUPDI_SetInterfaceSymbolicLink(SP_DEVICE_INTERFACE_DATA *iface,
|
|
|
|
LPCWSTR symbolicLink)
|
|
|
|
{
|
|
|
|
struct InterfaceInfo *info = (struct InterfaceInfo *)iface->Reserved;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
if (info)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, info->symbolicLink);
|
|
|
|
info->symbolicLink = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
(lstrlenW(symbolicLink) + 1) * sizeof(WCHAR));
|
|
|
|
if (info->symbolicLink)
|
|
|
|
{
|
|
|
|
lstrcpyW(info->symbolicLink, symbolicLink);
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-10-11 22:24:42 +02:00
|
|
|
static HKEY SETUPDI_CreateDevKey(struct DeviceInfo *devInfo)
|
|
|
|
{
|
|
|
|
HKEY enumKey, key = INVALID_HANDLE_VALUE;
|
|
|
|
LONG l;
|
|
|
|
|
|
|
|
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, Enum, 0, NULL, 0, KEY_ALL_ACCESS,
|
|
|
|
NULL, &enumKey, NULL);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
RegCreateKeyExW(enumKey, devInfo->instanceId, 0, NULL, 0,
|
|
|
|
KEY_READ | KEY_WRITE, NULL, &key, NULL);
|
|
|
|
RegCloseKey(enumKey);
|
|
|
|
}
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2007-10-11 22:25:52 +02:00
|
|
|
static HKEY SETUPDI_CreateDrvKey(struct DeviceInfo *devInfo)
|
|
|
|
{
|
|
|
|
static const WCHAR slash[] = { '\\',0 };
|
|
|
|
WCHAR classKeyPath[MAX_PATH];
|
|
|
|
HKEY classKey, key = INVALID_HANDLE_VALUE;
|
|
|
|
LONG l;
|
|
|
|
|
|
|
|
lstrcpyW(classKeyPath, ControlClass);
|
|
|
|
lstrcatW(classKeyPath, slash);
|
|
|
|
SETUPDI_GuidToString(&devInfo->set->ClassGuid,
|
|
|
|
classKeyPath + lstrlenW(classKeyPath));
|
|
|
|
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, classKeyPath, 0, NULL, 0,
|
|
|
|
KEY_ALL_ACCESS, NULL, &classKey, NULL);
|
|
|
|
if (!l)
|
|
|
|
{
|
2007-10-12 17:26:31 +02:00
|
|
|
static const WCHAR fmt[] = { '%','0','4','u',0 };
|
|
|
|
WCHAR devId[10];
|
2007-10-11 22:25:52 +02:00
|
|
|
|
|
|
|
sprintfW(devId, fmt, devInfo->devId);
|
|
|
|
RegCreateKeyExW(classKey, devId, 0, NULL, 0, KEY_READ | KEY_WRITE,
|
|
|
|
NULL, &key, NULL);
|
|
|
|
RegCloseKey(classKey);
|
|
|
|
}
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2007-09-22 02:07:37 +02:00
|
|
|
static struct DeviceInfo *SETUPDI_AllocateDeviceInfo(struct DeviceInfoSet *set,
|
2007-10-11 22:25:29 +02:00
|
|
|
DWORD devId, LPCWSTR instanceId, BOOL phantom)
|
2007-09-20 18:09:18 +02:00
|
|
|
{
|
2008-03-01 02:46:58 +01:00
|
|
|
struct DeviceInfo *devInfo = NULL;
|
|
|
|
HANDLE devInst = GlobalAlloc(GMEM_FIXED, sizeof(struct DeviceInfo));
|
|
|
|
if (devInst)
|
|
|
|
devInfo = GlobalLock(devInst);
|
2007-09-20 18:09:18 +02:00
|
|
|
|
|
|
|
if (devInfo)
|
|
|
|
{
|
2007-09-22 02:07:37 +02:00
|
|
|
devInfo->set = set;
|
2008-03-01 02:46:58 +01:00
|
|
|
devInfo->devId = (DWORD)devInst;
|
|
|
|
|
2007-09-20 18:09:18 +02:00
|
|
|
devInfo->instanceId = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
(lstrlenW(instanceId) + 1) * sizeof(WCHAR));
|
|
|
|
if (devInfo->instanceId)
|
2007-09-20 18:09:43 +02:00
|
|
|
{
|
2007-09-20 18:10:10 +02:00
|
|
|
devInfo->key = INVALID_HANDLE_VALUE;
|
2007-09-20 18:14:53 +02:00
|
|
|
devInfo->phantom = phantom;
|
2007-09-20 18:09:18 +02:00
|
|
|
lstrcpyW(devInfo->instanceId, instanceId);
|
2007-09-20 18:09:43 +02:00
|
|
|
struprW(devInfo->instanceId);
|
2007-10-11 22:24:42 +02:00
|
|
|
devInfo->key = SETUPDI_CreateDevKey(devInfo);
|
|
|
|
if (devInfo->key != INVALID_HANDLE_VALUE)
|
2007-09-20 18:10:10 +02:00
|
|
|
{
|
2007-09-20 18:14:53 +02:00
|
|
|
if (phantom)
|
|
|
|
RegSetValueExW(devInfo->key, Phantom, 0, REG_DWORD,
|
|
|
|
(LPBYTE)&phantom, sizeof(phantom));
|
2007-09-20 18:10:10 +02:00
|
|
|
}
|
2007-09-22 02:04:09 +02:00
|
|
|
list_init(&devInfo->interfaces);
|
2008-03-01 02:46:58 +01:00
|
|
|
GlobalUnlock(devInst);
|
2007-09-20 18:09:43 +02:00
|
|
|
}
|
2007-09-20 18:09:18 +02:00
|
|
|
else
|
|
|
|
{
|
2008-03-01 02:46:58 +01:00
|
|
|
GlobalUnlock(devInst);
|
|
|
|
GlobalFree(devInst);
|
2007-09-20 18:09:18 +02:00
|
|
|
devInfo = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return devInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SETUPDI_FreeDeviceInfo(struct DeviceInfo *devInfo)
|
|
|
|
{
|
2007-09-22 02:04:09 +02:00
|
|
|
struct InterfaceInstances *iface, *next;
|
2007-09-21 20:36:12 +02:00
|
|
|
|
2007-09-20 18:10:10 +02:00
|
|
|
if (devInfo->key != INVALID_HANDLE_VALUE)
|
|
|
|
RegCloseKey(devInfo->key);
|
2007-09-20 18:14:53 +02:00
|
|
|
if (devInfo->phantom)
|
|
|
|
{
|
|
|
|
HKEY enumKey;
|
|
|
|
LONG l;
|
|
|
|
|
|
|
|
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, Enum, 0, NULL, 0,
|
|
|
|
KEY_ALL_ACCESS, NULL, &enumKey, NULL);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
RegDeleteTreeW(enumKey, devInfo->instanceId);
|
|
|
|
RegCloseKey(enumKey);
|
|
|
|
}
|
|
|
|
}
|
2007-09-20 18:09:18 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, devInfo->instanceId);
|
2007-09-22 02:04:09 +02:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(iface, next, &devInfo->interfaces,
|
|
|
|
struct InterfaceInstances, entry)
|
|
|
|
{
|
|
|
|
list_remove(&iface->entry);
|
|
|
|
SETUPDI_FreeInterfaceInstances(iface);
|
|
|
|
HeapFree(GetProcessHeap(), 0, iface);
|
|
|
|
}
|
2008-03-01 02:46:58 +01:00
|
|
|
GlobalFree((HANDLE)devInfo->devId);
|
2007-09-20 18:09:18 +02:00
|
|
|
}
|
|
|
|
|
2011-08-02 22:20:32 +02:00
|
|
|
/* Adds a device with GUID guid and identifier devInst to set. Allocates a
|
2007-09-20 18:09:18 +02:00
|
|
|
* struct DeviceInfo, and points the returned device info's Reserved member
|
2007-09-20 18:14:53 +02:00
|
|
|
* to it. "Phantom" devices are deleted from the registry when closed.
|
2007-09-20 18:09:18 +02:00
|
|
|
* Returns a pointer to the newly allocated device info.
|
|
|
|
*/
|
|
|
|
static BOOL SETUPDI_AddDeviceToSet(struct DeviceInfoSet *set,
|
|
|
|
const GUID *guid,
|
2015-07-22 11:57:07 +02:00
|
|
|
DWORD dev_inst,
|
2007-09-20 18:09:18 +02:00
|
|
|
LPCWSTR instanceId,
|
2007-09-20 18:14:53 +02:00
|
|
|
BOOL phantom,
|
2007-09-20 18:09:18 +02:00
|
|
|
SP_DEVINFO_DATA **dev)
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
2007-10-11 22:25:29 +02:00
|
|
|
struct DeviceInfo *devInfo = SETUPDI_AllocateDeviceInfo(set, set->cDevices,
|
|
|
|
instanceId, phantom);
|
2007-09-20 18:09:18 +02:00
|
|
|
|
2015-07-22 11:57:07 +02:00
|
|
|
TRACE("%p, %s, %d, %s, %d\n", set, debugstr_guid(guid), dev_inst,
|
2007-09-20 18:16:45 +02:00
|
|
|
debugstr_w(instanceId), phantom);
|
|
|
|
|
2007-09-20 18:09:18 +02:00
|
|
|
if (devInfo)
|
|
|
|
{
|
2008-04-03 17:19:40 +02:00
|
|
|
struct DeviceInstance *devInst =
|
|
|
|
HeapAlloc(GetProcessHeap(), 0, sizeof(struct DeviceInstance));
|
|
|
|
|
|
|
|
if (devInst)
|
2007-09-20 18:09:18 +02:00
|
|
|
{
|
2007-09-20 18:14:27 +02:00
|
|
|
WCHAR classGuidStr[39];
|
|
|
|
|
2008-04-03 17:19:40 +02:00
|
|
|
list_add_tail(&set->devices, &devInst->entry);
|
|
|
|
set->cDevices++;
|
|
|
|
devInst->data.cbSize = sizeof(SP_DEVINFO_DATA);
|
|
|
|
devInst->data.ClassGuid = *guid;
|
|
|
|
devInst->data.DevInst = devInfo->devId;
|
|
|
|
devInst->data.Reserved = (ULONG_PTR)devInfo;
|
2007-09-20 18:14:27 +02:00
|
|
|
SETUPDI_GuidToString(guid, classGuidStr);
|
2008-12-08 04:06:20 +01:00
|
|
|
SetupDiSetDeviceRegistryPropertyW(set, &devInst->data,
|
|
|
|
SPDRP_CLASSGUID, (const BYTE *)classGuidStr,
|
2007-09-20 18:14:27 +02:00
|
|
|
lstrlenW(classGuidStr) * sizeof(WCHAR));
|
2008-04-03 17:19:40 +02:00
|
|
|
if (dev) *dev = &devInst->data;
|
2007-09-20 18:09:18 +02:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, devInfo);
|
|
|
|
SetLastError(ERROR_OUTOFMEMORY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2002-06-05 00:12:50 +02:00
|
|
|
/***********************************************************************
|
2004-12-02 19:09:53 +01:00
|
|
|
* SetupDiBuildClassInfoList (SETUPAPI.@)
|
2006-06-09 07:25:31 +02:00
|
|
|
*
|
|
|
|
* Returns a list of setup class GUIDs that identify the classes
|
|
|
|
* that are installed on a local machine.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* Flags [I] control exclusion of classes from the list.
|
|
|
|
* ClassGuidList [O] pointer to a GUID-typed array that receives a list of setup class GUIDs.
|
|
|
|
* ClassGuidListSize [I] The number of GUIDs in the array (ClassGuidList).
|
|
|
|
* RequiredSize [O] pointer, which receives the number of GUIDs that are returned.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE.
|
|
|
|
* Failure: FALSE.
|
2002-06-05 00:12:50 +02:00
|
|
|
*/
|
2004-12-02 19:09:53 +01:00
|
|
|
BOOL WINAPI SetupDiBuildClassInfoList(
|
|
|
|
DWORD Flags,
|
|
|
|
LPGUID ClassGuidList,
|
|
|
|
DWORD ClassGuidListSize,
|
|
|
|
PDWORD RequiredSize)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
return SetupDiBuildClassInfoListExW(Flags, ClassGuidList,
|
|
|
|
ClassGuidListSize, RequiredSize,
|
|
|
|
NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiBuildClassInfoListExA (SETUPAPI.@)
|
2006-06-09 07:25:31 +02:00
|
|
|
*
|
|
|
|
* Returns a list of setup class GUIDs that identify the classes
|
2011-08-02 22:20:32 +02:00
|
|
|
* that are installed on a local or remote machine.
|
2006-06-09 07:25:31 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* Flags [I] control exclusion of classes from the list.
|
|
|
|
* ClassGuidList [O] pointer to a GUID-typed array that receives a list of setup class GUIDs.
|
|
|
|
* ClassGuidListSize [I] The number of GUIDs in the array (ClassGuidList).
|
|
|
|
* RequiredSize [O] pointer, which receives the number of GUIDs that are returned.
|
|
|
|
* MachineName [I] name of a remote machine.
|
|
|
|
* Reserved [I] must be NULL.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE.
|
|
|
|
* Failure: FALSE.
|
2004-12-02 19:09:53 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiBuildClassInfoListExA(
|
|
|
|
DWORD Flags,
|
|
|
|
LPGUID ClassGuidList,
|
|
|
|
DWORD ClassGuidListSize,
|
|
|
|
PDWORD RequiredSize,
|
|
|
|
LPCSTR MachineName,
|
|
|
|
PVOID Reserved)
|
2002-05-29 00:39:14 +02:00
|
|
|
{
|
2005-02-03 14:34:50 +01:00
|
|
|
LPWSTR MachineNameW = NULL;
|
|
|
|
BOOL bResult;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (MachineName)
|
|
|
|
{
|
|
|
|
MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
|
|
|
|
if (MachineNameW == NULL) return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bResult = SetupDiBuildClassInfoListExW(Flags, ClassGuidList,
|
|
|
|
ClassGuidListSize, RequiredSize,
|
|
|
|
MachineNameW, Reserved);
|
|
|
|
|
2006-07-19 19:39:48 +02:00
|
|
|
MyFree(MachineNameW);
|
2005-02-03 14:34:50 +01:00
|
|
|
|
|
|
|
return bResult;
|
2002-05-29 00:39:14 +02:00
|
|
|
}
|
|
|
|
|
2002-06-05 00:12:50 +02:00
|
|
|
/***********************************************************************
|
2006-06-09 07:25:31 +02:00
|
|
|
* SetupDiBuildClassInfoListExW (SETUPAPI.@)
|
|
|
|
*
|
|
|
|
* Returns a list of setup class GUIDs that identify the classes
|
2011-08-02 22:20:32 +02:00
|
|
|
* that are installed on a local or remote machine.
|
2006-06-09 07:25:31 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* Flags [I] control exclusion of classes from the list.
|
|
|
|
* ClassGuidList [O] pointer to a GUID-typed array that receives a list of setup class GUIDs.
|
|
|
|
* ClassGuidListSize [I] The number of GUIDs in the array (ClassGuidList).
|
|
|
|
* RequiredSize [O] pointer, which receives the number of GUIDs that are returned.
|
|
|
|
* MachineName [I] name of a remote machine.
|
|
|
|
* Reserved [I] must be NULL.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE.
|
|
|
|
* Failure: FALSE.
|
2002-06-05 00:12:50 +02:00
|
|
|
*/
|
2004-12-02 19:09:53 +01:00
|
|
|
BOOL WINAPI SetupDiBuildClassInfoListExW(
|
|
|
|
DWORD Flags,
|
|
|
|
LPGUID ClassGuidList,
|
|
|
|
DWORD ClassGuidListSize,
|
|
|
|
PDWORD RequiredSize,
|
|
|
|
LPCWSTR MachineName,
|
|
|
|
PVOID Reserved)
|
2002-05-29 00:39:14 +02:00
|
|
|
{
|
2004-12-02 19:09:53 +01:00
|
|
|
WCHAR szKeyName[40];
|
|
|
|
HKEY hClassesKey;
|
|
|
|
HKEY hClassKey;
|
|
|
|
DWORD dwLength;
|
|
|
|
DWORD dwIndex;
|
|
|
|
LONG lError;
|
|
|
|
DWORD dwGuidListIndex = 0;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (RequiredSize != NULL)
|
|
|
|
*RequiredSize = 0;
|
|
|
|
|
|
|
|
hClassesKey = SetupDiOpenClassRegKeyExW(NULL,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
DIOCR_INSTALLER,
|
|
|
|
MachineName,
|
|
|
|
Reserved);
|
|
|
|
if (hClassesKey == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (dwIndex = 0; ; dwIndex++)
|
|
|
|
{
|
|
|
|
dwLength = 40;
|
|
|
|
lError = RegEnumKeyExW(hClassesKey,
|
|
|
|
dwIndex,
|
|
|
|
szKeyName,
|
|
|
|
&dwLength,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2006-10-13 23:32:50 +02:00
|
|
|
TRACE("RegEnumKeyExW() returns %d\n", lError);
|
2004-12-02 19:09:53 +01:00
|
|
|
if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA)
|
|
|
|
{
|
|
|
|
TRACE("Key name: %p\n", szKeyName);
|
|
|
|
|
|
|
|
if (RegOpenKeyExW(hClassesKey,
|
|
|
|
szKeyName,
|
|
|
|
0,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
&hClassKey))
|
|
|
|
{
|
|
|
|
RegCloseKey(hClassesKey);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!RegQueryValueExW(hClassKey,
|
|
|
|
NoUseClass,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL))
|
|
|
|
{
|
|
|
|
TRACE("'NoUseClass' value found!\n");
|
|
|
|
RegCloseKey(hClassKey);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((Flags & DIBCI_NOINSTALLCLASS) &&
|
|
|
|
(!RegQueryValueExW(hClassKey,
|
|
|
|
NoInstallClass,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL)))
|
|
|
|
{
|
|
|
|
TRACE("'NoInstallClass' value found!\n");
|
|
|
|
RegCloseKey(hClassKey);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((Flags & DIBCI_NODISPLAYCLASS) &&
|
|
|
|
(!RegQueryValueExW(hClassKey,
|
|
|
|
NoDisplayClass,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL)))
|
|
|
|
{
|
|
|
|
TRACE("'NoDisplayClass' value found!\n");
|
|
|
|
RegCloseKey(hClassKey);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hClassKey);
|
|
|
|
|
|
|
|
TRACE("Guid: %p\n", szKeyName);
|
|
|
|
if (dwGuidListIndex < ClassGuidListSize)
|
|
|
|
{
|
2007-06-21 22:56:32 +02:00
|
|
|
if (szKeyName[0] == '{' && szKeyName[37] == '}')
|
2004-12-02 19:09:53 +01:00
|
|
|
{
|
|
|
|
szKeyName[37] = 0;
|
|
|
|
}
|
|
|
|
TRACE("Guid: %p\n", &szKeyName[1]);
|
|
|
|
|
|
|
|
UuidFromStringW(&szKeyName[1],
|
|
|
|
&ClassGuidList[dwGuidListIndex]);
|
|
|
|
}
|
|
|
|
|
|
|
|
dwGuidListIndex++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hClassesKey);
|
|
|
|
|
|
|
|
if (RequiredSize != NULL)
|
|
|
|
*RequiredSize = dwGuidListIndex;
|
|
|
|
|
|
|
|
if (ClassGuidListSize < dwGuidListIndex)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiClassGuidsFromNameA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiClassGuidsFromNameA(
|
|
|
|
LPCSTR ClassName,
|
|
|
|
LPGUID ClassGuidList,
|
|
|
|
DWORD ClassGuidListSize,
|
|
|
|
PDWORD RequiredSize)
|
|
|
|
{
|
|
|
|
return SetupDiClassGuidsFromNameExA(ClassName, ClassGuidList,
|
|
|
|
ClassGuidListSize, RequiredSize,
|
|
|
|
NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiClassGuidsFromNameW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiClassGuidsFromNameW(
|
|
|
|
LPCWSTR ClassName,
|
|
|
|
LPGUID ClassGuidList,
|
|
|
|
DWORD ClassGuidListSize,
|
|
|
|
PDWORD RequiredSize)
|
|
|
|
{
|
|
|
|
return SetupDiClassGuidsFromNameExW(ClassName, ClassGuidList,
|
|
|
|
ClassGuidListSize, RequiredSize,
|
|
|
|
NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiClassGuidsFromNameExA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiClassGuidsFromNameExA(
|
|
|
|
LPCSTR ClassName,
|
|
|
|
LPGUID ClassGuidList,
|
|
|
|
DWORD ClassGuidListSize,
|
|
|
|
PDWORD RequiredSize,
|
|
|
|
LPCSTR MachineName,
|
|
|
|
PVOID Reserved)
|
|
|
|
{
|
2005-02-03 14:34:50 +01:00
|
|
|
LPWSTR ClassNameW = NULL;
|
|
|
|
LPWSTR MachineNameW = NULL;
|
|
|
|
BOOL bResult;
|
|
|
|
|
|
|
|
ClassNameW = MultiByteToUnicode(ClassName, CP_ACP);
|
|
|
|
if (ClassNameW == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2006-09-17 10:24:41 +02:00
|
|
|
if (MachineName)
|
2005-02-03 14:34:50 +01:00
|
|
|
{
|
|
|
|
MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
|
|
|
|
if (MachineNameW == NULL)
|
|
|
|
{
|
|
|
|
MyFree(ClassNameW);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bResult = SetupDiClassGuidsFromNameExW(ClassNameW, ClassGuidList,
|
|
|
|
ClassGuidListSize, RequiredSize,
|
|
|
|
MachineNameW, Reserved);
|
|
|
|
|
2006-07-19 19:39:48 +02:00
|
|
|
MyFree(MachineNameW);
|
2005-02-03 14:34:50 +01:00
|
|
|
MyFree(ClassNameW);
|
|
|
|
|
|
|
|
return bResult;
|
2004-12-02 19:09:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiClassGuidsFromNameExW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiClassGuidsFromNameExW(
|
|
|
|
LPCWSTR ClassName,
|
|
|
|
LPGUID ClassGuidList,
|
|
|
|
DWORD ClassGuidListSize,
|
|
|
|
PDWORD RequiredSize,
|
|
|
|
LPCWSTR MachineName,
|
|
|
|
PVOID Reserved)
|
|
|
|
{
|
|
|
|
WCHAR szKeyName[40];
|
|
|
|
WCHAR szClassName[256];
|
|
|
|
HKEY hClassesKey;
|
|
|
|
HKEY hClassKey;
|
|
|
|
DWORD dwLength;
|
|
|
|
DWORD dwIndex;
|
|
|
|
LONG lError;
|
|
|
|
DWORD dwGuidListIndex = 0;
|
|
|
|
|
|
|
|
if (RequiredSize != NULL)
|
|
|
|
*RequiredSize = 0;
|
|
|
|
|
|
|
|
hClassesKey = SetupDiOpenClassRegKeyExW(NULL,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
DIOCR_INSTALLER,
|
|
|
|
MachineName,
|
|
|
|
Reserved);
|
|
|
|
if (hClassesKey == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (dwIndex = 0; ; dwIndex++)
|
|
|
|
{
|
|
|
|
dwLength = 40;
|
|
|
|
lError = RegEnumKeyExW(hClassesKey,
|
|
|
|
dwIndex,
|
|
|
|
szKeyName,
|
|
|
|
&dwLength,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2006-10-13 23:32:50 +02:00
|
|
|
TRACE("RegEnumKeyExW() returns %d\n", lError);
|
2004-12-02 19:09:53 +01:00
|
|
|
if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA)
|
|
|
|
{
|
|
|
|
TRACE("Key name: %p\n", szKeyName);
|
|
|
|
|
|
|
|
if (RegOpenKeyExW(hClassesKey,
|
|
|
|
szKeyName,
|
|
|
|
0,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
&hClassKey))
|
|
|
|
{
|
|
|
|
RegCloseKey(hClassesKey);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dwLength = 256 * sizeof(WCHAR);
|
|
|
|
if (!RegQueryValueExW(hClassKey,
|
|
|
|
Class,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(LPBYTE)szClassName,
|
|
|
|
&dwLength))
|
|
|
|
{
|
|
|
|
TRACE("Class name: %p\n", szClassName);
|
|
|
|
|
|
|
|
if (strcmpiW(szClassName, ClassName) == 0)
|
|
|
|
{
|
|
|
|
TRACE("Found matching class name\n");
|
|
|
|
|
|
|
|
TRACE("Guid: %p\n", szKeyName);
|
|
|
|
if (dwGuidListIndex < ClassGuidListSize)
|
|
|
|
{
|
2007-06-21 22:56:32 +02:00
|
|
|
if (szKeyName[0] == '{' && szKeyName[37] == '}')
|
2004-12-02 19:09:53 +01:00
|
|
|
{
|
|
|
|
szKeyName[37] = 0;
|
|
|
|
}
|
|
|
|
TRACE("Guid: %p\n", &szKeyName[1]);
|
|
|
|
|
|
|
|
UuidFromStringW(&szKeyName[1],
|
|
|
|
&ClassGuidList[dwGuidListIndex]);
|
|
|
|
}
|
|
|
|
|
|
|
|
dwGuidListIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hClassKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hClassesKey);
|
|
|
|
|
|
|
|
if (RequiredSize != NULL)
|
|
|
|
*RequiredSize = dwGuidListIndex;
|
|
|
|
|
|
|
|
if (ClassGuidListSize < dwGuidListIndex)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiClassNameFromGuidA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiClassNameFromGuidA(
|
|
|
|
const GUID* ClassGuid,
|
|
|
|
PSTR ClassName,
|
|
|
|
DWORD ClassNameSize,
|
|
|
|
PDWORD RequiredSize)
|
|
|
|
{
|
|
|
|
return SetupDiClassNameFromGuidExA(ClassGuid, ClassName,
|
|
|
|
ClassNameSize, RequiredSize,
|
|
|
|
NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiClassNameFromGuidW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiClassNameFromGuidW(
|
|
|
|
const GUID* ClassGuid,
|
|
|
|
PWSTR ClassName,
|
|
|
|
DWORD ClassNameSize,
|
|
|
|
PDWORD RequiredSize)
|
|
|
|
{
|
|
|
|
return SetupDiClassNameFromGuidExW(ClassGuid, ClassName,
|
|
|
|
ClassNameSize, RequiredSize,
|
|
|
|
NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiClassNameFromGuidExA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiClassNameFromGuidExA(
|
|
|
|
const GUID* ClassGuid,
|
|
|
|
PSTR ClassName,
|
|
|
|
DWORD ClassNameSize,
|
|
|
|
PDWORD RequiredSize,
|
|
|
|
PCSTR MachineName,
|
|
|
|
PVOID Reserved)
|
|
|
|
{
|
2005-04-11 14:59:45 +02:00
|
|
|
WCHAR ClassNameW[MAX_CLASS_NAME_LEN];
|
|
|
|
LPWSTR MachineNameW = NULL;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
if (MachineName)
|
|
|
|
MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
|
|
|
|
ret = SetupDiClassNameFromGuidExW(ClassGuid, ClassNameW, MAX_CLASS_NAME_LEN,
|
|
|
|
NULL, MachineNameW, Reserved);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
int len = WideCharToMultiByte(CP_ACP, 0, ClassNameW, -1, ClassName,
|
|
|
|
ClassNameSize, NULL, NULL);
|
|
|
|
|
|
|
|
if (!ClassNameSize && RequiredSize)
|
|
|
|
*RequiredSize = len;
|
|
|
|
}
|
|
|
|
MyFree(MachineNameW);
|
|
|
|
return ret;
|
2004-12-02 19:09:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiClassNameFromGuidExW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiClassNameFromGuidExW(
|
|
|
|
const GUID* ClassGuid,
|
|
|
|
PWSTR ClassName,
|
|
|
|
DWORD ClassNameSize,
|
|
|
|
PDWORD RequiredSize,
|
|
|
|
PCWSTR MachineName,
|
|
|
|
PVOID Reserved)
|
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
DWORD dwLength;
|
|
|
|
|
|
|
|
hKey = SetupDiOpenClassRegKeyExW(ClassGuid,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
DIOCR_INSTALLER,
|
|
|
|
MachineName,
|
|
|
|
Reserved);
|
|
|
|
if (hKey == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RequiredSize != NULL)
|
|
|
|
{
|
|
|
|
dwLength = 0;
|
|
|
|
if (RegQueryValueExW(hKey,
|
|
|
|
Class,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&dwLength))
|
|
|
|
{
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*RequiredSize = dwLength / sizeof(WCHAR);
|
|
|
|
}
|
|
|
|
|
|
|
|
dwLength = ClassNameSize * sizeof(WCHAR);
|
|
|
|
if (RegQueryValueExW(hKey,
|
|
|
|
Class,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(LPBYTE)ClassName,
|
|
|
|
&dwLength))
|
|
|
|
{
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiCreateDeviceInfoList (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
HDEVINFO WINAPI
|
|
|
|
SetupDiCreateDeviceInfoList(const GUID *ClassGuid,
|
|
|
|
HWND hwndParent)
|
|
|
|
{
|
|
|
|
return SetupDiCreateDeviceInfoListExW(ClassGuid, hwndParent, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiCreateDeviceInfoListExA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
HDEVINFO WINAPI
|
|
|
|
SetupDiCreateDeviceInfoListExA(const GUID *ClassGuid,
|
|
|
|
HWND hwndParent,
|
|
|
|
PCSTR MachineName,
|
|
|
|
PVOID Reserved)
|
|
|
|
{
|
2005-02-03 14:34:50 +01:00
|
|
|
LPWSTR MachineNameW = NULL;
|
|
|
|
HDEVINFO hDevInfo;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (MachineName)
|
|
|
|
{
|
|
|
|
MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
|
|
|
|
if (MachineNameW == NULL)
|
2008-01-19 15:56:39 +01:00
|
|
|
return INVALID_HANDLE_VALUE;
|
2005-02-03 14:34:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hDevInfo = SetupDiCreateDeviceInfoListExW(ClassGuid, hwndParent,
|
|
|
|
MachineNameW, Reserved);
|
|
|
|
|
2006-07-19 19:39:48 +02:00
|
|
|
MyFree(MachineNameW);
|
2005-02-03 14:34:50 +01:00
|
|
|
|
|
|
|
return hDevInfo;
|
2004-12-02 19:09:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiCreateDeviceInfoListExW (SETUPAPI.@)
|
2006-06-13 19:13:32 +02:00
|
|
|
*
|
|
|
|
* Create an empty DeviceInfoSet list.
|
|
|
|
*
|
|
|
|
* PARAMS
|
2008-04-21 07:17:27 +02:00
|
|
|
* ClassGuid [I] if not NULL only devices with GUID ClassGuid are associated
|
2006-06-13 19:13:32 +02:00
|
|
|
* with this list.
|
|
|
|
* hwndParent [I] hwnd needed for interface related actions.
|
2016-05-01 10:24:05 +02:00
|
|
|
* MachineName [I] name of machine to create empty DeviceInfoSet list, if NULL
|
2007-02-20 12:03:31 +01:00
|
|
|
* local registry will be used.
|
2006-06-13 19:13:32 +02:00
|
|
|
* Reserved [I] must be NULL
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: empty list.
|
|
|
|
* Failure: INVALID_HANDLE_VALUE.
|
2004-12-02 19:09:53 +01:00
|
|
|
*/
|
|
|
|
HDEVINFO WINAPI
|
|
|
|
SetupDiCreateDeviceInfoListExW(const GUID *ClassGuid,
|
|
|
|
HWND hwndParent,
|
|
|
|
PCWSTR MachineName,
|
|
|
|
PVOID Reserved)
|
|
|
|
{
|
2006-06-13 19:13:32 +02:00
|
|
|
struct DeviceInfoSet *list = NULL;
|
|
|
|
DWORD size = sizeof(struct DeviceInfoSet);
|
|
|
|
|
|
|
|
TRACE("%s %p %s %p\n", debugstr_guid(ClassGuid), hwndParent,
|
|
|
|
debugstr_w(MachineName), Reserved);
|
|
|
|
|
2011-06-09 20:35:11 +02:00
|
|
|
if (MachineName && *MachineName)
|
2006-06-13 19:13:32 +02:00
|
|
|
{
|
2006-10-05 11:11:03 +02:00
|
|
|
FIXME("remote support is not implemented\n");
|
2006-06-13 19:13:32 +02:00
|
|
|
SetLastError(ERROR_INVALID_MACHINENAME);
|
2008-01-19 15:56:39 +01:00
|
|
|
return INVALID_HANDLE_VALUE;
|
2006-06-13 19:13:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Reserved != NULL)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
2008-01-19 15:56:39 +01:00
|
|
|
return INVALID_HANDLE_VALUE;
|
2006-06-13 19:13:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
list = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
if (!list)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
2008-01-19 15:56:39 +01:00
|
|
|
return INVALID_HANDLE_VALUE;
|
2006-06-13 19:13:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
list->magic = SETUP_DEVICE_INFO_SET_MAGIC;
|
|
|
|
list->hwndParent = hwndParent;
|
|
|
|
memcpy(&list->ClassGuid,
|
|
|
|
ClassGuid ? ClassGuid : &GUID_NULL,
|
|
|
|
sizeof(list->ClassGuid));
|
2007-09-20 02:46:29 +02:00
|
|
|
list->cDevices = 0;
|
2008-04-03 17:19:40 +02:00
|
|
|
list_init(&list->devices);
|
2006-06-13 19:13:32 +02:00
|
|
|
|
2008-12-08 04:06:20 +01:00
|
|
|
return list;
|
2004-12-02 19:09:53 +01:00
|
|
|
}
|
|
|
|
|
2007-10-11 22:23:56 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiCreateDevRegKeyA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
HKEY WINAPI SetupDiCreateDevRegKeyA(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
DWORD Scope,
|
|
|
|
DWORD HwProfile,
|
|
|
|
DWORD KeyType,
|
|
|
|
HINF InfHandle,
|
|
|
|
PCSTR InfSectionName)
|
|
|
|
{
|
2007-10-11 22:24:19 +02:00
|
|
|
PWSTR InfSectionNameW = NULL;
|
|
|
|
HKEY key;
|
|
|
|
|
|
|
|
TRACE("%p %p %d %d %d %p %s\n", DeviceInfoSet, DeviceInfoData, Scope,
|
2007-10-11 22:23:56 +02:00
|
|
|
HwProfile, KeyType, InfHandle, debugstr_a(InfSectionName));
|
2007-10-11 22:24:19 +02:00
|
|
|
|
|
|
|
if (InfHandle)
|
|
|
|
{
|
|
|
|
if (!InfSectionName)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
InfSectionNameW = MultiByteToUnicode(InfSectionName, CP_ACP);
|
|
|
|
if (InfSectionNameW == NULL) return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
key = SetupDiCreateDevRegKeyW(DeviceInfoSet, DeviceInfoData, Scope,
|
|
|
|
HwProfile, KeyType, InfHandle, InfSectionNameW);
|
|
|
|
MyFree(InfSectionNameW);
|
|
|
|
return key;
|
2007-10-11 22:23:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiCreateDevRegKeyW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
HKEY WINAPI SetupDiCreateDevRegKeyW(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
DWORD Scope,
|
|
|
|
DWORD HwProfile,
|
|
|
|
DWORD KeyType,
|
|
|
|
HINF InfHandle,
|
|
|
|
PCWSTR InfSectionName)
|
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-10-11 22:25:52 +02:00
|
|
|
struct DeviceInfo *devInfo;
|
|
|
|
HKEY key = INVALID_HANDLE_VALUE;
|
|
|
|
|
|
|
|
TRACE("%p %p %d %d %d %p %s\n", DeviceInfoSet, DeviceInfoData, Scope,
|
2007-10-11 22:23:56 +02:00
|
|
|
HwProfile, KeyType, InfHandle, debugstr_w(InfSectionName));
|
2007-10-11 22:25:52 +02:00
|
|
|
|
2008-01-19 15:56:39 +01:00
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
|
2007-10-11 22:25:52 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA)
|
|
|
|
|| !DeviceInfoData->Reserved)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
|
|
|
if (devInfo->set != set)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
2007-10-12 17:25:51 +02:00
|
|
|
if (Scope != DICS_FLAG_GLOBAL && Scope != DICS_FLAG_CONFIGSPECIFIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_FLAGS);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
if (KeyType != DIREG_DEV && KeyType != DIREG_DRV)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_FLAGS);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
2007-10-11 22:25:52 +02:00
|
|
|
if (devInfo->phantom)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_DEVINFO_NOT_REGISTERED);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
if (Scope != DICS_FLAG_GLOBAL)
|
|
|
|
FIXME("unimplemented for scope %d\n", Scope);
|
|
|
|
switch (KeyType)
|
|
|
|
{
|
|
|
|
case DIREG_DEV:
|
|
|
|
key = SETUPDI_CreateDevKey(devInfo);
|
|
|
|
break;
|
|
|
|
case DIREG_DRV:
|
|
|
|
key = SETUPDI_CreateDrvKey(devInfo);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN("unknown KeyType %d\n", KeyType);
|
|
|
|
}
|
|
|
|
if (InfHandle)
|
|
|
|
SetupInstallFromInfSectionW(NULL, InfHandle, InfSectionName, SPINST_ALL,
|
|
|
|
NULL, NULL, SP_COPY_NEWER_ONLY, NULL, NULL, DeviceInfoSet,
|
|
|
|
DeviceInfoData);
|
|
|
|
return key;
|
2007-10-11 22:23:56 +02:00
|
|
|
}
|
|
|
|
|
2006-07-20 16:08:43 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiCreateDeviceInfoA (SETUPAPI.@)
|
|
|
|
*/
|
2013-09-23 00:37:16 +02:00
|
|
|
BOOL WINAPI SetupDiCreateDeviceInfoA(HDEVINFO DeviceInfoSet, PCSTR DeviceName,
|
|
|
|
const GUID *ClassGuid, PCSTR DeviceDescription, HWND hwndParent, DWORD CreationFlags,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData)
|
2006-07-20 16:08:43 +02:00
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
LPWSTR DeviceNameW = NULL;
|
|
|
|
LPWSTR DeviceDescriptionW = NULL;
|
|
|
|
|
|
|
|
if (DeviceName)
|
|
|
|
{
|
|
|
|
DeviceNameW = MultiByteToUnicode(DeviceName, CP_ACP);
|
|
|
|
if (DeviceNameW == NULL) return FALSE;
|
|
|
|
}
|
|
|
|
if (DeviceDescription)
|
|
|
|
{
|
|
|
|
DeviceDescriptionW = MultiByteToUnicode(DeviceDescription, CP_ACP);
|
|
|
|
if (DeviceDescriptionW == NULL)
|
|
|
|
{
|
|
|
|
MyFree(DeviceNameW);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = SetupDiCreateDeviceInfoW(DeviceInfoSet, DeviceNameW, ClassGuid, DeviceDescriptionW,
|
|
|
|
hwndParent, CreationFlags, DeviceInfoData);
|
|
|
|
|
|
|
|
MyFree(DeviceNameW);
|
|
|
|
MyFree(DeviceDescriptionW);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-09-20 18:09:18 +02:00
|
|
|
static DWORD SETUPDI_DevNameToDevID(LPCWSTR devName)
|
|
|
|
{
|
|
|
|
LPCWSTR ptr;
|
2008-11-10 20:37:42 +01:00
|
|
|
int devNameLen = lstrlenW(devName);
|
|
|
|
DWORD devInst = 0;
|
2007-09-20 18:09:18 +02:00
|
|
|
BOOL valid = TRUE;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(devName));
|
|
|
|
for (ptr = devName; valid && *ptr && ptr - devName < devNameLen; )
|
|
|
|
{
|
|
|
|
if (isdigitW(*ptr))
|
|
|
|
{
|
|
|
|
devInst *= 10;
|
|
|
|
devInst |= *ptr - '0';
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
valid = FALSE;
|
|
|
|
}
|
|
|
|
TRACE("%d\n", valid ? devInst : 0xffffffff);
|
|
|
|
return valid ? devInst : 0xffffffff;
|
|
|
|
}
|
|
|
|
|
2006-07-19 19:58:47 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiCreateDeviceInfoW (SETUPAPI.@)
|
|
|
|
*/
|
2013-09-23 00:37:16 +02:00
|
|
|
BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO DeviceInfoSet, PCWSTR DeviceName,
|
|
|
|
const GUID *ClassGuid, PCWSTR DeviceDescription, HWND hwndParent, DWORD CreationFlags,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData)
|
2006-07-19 19:58:47 +02:00
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-09-20 18:09:18 +02:00
|
|
|
BOOL ret = FALSE, allocatedInstanceId = FALSE;
|
|
|
|
LPCWSTR instanceId = NULL;
|
2007-09-20 02:49:17 +02:00
|
|
|
|
2006-10-13 23:32:50 +02:00
|
|
|
TRACE("%p %s %s %s %p %x %p\n", DeviceInfoSet, debugstr_w(DeviceName),
|
2006-07-19 19:58:47 +02:00
|
|
|
debugstr_guid(ClassGuid), debugstr_w(DeviceDescription),
|
|
|
|
hwndParent, CreationFlags, DeviceInfoData);
|
|
|
|
|
2007-09-20 02:49:17 +02:00
|
|
|
if (!DeviceName)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_DEVINST_NAME);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-01-19 15:56:39 +01:00
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
|
2007-09-20 02:49:17 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!ClassGuid)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-09-20 18:09:18 +02:00
|
|
|
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
2007-09-20 02:49:17 +02:00
|
|
|
{
|
2007-09-20 18:09:18 +02:00
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!IsEqualGUID(&set->ClassGuid, &GUID_NULL) &&
|
|
|
|
!IsEqualGUID(ClassGuid, &set->ClassGuid))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_CLASS_MISMATCH);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if ((CreationFlags & DICD_GENERATE_ID))
|
|
|
|
{
|
|
|
|
if (strchrW(DeviceName, '\\'))
|
|
|
|
SetLastError(ERROR_INVALID_DEVINST_NAME);
|
2007-09-20 02:49:17 +02:00
|
|
|
else
|
|
|
|
{
|
2007-09-20 18:09:43 +02:00
|
|
|
static const WCHAR newDeviceFmt[] = {'R','O','O','T','\\','%','s',
|
2007-09-20 18:09:18 +02:00
|
|
|
'\\','%','0','4','d',0};
|
|
|
|
DWORD devId;
|
|
|
|
|
|
|
|
if (set->cDevices)
|
|
|
|
{
|
2008-04-03 17:19:40 +02:00
|
|
|
DWORD highestDevID = 0;
|
|
|
|
struct DeviceInstance *devInst;
|
2007-09-20 18:09:18 +02:00
|
|
|
|
2008-04-03 17:19:40 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(devInst, &set->devices, struct DeviceInstance, entry)
|
2007-09-20 18:09:18 +02:00
|
|
|
{
|
2008-04-03 17:19:40 +02:00
|
|
|
struct DeviceInfo *devInfo = (struct DeviceInfo *)devInst->data.Reserved;
|
2007-09-20 18:09:18 +02:00
|
|
|
LPCWSTR devName = strrchrW(devInfo->instanceId, '\\');
|
|
|
|
DWORD id;
|
|
|
|
|
|
|
|
if (devName)
|
|
|
|
devName++;
|
|
|
|
else
|
|
|
|
devName = devInfo->instanceId;
|
|
|
|
id = SETUPDI_DevNameToDevID(devName);
|
|
|
|
if (id != 0xffffffff && id > highestDevID)
|
|
|
|
highestDevID = id;
|
|
|
|
}
|
|
|
|
devId = highestDevID + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
devId = 0;
|
|
|
|
/* 17 == lstrlenW(L"Root\\") + lstrlenW("\\") + 1 + %d max size */
|
|
|
|
instanceId = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
(17 + lstrlenW(DeviceName)) * sizeof(WCHAR));
|
|
|
|
if (instanceId)
|
|
|
|
{
|
|
|
|
sprintfW((LPWSTR)instanceId, newDeviceFmt, DeviceName,
|
|
|
|
devId);
|
|
|
|
allocatedInstanceId = TRUE;
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = FALSE;
|
2007-09-20 02:49:17 +02:00
|
|
|
}
|
2007-09-20 18:09:18 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-03 17:19:40 +02:00
|
|
|
struct DeviceInstance *devInst;
|
2007-09-20 18:09:18 +02:00
|
|
|
|
|
|
|
ret = TRUE;
|
|
|
|
instanceId = DeviceName;
|
2008-04-03 17:19:40 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(devInst, &set->devices, struct DeviceInstance, entry)
|
2007-09-20 02:49:17 +02:00
|
|
|
{
|
2008-04-03 17:19:40 +02:00
|
|
|
struct DeviceInfo *devInfo = (struct DeviceInfo *)devInst->data.Reserved;
|
2007-09-20 18:09:18 +02:00
|
|
|
|
2007-09-20 18:09:43 +02:00
|
|
|
if (!lstrcmpiW(DeviceName, devInfo->instanceId))
|
2007-09-20 18:09:18 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_DEVINST_ALREADY_EXISTS);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
2007-09-20 02:49:17 +02:00
|
|
|
}
|
|
|
|
}
|
2007-09-20 18:09:18 +02:00
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
SP_DEVINFO_DATA *dev = NULL;
|
|
|
|
|
|
|
|
ret = SETUPDI_AddDeviceToSet(set, ClassGuid, 0 /* FIXME: DevInst */,
|
2007-09-20 18:14:53 +02:00
|
|
|
instanceId, TRUE, &dev);
|
2007-09-20 18:13:00 +02:00
|
|
|
if (ret)
|
2007-09-20 18:09:18 +02:00
|
|
|
{
|
2007-09-20 18:13:00 +02:00
|
|
|
if (DeviceDescription)
|
|
|
|
SetupDiSetDeviceRegistryPropertyW(DeviceInfoSet,
|
|
|
|
dev, SPDRP_DEVICEDESC, (const BYTE *)DeviceDescription,
|
|
|
|
lstrlenW(DeviceDescription) * sizeof(WCHAR));
|
|
|
|
if (DeviceInfoData)
|
2007-09-20 18:09:18 +02:00
|
|
|
{
|
2007-09-20 18:13:00 +02:00
|
|
|
if (DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
else
|
2008-03-16 00:25:45 +01:00
|
|
|
*DeviceInfoData = *dev;
|
2007-09-20 18:09:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (allocatedInstanceId)
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPWSTR)instanceId);
|
2006-07-19 19:58:47 +02:00
|
|
|
|
2007-09-20 02:49:17 +02:00
|
|
|
return ret;
|
2006-07-19 19:58:47 +02:00
|
|
|
}
|
|
|
|
|
2007-09-20 18:15:32 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiRegisterDeviceInfo (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiRegisterDeviceInfo(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
DWORD Flags,
|
|
|
|
PSP_DETSIG_CMPPROC CompareProc,
|
|
|
|
PVOID CompareContext,
|
|
|
|
PSP_DEVINFO_DATA DupDeviceInfoData)
|
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-09-20 18:16:25 +02:00
|
|
|
struct DeviceInfo *devInfo;
|
|
|
|
|
2007-09-20 18:15:32 +02:00
|
|
|
TRACE("%p %p %08x %p %p %p\n", DeviceInfoSet, DeviceInfoData, Flags,
|
|
|
|
CompareProc, CompareContext, DupDeviceInfoData);
|
|
|
|
|
2008-01-19 15:56:39 +01:00
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
|
2007-09-20 18:16:25 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA)
|
|
|
|
|| !DeviceInfoData->Reserved)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
2007-09-22 02:07:37 +02:00
|
|
|
if (devInfo->set != set)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-09-20 18:16:25 +02:00
|
|
|
if (devInfo->phantom)
|
|
|
|
{
|
|
|
|
devInfo->phantom = FALSE;
|
|
|
|
RegDeleteValueW(devInfo->key, Phantom);
|
|
|
|
}
|
|
|
|
return TRUE;
|
2007-09-20 18:15:32 +02:00
|
|
|
}
|
|
|
|
|
2010-03-13 13:16:01 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiRemoveDevice (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiRemoveDevice(
|
|
|
|
HDEVINFO devinfo,
|
|
|
|
PSP_DEVINFO_DATA info)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p): stub\n", devinfo, info);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-12-02 19:09:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiEnumDeviceInfo (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiEnumDeviceInfo(
|
|
|
|
HDEVINFO devinfo,
|
|
|
|
DWORD index,
|
|
|
|
PSP_DEVINFO_DATA info)
|
|
|
|
{
|
2007-09-20 02:46:58 +02:00
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
TRACE("%p %d %p\n", devinfo, index, info);
|
2004-12-02 19:09:53 +01:00
|
|
|
|
|
|
|
if(info==NULL)
|
2007-09-21 20:35:46 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
2004-12-02 19:09:53 +01:00
|
|
|
return FALSE;
|
2007-09-21 20:35:46 +02:00
|
|
|
}
|
2008-01-19 15:56:39 +01:00
|
|
|
if (devinfo && devinfo != INVALID_HANDLE_VALUE)
|
2007-09-20 02:46:58 +02:00
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *list = devinfo;
|
2007-09-20 02:46:58 +02:00
|
|
|
if (list->magic == SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
if (index < list->cDevices)
|
|
|
|
{
|
|
|
|
if (info->cbSize == sizeof(SP_DEVINFO_DATA))
|
|
|
|
{
|
2008-04-03 17:19:40 +02:00
|
|
|
struct DeviceInstance *devInst;
|
|
|
|
DWORD i = 0;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(devInst, &list->devices,
|
|
|
|
struct DeviceInstance, entry)
|
|
|
|
{
|
|
|
|
if (i++ == index)
|
|
|
|
{
|
|
|
|
*info = devInst->data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-09-20 02:46:58 +02:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetLastError(ERROR_NO_MORE_ITEMS);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return ret;
|
2002-05-29 00:39:14 +02:00
|
|
|
}
|
|
|
|
|
2007-09-20 02:45:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetDeviceInstanceIdA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiGetDeviceInstanceIdA(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
PSTR DeviceInstanceId,
|
|
|
|
DWORD DeviceInstanceIdSize,
|
|
|
|
PDWORD RequiredSize)
|
|
|
|
{
|
2007-09-20 02:47:52 +02:00
|
|
|
BOOL ret = FALSE;
|
|
|
|
DWORD size;
|
|
|
|
PWSTR instanceId;
|
|
|
|
|
|
|
|
TRACE("%p %p %p %d %p\n", DeviceInfoSet, DeviceInfoData, DeviceInstanceId,
|
2007-09-20 02:45:31 +02:00
|
|
|
DeviceInstanceIdSize, RequiredSize);
|
2007-09-20 02:47:52 +02:00
|
|
|
|
|
|
|
SetupDiGetDeviceInstanceIdW(DeviceInfoSet,
|
|
|
|
DeviceInfoData,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
&size);
|
|
|
|
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
|
|
|
return FALSE;
|
|
|
|
instanceId = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
|
|
|
|
if (instanceId)
|
|
|
|
{
|
|
|
|
ret = SetupDiGetDeviceInstanceIdW(DeviceInfoSet,
|
|
|
|
DeviceInfoData,
|
|
|
|
instanceId,
|
|
|
|
size,
|
|
|
|
&size);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
int len = WideCharToMultiByte(CP_ACP, 0, instanceId, -1,
|
|
|
|
DeviceInstanceId,
|
|
|
|
DeviceInstanceIdSize, NULL, NULL);
|
|
|
|
|
|
|
|
if (!len)
|
|
|
|
ret = FALSE;
|
2007-09-20 18:09:43 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (len > DeviceInstanceIdSize)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
if (RequiredSize)
|
|
|
|
*RequiredSize = len;
|
|
|
|
}
|
2007-09-20 02:47:52 +02:00
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, instanceId);
|
|
|
|
}
|
|
|
|
return ret;
|
2007-09-20 02:45:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetDeviceInstanceIdW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiGetDeviceInstanceIdW(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
PWSTR DeviceInstanceId,
|
|
|
|
DWORD DeviceInstanceIdSize,
|
|
|
|
PDWORD RequiredSize)
|
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-09-20 18:09:43 +02:00
|
|
|
struct DeviceInfo *devInfo;
|
|
|
|
|
|
|
|
TRACE("%p %p %p %d %p\n", DeviceInfoSet, DeviceInfoData, DeviceInstanceId,
|
2007-09-20 02:45:31 +02:00
|
|
|
DeviceInstanceIdSize, RequiredSize);
|
2007-09-20 18:09:43 +02:00
|
|
|
|
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA)
|
|
|
|
|| !DeviceInfoData->Reserved)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
2007-09-22 02:07:37 +02:00
|
|
|
if (devInfo->set != set)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-09-20 18:09:43 +02:00
|
|
|
TRACE("instance ID: %s\n", debugstr_w(devInfo->instanceId));
|
2008-11-10 20:37:42 +01:00
|
|
|
if (DeviceInstanceIdSize < strlenW(devInfo->instanceId) + 1)
|
2007-09-20 18:09:43 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
if (RequiredSize)
|
|
|
|
*RequiredSize = lstrlenW(devInfo->instanceId) + 1;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
lstrcpyW(DeviceInstanceId, devInfo->instanceId);
|
|
|
|
if (RequiredSize)
|
|
|
|
*RequiredSize = lstrlenW(devInfo->instanceId) + 1;
|
|
|
|
return TRUE;
|
2007-09-20 02:45:31 +02:00
|
|
|
}
|
|
|
|
|
2004-12-02 19:09:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetActualSectionToInstallA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiGetActualSectionToInstallA(
|
|
|
|
HINF InfHandle,
|
|
|
|
PCSTR InfSectionName,
|
|
|
|
PSTR InfSectionWithExt,
|
|
|
|
DWORD InfSectionWithExtSize,
|
|
|
|
PDWORD RequiredSize,
|
|
|
|
PSTR *Extension)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetActualSectionToInstallW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiGetActualSectionToInstallW(
|
|
|
|
HINF InfHandle,
|
|
|
|
PCWSTR InfSectionName,
|
|
|
|
PWSTR InfSectionWithExt,
|
|
|
|
DWORD InfSectionWithExtSize,
|
|
|
|
PDWORD RequiredSize,
|
|
|
|
PWSTR *Extension)
|
|
|
|
{
|
|
|
|
WCHAR szBuffer[MAX_PATH];
|
|
|
|
DWORD dwLength;
|
|
|
|
DWORD dwFullLength;
|
|
|
|
LONG lLineCount = -1;
|
|
|
|
|
|
|
|
lstrcpyW(szBuffer, InfSectionName);
|
|
|
|
dwLength = lstrlenW(szBuffer);
|
|
|
|
|
|
|
|
if (OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
|
|
|
{
|
|
|
|
/* Test section name with '.NTx86' extension */
|
|
|
|
lstrcpyW(&szBuffer[dwLength], NtPlatformExtension);
|
|
|
|
lLineCount = SetupGetLineCountW(InfHandle, szBuffer);
|
|
|
|
|
|
|
|
if (lLineCount == -1)
|
|
|
|
{
|
|
|
|
/* Test section name with '.NT' extension */
|
|
|
|
lstrcpyW(&szBuffer[dwLength], NtExtension);
|
|
|
|
lLineCount = SetupGetLineCountW(InfHandle, szBuffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Test section name with '.Win' extension */
|
|
|
|
lstrcpyW(&szBuffer[dwLength], WinExtension);
|
|
|
|
lLineCount = SetupGetLineCountW(InfHandle, szBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lLineCount == -1)
|
|
|
|
{
|
|
|
|
/* Test section name without extension */
|
|
|
|
szBuffer[dwLength] = 0;
|
|
|
|
lLineCount = SetupGetLineCountW(InfHandle, szBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lLineCount == -1)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dwFullLength = lstrlenW(szBuffer);
|
|
|
|
|
|
|
|
if (InfSectionWithExt != NULL && InfSectionWithExtSize != 0)
|
|
|
|
{
|
|
|
|
if (InfSectionWithExtSize < (dwFullLength + 1))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
lstrcpyW(InfSectionWithExt, szBuffer);
|
|
|
|
if (Extension != NULL)
|
|
|
|
{
|
|
|
|
*Extension = (dwLength == dwFullLength) ? NULL : &InfSectionWithExt[dwLength];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RequiredSize != NULL)
|
|
|
|
{
|
|
|
|
*RequiredSize = dwFullLength + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetClassDescriptionA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiGetClassDescriptionA(
|
|
|
|
const GUID* ClassGuid,
|
|
|
|
PSTR ClassDescription,
|
|
|
|
DWORD ClassDescriptionSize,
|
|
|
|
PDWORD RequiredSize)
|
|
|
|
{
|
|
|
|
return SetupDiGetClassDescriptionExA(ClassGuid, ClassDescription,
|
|
|
|
ClassDescriptionSize,
|
|
|
|
RequiredSize, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetClassDescriptionW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiGetClassDescriptionW(
|
|
|
|
const GUID* ClassGuid,
|
|
|
|
PWSTR ClassDescription,
|
|
|
|
DWORD ClassDescriptionSize,
|
|
|
|
PDWORD RequiredSize)
|
|
|
|
{
|
|
|
|
return SetupDiGetClassDescriptionExW(ClassGuid, ClassDescription,
|
|
|
|
ClassDescriptionSize,
|
|
|
|
RequiredSize, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetClassDescriptionExA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiGetClassDescriptionExA(
|
|
|
|
const GUID* ClassGuid,
|
|
|
|
PSTR ClassDescription,
|
|
|
|
DWORD ClassDescriptionSize,
|
|
|
|
PDWORD RequiredSize,
|
|
|
|
PCSTR MachineName,
|
|
|
|
PVOID Reserved)
|
|
|
|
{
|
2007-09-20 18:15:16 +02:00
|
|
|
HKEY hKey;
|
|
|
|
DWORD dwLength;
|
2007-09-21 12:21:17 +02:00
|
|
|
BOOL ret;
|
2007-09-20 18:15:16 +02:00
|
|
|
|
|
|
|
hKey = SetupDiOpenClassRegKeyExA(ClassGuid,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
DIOCR_INSTALLER,
|
|
|
|
MachineName,
|
|
|
|
Reserved);
|
|
|
|
if (hKey == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
WARN("SetupDiOpenClassRegKeyExA() failed (Error %u)\n", GetLastError());
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dwLength = ClassDescriptionSize;
|
2007-09-21 12:21:17 +02:00
|
|
|
ret = !RegQueryValueExA( hKey, NULL, NULL, NULL,
|
|
|
|
(LPBYTE)ClassDescription, &dwLength );
|
|
|
|
if (RequiredSize) *RequiredSize = dwLength;
|
2007-09-20 18:15:16 +02:00
|
|
|
RegCloseKey(hKey);
|
2007-09-21 12:21:17 +02:00
|
|
|
return ret;
|
2004-12-02 19:09:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetClassDescriptionExW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiGetClassDescriptionExW(
|
|
|
|
const GUID* ClassGuid,
|
|
|
|
PWSTR ClassDescription,
|
|
|
|
DWORD ClassDescriptionSize,
|
|
|
|
PDWORD RequiredSize,
|
|
|
|
PCWSTR MachineName,
|
|
|
|
PVOID Reserved)
|
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
DWORD dwLength;
|
2007-09-21 12:21:17 +02:00
|
|
|
BOOL ret;
|
2004-12-02 19:09:53 +01:00
|
|
|
|
|
|
|
hKey = SetupDiOpenClassRegKeyExW(ClassGuid,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
DIOCR_INSTALLER,
|
|
|
|
MachineName,
|
|
|
|
Reserved);
|
|
|
|
if (hKey == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
2006-10-13 23:32:50 +02:00
|
|
|
WARN("SetupDiOpenClassRegKeyExW() failed (Error %u)\n", GetLastError());
|
2004-12-02 19:09:53 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dwLength = ClassDescriptionSize * sizeof(WCHAR);
|
2007-09-21 12:21:17 +02:00
|
|
|
ret = !RegQueryValueExW( hKey, NULL, NULL, NULL,
|
|
|
|
(LPBYTE)ClassDescription, &dwLength );
|
|
|
|
if (RequiredSize) *RequiredSize = dwLength / sizeof(WCHAR);
|
2004-12-02 19:09:53 +01:00
|
|
|
RegCloseKey(hKey);
|
2007-09-21 12:21:17 +02:00
|
|
|
return ret;
|
2004-12-02 19:09:53 +01:00
|
|
|
}
|
|
|
|
|
2002-06-05 00:12:50 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetClassDevsA (SETUPAPI.@)
|
|
|
|
*/
|
2013-09-23 00:37:16 +02:00
|
|
|
HDEVINFO WINAPI SetupDiGetClassDevsA(const GUID *class, LPCSTR enumstr, HWND parent, DWORD flags)
|
2002-05-29 00:39:14 +02:00
|
|
|
{
|
2005-03-01 12:44:27 +01:00
|
|
|
HDEVINFO ret;
|
|
|
|
LPWSTR enumstrW = NULL;
|
2002-05-29 00:39:14 +02:00
|
|
|
|
2005-03-01 12:44:27 +01:00
|
|
|
if (enumstr)
|
|
|
|
{
|
|
|
|
int len = MultiByteToWideChar(CP_ACP, 0, enumstr, -1, NULL, 0);
|
|
|
|
enumstrW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (!enumstrW)
|
|
|
|
{
|
2008-01-19 15:56:39 +01:00
|
|
|
ret = INVALID_HANDLE_VALUE;
|
2005-03-01 12:44:27 +01:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, enumstr, -1, enumstrW, len);
|
|
|
|
}
|
2007-09-24 22:02:58 +02:00
|
|
|
ret = SetupDiGetClassDevsExW(class, enumstrW, parent, flags, NULL, NULL,
|
|
|
|
NULL);
|
2005-03-01 12:44:27 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, enumstrW);
|
|
|
|
|
|
|
|
end:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-09-24 22:32:46 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetClassDevsExA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
HDEVINFO WINAPI SetupDiGetClassDevsExA(
|
|
|
|
const GUID *class,
|
|
|
|
PCSTR enumstr,
|
|
|
|
HWND parent,
|
|
|
|
DWORD flags,
|
|
|
|
HDEVINFO deviceset,
|
|
|
|
PCSTR machine,
|
|
|
|
PVOID reserved)
|
|
|
|
{
|
|
|
|
HDEVINFO ret;
|
|
|
|
LPWSTR enumstrW = NULL, machineW = NULL;
|
|
|
|
|
|
|
|
if (enumstr)
|
|
|
|
{
|
|
|
|
int len = MultiByteToWideChar(CP_ACP, 0, enumstr, -1, NULL, 0);
|
|
|
|
enumstrW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (!enumstrW)
|
|
|
|
{
|
2008-01-19 15:56:39 +01:00
|
|
|
ret = INVALID_HANDLE_VALUE;
|
2007-09-24 22:32:46 +02:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, enumstr, -1, enumstrW, len);
|
|
|
|
}
|
|
|
|
if (machine)
|
|
|
|
{
|
|
|
|
int len = MultiByteToWideChar(CP_ACP, 0, machine, -1, NULL, 0);
|
|
|
|
machineW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (!machineW)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, enumstrW);
|
2008-01-19 15:56:39 +01:00
|
|
|
ret = INVALID_HANDLE_VALUE;
|
2007-09-24 22:32:46 +02:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, machine, -1, machineW, len);
|
|
|
|
}
|
|
|
|
ret = SetupDiGetClassDevsExW(class, enumstrW, parent, flags, deviceset,
|
|
|
|
machineW, reserved);
|
|
|
|
HeapFree(GetProcessHeap(), 0, enumstrW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, machineW);
|
|
|
|
|
|
|
|
end:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-09-21 20:37:09 +02:00
|
|
|
static void SETUPDI_AddDeviceInterfaces(SP_DEVINFO_DATA *dev, HKEY key,
|
2009-02-09 13:04:55 +01:00
|
|
|
const GUID *guid)
|
2007-09-21 20:37:09 +02:00
|
|
|
{
|
|
|
|
DWORD i, len;
|
|
|
|
WCHAR subKeyName[MAX_PATH];
|
|
|
|
LONG l = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
for (i = 0; !l; i++)
|
|
|
|
{
|
|
|
|
len = sizeof(subKeyName) / sizeof(subKeyName[0]);
|
|
|
|
l = RegEnumKeyExW(key, i, subKeyName, &len, NULL, NULL, NULL, NULL);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
HKEY subKey;
|
|
|
|
SP_DEVICE_INTERFACE_DATA *iface = NULL;
|
|
|
|
|
2008-03-28 16:49:34 +01:00
|
|
|
if (*subKeyName == '#')
|
2007-09-21 20:37:09 +02:00
|
|
|
{
|
2008-03-28 16:49:34 +01:00
|
|
|
/* The subkey name is the reference string, with a '#' prepended */
|
2009-02-09 13:04:55 +01:00
|
|
|
SETUPDI_AddInterfaceInstance(dev, guid, subKeyName + 1, &iface);
|
2008-03-28 16:49:34 +01:00
|
|
|
l = RegOpenKeyExW(key, subKeyName, 0, KEY_READ, &subKey);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
WCHAR symbolicLink[MAX_PATH];
|
|
|
|
DWORD dataType;
|
|
|
|
|
|
|
|
len = sizeof(symbolicLink);
|
|
|
|
l = RegQueryValueExW(subKey, SymbolicLink, NULL, &dataType,
|
|
|
|
(BYTE *)symbolicLink, &len);
|
|
|
|
if (!l && dataType == REG_SZ)
|
|
|
|
SETUPDI_SetInterfaceSymbolicLink(iface, symbolicLink);
|
|
|
|
RegCloseKey(subKey);
|
|
|
|
}
|
2007-09-21 20:37:09 +02:00
|
|
|
}
|
2007-10-12 17:26:56 +02:00
|
|
|
/* Allow enumeration to continue */
|
|
|
|
l = ERROR_SUCCESS;
|
2007-09-21 20:37:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* FIXME: find and add all the device's interfaces to the device */
|
|
|
|
}
|
|
|
|
|
2007-09-20 18:16:45 +02:00
|
|
|
static void SETUPDI_EnumerateMatchingInterfaces(HDEVINFO DeviceInfoSet,
|
2009-02-09 13:04:55 +01:00
|
|
|
HKEY key, const GUID *guid, LPCWSTR enumstr)
|
2007-09-20 18:16:45 +02:00
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-09-20 18:16:45 +02:00
|
|
|
DWORD i, len;
|
|
|
|
WCHAR subKeyName[MAX_PATH];
|
|
|
|
LONG l;
|
|
|
|
HKEY enumKey = INVALID_HANDLE_VALUE;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(enumstr));
|
|
|
|
|
|
|
|
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, Enum, 0, NULL, 0, KEY_READ, NULL,
|
|
|
|
&enumKey, NULL);
|
|
|
|
for (i = 0; !l; i++)
|
|
|
|
{
|
|
|
|
len = sizeof(subKeyName) / sizeof(subKeyName[0]);
|
|
|
|
l = RegEnumKeyExW(key, i, subKeyName, &len, NULL, NULL, NULL, NULL);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
HKEY subKey;
|
|
|
|
|
|
|
|
l = RegOpenKeyExW(key, subKeyName, 0, KEY_READ, &subKey);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
WCHAR deviceInst[MAX_PATH * 3];
|
|
|
|
DWORD dataType;
|
|
|
|
|
|
|
|
len = sizeof(deviceInst);
|
|
|
|
l = RegQueryValueExW(subKey, DeviceInstance, NULL, &dataType,
|
|
|
|
(BYTE *)deviceInst, &len);
|
|
|
|
if (!l && dataType == REG_SZ)
|
|
|
|
{
|
|
|
|
TRACE("found instance ID %s\n", debugstr_w(deviceInst));
|
|
|
|
if (!enumstr || !lstrcmpiW(enumstr, deviceInst))
|
|
|
|
{
|
|
|
|
HKEY deviceKey;
|
|
|
|
|
|
|
|
l = RegOpenKeyExW(enumKey, deviceInst, 0, KEY_READ,
|
|
|
|
&deviceKey);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
WCHAR deviceClassStr[40];
|
|
|
|
|
|
|
|
len = sizeof(deviceClassStr);
|
|
|
|
l = RegQueryValueExW(deviceKey, ClassGUID, NULL,
|
|
|
|
&dataType, (BYTE *)deviceClassStr, &len);
|
|
|
|
if (!l && dataType == REG_SZ &&
|
|
|
|
deviceClassStr[0] == '{' &&
|
|
|
|
deviceClassStr[37] == '}')
|
|
|
|
{
|
|
|
|
GUID deviceClass;
|
|
|
|
SP_DEVINFO_DATA *dev;
|
|
|
|
|
|
|
|
deviceClassStr[37] = 0;
|
|
|
|
UuidFromStringW(&deviceClassStr[1],
|
|
|
|
&deviceClass);
|
2007-09-21 20:37:09 +02:00
|
|
|
if (SETUPDI_AddDeviceToSet(set, &deviceClass,
|
2007-09-20 18:16:45 +02:00
|
|
|
0 /* FIXME: DevInst */, deviceInst,
|
2007-09-21 20:37:09 +02:00
|
|
|
FALSE, &dev))
|
2009-02-09 13:04:55 +01:00
|
|
|
SETUPDI_AddDeviceInterfaces(dev, subKey, guid);
|
2007-09-20 18:16:45 +02:00
|
|
|
}
|
|
|
|
RegCloseKey(deviceKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey(subKey);
|
|
|
|
}
|
2007-10-12 17:26:56 +02:00
|
|
|
/* Allow enumeration to continue */
|
|
|
|
l = ERROR_SUCCESS;
|
2007-09-20 18:16:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (enumKey != INVALID_HANDLE_VALUE)
|
|
|
|
RegCloseKey(enumKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SETUPDI_EnumerateInterfaces(HDEVINFO DeviceInfoSet,
|
2009-02-09 13:04:55 +01:00
|
|
|
const GUID *guid, LPCWSTR enumstr, DWORD flags)
|
2007-09-20 18:16:45 +02:00
|
|
|
{
|
2009-02-09 13:04:55 +01:00
|
|
|
HKEY interfacesKey = SetupDiOpenClassRegKeyExW(guid, KEY_READ,
|
2007-09-20 18:16:45 +02:00
|
|
|
DIOCR_INTERFACE, NULL, NULL);
|
|
|
|
|
2009-02-09 13:04:55 +01:00
|
|
|
TRACE("%p, %s, %s, %08x\n", DeviceInfoSet, debugstr_guid(guid),
|
2007-09-20 18:16:45 +02:00
|
|
|
debugstr_w(enumstr), flags);
|
|
|
|
|
|
|
|
if (interfacesKey != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
if (flags & DIGCF_ALLCLASSES)
|
|
|
|
{
|
|
|
|
DWORD i, len;
|
|
|
|
WCHAR interfaceGuidStr[40];
|
|
|
|
LONG l = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
for (i = 0; !l; i++)
|
|
|
|
{
|
|
|
|
len = sizeof(interfaceGuidStr) / sizeof(interfaceGuidStr[0]);
|
|
|
|
l = RegEnumKeyExW(interfacesKey, i, interfaceGuidStr, &len,
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
if (interfaceGuidStr[0] == '{' &&
|
|
|
|
interfaceGuidStr[37] == '}')
|
|
|
|
{
|
|
|
|
HKEY interfaceKey;
|
|
|
|
GUID interfaceGuid;
|
|
|
|
|
|
|
|
interfaceGuidStr[37] = 0;
|
|
|
|
UuidFromStringW(&interfaceGuidStr[1], &interfaceGuid);
|
2015-05-01 14:58:37 +02:00
|
|
|
interfaceGuidStr[37] = '}';
|
|
|
|
interfaceGuidStr[38] = 0;
|
2007-09-20 18:16:45 +02:00
|
|
|
l = RegOpenKeyExW(interfacesKey, interfaceGuidStr, 0,
|
|
|
|
KEY_READ, &interfaceKey);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
SETUPDI_EnumerateMatchingInterfaces(DeviceInfoSet,
|
|
|
|
interfaceKey, &interfaceGuid, enumstr);
|
|
|
|
RegCloseKey(interfaceKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* In this case, SetupDiOpenClassRegKeyExW opened the specific
|
|
|
|
* interface's key, so just pass that long
|
|
|
|
*/
|
|
|
|
SETUPDI_EnumerateMatchingInterfaces(DeviceInfoSet,
|
2009-02-09 13:04:55 +01:00
|
|
|
interfacesKey, guid, enumstr);
|
2007-09-20 18:16:45 +02:00
|
|
|
}
|
|
|
|
RegCloseKey(interfacesKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-12 17:30:10 +02:00
|
|
|
static void SETUPDI_EnumerateMatchingDeviceInstances(struct DeviceInfoSet *set,
|
|
|
|
LPCWSTR enumerator, LPCWSTR deviceName, HKEY deviceKey,
|
|
|
|
const GUID *class, DWORD flags)
|
2007-09-20 18:16:45 +02:00
|
|
|
{
|
|
|
|
DWORD i, len;
|
2007-10-12 17:30:10 +02:00
|
|
|
WCHAR deviceInstance[MAX_PATH];
|
2007-09-20 18:16:45 +02:00
|
|
|
LONG l = ERROR_SUCCESS;
|
|
|
|
|
2007-10-12 17:30:10 +02:00
|
|
|
TRACE("%s %s\n", debugstr_w(enumerator), debugstr_w(deviceName));
|
2007-09-20 18:16:45 +02:00
|
|
|
|
|
|
|
for (i = 0; !l; i++)
|
|
|
|
{
|
2007-10-12 17:30:10 +02:00
|
|
|
len = sizeof(deviceInstance) / sizeof(deviceInstance[0]);
|
|
|
|
l = RegEnumKeyExW(deviceKey, i, deviceInstance, &len, NULL, NULL, NULL,
|
|
|
|
NULL);
|
2007-09-20 18:16:45 +02:00
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
HKEY subKey;
|
|
|
|
|
2007-10-12 17:30:10 +02:00
|
|
|
l = RegOpenKeyExW(deviceKey, deviceInstance, 0, KEY_READ, &subKey);
|
2007-09-20 18:16:45 +02:00
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
WCHAR classGuid[40];
|
|
|
|
DWORD dataType;
|
|
|
|
|
|
|
|
len = sizeof(classGuid);
|
|
|
|
l = RegQueryValueExW(subKey, ClassGUID, NULL, &dataType,
|
|
|
|
(BYTE *)classGuid, &len);
|
|
|
|
if (!l && dataType == REG_SZ)
|
|
|
|
{
|
|
|
|
if (classGuid[0] == '{' && classGuid[37] == '}')
|
|
|
|
{
|
|
|
|
GUID deviceClass;
|
|
|
|
|
|
|
|
classGuid[37] = 0;
|
|
|
|
UuidFromStringW(&classGuid[1], &deviceClass);
|
|
|
|
if ((flags & DIGCF_ALLCLASSES) ||
|
|
|
|
IsEqualGUID(class, &deviceClass))
|
|
|
|
{
|
2007-10-25 17:10:59 +02:00
|
|
|
static const WCHAR fmt[] =
|
|
|
|
{'%','s','\\','%','s','\\','%','s',0};
|
2007-09-20 18:16:45 +02:00
|
|
|
LPWSTR instanceId;
|
|
|
|
|
|
|
|
instanceId = HeapAlloc(GetProcessHeap(), 0,
|
2007-10-25 17:10:59 +02:00
|
|
|
(lstrlenW(enumerator) + lstrlenW(deviceName) +
|
|
|
|
lstrlenW(deviceInstance) + 3) * sizeof(WCHAR));
|
2007-09-20 18:16:45 +02:00
|
|
|
if (instanceId)
|
|
|
|
{
|
2007-10-25 17:10:59 +02:00
|
|
|
sprintfW(instanceId, fmt, enumerator,
|
|
|
|
deviceName, deviceInstance);
|
2007-09-20 18:16:45 +02:00
|
|
|
SETUPDI_AddDeviceToSet(set, &deviceClass,
|
|
|
|
0 /* FIXME: DevInst */, instanceId,
|
2007-10-11 22:25:08 +02:00
|
|
|
FALSE, NULL);
|
2007-09-20 18:16:45 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, instanceId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey(subKey);
|
|
|
|
}
|
2007-10-12 17:26:56 +02:00
|
|
|
/* Allow enumeration to continue */
|
|
|
|
l = ERROR_SUCCESS;
|
2007-09-20 18:16:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-12 17:30:10 +02:00
|
|
|
static void SETUPDI_EnumerateMatchingDevices(HDEVINFO DeviceInfoSet,
|
|
|
|
LPCWSTR parent, HKEY key, const GUID *class, DWORD flags)
|
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-10-12 17:30:10 +02:00
|
|
|
DWORD i, len;
|
|
|
|
WCHAR subKeyName[MAX_PATH];
|
|
|
|
LONG l = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(parent));
|
|
|
|
|
|
|
|
for (i = 0; !l; i++)
|
|
|
|
{
|
|
|
|
len = sizeof(subKeyName) / sizeof(subKeyName[0]);
|
|
|
|
l = RegEnumKeyExW(key, i, subKeyName, &len, NULL, NULL, NULL, NULL);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
HKEY subKey;
|
|
|
|
|
|
|
|
l = RegOpenKeyExW(key, subKeyName, 0, KEY_READ, &subKey);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
TRACE("%s\n", debugstr_w(subKeyName));
|
|
|
|
SETUPDI_EnumerateMatchingDeviceInstances(set, parent,
|
|
|
|
subKeyName, subKey, class, flags);
|
|
|
|
RegCloseKey(subKey);
|
|
|
|
}
|
|
|
|
/* Allow enumeration to continue */
|
|
|
|
l = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-20 18:16:45 +02:00
|
|
|
static void SETUPDI_EnumerateDevices(HDEVINFO DeviceInfoSet, const GUID *class,
|
|
|
|
LPCWSTR enumstr, DWORD flags)
|
|
|
|
{
|
2007-10-12 17:30:10 +02:00
|
|
|
HKEY enumKey;
|
|
|
|
LONG l;
|
2007-09-20 18:16:45 +02:00
|
|
|
|
|
|
|
TRACE("%p, %s, %s, %08x\n", DeviceInfoSet, debugstr_guid(class),
|
|
|
|
debugstr_w(enumstr), flags);
|
|
|
|
|
2007-10-12 17:30:10 +02:00
|
|
|
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, Enum, 0, NULL, 0, KEY_READ, NULL,
|
|
|
|
&enumKey, NULL);
|
|
|
|
if (enumKey != INVALID_HANDLE_VALUE)
|
2007-09-20 18:16:45 +02:00
|
|
|
{
|
|
|
|
if (enumstr)
|
|
|
|
{
|
2007-10-12 17:30:10 +02:00
|
|
|
HKEY enumStrKey;
|
2007-09-20 18:16:45 +02:00
|
|
|
|
2007-10-12 17:30:10 +02:00
|
|
|
l = RegOpenKeyExW(enumKey, enumstr, 0, KEY_READ,
|
|
|
|
&enumStrKey);
|
2007-09-20 18:16:45 +02:00
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
SETUPDI_EnumerateMatchingDevices(DeviceInfoSet, enumstr,
|
2007-10-12 17:30:10 +02:00
|
|
|
enumStrKey, class, flags);
|
|
|
|
RegCloseKey(enumStrKey);
|
2007-09-20 18:16:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD i, len;
|
|
|
|
WCHAR subKeyName[MAX_PATH];
|
|
|
|
|
2007-10-12 17:30:10 +02:00
|
|
|
l = ERROR_SUCCESS;
|
2007-09-20 18:16:45 +02:00
|
|
|
for (i = 0; !l; i++)
|
|
|
|
{
|
|
|
|
len = sizeof(subKeyName) / sizeof(subKeyName[0]);
|
2007-10-12 17:30:10 +02:00
|
|
|
l = RegEnumKeyExW(enumKey, i, subKeyName, &len, NULL,
|
2007-09-20 18:16:45 +02:00
|
|
|
NULL, NULL, NULL);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
HKEY subKey;
|
|
|
|
|
2007-10-12 17:30:10 +02:00
|
|
|
l = RegOpenKeyExW(enumKey, subKeyName, 0, KEY_READ,
|
2007-09-20 18:16:45 +02:00
|
|
|
&subKey);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
SETUPDI_EnumerateMatchingDevices(DeviceInfoSet,
|
|
|
|
subKeyName, subKey, class, flags);
|
|
|
|
RegCloseKey(subKey);
|
|
|
|
}
|
2007-10-12 17:26:56 +02:00
|
|
|
/* Allow enumeration to continue */
|
|
|
|
l = ERROR_SUCCESS;
|
2007-09-20 18:16:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-12 17:30:10 +02:00
|
|
|
RegCloseKey(enumKey);
|
2007-09-20 18:16:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-10 20:57:32 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetClassDevsW (SETUPAPI.@)
|
|
|
|
*/
|
2013-09-23 00:37:16 +02:00
|
|
|
HDEVINFO WINAPI SetupDiGetClassDevsW(const GUID *class, LPCWSTR enumstr, HWND parent, DWORD flags)
|
2002-10-10 20:57:32 +02:00
|
|
|
{
|
2007-09-24 22:02:01 +02:00
|
|
|
return SetupDiGetClassDevsExW(class, enumstr, parent, flags, NULL, NULL,
|
|
|
|
NULL);
|
2005-03-01 12:44:27 +01:00
|
|
|
}
|
|
|
|
|
2006-07-24 13:13:47 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetClassDevsExW (SETUPAPI.@)
|
|
|
|
*/
|
2013-09-23 00:37:16 +02:00
|
|
|
HDEVINFO WINAPI SetupDiGetClassDevsExW(const GUID *class, PCWSTR enumstr, HWND parent, DWORD flags,
|
|
|
|
HDEVINFO deviceset, PCWSTR machine, void *reserved)
|
2006-07-24 13:13:47 +02:00
|
|
|
{
|
2007-09-24 22:00:42 +02:00
|
|
|
static const DWORD unsupportedFlags = DIGCF_DEFAULT | DIGCF_PRESENT |
|
|
|
|
DIGCF_PROFILE;
|
|
|
|
HDEVINFO set;
|
|
|
|
|
|
|
|
TRACE("%s %s %p 0x%08x %p %s %p\n", debugstr_guid(class),
|
|
|
|
debugstr_w(enumstr), parent, flags, deviceset, debugstr_w(machine),
|
|
|
|
reserved);
|
|
|
|
|
|
|
|
if (!(flags & DIGCF_ALLCLASSES) && !class)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
2015-07-22 11:57:14 +02:00
|
|
|
return INVALID_HANDLE_VALUE;
|
2007-09-24 22:00:42 +02:00
|
|
|
}
|
|
|
|
if (flags & unsupportedFlags)
|
|
|
|
WARN("unsupported flags %08x\n", flags & unsupportedFlags);
|
|
|
|
if (deviceset)
|
|
|
|
set = deviceset;
|
|
|
|
else
|
|
|
|
set = SetupDiCreateDeviceInfoListExW(class, parent, machine, reserved);
|
2015-07-22 11:57:19 +02:00
|
|
|
if (set != INVALID_HANDLE_VALUE)
|
2007-09-24 22:00:42 +02:00
|
|
|
{
|
2011-06-09 20:35:11 +02:00
|
|
|
if (machine && *machine)
|
2007-09-24 22:00:42 +02:00
|
|
|
FIXME("%s: unimplemented for remote machines\n",
|
|
|
|
debugstr_w(machine));
|
|
|
|
else if (flags & DIGCF_DEVICEINTERFACE)
|
|
|
|
SETUPDI_EnumerateInterfaces(set, class, enumstr, flags);
|
|
|
|
else
|
|
|
|
SETUPDI_EnumerateDevices(set, class, enumstr, flags);
|
|
|
|
}
|
|
|
|
return set;
|
2006-07-24 13:13:47 +02:00
|
|
|
}
|
|
|
|
|
2007-09-24 21:45:42 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetDeviceInfoListDetailA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiGetDeviceInfoListDetailA(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_LIST_DETAIL_DATA_A DevInfoData )
|
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-09-24 21:45:42 +02:00
|
|
|
|
|
|
|
TRACE("%p %p\n", DeviceInfoSet, DevInfoData);
|
|
|
|
|
2008-01-19 15:56:39 +01:00
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
|
2007-09-24 21:45:42 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!DevInfoData ||
|
|
|
|
DevInfoData->cbSize != sizeof(SP_DEVINFO_LIST_DETAIL_DATA_A))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-03-16 00:25:45 +01:00
|
|
|
DevInfoData->ClassGuid = set->ClassGuid;
|
2007-09-24 21:45:42 +02:00
|
|
|
DevInfoData->RemoteMachineHandle = NULL;
|
|
|
|
DevInfoData->RemoteMachineName[0] = '\0';
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetDeviceInfoListDetailW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiGetDeviceInfoListDetailW(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_LIST_DETAIL_DATA_W DevInfoData )
|
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-09-24 21:45:42 +02:00
|
|
|
|
|
|
|
TRACE("%p %p\n", DeviceInfoSet, DevInfoData);
|
|
|
|
|
2008-01-19 15:56:39 +01:00
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
|
2007-09-24 21:45:42 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!DevInfoData ||
|
|
|
|
DevInfoData->cbSize != sizeof(SP_DEVINFO_LIST_DETAIL_DATA_W))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-03-16 00:25:45 +01:00
|
|
|
DevInfoData->ClassGuid = set->ClassGuid;
|
2007-09-24 21:45:42 +02:00
|
|
|
DevInfoData->RemoteMachineHandle = NULL;
|
|
|
|
DevInfoData->RemoteMachineName[0] = '\0';
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-09-21 20:33:43 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiCreateDeviceInterfaceA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiCreateDeviceInterfaceA(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
const GUID *InterfaceClassGuid,
|
|
|
|
PCSTR ReferenceString,
|
|
|
|
DWORD CreationFlags,
|
|
|
|
PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
|
|
|
|
{
|
2007-09-21 20:34:30 +02:00
|
|
|
BOOL ret;
|
|
|
|
LPWSTR ReferenceStringW = NULL;
|
|
|
|
|
2007-09-21 20:33:43 +02:00
|
|
|
TRACE("%p %p %s %s %08x %p\n", DeviceInfoSet, DeviceInfoData,
|
|
|
|
debugstr_guid(InterfaceClassGuid), debugstr_a(ReferenceString),
|
|
|
|
CreationFlags, DeviceInterfaceData);
|
|
|
|
|
2007-09-21 20:34:30 +02:00
|
|
|
if (ReferenceString)
|
|
|
|
{
|
|
|
|
ReferenceStringW = MultiByteToUnicode(ReferenceString, CP_ACP);
|
|
|
|
if (ReferenceStringW == NULL) return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = SetupDiCreateDeviceInterfaceW(DeviceInfoSet, DeviceInfoData,
|
|
|
|
InterfaceClassGuid, ReferenceStringW, CreationFlags,
|
|
|
|
DeviceInterfaceData);
|
|
|
|
|
|
|
|
MyFree(ReferenceStringW);
|
|
|
|
|
|
|
|
return ret;
|
2007-09-21 20:33:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiCreateDeviceInterfaceW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiCreateDeviceInterfaceW(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
const GUID *InterfaceClassGuid,
|
|
|
|
PCWSTR ReferenceString,
|
|
|
|
DWORD CreationFlags,
|
|
|
|
PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
|
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-09-22 02:07:37 +02:00
|
|
|
struct DeviceInfo *devInfo;
|
2007-09-21 20:36:12 +02:00
|
|
|
SP_DEVICE_INTERFACE_DATA *iface = NULL;
|
|
|
|
BOOL ret;
|
2007-09-21 20:34:53 +02:00
|
|
|
|
2007-09-21 20:33:43 +02:00
|
|
|
TRACE("%p %p %s %s %08x %p\n", DeviceInfoSet, DeviceInfoData,
|
|
|
|
debugstr_guid(InterfaceClassGuid), debugstr_w(ReferenceString),
|
|
|
|
CreationFlags, DeviceInterfaceData);
|
|
|
|
|
2008-01-19 15:56:39 +01:00
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
|
2007-09-21 20:34:53 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA)
|
|
|
|
|| !DeviceInfoData->Reserved)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-09-22 02:07:37 +02:00
|
|
|
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
|
|
|
if (devInfo->set != set)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-09-21 20:34:53 +02:00
|
|
|
if (!InterfaceClassGuid)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-09-22 02:06:18 +02:00
|
|
|
if ((ret = SETUPDI_AddInterfaceInstance(DeviceInfoData, InterfaceClassGuid,
|
2007-09-21 20:36:12 +02:00
|
|
|
ReferenceString, &iface)))
|
|
|
|
{
|
|
|
|
if (DeviceInterfaceData)
|
|
|
|
{
|
|
|
|
if (DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
else
|
2008-03-16 00:25:45 +01:00
|
|
|
*DeviceInterfaceData = *iface;
|
2007-09-21 20:36:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
2007-09-21 20:33:43 +02:00
|
|
|
}
|
|
|
|
|
2007-09-22 02:05:48 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiCreateDeviceInterfaceRegKeyA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyA(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
|
|
|
|
DWORD Reserved,
|
|
|
|
REGSAM samDesired,
|
|
|
|
HINF InfHandle,
|
|
|
|
PCSTR InfSectionName)
|
|
|
|
{
|
2007-09-22 02:07:16 +02:00
|
|
|
HKEY key;
|
|
|
|
PWSTR InfSectionNameW = NULL;
|
|
|
|
|
|
|
|
TRACE("%p %p %d %08x %p %p\n", DeviceInfoSet, DeviceInterfaceData, Reserved,
|
2007-09-22 02:05:48 +02:00
|
|
|
samDesired, InfHandle, InfSectionName);
|
2007-09-22 02:07:16 +02:00
|
|
|
if (InfHandle)
|
|
|
|
{
|
|
|
|
if (!InfSectionName)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
InfSectionNameW = MultiByteToUnicode(InfSectionName, CP_ACP);
|
|
|
|
if (!InfSectionNameW)
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
key = SetupDiCreateDeviceInterfaceRegKeyW(DeviceInfoSet,
|
|
|
|
DeviceInterfaceData, Reserved, samDesired, InfHandle,
|
|
|
|
InfSectionNameW);
|
|
|
|
MyFree(InfSectionNameW);
|
|
|
|
return key;
|
2007-09-22 02:05:48 +02:00
|
|
|
}
|
|
|
|
|
2007-09-22 02:08:28 +02:00
|
|
|
static PWSTR SETUPDI_GetInstancePath(struct InterfaceInfo *ifaceInfo)
|
|
|
|
{
|
|
|
|
static const WCHAR hash[] = {'#',0};
|
|
|
|
PWSTR instancePath = NULL;
|
|
|
|
|
|
|
|
if (ifaceInfo->referenceString)
|
|
|
|
{
|
|
|
|
instancePath = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
(lstrlenW(ifaceInfo->referenceString) + 2) * sizeof(WCHAR));
|
|
|
|
if (instancePath)
|
|
|
|
{
|
|
|
|
lstrcpyW(instancePath, hash);
|
|
|
|
lstrcatW(instancePath, ifaceInfo->referenceString);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetLastError(ERROR_OUTOFMEMORY);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
instancePath = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
(lstrlenW(hash) + 1) * sizeof(WCHAR));
|
|
|
|
if (instancePath)
|
|
|
|
lstrcpyW(instancePath, hash);
|
|
|
|
}
|
|
|
|
return instancePath;
|
|
|
|
}
|
|
|
|
|
2007-09-22 02:05:48 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiCreateDeviceInterfaceRegKeyW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
HKEY WINAPI SetupDiCreateDeviceInterfaceRegKeyW(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
|
|
|
|
DWORD Reserved,
|
|
|
|
REGSAM samDesired,
|
|
|
|
HINF InfHandle,
|
|
|
|
PCWSTR InfSectionName)
|
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-09-22 02:07:16 +02:00
|
|
|
HKEY key = INVALID_HANDLE_VALUE, interfacesKey;
|
|
|
|
LONG l;
|
|
|
|
|
|
|
|
TRACE("%p %p %d %08x %p %p\n", DeviceInfoSet, DeviceInterfaceData, Reserved,
|
2007-09-22 02:05:48 +02:00
|
|
|
samDesired, InfHandle, InfSectionName);
|
2007-09-22 02:07:16 +02:00
|
|
|
|
2008-01-19 15:56:39 +01:00
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE ||
|
2007-09-22 02:07:16 +02:00
|
|
|
set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
if (!DeviceInterfaceData ||
|
|
|
|
DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA) ||
|
|
|
|
!DeviceInterfaceData->Reserved)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
if (InfHandle && !InfSectionName)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
if (!(l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, DeviceClasses, 0, NULL, 0,
|
|
|
|
samDesired, NULL, &interfacesKey, NULL)))
|
|
|
|
{
|
|
|
|
HKEY parent;
|
|
|
|
WCHAR bracedGuidString[39];
|
|
|
|
|
|
|
|
SETUPDI_GuidToString(&DeviceInterfaceData->InterfaceClassGuid,
|
|
|
|
bracedGuidString);
|
|
|
|
if (!(l = RegCreateKeyExW(interfacesKey, bracedGuidString, 0, NULL, 0,
|
|
|
|
samDesired, NULL, &parent, NULL)))
|
|
|
|
{
|
|
|
|
struct InterfaceInfo *ifaceInfo =
|
|
|
|
(struct InterfaceInfo *)DeviceInterfaceData->Reserved;
|
2007-09-22 02:08:28 +02:00
|
|
|
PWSTR instancePath = SETUPDI_GetInstancePath(ifaceInfo);
|
2008-04-01 13:25:01 +02:00
|
|
|
PWSTR interfKeyName = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
(lstrlenW(ifaceInfo->symbolicLink) + 1) * sizeof(WCHAR));
|
|
|
|
HKEY interfKey;
|
|
|
|
WCHAR *ptr;
|
2007-09-22 02:07:16 +02:00
|
|
|
|
2008-04-01 13:25:01 +02:00
|
|
|
lstrcpyW(interfKeyName, ifaceInfo->symbolicLink);
|
|
|
|
if (lstrlenW(ifaceInfo->symbolicLink) > 3)
|
2007-09-22 02:07:16 +02:00
|
|
|
{
|
2008-04-01 13:25:01 +02:00
|
|
|
interfKeyName[0] = '#';
|
|
|
|
interfKeyName[1] = '#';
|
|
|
|
interfKeyName[3] = '#';
|
|
|
|
}
|
|
|
|
ptr = strchrW(interfKeyName, '\\');
|
|
|
|
if (ptr)
|
|
|
|
*ptr = 0;
|
|
|
|
l = RegCreateKeyExW(parent, interfKeyName, 0, NULL, 0,
|
|
|
|
samDesired, NULL, &interfKey, NULL);
|
|
|
|
if (!l)
|
|
|
|
{
|
2008-04-01 13:25:10 +02:00
|
|
|
struct DeviceInfo *devInfo =
|
|
|
|
(struct DeviceInfo *)ifaceInfo->device->Reserved;
|
2008-04-01 13:25:01 +02:00
|
|
|
|
2008-04-01 13:25:10 +02:00
|
|
|
l = RegSetValueExW(interfKey, DeviceInstance, 0, REG_SZ,
|
|
|
|
(BYTE *)devInfo->instanceId,
|
|
|
|
(lstrlenW(devInfo->instanceId) + 1) * sizeof(WCHAR));
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
if (instancePath)
|
2008-04-01 13:25:01 +02:00
|
|
|
{
|
2008-04-01 13:25:10 +02:00
|
|
|
LONG l;
|
|
|
|
|
|
|
|
l = RegCreateKeyExW(interfKey, instancePath, 0, NULL, 0,
|
|
|
|
samDesired, NULL, &key, NULL);
|
|
|
|
if (l)
|
|
|
|
{
|
|
|
|
SetLastError(l);
|
|
|
|
key = INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
else if (InfHandle)
|
|
|
|
FIXME("INF section installation unsupported\n");
|
2008-04-01 13:25:01 +02:00
|
|
|
}
|
2007-09-22 02:07:16 +02:00
|
|
|
}
|
2008-04-01 13:25:10 +02:00
|
|
|
else
|
|
|
|
SetLastError(l);
|
2008-04-01 13:25:01 +02:00
|
|
|
RegCloseKey(interfKey);
|
2007-09-22 02:07:16 +02:00
|
|
|
}
|
2008-04-01 13:25:01 +02:00
|
|
|
else
|
|
|
|
SetLastError(l);
|
|
|
|
HeapFree(GetProcessHeap(), 0, interfKeyName);
|
2007-09-22 02:08:28 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, instancePath);
|
2007-09-22 02:07:16 +02:00
|
|
|
RegCloseKey(parent);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetLastError(l);
|
|
|
|
RegCloseKey(interfacesKey);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetLastError(l);
|
|
|
|
return key;
|
2007-09-22 02:05:48 +02:00
|
|
|
}
|
|
|
|
|
2007-09-22 02:08:28 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiDeleteDeviceInterfaceRegKey (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiDeleteDeviceInterfaceRegKey(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
|
|
|
|
DWORD Reserved)
|
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-09-22 02:08:28 +02:00
|
|
|
HKEY parent;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
TRACE("%p %p %d\n", DeviceInfoSet, DeviceInterfaceData, Reserved);
|
|
|
|
|
2008-01-19 15:56:39 +01:00
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE ||
|
2007-09-22 02:08:28 +02:00
|
|
|
set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!DeviceInterfaceData ||
|
|
|
|
DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA) ||
|
|
|
|
!DeviceInterfaceData->Reserved)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
parent = SetupDiOpenClassRegKeyExW(&DeviceInterfaceData->InterfaceClassGuid,
|
|
|
|
KEY_ALL_ACCESS, DIOCR_INTERFACE, NULL, NULL);
|
|
|
|
if (parent != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
struct InterfaceInfo *ifaceInfo =
|
|
|
|
(struct InterfaceInfo *)DeviceInterfaceData->Reserved;
|
|
|
|
PWSTR instancePath = SETUPDI_GetInstancePath(ifaceInfo);
|
|
|
|
|
|
|
|
if (instancePath)
|
|
|
|
{
|
|
|
|
LONG l = RegDeleteKeyW(parent, instancePath);
|
|
|
|
|
|
|
|
if (l)
|
|
|
|
SetLastError(l);
|
|
|
|
else
|
|
|
|
ret = TRUE;
|
|
|
|
HeapFree(GetProcessHeap(), 0, instancePath);
|
|
|
|
}
|
|
|
|
RegCloseKey(parent);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-03-01 12:44:27 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiEnumDeviceInterfaces (SETUPAPI.@)
|
2007-09-21 20:36:37 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* DeviceInfoSet [I] Set of devices from which to enumerate
|
|
|
|
* interfaces
|
|
|
|
* DeviceInfoData [I] (Optional) If specified, a specific device
|
|
|
|
* instance from which to enumerate interfaces.
|
|
|
|
* If it isn't specified, all interfaces for all
|
|
|
|
* devices in the set are enumerated.
|
|
|
|
* InterfaceClassGuid [I] The interface class to enumerate.
|
|
|
|
* MemberIndex [I] An index of the interface instance to enumerate.
|
|
|
|
* A caller should start with MemberIndex set to 0,
|
|
|
|
* and continue until the function fails with
|
|
|
|
* ERROR_NO_MORE_ITEMS.
|
|
|
|
* DeviceInterfaceData [I/O] Returns an enumerated interface. Its cbSize
|
|
|
|
* member must be set to
|
|
|
|
* sizeof(SP_DEVICE_INTERFACE_DATA).
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: non-zero value.
|
|
|
|
* Failure: FALSE. Call GetLastError() for more info.
|
2005-03-01 12:44:27 +01:00
|
|
|
*/
|
2013-09-23 00:37:16 +02:00
|
|
|
BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
const GUID *InterfaceClassGuid, DWORD MemberIndex,
|
|
|
|
PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
|
2005-03-01 12:44:27 +01:00
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2005-03-01 12:44:27 +01:00
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
2007-09-21 20:36:37 +02:00
|
|
|
TRACE("%p, %p, %s, %d, %p\n", DeviceInfoSet, DeviceInfoData,
|
2005-03-01 12:44:27 +01:00
|
|
|
debugstr_guid(InterfaceClassGuid), MemberIndex, DeviceInterfaceData);
|
|
|
|
|
2008-01-19 15:56:39 +01:00
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE ||
|
2007-09-21 20:36:37 +02:00
|
|
|
set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
2006-08-04 22:31:59 +02:00
|
|
|
{
|
2007-09-21 20:36:37 +02:00
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (DeviceInfoData && (DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA) ||
|
|
|
|
!DeviceInfoData->Reserved))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!DeviceInterfaceData ||
|
|
|
|
DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-03-15 00:45:19 +01:00
|
|
|
|
2011-05-14 23:55:28 +02:00
|
|
|
/* In case application fails to check return value, clear output */
|
|
|
|
memset(DeviceInterfaceData, 0, sizeof(*DeviceInterfaceData));
|
2014-03-15 00:45:19 +01:00
|
|
|
DeviceInterfaceData->cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
|
|
|
|
2007-09-21 20:36:37 +02:00
|
|
|
if (DeviceInfoData)
|
|
|
|
{
|
|
|
|
struct DeviceInfo *devInfo =
|
|
|
|
(struct DeviceInfo *)DeviceInfoData->Reserved;
|
2007-09-22 02:04:09 +02:00
|
|
|
struct InterfaceInstances *iface;
|
2007-09-21 20:36:37 +02:00
|
|
|
|
2007-09-22 02:04:09 +02:00
|
|
|
if ((ret = SETUPDI_FindInterface(devInfo, InterfaceClassGuid, &iface)))
|
2007-09-21 20:36:37 +02:00
|
|
|
{
|
2007-09-22 02:04:09 +02:00
|
|
|
if (MemberIndex < iface->cInstances)
|
2008-03-16 00:25:45 +01:00
|
|
|
*DeviceInterfaceData = iface->instances[MemberIndex];
|
2007-09-21 20:36:37 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NO_MORE_ITEMS);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
}
|
2006-08-04 22:31:59 +02:00
|
|
|
else
|
2007-09-21 20:36:37 +02:00
|
|
|
SetLastError(ERROR_NO_MORE_ITEMS);
|
2006-08-04 22:31:59 +02:00
|
|
|
}
|
|
|
|
else
|
2007-09-21 20:36:37 +02:00
|
|
|
{
|
2008-04-03 17:19:40 +02:00
|
|
|
struct DeviceInstance *devInst;
|
|
|
|
DWORD cEnumerated = 0;
|
2007-09-21 20:36:37 +02:00
|
|
|
BOOL found = FALSE;
|
|
|
|
|
2008-04-03 17:19:40 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(devInst, &set->devices, struct DeviceInstance, entry)
|
2007-09-21 20:36:37 +02:00
|
|
|
{
|
2008-04-03 17:19:40 +02:00
|
|
|
struct DeviceInfo *devInfo = (struct DeviceInfo *)devInst->data.Reserved;
|
2007-09-22 02:04:09 +02:00
|
|
|
struct InterfaceInstances *iface;
|
2007-09-21 20:36:37 +02:00
|
|
|
|
2008-04-03 17:19:40 +02:00
|
|
|
if (found || cEnumerated >= MemberIndex + 1)
|
|
|
|
break;
|
2007-09-22 02:04:09 +02:00
|
|
|
if (SETUPDI_FindInterface(devInfo, InterfaceClassGuid, &iface))
|
2007-09-21 20:36:37 +02:00
|
|
|
{
|
2007-09-22 02:04:09 +02:00
|
|
|
if (cEnumerated + iface->cInstances < MemberIndex + 1)
|
|
|
|
cEnumerated += iface->cInstances;
|
2007-09-21 20:36:37 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD instanceIndex = MemberIndex - cEnumerated;
|
|
|
|
|
2008-03-16 00:25:45 +01:00
|
|
|
*DeviceInterfaceData = iface->instances[instanceIndex];
|
2007-09-21 20:36:37 +02:00
|
|
|
cEnumerated += instanceIndex + 1;
|
|
|
|
found = TRUE;
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
SetLastError(ERROR_NO_MORE_ITEMS);
|
|
|
|
}
|
2005-03-01 12:44:27 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiDestroyDeviceInfoList (SETUPAPI.@)
|
2006-06-13 19:13:32 +02:00
|
|
|
*
|
|
|
|
* Destroy a DeviceInfoList and free all used memory of the list.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* devinfo [I] DeviceInfoList pointer to list to destroy
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: non zero value.
|
|
|
|
* Failure: zero value.
|
2005-03-01 12:44:27 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
TRACE("%p\n", devinfo);
|
2008-01-19 15:56:39 +01:00
|
|
|
if (devinfo && devinfo != INVALID_HANDLE_VALUE)
|
2005-03-01 12:44:27 +01:00
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *list = devinfo;
|
2005-03-01 12:44:27 +01:00
|
|
|
|
2006-06-13 19:13:32 +02:00
|
|
|
if (list->magic == SETUP_DEVICE_INFO_SET_MAGIC)
|
2005-03-01 12:44:27 +01:00
|
|
|
{
|
2008-04-03 17:19:40 +02:00
|
|
|
struct DeviceInstance *devInst, *devInst2;
|
2007-09-20 18:09:18 +02:00
|
|
|
|
2008-04-03 17:19:40 +02:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(devInst, devInst2, &list->devices,
|
|
|
|
struct DeviceInstance, entry)
|
|
|
|
{
|
|
|
|
SETUPDI_FreeDeviceInfo( (struct DeviceInfo *)devInst->data.Reserved );
|
|
|
|
list_remove(&devInst->entry);
|
|
|
|
HeapFree(GetProcessHeap(), 0, devInst);
|
|
|
|
}
|
2005-03-01 12:44:27 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, list);
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2006-06-13 19:13:32 +02:00
|
|
|
|
2014-02-13 12:07:19 +01:00
|
|
|
if (!ret)
|
2005-03-01 12:44:27 +01:00
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
2006-06-13 19:13:32 +02:00
|
|
|
|
2005-03-01 12:44:27 +01:00
|
|
|
return ret;
|
2002-10-10 20:57:32 +02:00
|
|
|
}
|
2004-12-02 19:09:53 +01:00
|
|
|
|
2002-06-05 00:12:50 +02:00
|
|
|
/***********************************************************************
|
2004-12-02 19:09:53 +01:00
|
|
|
* SetupDiGetDeviceInterfaceDetailA (SETUPAPI.@)
|
2002-06-05 00:12:50 +02:00
|
|
|
*/
|
2004-12-02 19:09:53 +01:00
|
|
|
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)
|
2002-05-29 00:39:14 +02:00
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-09-21 20:38:55 +02:00
|
|
|
struct InterfaceInfo *info;
|
2009-08-27 20:23:40 +02:00
|
|
|
DWORD bytesNeeded = FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath[1]);
|
2005-03-01 12:44:27 +01:00
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
2007-09-21 20:38:55 +02:00
|
|
|
TRACE("(%p, %p, %p, %d, %p, %p)\n", DeviceInfoSet,
|
2005-03-01 12:44:27 +01:00
|
|
|
DeviceInterfaceData, DeviceInterfaceDetailData,
|
|
|
|
DeviceInterfaceDetailDataSize, RequiredSize, DeviceInfoData);
|
|
|
|
|
2008-01-19 15:56:39 +01:00
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE ||
|
2007-09-21 20:38:55 +02:00
|
|
|
set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!DeviceInterfaceData ||
|
|
|
|
DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA) ||
|
|
|
|
!DeviceInterfaceData->Reserved)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-08-27 20:23:40 +02:00
|
|
|
if (DeviceInterfaceDetailData &&
|
|
|
|
DeviceInterfaceDetailData->cbSize != sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A))
|
2007-09-21 20:38:55 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!DeviceInterfaceDetailData && DeviceInterfaceDetailDataSize)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
info = (struct InterfaceInfo *)DeviceInterfaceData->Reserved;
|
|
|
|
if (info->symbolicLink)
|
|
|
|
bytesNeeded += WideCharToMultiByte(CP_ACP, 0, info->symbolicLink, -1,
|
|
|
|
NULL, 0, NULL, NULL);
|
|
|
|
if (DeviceInterfaceDetailDataSize >= bytesNeeded)
|
|
|
|
{
|
|
|
|
if (info->symbolicLink)
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, info->symbolicLink, -1,
|
|
|
|
DeviceInterfaceDetailData->DevicePath,
|
|
|
|
DeviceInterfaceDetailDataSize -
|
|
|
|
offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath),
|
|
|
|
NULL, NULL);
|
|
|
|
else
|
|
|
|
DeviceInterfaceDetailData->DevicePath[0] = '\0';
|
2007-09-22 02:06:46 +02:00
|
|
|
if (DeviceInfoData && DeviceInfoData->cbSize == sizeof(SP_DEVINFO_DATA))
|
2008-03-16 00:25:45 +01:00
|
|
|
*DeviceInfoData = *info->device;
|
2007-09-21 20:38:55 +02:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (RequiredSize)
|
|
|
|
*RequiredSize = bytesNeeded;
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
}
|
2005-03-01 12:44:27 +01:00
|
|
|
return ret;
|
2002-05-29 00:39:14 +02:00
|
|
|
}
|
|
|
|
|
2002-06-05 00:12:50 +02:00
|
|
|
/***********************************************************************
|
2004-12-02 19:09:53 +01:00
|
|
|
* SetupDiGetDeviceInterfaceDetailW (SETUPAPI.@)
|
2002-06-05 00:12:50 +02:00
|
|
|
*/
|
2004-12-02 19:09:53 +01:00
|
|
|
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)
|
2002-05-29 00:39:14 +02:00
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-09-21 20:38:55 +02:00
|
|
|
struct InterfaceInfo *info;
|
|
|
|
DWORD bytesNeeded = offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA_W, DevicePath)
|
|
|
|
+ sizeof(WCHAR); /* include NULL terminator */
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p, %d, %p, %p)\n", DeviceInfoSet,
|
2005-03-01 12:44:27 +01:00
|
|
|
DeviceInterfaceData, DeviceInterfaceDetailData,
|
|
|
|
DeviceInterfaceDetailDataSize, RequiredSize, DeviceInfoData);
|
2007-09-21 20:38:55 +02:00
|
|
|
|
2008-01-19 15:56:39 +01:00
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE ||
|
2007-09-21 20:38:55 +02:00
|
|
|
set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!DeviceInterfaceData ||
|
|
|
|
DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA) ||
|
|
|
|
!DeviceInterfaceData->Reserved)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (DeviceInterfaceDetailData && (DeviceInterfaceDetailData->cbSize <
|
|
|
|
offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA_W, DevicePath) + sizeof(WCHAR) ||
|
|
|
|
DeviceInterfaceDetailData->cbSize > sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W)))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!DeviceInterfaceDetailData && DeviceInterfaceDetailDataSize)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
info = (struct InterfaceInfo *)DeviceInterfaceData->Reserved;
|
|
|
|
if (info->symbolicLink)
|
2008-03-27 05:38:53 +01:00
|
|
|
bytesNeeded += sizeof(WCHAR)*lstrlenW(info->symbolicLink);
|
2007-09-21 20:38:55 +02:00
|
|
|
if (DeviceInterfaceDetailDataSize >= bytesNeeded)
|
|
|
|
{
|
|
|
|
if (info->symbolicLink)
|
|
|
|
lstrcpyW(DeviceInterfaceDetailData->DevicePath, info->symbolicLink);
|
|
|
|
else
|
|
|
|
DeviceInterfaceDetailData->DevicePath[0] = '\0';
|
2007-09-22 02:06:46 +02:00
|
|
|
if (DeviceInfoData && DeviceInfoData->cbSize == sizeof(SP_DEVINFO_DATA))
|
2008-03-16 00:25:45 +01:00
|
|
|
*DeviceInfoData = *info->device;
|
2007-09-21 20:38:55 +02:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (RequiredSize)
|
|
|
|
*RequiredSize = bytesNeeded;
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
}
|
|
|
|
return ret;
|
2002-05-29 00:39:14 +02:00
|
|
|
}
|
|
|
|
|
2007-09-20 18:10:10 +02:00
|
|
|
struct PropertyMapEntry
|
|
|
|
{
|
|
|
|
DWORD regType;
|
|
|
|
LPCSTR nameA;
|
|
|
|
LPCWSTR nameW;
|
|
|
|
};
|
|
|
|
|
2008-06-19 23:52:02 +02:00
|
|
|
static const struct PropertyMapEntry PropertyMap[] = {
|
2007-09-20 18:10:10 +02:00
|
|
|
{ REG_SZ, "DeviceDesc", DeviceDesc },
|
|
|
|
{ REG_MULTI_SZ, "HardwareId", HardwareId },
|
|
|
|
{ REG_MULTI_SZ, "CompatibleIDs", CompatibleIDs },
|
|
|
|
{ 0, NULL, NULL }, /* SPDRP_UNUSED0 */
|
|
|
|
{ REG_SZ, "Service", Service },
|
|
|
|
{ 0, NULL, NULL }, /* SPDRP_UNUSED1 */
|
|
|
|
{ 0, NULL, NULL }, /* SPDRP_UNUSED2 */
|
|
|
|
{ REG_SZ, "Class", Class },
|
|
|
|
{ REG_SZ, "ClassGUID", ClassGUID },
|
|
|
|
{ REG_SZ, "Driver", Driver },
|
|
|
|
{ REG_DWORD, "ConfigFlags", ConfigFlags },
|
|
|
|
{ REG_SZ, "Mfg", Mfg },
|
|
|
|
{ REG_SZ, "FriendlyName", FriendlyName },
|
|
|
|
{ REG_SZ, "LocationInformation", LocationInformation },
|
|
|
|
{ 0, NULL, NULL }, /* SPDRP_PHYSICAL_DEVICE_OBJECT_NAME */
|
|
|
|
{ REG_DWORD, "Capabilities", Capabilities },
|
|
|
|
{ REG_DWORD, "UINumber", UINumber },
|
|
|
|
{ REG_MULTI_SZ, "UpperFilters", UpperFilters },
|
|
|
|
{ REG_MULTI_SZ, "LowerFilters", LowerFilters },
|
|
|
|
};
|
|
|
|
|
2002-06-05 00:12:50 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetDeviceRegistryPropertyA (SETUPAPI.@)
|
|
|
|
*/
|
2002-05-29 00:39:14 +02:00
|
|
|
BOOL WINAPI SetupDiGetDeviceRegistryPropertyA(
|
2007-09-20 18:10:10 +02:00
|
|
|
HDEVINFO DeviceInfoSet,
|
2002-05-29 00:39:14 +02:00
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
DWORD Property,
|
|
|
|
PDWORD PropertyRegDataType,
|
|
|
|
PBYTE PropertyBuffer,
|
|
|
|
DWORD PropertyBufferSize,
|
|
|
|
PDWORD RequiredSize)
|
|
|
|
{
|
2007-09-20 18:10:10 +02:00
|
|
|
BOOL ret = FALSE;
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-09-20 18:10:10 +02:00
|
|
|
struct DeviceInfo *devInfo;
|
|
|
|
|
|
|
|
TRACE("%04x %p %d %p %p %d %p\n", (DWORD)DeviceInfoSet, DeviceInfoData,
|
2002-05-29 00:39:14 +02:00
|
|
|
Property, PropertyRegDataType, PropertyBuffer, PropertyBufferSize,
|
|
|
|
RequiredSize);
|
2007-09-20 18:10:10 +02:00
|
|
|
|
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA)
|
|
|
|
|| !DeviceInfoData->Reserved)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-04-17 18:28:14 +02:00
|
|
|
if (PropertyBufferSize && PropertyBuffer == NULL)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_DATA);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-09-20 18:10:10 +02:00
|
|
|
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
|
|
|
if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
|
|
|
|
&& PropertyMap[Property].nameA)
|
|
|
|
{
|
|
|
|
DWORD size = PropertyBufferSize;
|
|
|
|
LONG l = RegQueryValueExA(devInfo->key, PropertyMap[Property].nameA,
|
|
|
|
NULL, PropertyRegDataType, PropertyBuffer, &size);
|
|
|
|
|
2008-04-17 18:28:09 +02:00
|
|
|
if (l == ERROR_MORE_DATA || !PropertyBufferSize)
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
2007-10-24 19:37:29 +02:00
|
|
|
else if (!l)
|
2007-09-20 18:10:10 +02:00
|
|
|
ret = TRUE;
|
|
|
|
else
|
|
|
|
SetLastError(l);
|
2008-04-17 18:28:09 +02:00
|
|
|
if (RequiredSize)
|
|
|
|
*RequiredSize = size;
|
2007-09-20 18:10:10 +02:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetDeviceRegistryPropertyW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiGetDeviceRegistryPropertyW(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
DWORD Property,
|
|
|
|
PDWORD PropertyRegDataType,
|
|
|
|
PBYTE PropertyBuffer,
|
|
|
|
DWORD PropertyBufferSize,
|
|
|
|
PDWORD RequiredSize)
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-09-20 18:10:10 +02:00
|
|
|
struct DeviceInfo *devInfo;
|
|
|
|
|
|
|
|
TRACE("%04x %p %d %p %p %d %p\n", (DWORD)DeviceInfoSet, DeviceInfoData,
|
|
|
|
Property, PropertyRegDataType, PropertyBuffer, PropertyBufferSize,
|
|
|
|
RequiredSize);
|
|
|
|
|
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA)
|
|
|
|
|| !DeviceInfoData->Reserved)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-04-17 18:28:14 +02:00
|
|
|
if (PropertyBufferSize && PropertyBuffer == NULL)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_DATA);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-09-20 18:10:10 +02:00
|
|
|
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
|
|
|
if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
|
|
|
|
&& PropertyMap[Property].nameW)
|
|
|
|
{
|
|
|
|
DWORD size = PropertyBufferSize;
|
|
|
|
LONG l = RegQueryValueExW(devInfo->key, PropertyMap[Property].nameW,
|
|
|
|
NULL, PropertyRegDataType, PropertyBuffer, &size);
|
|
|
|
|
2008-04-17 18:28:09 +02:00
|
|
|
if (l == ERROR_MORE_DATA || !PropertyBufferSize)
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
2007-10-24 19:37:29 +02:00
|
|
|
else if (!l)
|
2007-09-20 18:10:10 +02:00
|
|
|
ret = TRUE;
|
|
|
|
else
|
|
|
|
SetLastError(l);
|
2008-04-17 18:28:09 +02:00
|
|
|
if (RequiredSize)
|
|
|
|
*RequiredSize = size;
|
2007-09-20 18:10:10 +02:00
|
|
|
}
|
|
|
|
return ret;
|
2002-05-29 00:39:14 +02:00
|
|
|
}
|
2004-12-02 19:09:53 +01:00
|
|
|
|
2007-09-20 18:10:32 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiSetDeviceRegistryPropertyA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiSetDeviceRegistryPropertyA(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
DWORD Property,
|
|
|
|
const BYTE *PropertyBuffer,
|
|
|
|
DWORD PropertyBufferSize)
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-09-20 18:10:32 +02:00
|
|
|
struct DeviceInfo *devInfo;
|
|
|
|
|
|
|
|
TRACE("%p %p %d %p %d\n", DeviceInfoSet, DeviceInfoData, Property,
|
|
|
|
PropertyBuffer, PropertyBufferSize);
|
|
|
|
|
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA)
|
|
|
|
|| !DeviceInfoData->Reserved)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
|
|
|
if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
|
|
|
|
&& PropertyMap[Property].nameA)
|
|
|
|
{
|
|
|
|
LONG l = RegSetValueExA(devInfo->key, PropertyMap[Property].nameA, 0,
|
|
|
|
PropertyMap[Property].regType, PropertyBuffer,
|
|
|
|
PropertyBufferSize);
|
|
|
|
if (!l)
|
|
|
|
ret = TRUE;
|
|
|
|
else
|
|
|
|
SetLastError(l);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiSetDeviceRegistryPropertyW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiSetDeviceRegistryPropertyW(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
DWORD Property,
|
|
|
|
const BYTE *PropertyBuffer,
|
|
|
|
DWORD PropertyBufferSize)
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-09-20 18:10:32 +02:00
|
|
|
struct DeviceInfo *devInfo;
|
|
|
|
|
|
|
|
TRACE("%p %p %d %p %d\n", DeviceInfoSet, DeviceInfoData, Property,
|
|
|
|
PropertyBuffer, PropertyBufferSize);
|
|
|
|
|
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA)
|
|
|
|
|| !DeviceInfoData->Reserved)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
|
|
|
if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
|
|
|
|
&& PropertyMap[Property].nameW)
|
|
|
|
{
|
|
|
|
LONG l = RegSetValueExW(devInfo->key, PropertyMap[Property].nameW, 0,
|
|
|
|
PropertyMap[Property].regType, PropertyBuffer,
|
|
|
|
PropertyBufferSize);
|
|
|
|
if (!l)
|
|
|
|
ret = TRUE;
|
|
|
|
else
|
|
|
|
SetLastError(l);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-12-02 19:09:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiInstallClassA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiInstallClassA(
|
|
|
|
HWND hwndParent,
|
|
|
|
PCSTR InfFileName,
|
|
|
|
DWORD Flags,
|
|
|
|
HSPFILEQ FileQueue)
|
|
|
|
{
|
|
|
|
UNICODE_STRING FileNameW;
|
|
|
|
BOOL Result;
|
|
|
|
|
2007-10-12 17:24:04 +02:00
|
|
|
if (!InfFileName)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-12-02 19:09:53 +01:00
|
|
|
if (!RtlCreateUnicodeStringFromAsciiz(&FileNameW, InfFileName))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Result = SetupDiInstallClassW(hwndParent, FileNameW.Buffer, Flags, FileQueue);
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(&FileNameW);
|
|
|
|
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HKEY CreateClassKey(HINF hInf)
|
|
|
|
{
|
2007-10-11 22:22:55 +02:00
|
|
|
static const WCHAR slash[] = { '\\',0 };
|
2004-12-02 19:09:53 +01:00
|
|
|
WCHAR FullBuffer[MAX_PATH];
|
|
|
|
WCHAR Buffer[MAX_PATH];
|
|
|
|
DWORD RequiredSize;
|
|
|
|
HKEY hClassKey;
|
|
|
|
|
|
|
|
if (!SetupGetLineTextW(NULL,
|
|
|
|
hInf,
|
|
|
|
Version,
|
|
|
|
ClassGUID,
|
|
|
|
Buffer,
|
|
|
|
MAX_PATH,
|
|
|
|
&RequiredSize))
|
|
|
|
{
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
lstrcpyW(FullBuffer, ControlClass);
|
2007-10-11 22:22:55 +02:00
|
|
|
lstrcatW(FullBuffer, slash);
|
2004-12-02 19:09:53 +01:00
|
|
|
lstrcatW(FullBuffer, Buffer);
|
|
|
|
|
|
|
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
|
|
|
FullBuffer,
|
|
|
|
0,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
&hClassKey))
|
|
|
|
{
|
|
|
|
if (!SetupGetLineTextW(NULL,
|
|
|
|
hInf,
|
|
|
|
Version,
|
|
|
|
Class,
|
|
|
|
Buffer,
|
|
|
|
MAX_PATH,
|
|
|
|
&RequiredSize))
|
|
|
|
{
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RegCreateKeyExW(HKEY_LOCAL_MACHINE,
|
|
|
|
FullBuffer,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
NULL,
|
|
|
|
&hClassKey,
|
|
|
|
NULL))
|
|
|
|
{
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RegSetValueExW(hClassKey,
|
|
|
|
Class,
|
|
|
|
0,
|
|
|
|
REG_SZ,
|
|
|
|
(LPBYTE)Buffer,
|
|
|
|
RequiredSize * sizeof(WCHAR)))
|
|
|
|
{
|
|
|
|
RegCloseKey(hClassKey);
|
|
|
|
RegDeleteKeyW(HKEY_LOCAL_MACHINE,
|
|
|
|
FullBuffer);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hClassKey;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiInstallClassW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiInstallClassW(
|
|
|
|
HWND hwndParent,
|
|
|
|
PCWSTR InfFileName,
|
|
|
|
DWORD Flags,
|
|
|
|
HSPFILEQ FileQueue)
|
|
|
|
{
|
|
|
|
WCHAR SectionName[MAX_PATH];
|
|
|
|
DWORD SectionNameLength = 0;
|
|
|
|
HINF hInf;
|
|
|
|
BOOL bFileQueueCreated = FALSE;
|
|
|
|
HKEY hClassKey;
|
|
|
|
|
|
|
|
|
|
|
|
FIXME("\n");
|
|
|
|
|
2007-10-12 17:24:04 +02:00
|
|
|
if (!InfFileName)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-12-02 19:09:53 +01:00
|
|
|
if ((Flags & DI_NOVCP) && (FileQueue == NULL || FileQueue == INVALID_HANDLE_VALUE))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Open the .inf file */
|
|
|
|
hInf = SetupOpenInfFileW(InfFileName,
|
|
|
|
NULL,
|
|
|
|
INF_STYLE_WIN4,
|
|
|
|
NULL);
|
|
|
|
if (hInf == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create or open the class registry key 'HKLM\\CurrentControlSet\\Class\\{GUID}' */
|
|
|
|
hClassKey = CreateClassKey(hInf);
|
|
|
|
if (hClassKey == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
SetupCloseInfFile(hInf);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Try to append a layout file */
|
|
|
|
SetupOpenAppendInfFileW(NULL, hInf, NULL);
|
|
|
|
|
|
|
|
/* Retrieve the actual section name */
|
|
|
|
SetupDiGetActualSectionToInstallW(hInf,
|
|
|
|
ClassInstall32,
|
|
|
|
SectionName,
|
|
|
|
MAX_PATH,
|
|
|
|
&SectionNameLength,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (!(Flags & DI_NOVCP))
|
|
|
|
{
|
|
|
|
FileQueue = SetupOpenFileQueue();
|
|
|
|
if (FileQueue == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
SetupCloseInfFile(hInf);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bFileQueueCreated = TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
SetupInstallFromInfSectionW(NULL,
|
|
|
|
hInf,
|
|
|
|
SectionName,
|
2007-10-11 22:23:21 +02:00
|
|
|
SPINST_COPYINF | SPINST_FILES | SPINST_REGISTRY,
|
2004-12-02 19:09:53 +01:00
|
|
|
hClassKey,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
INVALID_HANDLE_VALUE,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* FIXME: More code! */
|
|
|
|
|
|
|
|
if (bFileQueueCreated)
|
|
|
|
SetupCloseFileQueue(FileQueue);
|
|
|
|
|
|
|
|
SetupCloseInfFile(hInf);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiOpenClassRegKey (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
HKEY WINAPI SetupDiOpenClassRegKey(
|
|
|
|
const GUID* ClassGuid,
|
|
|
|
REGSAM samDesired)
|
|
|
|
{
|
|
|
|
return SetupDiOpenClassRegKeyExW(ClassGuid, samDesired,
|
|
|
|
DIOCR_INSTALLER, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiOpenClassRegKeyExA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
HKEY WINAPI SetupDiOpenClassRegKeyExA(
|
|
|
|
const GUID* ClassGuid,
|
|
|
|
REGSAM samDesired,
|
|
|
|
DWORD Flags,
|
|
|
|
PCSTR MachineName,
|
|
|
|
PVOID Reserved)
|
|
|
|
{
|
2005-02-03 14:34:50 +01:00
|
|
|
PWSTR MachineNameW = NULL;
|
|
|
|
HKEY hKey;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (MachineName)
|
|
|
|
{
|
|
|
|
MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
|
|
|
|
if (MachineNameW == NULL)
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hKey = SetupDiOpenClassRegKeyExW(ClassGuid, samDesired,
|
|
|
|
Flags, MachineNameW, Reserved);
|
|
|
|
|
2006-07-19 19:39:48 +02:00
|
|
|
MyFree(MachineNameW);
|
2005-02-03 14:34:50 +01:00
|
|
|
|
|
|
|
return hKey;
|
2004-12-02 19:09:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiOpenClassRegKeyExW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
HKEY WINAPI SetupDiOpenClassRegKeyExW(
|
|
|
|
const GUID* ClassGuid,
|
|
|
|
REGSAM samDesired,
|
|
|
|
DWORD Flags,
|
|
|
|
PCWSTR MachineName,
|
|
|
|
PVOID Reserved)
|
|
|
|
{
|
|
|
|
HKEY hClassesKey;
|
2007-09-21 20:33:05 +02:00
|
|
|
HKEY key;
|
2004-12-02 19:09:53 +01:00
|
|
|
LPCWSTR lpKeyName;
|
2007-09-21 20:33:05 +02:00
|
|
|
LONG l;
|
2004-12-02 19:09:53 +01:00
|
|
|
|
2011-06-09 20:35:11 +02:00
|
|
|
if (MachineName && *MachineName)
|
2004-12-02 19:09:53 +01:00
|
|
|
{
|
|
|
|
FIXME("Remote access not supported yet!\n");
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Flags == DIOCR_INSTALLER)
|
|
|
|
{
|
|
|
|
lpKeyName = ControlClass;
|
|
|
|
}
|
|
|
|
else if (Flags == DIOCR_INTERFACE)
|
|
|
|
{
|
|
|
|
lpKeyName = DeviceClasses;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Invalid Flags parameter!\n");
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
2007-09-21 20:32:24 +02:00
|
|
|
if (!ClassGuid)
|
2004-12-02 19:09:53 +01:00
|
|
|
{
|
2007-09-21 20:33:05 +02:00
|
|
|
if ((l = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
2007-09-21 20:32:24 +02:00
|
|
|
lpKeyName,
|
|
|
|
0,
|
|
|
|
samDesired,
|
2007-09-21 20:33:05 +02:00
|
|
|
&hClassesKey)))
|
2007-09-21 20:32:24 +02:00
|
|
|
{
|
2007-09-21 20:33:05 +02:00
|
|
|
SetLastError(l);
|
|
|
|
hClassesKey = INVALID_HANDLE_VALUE;
|
2007-09-21 20:32:24 +02:00
|
|
|
}
|
2007-09-21 20:33:05 +02:00
|
|
|
key = hClassesKey;
|
2007-09-21 20:32:24 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WCHAR bracedGuidString[39];
|
2004-12-02 19:09:53 +01:00
|
|
|
|
2007-09-21 20:32:24 +02:00
|
|
|
SETUPDI_GuidToString(ClassGuid, bracedGuidString);
|
2004-12-02 19:09:53 +01:00
|
|
|
|
2007-09-21 20:33:05 +02:00
|
|
|
if (!(l = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
2007-09-21 20:32:24 +02:00
|
|
|
lpKeyName,
|
|
|
|
0,
|
|
|
|
samDesired,
|
2007-09-21 20:33:05 +02:00
|
|
|
&hClassesKey)))
|
2007-09-21 20:32:24 +02:00
|
|
|
{
|
2007-09-21 20:33:05 +02:00
|
|
|
if ((l = RegOpenKeyExW(hClassesKey,
|
|
|
|
bracedGuidString,
|
|
|
|
0,
|
|
|
|
samDesired,
|
|
|
|
&key)))
|
|
|
|
{
|
|
|
|
SetLastError(l);
|
|
|
|
key = INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
RegCloseKey(hClassesKey);
|
2007-09-21 20:32:24 +02:00
|
|
|
}
|
2007-09-21 20:33:05 +02:00
|
|
|
else
|
2007-09-21 20:32:24 +02:00
|
|
|
{
|
2007-09-21 20:33:05 +02:00
|
|
|
SetLastError(l);
|
|
|
|
key = INVALID_HANDLE_VALUE;
|
2007-09-21 20:32:24 +02:00
|
|
|
}
|
|
|
|
}
|
2007-09-21 20:33:05 +02:00
|
|
|
return key;
|
2004-12-02 19:09:53 +01:00
|
|
|
}
|
2004-12-06 17:19:15 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2005-02-03 14:34:50 +01:00
|
|
|
* SetupDiOpenDeviceInterfaceW (SETUPAPI.@)
|
2004-12-06 17:19:15 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiOpenDeviceInterfaceW(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PCWSTR DevicePath,
|
|
|
|
DWORD OpenFlags,
|
|
|
|
PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
|
|
|
|
{
|
2006-10-13 23:32:50 +02:00
|
|
|
FIXME("%p %s %08x %p\n",
|
2004-12-06 17:19:15 +01:00
|
|
|
DeviceInfoSet, debugstr_w(DevicePath), OpenFlags, DeviceInterfaceData);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiOpenDeviceInterfaceA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiOpenDeviceInterfaceA(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PCSTR DevicePath,
|
|
|
|
DWORD OpenFlags,
|
|
|
|
PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
|
|
|
|
{
|
2006-10-13 23:32:50 +02:00
|
|
|
FIXME("%p %s %08x %p\n", DeviceInfoSet,
|
2004-12-06 17:19:15 +01:00
|
|
|
debugstr_a(DevicePath), OpenFlags, DeviceInterfaceData);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-01-19 17:57:24 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiSetClassInstallParamsA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiSetClassInstallParamsA(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
PSP_CLASSINSTALL_HEADER ClassInstallParams,
|
|
|
|
DWORD ClassInstallParamsSize)
|
|
|
|
{
|
2006-10-13 23:32:50 +02:00
|
|
|
FIXME("%p %p %x %u\n",DeviceInfoSet, DeviceInfoData,
|
2005-01-19 17:57:24 +01:00
|
|
|
ClassInstallParams->InstallFunction, ClassInstallParamsSize);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-07-14 01:45:25 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiSetClassInstallParamsW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiSetClassInstallParamsW(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
PSP_CLASSINSTALL_HEADER ClassInstallParams,
|
|
|
|
DWORD ClassInstallParamsSize)
|
|
|
|
{
|
|
|
|
FIXME("%p %p %x %u\n",DeviceInfoSet, DeviceInfoData,
|
|
|
|
ClassInstallParams->InstallFunction, ClassInstallParamsSize);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-01-19 17:57:24 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiCallClassInstaller (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiCallClassInstaller(
|
2005-06-07 22:07:34 +02:00
|
|
|
DI_FUNCTION InstallFunction,
|
2005-01-19 17:57:24 +01:00
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData)
|
|
|
|
{
|
2005-06-07 22:07:34 +02:00
|
|
|
FIXME("%d %p %p\n", InstallFunction, DeviceInfoSet, DeviceInfoData);
|
2005-01-19 17:57:24 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-07-07 15:19:53 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetDeviceInstallParamsW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiGetDeviceInstallParamsW(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
|
|
|
|
{
|
|
|
|
FIXME("%p %p %p\n", DeviceInfoSet, DeviceInfoData, DeviceInstallParams);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-01-19 17:57:24 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetDeviceInstallParamsA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiGetDeviceInstallParamsA(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
PSP_DEVINSTALL_PARAMS_A DeviceInstallParams)
|
|
|
|
{
|
|
|
|
FIXME("%p %p %p\n", DeviceInfoSet, DeviceInfoData, DeviceInstallParams);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-04-18 21:28:24 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiSetDeviceInstallParamsA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiSetDeviceInstallParamsA(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
PSP_DEVINSTALL_PARAMS_A DeviceInstallParams)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p, %p) stub\n", DeviceInfoSet, DeviceInfoData, DeviceInstallParams);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-12-16 04:32:38 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiSetDeviceInstallParamsW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiSetDeviceInstallParamsW(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p, %p) stub\n", DeviceInfoSet, DeviceInfoData, DeviceInstallParams);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-10-12 17:25:24 +02:00
|
|
|
static HKEY SETUPDI_OpenDevKey(struct DeviceInfo *devInfo, REGSAM samDesired)
|
|
|
|
{
|
|
|
|
HKEY enumKey, key = INVALID_HANDLE_VALUE;
|
|
|
|
LONG l;
|
|
|
|
|
|
|
|
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, Enum, 0, NULL, 0, KEY_ALL_ACCESS,
|
|
|
|
NULL, &enumKey, NULL);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
RegOpenKeyExW(enumKey, devInfo->instanceId, 0, samDesired, &key);
|
|
|
|
RegCloseKey(enumKey);
|
|
|
|
}
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HKEY SETUPDI_OpenDrvKey(struct DeviceInfo *devInfo, REGSAM samDesired)
|
|
|
|
{
|
|
|
|
static const WCHAR slash[] = { '\\',0 };
|
|
|
|
WCHAR classKeyPath[MAX_PATH];
|
|
|
|
HKEY classKey, key = INVALID_HANDLE_VALUE;
|
|
|
|
LONG l;
|
|
|
|
|
|
|
|
lstrcpyW(classKeyPath, ControlClass);
|
|
|
|
lstrcatW(classKeyPath, slash);
|
|
|
|
SETUPDI_GuidToString(&devInfo->set->ClassGuid,
|
|
|
|
classKeyPath + lstrlenW(classKeyPath));
|
|
|
|
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, classKeyPath, 0, NULL, 0,
|
|
|
|
KEY_ALL_ACCESS, NULL, &classKey, NULL);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
static const WCHAR fmt[] = { '%','0','4','u',0 };
|
|
|
|
WCHAR devId[10];
|
|
|
|
|
|
|
|
sprintfW(devId, fmt, devInfo->devId);
|
2011-07-08 18:43:59 +02:00
|
|
|
l = RegOpenKeyExW(classKey, devId, 0, samDesired, &key);
|
2007-10-12 17:25:24 +02:00
|
|
|
RegCloseKey(classKey);
|
2011-07-08 18:43:59 +02:00
|
|
|
if (l)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_KEY_DOES_NOT_EXIST);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
2007-10-12 17:25:24 +02:00
|
|
|
}
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2005-01-19 17:57:24 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiOpenDevRegKey (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
HKEY WINAPI SetupDiOpenDevRegKey(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
DWORD Scope,
|
|
|
|
DWORD HwProfile,
|
|
|
|
DWORD KeyType,
|
|
|
|
REGSAM samDesired)
|
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-10-12 17:25:24 +02:00
|
|
|
struct DeviceInfo *devInfo;
|
|
|
|
HKEY key = INVALID_HANDLE_VALUE;
|
|
|
|
|
|
|
|
TRACE("%p %p %d %d %d %x\n", DeviceInfoSet, DeviceInfoData,
|
2005-01-19 17:57:24 +01:00
|
|
|
Scope, HwProfile, KeyType, samDesired);
|
2007-10-12 17:25:24 +02:00
|
|
|
|
2008-01-19 15:56:39 +01:00
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
|
2007-10-12 17:25:24 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA)
|
|
|
|
|| !DeviceInfoData->Reserved)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
if (Scope != DICS_FLAG_GLOBAL && Scope != DICS_FLAG_CONFIGSPECIFIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_FLAGS);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
if (KeyType != DIREG_DEV && KeyType != DIREG_DRV)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_FLAGS);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
|
|
|
if (devInfo->set != set)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
if (devInfo->phantom)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_DEVINFO_NOT_REGISTERED);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
if (Scope != DICS_FLAG_GLOBAL)
|
|
|
|
FIXME("unimplemented for scope %d\n", Scope);
|
|
|
|
switch (KeyType)
|
|
|
|
{
|
|
|
|
case DIREG_DEV:
|
|
|
|
key = SETUPDI_OpenDevKey(devInfo, samDesired);
|
|
|
|
break;
|
|
|
|
case DIREG_DRV:
|
|
|
|
key = SETUPDI_OpenDrvKey(devInfo, samDesired);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN("unknown KeyType %d\n", KeyType);
|
|
|
|
}
|
|
|
|
return key;
|
2005-01-19 17:57:24 +01:00
|
|
|
}
|
2007-10-12 17:26:31 +02:00
|
|
|
|
|
|
|
static BOOL SETUPDI_DeleteDevKey(struct DeviceInfo *devInfo)
|
|
|
|
{
|
|
|
|
HKEY enumKey;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
LONG l;
|
|
|
|
|
|
|
|
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, Enum, 0, NULL, 0, KEY_ALL_ACCESS,
|
|
|
|
NULL, &enumKey, NULL);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
ret = RegDeleteTreeW(enumKey, devInfo->instanceId);
|
|
|
|
RegCloseKey(enumKey);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetLastError(l);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL SETUPDI_DeleteDrvKey(struct DeviceInfo *devInfo)
|
|
|
|
{
|
|
|
|
static const WCHAR slash[] = { '\\',0 };
|
|
|
|
WCHAR classKeyPath[MAX_PATH];
|
|
|
|
HKEY classKey;
|
|
|
|
LONG l;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
lstrcpyW(classKeyPath, ControlClass);
|
|
|
|
lstrcatW(classKeyPath, slash);
|
|
|
|
SETUPDI_GuidToString(&devInfo->set->ClassGuid,
|
|
|
|
classKeyPath + lstrlenW(classKeyPath));
|
|
|
|
l = RegCreateKeyExW(HKEY_LOCAL_MACHINE, classKeyPath, 0, NULL, 0,
|
|
|
|
KEY_ALL_ACCESS, NULL, &classKey, NULL);
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
static const WCHAR fmt[] = { '%','0','4','u',0 };
|
|
|
|
WCHAR devId[10];
|
|
|
|
|
|
|
|
sprintfW(devId, fmt, devInfo->devId);
|
|
|
|
ret = RegDeleteTreeW(classKey, devId);
|
|
|
|
RegCloseKey(classKey);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetLastError(l);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2009-12-17 00:01:47 +01:00
|
|
|
* SetupDiDeleteDevRegKey (SETUPAPI.@)
|
2007-10-12 17:26:31 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiDeleteDevRegKey(
|
|
|
|
HDEVINFO DeviceInfoSet,
|
|
|
|
PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
DWORD Scope,
|
|
|
|
DWORD HwProfile,
|
|
|
|
DWORD KeyType)
|
|
|
|
{
|
2009-01-28 10:24:55 +01:00
|
|
|
struct DeviceInfoSet *set = DeviceInfoSet;
|
2007-10-12 17:26:31 +02:00
|
|
|
struct DeviceInfo *devInfo;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
TRACE("%p %p %d %d %d\n", DeviceInfoSet, DeviceInfoData, Scope, HwProfile,
|
|
|
|
KeyType);
|
|
|
|
|
2008-01-19 15:56:39 +01:00
|
|
|
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
|
2007-10-12 17:26:31 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA)
|
|
|
|
|| !DeviceInfoData->Reserved)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (Scope != DICS_FLAG_GLOBAL && Scope != DICS_FLAG_CONFIGSPECIFIC)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_FLAGS);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-01-12 17:52:20 +01:00
|
|
|
if (KeyType != DIREG_DEV && KeyType != DIREG_DRV && KeyType != DIREG_BOTH)
|
2007-10-12 17:26:31 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_FLAGS);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
|
|
|
if (devInfo->set != set)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (devInfo->phantom)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_DEVINFO_NOT_REGISTERED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (Scope != DICS_FLAG_GLOBAL)
|
|
|
|
FIXME("unimplemented for scope %d\n", Scope);
|
|
|
|
switch (KeyType)
|
|
|
|
{
|
|
|
|
case DIREG_DEV:
|
|
|
|
ret = SETUPDI_DeleteDevKey(devInfo);
|
|
|
|
break;
|
|
|
|
case DIREG_DRV:
|
|
|
|
ret = SETUPDI_DeleteDrvKey(devInfo);
|
|
|
|
break;
|
|
|
|
case DIREG_BOTH:
|
|
|
|
ret = SETUPDI_DeleteDevKey(devInfo);
|
|
|
|
if (ret)
|
|
|
|
ret = SETUPDI_DeleteDrvKey(devInfo);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN("unknown KeyType %d\n", KeyType);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2008-03-01 02:46:58 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CM_Get_Device_IDA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
CONFIGRET WINAPI CM_Get_Device_IDA( DEVINST dnDevInst, PSTR Buffer,
|
|
|
|
ULONG BufferLen, ULONG ulFlags)
|
|
|
|
{
|
|
|
|
struct DeviceInfo *devInfo = GlobalLock((HANDLE)dnDevInst);
|
|
|
|
|
|
|
|
TRACE("%x->%p, %p, %u %u\n", dnDevInst, devInfo, Buffer, BufferLen, ulFlags);
|
|
|
|
|
|
|
|
if (!devInfo)
|
|
|
|
return CR_NO_SUCH_DEVINST;
|
|
|
|
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, devInfo->instanceId, -1, Buffer, BufferLen, 0, 0);
|
|
|
|
TRACE("Returning %s\n", debugstr_a(Buffer));
|
|
|
|
return CR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CM_Get_Device_IDW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
CONFIGRET WINAPI CM_Get_Device_IDW( DEVINST dnDevInst, LPWSTR Buffer,
|
|
|
|
ULONG BufferLen, ULONG ulFlags)
|
|
|
|
{
|
|
|
|
struct DeviceInfo *devInfo = GlobalLock((HANDLE)dnDevInst);
|
|
|
|
|
|
|
|
TRACE("%x->%p, %p, %u %u\n", dnDevInst, devInfo, Buffer, BufferLen, ulFlags);
|
|
|
|
|
|
|
|
if (!devInfo)
|
|
|
|
{
|
|
|
|
WARN("dev instance %d not found!\n", dnDevInst);
|
|
|
|
return CR_NO_SUCH_DEVINST;
|
|
|
|
}
|
|
|
|
|
|
|
|
lstrcpynW(Buffer, devInfo->instanceId, BufferLen);
|
|
|
|
TRACE("Returning %s\n", debugstr_w(Buffer));
|
|
|
|
GlobalUnlock((HANDLE)dnDevInst);
|
|
|
|
return CR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CM_Get_Device_ID_Size (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
CONFIGRET WINAPI CM_Get_Device_ID_Size( PULONG pulLen, DEVINST dnDevInst,
|
|
|
|
ULONG ulFlags)
|
|
|
|
{
|
|
|
|
struct DeviceInfo *ppdevInfo = GlobalLock((HANDLE)dnDevInst);
|
|
|
|
|
|
|
|
TRACE("%x->%p, %p, %u\n", dnDevInst, ppdevInfo, pulLen, ulFlags);
|
|
|
|
|
|
|
|
if (!ppdevInfo)
|
|
|
|
{
|
|
|
|
WARN("dev instance %d not found!\n", dnDevInst);
|
|
|
|
return CR_NO_SUCH_DEVINST;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pulLen = lstrlenW(ppdevInfo->instanceId);
|
|
|
|
GlobalUnlock((HANDLE)dnDevInst);
|
|
|
|
return CR_SUCCESS;
|
|
|
|
}
|
2010-10-04 18:16:25 +02:00
|
|
|
|
2010-10-04 18:16:34 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetINFClassA (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiGetINFClassA(PCSTR inf, LPGUID class_guid, PSTR class_name,
|
|
|
|
DWORD size, PDWORD required_size)
|
|
|
|
{
|
|
|
|
BOOL retval;
|
|
|
|
DWORD required_sizeA, required_sizeW;
|
|
|
|
PWSTR class_nameW = NULL;
|
|
|
|
UNICODE_STRING infW;
|
|
|
|
|
2011-01-15 09:28:37 +01:00
|
|
|
if (inf)
|
|
|
|
{
|
|
|
|
if (!RtlCreateUnicodeStringFromAsciiz(&infW, inf))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
infW.Buffer = NULL;
|
|
|
|
|
2010-10-04 18:16:34 +02:00
|
|
|
if (class_name && size)
|
2011-01-15 09:28:37 +01:00
|
|
|
{
|
|
|
|
if (!(class_nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR))))
|
|
|
|
{
|
|
|
|
RtlFreeUnicodeString(&infW);
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2010-10-04 18:16:34 +02:00
|
|
|
|
|
|
|
retval = SetupDiGetINFClassW(infW.Buffer, class_guid, class_nameW, size, &required_sizeW);
|
|
|
|
|
|
|
|
if (retval)
|
|
|
|
{
|
|
|
|
required_sizeA = WideCharToMultiByte( CP_ACP, 0, class_nameW, required_sizeW,
|
|
|
|
class_name, size, NULL, NULL);
|
|
|
|
|
|
|
|
if(required_size) *required_size = required_sizeA;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if(required_size) *required_size = required_sizeW;
|
|
|
|
|
2011-01-15 09:28:37 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, class_nameW);
|
|
|
|
RtlFreeUnicodeString(&infW);
|
2010-10-04 18:16:34 +02:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-10-04 18:16:25 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetupDiGetINFClassW (SETUPAPI.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetupDiGetINFClassW(PCWSTR inf, LPGUID class_guid, PWSTR class_name,
|
|
|
|
DWORD size, PDWORD required_size)
|
|
|
|
{
|
|
|
|
BOOL have_guid, have_name;
|
|
|
|
DWORD dret;
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!inf)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW(inf))
|
|
|
|
{
|
|
|
|
FIXME("%s not found. Searching via DevicePath not implemented\n", debugstr_w(inf));
|
|
|
|
SetLastError(ERROR_FILE_NOT_FOUND);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!class_guid || !class_name || !size)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!GetPrivateProfileStringW(Version, Signature, NULL, buffer, MAX_PATH, inf))
|
|
|
|
return FALSE;
|
|
|
|
|
2013-12-17 21:42:00 +01:00
|
|
|
if (lstrcmpiW(buffer, Chicago) && lstrcmpiW(buffer, WindowsNT))
|
2010-10-04 18:16:25 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
have_guid = 0 < GetPrivateProfileStringW(Version, ClassGUID, NULL, buffer, MAX_PATH, inf);
|
|
|
|
if (have_guid)
|
|
|
|
{
|
|
|
|
buffer[lstrlenW(buffer)-1] = 0;
|
|
|
|
if (RPC_S_OK != UuidFromStringW(buffer + 1, class_guid))
|
|
|
|
{
|
|
|
|
FIXME("failed to convert \"%s\" into a guid\n", debugstr_w(buffer));
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
dret = GetPrivateProfileStringW(Version, Class, NULL, buffer, MAX_PATH, inf);
|
|
|
|
have_name = 0 < dret;
|
|
|
|
|
|
|
|
if (dret >= MAX_PATH -1) FIXME("buffer might be too small\n");
|
|
|
|
if (have_guid && !have_name) FIXME("class name lookup via guid not implemented\n");
|
|
|
|
|
|
|
|
if (have_name)
|
|
|
|
{
|
|
|
|
if (dret < size) lstrcpyW(class_name, buffer);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
have_name = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (required_size) *required_size = dret + ((dret) ? 1 : 0);
|
|
|
|
|
|
|
|
return (have_guid || have_name);
|
|
|
|
}
|