IBinTools: Block loading incompatible interface versions (#979)

In #705 SourceMod received support for x64 binaries. The `IBinTools` interface was updated to call functions in 64bit binaries. The `PassInfo` struct's size was increased and the `Create(V)Call()` functions signatures changed, thus making the interface incompatible for consumers which were compiled against an earlier version.

`SMInterface::IsVersionCompatible` wasn't adjusted to that fact, so extensions compiled against pre SM 1.10 could request an `IBinTools` interface pointer, but crash when they try to use it.

This change makes requests to older interface versions invalid, thus letting `RequestInterface` return `NULL` for older extensions. It doesn't fix the backwards incompatibility, but at least makes the problem more blatant, so extensions can handle it themselves.
This commit is contained in:
peace-maker 2019-04-11 23:51:38 +02:00 committed by Kyle Sanderson
parent 8f0527487f
commit e3f4d239f1

View File

@ -37,6 +37,8 @@
#define SMINTERFACE_BINTOOLS_NAME "IBinTools"
#define SMINTERFACE_BINTOOLS_VERSION 4
// Backwards incompatible change for x64 support.
#define SMINTERFACE_BINTOOLS_MIN_VERSION 4
/**
* @brief Function calling encoding utilities
@ -184,6 +186,15 @@ namespace SourceMod
{
return SMINTERFACE_BINTOOLS_VERSION;
}
virtual bool IsVersionCompatible(unsigned int version)
{
if (version < SMINTERFACE_BINTOOLS_MIN_VERSION || version > SMINTERFACE_BINTOOLS_VERSION)
{
return false;
}
return true;
}
public:
/**
* @brief Creates a call decoder.