Skip to content

Commit c5325f5

Browse files
committed
[UMPNPMGR] Implement first part of PNP_AddEmptyLogConf
TODO: Adding a new configuration to an already existing configuration of the same type.
1 parent 81d845f commit c5325f5

File tree

1 file changed

+153
-6
lines changed

1 file changed

+153
-6
lines changed

base/services/umpnpmgr/rpcserver.c

Lines changed: 153 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,9 @@ GetConfigurationData(
494494
_In_ ULONG ulLogConfType,
495495
_Out_ PULONG pulRegDataType,
496496
_Out_ PULONG pulDataSize,
497-
_Out_ LPBYTE *ppBuffer)
497+
_Out_ LPBYTE *ppBuffer,
498+
_In_ ULONG ulValueNameBufferSize,
499+
_Out_opt_ LPWSTR pszValueNameBuffer)
498500
{
499501
LPCWSTR pszValueName;
500502

@@ -535,6 +537,11 @@ GetConfigurationData(
535537
return CR_FAILURE;
536538
}
537539

540+
/* Return the selected configuration value name */
541+
if ((ulValueNameBufferSize > 0) && (pszValueNameBuffer != NULL) &&
542+
(wcslen(pszValueName) + 1 <= ulValueNameBufferSize))
543+
wcscpy(pszValueNameBuffer, pszValueName);
544+
538545
/* Get the configuration data size */
539546
if (RegQueryValueExW(hKey,
540547
pszValueName,
@@ -4168,8 +4175,142 @@ PNP_AddEmptyLogConf(
41684175
DWORD *pulLogConfTag,
41694176
DWORD ulFlags)
41704177
{
4171-
UNIMPLEMENTED;
4172-
return CR_CALL_NOT_IMPLEMENTED;
4178+
HKEY hConfigKey = NULL;
4179+
DWORD RegDataType = 0;
4180+
ULONG ulDataSize = 0;
4181+
LPBYTE pDataBuffer = NULL;
4182+
WCHAR szValueNameBuffer[64];
4183+
CONFIGRET ret = CR_SUCCESS;
4184+
4185+
DPRINT("PNP_AddEmptyLogConf(%p %S %lu %p 0x%08lx)\n",
4186+
hBinding, pDeviceID, ulPriority, pulLogConfTag, ulFlags);
4187+
4188+
if (pulLogConfTag == NULL)
4189+
return CR_INVALID_POINTER;
4190+
4191+
*pulLogConfTag = 0;
4192+
4193+
if (ulFlags & ~(LOG_CONF_BITS | PRIORITY_BIT))
4194+
return CR_INVALID_FLAG;
4195+
4196+
if (!IsValidDeviceInstanceID(pDeviceID) || IsRootDeviceInstanceID(pDeviceID))
4197+
return CR_INVALID_DEVNODE;
4198+
4199+
ret = OpenConfigurationKey(pDeviceID,
4200+
ulFlags & LOG_CONF_BITS,
4201+
&hConfigKey);
4202+
if (ret != CR_SUCCESS)
4203+
{
4204+
DPRINT1("OpenConfigurationKey() failed (Error %lu)\n", ret);
4205+
ret = CR_NO_MORE_LOG_CONF;
4206+
goto done;
4207+
}
4208+
4209+
ret = GetConfigurationData(hConfigKey,
4210+
ulFlags & LOG_CONF_BITS,
4211+
&RegDataType,
4212+
&ulDataSize,
4213+
&pDataBuffer,
4214+
64,
4215+
szValueNameBuffer);
4216+
4217+
if (ret != CR_SUCCESS || ulDataSize == 0)
4218+
{
4219+
ret = CR_SUCCESS;
4220+
4221+
if (RegDataType == REG_RESOURCE_LIST)
4222+
{
4223+
PCM_RESOURCE_LIST pResourceList = NULL;
4224+
4225+
ulDataSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
4226+
pDataBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ulDataSize);
4227+
if (pDataBuffer == NULL)
4228+
{
4229+
ret = CR_OUT_OF_MEMORY;
4230+
goto done;
4231+
}
4232+
4233+
pResourceList = (PCM_RESOURCE_LIST)pDataBuffer;
4234+
pResourceList->Count = 1;
4235+
pResourceList->List[0].InterfaceType = InterfaceTypeUndefined;
4236+
pResourceList->List[0].BusNumber = 0;
4237+
pResourceList->List[0].PartialResourceList.Version = 1;
4238+
pResourceList->List[0].PartialResourceList.Revision = 1;
4239+
pResourceList->List[0].PartialResourceList.Count = 0;
4240+
}
4241+
else if (RegDataType == REG_RESOURCE_REQUIREMENTS_LIST)
4242+
{
4243+
PIO_RESOURCE_REQUIREMENTS_LIST pRequirementsList = NULL;
4244+
PIO_RESOURCE_LIST pResourceList = NULL;
4245+
4246+
ulDataSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST);
4247+
pDataBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ulDataSize);
4248+
if (pDataBuffer == NULL)
4249+
{
4250+
ret = CR_OUT_OF_MEMORY;
4251+
goto done;
4252+
}
4253+
4254+
pRequirementsList = (PIO_RESOURCE_REQUIREMENTS_LIST)pDataBuffer;
4255+
pRequirementsList->ListSize = ulDataSize;
4256+
pRequirementsList->InterfaceType = InterfaceTypeUndefined;
4257+
pRequirementsList->BusNumber = 0;
4258+
pRequirementsList->SlotNumber = 0;
4259+
pRequirementsList->AlternativeLists = 1;
4260+
4261+
pResourceList = (PIO_RESOURCE_LIST)&pRequirementsList->List[0];
4262+
pResourceList->Version = 1;
4263+
pResourceList->Revision = 1;
4264+
pResourceList->Count = 1;
4265+
4266+
pResourceList->Descriptors[0].Option = IO_RESOURCE_PREFERRED;
4267+
pResourceList->Descriptors[0].Type = CmResourceTypeConfigData;
4268+
pResourceList->Descriptors[0].u.ConfigData.Priority = ulPriority;
4269+
}
4270+
else
4271+
{
4272+
ret = CR_FAILURE;
4273+
goto done;
4274+
}
4275+
}
4276+
else
4277+
{
4278+
if (RegDataType == REG_RESOURCE_LIST)
4279+
{
4280+
/* FIXME */
4281+
}
4282+
else if (RegDataType == REG_RESOURCE_REQUIREMENTS_LIST)
4283+
{
4284+
/* FIXME */
4285+
}
4286+
else
4287+
{
4288+
ret = CR_FAILURE;
4289+
goto done;
4290+
}
4291+
}
4292+
4293+
if (RegSetValueEx(hConfigKey,
4294+
szValueNameBuffer,
4295+
0,
4296+
RegDataType,
4297+
pDataBuffer,
4298+
ulDataSize) != ERROR_SUCCESS)
4299+
{
4300+
ret = CR_REGISTRY_ERROR;
4301+
goto done;
4302+
}
4303+
4304+
done:
4305+
if (pDataBuffer != NULL)
4306+
HeapFree(GetProcessHeap(), 0, pDataBuffer);
4307+
4308+
if (hConfigKey != NULL)
4309+
RegCloseKey(hConfigKey);
4310+
4311+
DPRINT("PNP_AddEmptyLogConf() returns %lu\n", ret);
4312+
4313+
return ret;
41734314
}
41744315

