[SETUPAPI] Implement CM_Free_Res_Des_Handle() and improve CM_Get_Next_Re_Des_Ex()

This commit is contained in:
Eric Kohl 2024-07-20 22:20:36 +02:00
parent 39077a7bf0
commit 894ad4f17d

View file

@ -70,6 +70,17 @@ typedef struct _LOG_CONF_INFO
#define LOG_CONF_MAGIC 0x464E434C /* "LCNF" */ #define LOG_CONF_MAGIC 0x464E434C /* "LCNF" */
typedef struct _RES_DES_INFO
{
ULONG ulMagic;
DEVINST dnDevInst;
ULONG ulLogConfType;
ULONG ulLogConfTag;
ULONG ulResDesType;
ULONG ulResDesTag;
} RES_DES_INFO, *PRES_DES_INFO;
#define RES_DES_MAGIC 0x53445352 /* "RSDS" */
typedef struct _NOTIFY_DATA typedef struct _NOTIFY_DATA
{ {
@ -434,6 +445,30 @@ IsValidLogConf(
} }
BOOL
IsValidResDes(
_In_opt_ PRES_DES_INFO pResDesInfo)
{
BOOL bValid = TRUE;
if (pResDesInfo == NULL)
return FALSE;
_SEH2_TRY
{
if (pResDesInfo->ulMagic != RES_DES_MAGIC)
bValid = FALSE;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
bValid = FALSE;
}
_SEH2_END;
return bValid;
}
BOOL BOOL
IsValidConflictData( IsValidConflictData(
_In_opt_ PCONFLICT_DATA pConflictData) _In_opt_ PCONFLICT_DATA pConflictData)
@ -2490,9 +2525,17 @@ WINAPI
CM_Free_Res_Des_Handle( CM_Free_Res_Des_Handle(
_In_ RES_DES rdResDes) _In_ RES_DES rdResDes)
{ {
PRES_DES_INFO pResDesInfo;
FIXME("CM_Free_Res_Des_Handle(%p)\n", rdResDes); FIXME("CM_Free_Res_Des_Handle(%p)\n", rdResDes);
return CR_CALL_NOT_IMPLEMENTED; pResDesInfo = (PRES_DES_INFO)rdResDes;
if (!IsValidResDes(pResDesInfo))
return CR_INVALID_RES_DES;
HeapFree(GetProcessHeap(), 0, pResDesInfo);
return CR_SUCCESS;
} }
@ -5175,7 +5218,7 @@ CM_Get_Next_Log_Conf_Ex(
/*********************************************************************** /***********************************************************************
* CM_Get_Next_Re_Des [SETUPAPI.@] * CM_Get_Next_Res_Des [SETUPAPI.@]
*/ */
CONFIGRET CONFIGRET
WINAPI WINAPI
@ -5209,8 +5252,9 @@ CM_Get_Next_Res_Des_Ex(
{ {
RPC_BINDING_HANDLE BindingHandle = NULL; RPC_BINDING_HANDLE BindingHandle = NULL;
HSTRING_TABLE StringTable = NULL; HSTRING_TABLE StringTable = NULL;
ULONG ulInTag, ulOutTag = 0; PRES_DES_INFO pNewResDesInfo = NULL;
ULONG ulInType, ulOutType = 0; ULONG ulLogConfTag, ulLogConfType, ulResDesTag;
ULONG ulNextResDesType = 0, ulNextResDesTag = 0;
LPWSTR lpDevInst; LPWSTR lpDevInst;
DEVINST dnDevInst; DEVINST dnDevInst;
CONFIGRET ret; CONFIGRET ret;
@ -5225,23 +5269,29 @@ CM_Get_Next_Res_Des_Ex(
{ {
FIXME("LogConf found!\n"); FIXME("LogConf found!\n");
dnDevInst = ((PLOG_CONF_INFO)rdResDes)->dnDevInst; dnDevInst = ((PLOG_CONF_INFO)rdResDes)->dnDevInst;
ulInTag = ((PLOG_CONF_INFO)rdResDes)->ulTag; ulLogConfTag = ((PLOG_CONF_INFO)rdResDes)->ulTag;
ulInType = ((PLOG_CONF_INFO)rdResDes)->ulType; ulLogConfType = ((PLOG_CONF_INFO)rdResDes)->ulType;
ulResDesTag = (ULONG)-1;
} }
#if 0
else if (IsValidResDes((PRES_DES_INFO)rdResDes)) else if (IsValidResDes((PRES_DES_INFO)rdResDes))
{ {
FIXME("ResDes found!\n"); FIXME("ResDes found!\n");
dnDevInst = ((PRES_DES_INFO)rdResDes)->dnDevInst; dnDevInst = ((PRES_DES_INFO)rdResDes)->dnDevInst;
ulInTag = ((PRES_DES_INFO)rdResDes)->ulTag; ulLogConfTag = ((PRES_DES_INFO)rdResDes)->ulLogConfTag;
ulInType = ((PRES_DES_INFO)rdResDes)->ulType; ulLogConfType = ((PRES_DES_INFO)rdResDes)->ulLogConfType;
ulResDesTag = ((PRES_DES_INFO)rdResDes)->ulResDesTag;
} }
#endif
else else
{ {
return CR_INVALID_RES_DES; return CR_INVALID_RES_DES;
} }
if ((ForResource == ResType_All) && (pResourceID == NULL))
return CR_INVALID_POINTER;
if (ulFlags != 0)
return CR_INVALID_FLAG;
if (hMachine != NULL) if (hMachine != NULL)
{ {
BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle;
@ -5266,12 +5316,12 @@ CM_Get_Next_Res_Des_Ex(
{ {
ret = PNP_GetNextResDes(BindingHandle, ret = PNP_GetNextResDes(BindingHandle,
lpDevInst, lpDevInst,
ulInTag, ulLogConfTag,
ulInType, ulLogConfType,
ForResource, ForResource,
0, /* unsigned long ulResourceTag, */ ulResDesTag,
&ulOutTag, &ulNextResDesTag,
&ulOutType, &ulNextResDesType,
0); 0);
} }
RpcExcept(EXCEPTION_EXECUTE_HANDLER) RpcExcept(EXCEPTION_EXECUTE_HANDLER)
@ -5283,7 +5333,24 @@ CM_Get_Next_Res_Des_Ex(
if (ret != CR_SUCCESS) if (ret != CR_SUCCESS)
return ret; return ret;
/* FIXME: Create the ResDes handle */ if (ForResource == ResType_All)
*pResourceID = ulNextResDesType;
if (prdResDes)
{
pNewResDesInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(RES_DES_INFO));
if (pNewResDesInfo == NULL)
return CR_OUT_OF_MEMORY;
pNewResDesInfo->ulMagic = LOG_CONF_MAGIC;
pNewResDesInfo->dnDevInst = dnDevInst;
pNewResDesInfo->ulLogConfType = ulLogConfType;
pNewResDesInfo->ulLogConfTag = ulLogConfTag;
pNewResDesInfo->ulResDesType = ulNextResDesType;
pNewResDesInfo->ulResDesTag = ulNextResDesTag;
*prdResDes = (RES_DES)pNewResDesInfo;
}
return CR_SUCCESS; return CR_SUCCESS;
} }