ReXGlue SDK
Toggle main menu visibility
Loading...
Searching...
No Matches
dynlib.h
Go to the documentation of this file.
1
10
#pragma once
11
12
#include <cstdint>
13
#include <filesystem>
14
#include <span>
15
#include <string>
16
#include <string_view>
17
18
#include <
rex/platform.h
>
19
#include <
rex/types.h
>
20
#include <
rex/utility.h
>
21
22
namespace
rex::platform
{
23
24
enum class
SymbolResolution
: u8 {
25
kLazy
,
26
kImmediate
,
27
};
28
30
class
REX_API
DynamicLibrary :
public
rex::MoveOnly
{
31
public
:
32
DynamicLibrary() =
default
;
33
~DynamicLibrary();
34
35
DynamicLibrary(DynamicLibrary&& other)
noexcept
;
36
DynamicLibrary& operator=(DynamicLibrary&& other)
noexcept
;
37
44
bool
Load
(
const
std::filesystem::path& path,
SymbolResolution
mode =
SymbolResolution::kLazy
);
45
50
bool
LoadNamed
(std::string_view name,
SymbolResolution
mode =
SymbolResolution::kLazy
);
51
58
bool
Attach
(
const
std::filesystem::path& path);
59
61
void
Close
();
62
63
explicit
operator
bool()
const
{
return
handle_ !=
nullptr
; }
64
69
void
*
GetRawSymbol
(
const
char
* name)
const
;
70
76
template
<
typename
T>
77
T
GetSymbol
(
const
char
* name)
const
{
78
return
reinterpret_cast<
T
>
(
GetRawSymbol
(name));
79
}
80
82
const
std::string&
GetLastError
()
const
{
return
last_error_; }
83
84
private
:
85
void
* handle_ =
nullptr
;
86
std::string last_error_;
87
};
88
89
#if REX_PLATFORM_WIN32
96
REX_API
std::span<const u8> FindImageSection(
const
void
* image, std::string_view name);
97
#endif
98
99
}
// namespace rex::platform
rex::MoveOnly
Definition
utility.h:28
rex::platform::DynamicLibrary::Attach
bool Attach(const std::filesystem::path &path)
rex::platform::DynamicLibrary::GetRawSymbol
void * GetRawSymbol(const char *name) const
rex::platform::DynamicLibrary::GetLastError
const std::string & GetLastError() const
Definition
dynlib.h:82
rex::platform::DynamicLibrary::GetSymbol
T GetSymbol(const char *name) const
Definition
dynlib.h:77
rex::platform::DynamicLibrary::LoadNamed
bool LoadNamed(std::string_view name, SymbolResolution mode=SymbolResolution::kLazy)
rex::platform::DynamicLibrary::Close
void Close()
rex::platform::DynamicLibrary::Load
bool Load(const std::filesystem::path &path, SymbolResolution mode=SymbolResolution::kLazy)
rex::platform
Definition
platform.h:345
rex::platform::SymbolResolution
SymbolResolution
Definition
dynlib.h:24
rex::platform::SymbolResolution::kImmediate
@ kImmediate
Definition
dynlib.h:26
rex::platform::SymbolResolution::kLazy
@ kLazy
Definition
dynlib.h:25
platform.h
Platform flags, packing macros and export markers.
REX_API
#define REX_API
Definition
platform.h:177
types.h
Integer types, byte order wrappers and size literals.
utility.h
Move only function, const propagating pointer and scope guard.
rex
platform
dynlib.h
Generated by
1.18.0