Article View: borland.public.cppbuilder.nativeapi
Article #16422Re: Shared memory question
From: Remy Lebeau (TeamB)
Date: Thu, 15 May 2003 17:04
Date: Thu, 15 May 2003 17:04
41 lines
3296 bytes
3296 bytes
"Vladimir Afanasyev" <avv@systema.kiev.ua> wrote in message news:3ec37cee$1@newsgroups.borland.com... > It can be so if name of the file-mapping object is > known for all processes that want to use it. But process > can create file mapping with name that is defines via > random generator. In this case another process can't > connect to file mapping via OpenFileMapping because > name is unknown. Well, of course. But the whole point of sharing memory that is the other processes know about it, thus they will know the name of the mapping and can use Create/OpenFileMapping to get at it. However, that is not the issue being discussed. The original question was how to restrict access to read-only for other processes who do want to use the shared memory. In that regard, the answer is as stated earlier - the process who initially creates the memory can't control that aspect of the memory, as each process obtaining a pointer to the memory can specify their own individual settings for how they want to access the memory. Each process is only responsible for its own local pointers to the memory, to to other process's pointers. > If to return to question: > >> Is there a way to share the memory, but to make > >> it read-only to other processes? > The answer is yes and DuplicateHandle just for it. That can only work if you are actually passing the duplicated handle to the other process directly, which I get the feeling is not the actual case in MWP's situation, but that the other processes are accessing his mapped memory directly. DuplicateHandle() does not copy the new handle to other processes, and certainly is not doing so in your examples. To do that, the other process would have to not be allowed to know the memory's mapped name (aka, make it random), and the other process would have to know the process handle of the memory's initial owner as well as the numeric value of the original read-only handle inside that process. That last step is not one you have shown yet in your examples, as the other process has to make the call to DuplicateHandle() passing it the original process's information. Gambit
Technical Details
Message-ID:
<3ec3c804$3@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!out.nntp.be!propagator2-sterling!in.nntp.be!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!uunet!sac.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3ec201ad$1@newsgroups.borland.com> <3ec2709a@newsgroups.borland.com> <3ec37cee$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,e0ac8188bda6f9e X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-05-15 10:05:44 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3ec201ad$1@newsgroups.borland.com> <3ec2709a@newsgroups.borland.com> <3ec37cee$1@newsgroups.borland.com> Subject: Re: Shared memory question Date: Thu, 15 May 2003 10:04:03 -0700 Lines: 43 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 207.175.226.26 Message-ID: <3ec3c804$3@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1053018116 207.175.226.26 (15 May 2003 10:01:56 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!out.nntp.be!propagator2-sterling!in.nntp.be!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!uunet!sac.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail