renames
This commit is contained in:
parent
5e76138b53
commit
327dfb0cb7
5 changed files with 34 additions and 34 deletions
|
|
@ -6,36 +6,36 @@
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "test_func.h"
|
||||
#include "lib_function.h"
|
||||
int (*realLibFunction)() = libFunction;
|
||||
|
||||
static int testFunctionDetourCounter = 0;
|
||||
int testFunctionDetour()
|
||||
static int libFunctionDetourCounter = 0;
|
||||
int libFunctionDetour()
|
||||
{
|
||||
testFunctionDetourCounter++;
|
||||
libFunctionDetourCounter++;
|
||||
return 94;
|
||||
}
|
||||
|
||||
TEST_CASE( "Overriding custom function in dylib" )
|
||||
{
|
||||
int (*realTestFunction)() = testFunction;
|
||||
testFunctionCounter = 0;
|
||||
testFunctionDetourCounter = 0;
|
||||
libFunctionCounter = 0;
|
||||
libFunctionDetourCounter = 0;
|
||||
|
||||
REQUIRE( testFunction() == 42 );
|
||||
REQUIRE( testFunctionCounter == 1 );
|
||||
REQUIRE( testFunctionDetourCounter == 0 );
|
||||
REQUIRE( libFunction() == 42 );
|
||||
REQUIRE( libFunctionCounter == 1 );
|
||||
REQUIRE( libFunctionDetourCounter == 0 );
|
||||
|
||||
CHECK( detour_transaction_begin() == err_none );
|
||||
CHECK( detour_attach(reinterpret_cast<detour_func_t*>(&realTestFunction), reinterpret_cast<detour_func_t>(testFunctionDetour)) == err_none );
|
||||
CHECK( detour_attach(reinterpret_cast<detour_func_t*>(&realLibFunction), reinterpret_cast<detour_func_t>(libFunctionDetour)) == err_none );
|
||||
CHECK( detour_transaction_commit() == err_none );
|
||||
|
||||
REQUIRE( realTestFunction != testFunction );
|
||||
REQUIRE( realLibFunction != libFunction );
|
||||
|
||||
REQUIRE( testFunctionCounter == 1 );
|
||||
REQUIRE( testFunctionDetourCounter == 0 );
|
||||
REQUIRE( testFunction() == 94 );
|
||||
REQUIRE( testFunctionCounter == 1 );
|
||||
REQUIRE( testFunctionDetourCounter == 1 );
|
||||
REQUIRE( libFunctionCounter == 1 );
|
||||
REQUIRE( libFunctionDetourCounter == 0 );
|
||||
REQUIRE( libFunction() == 94 );
|
||||
REQUIRE( libFunctionCounter == 1 );
|
||||
REQUIRE( libFunctionDetourCounter == 1 );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue