Add PrepSDKCall_SetAddress and Address support to PrepSDKCall_SetFromConf (bug 5261, r=asherkin).
authorNicholas Hastings <skamonkey@gmail.com>
Wed May 07 12:58:16 2014 -0400 (2014-05-07)
changeset 4346a2f9c923d545
parent 4345 2b9b95b41208
child 4347 de9fda7d5309
Add PrepSDKCall_SetAddress and Address support to PrepSDKCall_SetFromConf (bug 5261, r=asherkin).
extensions/sdktools/vcaller.cpp
plugins/include/sdktools.inc
     1.1 --- a/extensions/sdktools/vcaller.cpp	Tue May 06 18:48:53 2014 -0700
     1.2 +++ b/extensions/sdktools/vcaller.cpp	Wed May 07 12:58:16 2014 -0400
     1.3 @@ -155,6 +155,21 @@
     1.4  	return (s_call_addr != NULL) ? 1 : 0;
     1.5  }
     1.6  
     1.7 +static cell_t PrepSDKCall_SetAddress(IPluginContext *pContext, const cell_t *params)
     1.8 +{
     1.9 +	s_call_addr = reinterpret_cast<void *>(params[1]);
    1.10 +
    1.11 +	return (s_call_addr != NULL) ? 1 : 0;
    1.12 +}
    1.13 +
    1.14 +// Must match same enum in sdktools.inc
    1.15 +enum SDKFuncConfSource
    1.16 +{
    1.17 +	SDKConf_Virtual,
    1.18 +	SDKConf_Signature,
    1.19 +	SDKConf_Address
    1.20 +};
    1.21 +
    1.22  static cell_t PrepSDKCall_SetFromConf(IPluginContext *pContext, const cell_t *params)
    1.23  {
    1.24  	IGameConfig *conf;
    1.25 @@ -173,12 +188,26 @@
    1.26  	char *key;
    1.27  	pContext->LocalToString(params[3], &key);
    1.28  
    1.29 -	if (params[2] == 0)
    1.30 +	switch (params[2])
    1.31  	{
    1.32 -		return conf->GetOffset(key, &s_vtbl_index) ? 1 : 0;
    1.33 -	} else if (params[2] == 1) {
    1.34 -		bool result = conf->GetMemSig(key, &s_call_addr) ? 1 : 0;
    1.35 -		return (result && s_call_addr != NULL) ? 1 : 0;
    1.36 +	case SDKConf_Virtual:
    1.37 +		if (conf->GetOffset(key, &s_vtbl_index))
    1.38 +		{
    1.39 +			return 1;
    1.40 +		}
    1.41 +		break;
    1.42 +	case SDKConf_Signature:
    1.43 +		if (conf->GetMemSig(key, &s_call_addr) && s_call_addr)
    1.44 +		{
    1.45 +			return 1;
    1.46 +		}
    1.47 +		break;
    1.48 +	case SDKConf_Address:
    1.49 +		if (conf->GetAddress(key, &s_call_addr) && s_call_addr)
    1.50 +		{
    1.51 +			return 1;
    1.52 +		}
    1.53 +		break;
    1.54  	}
    1.55  
    1.56  	return 0;
    1.57 @@ -477,6 +506,7 @@
    1.58  	{"StartPrepSDKCall",			StartPrepSDKCall},
    1.59  	{"PrepSDKCall_SetVirtual",		PrepSDKCall_SetVirtual},
    1.60  	{"PrepSDKCall_SetSignature",	PrepSDKCall_SetSignature},
    1.61 +	{"PrepSDKCall_SetAddress",		PrepSDKCall_SetAddress},
    1.62  	{"PrepSDKCall_SetFromConf",		PrepSDKCall_SetFromConf},
    1.63  	{"PrepSDKCall_SetReturnInfo",	PrepSDKCall_SetReturnInfo},
    1.64  	{"PrepSDKCall_AddParameter",	PrepSDKCall_AddParameter},
     2.1 --- a/plugins/include/sdktools.inc	Tue May 06 18:48:53 2014 -0700
     2.2 +++ b/plugins/include/sdktools.inc	Wed May 07 12:58:16 2014 -0400
     2.3 @@ -72,6 +72,7 @@
     2.4  {
     2.5  	SDKConf_Virtual = 0,	/**< Read a virtual index from the Offsets section */
     2.6  	SDKConf_Signature = 1,	/**< Read a signature from the Signatures section */
     2.7 +	SDKConf_Address = 2,	/**< Read an address from the Addresses section */
     2.8  };
     2.9  
    2.10  enum SDKType
    2.11 @@ -131,6 +132,14 @@
    2.12  native bool:PrepSDKCall_SetSignature(SDKLibrary:lib, const String:signature[], bytes);
    2.13  
    2.14  /**
    2.15 + * Uses the given function address for the SDK call.
    2.16 + *
    2.17 + * @param addr			Address of function to use.
    2.18 + * @return				True on success, false on failure.
    2.19 + */
    2.20 +native bool:PrepSDKCall_SetAddress(Address:addr);
    2.21 +
    2.22 +/**
    2.23   * Finds an address or virtual function index in a GameConfig file and sets it as
    2.24   * the calling information for the SDK call.
    2.25   *