Re: writeable file mapping

Tech-Archive recommends: Fix windows errors by optimizing your registry



"William DePalo [MVP VC++]" <willd.no.spam@xxxxxxxx> wrote in message
news:%23JTSExedGHA.4276@xxxxxxxxxxxxxxxxxxxxxxx
"Henry Townsend" <henry.townsend@xxxxxxxx> wrote in message
news:vZidnfEUectVXvnZRVn-jg@xxxxxxxxxxxxxx
I'm trying to do something which should be basic but doesn't seem to be
documented. I need to map a file into memory and be able to modify the
mapping while being sure I don't modify the file itself. On Unix this is
done by setting mmap flags = MAP_PRIVATE. On Windows there seems no
documented way to do it. ...I probably won't have write access to the
files and I certainly don't want to risk modifying them even if I do.

This doesn't sound like a need for file-mapping at all, since: (1) you are
not writing to the file using a pointer and (2) you are not expecting other
users' changes to automatically appear (since you want copy-on-write). So,
just do a bulk read from the file into private process memory allocated from
the heap.

Or are you trying to affect the data retrieved by file i/o apis called
elsewhere in your process?


There are at least two possibilities.

The first is that you don't specify a file. If you use
INVALID_HANDLE_VALUE the section will be backed by the paging file. Then
read your file into the mapped section. Of course, there'd be a small
window between its creation and the time when the section has good data.

The second is that you copy the file to another one first.

Regards,
Will



.



Relevant Pages

  • Re: Attempting to port and app to linux but cant find an equivalent system call
    ... An Operating system that permits one process to modify another process' memory ... Linux, like it's Unix forefathers, does not permit such uncontrolled access. ...
    (comp.os.linux.development.apps)
  • Re: Attempting to port and app to linux but cant find an equivalent system call
    ... |>>cannot find anything in linux remotely like the following... ... |>An Operating system that permits one process to modify another process' memory ... Your parent process can use fork/execto launch the program to be ...
    (comp.os.linux.development.apps)
  • Re: change .exe at runtime
    ... That is, if you modify your binary code on the fly, then your ... On Windows 9x the change is system wide, so for instance, if you change the ... to change the wrights back after you are done with a memory zone. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: writeable file mapping
    ... I need to map a file into memory and be able to modify the mapping while being sure I don't modify the file itself. ... Of course I could read in a block at a time and compare blocks but that would mean rewriting the entire library, ...
    (microsoft.public.win32.programmer.kernel)
  • Re: mmap specification - was: ... select specification
    ... >> Linux does this. ... that if you modify the memory at an address ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)