From 9bbca712b613058d41f38a7614b3a822192e2b1c Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Wed, 18 Apr 2018 00:50:26 +0200 Subject: [PATCH] Fix detouring |thiscall| on linux The this-pointer is always pushed first on the stack. --- DynamicHooks/conventions/x86GccThiscall.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/DynamicHooks/conventions/x86GccThiscall.h b/DynamicHooks/conventions/x86GccThiscall.h index d754dbc..a742157 100644 --- a/DynamicHooks/conventions/x86GccThiscall.h +++ b/DynamicHooks/conventions/x86GccThiscall.h @@ -40,7 +40,19 @@ // ============================================================================ // >> CLASSES // ============================================================================ -typedef x86GccCdecl x86GccThiscall; - +class x86GccThiscall: public x86GccCdecl +{ +public: + x86GccThiscall(ke::Vector &vecArgTypes, DataTypeSized_t returnType, int iAlignment = 4) : + x86GccCdecl(vecArgTypes, returnType, iAlignment) + { + // Always add the |this| pointer. + DataTypeSized_t type; + type.type = DATA_TYPE_POINTER; + type.size = GetDataTypeSize(type, iAlignment); + type.custom_register = None; + m_vecArgTypes.insert(0, type); + } +}; #endif // _X86_GCC_THISCALL_H \ No newline at end of file