Skip to content

Commit 2ec3a19

Browse files
committed
[UMPNPMGR] Implement first part of PNP_FreeLogConf
1 parent 208dfd2 commit 2ec3a19

File tree

2 files changed

+85
-4
lines changed

2 files changed

+85
-4
lines changed

base/services/umpnpmgr/precomp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include <pnp_s.h>
3434

3535

36+
#define LOGCONF_NAME_BUFFER_SIZE 32
37+
3638
typedef struct
3739
{
3840
LIST_ENTRY ListEntry;

base/services/umpnpmgr/rpcserver.c

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4179,7 +4179,7 @@ PNP_AddEmptyLogConf(
41794179
DWORD RegDataType = 0;
41804180
ULONG ulDataSize = 0;
41814181
LPBYTE pDataBuffer = NULL;
4182-
WCHAR szValueNameBuffer[64];
4182+
WCHAR szValueNameBuffer[LOGCONF_NAME_BUFFER_SIZE];
41834183
CONFIGRET ret = CR_SUCCESS;
41844184

41854185
DPRINT("PNP_AddEmptyLogConf(%p %S %lu %p 0x%08lx)\n",
@@ -4211,7 +4211,7 @@ PNP_AddEmptyLogConf(
42114211
&RegDataType,
42124212
&ulDataSize,
42134213
&pDataBuffer,
4214-
64,
4214+
LOGCONF_NAME_BUFFER_SIZE,
42154215
szValueNameBuffer);
42164216

42174217
if (ret != CR_SUCCESS || ulDataSize == 0)
@@ -4324,8 +4324,87 @@ PNP_FreeLogConf(
43244324
DWORD ulLogConfTag,
43254325
DWORD ulFlags)
43264326
{
4327-
UNIMPLEMENTED;
4328-
return CR_CALL_NOT_IMPLEMENTED;
4327+
HKEY hConfigKey = NULL;
4328+
DWORD RegDataType = 0;
4329+
ULONG ulDataSize = 0;
4330+
LPBYTE pDataBuffer = NULL;
4331+
WCHAR szValueNameBuffer[LOGCONF_NAME_BUFFER_SIZE];
4332+
CONFIGRET ret = CR_SUCCESS;
4333+
4334+
DPRINT("PNP_FreeLogConf(%p %S %lu %lu 0x%08lx)\n",
4335+
hBinding, pDeviceID, ulLogConfType, ulLogConfTag, ulFlags);
4336+
4337+
if (ulFlags != 0)
4338+
return CR_INVALID_FLAG;
4339+
4340+
if (!IsValidDeviceInstanceID(pDeviceID))
4341+
return CR_INVALID_DEVNODE;
4342+
4343+
ret = OpenConfigurationKey(pDeviceID,
4344+
ulLogConfType,
4345+
&hConfigKey);
4346+
if (ret != CR_SUCCESS)
4347+
{
4348+
DPRINT1("OpenConfigurationKey() failed (Error %lu)\n", ret);
4349+
ret = CR_NO_MORE_LOG_CONF;
4350+
goto done;
4351+
}
4352+
4353+
ret = GetConfigurationData(hConfigKey,
4354+
ulLogConfType,
4355+
&RegDataType,
4356+
&ulDataSize,
4357+
&pDataBuffer,
4358+
LOGCONF_NAME_BUFFER_SIZE,
4359+
szValueNameBuffer);
4360+
if (ret != CR_SUCCESS)
4361+
{
4362+
ret = CR_INVALID_LOG_CONF;
4363+
goto done;
4364+
}
4365+
4366+
if (RegDataType == REG_RESOURCE_LIST)
4367+
{
4368+
if (((PCM_RESOURCE_LIST)pDataBuffer)->Count <= 1)
4369+
{
4370+
/* Delete the key if there is only one or no configuration in the key */
4371+
DPRINT("Delete value %S\n", szValueNameBuffer);
4372+
RegDeleteValue(hConfigKey, szValueNameBuffer);
4373+
}
4374+
else
4375+
{
4376+
/* FIXME */
4377+
}
4378+
}
4379+
else if (RegDataType == REG_RESOURCE_REQUIREMENTS_LIST)
4380+
{
4381+
if (((PIO_RESOURCE_REQUIREMENTS_LIST)pDataBuffer)->AlternativeLists <= 1)
4382+
{
4383+
/* Delete the key if there is only one or no configuration in the key */
4384+
DPRINT("Delete value %S\n", szValueNameBuffer);
4385+
RegDeleteValue(hConfigKey, szValueNameBuffer);
4386+
}
4387+
else
4388+
{
4389+
/* FIXME */
4390+
}
4391+
}
4392+
else
4393+
{
4394+
ret = CR_FAILURE;
4395+
goto done;
4396+
}
4397+
4398+
done:
4399+
if (pDataBuffer != NULL)
4400+
HeapFree(GetProcessHeap(), 0, pDataBuffer);
4401+
4402+
if (hConfigKey != NULL)
4403+
RegCloseKey(hConfigKey);
4404+
4405+
DPRINT("PNP_FreeLogConf() returns %lu\n", ret);
4406+
4407+
return ret;
43294408
}
43304409

43314410

0 commit comments

Comments
 (0)