Skip to content

Commit debb5ad

Browse files
authored
feat: merge pr #4 from libxse/dev/refactor
2 parents 462dfac + 10c2d9d commit debb5ad

76 files changed

Lines changed: 2918 additions & 2588 deletions

Some content is hidden

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

.github/workflows/build.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- ".github/workflows/build.yml"
8+
- "include/**"
9+
- "src/**"
10+
- "xmake.lua"
11+
pull_request:
12+
branches: [ main ]
13+
workflow_dispatch:
14+
15+
jobs:
16+
xmake:
17+
runs-on: windows-latest
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
mode:
22+
- debug
23+
- release
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
with:
28+
submodules: recursive
29+
30+
- name: Setup XMake
31+
uses: xmake-io/github-action-setup-xmake@v1
32+
with:
33+
xmake-version: "latest"
34+
35+
- name: Configure
36+
run: xmake config -y --mode=${{ matrix.mode }}
37+
38+
- name: Build
39+
run: xmake build -y -vD

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/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+
}

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: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,34 @@
22

33
#include "REX/BASE.h"
44

5-
#include "REX/REX/CAST.h"
5+
#include "REX/CAST.h"
66
#include "REX/W32/BASE.h"
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: 3 additions & 4 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/FModule.h"
44

55
#include "REL/IDDB.h"
6-
#include "REL/Module.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

include/REL/IDDB.h

Lines changed: 4 additions & 4 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/FMemoryMap.h"
6+
#include "REX/TSingleton.h"
77

88
namespace REL
99
{
1010
class IDDB :
11-
public REX::Singleton<IDDB>
11+
public REX::TSingleton<IDDB>
1212
{
1313
public:
1414
enum class Loader : std::uint32_t
@@ -63,7 +63,7 @@ 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
};

0 commit comments

Comments
 (0)