Skip to content

Commit

Permalink
Strip SharpDisasm from LibCpp2IL in favor of iced
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam committed Sep 11, 2020
1 parent 786f970 commit 38fab4d
Show file tree
Hide file tree
Showing 17 changed files with 437 additions and 410 deletions.
64 changes: 32 additions & 32 deletions Cpp2IL/Analysis/ASMAnalyzer.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cpp2IL/Analysis/Actions/CallManagedFunctionAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private bool CheckParameters(Il2CppMethodDefinition method, MethodAnalysis conte

public CallManagedFunctionAction(MethodAnalysis context, Instruction instruction) : base(context, instruction)
{
var jumpTarget = LibCpp2ILUtils.GetJumpTarget(instruction, context.MethodStart + instruction.PC);
var jumpTarget = Utils.GetJumpTarget(instruction, context.MethodStart + instruction.PC);
var objectMethodBeingCalledOn = context.GetLocalInReg("rcx");
var listOfCallableMethods = LibCpp2IlMain.GetManagedMethodImplementationsAtAddress(jumpTarget);

Expand Down
2 changes: 1 addition & 1 deletion Cpp2IL/Analysis/Actions/CallVirtualMethodAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public CallVirtualMethodAction(MethodAnalysis context, Instruction instruction)

var classReadFrom = klass.backingType;

var readOffset = LibCpp2ILUtils.GetOperandMemoryOffset(instruction.Operands[0]);
var readOffset = Utils.GetOperandMemoryOffset(instruction.Operands[0]);
Called = Utils.GetMethodFromReadKlassOffset(readOffset);

if (Called == null) return;
Expand Down
2 changes: 1 addition & 1 deletion Cpp2IL/Analysis/Actions/GlobalMethodRefToConstantAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class GlobalMethodRefToConstantAction : BaseAction

public GlobalMethodRefToConstantAction(MethodAnalysis context, Instruction instruction) : base(context, instruction)
{
var globalAddress = context.MethodStart + LibCpp2ILUtils.GetOffsetFromMemoryAccess(instruction, instruction.Operands[1]);
var globalAddress = context.MethodStart + Utils.GetOffsetFromMemoryAccess(instruction, instruction.Operands[1]);
MethodData = LibCpp2IlMain.GetMethodDefinitionByGlobalAddress(globalAddress);
var (type, genericParams) = Utils.TryLookupTypeDefByName(MethodData!.DeclaringType.FullName);

Expand Down
2 changes: 1 addition & 1 deletion Cpp2IL/Analysis/Actions/GlobalStringRefToConstantAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class GlobalStringRefToConstantAction : BaseAction

public GlobalStringRefToConstantAction(MethodAnalysis context, Instruction instruction) : base(context, instruction)
{
var globalAddress = context.MethodStart + LibCpp2ILUtils.GetOffsetFromMemoryAccess(instruction, instruction.Operands[1]);
var globalAddress = context.MethodStart + Utils.GetOffsetFromMemoryAccess(instruction, instruction.Operands[1]);
ResolvedString = LibCpp2IlMain.GetLiteralByAddress(globalAddress);

if (ResolvedString == null) return;
Expand Down
2 changes: 1 addition & 1 deletion Cpp2IL/Analysis/Actions/GlobalTypeRefToConstantAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class GlobalTypeRefToConstantAction : BaseAction

public GlobalTypeRefToConstantAction(MethodAnalysis context, Instruction instruction) : base(context, instruction)
{
var globalAddress = context.MethodStart + LibCpp2ILUtils.GetOffsetFromMemoryAccess(instruction, instruction.Operands[1]);
var globalAddress = context.MethodStart + Utils.GetOffsetFromMemoryAccess(instruction, instruction.Operands[1]);
var typeData = LibCpp2IlMain.GetTypeGlobalByAddress(globalAddress);
var (type, genericParams) = Utils.TryLookupTypeDefByName(typeData!.ToString());
ResolvedType = type;
Expand Down
2 changes: 1 addition & 1 deletion Cpp2IL/Analysis/Actions/JumpIfNonZeroOrNonNullAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class JumpIfNonZeroOrNonNullAction : BaseAction

public JumpIfNonZeroOrNonNullAction(MethodAnalysis context, Instruction instruction) : base(context, instruction)
{
jumpTarget = LibCpp2ILUtils.GetJumpTarget(instruction, instruction.PC + context.MethodStart);
jumpTarget = Utils.GetJumpTarget(instruction, instruction.PC + context.MethodStart);

if (jumpTarget > context.MethodStart + instruction.PC && jumpTarget < context.AbsoluteMethodEnd)
{
Expand Down
2 changes: 1 addition & 1 deletion Cpp2IL/Analysis/Actions/JumpIfZeroOrNullAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class JumpIfZeroOrNullAction : BaseAction

public JumpIfZeroOrNullAction(MethodAnalysis context, Instruction instruction) : base(context, instruction)
{
jumpTarget = LibCpp2ILUtils.GetJumpTarget(instruction, instruction.PC + context.MethodStart);
jumpTarget = Utils.GetJumpTarget(instruction, instruction.PC + context.MethodStart);

if (jumpTarget > context.MethodStart + instruction.PC && jumpTarget < context.AbsoluteMethodEnd)
{
Expand Down
4 changes: 2 additions & 2 deletions Cpp2IL/Analysis/Actions/LoadVirtualFunctionPointerAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public LoadVirtualFunctionPointerAction(MethodAnalysis context, Instruction inst

classReadFrom = klass.backingType;

var readOffset = LibCpp2ILUtils.GetOperandMemoryOffset(instruction.Operands[1]);
var readOffset = Utils.GetOperandMemoryOffset(instruction.Operands[1]);
methodPointerRead = Utils.GetMethodFromReadKlassOffset(readOffset);

if (methodPointerRead == null) return;

var regPutInto = Utils.GetRegisterName(instruction.Operands[0]);
if (regPutInto == "rsp")
{
var stackOffset = LibCpp2ILUtils.GetOperandMemoryOffset(instruction.Operands[0]);
var stackOffset = Utils.GetOperandMemoryOffset(instruction.Operands[0]);
context.PushToStack(context.MakeConstant(typeof(MethodDefinition), methodPointerRead), stackOffset);
}
else
Expand Down
Loading

0 comments on commit 38fab4d

Please sign in to comment.