When using C++ Shared Memory (Memory mapped) DLLs in C++ & C#

Asked 2 years ago, Updated 2 years ago, 107 views

Create DLLs in Project X (C++); Project X defines functions that read and write data using MemoryMapped.

Project Y uses a DLL called X Enter data mainly (C++);

Project Z uses a DLL called X Mainly read data. (C#) Use Marshall

When programs Y and Z are running together in the window, is there a way to check if the value of program Z has been updated by entering the memory because the value is generated in program Y?

I don't understand that it can be implemented using the CallBack function in DLLs, not the method that is always checked using Loop separately.

Please give us many opinions (__)

c++ c# dll

2022-09-22 19:29

1 Answers

It is a method of utilizing the characteristics of dll.

For dll, physical memory is committed only once.

This means that even if the dll is loaded into memory in each process, it is only raised once in physical memory and shared. Of course, they are mapped to virtual process memory.

If you look at the memory that the process is assigned to, there is a place called a shared area. And then the dlls are located there and the processes can be shared.

As for the variable, c++ would have defined it in the form of #pragma data_seg ("section name"), which is to store the data to be shared in that section in the pe file.

You can define and use the callback function in dll.


2022-09-22 19:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.