Fix CM_Get_Registry_Property_ExW. Implement CM_Set_Registry_Property_ExA. Modified: trunk/reactos/lib/setupapi/cfgmgr.c Modified: trunk/reactos/services/umpnpmgr/umpnpmgr.c _____
Modified: trunk/reactos/lib/setupapi/cfgmgr.c --- trunk/reactos/lib/setupapi/cfgmgr.c 2005-08-07 08:06:56 UTC (rev 17146) +++ trunk/reactos/lib/setupapi/cfgmgr.c 2005-08-07 09:03:35 UTC (rev 17147) @@ -148,7 +148,6 @@
ULONG ulClassIndex, LPGUID ClassGuid, ULONG ulFlags) { TRACE("%lx %p %lx\n", ulClassIndex, ClassGuid, ulFlags); - return CM_Enumerate_Classes_Ex(ulClassIndex, ClassGuid, ulFlags, NULL); }
@@ -192,10 +191,16 @@ { HKEY hRelativeKey, hKey; DWORD rc; - WCHAR Buffer[39]; + WCHAR Buffer[MAX_GUID_STRING_LEN];
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) { FIXME("hMachine argument ignored\n"); @@ -224,7 +229,7 @@ if (rc == ERROR_SUCCESS) { /* Remove the {} */ - Buffer[37] = UNICODE_NULL; + Buffer[MAX_GUID_STRING_LEN - 2] = UNICODE_NULL; /* Convert the buffer to a GUID */ if (UuidFromStringW(&Buffer[1], ClassGuid) != RPC_S_OK) return CR_FAILURE; @@ -476,6 +481,7 @@ if (lpDevInst == NULL) return CR_INVALID_DEVNODE;
+ ulTransferLength = *pulLength; ret = PNP_GetDeviceRegProp(BindingHandle, lpDevInst, ulProperty, @@ -1332,9 +1338,129 @@ DEVINST dnDevInst, ULONG ulProperty, PCVOID Buffer, ULONG ulLength, ULONG ulFlags, HMACHINE hMachine) { + CONFIGRET ret = CR_SUCCESS; + LPWSTR lpBuffer; + ULONG ulType; + FIXME("%lx %lu %p %lx %lx %lx\n", 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 @@ LPWSTR lpDevInst; ULONG ulType;
- FIXME("%lx %lu %p %lx %lx %lx\n", + TRACE("%lx %lu %p %lx %lx %lx\n", dnDevInst, ulProperty, Buffer, ulLength, ulFlags, hMachine);
if (dnDevInst == 0) _____
Modified: trunk/reactos/services/umpnpmgr/umpnpmgr.c --- trunk/reactos/services/umpnpmgr/umpnpmgr.c 2005-08-07 08:06:56 UTC (rev 17146) +++ trunk/reactos/services/umpnpmgr/umpnpmgr.c 2005-08-07 09:03:35 UTC (rev 17147) @@ -457,11 +457,13 @@
unsigned long *Length, DWORD Flags) { + PLUGPLAY_CONTROL_PROPERTY_DATA PlugPlayData; CONFIGRET ret = CR_SUCCESS; LPWSTR lpValueName = NULL; - ULONG Data; + HKEY hKey = 0; + NTSTATUS Status;
- DPRINT1("PNP_GetDeviceRegProp() called\n"); + DPRINT("PNP_GetDeviceRegProp() called\n");
switch (Property) { @@ -518,6 +520,7 @@ break;
case CM_DRP_UI_NUMBER: + lpValueName = NULL; break;
case CM_DRP_UPPERFILTERS: @@ -529,41 +532,104 @@ break;
case CM_DRP_BUSTYPEGUID: + lpValueName = NULL; break;
case CM_DRP_LEGACYBUSTYPE: + lpValueName = NULL; break;
case CM_DRP_BUSNUMBER: + lpValueName = NULL; break;
case CM_DRP_ENUMERATOR_NAME: + lpValueName = NULL; break;
default: return CR_INVALID_PROPERTY; }
- DPRINT1("Value name: %S\n", lpValueName); + DPRINT("Value name: %S\n", lpValueName);
if (lpValueName) { /* 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 { /* 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;
- Data = 0xbaadf00d; - memcpy(Buffer, &Data, sizeof(ULONG)); - *Length = sizeof(ULONG); + case CM_DRP_BUSTYPEGUID: + PlugPlayData.Property = DevicePropertyBusTypeGuid; + break;
- DPRINT1("PNP_GetDeviceRegProp() done (returns %lx)\n", ret); + 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); + return ret; }