Go to the source code of this file.
◆ ImpersonatePrinterClient()
- See also
- RevertToPrinterSelf
Definition at line 14 of file context.c.
31 ERR(
"GetTokenInformation failed with error %lu!\n", dwErrorCode);
42 ERR(
"SetThreadToken failed with error %lu!\n", dwErrorCode);
#define ERROR_INVALID_HANDLE
DWORD WINAPI GetLastError(VOID)
BOOL WINAPI SetThreadToken(IN PHANDLE ThreadHandle OPTIONAL, IN HANDLE TokenHandle)
static const WCHAR Cleanup[]
enum _TOKEN_TYPE TOKEN_TYPE
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_ BOOLEAN _In_ TOKEN_TYPE TokenType
◆ RevertToPrinterSelf()
RevertToPrinterSelf reverts the security context from the current user's context back to the process context. As spoolss.dll is used by spoolsv.exe, this is usually the SYSTEM security context.
Unlike the traditional ImpersonateClient and then RevertToSelf approach, we do it the other way round here, because spoolss.dll is delay-loaded by spoolsv.exe in the current user's context. Use RevertToPrinterSelf then to return to the SYSTEM context for specific tasks.
Definition at line 64 of file context.c.
80 ERR(
"SetThreadToken failed with error %lu!\n", dwErrorCode);
87 ERR(
"OpenProcessToken failed with error %lu!\n", dwErrorCode);
93 hReturnValue = hToken;
DWORD WINAPI GetLastError(VOID)
BOOL WINAPI SetThreadToken(IN PHANDLE ThreadHandle OPTIONAL, IN HANDLE TokenHandle)
#define TOKEN_IMPERSONATE
HANDLE WINAPI GetCurrentThread(VOID)
#define GetCurrentProcess()
static const WCHAR Cleanup[]
BOOL WINAPI OpenThreadToken(HANDLE ThreadHandle, DWORD DesiredAccess, BOOL OpenAsSelf, HANDLE *TokenHandle)
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Referenced by _CreateNonspooledPort(), _HandleAddPort(), _HandleConfigureLPTPortCommandOK(), _HandleDeletePort(), and _HandleSetDefaultCommConfig().