Skip to content

Commit

Permalink
Update funchook.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Aug 6, 2024
1 parent 90bfdb9 commit 1952b89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion source/detours/funchook_detour/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set(target_depends funchook_detour_depends)

include(ExternalProject)

set(FUNCHOOK_VERSION 1.1.1)
set(FUNCHOOK_VERSION 1.1.3)

if(WIN32)
set(FUNCHOOK_LIBRARY_PREFIX "")
Expand Down
14 changes: 9 additions & 5 deletions source/tests/detour_test/source/detour_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,26 @@ static detour_handle handle;

int hook_function(int x)
{
EXPECT_EQ((int)2, (int)x);
EXPECT_EQ((int)128, (int)x);

log_write("metacall", LOG_LEVEL_DEBUG, "Hook function %d", x);

int (*target_function_ptr)(int) = (int (*)(int))detour_trampoline(handle);

return target_function_ptr(x + 4) + 2;
int result = target_function_ptr(x + 2) + 2;

log_write("metacall", LOG_LEVEL_DEBUG, "Hook function result %d", result);

return result;
}

int target_function(int x)
{
EXPECT_EQ((int)6, (int)x);
EXPECT_EQ((int)130, (int)x);

log_write("metacall", LOG_LEVEL_DEBUG, "Target function %d", x);

return 4;
return x;
}

TEST_F(detour_test, DefaultConstructor)
Expand Down Expand Up @@ -80,7 +84,7 @@ TEST_F(detour_test, DefaultConstructor)
EXPECT_NE((detour_handle)NULL, (detour_handle)handle);

/* Call detour, it should call hooked function */
EXPECT_EQ((int)6, (int)target_function(2));
EXPECT_EQ((int)132, (int)target_function(128));

/* Uninstall detour */
EXPECT_EQ((int)0, (int)detour_uninstall(d, handle));
Expand Down

0 comments on commit 1952b89

Please sign in to comment.