OpenFileMapping in IIS4.0

Hai,

I am new to this FileMapping Conepets.Please let me
help to solve this problem.This is very Urgent

I written one service and used the CreateFileMapping.

From CGI (C) application i try to use OpenFileMapping
which running in IIS4.0

But it is giving ERROR_ACCESS_DENIED error.

I know b’coz of securityattribute only it is giving
problem.But i don’t know how to set SecurityDescriptor
to this.

//Service CallBack function

DWORD ServiceThread(LPWORD param)
{
HANDLE fileHandle;

char *append;

HANDLE mapFileHandle;

char *timeline;

struct _timeb startTime;

SECURITY_ATTRIBUTES sa;

sa.nLength = sizeof(SECURITY_ATTRIBUTES);

sa.bInheritHandle = TRUE;

sa.lpSecurityDescriptor = 0;

fileHandle =
CreateFile(“D:\FileShare.txt”,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,&sa,OPEN_EXISTING,FILE_FLAG_WRITE_THROUGH,0);

if(fileHandle == INVALID_HANDLE_VALUE)
{
printf(“\nError”);
}

mapFileHandle =
CreateFileMapping(fileHandle,&sa,PAGE_READWRITE,0,sizeof(char)
* 20000,“FILESHARE”);

if(mapFileHandle <=0)
{
printf(“\nError1”);
}

append = (char
*)MapViewOfFile(mapFileHandle,FILE_MAP_ALL_ACCESS,0,0,0);

_ftime(&startTime);

timeline = ctime(&(startTime.time));

strcat(append,timeline);

if(FlushViewOfFile(append,sizeof(append)) < 0)
{
printf(“\nError”);
}

Sleep(60000);
}

//CGI Application running in IIS

HANDLE mapFileHandle;

struct _timeb startTime;

char *append;

char *timeline;

_ftime(&startTime);

mapFileHandle =
OpenFileMapping(FILE_MAP_ALL_ACCESS,TRUE,“FILESHARE”);

if(mapFileHandle <=0)
{

printf(“%d”,GetLastError());
printf(“\nError1”);
}

append = (char
*)MapViewOfFile(mapFileHandle,FILE_MAP_ALL_ACCESS,0,0,0);

timeline = ctime(&(startTime.time));

strcat(append,timeline);

printf(“%s”,append);

if(FlushViewOfFile(append,sizeof(append)) < 0)
{
printf(“\nError”);
}

cgimain(append);

if(!UnmapViewOfFile(append))
{
printf(“\nError”);
}

Please help me.This is very Urgent


Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

Hai,

This is Some very Urgent.Can any on e help me to solve this problem

I don’t necessarily have the answer but you may have to create proper
security descriptor to put into SECURITY_ATTRIBUTES.
Check doco on InitializeSecurityDescriptor() and SetSecurityDescriptorDacl(),
note particularly the comments on “difference between an empty and a nonexistent
discretionary ACL”.

steps are:

  1. LocalAlloc() memory for SECURITY_DESCRIPTOR, ie of SECURITY_DESCRIPTOR_MIN_LENGTH size.
  2. InitializeSecurityDescriptor()
  3. SetSecurityDescriptorDacl()

ned

Udhayakumar wrote:

Hai,

This is Some very Urgent.Can any on e help me to solve this problem


You are currently subscribed to ntdev as: xxxxx@colorbus.com.au
To unsubscribe send a blank email to %%email.unsub%%