Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Memory Mapped Files - CreateFileMapping

296 views
Skip to first unread message

A Parmar

unread,
Nov 24, 2004, 11:28:56 AM11/24/04
to
Hi there,

I have the following piece of code that is used to share data between
terminal server sessions, it simply sets up a memory map using the swap
file, all standard stuff. It works just fine when used on when the user is
logged on as an Adminstrator, however if the user is NOT logged on as an
Administrator, for some reason the CreateFileMapping function fails with the
error message 'Access is denied' (retrieved using GetLastError). Furthermore
if the Adminisrator first logs on and creates the filemapping then
subsequent non-adminstrative users can open the file map.

cSPMemoryMap := 'Global\SP_MEMORYMAP';

InitializeSecurityDescriptor(@SD, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDACL(@SD, True, nil, False);
SA.bInheritHandle := False;
SA.lpSecurityDescriptor := @SD;
SA.nLength := SizeOf(SA);

hSPMemoryMap := OpenFileMapping(FILE_MAP_WRITE, False, cSPMemoryMap);
if hSPMemoryMap = 0 then
hSPMemoryMap := CreateFileMapping($FFFFFFFF, @SA, PAGE_READWRITE, 0, 4095,
cSPMemoryMap);
SPMemoryMapData := MapViewOfFile(hSPMemoryMap, FILE_MAP_WRITE, 0, 0, 0);


I would be very grateful for any insight into this problem, or any
alternative approaches to sharing data between sessions under terminal
server.

Thank you


Jahanmir

unread,
Nov 24, 2004, 12:45:05 PM11/24/04
to
Hi,
seems an OS XP? specific permition problem?
when possible, may be helps if you try to setup new users or a new group
with all needed permitions.


"A Parmar" <An...@StaffPlan.co.uk> schrieb im Newsbeitrag
news:41a4...@newsgroups.borland.com...

Martin Harvey (Demon Account)

unread,
Nov 24, 2004, 3:10:25 PM11/24/04
to
On Wed, 24 Nov 2004 16:28:56 -0000, "A Parmar" <An...@StaffPlan.co.uk>
wrote:

>cSPMemoryMap := 'Global\SP_MEMORYMAP';
>
>InitializeSecurityDescriptor(@SD, SECURITY_DESCRIPTOR_REVISION);
>SetSecurityDescriptorDACL(@SD, True, nil, False);
>SA.bInheritHandle := False;
>SA.lpSecurityDescriptor := @SD;
>SA.nLength := SizeOf(SA);

One of two issues:

1. Perhaps non-admins don't have enough privileges for the ACL.
2. The memory map name seems to indicate it might be in the global
namespace?

I'd suggest playing with it, and seeing what happens.

MH.

A Parmar

unread,
Nov 25, 2004, 4:52:03 AM11/25/04
to
I am using Windows 2003 Server and am creating a mapping using the swap
file, surely all users have permission to this ? Have also given the non
admin user permissions for the C drive, but still get the same error.

"Jahanmir" <BJahan...@SageKHK.de> wrote in message
news:41a4c8a5$1...@newsgroups.borland.com...

Deepak Shenoy (TeamB)

unread,
Nov 26, 2004, 3:14:25 AM11/26/04
to
A Parmar wrote:

> cSPMemoryMap := 'Global\SP_MEMORYMAP';
>
> InitializeSecurityDescriptor(@SD, SECURITY_DESCRIPTOR_REVISION);
> SetSecurityDescriptorDACL(@SD, True, nil, False);
> SA.bInheritHandle := False;
> SA.lpSecurityDescriptor := @SD;
> SA.nLength := SizeOf(SA);

Set bInheritHandle := True; That's the only difference I have in code
that works with different desktops (IIS user vs. logged on user)

--
Deepak Shenoy (TeamB)
Agni Software
http://www.agnisoft.com

0 new messages