TsudaKageyu / minhook

The Minimalistic x86/x64 API Hooking Library for Windows
http://www.codeproject.com/KB/winsdk/LibMinHook.aspx
Other
4.43k stars 897 forks source link

Defines #36

Closed ZLOFENIX closed 7 years ago

ZLOFENIX commented 7 years ago

Can you add checks for x32 and x64 builds? Because cotire unity build makes all as one file and defines for x32 and x64 in table*.h redefines each other.

TsudaKageyu commented 7 years ago

Can you provide me with the specific error messages?

ZLOFENIX commented 7 years ago
[ 93%] Building C object minhook/CMakeFiles/minhook_unity.dir/cotire/minhook_C_unity.c.obj
In file included from minhook/HDE/hde32.c:8:0,
                 from /build/minhook/cotire/minhook_C_unity.c:5:
minhook/HDE/hde32.h:29:0: warning: "F_DISP8" redefined
 #define F_DISP8         0x00000020

In file included from minhook/trampoline.c:37:0,
                 from /build/minhook/cotire/minhook_C_unity.c:4:
minhook/HDE/hde64.h:30:0: note: this is the location of the previous definition
 #define F_DISP8         0x00000040

In file included from minhook/HDE/hde32.c:8:0,
                 from /build/minhook/cotire/minhook_C_unity.c:5:
minhook/HDE/hde32.h:30:0: warning: "F_DISP16" redefined
 #define F_DISP16        0x00000040

In file included from minhook/trampoline.c:37:0,
                 from /build/minhook/cotire/minhook_C_unity.c:4:
minhook/HDE/hde64.h:31:0: note: this is the location of the previous definition
 #define F_DISP16        0x00000080

In file included from minhook/HDE/hde32.c:8:0,
                 from /build/minhook/cotire/minhook_C_unity.c:5:
minhook/HDE/hde32.h:31:0: warning: "F_DISP32" redefined
 #define F_DISP32        0x00000080

In file included from minhook/trampoline.c:37:0,
                 from /build/minhook/cotire/minhook_C_unity.c:4:
minhook/HDE/hde64.h:32:0: note: this is the location of the previous definition
 #define F_DISP32        0x00000100

In file included from minhook/HDE/hde32.c:8:0,
                 from /build/minhook/cotire/minhook_C_unity.c:5:
minhook/HDE/hde32.h:32:0: warning: "F_RELATIVE" redefined
 #define F_RELATIVE      0x00000100

In file included from minhook/trampoline.c:37:0,
                 from /build/minhook/cotire/minhook_C_unity.c:4:
minhook/HDE/hde64.h:33:0: note: this is the location of the previous definition
 #define F_RELATIVE      0x00000200

In file included from minhook/HDE/hde32.c:8:0,
                 from /build/minhook/cotire/minhook_C_unity.c:5:
minhook/HDE/hde32.h:46:0: warning: "F_PREFIX_ANY" redefined
 #define F_PREFIX_ANY    0x3f000000

In file included from minhook/trampoline.c:37:0,
                 from /build/minhook/cotire/minhook_C_unity.c:4:
minhook/HDE/hde64.h:47:0: note: this is the location of the previous definition
 #define F_PREFIX_ANY    0x7f000000

In file included from minhook/HDE/hde64.c:9:0,
                 from /build/minhook/cotire/minhook_C_unity.c:6:
minhook/HDE/table64.h:29:0: warning: "DELTA_FPU_REG" redefined
 #define DELTA_FPU_REG      0xfd

In file included from minhook/HDE/hde32.c:9:0,
                 from /build/minhook/cotire/minhook_C_unity.c:5:
minhook/HDE/table32.h:29:0: note: this is the location of the previous definition
 #define DELTA_FPU_REG      0xf1

In file included from minhook/HDE/hde64.c:9:0,
                 from /build/minhook/cotire/minhook_C_unity.c:6:
minhook/HDE/table64.h:30:0: warning: "DELTA_FPU_MODRM" redefined
 #define DELTA_FPU_MODRM    0x104

In file included from minhook/HDE/hde32.c:9:0,
                 from /build/minhook/cotire/minhook_C_unity.c:5:
minhook/HDE/table32.h:30:0: note: this is the location of the previous definition
 #define DELTA_FPU_MODRM    0xf8

