the first < 5 bytesmaster
@@ -6,16 +6,13 @@ use64 | |||
public _loop | |||
_loop: | |||
xor eax, eax | |||
inc eax | |||
mov rbx, rdx ; RDX is overwritten by mul | |||
@again: | |||
cmp rbx, 0 | |||
je @loop_end | |||
mov rax, rcx | |||
@loop_loop: | |||
mul rcx | |||
dec rbx | |||
jmp @again | |||
@loop_end: | |||
nop | |||
nop | |||
nop | |||
loop @loop_loop ; lol | |||
ret | |||
public _tail_recursion |
@@ -1,12 +1,11 @@ | |||
#pragma once | |||
extern "C" { | |||
/** | |||
* Raises @num @cnt times | |||
* $$ x*x * (x-1)! $$ | |||
* | |||
* @param num | |||
* @param cnt | |||
*/ | |||
uint32_t _loop(uint32_t num, uint32_t cnt); | |||
uint32_t _loop(uint32_t x); | |||
/** | |||
* Computes factorial |
@@ -32,10 +32,10 @@ TEST_CASE("Advanced instruction functions work as expected, unhokked") { | |||
} | |||
TEST_CASE("Loops & tail recursion work as expected, unhook") { | |||
REQUIRE(_loop(2, 3) == 8); | |||
REQUIRE(_loop(5, 3) == 125); | |||
REQUIRE(_loop(5, 0) == 1); | |||
REQUIRE(_loop(5, 1) == 5); | |||
REQUIRE(_loop(1) == 1); | |||
REQUIRE(_loop(2) == 4); | |||
REQUIRE(_loop(3) == 18); | |||
REQUIRE(_loop(5) == 25*24); | |||
REQUIRE(_tail_recursion(0) == 1); | |||
REQUIRE(_tail_recursion(1) == 1); |
@@ -49,10 +49,10 @@ uint32_t MHook_Hooks::hookRDRAND(void) { | |||
return trueRDRAND(); | |||
} | |||
uint32_t MHook_Hooks::hookLoop(uint32_t num, uint32_t cnt) { | |||
uint32_t MHook_Hooks::hookLoop(uint32_t x) { | |||
g_mhook->loop = true; | |||
return trueLoop(num, cnt); | |||
return trueLoop(x); | |||
} | |||
uint32_t MHook_Hooks::hookTail_recursion(uint32_t x) { |
@@ -6,7 +6,7 @@ namespace MHook_Hooks { | |||
uint64_t hookRip_relative(void); | |||
void hookAVX(float num, void* res); | |||
uint32_t hookRDRAND(void); | |||
uint32_t hookLoop(uint32_t num, uint32_t cnt); | |||
uint32_t hookLoop(uint32_t x); | |||
uint32_t hookTail_recursion(uint32_t x); | |||
}; | |||
@@ -25,6 +25,6 @@ public: | |||
friend void MHook_Hooks::hookAVX(float num, void* res); | |||
friend uint32_t MHook_Hooks::hookRDRAND(void); | |||
friend uint32_t MHook_Hooks::hookLoop(uint32_t num, uint32_t cnt); | |||
friend uint32_t MHook_Hooks::hookLoop(uint32_t x); | |||
friend uint32_t MHook_Hooks::hookTail_recursion(uint32_t x); | |||
}; |
@@ -50,10 +50,10 @@ uint32_t MinHook_Hooks::hookRDRAND(void) { | |||
return trueRDRAND(); | |||
} | |||
uint32_t MinHook_Hooks::hookLoop(uint32_t num, uint32_t cnt) { | |||
uint32_t MinHook_Hooks::hookLoop(uint32_t x) { | |||
g_MinHook->loop = true; | |||
return trueLoop(num, cnt); | |||
return trueLoop(x); | |||
} | |||
uint32_t MinHook_Hooks::hookTail_recursion(uint32_t x) { |
@@ -6,7 +6,7 @@ namespace MinHook_Hooks { | |||
uint64_t hookRip_relative(void); | |||
void hookAVX(float num, void* res); | |||
uint32_t hookRDRAND(void); | |||
uint32_t hookLoop(uint32_t num, uint32_t cnt); | |||
uint32_t hookLoop(uint32_t x); | |||
uint32_t hookTail_recursion(uint32_t x); | |||
}; | |||
@@ -28,6 +28,6 @@ public: | |||
friend void MinHook_Hooks::hookAVX(float num, void* res); | |||
friend uint32_t MinHook_Hooks::hookRDRAND(void); | |||
friend uint32_t MinHook_Hooks::hookLoop(uint32_t num, uint32_t cnt); | |||
friend uint32_t MinHook_Hooks::hookLoop(uint32_t x); | |||
friend uint32_t MinHook_Hooks::hookTail_recursion(uint32_t x); | |||
}; |
@@ -49,10 +49,10 @@ uint32_t PolyHook_Hooks::hookRDRAND(void) { | |||
return trueRDRAND(); | |||
} | |||
uint32_t PolyHook_Hooks::hookLoop(uint32_t num, uint32_t cnt) { | |||
uint32_t PolyHook_Hooks::hookLoop(uint32_t x) { | |||
g_PolyHook->loop = true; | |||
return trueLoop(num, cnt); | |||
return trueLoop(x); | |||
} | |||
uint32_t PolyHook_Hooks::hookTail_recursion(uint32_t x) { |
@@ -6,7 +6,7 @@ namespace PolyHook_Hooks { | |||
uint64_t hookRip_relative(void); | |||
void hookAVX(float num, void* res); | |||
uint32_t hookRDRAND(void); | |||
uint32_t hookLoop(uint32_t num, uint32_t cnt); | |||
uint32_t hookLoop(uint32_t x); | |||
uint32_t hookTail_recursion(uint32_t x); | |||
}; | |||
@@ -58,6 +58,6 @@ public: | |||
friend void PolyHook_Hooks::hookAVX(float num, void* res); | |||
friend uint32_t PolyHook_Hooks::hookRDRAND(void); | |||
friend uint32_t PolyHook_Hooks::hookLoop(uint32_t num, uint32_t cnt); | |||
friend uint32_t PolyHook_Hooks::hookLoop(uint32_t num); | |||
friend uint32_t PolyHook_Hooks::hookTail_recursion(uint32_t x); | |||
}; |
@@ -11,6 +11,6 @@ typedef void (*TypeAVX)(float num, void* res); | |||
typedef uint32_t (*TypeRDRAND)(void); | |||
typedef uint32_t (*TypeLoop)(uint32_t num, uint32_t cnt); | |||
typedef uint32_t (*TypeLoop)(uint32_t num); | |||
typedef uint32_t (*TypeTailRecursion)(uint32_t x); |