41754316

@@ -4232,7 +4373,9 @@ PNP_GetFirstLogConf(
42324373
ulLogConfType,
42334374
&RegDataType,
42344375
&ulDataSize,
4235-
&lpData);
4376+
&lpData,
4377+
0,
4378+
NULL);
42364379
if (ret != CR_SUCCESS)
42374380
{
42384381
DPRINT1("GetConfigurationData() failed (Error %lu)\n", ret);
@@ -4332,7 +4475,9 @@ PNP_GetNextLogConf(
43324475
ulLogConfType,
43334476
&RegDataType,
43344477
&ulDataSize,
4335-
&lpData);
4478+
&lpData,
4479+
0,
4480+
NULL);
43364481
if (ret != CR_SUCCESS)
43374482
{
43384483
DPRINT1("GetConfigurationData() failed (Error %lu)\n", ret);
@@ -4507,7 +4652,9 @@ PNP_GetNextResDes(
45074652
ulLogConfType,
45084653
&RegDataType,
45094654
&ulDataSize,
4510-
&lpData);
4655+
&lpData,
4656+
0,
4657+
NULL);
45114658
if (ret != CR_SUCCESS)
45124659
{
45134660
DPRINT1("GetConfigurationData() failed (Error %lu)\n", ret);

0 commit comments

Comments
 (0)