ReXGlue SDK
Loading...
Searching...
No Matches
kernel_object.h
Go to the documentation of this file.
1
10
11#pragma once
12
13#include <atomic>
14#include <memory>
15#include <string>
16#include <utility>
17#include <variant>
18#include <vector>
19
34#include <rex/types.h>
35
36namespace rex::kernel {
37
42
51 template <typename T, typename... Args>
52 explicit KernelObject(std::in_place_type_t<T> tag, Args&&... args)
53 : data(tag, std::forward<Args>(args)...) {}
54
56
57 [[nodiscard]] ObjectType GetType() const { return static_cast<ObjectType>(data.index()); }
58
59 ObjectData data;
60 std::string name;
61 std::vector<X_HANDLE> handles;
62 bool header_hold = false;
63 u32 pointer_refs = 0;
64 u32 guest_ptr = 0;
65 bool owns_guest_block = false;
67 std::atomic<bool> reinit_pending{false};
72 void (*destroy)(KernelObject* object) noexcept = nullptr;
73};
74
80template <typename T, typename... Args>
81[[nodiscard]] std::unique_ptr<KernelObject> MakeObject(Args&&... args) {
82 if constexpr (XAMObjectClass<T>) {
83 return std::make_unique<KernelObject>(std::in_place_type<XAMObject>,
84 std::make_unique<T>(std::forward<Args>(args)...));
85 } else {
86 return std::make_unique<KernelObject>(std::in_place_type<T>, std::forward<Args>(args)...);
87 }
88}
89
90} // namespace rex::kernel
Definition heap.h:594
Definition object.h:150
Definition guest_allocator.h:179
Definition xam_object.h:40
Definition export.h:24
std::variant< EventObject, SemaphoreObject, MutantObject, TimerObject, FileObject, NotifyListenerObject, IOCompletionObject, SymbolicLinkObject, ModuleObject, ThreadRef, XAMObject > ObjectData
Definition kernel_object.h:39
std::unique_ptr< KernelObject > MakeObject(Args &&... args)
Definition kernel_object.h:81
Definition endian.h:27
#define REX_KERNEL_API
Definition platform.h:297
Definition event_object.h:59
Definition file_object.h:161
Definition io_completion_object.h:49
void(*) destroy(KernelObject *object) noexcept
Definition kernel_object.h:72
u32 guest_ptr
Definition kernel_object.h:64
std::atomic< bool > reinit_pending
Definition kernel_object.h:67
std::vector< X_HANDLE > handles
Definition kernel_object.h:61
bool owns_guest_block
Definition kernel_object.h:65
bool header_hold
Definition kernel_object.h:62
PinCount pins
Definition kernel_object.h:70
u32 pointer_refs
Definition kernel_object.h:63
std::string name
Definition kernel_object.h:60
WorkspaceHeap * workspace
Definition kernel_object.h:69
KernelObject(std::in_place_type_t< T > tag, Args &&... args)
Definition kernel_object.h:52
Definition module_object.h:189
Definition mutant_object.h:54
Definition notify_listener_object.h:68
Definition semaphore_object.h:38
Definition symbolic_link_object.h:27
Definition kernel_thread.h:48
Definition timer_object.h:45
Definition xam_object.h:28
Integer types, byte order wrappers and size literals.