Tech Support > Microsoft Windows > Drivers > A "memory-mapped" file system, need advice
A "memory-mapped" file system, need advice
Posted by rep_movsd on August 14th, 2007


Hi

I'm pretty green when it comes to device driver development, having
made only one small driver modified from MS sample code.

I now have an idea for a filesystem driver that would allow
applications to expose buffers of memory as files.

For eg:
Application opens a shared memory section "Q:\somename" and driver
shows a file "somename" in a virtual drive Q: which any application
can access.
This can lead to all sorts of interesting applications.
Several times I used memory mapped files and several times I wished
the inverse existed where opening a file gets u a block of memory that
another application is generating.

OK yes, one can always use a temporary file to get a similar effect,
but I would like to try this driver approach.

Where do I start and hows the best way to go about this?

Advice, admonitions, suggestions, criticisms, caveats, are all
welcome....

Vivek

Posted by Paul Baker [MVP, Windows - SDK] on August 14th, 2007


What would be the advantage of accessing memory as if it were a file?

All the relevant operations of a file can easily be implemented in memory -
seek, read, write. In fact, this may already be done for you. In Delphi, for
example, there is a TMemoryStream class that has the same ancestor as a file
(TFileStream) and can be exposed as an IStream interface.

Paul

"rep_movsd" <rep.movsd@gmail.com> wrote in message
news:1187077081.722132.211820@l70g2000hse.googlegr oups.com...


Posted by John Hensley on August 15th, 2007


Windows already lets you do exactly this using memory mapped files. You can
create a memory mapped file in one process and then open and map the same
file into the address space of any number of other processes. To make the
file virtual specify FILE_ATTRIBUTE_VIRTUAL creating the file in the first
process.

Here's a link to more information about using memory mapped files to share
memory between different processes.

http://msdn2.microsoft.com/en-us/library/aa366878.aspx

--
John Hensley
www.resqware.com


"rep_movsd" wrote:

Posted by Pavel Lebedinsky [MSFT] on August 16th, 2007


"John Hensley" wrote:

