Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
Hooks.h
Go to the documentation of this file.
1#pragma once
2
3#include <IHooks.h>
4
5#include <memory>
6#include <unordered_map>
7
8namespace API
9{
10 class Hooks : public AsaApi::IHooks
11 {
12 public:
13 Hooks();
14
15 Hooks(const Hooks&) = delete;
16 Hooks(Hooks&&) = delete;
17 Hooks& operator=(const Hooks&) = delete;
18 Hooks& operator=(Hooks&&) = delete;
19
20 ~Hooks() override = default;
21
22 bool SetHookInternal(const std::string& func_name, LPVOID detour, LPVOID* original) override;
23
24 bool DisableHook(const std::string& func_name, LPVOID detour) override;
25
26 private:
27 struct Hook
28 {
29 Hook(LPVOID target, LPVOID detour, LPVOID* original)
30 : target(target),
31 detour(detour),
32 original(original)
33 {
34 }
35
36 LPVOID target;
37 LPVOID detour;
38 LPVOID* original;
39 };
40
42 };
43} // namespace API
static void SetServerID(RCONClientConnection *, RCONPacket *, UWorld *)
std::string GetApiName() override
bool DownloadCacheFiles(const std::filesystem::path downloadFile, const std::filesystem::path localFile)
std::unique_ptr< AsaApi::IApiUtils > & GetApiUtils() override
static void LoadPluginCmd(APlayerController *, FString *, bool)
std::unique_ptr< AsaApi::ICommands > commands_
Definition ArkBaseApi.h:45
void RegisterCommands() override
float GetVersion() override
~ArkBaseApi() override=default
static FString LoadPlugin(FString *cmd)
static void UnloadPluginRcon(RCONClientConnection *, RCONPacket *, UWorld *)
nlohmann::json GetConfig()
std::unique_ptr< AsaApi::IApiUtils > api_utils_
Definition ArkBaseApi.h:47
bool Init() override
static void UnloadPluginCmd(APlayerController *, FString *, bool)
static void LoadPluginRcon(RCONClientConnection *, RCONPacket *, UWorld *)
static FString UnloadPlugin(FString *cmd)
std::unique_ptr< AsaApi::ICommands > & GetCommands() override
std::unique_ptr< AsaApi::IHooks > & GetHooks() override
std::unique_ptr< AsaApi::IHooks > hooks_
Definition ArkBaseApi.h:46
Hooks(const Hooks &)=delete
Hooks & operator=(const Hooks &)=delete
std::unordered_map< std::string, std::vector< std::shared_ptr< Hook > > > all_hooks_
Definition Hooks.h:41
~Hooks() override=default
Hooks & operator=(Hooks &&)=delete
bool DisableHook(const std::string &func_name, LPVOID detour) override
Removes a hook from a function.
Definition Hooks.cpp:66
bool SetHookInternal(const std::string &func_name, LPVOID detour, LPVOID *original) override
Definition Hooks.cpp:18
Hooks(Hooks &&)=delete
std::vector< std::shared_ptr< Plugin > > loaded_plugins_
std::vector< std::shared_ptr< Plugin > >::const_iterator FindPlugin(const std::string &plugin_name)
Find plugin by it's name.
PluginManager & operator=(const PluginManager &)=delete
PluginManager()=default
PluginManager(const PluginManager &)=delete
PluginManager(PluginManager &&)=delete
void LoadAllPlugins()
Find and load all plugins.
static PluginManager & Get()
static nlohmann::json ReadPluginInfo(const std::string &plugin_name)
bool IsPluginLoaded(const std::string &plugin_name)
Returns true if plugin was loaded, false otherwise.
std::shared_ptr< Plugin > & LoadPlugin(const std::string &plugin_name) noexcept(false)
Load plugin by it's name.
static void DetectPluginChangesTimerCallback()
Checks for auto plugin reloads.
void UnloadPlugin(const std::string &plugin_name) noexcept(false)
Unload plugin by it's name. Plugin must free all used resources.
PluginManager & operator=(PluginManager &&)=delete
~PluginManager()=default
static nlohmann::json ReadSettingsConfig()
static const FColor Green
Definition ColorList.h:24
UE_NODISCARD FORCEINLINE const TCHAR * operator*() const UE_LIFETIMEBOUND
Definition IBaseApi.h:9
constexpr float api_version
ARK_API std::string GetCurrentDir()
Definition Tools.cpp:8
IApiUtils & GetApiUtils()
Definition ApiUtils.cpp:206
void InitHooks()
Definition HooksImpl.cpp:43
Definition json.hpp:4518
LPVOID target
Definition Hooks.h:36
LPVOID * original
Definition Hooks.h:38
Hook(LPVOID target, LPVOID detour, LPVOID *original)
Definition Hooks.h:29
LPVOID detour
Definition Hooks.h:37
std::string description
std::vector< std::string > dependencies
Plugin(HINSTANCE h_module, std::string name, std::string full_name, std::string description, float version, float min_api_version, std::vector< std::string > dependencies)
HINSTANCE h_module
float min_api_version
std::string full_name
std::string name
void SendMessageW(int Id, int Type, FString *OutGoingMessage)
Definition Other.h:38
int Id
Definition Other.h:13