/* Unicode constants */
static const WCHAR BackSlash[] = {'\\',0};
-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 DateFormat[] = {'%','u','-','%','u','-','%','u',0};
static const WCHAR DotCoInstallers[] = {'.','C','o','I','n','s','t','a','l','l','e','r','s',0};
static const WCHAR DotHW[] = {'.','H','W',0};
if (CurrentPlatform.cbSize != sizeof(SP_ALTPLATFORM_INFO))
{
/* That's the first time we go here. We need to fill in the structure */
- OSVERSIONINFOEX VersionInfo;
SYSTEM_INFO SystemInfo;
- VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
- ret = GetVersionExW((OSVERSIONINFO*)&VersionInfo);
- if (!ret)
- goto done;
GetSystemInfo(&SystemInfo);
CurrentPlatform.cbSize = sizeof(SP_ALTPLATFORM_INFO);
- CurrentPlatform.Platform = VersionInfo.dwPlatformId;
- CurrentPlatform.MajorVersion = VersionInfo.dwMajorVersion;
- CurrentPlatform.MinorVersion = VersionInfo.dwMinorVersion;
+ CurrentPlatform.Platform = OsVersionInfo.dwPlatformId;
+ CurrentPlatform.MajorVersion = OsVersionInfo.dwMajorVersion;
+ CurrentPlatform.MinorVersion = OsVersionInfo.dwMinorVersion;
CurrentPlatform.ProcessorArchitecture = SystemInfo.wProcessorArchitecture;
CurrentPlatform.Reserved = 0;
- CurrentProductType = VersionInfo.wProductType;
- CurrentSuiteMask = VersionInfo.wSuiteMask;
+ CurrentProductType = OsVersionInfo.wProductType;
+ CurrentSuiteMask = OsVersionInfo.wSuiteMask;
}
ProductType = CurrentProductType;
SuiteMask = CurrentSuiteMask;
CallbackInfo.BestScore4 = ULONG_MAX;
CallbackInfo.BestScore5 = ULONG_MAX;
strcpyW(CallbackInfo.BestSection, InfSectionName);
+ TRACE("EnumerateSectionsStartingWith(InfSectionName = %S)\n", InfSectionName);
if (!EnumerateSectionsStartingWith(
InfHandle,
InfSectionName,
SetLastError(ERROR_GEN_FAILURE);
goto done;
}
+ TRACE("CallbackInfo.BestSection = %S\n", CallbackInfo.BestSection);
dwFullLength = lstrlenW(CallbackInfo.BestSection);
if (RequiredSize != NULL)
* SetupDiBuildClassInfoListExA (SETUPAPI.@)
*
* Returns a list of setup class GUIDs that identify the classes
- * that are installed on a local or remote macine.
+ * that are installed on a local or remote machine.
*
* PARAMS
* Flags [I] control exclusion of classes from the list.
* SetupDiBuildClassInfoListExW (SETUPAPI.@)
*
* Returns a list of setup class GUIDs that identify the classes
- * that are installed on a local or remote macine.
+ * that are installed on a local or remote machine.
*
* PARAMS
* Flags [I] control exclusion of classes from the list.
dwLength = MAX_CLASS_NAME_LEN * sizeof(WCHAR);
if (!RegQueryValueExW(hClassKey,
- Class,
+ REGSTR_VAL_CLASS,
NULL,
NULL,
(LPBYTE)szClassName,
return FALSE;
/* Retrieve the class name data and close the key */
- rc = QueryRegistryValue(hKey, Class, (LPBYTE *) &Buffer, &dwRegType, &dwLength);
+ rc = QueryRegistryValue(hKey, REGSTR_VAL_CLASS, (LPBYTE *) &Buffer, &dwRegType, &dwLength);
RegCloseKey(hKey);
/* Make sure we got the data */
* Create an empty DeviceInfoSet list.
*
* PARAMS
- * ClassGuid [I] if not NULL only devices with GUID ClcassGuid are associated
+ * ClassGuid [I] if not NULL only devices with GUID ClassGuid are associated
* with this list.
* hwndParent [I] hwnd needed for interface related actions.
* MachineName [I] name of machine to create emtpy DeviceInfoSet list, if NULL
SetLastError(rc);
goto cleanup;
}
+
+ if (Scope == DICS_FLAG_GLOBAL)
+ {
+ HKEY hTempKey = hKey;
+
+ rc = RegCreateKeyExW(hTempKey,
+ L"Device Parameters",
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+#if _WIN32_WINNT >= 0x502
+ KEY_READ | KEY_WRITE,
+#else
+ KEY_ALL_ACCESS,
+#endif
+ NULL,
+ &hKey,
+ NULL);
+ if (rc == ERROR_SUCCESS)
+ RegCloseKey(hTempKey);
+ }
}
else /* KeyType == DIREG_DRV */
{
DWORD PropertyBufferSize,
PDWORD RequiredSize)
{
- BOOL ret = FALSE;
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
struct DeviceInfo *devInfo;
+ CONFIGRET cr;
+ LONG lError = ERROR_SUCCESS;
+ DWORD size;
TRACE("%p %p %d %p %p %d %p\n", DeviceInfoSet, DeviceInfoData,
Property, PropertyRegDataType, PropertyBuffer, PropertyBufferSize,
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
+
+ if (Property >= SPDRP_MAXIMUM_PROPERTY)
+ {
+ SetLastError(ERROR_INVALID_REG_PROPERTY);
+ return FALSE;
+ }
+
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
+
if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
&& PropertyMap[Property].nameW)
{
- DWORD size = PropertyBufferSize;
HKEY hKey;
- LONG l;
+ size = PropertyBufferSize;
hKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_QUERY_VALUE);
if (hKey == INVALID_HANDLE_VALUE)
return FALSE;
- l = RegQueryValueExW(hKey, PropertyMap[Property].nameW,
- NULL, PropertyRegDataType, PropertyBuffer, &size);
+ lError = RegQueryValueExW(hKey, PropertyMap[Property].nameW,
+ NULL, PropertyRegDataType, PropertyBuffer, &size);
RegCloseKey(hKey);
if (RequiredSize)
*RequiredSize = size;
- switch(l) {
+
+ switch (lError)
+ {
case ERROR_SUCCESS:
- if (PropertyBuffer != NULL || size == 0)
- ret = TRUE;
- else
- SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ if (PropertyBuffer == NULL && size != 0)
+ lError = ERROR_INSUFFICIENT_BUFFER;
break;
case ERROR_MORE_DATA:
- SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ lError = ERROR_INSUFFICIENT_BUFFER;
break;
default:
- SetLastError(l);
+ break;
}
}
else if (Property == SPDRP_PHYSICAL_DEVICE_OBJECT_NAME)
{
- DWORD required = (strlenW(devInfo->Data) + 1) * sizeof(WCHAR);
+ size = (strlenW(devInfo->Data) + 1) * sizeof(WCHAR);
if (PropertyRegDataType)
*PropertyRegDataType = REG_SZ;
if (RequiredSize)
- *RequiredSize = required;
- if (PropertyBufferSize >= required)
+ *RequiredSize = size;
+ if (PropertyBufferSize >= size)
{
strcpyW((LPWSTR)PropertyBuffer, devInfo->Data);
- ret = TRUE;
}
else
- SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ lError = ERROR_INSUFFICIENT_BUFFER;
}
else
{
- ERR("Property 0x%lx not implemented\n", Property);
- SetLastError(ERROR_NOT_SUPPORTED);
- }
- return ret;
-}
+ size = PropertyBufferSize;
-/***********************************************************************
- * SetupDiSetDeviceRegistryPropertyA (SETUPAPI.@)
- */
-BOOL WINAPI SetupDiSetDeviceRegistryPropertyA(
- HDEVINFO DeviceInfoSet,
- PSP_DEVINFO_DATA DeviceInfoData,
- DWORD Property,
- const BYTE *PropertyBuffer,
- DWORD PropertyBufferSize)
-{
- BOOL ret = FALSE;
- struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
+ cr = CM_Get_DevNode_Registry_Property_ExW(devInfo->dnDevInst,
+ Property + (CM_DRP_DEVICEDESC - SPDRP_DEVICEDESC),
+ PropertyRegDataType,
+ PropertyBuffer,
+ &size,
+ 0,
+ set->hMachine);
+ if ((cr == CR_SUCCESS) || (cr == CR_BUFFER_SMALL))
+ {
+ if (RequiredSize)
+ *RequiredSize = size;
+ }
- TRACE("%p %p %d %p %d\n", DeviceInfoSet, DeviceInfoData, Property,
- PropertyBuffer, PropertyBufferSize);
+ if (cr != CR_SUCCESS)
+ {
+ switch (cr)
+ {
+ case CR_INVALID_DEVINST:
+ lError = ERROR_NO_SUCH_DEVINST;
+ break;
- 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;
+ case CR_INVALID_PROPERTY:
+ lError = ERROR_INVALID_REG_PROPERTY;
+ break;
+
+ case CR_BUFFER_SMALL:
+ lError = ERROR_INSUFFICIENT_BUFFER;
+ break;
+
+ default :
+ lError = ERROR_INVALID_DATA;
+ break;
+ }
+ }
}
- FIXME("%p %p 0x%lx %p 0x%lx\n", DeviceInfoSet, DeviceInfoData,
- Property, PropertyBuffer, PropertyBufferSize);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return ret;
+ SetLastError(lError);
+ return (lError == ERROR_SUCCESS);
}
/***********************************************************************
- * SetupDiSetDeviceRegistryPropertyW (SETUPAPI.@)
+ * Internal for SetupDiSetDeviceRegistryPropertyA/W
*/
-BOOL WINAPI SetupDiSetDeviceRegistryPropertyW(
+BOOL WINAPI IntSetupDiSetDeviceRegistryPropertyAW(
HDEVINFO DeviceInfoSet,
PSP_DEVINFO_DATA DeviceInfoData,
DWORD Property,
const BYTE *PropertyBuffer,
- DWORD PropertyBufferSize)
+ DWORD PropertyBufferSize,
+ BOOL isAnsi)
{
BOOL ret = FALSE;
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
return FALSE;
}
if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
- && PropertyMap[Property].nameW)
+ && PropertyMap[Property].nameW
+ && PropertyMap[Property].nameA)
{
HKEY hKey;
LONG l;
if (hKey == INVALID_HANDLE_VALUE)
return FALSE;
/* Write new data */
- l = RegSetValueExW(
- hKey, PropertyMap[Property].nameW, 0,
- PropertyMap[Property].regType, PropertyBuffer,
- PropertyBufferSize);
+ if (isAnsi)
+ {
+ l = RegSetValueExA(
+ hKey, PropertyMap[Property].nameA, 0,
+ PropertyMap[Property].regType, PropertyBuffer,
+ PropertyBufferSize);
+ }
+ else
+ {
+ l = RegSetValueExW(
+ hKey, PropertyMap[Property].nameW, 0,
+ PropertyMap[Property].regType, PropertyBuffer,
+ PropertyBufferSize);
+ }
if (!l)
ret = TRUE;
else
TRACE("Returning %d\n", ret);
return ret;
}
+/***********************************************************************
+ * SetupDiSetDeviceRegistryPropertyA (SETUPAPI.@)
+ */
+BOOL WINAPI SetupDiSetDeviceRegistryPropertyA(
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_DATA DeviceInfoData,
+ DWORD Property,
+ const BYTE *PropertyBuffer,
+ DWORD PropertyBufferSize)
+{
+ return IntSetupDiSetDeviceRegistryPropertyAW(DeviceInfoSet,
+ DeviceInfoData,
+ Property,
+ PropertyBuffer,
+ PropertyBufferSize,
+ TRUE);
+}
+
+/***********************************************************************
+ * SetupDiSetDeviceRegistryPropertyW (SETUPAPI.@)
+ */
+BOOL WINAPI SetupDiSetDeviceRegistryPropertyW(
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_DATA DeviceInfoData,
+ DWORD Property,
+ const BYTE *PropertyBuffer,
+ DWORD PropertyBufferSize)
+{
+ return IntSetupDiSetDeviceRegistryPropertyAW(DeviceInfoSet,
+ DeviceInfoData,
+ Property,
+ PropertyBuffer,
+ PropertyBufferSize,
+ FALSE);
+}
/***********************************************************************
* SetupDiInstallClassA (SETUPAPI.@)
HKEY SETUP_CreateClassKey(HINF hInf)
{
- static const WCHAR slash[] = { '\\',0 };
WCHAR FullBuffer[MAX_PATH];
WCHAR Buffer[MAX_PATH];
DWORD RequiredSize;
HKEY hClassKey;
+ DWORD Disposition;
+ /* Obtain the Class GUID for this class */
if (!SetupGetLineTextW(NULL,
hInf,
Version,
- ClassGUID,
+ REGSTR_VAL_CLASSGUID,
Buffer,
- MAX_PATH,
+ sizeof(Buffer) / sizeof(WCHAR),
&RequiredSize))
{
return INVALID_HANDLE_VALUE;
}
+ /* Build the corresponding registry key name */
lstrcpyW(FullBuffer, REGSTR_PATH_CLASS_NT);
- lstrcatW(FullBuffer, slash);
+ lstrcatW(FullBuffer, BackSlash);
lstrcatW(FullBuffer, Buffer);
+ /* Obtain the Class name for this class */
+ if (!SetupGetLineTextW(NULL,
+ hInf,
+ Version,
+ REGSTR_VAL_CLASS,
+ Buffer,
+ sizeof(Buffer) / sizeof(WCHAR),
+ &RequiredSize))
+ {
+ return INVALID_HANDLE_VALUE;
+ }
+
+ /* Try to open or create the registry key */
+ TRACE("Opening class key %s\n", debugstr_w(FullBuffer));
+#if 0 // I keep this for reference...
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
FullBuffer,
0,
KEY_SET_VALUE,
&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_SET_VALUE,
- NULL,
- &hClassKey,
- NULL))
- {
- return INVALID_HANDLE_VALUE;
- }
+ /* Use RegCreateKeyExW */
}
+#endif
+ if (RegCreateKeyExW(HKEY_LOCAL_MACHINE,
+ FullBuffer,
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+ KEY_SET_VALUE,
+ NULL,
+ &hClassKey,
+ &Disposition))
+ {
+ ERR("RegCreateKeyExW(%s) failed\n", debugstr_w(FullBuffer));
+ return INVALID_HANDLE_VALUE;
+ }
+ if (Disposition == REG_CREATED_NEW_KEY)
+ TRACE("The class key %s was successfully created\n", debugstr_w(FullBuffer));
+ else
+ TRACE("The class key %s was successfully opened\n", debugstr_w(FullBuffer));
+ TRACE( "setting value %s to %s\n", debugstr_w(REGSTR_VAL_CLASS), debugstr_w(Buffer) );
if (RegSetValueExW(hClassKey,
- Class,
+ REGSTR_VAL_CLASS,
0,
REG_SZ,
(LPBYTE)Buffer,
&hKey);
if (rc == ERROR_SUCCESS)
{
- LPWSTR lpGuidString;
- if (UuidToStringW((UUID*)&DeviceInfoData->ClassGuid, &lpGuidString) == RPC_S_OK)
+ WCHAR szGuidString[40];
+ if (pSetupStringFromGuid(&DeviceInfoData->ClassGuid, szGuidString, ARRAYSIZE(szGuidString)) == ERROR_SUCCESS)
{
- rc = RegQueryValueExW(hKey, lpGuidString, NULL, &dwRegType, NULL, &dwLength);
+ rc = RegQueryValueExW(hKey, szGuidString, NULL, &dwRegType, NULL, &dwLength);
if (rc == ERROR_SUCCESS && dwRegType == REG_MULTI_SZ)
{
LPWSTR KeyBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
if (KeyBuffer != NULL)
{
- rc = RegQueryValueExW(hKey, lpGuidString, NULL, NULL, (LPBYTE)KeyBuffer, &dwLength);
+ rc = RegQueryValueExW(hKey, szGuidString, NULL, NULL, (LPBYTE)KeyBuffer, &dwLength);
if (rc == ERROR_SUCCESS)
{
LPWSTR ptr;
HeapFree(GetProcessHeap(), 0, KeyBuffer);
}
}
- RpcStringFreeW(&lpGuidString);
}
RegCloseKey(hKey);
}
rc = RegOpenKeyExW(HKLM,
REGSTR_PATH_HWPROFILES,
0,
- 0,
+ READ_CONTROL,
&hHWProfilesKey);
if (rc != ERROR_SUCCESS)
{
list->HKLM,
REGSTR_PATH_SYSTEMENUM,
0, /* Options */
- 0,
+ READ_CONTROL,
&hEnumKey);
if (rc != ERROR_SUCCESS)
{
HKEY enumKey, key = INVALID_HANDLE_VALUE;
LONG l;
- l = RegOpenKeyExW(RootKey, REGSTR_PATH_SYSTEMENUM, 0, 0, &enumKey);
+ l = RegOpenKeyExW(RootKey, REGSTR_PATH_SYSTEMENUM, 0, READ_CONTROL, &enumKey);
if (!l)
{
l = RegOpenKeyExW(enumKey, devInfo->instanceId, 0, samDesired, &key);
RootKey,
REGSTR_PATH_CLASS_NT,
0, /* Options */
- 0,
+ READ_CONTROL,
&hEnumKey);
if (rc != ERROR_SUCCESS)
{
RegCloseKey(hEnumKey);
if (hKey != NULL && hKey != key)
RegCloseKey(hKey);
+ if (DriverKey)
+ HeapFree(GetProcessHeap(), 0, DriverKey);
return key;
}
{
case DIREG_DEV:
key = SETUPDI_OpenDevKey(RootKey, devInfo, samDesired);
+ if (Scope == DICS_FLAG_GLOBAL)
+ {
+ LONG rc;
+ HKEY hTempKey = key;
+ rc = RegOpenKeyExW(hTempKey,
+ L"Device Parameters",
+ 0,
+ samDesired,
+ &key);
+ if (rc == ERROR_SUCCESS)
+ RegCloseKey(hTempKey);
+ }
break;
case DIREG_DRV:
key = SETUPDI_OpenDrvKey(RootKey, devInfo, samDesired);