In file included from minhook/HDE/hde64.c:9:0,
                 from /build/minhook/cotire/minhook_C_unity.c:6:
minhook/HDE/table64.h:31:0: warning: "DELTA_PREFIXES" redefined
 #define DELTA_PREFIXES     0x13c

In file included from minhook/HDE/hde32.c:9:0,
                 from /build/minhook/cotire/minhook_C_unity.c:5:
minhook/HDE/table32.h:31:0: note: this is the location of the previous definition
 #define DELTA_PREFIXES     0x130

In file included from minhook/HDE/hde64.c:9:0,
                 from /build/minhook/cotire/minhook_C_unity.c:6:
minhook/HDE/table64.h:32:0: warning: "DELTA_OP_LOCK_OK" redefined
 #define DELTA_OP_LOCK_OK   0x1ae

In file included from minhook/HDE/hde32.c:9:0,
                 from /build/minhook/cotire/minhook_C_unity.c:5:
minhook/HDE/table32.h:32:0: note: this is the location of the previous definition
 #define DELTA_OP_LOCK_OK   0x1a1

In file included from minhook/HDE/hde64.c:9:0,
                 from /build/minhook/cotire/minhook_C_unity.c:6:
minhook/HDE/table64.h:33:0: warning: "DELTA_OP2_LOCK_OK" redefined
 #define DELTA_OP2_LOCK_OK  0x1c6

In file included from minhook/HDE/hde32.c:9:0,
                 from /build/minhook/cotire/minhook_C_unity.c:5:
minhook/HDE/table32.h:33:0: note: this is the location of the previous definition
 #define DELTA_OP2_LOCK_OK  0x1b9

In file included from minhook/HDE/hde64.c:9:0,
                 from /build/minhook/cotire/minhook_C_unity.c:6:
minhook/HDE/table64.h:34:0: warning: "DELTA_OP_ONLY_MEM" redefined
 #define DELTA_OP_ONLY_MEM  0x1d8

In file included from minhook/HDE/hde32.c:9:0,
                 from /build/minhook/cotire/minhook_C_unity.c:5:
minhook/HDE/table32.h:34:0: note: this is the location of the previous definition
 #define DELTA_OP_ONLY_MEM  0x1cb

In file included from minhook/HDE/hde64.c:9:0,
                 from /build/minhook/cotire/minhook_C_unity.c:6:
minhook/HDE/table64.h:35:0: warning: "DELTA_OP2_ONLY_MEM" redefined
 #define DELTA_OP2_ONLY_MEM 0x1e7

In file included from minhook/HDE/hde32.c:9:0,
                 from /build/minhook/cotire/minhook_C_unity.c:5:
minhook/HDE/table32.h:35:0: note: this is the location of the previous definition
 #define DELTA_OP2_ONLY_MEM 0x1da
TsudaKageyu commented 7 years ago

I see. Thanks!

ZLOFENIX commented 7 years ago

Also my CMakeLists.txt

project(minhook C)
file(GLOB_RECURSE src *.c *.h)
include_directories(
  ${CMAKE_BINARY_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}
)
add_library(minhook STATIC ${src})
target_link_libraries(minhook)
set_target_properties(minhook PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "MinHook.h")
cotire(minhook)
TsudaKageyu commented 7 years ago

I updated the code. Does it work?

ZLOFENIX commented 7 years ago

Yes, all ok now. Only one warning: hook.c:249:12: warning: ‘enable’ may be used uninitialized in this function

TsudaKageyu commented 7 years ago

That warning is a "False Positive". Actually, enable is always initialized. Anyway I will close this issue.

ZLOFENIX commented 7 years ago

Simple BOOL enable = FALSE; and problem solved.

TsudaKageyu commented 7 years ago

Or use default: instead of case ACTION_APPLY_QUEUED:. I think it's a bit more logical than initializing enable with FALSE.

ZLOFENIX commented 7 years ago

_M_IX86 and _M_X64 not defined in C. __x86_64__ works on mingw.

TsudaKageyu commented 7 years ago

I did it. Does it work?

ZLOFENIX commented 7 years ago

Will work, i think, but you have _M_X64 checks in other files.

TsudaKageyu commented 7 years ago

You are right. I have added checks for the __x86_64__ macro.

ZLOFENIX commented 7 years ago

Nice.