What do I need to look into?
section objects (and/or memory mapped files)
-r
You can go one of three routes.
Memory mapped files.
Marshal data using WM_COPYDATA
Use a shared DLL
In addition to those three, there are also a number of API's that will allocate shared memory, VirtualAllocEx/VirtualFreeEx being the most useful but they are only available on NT based systems. If you need 9x support (though I can't imagine why) you can use the ordinal calls available in comctl32.dll (ordinals 71,72,73 and 74 - Alloc, ReAlloc, Free and GetSize respectively)
Edgar
:lol What they said I was too slow :bg
I did find links though :P
Memory mapped Files: http://support.microsoft.com/kb/188535
WM_COPYDATA http://msdn.microsoft.com/en-us/library/ms649011(VS.85).aspx
See also the WM_COPYDATA thread (http://www.masm32.com/board/index.php?topic=13215.msg102618#msg102618) - it's really simple.
see also DDE,atom
:bg
You can tell the men from the boys by the paper they use. :bdg
use a "Memory Mapped File", the way REAL MEN[TM} do. :P
Just to clarify, a "memory mapped file" is not necessarily a real actual disk file; shared memory just uses the same mechanisms as mapping files (section objects), so a named section object that is backed by the pagefile is, essentially, a block of shared memory.
-r
Quote from: redskull on September 24, 2010, 12:48:57 PM
Just to clarify, a "memory mapped file" is not necessarily a real actual disk file; shared memory just uses the same mechanisms as mapping files (section objects), so a named section object that is backed by the pagefile is, essentially, a block of shared memory.
-r
Red,
Can you give an example of a memory mapped file that does not use a disk? It is one of the reasons why I'd prefer WM_COPYDATA (not being a Real Man in Hutch' opinion :green2).
Call CreateFileMapping() with hFile as INVALID_HANDLE_VALUE on a system with no pagefile. :bg
Quote from: redskull on September 24, 2010, 01:45:00 PM
Call CreateFileMapping() with hFile as INVALID_HANDLE_VALUE on a system with no pagefile. :bg
Sounds exciting but where do a find a system with no pagefile?
:wink
My point was that you don't need create the file yourself; tell someone that they need to use a "memory-mapped file", and they often get the misconception that they have to create "MyTempFile.tmp" someone on the hard drive, map it into memory, and use that. Perhaps I should have said it doesn't use the disk any more than something like GlobalAlloc() (or WM_COPYDATA) does. :bg
-r
Quote from: redskull on September 24, 2010, 02:03:19 PM
Perhaps I should have said it doesn't use the disk any more than something like GlobalAlloc() (or WM_COPYDATA) does. :bg
Would GlobalAlloc use the disk (i.e. the pagefile) if enough physical RAM was available? I am not trying to be difficult, just curious :bg
It depends on what you consider "using". Technically, any commited memory is backed by a file, be it a "real" disk file or the page file. When the page of memory is commited (which, in the case of GlobalAlloc(), the heap manager would do), a space in the pagefile is reserved for it, but it would only really 'use' it if it gets paged out. So while it will potentially never be written to, the space in the file would still be there for it, and still count against you in the commit charge (which would be the same thing that happens in a pagefile backed memory mapped file).
Also, just to point out, paging has nothing really to do with physical RAM availability; a process is given a limit of space it can use, and if it exceeds this, it will start taking paging hits, regardless if there is usable RAM or not. Of course, if there's lots of free RAM, windows will up this limit for processess that are paging alot, so they are indirectly related.
-r
Memory mapping using the page file is documented at MSDN Creating Named Shared Memory (http://msdn.microsoft.com/en-us/library/aa366551%28v=VS.85%29.aspx), it includes a code example to use it. Be sure to check the UAC limitations at the bottom of the page.