Skip to content
Permalink
Browse files

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.
  • Loading branch information...
peace-maker authored and KyleSanderson committed Apr 11, 2019
1 parent 8f05274 commit e3f4d239f1b24f575e5ee82ffec74a38a4a58b71
Showing with 11 additions and 0 deletions.
  1. +11 −0 public/extensions/IBinTools.h
@@ -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.

0 comments on commit e3f4d23

Please sign in to comment.
You can’t perform that action at this time.