All,
We have an old PCMCIA driver that we are trying to port to 64-bit Windows 10. The port mostly works but we ran into a weird situation where we have full read/write access to the cards memory but only when the driver has been compiled in debug mode. When it compiled in release mode, we can read the card’s memory just fine but we can not write to it!
The driver was developed using the WDM model and the PCMCIA card (a memory card) is non standard. It’s non-standard because it does not have a proper attribute space to report IDs and required resources. To get around this, we are processing IRP_MN_FILTER_RESOURCE_REQUIREMENTS to request a 64K block of memory. This works fine and the memory resource is available by the time StartDevice is called. Here we’re using MmMapIoSpaceEx(, PAGE_READWRITE | PAGE_NOCACHE), to obtain a virtual address to the cards memory. When the driver is compiled in debug mode, we have full read/write access of the card and everything works fine. However, if the driver is compiled in release mode, we can only read from the card.
Below is a code that we’re using to request the memory resource. Btw: the driver is being compiled with VS2019 and WDK 10.0.18346.1000.
Any ideas would be greatly appreciated.
Jim.
case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
{
status = Pcd_CallPcmciaDriver(AttachedPDO, Irp);
NewRequirements = ExAllocatePool(PagedPool, sizeof(IO_RESOURCE_REQUIREMENTS_LIST));
if( NewRequirements == NULL )
{
status = STATUS_INSUFFICIENT_RESOURCES;
}
else
{
RtlZeroMemory(NewRequirements, sizeof(IO_RESOURCE_REQUIREMENTS_LIST));
NewRequirements->ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST);
NewRequirements->InterfaceType = 0; // not used by WDM drivers;
NewRequirements->BusNumber = 0; // not used by WDM drivers
NewRequirements->SlotNumber = 0; // not used by WDM drivers
NewRequirements->Reserved[0] = 0; // not used by WDM drivers
NewRequirements->Reserved[1] = 0; // not used by WDM drivers
NewRequirements->Reserved[2] = 0; // not used by WDM drivers
NewRequirements->AlternativeLists = 1;
NewRequirements->List[0].Version = 1;
NewRequirements->List[0].Revision = 1;
NewRequirements->List[0].Count = 1;
NewRequirements->List[0].Descriptors[0].Option = 0;
NewRequirements->List[0].Descriptors[0].Type = CmResourceTypeMemory;
NewRequirements->List[0].Descriptors[0].ShareDisposition = CmResourceShareDeviceExclusive;
NewRequirements->List[0].Descriptors[0].Spare1 = 0;
NewRequirements->List[0].Descriptors[0].Flags = CM_RESOURCE_MEMORY_READ_WRITE;
NewRequirements->List[0].Descriptors[0].Spare2 = 0;
NewRequirements->List[0].Descriptors[0].u.Memory.Length = (64 * 1024);
NewRequirements->List[0].Descriptors[0].u.Memory.Alignment = (64 * 1024);
NewRequirements->List[0].Descriptors[0].u.Memory.MinimumAddress.QuadPart = 0;
NewRequirements->List[0].Descriptors[0].u.Memory.MaximumAddress.QuadPart = (ULONG)-1;
IrpStack->Parameters.FilterResourceRequirements.IoResourceRequirementList = NewRequirements;
if( Irp->IoStatus.Information )
{
ExFreePool( (void *)Irp->IoStatus.Information );
Irp->IoStatus.Information = 0;
}
Irp->IoStatus.Information = (ULONG_PTR)NewRequirements;
status = STATUS_SUCCESS;
}
break;