I have C# and C++ programs and I am using memory mapping to interact between them.
I use WinAPi from both programs. Now I cannot write from C# program to the memory file, although I can read what has been written from c++ program.
I STRONGLY suspect that the problem is that I simply give a wrong number as an argument for read/write permissions in C# program.
In C++ it is simple, the API is used straight, e.g.
FILE_MAP_ALL_ACCESS, // read/write permission
In C# I obviously cannot use FILE_MAP_ALL_ACCESS or PAGE_READWRITE
so I use int, e.g.
internal static extern IntPtr MapViewOfFile(IntPtr handle, uint r_w_access, uint offset_h, uint offset_low, uint size);
and I simply send number 4 or 2 as r_w_access. I don't know why these spesific numbers (found somewhere on the Internet).
So my question is - there should be a more reliable way to pass access parameter from C# to WinAPI functions. What is it?