Skip to content

Commit

Permalink
fix: plugin import check
Browse files Browse the repository at this point in the history
  • Loading branch information
beheh committed Jan 8, 2024
1 parent ed72f36 commit 026f684
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Hearthstone Deck Tracker/Plugins/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ public void LoadPlugins(IEnumerable<FileInfo> files)
}
}

private static string NormalizeImport(string import) => import.Replace(".dll", "").Trim().ToLowerInvariant();

// Blizzard has kindly asked us to stop supporting reconnector plugins
private readonly string[] _prohibitedImports = { "iphlpapi.dll" };
private readonly string[] _prohibitedImports = { "iphlpapi" };
private IEnumerable<PluginWrapper> GetModule(string pFileName, Type pTypeInterface)
{
var plugins = new List<PluginWrapper>();
Expand All @@ -204,7 +206,7 @@ private IEnumerable<PluginWrapper> GetModule(string pFileName, Type pTypeInterfa
var assembly = Assembly.LoadFrom(pFileName);
var hasProhibitedImport = assembly.GetTypes().Any(t => t.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
.Any(m => m.GetCustomAttributes<DllImportAttribute>()
.Any(a => _prohibitedImports.Contains(a.Value))));
.Any(a => _prohibitedImports.Contains(NormalizeImport(a.Value)))));
if(hasProhibitedImport)
return plugins;

Expand Down

0 comments on commit 026f684

Please sign in to comment.