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

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

Mapping IO space to UserMode via CreateFileMapping

Hi All,

I am writing some proof of concept code for KVM for communication between Windows 10 and a Host Linux system.

What I have is a virtual RAM device that is actually connected to a shared memory segment on the Host. The PCIe BAR 2 is a direct mapping to this RAM.

My intent is to provide a high bandwidth low latency means of transferring data that doesn't involve other common means used (sockets, etc). ZeroCopy would be ideal.

So far I have pretty much everything working, I have written a driver that calls MmAllocateMdlForIoSpace and then maps the memory using MmMapLockedPagesSpecifyCache to user mode via a DeviceIOControl. This works perfectly, the user mode application is able to address the shared memory and write to it.

What I am missing is the ability to use CreateFileMapping in user mode to obtain a HANDLE to a mapping of this memory. I am fairly new to windows driver programming and as such I am uncertain as to if this is even possible. Any pointers as to the best way to achieve this would be very helpful.

Comments

  • anton_bassovanton_bassov Posts: 4,799
    <quote>

    What I am missing is the ability to use CreateFileMapping in user mode to obtain a HANDLE to a mapping of this memory. I am fairly new to windows driver programming and as such I am uncertain as to if this is even possible. Any pointers as to the best way to achieve this would be very helpful.

    </quote>

    You seem to confuse Windows with the OSes that provide mmap() call and think just of everything in existence either as of a file or of a process. Windows does not, and it does not have VFS either, so that flle mapping and file IO functions are two totally dfferent sets of API that rely upon two totally different subsystems, namely, Memory Manager and IO Manager respectively. Therefore, device mapping that is exposed to the userland via IOCTL mechanism is the only option
    that is available to you - you cannot use a section object for this purpose....

    Anton Bassov
  • Hi Anton,

    Thanks for that, I thought that may be the case, but figured someone with much more experience in this field might have a magic bullet :)
  • Mark_RoddyMark_Roddy Posts: 4,269
    MDL based IO can provide zero copy but you still need to initiate it with
    IOCTL requests.

    Mark Roddy

    On Sun, Oct 8, 2017 at 10:42 PM, xxxxx@hostfission.com
    wrote:

    > Hi Anton,
    >
    > Thanks for that, I thought that may be the case, but figured someone with
    > much more experience in this field might have a magic bullet :)
    >
    > ---
    > NTDEV is sponsored by OSR
    >
    > Visit the list online at: showlists.cfm?list=ntdev>
    >
    > MONTHLY seminars on crash dump analysis, WDF, Windows internals and
    > software drivers!
    > Details at
    >
    > To unsubscribe, visit the List Server section of OSR Online at <
    > http://www.osronline.com/page.cfm?name=ListServer>;
    >
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!