Skip to content

Commit 9184996

Browse files
committed
feat: refactoring and renaming
- should mostly still be backwards compatible with a deprecation warning
1 parent 462dfac commit 9184996

42 files changed

Lines changed: 1060 additions & 954 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/REL/FHook.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#pragma once
2+
3+
#include "REX/BASE.h"
4+
5+
#include "REL/IHook.h"
6+
7+
namespace REL
8+
{
9+
class FHook :
10+
public IHook
11+
{
12+
public:
13+
FHook(const std::uintptr_t a_address);
14+
FHook(const std::uintptr_t a_address, const char* a_name);
15+
FHook(const std::uintptr_t a_address, const EHookType a_type);
16+
FHook(const std::uintptr_t a_address, const EHookType a_type, const EHookStep a_step);
17+
FHook(const std::uintptr_t a_address, const EHookStep a_step);
18+
FHook(const std::uintptr_t a_address, const char* a_name, const EHookStep a_step);
19+
FHook(const std::uintptr_t a_address, const char* a_name, const EHookType a_type);
20+
FHook(const std::uintptr_t a_address, const char* a_name, const EHookType a_type, const EHookStep a_step);
21+
22+
~FHook();
23+
24+
virtual bool Init() override;
25+
virtual FHookHandle GetHandle() const override;
26+
virtual const char* GetName() const override;
27+
virtual EHookType GetType() const override;
28+
virtual EHookStep GetStep() const override;
29+
virtual std::size_t GetSize() const override;
30+
virtual std::size_t GetSizeTrampoline() const override;
31+
virtual bool GetEnabled() const override;
32+
33+
protected:
34+
std::uintptr_t m_address{ 0 };
35+
std::string m_name;
36+
FHookHandle m_handle;
37+
EHookType m_type{ EHookType::None };
38+
EHookStep m_step{ EHookStep::Load };
39+
std::size_t m_size{ 8 };
40+
std::size_t m_sizeTrampoline{ 0 };
41+
bool m_enabled{ false };
42+
};
43+
}

include/REL/FHookStore.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#pragma once
2+
3+
#include "REL/IHook.h"
4+
#include "REX/BASE.h"
5+
#include "REX/REX/TSingleton.h"
6+
7+
namespace REL
8+
{
9+
class FHookStore :
10+
public REX::TSingleton<FHookStore>
11+
{
12+
public:
13+
FHookHandle Add(IHook* a_hook);
14+
void Remove(const FHookHandle a_handle);
15+
16+
void Init();
17+
18+
void Enable();
19+
void Enable(const FHookHandle a_handle);
20+
void Enable(const EHookType a_type);
21+
void Enable(const EHookStep a_step);
22+
23+
void Disable();
24+
void Disable(const FHookHandle a_handle);
25+
void Disable(const EHookType a_type);
26+
27+
std::size_t GetSizeTrampoline();
28+
29+
private:
30+
std::map<FHookHandle, IHook*> m_hooks;
31+
std::queue<FHookHandle> m_hookQueue;
32+
std::uint32_t m_handleCount{ 0 };
33+
};
34+
}
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
#include "REX/BASE.h"
44

5-
#include "REX/REX/MemoryMap.h"
6-
#include "REX/REX/Singleton.h"
5+
#include "REX/REX/FMemoryMap.h"
6+
#include "REX/REX/TSingleton.h"
77

88
namespace REL
99
{
10-
class IDDB :
11-
public REX::Singleton<IDDB>
10+
class FIDDB :
11+
public REX::TSingleton<FIDDB>
1212
{
1313
public:
1414
enum class Loader : std::uint32_t
@@ -35,7 +35,7 @@ namespace REL
3535
std::uint64_t offset;
3636
};
3737

38-
IDDB();
38+
FIDDB();
3939

4040
std::uint64_t offset(std::uint64_t a_id) const;
4141

@@ -63,8 +63,10 @@ namespace REL
6363
std::filesystem::path m_path;
6464
Loader m_loader{ Loader::None };
6565
Format m_format{ Format::None };
66-
REX::MemoryMap m_mmap;
66+
REX::FMemoryMap m_mmap;
6767
std::span<MAPPING> m_v0;
6868
std::span<std::uint32_t> m_v5;
6969
};
70+
71+
using IDDB [[deprecated("Renamed to 'REL::FIDDB'")]] = FIDDB;
7072
}

