As stated in ntifs.h, the fields of SECURITY_SUBJECT_CONTEXT structure
should be considered opaque. So, the following code is somewhat cleaner:
NTSTATUS
xxxOpenCreatorToken(
IN PIO_SECURITY_CONTEXT SecurityContextPtr,
OUT PACCESS_TOKEN *TokenPtr,
OUT HANDLE *TokenHandlePtr)
{
NTSTATUS Status;
// Extract token pointer.
*TokenPtr =
SeQuerySubjectContextToken(&SecurityContextPtr->AccessState->SubjectSecurity
Context);
if (*TokenPtr == NULL)
{
// We must never get here, but still.
*TokenHandlePtr = NULL;
return STATUS_UNSUCCESSFUL;
}
// Create the handle.
Status = ObOpenObjectByPointer(*TokenPtr, OBJ_CASE_INSENSITIVE, NULL,
TOKEN_QUERY, NULL, KernelMode, TokenHandlePtr);
// Exit routine.
return Status;
}
----- Original Message -----
From: “Maxim S. Shatskih”
To: “File Systems Developers”
Sent: Friday, June 06, 2003 9:02 AM
Subject: [ntfsd] Re: Classifying IRP_MJ_CREATE on user name (PSID)
> // Opens a token handle for specified security context
> static NTSTATUS xxxOpenCreatorToken(PIO_SECURITY_CONTEXT
> SecurityContext,
> OUT PACCESS_TOKEN* Token,
> OUT HANDLE* hToken)
> {
> // “Conditional expression is constant”
> #pragma warning(disable:4127)
> PAGED_CODE();
> #pragma warning(default:4127)
> // Extract a token pointer from the security context
> *Token =
> SecurityContext->AccessState->SubjectSecurityContext.ClientToken;
> if( *Token == NULL )
> *Token =
> SecurityContext->AccessState->SubjectSecurityContext.PrimaryToken;
> // Now create the handle
> return ObOpenObjectByPointer(*Token, OBJ_CASE_INSENSITIVE, NULL,
> TOKEN_QUERY,
> NULL,
> KernelMode, hToken);
> }
>
> Then use ZwQueryInformationToken with the handle.
>
> Max
>
>
> ----- Original Message -----
> From:
> To: “File Systems Developers”
> Sent: Friday, June 06, 2003 9:17 AM
> Subject: [ntfsd] Re: Classifying IRP_MJ_CREATE on user name (PSID)
>
>
> > Max,
> > token pointer? From where does he get it?
> >
> > -Srin.
> >
> > > -----Original Message-----
> > > From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
> > > Sent: Thursday, June 05, 2003 4:52 PM
> > > To: File Systems Developers
> > > Subject: [ntfsd] Re: Classifying IRP_MJ_CREATE on user name (PSID)
> > >
> > > > I’ve thought about using
> > > pCurrIrpStack->Parameters.Create.SecurityContext,
> > > > taking SecurityDescriptor and converting it to PSID, but
> > > SecurityDescriptor
> > > > is NULL at this time.
> > >
> > > Call ObOpenObjectByPointer on the token pointer from there, then
> > > ZwQueryInformationToken.
> > >
> > > Max
> > >
> > >
> > >
> > > —
> > > You are currently subscribed to ntfsd as: xxxxx@nai.com
> > > To unsubscribe send a blank email to
> xxxxx@lists.osr.com
> >
> >
> > —
> > You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@vba.com.by
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>