Changed SMAPI to load the modified assembly, but it doesn't work yet.

This commit is contained in:
ClxS 2016-03-09 19:04:33 +00:00
parent 8201b96034
commit 608a5cb257
2 changed files with 10 additions and 10 deletions

View File

@ -23,7 +23,7 @@ namespace StardewModdingAPI.Helpers
private bool _isMemoryStreamDirty { get; set; }
private MemoryStream _modifiedAssembly;
private MemoryStream ModifiedAssembly
public MemoryStream ModifiedAssembly
{
get
{

View File

@ -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
/// </summary>
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();