mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 20:33:40 +01:00
feat: add PluginManager::FindCallingPlugin()
This commit is contained in:
parent
78581d637a
commit
3072d624a6
1 changed files with 29 additions and 0 deletions
|
|
@ -1299,6 +1299,35 @@ Thanks and have fun!";
|
||||||
return this.bannedPlugins.LastOrDefault(ban => ban.Name == manifest.InternalName).Reason;
|
return this.bannedPlugins.LastOrDefault(ban => ban.Name == manifest.InternalName).Reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the plugin that called this method by walking the stack,
|
||||||
|
/// or null, if it cannot be determined.
|
||||||
|
/// At the time, this is naive and shouldn't be used for security-critical checks.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The calling plugin, or null.</returns>
|
||||||
|
public LocalPlugin? FindCallingPlugin()
|
||||||
|
{
|
||||||
|
var trace = new StackTrace();
|
||||||
|
foreach (var frame in trace.GetFrames())
|
||||||
|
{
|
||||||
|
var declaringType = frame.GetMethod()?.DeclaringType;
|
||||||
|
if (declaringType == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
lock (this.pluginListLock)
|
||||||
|
{
|
||||||
|
foreach (var plugin in this.InstalledPlugins)
|
||||||
|
{
|
||||||
|
if (plugin.AssemblyName != null &&
|
||||||
|
plugin.AssemblyName.FullName == declaringType.Assembly.GetName().FullName)
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private void DetectAvailablePluginUpdates()
|
private void DetectAvailablePluginUpdates()
|
||||||
{
|
{
|
||||||
var updatablePlugins = new List<AvailablePluginUpdate>();
|
var updatablePlugins = new List<AvailablePluginUpdate>();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue