Alias two virtual regions - is it possible? RRS feed

  • General discussion

  • If we have two virtual memory buffers A and B allocated using VirtualAlloc, is there any way to alias them? What I mean by that is that writes to *A will modify the same physical pages than writing to *B. Note that simple pointer assignment A = B does not work in my case - i want them to remain as separate virtual addresses. The following code snippet should clarify my goal:

      int* A = (int*) VirtualAlloc(...);
      int* B = (int*) VirtualAlloc(...);
      MAKE_ALIAS(A, B, size); // assume both buffers have the same size 'size'
      *A = 3;
      assert(*B =3); 
    I posted this question under driver development but user-level solutions are perfectly fine for me!

    Thursday, December 19, 2013 5:33 PM

All replies

  • a bit of a contortion to do this. what bigger problem are you trying to solve?

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

    Thursday, December 19, 2013 8:29 PM