Skip to content

Commit

Permalink
Log Detour Hook creations
Browse files Browse the repository at this point in the history
  • Loading branch information
illusion0001 committed Jun 24, 2023
1 parent 2355053 commit fc6fa34
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ TARGETSTATIC := libGoldHEN_Hook.a
TARGETCRT := build/crtprx.o

# Libraries linked into the ELF.
LIBS := -lkernel -lSceLibcInternal -lSceSysmodule
LIBS := -lSceLibcInternal -lkernel -lSceSysmodule

LOG_TYPE = -D__USE_KLOG__
DEBUG_FLAGS = -DDEBUG=0
Expand Down
12 changes: 4 additions & 8 deletions include/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ typedef unsigned long HA;
#define HA_MANYARGS HA arg1, HA arg2, HA arg3, HA arg4, HA arg5, HA arg6, HA arg7, HA arg8, HA arg9, HA arg10, HA arg11, HA arg12
#define MANYARGS arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12

#define klog printf

// if you need to define the hook in some header file, this only externs it.
#define HOOK_EXTERN(name) \
extern Detour Detour_##name
Expand All @@ -45,12 +47,14 @@ typedef unsigned long HA;

// this does a 64bit hook
#define HOOK(name) do { \
klog("%s:%d HOOK64() Create " #name "\n", __FUNCTION__, __LINE__); \
Detour_Construct( (&(Detour_##name)), DetourMode_x64); \
Detour_DetourFunction( (&(Detour_##name)), (uint64_t)name, (void *)(&(name##_hook)) ); \
} while (0)

// 32bit...
#define HOOK32(name) do { \
klog("%s:%d HOOK32() Create " #name "\n", __FUNCTION__, __LINE__); \
Detour_Construct( (&(Detour_##name)), DetourMode_x32); \
Detour_DetourFunction( (&(Detour_##name)), (uint64_t)name, (void *)(&(name##_hook)) ); \
} while (0)
Expand All @@ -61,14 +65,6 @@ typedef unsigned long HA;
// unhooks, killing the defined hook, CANNOT BE REUSED
#define UNHOOK(name) Detour_Destroy( (&(Detour_##name)) )

#ifdef __USE_PRINTF__
#define klog printf
#endif

#ifdef __USE_KLOG__
void klog(char* fmt, ...);
#endif

void hex_dump(void *data, size_t size);

#ifdef __cplusplus
Expand Down
16 changes: 0 additions & 16 deletions source/Utilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,6 @@

#include "Common.h"

#ifdef __USE_PRINTF__
#define klog printf
#endif

#ifdef __USE_KLOG__
void klog(char* fmt, ...) {
// DO NOT INITIALIZE WITH 0!!
char Buffer[255];
va_list args;
va_start(args, fmt);
vsnprintf(Buffer, sizeof(Buffer), fmt, args);
va_end(args);
sys_sdk_cmd(GOLDHEN_SDK_CMD_KLOG, Buffer);
}
#endif

void hex_dump(void *data, size_t size) {
unsigned char *p = (unsigned char *)data;
int i;
Expand Down

0 comments on commit fc6fa34

Please sign in to comment.