Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging

The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.

Check out The OSR Learning Library at:

PCMCIA on Windows 10

Jimmy_JamesJimmy_James Member - All Emails Posts: 107

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.

status = Pcd_CallPcmciaDriver(AttachedPDO, Irp);
NewRequirements = ExAllocatePool(PagedPool, sizeof(IO_RESOURCE_REQUIREMENTS_LIST));

    if( NewRequirements == NULL )
        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;

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 15 Jun 2020 LIVE ONLINE
Writing WDF Drivers 22 June 2020 LIVE ONLINE
Internals & Software Drivers 28 Sept 2020 Dulles, VA