include/REL/HookObject.h

Lines changed: 0 additions & 134 deletions
This file was deleted.

include/REL/HookStore.h

Lines changed: 0 additions & 35 deletions
This file was deleted.

include/REL/IAT.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,29 @@
77

88
namespace REL
99
{
10-
[[nodiscard]] std::uintptr_t GetIATAddr(std::string_view a_dll, std::string_view a_function);
11-
[[nodiscard]] std::uintptr_t GetIATAddr(REX::W32::HMODULE a_module, std::string_view a_dll, std::string_view a_function);
10+
[[nodiscard, deprecated("Use 'REX::FModule' instead")]] std::uintptr_t GetIATAddr(std::string_view a_dll, std::string_view a_function);
11+
[[nodiscard, deprecated("Use 'REX::FModule' instead")]] std::uintptr_t GetIATAddr(REX::W32::HMODULE a_module, std::string_view a_dll, std::string_view a_function);
1212

13-
[[nodiscard]] void* GetIATPtr(std::string_view a_dll, std::string_view a_function);
13+
[[nodiscard, deprecated("Use 'REX::FModule' instead")]] void* GetIATPtr(std::string_view a_dll, std::string_view a_function);
1414

1515
template <class T>
16-
[[nodiscard]] T* GetIATPtr(std::string_view a_dll, std::string_view a_function)
16+
[[nodiscard, deprecated("Use 'REX::FModule' instead")]] T* GetIATPtr(std::string_view a_dll, std::string_view a_function)
1717
{
1818
return static_cast<T*>(GetIATPtr(std::move(a_dll), std::move(a_function)));
1919
}
2020

21-
[[nodiscard]] void* GetIATPtr(REX::W32::HMODULE a_module, std::string_view a_dll, std::string_view a_function);
21+
[[nodiscard, deprecated("Use 'REX::FModule' instead")]] void* GetIATPtr(REX::W32::HMODULE a_module, std::string_view a_dll, std::string_view a_function);
2222

2323
template <class T>
24-
[[nodiscard]] T* GetIATPtr(REX::W32::HMODULE a_module, std::string_view a_dll, std::string_view a_function)
24+
[[nodiscard, deprecated("Use 'REX::FModule' instead")]] T* GetIATPtr(REX::W32::HMODULE a_module, std::string_view a_dll, std::string_view a_function)
2525
{
2626
return static_cast<T*>(GetIATPtr(a_module, std::move(a_dll), std::move(a_function)));
2727
}
2828

29-
std::uintptr_t PatchIAT(std::uintptr_t a_newFunc, std::string_view a_dll, std::string_view a_function);
29+
[[deprecated("Use 'REX::FModule' instead")]] std::uintptr_t PatchIAT(std::uintptr_t a_newFunc, std::string_view a_dll, std::string_view a_function);
3030

3131
template <class F>
32-
std::uintptr_t PatchIAT(F a_newFunc, std::string_view a_dll, std::string_view a_function)
32+
[[deprecated("Use 'REX::FModule' instead")]] std::uintptr_t PatchIAT(F a_newFunc, std::string_view a_dll, std::string_view a_function)
3333
{
3434
return PatchIAT(REX::UNRESTRICTED_CAST<std::uintptr_t>(a_newFunc), a_dll, a_function);
3535
}

include/REL/ID.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#pragma once
22

3-
#include "REX/BASE.h"
3+
#include "REX/REX/FModule.h"
44

5-
#include "REL/IDDB.h"
6-
#include "REL/Module.h"
5+
#include "REL/FIDDB.h"
76

87
namespace REL
98
{
@@ -24,8 +23,8 @@ namespace REL
2423

2524
[[nodiscard]] std::uintptr_t address() const
2625
{
27-
const auto mod = Module::GetSingleton();
28-
return mod->base() + offset();
26+
const auto mod = REX::FModule::GetExecutingModule();
27+
return mod.GetBaseAddress() + offset();
2928
}
3029

3130
[[nodiscard]] constexpr std::uint64_t id() const noexcept
@@ -35,7 +34,7 @@ namespace REL
3534

3635
[[nodiscard]] std::size_t offset() const
3736
{
38-
const auto iddb = IDDB::GetSingleton();
37+
const auto iddb = FIDDB::GetSingleton();
3938
return iddb->offset(m_id);
4039
}
4140

0 commit comments

Comments
 (0)