Skip to content

Commit

Permalink
tweak(asi/five): require plugins to explicitly advertise build compat…
Browse files Browse the repository at this point in the history
…ibility

There's a *lot* of weird issues with plugins on 2189/2372, so we don't load them unless they're specified as updated.
  • Loading branch information
blattersturm committed Jul 26, 2021
1 parent bf675af commit 200916a
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion code/components/asi-five/src/Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "StdInc.h"
#include "ComponentLoader.h"
#include <boost/algorithm/string.hpp>

#include <CrossBuildRuntime.h>
#include <filesystem>
#include <wchar.h>

Expand Down Expand Up @@ -148,13 +150,48 @@ bool ComponentInstance::DoGameLoad(void* module)
}
}

if (xbr::IsGameBuildOrGreater<2189>())
{
bad = true;

HMODULE hModule = LoadLibraryEx(it->path().c_str(), nullptr, LOAD_LIBRARY_AS_DATAFILE);

if (hModule)
{
HRSRC hResource = FindResource(hModule, L"FX_ASI_BUILD", MAKEINTRESOURCE(xbr::GetGameBuild()));

if (hResource)
{
auto resSize = SizeofResource(hModule, hResource);
auto resData = LoadResource(hModule, hResource);

auto resPtr = static_cast<const char*>(LockResource(resData));

if (resPtr)
{
bad = false;
}
}

FreeLibrary(hModule);
}

if (bad)
{
trace("Unable to load %s - this ASI plugin does not claim to support game build %d. If you have access to its source code, add `FX_ASI_BUILD %d dummy.txt` to the .rc file when building this plugin. If not, contact its maintainer.\n",
ToNarrow(it->path().wstring()).c_str(),
xbr::GetGameBuild(),
xbr::GetGameBuild()
);
}
}

if (LoadPEFile(it->path(), libraryBuffer))
{
if (!CfxIsSinglePlayer())
{
for (auto itt = blacklistedAsis.begin(); itt != blacklistedAsis.end(); ++itt)
{

if (*itt != L"")
{
if (wcsicmp(it->path().filename().c_str(), itt->c_str()) == 0 || wcsicmp(badFileName.c_str(), itt->c_str()) == 0)
Expand Down

0 comments on commit 200916a

Please sign in to comment.