Name from Section handle. Vista

Hi gurus.

I’m having a problem with name retrieval of section object.

In User Application I created a file mapping, then send handle of this mapping to a driver.
In driver I’m trying to get name of object via handle, but I’m getting STATUS_ACCESS_DENIED.

Here is a code piece:
// hMap - handle from user application
PVOID pObj = NULL;
Status = ObReferenceObjectByHandle(hMap,STANDARD_RIGHTS_REQUIRED ,NULL,KernelMode,&pObj,NULL);
if(NT_SUCCESS(Status))
{
ULONG ulRetSize = 0;
POBJECT_NAME_INFORMATION pObjNameInfo = (POBJECT_NAME_INFORMATION) ExAllocatePoolWithTag(NonPagedPool,0x1000,POOL_TAG);
memset(pObjNameInfo,0,0x1000);
Status = ObQueryNameString(hMap,pObjNameInfo,0x1000,&ulRetSize);
if(NT_SUCCESS(Status))
{

LOGF((“ObQueryNameString %wZ\n”,&pObjNameInfo->Name));
}
else
{
LOGF((“ObQueryNameString FAILED 0x%08x\n”,Status));
}
ExFreePoolWithTag(pObjNameInfo,WLNR_POOL_TAG);
ObDereferenceObject(pObj);

What could be a reason of such error?
Basically I have to use this section to share some data.
And I’m going to get full path to object section for future use in ZwOpenSection.

Can anybody help with this issue?

Thanx in advance

You have to pass pObj instead of hMap as first argument of
ObQueryNameString.

On Feb 1, 2008 10:01 AM, wrote:

> Hi gurus.
>
> I’m having a problem with name retrieval of section object.
>
> In User Application I created a file mapping, then send handle of this
> mapping to a driver.
> In driver I’m trying to get name of object via handle, but I’m getting
> STATUS_ACCESS_DENIED.
>
> Here is a code piece:
> // hMap - handle from user application
> PVOID pObj = NULL;
> Status = ObReferenceObjectByHandle(hMap,STANDARD_RIGHTS_REQUIRED
> ,NULL,KernelMode,&pObj,NULL);
> if(NT_SUCCESS(Status))
> {
> ULONG ulRetSize = 0;
> POBJECT_NAME_INFORMATION
> pObjNameInfo = (POBJECT_NAME_INFORMATION)
>
> ExAllocatePoolWithTag(NonPagedPool,0x1000,POOL_TAG);
>
> memset(pObjNameInfo,0,0x1000);
> Status =
> ObQueryNameString(hMap,pObjNameInfo,0x1000,&ulRetSize);
>
> if(NT_SUCCESS(Status))
> {
>
>
> LOGF((“ObQueryNameString %wZ\n”,&pObjNameInfo->Name));
> }
> else
> {
>
> LOGF((“ObQueryNameString FAILED 0x%08x\n”,Status));
> }
>
> ExFreePoolWithTag(pObjNameInfo,WLNR_POOL_TAG);
> ObDereferenceObject(pObj);
>
>
> What could be a reason of such error?
> Basically I have to use this section to share some data.
> And I’m going to get full path to object section for future use in
> ZwOpenSection.
>
> Can anybody help with this issue?
>
> Thanx in advance
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

Thanx a lot.

Really stupid error from my side.
Thanks again.

xxxxx@ukr.net wrote:

Hi gurus.

I’m having a problem with name retrieval of section object.

In User Application I created a file mapping, then send handle of this mapping to a driver.
In driver I’m trying to get name of object via handle, but I’m getting STATUS_ACCESS_DENIED.

What could be a reason of such error?
Basically I have to use this section to share some data.
And I’m going to get full path to object section for future use in ZwOpenSection.

If you already have a handle, why do you need the name?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.