FILE_ATTRIBUTE_VIRTUAL means the file has been virtualized
to a per-user location (one of UAC features in Vista). This is not a valid
flag to pass to CreateFile, and it shouldn't be mentioned in CreateFile
docs (it's a doc bug that it is mentioned).

FILE_ATTRIBUTE_TEMPORARY and possibly FILE_FLAG_DELETE_ON_CLOSE
might be more appropriate in this case.

--
This posting is provided "AS IS" with no warranties, and confers no
rights.



Posted by Maxim S. Shatskih on August 16th, 2007


FILE_ATTRIBUTE_VIRTUAL is very poorly documented in the Library anyway.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com

"Pavel Lebedinsky [MSFT]" <pavel@online.microsoft.com> wrote in message
news:esPg7X73HHA.536@TK2MSFTNGP06.phx.gbl...

Posted by kuasha on August 17th, 2007


First read the Windows Driver Kit Documentation as much you can. Write some
samll drivers from scratch. Then collect the book Windows NT File System
Internals. Filesystem driver is a little bit complex. You may consider disk
driver. A sample is available with the WDK.

--
Sincerely,
Maruf Maniruzzaman,
Software Engineer,
KAZ Software Limited,
Dhaka, Bangladesh.
http://www.kaz.com.bd
http://www.kuashaonline.com



"rep_movsd" wrote:

Posted by Don Burn on August 17th, 2007



"kuasha" <kuasha@discussions.microsoft.com> wrote in message
news:29B71C58-66C6-43C7-8EAD-CFA73378B900@microsoft.com...
First the OP asked about handling specific files in a memory mapped manner.
You disk suggestion is a RAMDISK with a copy for every I/O, which is not
what was asked for.

Second, saying filesystem drivers are a "little bit complex" is way
understating things. From a lot of experiences, most people think "I can
write a production file system in 6 man-months" and end up taking 10 times
longer. This is definitely not a project for someone to jump in on.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply



Posted by rep_movsd on August 17th, 2007


Hi

What I really need is to let third party applications see my buffer as
a file. Its kind of a ramdisk, but at a file level.
Even 20 man-months would be OK for me if there is enough documentation
to proceed.

My question is do i need one of those costly IFS kits or something
from MS or just the plain old DDK suffice?


Vivek

Posted by Don Burn on August 17th, 2007


You do not need the IFS kit, get the latest WDK and it contains everything
needed for a file system. Whether you can do it in 20 months is another
question, to be production quality without purchasing an expensive kit from
OSR ($100,000) you are really pushing the evelope.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

"rep_movsd" <rep.movsd@gmail.com> wrote in message
news:1187355043.016512.167460@k79g2000hse.googlegr oups.com...


Posted by John Hensley on August 17th, 2007


"rep_movsd" wrote:
I might be missing the point of what you are trying to do but if you expose
your buffer as a memory mapped file it will allow third party applications
see the buffer as a file that can be opened for reading and writing just like
any other file.

I don't understand why you would need a file system driver to accomplish
this, but then again I may be missing the point of what you are trying to do.

John Hensley
www.resqware.com


Posted by Paul Baker [MVP, Windows - SDK] on August 17th, 2007


Yes. My original question about the intent seems to be answered. It would
seem the OP would like his buffer to be exposed to other processes. However,
I do think the question of intent is still a valid one. What does the OP
wish to achieve beyond what can already be achieved using a memory mapped
file?

Paul

"John Hensley" <resqware@discussions.microsoft.com> wrote in message
news:2ED50976-2F9A-44C0-9A88-ADC5F3F38D28@microsoft.com...


Posted by Don Burn on August 17th, 2007



"Paul Baker [MVP, Windows - SDK]" <paulrichardbaker@community.nospam> wrote
in message news:%23DxUGDO4HHA.1168@TK2MSFTNGP02.phx.gbl...
tell us what the model is, there is likely to be a solution much less
costly than a file system.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply



Posted by Chuck Chopp on August 17th, 2007


Don Burn wrote:

Hmmm... speaking of the IFS being integrated into the latest WDK, I'm having
some difficulty obtaining the WDK download thru my MSDN Subscription
Downloads. I can see where the WDK page mentions that the IFS, updated for
Win2K3 R2 & Vista, is now supposed to be part of the WDK. I can also see
where the WDK page mentions either signing up thru Microsoft Connect, or
using the MSDN Subscriber Downloads to obtain the latest WDK. However, when
I logon to the subscriber downloads page and browse what's available under
the Tools & SDKs, I see an *old* date on the WDK... from back in 2006. I
see no mention of the updated IFS being part of this DVD ISO image, nor do I
see any mention of Win2K3 R2 & Vista associated with it.

I have an IFS kit that arrived last week, and it's even older... dated 2005,
and only covers up thru Win2K3 SP1.

Via the MSDN Subscriber downloads page(s), where is this newer WDK located?


TIA,

Chuck
--
Chuck Chopp

ChuckChopp (at) rtfmcsi (dot) com http://www.rtfmcsi.com

RTFM Consulting Services Inc. 864 801 2795 voice & voicemail
103 Autumn Hill Road 864 801 2774 fax
Greer, SC 29651

Do not send me unsolicited commercial email.

Posted by Don Burn on August 17th, 2007



"Chuck Chopp" <ChuckChopp@rtfmcsi.com> wrote in message
news:Ov2jwsP4HHA.4476@TK2MSFTNGP06.phx.gbl...
Chuck,

I have never downloaded it from MSDN, but you can get it by following
the steps on
http://www.microsoft.com/whdc/DevTools/WDK/WDKpkg.mspx the beta for the
Windows Server 2008 WDK is also up there. If you do get the WDK be sure to
pick up the fixes to the docmentation at
http://www.microsoft.com/whdc/DevTools/WDK/WDKdocs.mspx


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply



Posted by kuasha on August 18th, 2007


I know exactly what you mean. But I do not like to discourage people
directly who wants to do something. You know better than me - FS is not easy
task. I am working on a FS project. But as he stated:

Possibly he is trying to do it for interest. In that case I encourage to
give a try. At least good way to learn - while just working out of couriocity.

--
Sincerely,
Maruf Maniruzzaman,
Software Engineer,
KAZ Software Limited,
Dhaka, Bangladesh.
http://www.kaz.com.bd
http://www.kuashaonline.com



"Don Burn" wrote: