Skip to content

Commit

Permalink
Block loading of incompatible IBinTools interface
Browse files Browse the repository at this point in the history
In alliedmodders#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 committed Apr 9, 2019
1 parent 8f05274 commit 178b0f8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions public/extensions/IBinTools.h
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 178b0f8

Please sign in to comment.