mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-01-19 08:52:34 +01:00
Fixed crashes in code generated by SourceHook's HookManGen on Mac OS X (bug 3514, r=dvander).
This fixes two problems: 1) On OS X structures/objects with sizes of 1, 2, 4, or 8 are returned from functions in registers, not memory addresses. 2) A function returning anything which was 8 bytes in size was crashing. This problem affected all compilers/operating systems.
This commit is contained in:
parent
2e4b4c9f62
commit
d1e8ae40af
@ -1,5 +1,5 @@
|
|||||||
/* ======== SourceHook ========
|
/* ======== SourceHook ========
|
||||||
* Copyright (C) 2004-2008 Metamod:Source Development Team
|
* Copyright (C) 2004-2009 Metamod:Source Development Team
|
||||||
* No warranties of any kind
|
* No warranties of any kind
|
||||||
*
|
*
|
||||||
* License: zlib/libpng
|
* License: zlib/libpng
|
||||||
@ -873,7 +873,7 @@ namespace SourceHook
|
|||||||
// mov eax, [ecx]
|
// mov eax, [ecx]
|
||||||
// mov edx, [ecx+4]
|
// mov edx, [ecx+4]
|
||||||
IA32_Mov_Reg_Rm(&m_HookFunc, REG_EAX, REG_ECX, MOD_MEM_REG);
|
IA32_Mov_Reg_Rm(&m_HookFunc, REG_EAX, REG_ECX, MOD_MEM_REG);
|
||||||
IA32_Mov_Reg_Rm_DispAuto(&m_HookFunc, REG_EAX, REG_ECX, 4);
|
IA32_Mov_Reg_Rm_DispAuto(&m_HookFunc, REG_EDX, REG_ECX, 4);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1869,8 +1869,18 @@ namespace SourceHook
|
|||||||
// MSVC seems to return _all_ structs, classes, unions in memory
|
// MSVC seems to return _all_ structs, classes, unions in memory
|
||||||
pi.flags |= PassInfo::PassFlag_RetMem;
|
pi.flags |= PassInfo::PassFlag_RetMem;
|
||||||
#elif SH_COMP == SH_COMP_GCC
|
#elif SH_COMP == SH_COMP_GCC
|
||||||
// Same goes for GCC :)
|
#if SH_SYS == SH_SYS_APPLE
|
||||||
|
// Apple GCC returns in memory if size isn't a power of 2 or > 8
|
||||||
|
if ((pi.size & (pi.size - 1)) == 0 && pi.size <= 8)
|
||||||
|
{
|
||||||
|
pi.flags |= PassInfo::PassFlag_RetReg;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
// GCC on Linux does same thing as MSVC
|
||||||
pi.flags |= PassInfo::PassFlag_RetMem;
|
pi.flags |= PassInfo::PassFlag_RetMem;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#(C)2004-2008 SourceMM Development Team
|
# (C)2004-2009 Metamod:Source Development Team
|
||||||
# Makefile written by David "BAILOPAN" Anderson and Pavol Marko
|
# Makefile written by David "BAILOPAN" Anderson and Pavol Marko
|
||||||
|
|
||||||
OPT_FLAGS = -O3 -funroll-loops -s -pipe
|
OPT_FLAGS = -O3 -funroll-loops -s -pipe
|
||||||
@ -9,7 +9,7 @@ INCLUDE = -I. -I..
|
|||||||
MAX_PARAMS=20
|
MAX_PARAMS=20
|
||||||
|
|
||||||
BINARY = sourcehook_test
|
BINARY = sourcehook_test
|
||||||
OBJECTS = main.cpp sourcehook.cpp ../sourcehook_hookmangen.cpp $(shell ls -t test*.cpp)
|
OBJECTS = main.cpp sourcehook.cpp sourcehook_hookmangen.cpp $(shell ls -t test*.cpp)
|
||||||
HEADERS = ../sh_list.h ../sh_tinyhash.h ../sh_memory.h ../sh_string.h ../sh_vector.h ../sourcehook_impl.h ../FastDelegate.h ../sourcehook.h ../sh_memfuncinfo.h
|
HEADERS = ../sh_list.h ../sh_tinyhash.h ../sh_memory.h ../sh_string.h ../sh_vector.h ../sourcehook_impl.h ../FastDelegate.h ../sourcehook.h ../sh_memfuncinfo.h
|
||||||
|
|
||||||
ifeq "$(DEBUG)" "true"
|
ifeq "$(DEBUG)" "true"
|
||||||
@ -46,10 +46,12 @@ debug:
|
|||||||
|
|
||||||
all:
|
all:
|
||||||
mkdir -p $(BIN_DIR)
|
mkdir -p $(BIN_DIR)
|
||||||
ln -sf ../sourcehook.cpp sourcehook.cpp
|
ln -sf ../sourcehook.cpp
|
||||||
|
ln -sf ../sourcehook_hookmangen.cpp
|
||||||
$(MAKE) $(BINARY)
|
$(MAKE) $(BINARY)
|
||||||
rm -f $(BINARY)
|
rm -f $(BINARY)
|
||||||
rm -f sourcehook.cpp
|
rm -f sourcehook.cpp
|
||||||
|
rm -f sourcehook_hookmangen.cpp
|
||||||
ln -sf $(BIN_DIR)/$(BINARY) $(BINARY)
|
ln -sf $(BIN_DIR)/$(BINARY) $(BINARY)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user