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;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using Mono.Cecil;
|
||||||
using StardewModdingAPI.Events;
|
using StardewModdingAPI.Events;
|
||||||
using StardewModdingAPI.Inheritance;
|
using StardewModdingAPI.Inheritance;
|
||||||
using StardewModdingAPI.Inheritance.Menus;
|
using StardewModdingAPI.Inheritance.Menus;
|
||||||
|
@ -49,10 +50,11 @@ namespace StardewModdingAPI
|
||||||
{
|
{
|
||||||
ConfigureUI();
|
ConfigureUI();
|
||||||
ConfigurePaths();
|
ConfigurePaths();
|
||||||
|
ConfigureMethodInjection();
|
||||||
ConfigureInjector();
|
ConfigureInjector();
|
||||||
ConfigureSDV();
|
ConfigureSDV();
|
||||||
|
|
||||||
GameRunInvoker();
|
//GameRunInvoker();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -63,6 +65,20 @@ namespace StardewModdingAPI
|
||||||
StardewModdingAPI.Log.Comment("The API will now terminate. Press any key to continue...");
|
StardewModdingAPI.Log.Comment("The API will now terminate. Press any key to continue...");
|
||||||
Console.ReadKey();
|
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>
|
/// <summary>
|
||||||
/// Set up the console properties
|
/// Set up the console properties
|
||||||
|
|
|
@ -37,16 +37,16 @@
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Choose>
|
<Choose>
|
||||||
<When Condition="'$(SteamInstallPath)' != ''">
|
<When Condition="'$(SteamInstallPath)' != ''">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SteamPath>$(SteamInstallPath)</SteamPath>
|
<SteamPath>$(SteamInstallPath)</SteamPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</When>
|
</When>
|
||||||
<Otherwise>
|
<Otherwise>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SteamPath>..\..\..\..\Games\SteamLibrary</SteamPath>
|
<SteamPath>..\..\..\..\Games\SteamLibrary</SteamPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Otherwise>
|
</Otherwise>
|
||||||
</Choose>
|
</Choose>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
@ -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.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.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="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">
|
<Reference Include="Stardew Valley, Version=1.0.5905.5747, Culture=neutral, processorArchitecture=x86">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<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>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
@ -105,7 +121,7 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="xTile, Version=2.0.4.0, Culture=neutral, processorArchitecture=x86">
|
<Reference Include="xTile, Version=2.0.4.0, Culture=neutral, processorArchitecture=x86">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>$(SteamPath)\steamapps\common\Stardew Valley\xTile.dll</HintPath>
|
<HintPath>D:\Games\steamapps\common\Stardew Valley\xTile.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -142,6 +158,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="icon.ico" />
|
<Content Include="icon.ico" />
|
||||||
|
@ -159,6 +176,9 @@
|
||||||
<Install>false</Install>
|
<Install>false</Install>
|
||||||
</BootstrapperPackage>
|
</BootstrapperPackage>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Cecil\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>
|
<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>
|
|
@ -34,16 +34,16 @@
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Choose>
|
<Choose>
|
||||||
<When Condition="'$(SteamInstallPath)' != ''">
|
<When Condition="'$(SteamInstallPath)' != ''">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SteamPath>$(SteamInstallPath)</SteamPath>
|
<SteamPath>$(SteamInstallPath)</SteamPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</When>
|
</When>
|
||||||
<Otherwise>
|
<Otherwise>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SteamPath>..\..\..\..\Games\SteamLibrary</SteamPath>
|
<SteamPath>..\..\..\..\Games\SteamLibrary</SteamPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Otherwise>
|
</Otherwise>
|
||||||
</Choose>
|
</Choose>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
||||||
|
@ -53,8 +53,7 @@
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Stardew Valley">
|
<Reference Include="Stardew Valley">
|
||||||
<HintPath>$(SteamPath)\steamapps\common\Stardew Valley\Stardew Valley.exe</HintPath>
|
<HintPath>D:\Games\steamapps\common\Stardew Valley\Stardew Valley.exe</HintPath>
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
@ -65,8 +64,7 @@
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="xTile">
|
<Reference Include="xTile">
|
||||||
<HintPath>$(SteamPath)\steamapps\common\Stardew Valley\xTile.dll</HintPath>
|
<HintPath>D:\Games\steamapps\common\Stardew Valley\xTile.dll</HintPath>
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
Loading…
Reference in New Issue