Reserve hard disk with memory in .NET before running application

We have a C # .NET application that communicates with an unmanaged C dll. The C dll uses CreateFileMapping () and MapViewOfFileEx () to share memory with other processes on the same computer.

MapViewOfFileEx () takes the last parameter (lpBaseAddress) and sets it to 0x08000000 in our case. This is fine for all c / C ++ applications as long as you call the initialization function in the dll early enough. However, in C #, a larger application allocates a lot of memory before we get a chance to call the init dll function in the autogenerated static Main () method. (Small C # console apps work fine).

Is there a way to reassign scope 0x08000000 to 0x08400000 when starting a .NET application before auto-allocating for classes and stuff? Then there should be no problem to map the total memory to 0x08000000 at any time.

Limitations: Obvious solutions cannot be applied here.

  • It is not possible to use a dynamically assigned virtual address by calling MapViewOfFile, as this would require significant changes to the C dlls that currently work with absolute pointers in all processes.
  • It is also impossible to agree on a common base address between all processes, since they do not start at the same time.
+3


source to share





All Articles