Test code for msil injection
This commit is contained in:
parent
1b6244c087
commit
318f5feada
|
@ -1,5 +1,6 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Mono.Cecil;
|
||||
using StardewModdingAPI.Events;
|
||||
using StardewModdingAPI.Inheritance;
|
||||
using StardewModdingAPI.Inheritance.Menus;
|
||||
|
@ -49,10 +50,11 @@ namespace StardewModdingAPI
|
|||
{
|
||||
ConfigureUI();
|
||||
ConfigurePaths();
|
||||
ConfigureMethodInjection();
|
||||
ConfigureInjector();
|
||||
ConfigureSDV();
|
||||
|
||||
GameRunInvoker();
|
||||
//GameRunInvoker();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -64,6 +66,20 @@ namespace StardewModdingAPI
|
|||
Console.ReadKey();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures Mono.Cecil injections
|
||||
/// </summary>
|
||||
private static void ConfigureMethodInjection()
|
||||
{
|
||||
AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(Constants.ExecutionPath + "\\Stardew Valley.exe");
|
||||
TypeDefinition type = assembly.MainModule.Types.FirstOrDefault(n => n.FullName == "StardewValley.FarmAnimal");
|
||||
//if (type != null)
|
||||
//{
|
||||
MethodDefinition foundMethod = type.Methods.FirstOrDefault(m => m.Name == "eatGrass");
|
||||
Mono.Cecil.Cil.ILProcessor worker = foundMethod.Body.GetILProcessor();
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set up the console properties
|
||||
/// </summary>
|
||||
|
|
|
@ -90,9 +90,25 @@
|
|||
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
|
||||
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
|
||||
<Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
|
||||
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Mdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Mdb.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Pdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Pdb.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Rocks, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Rocks.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Stardew Valley, Version=1.0.5905.5747, Culture=neutral, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(SteamPath)\steamapps\common\Stardew Valley\Stardew Valley.exe</HintPath>
|
||||
<HintPath>D:\Games\steamapps\common\Stardew Valley\Stardew Valley.exe</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
@ -105,7 +121,7 @@
|
|||
<Reference Include="System.Xml" />
|
||||
<Reference Include="xTile, Version=2.0.4.0, Culture=neutral, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(SteamPath)\steamapps\common\Stardew Valley\xTile.dll</HintPath>
|
||||
<HintPath>D:\Games\steamapps\common\Stardew Valley\xTile.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -142,6 +158,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="icon.ico" />
|
||||
|
@ -159,6 +176,9 @@
|
|||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Cecil\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Mono.Cecil" version="0.9.6.1" targetFramework="net45" />
|
||||
</packages>
|
|
@ -53,8 +53,7 @@
|
|||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Stardew Valley">
|
||||
<HintPath>$(SteamPath)\steamapps\common\Stardew Valley\Stardew Valley.exe</HintPath>
|
||||
<Private>False</Private>
|
||||
<HintPath>D:\Games\steamapps\common\Stardew Valley\Stardew Valley.exe</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
@ -65,8 +64,7 @@
|
|||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="xTile">
|
||||
<HintPath>$(SteamPath)\steamapps\common\Stardew Valley\xTile.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<HintPath>D:\Games\steamapps\common\Stardew Valley\xTile.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
Loading…
Reference in New Issue