-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bfa8789
Showing
60 changed files
with
3,035 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.vs/ | ||
bin/ | ||
obj/ | ||
packages/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Adds two values and pushes the result onto the evaluation stack. | ||
/// </summary> | ||
public class Add : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
return processor.Create(OpCodes.Add); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Computes the bitwise AND of two values and pushes the result onto the evaluation stack. | ||
/// </summary> | ||
public class And : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
return processor.Create(OpCodes.And); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
using System.Linq; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Transfers control to a target instruction if two values are equal. | ||
/// </summary> | ||
public class Beq : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
if (patchInstruction.TargetIndex < 0) | ||
return null; | ||
|
||
Instruction targetInstruction = methodDef.Body.Instructions.ElementAt(patchInstruction.TargetIndex); | ||
|
||
if (targetInstruction == null) | ||
return null; | ||
|
||
return processor.Create(OpCodes.Beq, targetInstruction); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
using System.Linq; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Transfers control to a target instruction if the first value is greater than or equal to the second value. | ||
/// </summary> | ||
public class Bge : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
if (patchInstruction.TargetIndex < 0) | ||
return null; | ||
|
||
Instruction targetInstruction = methodDef.Body.Instructions.ElementAt(patchInstruction.TargetIndex); | ||
|
||
if (targetInstruction == null) | ||
return null; | ||
|
||
return processor.Create(OpCodes.Bge, targetInstruction); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
using System.Linq; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Transfers control to a target instruction if the first value is greater than the second value. | ||
/// </summary> | ||
public class Bgt : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
if (patchInstruction.TargetIndex < 0) | ||
return null; | ||
|
||
Instruction targetInstruction = methodDef.Body.Instructions.ElementAt(patchInstruction.TargetIndex); | ||
|
||
if (targetInstruction == null) | ||
return null; | ||
|
||
return processor.Create(OpCodes.Bgt, targetInstruction); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
using System.Linq; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Transfers control to a target instruction if the first value is less than or equal to the second value. | ||
/// </summary> | ||
public class Ble : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
if (patchInstruction.TargetIndex < 0) | ||
return null; | ||
|
||
Instruction targetInstruction = methodDef.Body.Instructions.ElementAt(patchInstruction.TargetIndex); | ||
|
||
if (targetInstruction == null) | ||
return null; | ||
|
||
return processor.Create(OpCodes.Ble, targetInstruction); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
using System.Linq; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Transfers control to a target instruction if the first value is less than the second value. | ||
/// </summary> | ||
public class Blt : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
if (patchInstruction.TargetIndex < 0) | ||
return null; | ||
|
||
Instruction targetInstruction = methodDef.Body.Instructions.ElementAt(patchInstruction.TargetIndex); | ||
|
||
if (targetInstruction == null) | ||
return null; | ||
|
||
return processor.Create(OpCodes.Blt, targetInstruction); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
using System.Linq; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Transfers control to a target instruction when two unsigned integer values or unordered float values are not equal. | ||
/// </summary> | ||
public class Bne_Un : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
if (patchInstruction.TargetIndex < 0) | ||
return null; | ||
|
||
Instruction targetInstruction = methodDef.Body.Instructions.ElementAt(patchInstruction.TargetIndex); | ||
|
||
if (targetInstruction == null) | ||
return null; | ||
|
||
return processor.Create(OpCodes.Bne_Un, targetInstruction); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
using System.Linq; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Unconditionally transfers control to a target instruction. | ||
/// </summary> | ||
public class Br : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
if (patchInstruction.TargetIndex < 0) | ||
return null; | ||
|
||
Instruction targetInstruction = methodDef.Body.Instructions.ElementAt(patchInstruction.TargetIndex); | ||
|
||
if (targetInstruction == null) | ||
return null; | ||
|
||
return processor.Create(OpCodes.Br, targetInstruction); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
using System.Linq; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Transfers control to a target instruction if value is false, a null reference, or zero. | ||
/// </summary> | ||
public class Brfalse : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
if (patchInstruction.TargetIndex < 0) | ||
return null; | ||
|
||
Instruction targetInstruction = methodDef.Body.Instructions.ElementAt(patchInstruction.TargetIndex); | ||
|
||
if (targetInstruction == null) | ||
return null; | ||
|
||
return processor.Create(OpCodes.Brfalse, targetInstruction); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
using System.Linq; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Transfers control to a target instruction if value is true, not null, or non-zero. | ||
/// </summary> | ||
public class Brtrue : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
if (patchInstruction.TargetIndex < 0) | ||
return null; | ||
|
||
Instruction targetInstruction = methodDef.Body.Instructions.ElementAt(patchInstruction.TargetIndex); | ||
|
||
if (targetInstruction == null) | ||
return null; | ||
|
||
return processor.Create(OpCodes.Brtrue, targetInstruction); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
using System.Linq; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Calls the method indicated by the passed method descriptor. | ||
/// </summary> | ||
public class Call : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
if (patchInstruction.Type == null || patchInstruction.Method == null) | ||
return null; | ||
|
||
string typeName = patchInstruction.Type; | ||
string methodName = patchInstruction.Method; | ||
|
||
AssemblyDefinition _assemblyDef = assemblyDef; | ||
if (patchInstruction.Assembly != null) | ||
_assemblyDef = Patcher.ResolveAssembly(patchInstruction.Assembly); | ||
|
||
if (_assemblyDef == null) | ||
return null; | ||
|
||
// Get Type | ||
TypeDefinition typeDefinition = _assemblyDef.MainModule.GetType(typeName); | ||
|
||
// Get Method | ||
MethodDefinition methodDefinition = typeDefinition.Methods.FirstOrDefault(m => m.Name == methodName); | ||
MethodReference methodReference = assemblyDef.MainModule.ImportReference(methodDefinition); | ||
|
||
//if (patchInstruction.Parameters.Count > 0) { | ||
// List<TypeReference> genericParameters = new List<TypeReference>(); | ||
|
||
// foreach (PatchInstructionParameter genericAssembly in patchInstruction.Parameters) { | ||
// AssemblyDefinition genericAssemblyDef = Patcher.ResolveAssembly(genericAssembly.Assembly); | ||
// TypeReference genericTypeRef = assemblyDef.MainModule.ImportReference(genericAssemblyDef.MainModule.GetType(genericAssembly.Type)); | ||
|
||
// methodReference.GenericParameters.Add(new GenericParameter(genericTypeRef.Name, methodDefinition)); | ||
// } | ||
//} | ||
|
||
// Return Instruction | ||
return processor.Create(OpCodes.Call, methodReference); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
using System.Linq; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Calls a late-bound method on an object, pushing the return value onto the evaluation stack. | ||
/// </summary> | ||
public class Callvirt : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
if (patchInstruction.Type == null || patchInstruction.Method == null) | ||
return null; | ||
|
||
string typeName = patchInstruction.Type; | ||
string methodName = patchInstruction.Method; | ||
|
||
AssemblyDefinition _assemblyDef = assemblyDef; | ||
if (patchInstruction.Assembly != null) | ||
_assemblyDef = Patcher.ResolveAssembly(patchInstruction.Assembly); | ||
|
||
if (_assemblyDef == null) | ||
return null; | ||
|
||
// Get Type | ||
TypeDefinition typeDefinition = _assemblyDef.MainModule.GetType(typeName); | ||
|
||
// Get Method | ||
MethodDefinition methodDefinition = typeDefinition.Methods.FirstOrDefault(m => m.Name == methodName); | ||
MethodReference methodReference = assemblyDef.MainModule.ImportReference(methodDefinition); | ||
|
||
//if (patchInstruction.Parameters.Count > 0) { | ||
// List<TypeReference> genericParameters = new List<TypeReference>(); | ||
|
||
// foreach (PatchInstructionParameter genericAssembly in patchInstruction.Parameters) { | ||
// AssemblyDefinition genericAssemblyDef = Patcher.ResolveAssembly(genericAssembly.Assembly); | ||
// TypeReference genericTypeRef = assemblyDef.MainModule.ImportReference(genericAssemblyDef.MainModule.GetType(genericAssembly.Type)); | ||
|
||
// methodReference.GenericParameters.Add(new GenericParameter(genericTypeRef.Name, methodDefinition)); | ||
// } | ||
//} | ||
|
||
// Return Instruction | ||
return processor.Create(OpCodes.Callvirt, methodReference); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Compares two values. If they are equal, the integer value 1 (int32) is pushed onto the evaluation stack; otherwise 0 (int32) is pushed onto the evaluation stack. | ||
/// </summary> | ||
public class Ceq : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
return processor.Create(OpCodes.Ceq); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Compares two values. If the first value is greater than the second, the integer value 1 (int32) is pushed onto the evaluation stack; otherwise 0 (int32) is pushed onto the evaluation stack. | ||
/// </summary> | ||
public class Cgt : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
return processor.Create(OpCodes.Cgt); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Compares two values. If the first value is less than the second, the integer value 1 (int32) is pushed onto the evaluation stack; otherwise 0 (int32) is pushed onto the evaluation stack. | ||
/// </summary> | ||
public class Clt : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
return processor.Create(OpCodes.Clt); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
|
||
namespace UniversalUnityPatcher.Instructions { | ||
/// <summary> | ||
/// Divides two values and pushes the result as a floating-point (type F) or quotient (type int32) onto the evaluation stack. | ||
/// </summary> | ||
public class Div : InstructionBase { | ||
public override Instruction ParseInstruction(ILProcessor processor, AssemblyDefinition assemblyDef, TypeDefinition typeDef, MethodDefinition methodDef, PatchInstruction patchInstruction) { | ||
return processor.Create(OpCodes.Div); | ||
} | ||
} | ||
} |
Oops, something went wrong.