File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -311,6 +311,18 @@ namespace REL
311
311
safe_fill (address (), a_value, a_count);
312
312
}
313
313
314
+ #ifdef SFSE_SUPPORT_XBYAK
315
+ void write_func (const std::size_t a_count, const std::uintptr_t a_dst)
316
+ requires(std::same_as<value_type, std::uintptr_t >);
317
+
318
+ template <class F >
319
+ void write_func (const std::size_t a_count, const F a_dst)
320
+ requires(std::same_as<value_type, std::uintptr_t >)
321
+ {
322
+ write_func (a_count, stl::unrestricted_cast<std::uintptr_t >(a_dst));
323
+ }
324
+ #endif
325
+
314
326
constexpr std::uintptr_t write_vfunc (const std::size_t a_idx, const std::uintptr_t a_newFunc)
315
327
requires(std::same_as<value_type, std::uintptr_t >)
316
328
{
Original file line number Diff line number Diff line change
1
+ #include " REL/Relocation.h"
2
+
3
+ #ifdef SFSE_SUPPORT_XBYAK
4
+ # include < xbyak/xbyak.h>
5
+
6
+ namespace REL
7
+ {
8
+ struct write_func_impl : Xbyak::CodeGenerator
9
+ {
10
+ write_func_impl (std::uintptr_t a_dst)
11
+ {
12
+ Xbyak::Label dst;
13
+ jmp (ptr[rip + dst]);
14
+ L (dst);
15
+ dq (a_dst);
16
+ }
17
+ };
18
+
19
+ template <class T >
20
+ void Relocation<T>::write_func(const std::size_t a_count, const std::uintptr_t a_dst)
21
+ requires (std::same_as<value_type, std::uintptr_t >)
22
+ {
23
+ safe_fill (address (), INT3, a_count);
24
+ auto patch = write_func_impl{ a_dst };
25
+ patch.ready ();
26
+ assert (patch.getSize () <= a_count);
27
+ safe_write (address (), std::span{ patch.getCode <const std::byte*>(), patch.getSize () });
28
+ }
29
+
30
+ template void Relocation<std::uintptr_t >::write_func(const std::size_t , const std::uintptr_t );
31
+ }
32
+ #endif
You can’t perform that action at this time.
0 commit comments