21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

RestrictedSidCount<br />

Number of elements in the list SidsToRestrict. May be specified as 0 if there are<br />

no restricted SIDs to be added.<br />

SidsToRestrict<br />

List of SIDs to restrict. If the existing token is a restricted token that already has<br />

restricted SIDs, the resulting token will have a list of restricted SIDs that is the<br />

intersection of the existing token’s list and this list. May be specified as NULL if no<br />

restricted SIDs are to be added to the new token.<br />

NewTokenHandle<br />

Pointer to a HANDLE that will receive the handle to the newly created token.<br />

The function OpenProcessToken( ) will obtain a handle to the process’s primary<br />

token, while OpenThreadToken( ) will obtain a handle to the calling thread’s impersonation<br />

token. Both functions have a similar signature, though their arguments are<br />

treated slightly differently:<br />

BOOL OpenProcessToken(HANDLE hProcess, DWORD dwDesiredAccess, PHANDLE phToken);<br />

BOOL OpenThreadToken(HANDLE hThread, DWORD dwDesiredAccess, BOOL bOpenAsSelf,<br />

PHANDLE phToken);<br />

This function has the following arguments:<br />

hProcess<br />

Handle to the current process, which is normally obtained via a call to<br />

GetCurrentProcess( ).<br />

hThread<br />

Handle to the current thread, which is normally obtained via a call to<br />

GetCurrentThread( ).<br />

dwDesiredAccess<br />

Bit mask of the types of access desired for the returned token handle. For creating<br />

restricted tokens, this must always include TOKEN_DUPLICATE. If the restricted<br />

token being created will be used as a primary token for a new process, you must<br />

include TOKEN_ASSIGN_PRIMARY; otherwise, if the restricted token that will be created<br />

will be used as an impersonation token for the thread, you must include<br />

TOKEN_IMPERSONATE.<br />

bOpenAsSelf<br />

Boolean flag that determines how the access check for retrieving the thread’s<br />

token is performed. If specified as FALSE, the access check uses the calling<br />

thread’s permissions. If specified as TRUE, the access check uses the calling process’s<br />

permissions.<br />

phToken<br />

Pointer to a HANDLE that will receive the handle to the process’s primary token or<br />

the thread’s impersonation token, depending on whether you’re calling<br />

OpenProcessToken( ) or OpenThreadToken( ).<br />

10 | Chapter 1: Safe Initialization<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!