Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: build

on:
push:
branches: [ main ]
paths:
- ".github/workflows/build.yml"
- "include/**"
- "src/**"
- "xmake.lua"
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
xmake:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
mode:
- debug
- release
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup XMake
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: "latest"

- name: Configure
run: xmake config -y --mode=${{ matrix.mode }}

- name: Build
run: xmake build -y -vD
43 changes: 43 additions & 0 deletions include/REL/FHook.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#pragma once

#include "REX/BASE.h"

#include "REL/IHook.h"

namespace REL
{
class FHook :
public IHook
{
public:
FHook(const std::uintptr_t a_address);
FHook(const std::uintptr_t a_address, const char* a_name);
FHook(const std::uintptr_t a_address, const EHookType a_type);
FHook(const std::uintptr_t a_address, const EHookType a_type, const EHookStep a_step);
FHook(const std::uintptr_t a_address, const EHookStep a_step);
FHook(const std::uintptr_t a_address, const char* a_name, const EHookStep a_step);
FHook(const std::uintptr_t a_address, const char* a_name, const EHookType a_type);
FHook(const std::uintptr_t a_address, const char* a_name, const EHookType a_type, const EHookStep a_step);

~FHook();

virtual bool Init() override;
virtual FHookHandle GetHandle() const override;
virtual const char* GetName() const override;
virtual EHookType GetType() const override;
virtual EHookStep GetStep() const override;
virtual std::size_t GetSize() const override;
virtual std::size_t GetSizeTrampoline() const override;
virtual bool GetEnabled() const override;

protected:
std::uintptr_t m_address{ 0 };
std::string m_name;
FHookHandle m_handle;
EHookType m_type{ EHookType::None };
EHookStep m_step{ EHookStep::Load };
std::size_t m_size{ 8 };
std::size_t m_sizeTrampoline{ 0 };
bool m_enabled{ false };
};
}
34 changes: 34 additions & 0 deletions include/REL/FHookStore.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once

#include "REL/IHook.h"
#include "REX/BASE.h"
#include "REX/TSingleton.h"

namespace REL
{
class FHookStore :
public REX::TSingleton<FHookStore>
{
public:
FHookHandle Add(IHook* a_hook);
void Remove(const FHookHandle a_handle);

void Init();

void Enable();
void Enable(const FHookHandle a_handle);
void Enable(const EHookType a_type);
void Enable(const EHookStep a_step);

void Disable();
void Disable(const FHookHandle a_handle);
void Disable(const EHookType a_type);

std::size_t GetSizeTrampoline();

private:
std::map<FHookHandle, IHook*> m_hooks;
std::queue<FHookHandle> m_hookQueue;
std::uint32_t m_handleCount{ 0 };
};
}
134 changes: 0 additions & 134 deletions include/REL/HookObject.h

This file was deleted.

35 changes: 0 additions & 35 deletions include/REL/HookStore.h

This file was deleted.

18 changes: 9 additions & 9 deletions include/REL/IAT.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@

#include "REX/BASE.h"

#include "REX/REX/CAST.h"
#include "REX/CAST.h"
#include "REX/W32/BASE.h"

namespace REL
{
[[nodiscard]] std::uintptr_t GetIATAddr(std::string_view a_dll, std::string_view a_function);
[[nodiscard]] std::uintptr_t GetIATAddr(REX::W32::HMODULE a_module, std::string_view a_dll, std::string_view a_function);
[[nodiscard, deprecated("Use 'REX::FModule' instead")]] std::uintptr_t GetIATAddr(std::string_view a_dll, std::string_view a_function);
[[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);

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

template <class T>
[[nodiscard]] T* GetIATPtr(std::string_view a_dll, std::string_view a_function)
[[nodiscard, deprecated("Use 'REX::FModule' instead")]] T* GetIATPtr(std::string_view a_dll, std::string_view a_function)
{
return static_cast<T*>(GetIATPtr(std::move(a_dll), std::move(a_function)));
}

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

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

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

template <class F>
std::uintptr_t PatchIAT(F a_newFunc, std::string_view a_dll, std::string_view a_function)
[[deprecated("Use 'REX::FModule' instead")]] std::uintptr_t PatchIAT(F a_newFunc, std::string_view a_dll, std::string_view a_function)
{
return PatchIAT(REX::UNRESTRICTED_CAST<std::uintptr_t>(a_newFunc), a_dll, a_function);
}
Expand Down
7 changes: 3 additions & 4 deletions include/REL/ID.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#pragma once

#include "REX/BASE.h"
#include "REX/FModule.h"

#include "REL/IDDB.h"
#include "REL/Module.h"

namespace REL
{
Expand All @@ -24,8 +23,8 @@ namespace REL

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

[[nodiscard]] constexpr std::uint64_t id() const noexcept
Expand Down
8 changes: 4 additions & 4 deletions include/REL/IDDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

#include "REX/BASE.h"

#include "REX/REX/MemoryMap.h"
#include "REX/REX/Singleton.h"
#include "REX/FMemoryMap.h"
#include "REX/TSingleton.h"

namespace REL
{
class IDDB :
public REX::Singleton<IDDB>
public REX::TSingleton<IDDB>
{
public:
enum class Loader : std::uint32_t
Expand Down Expand Up @@ -63,7 +63,7 @@ namespace REL
std::filesystem::path m_path;
Loader m_loader{ Loader::None };
Format m_format{ Format::None };
REX::MemoryMap m_mmap;
REX::FMemoryMap m_mmap;
std::span<MAPPING> m_v0;
std::span<std::uint32_t> m_v5;
};
Expand Down
Loading