From c9079c79ae5cd9e7a35826a4d7c384f4df547fc5 Mon Sep 17 00:00:00 2001 From: Pursuit Date: Sat, 22 Jun 2019 18:18:02 +0200 Subject: [PATCH] v0.3.3 update --- AsiSupport/ASI/AsiInterface.cs | 14 ++++++++++++-- AsiSupport/Config.cs | 4 ++++ AsiSupport/ConsoleCommands.cs | 6 ++++++ AsiSupport/Properties/AssemblyInfo.cs | 7 +++---- AsiSupport/Support.cs | 2 +- Changelog.txt | 5 +++++ 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/AsiSupport/ASI/AsiInterface.cs b/AsiSupport/ASI/AsiInterface.cs index 8637996..077e147 100644 --- a/AsiSupport/ASI/AsiInterface.cs +++ b/AsiSupport/ASI/AsiInterface.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using AsiSupport.Managers; @@ -228,7 +229,16 @@ private static IntPtr NativeCall() argumentsIndex = 0; - *(NativeRetVal*)returnedValue = (NativeRetVal)NativeFunction.Call(nativeHash, typeof(NativeRetVal), args); + try + { + *(NativeRetVal*) returnedValue = (NativeRetVal) NativeFunction.Call(nativeHash, typeof(NativeRetVal), args); + } + catch(Exception e) + { + if(Support.Instance.Config.IgnoreUnknownNatives) + *(NativeRetVal*)returnedValue = new NativeRetVal(); //== 0 + else throw e; + } return returnedValue; } @@ -326,7 +336,7 @@ private static IntPtr GetScriptHandleBaseAddress(uint handle) private static int GetGameVersion() { - return Support.Instance.GameVersion; + return Support.Instance.Config.ConsiderVersionUnknown ? -1 : Support.Instance.GameVersion; } } } \ No newline at end of file diff --git a/AsiSupport/Config.cs b/AsiSupport/Config.cs index 027a6c6..f5e42c1 100644 --- a/AsiSupport/Config.cs +++ b/AsiSupport/Config.cs @@ -11,6 +11,10 @@ public class Config : ConfigFile { public bool LoadAllPluginsOnStartup { get; set; } = true; + public bool ConsiderVersionUnknown { get; set; } = false; + + public bool IgnoreUnknownNatives { get; set; } = false; + public Config() : base(Support.Instance.ConfigFile, true) {} } } \ No newline at end of file diff --git a/AsiSupport/ConsoleCommands.cs b/AsiSupport/ConsoleCommands.cs index 4339686..402386f 100644 --- a/AsiSupport/ConsoleCommands.cs +++ b/AsiSupport/ConsoleCommands.cs @@ -37,5 +37,11 @@ public static void UnloadAllAsiPlugins() { Support.Instance.Loader.UnloadAllPlugins(); } + + [ConsoleCommand(Description = "Reload AsiSupport's configuration")] + public static void ReloadAsiConfig() + { + Support.Instance.Config = new Config(); + } } } diff --git a/AsiSupport/Properties/AssemblyInfo.cs b/AsiSupport/Properties/AssemblyInfo.cs index d905a18..3dbfbf1 100644 --- a/AsiSupport/Properties/AssemblyInfo.cs +++ b/AsiSupport/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -10,7 +9,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Pursuit")] [assembly: AssemblyProduct("ASI Support")] -[assembly: AssemblyCopyright("Copyright © Pursuit 2018")] +[assembly: AssemblyCopyright("Copyright © Pursuit 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: Rage.Attributes.Plugin("ASI Support For RAGE Plugin Hook", Description = "Adds support for ASI plugins to RAGE Plugin Hook.", Author = "Pursuit")] @@ -33,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.3.2")] -[assembly: AssemblyFileVersion("0.3.2")] +[assembly: AssemblyVersion("0.3.3")] +[assembly: AssemblyFileVersion("0.3.3")] diff --git a/AsiSupport/Support.cs b/AsiSupport/Support.cs index 39b6fa3..b30ef2c 100644 --- a/AsiSupport/Support.cs +++ b/AsiSupport/Support.cs @@ -19,7 +19,7 @@ public class Support : RPHPlugin { public static Support Instance { get; private set; } - public Config Config { get; private set; } + public Config Config { get; set; } public int GameVersion { get; private set; } = -1; public AsiLoader Loader { get; private set; } public TextureManager TextureManager { get; private set; } diff --git a/Changelog.txt b/Changelog.txt index 77ca5fd..9431d4f 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,8 @@ +__0.3.3__ +* The plugin can now optionally consider the current game version as unknown (getGameVersion() then always returns -1) +* The plugin can now optionally ignore calls to unknown natives. This could prevent some plugins from crashing. If a plugin tries to call an unknown native, 0 will be returned. +* Added the ReloadAsiConfig command + __0.3.2__ * The plugin should no longer crash if it failed to load or convert an ASI file * The plugin now detects non ScriptHookV scripts instead of trying to convert them