diff --git a/hook_tests/advanced_instructions.asm b/hook_tests/advanced_instructions.asm new file mode 100644 index 0000000..61a961a --- /dev/null +++ b/hook_tests/advanced_instructions.asm @@ -0,0 +1,17 @@ +format ms64 coff + +section '.text' code readable executable + +use64 + +public _AVX +_AVX: + vbroadcastsd ymm0, xmm0 ; load @num into all slots + vsqrtpd ymm0, ymm0 + vmovdqu [rdx], ymm0 ; store result in @res + ret + +public _RDRAND +_RDRAND: + rdrand eax + ret \ No newline at end of file diff --git a/hook_tests/advanced_instructions.h b/hook_tests/advanced_instructions.h new file mode 100644 index 0000000..0a3d10f --- /dev/null +++ b/hook_tests/advanced_instructions.h @@ -0,0 +1,15 @@ +#pragma once +extern "C" { + /** + * Gets the square root of num four times and writes it to @res + * + * @param num: the number of which the square root shall be taken + * @param res: where the 4 results shall be written + */ + void _AVX(float num, void* res); + + /** + * Just a wrapper around RDRAND + */ + uint32_t _RDRAND(void); +} \ No newline at end of file diff --git a/hook_tests/hook_tests.vcxproj b/hook_tests/hook_tests.vcxproj index 161087d..6cb97a6 100644 --- a/hook_tests/hook_tests.vcxproj +++ b/hook_tests/hook_tests.vcxproj @@ -146,6 +146,7 @@ + @@ -153,10 +154,12 @@ + + diff --git a/hook_tests/hook_tests.vcxproj.filters b/hook_tests/hook_tests.vcxproj.filters index f8bad68..eadae6b 100644 --- a/hook_tests/hook_tests.vcxproj.filters +++ b/hook_tests/hook_tests.vcxproj.filters @@ -21,6 +21,9 @@ Header Files + + Header Files + @@ -32,8 +35,12 @@ Source Files + + Source Files + + \ No newline at end of file diff --git a/hook_tests/main.cpp b/hook_tests/main.cpp index 907b222..335b2a9 100644 --- a/hook_tests/main.cpp +++ b/hook_tests/main.cpp @@ -4,8 +4,9 @@ #define CATCH_CONFIG_MAIN #include "catch.hpp" #include "simple_tests.h" +#include "advanced_instructions.h" -TEST_CASE("Functions work as expected, unhooked") { +TEST_CASE("Simple functions work as expected, unhooked") { REQUIRE(_small() == 0); REQUIRE(_branch(1) == 0); @@ -14,4 +15,13 @@ TEST_CASE("Functions work as expected, unhooked") { for (int i = 0; i < 1000; i++) { REQUIRE(_rip_relative() == rand()); } +} + +TEST_CASE("Advanced instruction functions work as expected, unhokked") { + double result[4]; + _AVX(9., static_cast(result)); + REQUIRE((result[0] - result[1]) < DBL_EPSILON); + REQUIRE((result[1] - result[2]) < DBL_EPSILON); + REQUIRE((result[2] - result[3]) < DBL_EPSILON); + REQUIRE((result[0] - 3.) < DBL_EPSILON); } \ No newline at end of file