I am trying to remove the IO Port assigned to my Function driver as I do not need the IO Port. With the IO Port required as a resource I will get the code 12 on some systems.
I am using EvtDeviceFilterRemoveResourceRequirements to attempt to remove this resource from the requirements, but the IO Port is still getting assigned. Is there any trick to removing the Resource Requirement?
Do I need to use both WdfIoResourceListRemove and WdfIoResourceListRemoveByDescriptor, to remove a resource descriptor?
That did not seem to make sense that I needed to call both.
Code is shown below and is getting called:
(Sorry for the formatting)
NTSTATUS EvtDeviceFilterRemoveResourceRequirements(
IN WDFDEVICE Device,
IN WDFIORESREQLIST RequirementsList
)
{
NTSTATUS status = STATUS_SUCCESS;
PRDC_DEVICE_CONTEXT rdc;
ULONG requirementCount;
ULONG resourceCount;
ULONG i,j;
rdc = GetDeviceContext(Device);
if (!rdc)
return STATUS_UNSUCCESSFUL;
KdPrint((“%s:–> EvtDeviceFilterRemoveResourceRequirements\n”, rdc->name));
// Obtain the number of logical configurations.
requirementCount = WdfIoResourceRequirementsListGetCount(RequirementsList);
KdPrint((" %s: requirementCount %d\n", rdc->name, requirementCount));
// Search each logical configuration.
for (i = 0; i < requirementCount; i++)
{
WDFIORESLIST resList;
BOOLEAN foundIOPort = FALSE;
resList =
WdfIoResourceRequirementsListGetIoResList(RequirementsList,i);
if (resList == NULL)
break;
// Get the number of resource descriptors that
// are in this logical configuration.
resourceCount = WdfIoResourceListGetCount(resList);
KdPrint((“%s: –> resourceCount %d\n”, rdc->name, resourceCount));
for (j = 0; j < resourceCount; j++)
{
PIO_RESOURCE_DESCRIPTOR descriptor;
//
// Get the next resource descriptor.
//
descriptor =
WdfIoResourceListGetDescriptor(resList, j);
if (descriptor == NULL)
{
KdPrint((“%d: NULL descriptor\n”, j));
continue;
}
switch (descriptor->Type)
{
case CmResourceTypePort:
KdPrint((“%d:Port min:(%x:%x) max:(%x:%x) Len:%x drop\n”,
j,
descriptor->u.Port.MinimumAddress.HighPart,
descriptor->u.Port.MinimumAddress.LowPart,
descriptor->u.Port.MaximumAddress.HighPart,
descriptor->u.Port.MaximumAddress.LowPart,
descriptor->u.Port.Length));
foundIOPort = TRUE;
//WdfIoResourceListRemove(resList, j);
WdfIoResourceListRemoveByDescriptor(resList, descriptor);
break;
case CmResourceTypeInterrupt:
KdPrint((“%d:Int min:(%x:%x) keep\n”, j,
descriptor->u.Interrupt.MinimumVector,
descriptor->u.Interrupt.MaximumVector));
break;
case CmResourceTypeMemory:
KdPrint((“%d:Mem min:(%x:%x) max:(%x:%x) Len:%x %s\n”,
j,
descriptor->u.Memory.MinimumAddress.HighPart,
descriptor->u.Memory.MinimumAddress.LowPart,
descriptor->u.Memory.MaximumAddress.HighPart,
descriptor->u.Memory.MaximumAddress.LowPart,
descriptor->u.Memory.Length, “keep”));
//j == 0 ? “keep”:“drop”));
//if (j != 0)
// WdfIoResourceListRemove(resList, j);
break;
default:
KdPrint((“%d:Unknown %d Priv:(%x:%x:%x) drop\n”, j,
descriptor->Type,
descriptor->u.DevicePrivate.Data[0],
descriptor->u.DevicePrivate.Data[1],
descriptor->u.DevicePrivate.Data[2]));
WdfIoResourceListRemove(resList, j);
break;
} // End Switch
} // End for (j = 0; j < resourceCount; j++)
} // End for (i = 0; i < requirementCount; i++)
KdPrint((“%s:<– EvtDeviceFilterRemoveResourceRequirements\n”, rdc->name));
return status;
}