Hi,
My gold is remove a IO resource from a driver A and assign this resource
to a driver B.
Both drivers are hook with WdfFdoInitSetEventCallbacks.
The driver A:
WDF_FDO_EVENT_CALLBACKS WdfFdoEventCallBack;
WDF_FDO_EVENT_CALLBACKS_INIT(&WdfFdoEventCallBack);
WdfFdoEventCallBack.EvtDeviceFilterRemoveResourceRequirements =
AFilterRemoveResourceRequirements;
WdfFdoEventCallBack.EvtDeviceFilterAddResourceRequirements =
AFilterAddResourceRequirements;
WdfFdoEventCallBack.EvtDeviceRemoveAddedResources =
ARemoveAddedResources;
WdfFdoInitSetEventCallbacks(DeviceInit, &WdfFdoEventCallBack);
The driver B:
WDF_FDO_EVENT_CALLBACKS WdfFdoEventCallBack;
WDF_FDO_EVENT_CALLBACKS_INIT(&WdfFdoEventCallBack);
WdfFdoEventCallBack.EvtDeviceFilterRemoveResourceRequirements =
BFilterRemoveResourceRequirements;
WdfFdoEventCallBack.EvtDeviceFilterAddResourceRequirements =
BFilterAddResourceRequirements;
WdfFdoEventCallBack.EvtDeviceRemoveAddedResources =
BRemoveAddedResources;
WdfFdoInitSetEventCallbacks(DeviceInit, &WdfFdoEventCallBack);
In the function AFilterRemoveResourceRequirements:
if (descriptor->Type == CmResourceTypePort)
{
WdfIoResourceRequirementsListRemoveByIoResList(IoResourceRequirementsLis
t, reslist );
WdfIoResourceListRemove(reslist, i);
}
Also in function ARemoveAddedResources:
for (int i = 0; i < nres; i++)
{
prd = WdfCmResourceListGetDescriptor(ResourcesRaw, i);
if (prd->Type == CmResourceTypePort)
{
WdfCmResourceListRemove(ResourcesRaw, i);
WdfCmResourceListRemove(ResourcesTranslated, i);
break;
}
}
Here I expect the IO resource of driver A is not associated anymore to
this driver.
And in driver B in function: BFilterAddResourceRequirements
RtlZeroMemory( &descriptor, sizeof(descriptor) );
descriptor.Option = 0;
descriptor.Type = CmResourceTypePort;
descriptor.ShareDisposition = CmResourceShareDeviceExclusive;
descriptor.Flags = CM_RESOURCE_PORT_IO;
descriptor.u.Port.Length = (ULONG) BarSize;
descriptor.u.Port.Alignment = 0x01;
descriptor.u.Port.MinimumAddress.QuadPart = BAR IO of DRIVER A;
descriptor.u.Port.MaximumAddress.QuadPart = = BAR IO of DRIVER A +
Bar Size;
ntStatus = WdfIoResourceListAppendDescriptor( logConfig, &descriptor
);
if (NT_SUCCESS(ntStatus))
ntStatus =
WdfIoResourceRequirementsListAppendIoResList(IoResourceRequirementsList,
logConfig);
But the OS does not want to assign the IO resource to driver B.
What I forget to my implementation ?
Thanks Gilles.