Whew, massive-ish reorgranization for extensions and such. I will inevitably be shot for this.
(Yes, bail, it all compiles on both platforms)
3 * ===============================================================
4 * SourceMod BinTools Extension
5 * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
6 * ===============================================================
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 #include "extension.h"
25 #include "CallWrapper.h"
27 CallWrapper::CallWrapper(CallConvention cv, const PassInfo *paramInfo, const PassInfo *retInfo, unsigned int numParams)
33 m_Params = new PassEncode[numParams];
34 for (size_t i=0; i<numParams; i++)
36 m_Params[i].info = paramInfo[i];
42 m_RetParam = new PassInfo;
43 *m_RetParam = *retInfo;
48 m_NumParams = numParams;
50 /* Calculate virtual stack offsets for each parameter */
53 if (cv == CallConv_ThisCall)
55 offs += sizeof(void *);
57 for (size_t i=0; i<numParams; i++)
59 m_Params[i].offset = offs;
60 offs += m_Params[i].info.size;
64 CallWrapper::~CallWrapper()
68 g_SPEngine->ExecFree(m_Addrs[ADDR_CODEBASE]);
71 CallConvention CallWrapper::GetCallConvention()
76 const PassEncode *CallWrapper::GetParamInfo(unsigned int num)
78 return (num+1 > m_NumParams) ? NULL : &m_Params[num];
81 const PassInfo *CallWrapper::GetReturnInfo()
86 unsigned int CallWrapper::GetParamCount()
91 void CallWrapper::Execute(void *vParamStack, void *retBuffer)
93 typedef void (*CALL_EXECUTE)(void *, void *);
94 CALL_EXECUTE fn = (CALL_EXECUTE)m_Addrs[ADDR_CODEBASE];
95 fn(vParamStack, retBuffer);