Help on ZwMapViewOfSection.....

Greetings,
I am trying to open and map a Memory mapped file opened by client application in my driver…

pSectionHandle = NULL;

status = ZwOpenSection(
pSectionHandle,
SECTION_MAP_WRITE | SECTION_MAP_READ,
&FileObjectAttrbs
);

if(status != STATUS_SUCCESS)
{
DbgPrint(“ZwOpenSection Failed %x”,status);
break;
}

pVirtualAddress = NULL;

status = ZwMapViewOfSection(
pSectionHandle,
( HANDLE )-1, // Current Process
&VirtualAddress,
0,
PAGE_SIZE,
NULL,
PAGE_SIZE,
0L,
ViewShare,
PAGE_READWRITE
);

if(status != STATUS_SUCCESS)
{
DbgPrint(“ZwMapViewOfSection Failed %x”,status);
break;
}
But when this function is called by the driver it returns STATUS_INVALID_PARAMETER_8
which is defined in ntstatus.h as —

// An invalid parameter was passed to a service or function as the eightth argument.
//
#define STATUS_INVALID_PARAMETER_8 ((NTSTATUS)0xC00000F6L)

my work is based upon mapmem sample provided with nt 4 ddk.
can any one provide me with the help that which value should i user to work it correctly ???..

any help is appreciated…
—Subodh

For start, shouldn’t you have ‘&’ in front of pSectionHandle, as follows:

status = ZwOpenSection(
&pSectionHandle,
SECTION_MAP_WRITE | SECTION_MAP_READ,
&FileObjectAttrbs
);

Also, when using ZwMapViewOfSection, you are not passing in address of
view size variable ( declared as IN OUT PULONG ViewSize )

status = ZwMapViewOfSection(
pSectionHandle,
( HANDLE )-1, // Current Process
&VirtualAddress,
0,
PAGE_SIZE,
NULL,
–>>>> PAGE_SIZE,
0L,
ViewShare,
PAGE_READWRITE
);

ned