mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[SHELL32][SDK] Implement SHOpenEffectiveToken and SHGetUserSessionId (#5713)
- Implement SHOpenEffectiveToken and SHGetUserSessionId functions. - Add them to <undocshell.h>.
This commit is contained in:
parent
4bdfee8e8b
commit
4407e0aefa
3 changed files with 56 additions and 22 deletions
|
@ -1099,17 +1099,6 @@ SHSetUserPicturePathW(LPCWSTR lpPath, int csidl, LPVOID lpUnknown)
|
|||
return E_FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unimplemented
|
||||
*/
|
||||
EXTERN_C BOOL
|
||||
WINAPI
|
||||
SHOpenEffectiveToken(LPVOID Token)
|
||||
{
|
||||
FIXME("SHOpenEffectiveToken() stub\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unimplemented
|
||||
*/
|
||||
|
@ -1178,17 +1167,6 @@ SHGetProcessDword(DWORD dwUnknown1, DWORD dwUnknown2)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unimplemented
|
||||
*/
|
||||
EXTERN_C LPVOID
|
||||
WINAPI
|
||||
SHGetUserSessionId(HANDLE hHandle)
|
||||
{
|
||||
FIXME("SHGetUserSessionId() stub\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EXTERN_C
|
||||
DWORD WINAPI CheckStagingArea(VOID)
|
||||
{
|
||||
|
|
|
@ -9,6 +9,59 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
||||
|
||||
static BOOL OpenEffectiveToken(DWORD DesiredAccess, HANDLE *phToken)
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
if (phToken == NULL)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*phToken = NULL;
|
||||
|
||||
ret = OpenThreadToken(GetCurrentThread(), DesiredAccess, FALSE, phToken);
|
||||
if (!ret && GetLastError() == ERROR_NO_TOKEN)
|
||||
ret = OpenProcessToken(GetCurrentProcess(), DesiredAccess, phToken);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* SHOpenEffectiveToken (SHELL32.235)
|
||||
*/
|
||||
EXTERN_C BOOL WINAPI SHOpenEffectiveToken(_Out_ LPHANDLE phToken)
|
||||
{
|
||||
TRACE("%p\n", phToken);
|
||||
return OpenEffectiveToken(TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, phToken);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* SHGetUserSessionId (SHELL32.248)
|
||||
*/
|
||||
EXTERN_C DWORD WINAPI SHGetUserSessionId(_In_opt_ HANDLE hToken)
|
||||
{
|
||||
DWORD dwSessionId, dwLength;
|
||||
BOOL bOpenToken = FALSE;
|
||||
|
||||
TRACE("%p\n", hToken);
|
||||
|
||||
if (!hToken)
|
||||
bOpenToken = SHOpenEffectiveToken(&hToken);
|
||||
|
||||
if (!hToken ||
|
||||
!GetTokenInformation(hToken, TokenSessionId, &dwSessionId, sizeof(dwSessionId), &dwLength))
|
||||
{
|
||||
dwSessionId = 0;
|
||||
}
|
||||
|
||||
if (bOpenToken)
|
||||
CloseHandle(hToken);
|
||||
|
||||
return dwSessionId;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* SHGetShellStyleHInstance (SHELL32.749)
|
||||
*/
|
||||
|
|
|
@ -684,6 +684,9 @@ LargeIntegerToString(
|
|||
_In_opt_ const NUMBERFMTW *pNumberFormat,
|
||||
_In_ DWORD dwNumberFlags);
|
||||
|
||||
BOOL WINAPI SHOpenEffectiveToken(_Out_ LPHANDLE phToken);
|
||||
DWORD WINAPI SHGetUserSessionId(_In_opt_ HANDLE hToken);
|
||||
|
||||
/*****************************************************************************
|
||||
* Shell32 resources
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue