[SHELL32][SDK] Implement SHTestTokenPrivilegeW (#5725)

and modify shell32.spec.
This commit is contained in:
Katayama Hirofumi MZ 2023-09-26 07:36:07 +09:00 committed by GitHub
parent 1b3eed58ca
commit d1e9fe13de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 65 additions and 12 deletions

View file

@ -232,7 +232,7 @@
233 stdcall -noname SHGetUserPicturePathW(wstr long ptr)
234 stdcall -noname SHSetUserPicturePathW(wstr long ptr)
235 stdcall -noname SHOpenEffectiveToken(ptr)
236 stdcall -noname SHTestTokenPrivilegeW(ptr ptr)
236 stdcall -noname SHTestTokenPrivilegeW(ptr wstr)
237 stdcall -noname SHShouldShowWizards(ptr)
238 stdcall InternalExtractIconListW(ptr wstr ptr)
239 stdcall PathIsSlowW(wstr long)

View file

@ -1099,17 +1099,6 @@ SHSetUserPicturePathW(LPCWSTR lpPath, int csidl, LPVOID lpUnknown)
return E_FAIL;
}
/*
* Unimplemented
*/
EXTERN_C BOOL
WINAPI
SHTestTokenPrivilegeW(HANDLE hToken, LPDWORD ReturnLength)
{
FIXME("SHTestTokenPrivilegeW() stub\n");
return FALSE;
}
/*
* Unimplemented
*/

View file

@ -103,6 +103,67 @@ SHInvokePrivilegedFunctionW(
return hr;
}
/*************************************************************************
* SHTestTokenPrivilegeW (SHELL32.236)
*
* @see http://undoc.airesoft.co.uk/shell32.dll/SHTestTokenPrivilegeW.php
*/
EXTERN_C
BOOL WINAPI
SHTestTokenPrivilegeW(_In_opt_ HANDLE hToken, _In_z_ LPCWSTR lpName)
{
LUID Luid;
DWORD dwLength;
PTOKEN_PRIVILEGES pTokenPriv;
HANDLE hNewToken = NULL;
BOOL ret = FALSE;
TRACE("(%p, %s)\n", hToken, debugstr_w(lpName));
if (!lpName)
return FALSE;
if (!hToken)
{
if (!SHOpenEffectiveToken(&hNewToken))
goto Quit;
if (!hNewToken)
return FALSE;
hToken = hNewToken;
}
if (!LookupPrivilegeValueW(NULL, lpName, &Luid))
return FALSE;
dwLength = 0;
if (!GetTokenInformation(hToken, TokenPrivileges, NULL, 0, &dwLength))
goto Quit;
pTokenPriv = (PTOKEN_PRIVILEGES)LocalAlloc(LPTR, dwLength);
if (!pTokenPriv)
goto Quit;
if (GetTokenInformation(hToken, TokenPrivileges, pTokenPriv, dwLength, &dwLength))
{
UINT iPriv, cPrivs;
cPrivs = pTokenPriv->PrivilegeCount;
for (iPriv = 0; !ret && iPriv < cPrivs; ++iPriv)
{
ret = RtlEqualLuid(&Luid, &pTokenPriv->Privileges[iPriv].Luid);
}
}
LocalFree(pTokenPriv);
Quit:
if (hToken == hNewToken)
CloseHandle(hNewToken);
return ret;
}
/*************************************************************************
* SHGetShellStyleHInstance (SHELL32.749)
*/

View file

@ -695,6 +695,9 @@ SHInvokePrivilegedFunctionW(
_In_ PRIVILEGED_FUNCTION fn,
_In_opt_ LPARAM lParam);
BOOL WINAPI
SHTestTokenPrivilegeW(_In_opt_ HANDLE hToken, _In_z_ LPCWSTR lpName);
/*****************************************************************************
* Shell32 resources
*/