diff --git a/StardewModdingAPI/Helpers/CecilContext.cs b/StardewModdingAPI/Helpers/CecilContext.cs index c4487811..39e08270 100644 --- a/StardewModdingAPI/Helpers/CecilContext.cs +++ b/StardewModdingAPI/Helpers/CecilContext.cs @@ -23,7 +23,7 @@ namespace StardewModdingAPI.Helpers private bool _isMemoryStreamDirty { get; set; } private MemoryStream _modifiedAssembly; - private MemoryStream ModifiedAssembly + public MemoryStream ModifiedAssembly { get { diff --git a/StardewModdingAPI/Program.cs b/StardewModdingAPI/Program.cs index 468d5d89..7a75e2b7 100644 --- a/StardewModdingAPI/Program.cs +++ b/StardewModdingAPI/Program.cs @@ -53,9 +53,8 @@ namespace StardewModdingAPI ConfigureUI(); ConfigurePaths(); ConfigureMethodInjection(); - //ConfigureSDV(); - - //GameRunInvoker(); + ConfigureSDV(); + GameRunInvoker(); } catch (Exception e) { @@ -73,7 +72,7 @@ namespace StardewModdingAPI private static void ConfigureMethodInjection() { StardewContext = new CecilContext(CecilContextType.Stardew); - SmapiContext = new CecilContext(CecilContextType.SMAPI); + //SmapiContext = new CecilContext(CecilContextType.SMAPI); } private static void WeaveOnEnterMethod(Mono.Cecil.Cil.ILProcessor ilProcessor, Instruction target, MethodReference callback) @@ -141,10 +140,11 @@ namespace StardewModdingAPI /// private static void ConfigureSDV() { - StardewModdingAPI.Log.Info("Initializing SDV Assembly..."); - - // Load in the assembly - ignores security - StardewAssembly = Assembly.UnsafeLoadFrom(Constants.ExecutionPath + "\\Stardew Valley.exe"); + StardewModdingAPI.Log.Info("Initializing SDV Assembly..."); + + // Load in the assembly - ignores security + //StardewAssembly = Assembly.UnsafeLoadFrom(Constants.ExecutionPath + "\\Stardew Valley.exe"); + StardewAssembly = Assembly.Load(StardewContext.ModifiedAssembly.GetBuffer()); StardewProgramType = StardewAssembly.GetType("StardewValley.Program", true); StardewGameInfo = StardewProgramType.GetField("gamePtr"); @@ -253,7 +253,7 @@ namespace StardewModdingAPI StardewForm.Closing += StardewForm_Closing; ready = true; - + StardewGameInfo.SetValue(StardewProgramType, gamePtr); gamePtr.Run();