faluco@739: /** faluco@739: * vim: set ts=4 : faluco@739: * =============================================================== ds@757: * SourceMod BinTools Extension ds@757: * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. faluco@739: * =============================================================== faluco@739: * ds@757: * This program is free software; you can redistribute it and/or ds@757: * modify it under the terms of the GNU General Public License ds@757: * as published by the Free Software Foundation; either version 2 ds@757: * of the License, or (at your option) any later version. ds@757: * This program is distributed in the hope that it will be useful, ds@757: * but WITHOUT ANY WARRANTY; without even the implied warranty of ds@757: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ds@757: * GNU General Public License for more details. faluco@739: * ds@757: * You should have received a copy of the GNU General Public License ds@757: * along with this program; if not, write to the Free Software ds@757: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. faluco@739: * faluco@739: * Version: $Id$ faluco@739: */ faluco@739: faluco@739: #include "extension.h" faluco@739: #include "CallWrapper.h" faluco@739: faluco@739: CallWrapper::CallWrapper(CallConvention cv, const PassInfo *paramInfo, const PassInfo *retInfo, unsigned int numParams) faluco@739: { faluco@739: m_Cv = cv; faluco@739: faluco@739: if (numParams) faluco@739: { faluco@739: m_Params = new PassEncode[numParams]; faluco@739: for (size_t i=0; iExecFree(m_Addrs[ADDR_CODEBASE]); faluco@739: } faluco@739: dvander@942: void CallWrapper::Destroy() dvander@942: { dvander@942: delete this; dvander@942: } dvander@942: faluco@739: CallConvention CallWrapper::GetCallConvention() faluco@739: { faluco@739: return m_Cv; faluco@739: } faluco@739: faluco@739: const PassEncode *CallWrapper::GetParamInfo(unsigned int num) faluco@739: { faluco@739: return (num+1 > m_NumParams) ? NULL : &m_Params[num]; faluco@739: } faluco@739: faluco@739: const PassInfo *CallWrapper::GetReturnInfo() faluco@739: { faluco@739: return m_RetParam; faluco@739: } faluco@739: faluco@739: unsigned int CallWrapper::GetParamCount() faluco@739: { faluco@739: return m_NumParams; faluco@739: } faluco@739: faluco@739: void CallWrapper::Execute(void *vParamStack, void *retBuffer) faluco@739: { faluco@739: typedef void (*CALL_EXECUTE)(void *, void *); faluco@739: CALL_EXECUTE fn = (CALL_EXECUTE)m_Addrs[ADDR_CODEBASE]; faluco@739: fn(vParamStack, retBuffer); faluco@739: }