Fix CM_Get_Registry_Property_ExW.

Implement CM_Set_Registry_Property_ExA.

svn path=/trunk/; revision=17147
This commit is contained in:
Eric Kohl 2005-08-07 09:03:35 +00:00
parent a48242f711
commit 6e9638b203
2 changed files with 206 additions and 14 deletions

View file

@ -148,7 +148,6 @@ CONFIGRET WINAPI CM_Enumerate_Classes(
ULONG ulClassIndex, LPGUID ClassGuid, ULONG ulFlags) ULONG ulClassIndex, LPGUID ClassGuid, ULONG ulFlags)
{ {
TRACE("%lx %p %lx\n", ulClassIndex, ClassGuid, ulFlags); TRACE("%lx %p %lx\n", ulClassIndex, ClassGuid, ulFlags);
return CM_Enumerate_Classes_Ex(ulClassIndex, ClassGuid, ulFlags, NULL); return CM_Enumerate_Classes_Ex(ulClassIndex, ClassGuid, ulFlags, NULL);
} }
@ -192,10 +191,16 @@ CONFIGRET WINAPI CM_Enumerate_Classes_Ex(
{ {
HKEY hRelativeKey, hKey; HKEY hRelativeKey, hKey;
DWORD rc; DWORD rc;
WCHAR Buffer[39]; WCHAR Buffer[MAX_GUID_STRING_LEN];
TRACE("%lx %p %lx %p\n", ulClassIndex, ClassGuid, ulFlags, hMachine); TRACE("%lx %p %lx %p\n", ulClassIndex, ClassGuid, ulFlags, hMachine);
if (ClassGuid == NULL)
return CR_INVALID_POINTER;
if (ulFlags != 0)
return CR_INVALID_FLAG;
if (hMachine != NULL) if (hMachine != NULL)
{ {
FIXME("hMachine argument ignored\n"); FIXME("hMachine argument ignored\n");
@ -224,7 +229,7 @@ CONFIGRET WINAPI CM_Enumerate_Classes_Ex(
if (rc == ERROR_SUCCESS) if (rc == ERROR_SUCCESS)
{ {
/* Remove the {} */ /* Remove the {} */
Buffer[37] = UNICODE_NULL; Buffer[MAX_GUID_STRING_LEN - 2] = UNICODE_NULL;
/* Convert the buffer to a GUID */ /* Convert the buffer to a GUID */
if (UuidFromStringW(&Buffer[1], ClassGuid) != RPC_S_OK) if (UuidFromStringW(&Buffer[1], ClassGuid) != RPC_S_OK)
return CR_FAILURE; return CR_FAILURE;
@ -476,6 +481,7 @@ CONFIGRET WINAPI CM_Get_DevNode_Registry_Property_ExW(
if (lpDevInst == NULL) if (lpDevInst == NULL)
return CR_INVALID_DEVNODE; return CR_INVALID_DEVNODE;
ulTransferLength = *pulLength;
ret = PNP_GetDeviceRegProp(BindingHandle, ret = PNP_GetDeviceRegProp(BindingHandle,
lpDevInst, lpDevInst,
ulProperty, ulProperty,
@ -1332,9 +1338,129 @@ CONFIGRET WINAPI CM_Set_DevNode_Registry_Property_ExA(
DEVINST dnDevInst, ULONG ulProperty, PCVOID Buffer, ULONG ulLength, DEVINST dnDevInst, ULONG ulProperty, PCVOID Buffer, ULONG ulLength,
ULONG ulFlags, HMACHINE hMachine) ULONG ulFlags, HMACHINE hMachine)
{ {
CONFIGRET ret = CR_SUCCESS;
LPWSTR lpBuffer;
ULONG ulType;
FIXME("%lx %lu %p %lx %lx %lx\n", FIXME("%lx %lu %p %lx %lx %lx\n",
dnDevInst, ulProperty, Buffer, ulLength, ulFlags, hMachine); dnDevInst, ulProperty, Buffer, ulLength, ulFlags, hMachine);
return CR_CALL_NOT_IMPLEMENTED;
if (Buffer == NULL && ulLength != 0)
return CR_INVALID_POINTER;
if (Buffer == NULL)
{
ret = CM_Set_DevNode_Registry_Property_ExW(dnDevInst,
ulProperty,
NULL,
0,
ulFlags,
hMachine);
}
else
{
/* Get property type */
switch (ulProperty)
{
case CM_DRP_DEVICEDESC:
ulType = REG_SZ;
break;
case CM_DRP_HARDWAREID:
ulType = REG_MULTI_SZ;
break;
case CM_DRP_COMPATIBLEIDS:
ulType = REG_MULTI_SZ;
break;
case CM_DRP_SERVICE:
ulType = REG_SZ;
break;
case CM_DRP_CLASS:
ulType = REG_SZ;
break;
case CM_DRP_CLASSGUID:
ulType = REG_SZ;
break;
case CM_DRP_DRIVER:
ulType = REG_SZ;
break;
case CM_DRP_CONFIGFLAGS:
ulType = REG_DWORD;
break;
case CM_DRP_MFG:
ulType = REG_SZ;
break;
case CM_DRP_FRIENDLYNAME:
ulType = REG_SZ;
break;
case CM_DRP_LOCATION_INFORMATION:
ulType = REG_SZ;
break;
case CM_DRP_UPPERFILTERS:
ulType = REG_MULTI_SZ;
break;
case CM_DRP_LOWERFILTERS:
ulType = REG_MULTI_SZ;
break;
default:
return CR_INVALID_PROPERTY;
}
/* Allocate buffer if needed */
if (ulType == REG_SZ ||
ulType == REG_MULTI_SZ)
{
lpBuffer = MyMalloc(ulLength * sizeof(WCHAR));
if (lpBuffer == NULL)
{
ret = CR_OUT_OF_MEMORY;
}
else
{
if (!MultiByteToWideChar(CP_ACP, 0, Buffer,
ulLength, lpBuffer, ulLength))
{
MyFree(lpBuffer);
ret = CR_FAILURE;
}
else
{
ret = CM_Set_DevNode_Registry_Property_ExW(dnDevInst,
ulProperty,
lpBuffer,
ulLength * sizeof(WCHAR),
ulFlags,
hMachine);
MyFree(lpBuffer);
}
}
}
else
{
ret = CM_Set_DevNode_Registry_Property_ExW(dnDevInst,
ulProperty,
Buffer,
ulLength,
ulFlags,
hMachine);
}
ret = CR_CALL_NOT_IMPLEMENTED;
}
return ret;
} }
@ -1350,7 +1476,7 @@ CONFIGRET WINAPI CM_Set_DevNode_Registry_Property_ExW(
LPWSTR lpDevInst; LPWSTR lpDevInst;
ULONG ulType; ULONG ulType;
FIXME("%lx %lu %p %lx %lx %lx\n", TRACE("%lx %lu %p %lx %lx %lx\n",
dnDevInst, ulProperty, Buffer, ulLength, ulFlags, hMachine); dnDevInst, ulProperty, Buffer, ulLength, ulFlags, hMachine);
if (dnDevInst == 0) if (dnDevInst == 0)

View file

@ -457,11 +457,13 @@ PNP_GetDeviceRegProp(handle_t BindingHandle,
unsigned long *Length, unsigned long *Length,
DWORD Flags) DWORD Flags)
{ {
PLUGPLAY_CONTROL_PROPERTY_DATA PlugPlayData;
CONFIGRET ret = CR_SUCCESS; CONFIGRET ret = CR_SUCCESS;
LPWSTR lpValueName = NULL; LPWSTR lpValueName = NULL;
ULONG Data; HKEY hKey = 0;
NTSTATUS Status;
DPRINT1("PNP_GetDeviceRegProp() called\n"); DPRINT("PNP_GetDeviceRegProp() called\n");
switch (Property) switch (Property)
{ {
@ -518,6 +520,7 @@ PNP_GetDeviceRegProp(handle_t BindingHandle,
break; break;
case CM_DRP_UI_NUMBER: case CM_DRP_UI_NUMBER:
lpValueName = NULL;
break; break;
case CM_DRP_UPPERFILTERS: case CM_DRP_UPPERFILTERS:
@ -529,40 +532,103 @@ PNP_GetDeviceRegProp(handle_t BindingHandle,
break; break;
case CM_DRP_BUSTYPEGUID: case CM_DRP_BUSTYPEGUID:
lpValueName = NULL;
break; break;
case CM_DRP_LEGACYBUSTYPE: case CM_DRP_LEGACYBUSTYPE:
lpValueName = NULL;
break; break;
case CM_DRP_BUSNUMBER: case CM_DRP_BUSNUMBER:
lpValueName = NULL;
break; break;
case CM_DRP_ENUMERATOR_NAME: case CM_DRP_ENUMERATOR_NAME:
lpValueName = NULL;
break; break;
default: default:
return CR_INVALID_PROPERTY; return CR_INVALID_PROPERTY;
} }
DPRINT1("Value name: %S\n", lpValueName); DPRINT("Value name: %S\n", lpValueName);
if (lpValueName) if (lpValueName)
{ {
/* Retrieve information from the Registry */ /* Retrieve information from the Registry */
if (RegOpenKeyExW(hEnumKey,
DeviceInstance,
0,
KEY_ALL_ACCESS,
&hKey))
return CR_INVALID_DEVNODE;
if (RegQueryValueExW(hKey,
lpValueName,
NULL,
DataType,
(LPBYTE)Buffer,
Length))
ret = CR_REGISTRY_ERROR;
/* FIXME: Check buffer size */
RegCloseKey(hKey);
} }
else else
{ {
/* Retrieve information from the Device Node */ /* Retrieve information from the Device Node */
RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
DeviceInstance);
PlugPlayData.Buffer = Buffer;
PlugPlayData.BufferSize = *TransferLen;
switch (Property)
{
#if 0
case CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME:
PlugPlayData.Property = DevicePropertyPhysicalDeviceObjectName;
break;
case CM_DRP_UI_NUMBER:
PlugPlayData.Property = DevicePropertyUINumber;
break;
case CM_DRP_BUSTYPEGUID:
PlugPlayData.Property = DevicePropertyBusTypeGuid;
break;
case CM_DRP_LEGACYBUSTYPE:
PlugPlayData.Property = DevicePropertyLegacyBusType;
break;
case CM_DRP_BUSNUMBER:
PlugPlayData.Property = DevicePropertyBusNumber;
break;
case CM_DRP_ENUMERATOR_NAME:
PlugPlayData.Property = DevicePropertyEnumeratorName;
break;
#endif
default:
return CR_INVALID_PROPERTY;
}
Status = NtPlugPlayControl(PlugPlayControlProperty,
(PVOID)&PlugPlayData,
sizeof(PLUGPLAY_CONTROL_PROPERTY_DATA));
if (NT_SUCCESS(Status))
{
*Length = PlugPlayData.BufferSize;
}
else
{
ret = CR_FAILURE; /* FIXME */
}
} }
DPRINT("PNP_GetDeviceRegProp() done (returns %lx)\n", ret);
Data = 0xbaadf00d;
memcpy(Buffer, &Data, sizeof(ULONG));
*Length = sizeof(ULONG);
DPRINT1("PNP_GetDeviceRegProp() done (returns %lx)\n", ret);
return ret; return ret;
} }