sourcehook/sourcehook_hookmangen.cpp
branchhookman_autogen
changeset 475 20898390f369
parent 474 5ae85f004e81
child 476 cd2b9feb4205
     1.1 --- a/sourcehook/sourcehook_hookmangen.cpp	Sat Nov 24 23:02:35 2007 +0000
     1.2 +++ b/sourcehook/sourcehook_hookmangen.cpp	Sun Nov 25 00:05:02 2007 +0000
     1.3 @@ -243,11 +243,11 @@
     1.4  
     1.5  		void GenContext::CheckAlignmentBeforeCall()
     1.6  		{
     1.7 -#if 0
     1.8 +//#if 0
     1.9  			IA32_Test_Rm_Imm32(&m_HookFunc, REG_ESP, 15, MOD_REG);
    1.10  			IA32_Jump_Cond_Imm8(&m_HookFunc, CC_Z, 1);
    1.11  			IA32_Int3(&m_HookFunc);
    1.12 -#endif
    1.13 +//#endif
    1.14  		}
    1.15  
    1.16  		short GenContext::GetParamsTotalStackSize()
    1.17 @@ -400,10 +400,8 @@
    1.18  				IA32_Mov_Reg_Imm32(&m_HookFunc, REG_EDX, DownCastPtr(pi.pCopyCtor));
    1.19  				IA32_Call_Reg(&m_HookFunc, REG_EDX);
    1.20  
    1.21 -				// gcc: pop this ptr off the stack
    1.22 -				GCC_ONLY(IA32_Pop_Reg(&m_HookFunc, REG_ECX));
    1.23 -				// pop other params off the stack
    1.24 -				IA32_Pop_Reg(&m_HookFunc, REG_EAX);
    1.25 +				// gcc: clean up stack
    1.26 +				GCC_ONLY(IA32_Add_Rm_ImmAuto(&m_HookFunc, REG_ESP, 2 * SIZE_PTR, MOD_REG));
    1.27  
    1.28  				// restore eax
    1.29  				IA32_Pop_Reg(&m_HookFunc, REG_EAX);
    1.30 @@ -573,7 +571,7 @@
    1.31  						IA32_Mov_Reg_Imm32(&m_HookFunc, REG_EAX, DownCastPtr(m_Proto.GetRet().pAssignOperator));
    1.32  						CheckAlignmentBeforeCall();
    1.33  						IA32_Call_Reg(&m_HookFunc, REG_EAX);
    1.34 -						GCC_ONLY(IA32_Pop_Reg(&m_HookFunc, REG_ECX));
    1.35 +						GCC_ONLY(IA32_Add_Rm_ImmAuto(&m_HookFunc, REG_ESP, 2 * SIZE_PTR, MOD_REG));
    1.36  
    1.37  						AlignStackAfterCall(tmpAlign);
    1.38  					}
    1.39 @@ -1006,16 +1004,16 @@
    1.40  			IA32_Call_Reg(&m_HookFunc, REG_EAX);
    1.41  
    1.42  			AlignStackAfterCall(alignBytes);
    1.43 +			
    1.44 +			// cleanup (gcc only)
    1.45 +			//   params + thisptr
    1.46 +			if (SH_COMP == SH_COMP_GCC)
    1.47 +				IA32_Add_Rm_ImmAuto(&m_HookFunc, REG_ESP, caller_clean_bytes + SIZE_PTR, MOD_REG);
    1.48  
    1.49  			DestroyParams(v_place_fbrr_base);
    1.50  
    1.51  			SaveRetVal(v_plugin_ret, v_place_for_memret);
    1.52  
    1.53 -			// cleanup (gcc only)
    1.54 -			//   params + thisptr
    1.55 -			if (SH_COMP == SH_COMP_GCC)
    1.56 -				IA32_Add_Rm_ImmAuto(&m_HookFunc, REG_ESP, caller_clean_bytes + SIZE_PTR, MOD_REG);
    1.57 -
    1.58  			// process meta return:
    1.59  			//  prev_res = cur_res
    1.60  			//  if (cur_res > status) status = cur_res;
    1.61 @@ -1517,7 +1515,7 @@
    1.62  			{
    1.63  				// vsnprintf
    1.64  				
    1.65 -				jit_int32_t tmpAlign = AlignStackBeforeCall(SIZE_PTR*3 + sizeof(size_t), AlignStack_GCC_ThisOnStack);
    1.66 +				jit_int32_t tmpAlign = AlignStackBeforeCall(SIZE_PTR*3 + sizeof(size_t), 0);
    1.67  
    1.68  				// push valist, fmt param, maxsize, buffer
    1.69  				IA32_Push_Reg(&m_HookFunc, REG_EAX);