Click to See Complete Forum and Search --> : Access to filesystem in memory


gepht
July 18th, 2002, 09:21 PM
I've come across an interesting problem that I'm trying to solve, and maybe someone has the info I need.

I've read that on Linux memory can be mounted like a local filesystem and accessed as such. I'm not sure to what extent this is possible, but I'm trying to do the same thing on Windows. For example, I load a file into memory from the disk, and I want some program on my machine to be able to access that file in memory. Is there some way to do this? Is there some way to setup a connection between the filesystem on disk and the file in memory? A sort of virtual filesystem? Perhaps there is some way to do it with memory-mapped files, but MSDN says those are only useful for writing memory out to disk and loading it back in, not accessing the memory externally.

Any information is appreciated.

Kyle

cup
July 19th, 2002, 12:42 AM
Are you talking about mmap? If so, the MS equivalent is CreateFileMapping. Have a look at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fileref_79wn.asp.

There is a description of MapViewOfFile somewhere in there. This can also be used for shared memory but it isn't the same as Unix. You have to lock the handle to access the memory and unlock it before any other process can see your changes.

gepht
July 19th, 2002, 08:40 AM
Not exactly what I was looking for. At least, I think it's not. I've read over the memory-mapped file, but it doesn't seem to give me what I want. What I want is for another program, over which I have no control, to be able to see the memory like a local filesystem. More specifically, I want cl.exe (VC++ compiler) to be able to see my filesystem in memory. So I load a file into memory, keep it in memory, and somehow cl.exe can interact with that file. The only way I can see of doing this is if somehow you can mount the memory as a virtual local filesystem. From all of the options that I see with the compiler, it doesn't take standard input, so there must be a way to make the compiler see a file that isn't actually on disk, but is maybe contained in a page file or memory. I've seen it done with some other programs that never write the file to disk and hold it in memory. There must be a way to do this.

Kyle