mirror of
https://github.com/decompals/wibo.git
synced 2025-10-15 14:45:12 +00:00
29 lines
783 B
C++
29 lines
783 B
C++
#include "processthreadsapi.h"
|
|
|
|
#include "errors.h"
|
|
#include "handles.h"
|
|
#include "internal.h"
|
|
#include "processes.h"
|
|
|
|
namespace advapi32 {
|
|
|
|
BOOL WIN_FUNC OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle) {
|
|
WIN_API_SEGMENT_GUARD();
|
|
DEBUG_LOG("OpenProcessToken(%p, %u, %p)\n", ProcessHandle, DesiredAccess, TokenHandle);
|
|
if (!TokenHandle) {
|
|
wibo::lastError = ERROR_INVALID_PARAMETER;
|
|
return FALSE;
|
|
}
|
|
auto obj = wibo::handles().getAs<ProcessObject>(ProcessHandle);
|
|
if (!obj) {
|
|
wibo::lastError = ERROR_INVALID_HANDLE;
|
|
return FALSE;
|
|
}
|
|
auto token = make_pin<TokenObject>(std::move(obj), DesiredAccess);
|
|
*TokenHandle = wibo::handles().alloc(std::move(token), 0, 0);
|
|
wibo::lastError = ERROR_SUCCESS;
|
|
return TRUE;
|
|
}
|
|
|
|
} // namespace advapi32
|