mirror of
https://github.com/decompals/wibo.git
synced 2025-10-17 07:35:11 +00:00
Minor cleanup
This commit is contained in:
parent
f52ca2803f
commit
f5aa320800
@ -6,6 +6,7 @@
|
||||
#include "handles.h"
|
||||
#include "strutil.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
@ -115,12 +116,8 @@ Pin<RegistryKeyObject> handleDataFromHKeyLocked(HKEY hKey) {
|
||||
|
||||
bool isPredefinedKeyHandle(HKEY hKey) {
|
||||
uintptr_t raw = reinterpret_cast<uintptr_t>(hKey);
|
||||
for (const auto &kPredefinedKeyInfo : kPredefinedKeyInfos) {
|
||||
if (kPredefinedKeyInfo.value == raw) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return std::any_of(std::begin(kPredefinedKeyInfos), std::end(kPredefinedKeyInfos),
|
||||
[raw](const PredefinedKeyInfo &info) { return info.value == raw; });
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -37,22 +37,22 @@ BOOL WIN_FUNC DuplicateHandle(HANDLE hSourceProcessHandle, HANDLE hSourceHandle,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
auto &handles = wibo::handles();
|
||||
if (isPseudoCurrentProcessHandle(hSourceHandle)) {
|
||||
auto po = make_pin<ProcessObject>(getpid(), -1);
|
||||
auto handle = wibo::handles().alloc(std::move(po), 0, 0);
|
||||
auto handle = handles.alloc(std::move(po), 0, 0);
|
||||
DEBUG_LOG("DuplicateHandle: created process handle for current process -> %p\n", handle);
|
||||
*lpTargetHandle = handle;
|
||||
return TRUE;
|
||||
} else if (isPseudoCurrentThreadHandle(hSourceHandle)) {
|
||||
auto th = make_pin<ThreadObject>(pthread_self());
|
||||
auto handle = wibo::handles().alloc(std::move(th), 0, 0);
|
||||
auto handle = handles.alloc(std::move(th), 0, 0);
|
||||
DEBUG_LOG("DuplicateHandle: created thread handle for current thread -> %p\n", handle);
|
||||
*lpTargetHandle = handle;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!wibo::handles().duplicateTo(hSourceHandle, wibo::handles(), *lpTargetHandle, dwDesiredAccess, bInheritHandle,
|
||||
dwOptions)) {
|
||||
if (!handles.duplicateTo(hSourceHandle, handles, *lpTargetHandle, dwDesiredAccess, bInheritHandle, dwOptions)) {
|
||||
wibo::lastError = ERROR_INVALID_HANDLE;
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ bool Handles::duplicateTo(HANDLE src, Handles &dst, HANDLE &out, uint32_t desire
|
||||
uint32_t effAccess = (options & DUPLICATE_SAME_ACCESS) ? meta.grantedAccess : (desiredAccess & meta.grantedAccess);
|
||||
const uint32_t flags = (inherit ? HANDLE_FLAG_INHERIT : 0);
|
||||
|
||||
// Reuse the same handle if duplicating within the same table and no changes
|
||||
// Reuse the same handle if duplicating with DUPLICATE_CLOSE_SOURCE within the same table and no changes
|
||||
if (&dst == this && closeSource && effAccess == meta.grantedAccess && flags == meta.flags) {
|
||||
out = src;
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user