mirror of
https://github.com/reactos/reactos.git
synced 2024-12-30 19:14:31 +00:00
[UMPNPMGR] Add checks for the root device instance ID
This commit is contained in:
parent
8bf3f3feb9
commit
2a2dd8f726
1 changed files with 29 additions and 5 deletions
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
/* GLOBALS ******************************************************************/
|
/* GLOBALS ******************************************************************/
|
||||||
|
|
||||||
static WCHAR szRootDeviceId[] = L"HTREE\\ROOT\\0";
|
static WCHAR szRootDeviceInstanceID[] = L"HTREE\\ROOT\\0";
|
||||||
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
@ -292,6 +292,18 @@ IsValidDeviceInstanceID(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
BOOL
|
||||||
|
IsRootDeviceInstanceID(
|
||||||
|
_In_ PWSTR pszDeviceInstanceID)
|
||||||
|
{
|
||||||
|
if (_wcsicmp(pszDeviceInstanceID, szRootDeviceInstanceID) == 0)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* PUBLIC FUNCTIONS **********************************************************/
|
/* PUBLIC FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
/* Function 0 */
|
/* Function 0 */
|
||||||
|
@ -472,14 +484,14 @@ PNP_GetRootDeviceInstance(
|
||||||
ret = CR_INVALID_POINTER;
|
ret = CR_INVALID_POINTER;
|
||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
if (ulLength < lstrlenW(szRootDeviceId) + 1)
|
if (ulLength < lstrlenW(szRootDeviceInstanceID) + 1)
|
||||||
{
|
{
|
||||||
ret = CR_BUFFER_SMALL;
|
ret = CR_BUFFER_SMALL;
|
||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
lstrcpyW(pDeviceID,
|
lstrcpyW(pDeviceID,
|
||||||
szRootDeviceId);
|
szRootDeviceInstanceID);
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
DPRINT("PNP_GetRootDeviceInstance() done (returns %lx)\n", ret);
|
DPRINT("PNP_GetRootDeviceInstance() done (returns %lx)\n", ret);
|
||||||
|
@ -2626,7 +2638,18 @@ PNP_CreateDevInst(
|
||||||
{
|
{
|
||||||
CONFIGRET ret = CR_SUCCESS;
|
CONFIGRET ret = CR_SUCCESS;
|
||||||
|
|
||||||
DPRINT("PNP_CreateDevInst: %S\n", pszDeviceID);
|
DPRINT("PNP_CreateDevInst(%p %S %S %lu 0x%08lx)\n",
|
||||||
|
hBinding, pszParentDeviceID, pszDeviceID, ulLength, ulFlags);
|
||||||
|
|
||||||
|
if (ulFlags & ~CM_CREATE_DEVNODE_BITS)
|
||||||
|
return CR_INVALID_FLAG;
|
||||||
|
|
||||||
|
if (pszDeviceID == NULL || pszParentDeviceID == NULL)
|
||||||
|
return CR_INVALID_POINTER;
|
||||||
|
|
||||||
|
/* Fail, if the parent device is not the root device */
|
||||||
|
if (!IsRootDeviceInstanceID(pszParentDeviceID))
|
||||||
|
return CR_INVALID_DEVINST;
|
||||||
|
|
||||||
if (ulFlags & CM_CREATE_DEVNODE_GENERATE_ID)
|
if (ulFlags & CM_CREATE_DEVNODE_GENERATE_ID)
|
||||||
{
|
{
|
||||||
|
@ -3056,7 +3079,8 @@ PNP_QueryRemove(
|
||||||
if (ulFlags & ~CM_REMOVE_BITS)
|
if (ulFlags & ~CM_REMOVE_BITS)
|
||||||
return CR_INVALID_FLAG;
|
return CR_INVALID_FLAG;
|
||||||
|
|
||||||
if (!IsValidDeviceInstanceID(pszDeviceID))
|
if (!IsValidDeviceInstanceID(pszDeviceID) ||
|
||||||
|
IsRootDeviceInstanceID(pszDeviceID))
|
||||||
return CR_INVALID_DEVINST;
|
return CR_INVALID_DEVINST;
|
||||||
|
|
||||||
if (pVetoType != NULL)
|
if (pVetoType != NULL)
|
||||||
|
|
Loading…
Reference in a new issue