Skip to content

Commit

Permalink
Merge pull request #13 from imaxs/develop
Browse files Browse the repository at this point in the history
Version 1.0.3
  • Loading branch information
imaxs committed Feb 13, 2023
2 parents 8285c16 + dd979e4 commit 2bdc433
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 16 deletions.
5 changes: 5 additions & 0 deletions Framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.3] - 2023-02-13
- Fixed compilation errors on IL2CPP
- Cleared of unnecessary dependencies
- Removed logging on IL2CPP

## [1.0.2] - 2023-02-13
- Fixed bugs with dependency resolution for instances created by the factory.
- Added support resolve for an array in field.
Expand Down
7 changes: 5 additions & 2 deletions Framework/Hooking/Implementions/HookManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
#if ENABLE_IL2CPP
using System.Runtime.InteropServices;
#endif

namespace EasyJection.Hooking
{
Expand Down Expand Up @@ -77,11 +80,11 @@ private unsafe struct __IL2CPP
public HookManager(IMethodInvokeData invokeData, MethodBase hooked, MethodBase original, bool HookImmediately = true)
{
this.isHooked = false;
this.bytes = new byte[Architecture.SIZE_X64];
this.hookedMethod = hooked;
this.originalMethod = original;
this.invokeData = invokeData;
#if !ENABLE_IL2CPP
this.bytes = new byte[Architecture.SIZE_X64];
RuntimeHelpers.PrepareMethod(originalMethod.MethodHandle);
RuntimeHelpers.PrepareMethod(hookedMethod.MethodHandle);
#endif
Expand Down Expand Up @@ -153,7 +156,7 @@ public void Hook()
if (this.isHooked)
return;
#if ENABLE_IL2CPP
IL2CPP.__IL2CPP_LOG("Hooked: InjectMethod: " + hookedMethod.Name + " | Original: " + originalMethod.Name);
// IL2CPP.__IL2CPP_LOG("Hooked: InjectMethod: " + hookedMethod.Name + " | Original: " + originalMethod.Name);
m_Il2CPPStruct = new __IL2CPP() { originalMethodBase = originalMethod,
hookedMethodBase = hookedMethod };
unsafe
Expand Down
5 changes: 2 additions & 3 deletions Framework/Reflection/Implementions/ReflectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;

namespace EasyJection.Reflection
{
Expand All @@ -44,7 +43,7 @@ public IReflectedData Create(Type type)
}

#region Private Methods
private ParameterInfo[][] GetParameters(_MethodBase[] methods)
private ParameterInfo[][] GetParameters(MethodBase[] methods)
{
ParameterInfo[][] args = new ParameterInfo[methods.Length][];

Expand All @@ -54,7 +53,7 @@ private ParameterInfo[][] GetParameters(_MethodBase[] methods)
return args;
}

private ParameterInfo[] GetParameters(_MethodBase method)
private ParameterInfo[] GetParameters(MethodBase method)
{
var _params = method.GetParameters();
if (_params == null || _params.Length == 0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ Where:
- *UseForInstantiation* — if True, the container will use this constructor to create an instance, otherwise it will use the default constructor.
- *<T1, T2 ... T9>* — types of constructor parameters.
#### 🔘 Method Injection ####
The Inject-injection method works very similar to constructor injection in terms of specifying parameter types. However, there are nuances. There are two types of methods that return values and non-return (named as void).
The method injection works very similar to constructor injection in terms of specifying parameter types. However, there are nuances. There are two types of methods that return values and non-return (named as void).

##### Non-return Method (MethodVoid) #####
To specify the non-return method use the `MethodVoid()`.
Expand Down
8 changes: 7 additions & 1 deletion UnityPackage/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [1.0.3] - 2023-02-13
- Fixed compilation errors on IL2CPP
- Cleared of unnecessary dependencies
- Removed logging on IL2CPP

## [1.0.2] - 2023-02-13
- Fixed bugs with dependency resolution for instances created by the factory.
- Fixed bugs with resolving dependencies for instances created by the factory.
- Added support resolve for an array in field.
- Added support for binding to GameObject.
- Updated samples and added new ones.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
#if ENABLE_IL2CPP
using System.Runtime.InteropServices;
#endif

namespace EasyJection.Hooking
{
Expand Down Expand Up @@ -77,11 +80,11 @@ private unsafe struct __IL2CPP
public HookManager(IMethodInvokeData invokeData, MethodBase hooked, MethodBase original, bool HookImmediately = true)
{
this.isHooked = false;
this.bytes = new byte[Architecture.SIZE_X64];
this.hookedMethod = hooked;
this.originalMethod = original;
this.invokeData = invokeData;
#if !ENABLE_IL2CPP
this.bytes = new byte[Architecture.SIZE_X64];
RuntimeHelpers.PrepareMethod(originalMethod.MethodHandle);
RuntimeHelpers.PrepareMethod(hookedMethod.MethodHandle);
#endif
Expand Down Expand Up @@ -153,7 +156,7 @@ public void Hook()
if (this.isHooked)
return;
#if ENABLE_IL2CPP
IL2CPP.__IL2CPP_LOG("Hooked: InjectMethod: " + hookedMethod.Name + " | Original: " + originalMethod.Name);
// IL2CPP.__IL2CPP_LOG("Hooked: InjectMethod: " + hookedMethod.Name + " | Original: " + originalMethod.Name);
m_Il2CPPStruct = new __IL2CPP() { originalMethodBase = originalMethod,
hookedMethodBase = hookedMethod };
unsafe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;

namespace EasyJection.Reflection
{
Expand All @@ -44,7 +43,7 @@ public IReflectedData Create(Type type)
}

#region Private Methods
private ParameterInfo[][] GetParameters(_MethodBase[] methods)
private ParameterInfo[][] GetParameters(MethodBase[] methods)
{
ParameterInfo[][] args = new ParameterInfo[methods.Length][];

Expand All @@ -54,7 +53,7 @@ private ParameterInfo[][] GetParameters(_MethodBase[] methods)
return args;
}

private ParameterInfo[] GetParameters(_MethodBase method)
private ParameterInfo[] GetParameters(MethodBase method)
{
var _params = method.GetParameters();
if (_params == null || _params.Length == 0)
Expand Down
2 changes: 1 addition & 1 deletion UnityPackage/Samples/imaxs.EasyJection.Samples.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
Expand Down
1 change: 0 additions & 1 deletion UnityPackage/Tests/Editor/BindingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System;
using NUnit.Framework;
using EasyJection.Binding;
using FluentAssertions;
using EasyJection.Hooking;
using EasyJection.Binding.Extensions;

Expand Down
2 changes: 0 additions & 2 deletions UnityPackage/Tests/Editor/ReflectionFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using System;
using NUnit.Framework;
using EasyJection.Reflection;
using FluentAssertions;
using System.Diagnostics;

public class ReflectionFactoryTests
{
Expand Down

0 comments on commit 2bdc433

Please sign in to comment.