Add support to define function signatures in gamedata
A "Functions" section is parsed in gamedata files that allow you to define the signature of functions including metadata like the calling convention and specifying the register an argument is passed in. A new native DHookCreateFromConf can be used to setup a hook or detour from one of that function sections in the "Functions" section.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#ifndef _INCLUDE_SIGNATURES_H_
|
||||
#define _INCLUDE_SIGNATURES_H_
|
||||
|
||||
#include "extension.h"
|
||||
#include "util.h"
|
||||
#include <am-string.h>
|
||||
#include <sm_stringhashmap.h>
|
||||
|
||||
class SignatureWrapper {
|
||||
public:
|
||||
ke::AString signature;
|
||||
ke::AString address;
|
||||
ke::AString offset;
|
||||
StringHashMap<ParamInfo> args;
|
||||
CallingConvention callConv;
|
||||
HookType hookType;
|
||||
ReturnType retType;
|
||||
ThisPointerType thisType;
|
||||
};
|
||||
|
||||
class SignatureGameConfig : public ITextListener_SMC {
|
||||
public:
|
||||
SignatureWrapper *GetFunctionSignature(const char *function);
|
||||
public:
|
||||
//ITextListener_SMC
|
||||
SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name);
|
||||
SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value);
|
||||
SMCResult ReadSMC_LeavingSection(const SMCStates *states);
|
||||
void ReadSMC_ParseStart();
|
||||
|
||||
private:
|
||||
ReturnType GetReturnTypeFromString(const char *str);
|
||||
HookParamType GetHookParamTypeFromString(const char *str);
|
||||
Register_t GetCustomRegisterFromString(const char *str);
|
||||
|
||||
private:
|
||||
StringHashMap<SignatureWrapper *> signatures_;
|
||||
};
|
||||
|
||||
extern SignatureGameConfig *g_pSignatures;
|
||||
#endif
|
||||
Reference in New Issue
Block a user