mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2024-12-01 13:24:25 +01:00
First support attempt for reference returns
--HG-- branch : hookman_autogen extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/branches/hookman_autogen%40538
This commit is contained in:
parent
ebf7cf8fee
commit
2c8203f263
@ -380,13 +380,22 @@ namespace SourceHook
|
||||
|
||||
void GenContext::SaveRetVal(int v_where, int v_place_for_memret)
|
||||
{
|
||||
size_t size = m_Proto.GetRet().size;
|
||||
size_t size = GetRealSize(m_Proto.GetRet());
|
||||
if (size == 0)
|
||||
{
|
||||
// No return value -> nothing
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Proto.GetRet().flags & PassInfo::PassFlag_ByRef)
|
||||
{
|
||||
// mov [ebp + v_plugin_ret], eax
|
||||
IA32_Mov_Rm_Reg_DispAuto(&m_HookFunc, REG_EBP, REG_EAX, v_where);
|
||||
return;
|
||||
}
|
||||
// else: ByVal
|
||||
|
||||
|
||||
// Memory return:
|
||||
if (m_Proto.GetRet().flags & PassInfo::PassFlag_RetMem)
|
||||
{
|
||||
@ -557,6 +566,15 @@ namespace SourceHook
|
||||
|
||||
|
||||
// *eax = plugin_ret
|
||||
if (m_Proto.GetRet().flags & PassInfo::PassFlag_ByRef)
|
||||
{
|
||||
// mov ecx, [ebp+v_plugin_ret]
|
||||
// mov [eax], ecx
|
||||
IA32_Mov_Reg_Rm_DispAuto(&m_HookFunc, REG_ECX, REG_EBP, v_plugin_ret);
|
||||
IA32_Mov_Rm_Reg(&m_HookFunc, REG_EAX, REG_ECX, MOD_MEM_REG);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Proto.GetRet().pAssignOperator)
|
||||
{
|
||||
// lea edx, [ebp + v_plugin_ret]
|
||||
@ -588,6 +606,7 @@ namespace SourceHook
|
||||
|
||||
BitwiseCopy_Do(m_Proto.GetRet().size);
|
||||
}
|
||||
}
|
||||
|
||||
m_HookFunc.end_count(counter);
|
||||
m_HookFunc.rewrite(tmppos, static_cast<jit_uint8_t>(counter));
|
||||
@ -649,12 +668,18 @@ namespace SourceHook
|
||||
if (!size)
|
||||
return;
|
||||
|
||||
// :TODO: memory return support
|
||||
|
||||
// Get real ret pointer into ecx
|
||||
// mov ecx, [ebp + v_ret_ptr]
|
||||
IA32_Mov_Reg_Rm_DispAuto(&m_HookFunc, REG_ECX, REG_EBP, v_retptr);
|
||||
|
||||
if (m_Proto.GetRet().flags & PassInfo::PassFlag_ByRef)
|
||||
{
|
||||
// mov eax, [ecx]
|
||||
IA32_Mov_Reg_Rm(&m_HookFunc, REG_EAX, REG_ECX, MOD_MEM_REG);
|
||||
return;
|
||||
}
|
||||
// else: byval
|
||||
|
||||
if (m_Proto.GetRet().type == PassInfo::PassType_Float)
|
||||
{
|
||||
if (size == 4)
|
||||
@ -1441,6 +1466,12 @@ namespace SourceHook
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// byref: make sure that the flag is _not_ set
|
||||
pi.flags &= ~PassInfo::PassFlag_RetMem;
|
||||
pi.flags |= PassInfo::PassFlag_RetReg;
|
||||
}
|
||||
}
|
||||
|
||||
HookManagerPubFunc GenContext::Generate()
|
||||
|
@ -371,7 +371,6 @@ namespace
|
||||
THGM_SETUP_RI(110, ObjRet13, SourceHook::PassInfo::PassType_Object,
|
||||
SourceHook::PassInfo::PassFlag_ByVal | SourceHook::PassInfo::PassFlag_OCtor | SourceHook::PassInfo::PassFlag_ODtor |
|
||||
SourceHook::PassInfo::PassFlag_CCtor | SourceHook::PassInfo::PassFlag_AssignOp);
|
||||
|
||||
}
|
||||
|
||||
bool TestHookManGen(std::string &error)
|
||||
|
Loading…
Reference in New Issue
Block a user