|
faluco@739
|
1 |
/** |
|
faluco@739
|
2 |
* vim: set ts=4 : |
|
dvander@1226
|
3 |
* ================================================================ |
|
ds@757
|
4 |
* SourceMod BinTools Extension |
|
dvander@1226
|
5 |
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. |
|
dvander@1226
|
6 |
* ================================================================ |
|
faluco@739
|
7 |
* |
|
dvander@1226
|
8 |
* This program is free software; you can redistribute it and/or |
|
dvander@1226
|
9 |
* modify it under the terms of the GNU General Public License, |
|
dvander@1226
|
10 |
* version 3.0, as published by the Free Software Foundation. |
|
dvander@1226
|
11 |
* |
|
ds@757
|
12 |
* This program is distributed in the hope that it will be useful, |
|
ds@757
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
ds@757
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
ds@757
|
15 |
* GNU General Public License for more details. |
|
dvander@1226
|
16 |
* |
|
ds@757
|
17 |
* You should have received a copy of the GNU General Public License |
|
dvander@1226
|
18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
dvander@1226
|
19 |
* |
|
dvander@1226
|
20 |
* As a special exception, AlliedModders LLC gives you permission to |
|
dvander@1226
|
21 |
* link the code of this program (as well as its derivative works) to |
|
dvander@1226
|
22 |
* "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any |
|
dvander@1226
|
23 |
* Game MODs that run on software by the Valve Corporation. You must |
|
dvander@1226
|
24 |
* obey the GNU General Public License in all respects for all other |
|
dvander@1226
|
25 |
* code used. Additionally, AlliedModders LLC grants this exception |
|
dvander@1226
|
26 |
* to all derivative works. AlliedModders LLC defines further |
|
dvander@1226
|
27 |
* exceptions, found in LICENSE.txt (as of this writing, version |
|
dvander@1226
|
28 |
* JULY-31-2007), or <http://www.sourcemod.net/license.php>. |
|
faluco@739
|
29 |
* |
|
faluco@739
|
30 |
* Version: $Id$ |
|
faluco@739
|
31 |
*/ |
|
faluco@739
|
32 |
|
|
faluco@739
|
33 |
#ifndef _INCLUDE_SOURCEMOD_CCALLWRAPPER_H_ |
|
faluco@739
|
34 |
#define _INCLUDE_SOURCEMOD_CCALLWRAPPER_H_ |
|
faluco@739
|
35 |
|
|
faluco@739
|
36 |
#include <IBinTools.h> |
|
faluco@739
|
37 |
|
|
faluco@739
|
38 |
using namespace SourceMod; |
|
faluco@739
|
39 |
|
|
faluco@739
|
40 |
#define ADDR_CALLEE 0 |
|
faluco@739
|
41 |
#define ADDR_CODEBASE 1 |
|
faluco@739
|
42 |
|
|
faluco@739
|
43 |
struct VtableInfo |
|
faluco@739
|
44 |
{ |
|
faluco@739
|
45 |
unsigned int vtblIdx; |
|
faluco@739
|
46 |
unsigned int vtblOffs; |
|
faluco@739
|
47 |
unsigned int thisOffs; |
|
faluco@739
|
48 |
}; |
|
faluco@739
|
49 |
|
|
faluco@739
|
50 |
class CallWrapper : public ICallWrapper |
|
faluco@739
|
51 |
{ |
|
faluco@739
|
52 |
public: |
|
faluco@739
|
53 |
CallWrapper(CallConvention cv, const PassInfo *paramInfo, const PassInfo *retInfo, unsigned int numParams); |
|
faluco@739
|
54 |
~CallWrapper(); |
|
faluco@739
|
55 |
public: //ICallWrapper |
|
faluco@739
|
56 |
CallConvention GetCallConvention(); |
|
faluco@739
|
57 |
const PassEncode *GetParamInfo(unsigned int num); |
|
faluco@739
|
58 |
const PassInfo *GetReturnInfo(); |
|
faluco@739
|
59 |
unsigned int GetParamCount(); |
|
faluco@739
|
60 |
void Execute(void *vParamStack, void *retBuffer); |
|
dvander@942
|
61 |
void Destroy(); |
|
faluco@739
|
62 |
public: |
|
faluco@739
|
63 |
inline void deleteThis() { delete this; } |
|
faluco@739
|
64 |
void *m_Addrs[4]; |
|
faluco@739
|
65 |
VtableInfo m_VtInfo; |
|
faluco@739
|
66 |
private: |
|
faluco@739
|
67 |
CallConvention m_Cv; |
|
faluco@739
|
68 |
PassEncode *m_Params; |
|
faluco@739
|
69 |
PassInfo *m_RetParam; |
|
faluco@739
|
70 |
unsigned int m_NumParams; |
|
faluco@739
|
71 |
}; |
|
faluco@739
|
72 |
|
|
faluco@740
|
73 |
#endif //_INCLUDE_SOURCEMOD_CCALLWRAPPER_H_ |