generated from xforce/bazel-cpp-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Early work on API, no implementation, just trying to get a feel for a…
… nice API
- Loading branch information
Showing
13 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build --cpu=x64_windows --host_cpu=x64_windows --incompatible_windows_native_test_wrapper --shell_executable="cmd" --copt="/D_ITERATOR_DEBUG_LEVEL=0" --cxxopt=-std:c++latest --define internal=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
cc_library( | ||
name = "meow-hook", | ||
srcs = glob(["src/**/*.cc"]) + glob(["src/**/*.h"]), | ||
hdrs = glob(["include/**/*.h"]), | ||
includes = [ | ||
"include", | ||
], | ||
deps = [ | ||
"//third_party:asmjit", | ||
"//third_party:zydis", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
namespace meow_hook | ||
{ | ||
|
||
namespace detail | ||
{ | ||
template <class T> class detour; | ||
|
||
template <typename Ret, typename... Args> // | ||
class detour<Ret(Args...)>; | ||
|
||
class detour_base | ||
{ | ||
public: | ||
detour_base(uintptr_t address, void *func) | ||
: address_(address) | ||
, function_(func) | ||
{ | ||
// | ||
} | ||
virtual ~detour_base() = default; | ||
|
||
private: | ||
void hook(); | ||
void unhook(); | ||
|
||
uintptr_t address_ = 0; | ||
void * function_ = nullptr; | ||
|
||
template <class T> friend class detour; | ||
}; | ||
|
||
template <typename Ret, typename... Args> // | ||
class detour<Ret(Args...)> : public detour_base | ||
{ | ||
public: | ||
using function_t = Ret(Args...); | ||
|
||
// | ||
detour(uintptr_t address, function_t *fn) | ||
: detour_base(address, fn) | ||
{ | ||
// Hook | ||
detour_base::hook(); | ||
} | ||
|
||
~detour() override | ||
{ | ||
// Unhook | ||
detour_base::unhook(); | ||
} | ||
}; | ||
|
||
} // namespace detail | ||
|
||
template <typename T> using detour = detail::detour<T>; | ||
} // namespace meow_hook |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "meow_hook/detour.h" | ||
|
||
namespace meow_hook::detail | ||
{ | ||
void detour_base::hook() | ||
{ | ||
// | ||
} | ||
|
||
void detour_base::unhook() | ||
{ | ||
// | ||
} | ||
|
||
} // namespace meow_hook::detail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <Zydis/Zydis.h> | ||
|
||
#include "meow_hook/detour.h" | ||
|
||
bool hook(int) | ||
{ | ||
return false; | ||
} | ||
|
||
int main() | ||
{ | ||
ZydisDecoder decoder; | ||
ZydisDecoderInit(&decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_ADDRESS_WIDTH_64); | ||
|
||
meow_hook::detour<bool(int)> detour(0x0, hook); | ||
|
||
return 0; | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
cc_library( | ||
name = "spdlog", | ||
defines = [ | ||
"SPDLOG_WCHAR_FILENAMES" | ||
], | ||
hdrs = glob(["spdlog/include/**/*.h"]), | ||
includes = [ | ||
"spdlog/include", | ||
], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
cc_library( | ||
name = "zycore", | ||
hdrs = glob(["zydis/dependencies/zycore/include/**/*.h"]), | ||
srcs = glob(["zydis/dependencies/zycore/src/**/*.c"]), | ||
defines = [ | ||
"ZYCORE_STATIC_DEFINE" | ||
], | ||
includes = [ | ||
"zydis/dependencies/zycore/include", | ||
] + select({ | ||
"@bazel_tools//src/conditions:windows": ["zydis/msvc"], | ||
"//conditions:default": [], | ||
}), | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
cc_library( | ||
name = "zydis", | ||
hdrs = glob(["zydis/include/**/*.h"]), | ||
srcs = glob(["zydis/src/**/*.c", "zydis/src/**/*.inc"]), | ||
defines = [ | ||
"ZYDIS_STATIC_DEFINE" | ||
], | ||
includes = [ | ||
"zydis/include", | ||
] + select({ | ||
"@bazel_tools//src/conditions:windows": ["zydis/msvc"], | ||
"//conditions:default": [], | ||
}), | ||
copts = ["-Ithird_party/zydis/src"], # GOD THIS SUCKS SOOOOO MUCH, WHY BAZEL WHY, I LIKE YOU BUT INCLUDE PATHS ARE JUST GARBAGE | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
":zycore" | ||
] | ||
) | ||
|
||
cc_library( | ||
name = "asmjit", | ||
defines = [ ], | ||
hdrs = glob(["asmjit/src/**/*.h"]), | ||
srcs = glob(["asmjit/src/**/*.cpp"]), | ||
includes = [ | ||
"asmjit/src", | ||
], | ||
visibility = ["//visibility:public"], | ||
) |