mirror of
https://github.com/reactos/reactos.git
synced 2025-01-15 18:43:27 +00:00
[SHELL32][SDK] Implement SHInvokePrivilegedFunctionW (#5718)
Add it to <undocshell.h>. Modify shell32.spec.
This commit is contained in:
parent
ed06c06dcb
commit
cc6e444ceb
3 changed files with 50 additions and 1 deletions
|
@ -242,7 +242,7 @@
|
|||
243 stdcall -noname SHSetShellWindowEx(ptr ptr) user32.SetShellWindowEx
|
||||
244 stdcall -noname SHSettingsChanged(ptr ptr)
|
||||
245 stdcall SHTestTokenMembership(ptr ptr)
|
||||
246 stub -noname SHInvokePrivilegedFunctionW
|
||||
246 stdcall -noname SHInvokePrivilegedFunctionW(wstr ptr ptr)
|
||||
247 stub -noname SHGetActiveConsoleSessionId
|
||||
248 stdcall -noname SHGetUserSessionId(ptr)
|
||||
249 stdcall -noname PathParseIconLocation(wstr) PathParseIconLocationW
|
||||
|
|
|
@ -62,6 +62,47 @@ EXTERN_C DWORD WINAPI SHGetUserSessionId(_In_opt_ HANDLE hToken)
|
|||
return dwSessionId;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* SHInvokePrivilegedFunctionW (SHELL32.246)
|
||||
*/
|
||||
EXTERN_C
|
||||
HRESULT WINAPI
|
||||
SHInvokePrivilegedFunctionW(
|
||||
_In_z_ LPCWSTR pszName,
|
||||
_In_ PRIVILEGED_FUNCTION fn,
|
||||
_In_opt_ LPARAM lParam)
|
||||
{
|
||||
TRACE("(%s %p %p)\n", debugstr_w(pszName), fn, lParam);
|
||||
|
||||
if (!pszName || !fn)
|
||||
return E_INVALIDARG;
|
||||
|
||||
HANDLE hToken = NULL;
|
||||
TOKEN_PRIVILEGES NewPriv, PrevPriv;
|
||||
BOOL bAdjusted = FALSE;
|
||||
|
||||
if (SHOpenEffectiveToken(&hToken) &&
|
||||
::LookupPrivilegeValueW(NULL, pszName, &NewPriv.Privileges[0].Luid))
|
||||
{
|
||||
NewPriv.PrivilegeCount = 1;
|
||||
NewPriv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
DWORD dwReturnSize;
|
||||
bAdjusted = ::AdjustTokenPrivileges(hToken, FALSE, &NewPriv,
|
||||
sizeof(PrevPriv), &PrevPriv, &dwReturnSize);
|
||||
}
|
||||
|
||||
HRESULT hr = fn(lParam);
|
||||
|
||||
if (bAdjusted)
|
||||
::AdjustTokenPrivileges(hToken, FALSE, &PrevPriv, 0, NULL, NULL);
|
||||
|
||||
if (hToken)
|
||||
::CloseHandle(hToken);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* SHGetShellStyleHInstance (SHELL32.749)
|
||||
*/
|
||||
|
|
|
@ -687,6 +687,14 @@ LargeIntegerToString(
|
|||
BOOL WINAPI SHOpenEffectiveToken(_Out_ LPHANDLE phToken);
|
||||
DWORD WINAPI SHGetUserSessionId(_In_opt_ HANDLE hToken);
|
||||
|
||||
typedef HRESULT (CALLBACK *PRIVILEGED_FUNCTION)(LPARAM lParam);
|
||||
|
||||
HRESULT WINAPI
|
||||
SHInvokePrivilegedFunctionW(
|
||||
_In_z_ LPCWSTR pszName,
|
||||
_In_ PRIVILEGED_FUNCTION fn,
|
||||
_In_opt_ LPARAM lParam);
|
||||
|
||||
/*****************************************************************************
|
||||
* Shell32 resources
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue