Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4065720
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:01:10+00:00 2026-05-20T16:01:10+00:00

I use VirtualAlloc(Ex) to allocate and commit a large range of pages. Later in

  • 0

I use VirtualAlloc(Ex) to allocate and commit a large range of pages.

Later in the execution I wish to “fork” that memory, launch a new process that can read it in it’s current state, while the parent process treats it as copy-on-write memory.

Can this be done with VirtualAlloc(Ex) and VirtualProtect(Ex)?

This is trivial on posix systems thanks to fork(). Can I emulate just this part of fork efficiently on windows?

Thanks,
-Dan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:01:11+00:00Added an answer on May 20, 2026 at 4:01 pm

    I don’t believe any of these quite answer the question posed by the original poster. Perhaps I might venture the following example. Suppose one has some data in “bufferA” and one copies it to “bufferB” and then modifies both buffers. Now one examines both buffers, and decides to copy either “bufferA” or “bufferB” to “bufferC” and make more modifications to “bufferC”, and so forth.

    Assuming that the buffers are large and the modifications are small, the question is whether it would be an optimization to use the copy-on-write capability of the MMU on the host machine, and whether there is an API to allow this.

    The use of memory mapped files doesn’t quite work because, once one uses PAGE_WRITECOPY, there seems to be no way to say “now copy the virtual pages containing the changes”. For example, if “bufferA” and “bufferB” both were mappings of the same file, and at the time of the mapping one of them was marked “WRITECOPY”, there seems to be no way to map those modifications to “bufferC”. One can of course just copy the bits, but the question is whether there is a potential optimization.

    There is a function called VirtualCopy(), but that seems to be Windows CE specific, and works with physical addresses. The question here is whether there is something like “VirtualCopy”, but taking a virtual address as the source.

    Note that while “fork()” (on systems which have it) does this, one “fork’s” the whole process, not just the buffer. There was a related discussion regarding “copy-on-write memcpy” here ( Can I do a copy-on-write memcpy in Linux? ).

    So the API being sought might look something like this:
    void * VirualCopyVirtualAddressSpace( void* src, size_t length);

    So far, I have seen no API on any system which would allow the buffers to be copied either within a process or between existing processes. While I’m not an expert, I would have thought that copying a properly aligned segment of virtual memory via the copy-on-write mechanism would have be reasonably simple, at least within a single address space.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Memory that i'm trying to allocate is not huge or any thing. i
I need to allocate large regions of memory (megabytes) with large alignments (also potentially
use Control::CLI; $cli = new Control::CLI('SSH'); $cli->connect(Host=>'10.10.10.10',Username=>'user',Password=>'pwd'); $cli->waitfor('>'); $cli->print('Show XXXXXXXXXXXXXXXXXXXX| grep Active'); @f=$cli->waitfor('>'); print
use WWW::Mechanize; my $mech = WWW::Mechanize->new; $mech->get( $url ); say $mech->text; How could I
I use the following types to create a new function at runtime: typedef int
Use scenario is pretty simple: I have a desktop only application that could be
use case example I have a servlet that is receiving login requests. If a
use Thread; use warnings; use Tk; my $x = 10; my $mw = new
I use an O/R mapper, that can reload objects from the DB in a
I want to reserve space for my codecave in application. I use VirtualAlloc function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.