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.

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 :slight_smile:

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 :slight_smile:
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>