Re: A buffer mapped to a file?

You could try a named pipe, if the program really just calls CreateFile and reads or write to the resulting handle, but as soon as a program tries to do something like query file size, set file pointer, or soforth, that will break. So that really tends to be program specific as to whether it will work.

The most compatible solution is to create a temp file on disk and delete it when done, I would imagine.

Ken Johnson (Skywing)
Windows SDK MVP
"rep_movsd" <rep.movsd@xxxxxxxxx> wrote in message news:1175105745.453461.126290@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Its quite simple to map a file to memory using CreateFileMapping()
and MapViewOfFile().

Now I need the converse....

Basically I have a buffer of data and need to feed it into an API
which expects a filename.

I can think of 2 ways of the top of my head, but I'm not sure about
the details.

1) Launch a process with redirected stdin / stdout , make the API read
from "CON:" or "\.\\Device\Console" or whatever and the parent process
will feed the data into the <stdin> of the launched process.

2) Make some type of FIFO or pipe... , but do such objects have names
that are within the filesystem namespace and will the ReadFile() API
cope with them? As far as I can recall in linux it was quite simple to
make a fifo right on the filesystem and feed arbitrary data via it
into any program that needed it as a file.

Any way to do this under Win32?



Relevant Pages

  • Re: Flush SMB Cache on Windows Vista?
    ... when client tries to open that file on server machine (via CreateFile API) - the same pathname is used - which is incorrect of course because you need UNC name here. ... the cache information has not been updated.) ...
  • Re: How do I link to C Library functions in windows?
    ... Any Win32 API that takes or returns a string will have an A and a W ... What do you mean by "setup the stack"? ... If CreateFile returns ... push eax; which I should save to the stack ...
  • Re: ReadFile vs fread
    ... assured that the windows API would not hinder performance if I switch to using CreateFile ReadFile, ... So, I believe that if you switch to CreateFile, ReadFile, etc. you will be fine. ... I would suggest you to read this very interesting optimization series on Raymond Chen's blog (when he optimizes his code, he directly uses Win32 API functions like CreateFile, file-mapping, etc.) ... Loading the dictionary, part 2: ...
  • problem with opening device using CreateFile
    ... I have been wading through using SetupDi... ... API to get a device path to use ... The documentation on CreateFile indicates that the SecurityAttributes are ...
  • Re: Writing to an existing Named Pipe
    ... IIRC .NET do not have support for named piped, you will have to P/Invoke ... > Does anybody know how I can write to the named pipe from a .NET program. ... I have tried API calls, ...