-
-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement underlying work for arm64 attribute restoration
- Loading branch information
Sam Byass
committed
Oct 20, 2021
1 parent
e7a7b8d
commit 3e4268b
Showing
7 changed files
with
128 additions
and
75 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
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
25 changes: 25 additions & 0 deletions
25
Cpp2IL.Core/Analysis/Actions/Base/AbstractAttributeLoadFromListAction.cs
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,25 @@ | ||
using Cpp2IL.Core.Analysis.ResultModels; | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
|
||
namespace Cpp2IL.Core.Analysis.Actions.Base | ||
{ | ||
public abstract class AbstractAttributeLoadFromListAction<T> : BaseAction<T> | ||
{ | ||
public LocalDefinition? LocalMade; | ||
public long OffsetInList; | ||
protected TypeDefinition? _attributeType; | ||
|
||
protected AbstractAttributeLoadFromListAction(MethodAnalysis<T> context, T instruction) : base(context, instruction) { } | ||
|
||
public sealed override Instruction[] ToILInstructions(MethodAnalysis<T> context, ILProcessor processor) => throw new System.InvalidOperationException("Should not be attempting to generate IL for this type of instruction!"); | ||
|
||
public sealed override string? ToPsuedoCode() => throw new System.InvalidOperationException("Should not be attempting to generate pseudocode for this type of instruction!"); | ||
|
||
public sealed override string ToTextSummary() => $"[!] Loads the attribute instance at offset {OffsetInList} which is of type {_attributeType}, and stores in new local {LocalMade}"; | ||
|
||
public sealed override bool IsImportant() => false; | ||
|
||
public sealed override bool PseudocodeNeedsLinebreakBefore() => false; | ||
} | ||
} |
31 changes: 5 additions & 26 deletions
31
Cpp2IL.Core/Analysis/Actions/x86/LoadAttributeFromAttributeListAction.cs
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 |
---|---|---|
@@ -1,44 +1,23 @@ | ||
using System.Collections.Generic; | ||
using Cpp2IL.Core.Analysis.Actions.Base; | ||
using Cpp2IL.Core.Analysis.ResultModels; | ||
using Iced.Intel; | ||
using LibCpp2IL; | ||
using Mono.Cecil; | ||
using Mono.Cecil.Cil; | ||
using Instruction = Iced.Intel.Instruction; | ||
|
||
namespace Cpp2IL.Core.Analysis.Actions.x86 | ||
{ | ||
public class LoadAttributeFromAttributeListAction : BaseAction<Instruction> | ||
public class LoadAttributeFromAttributeListAction : AbstractAttributeLoadFromListAction<Instruction> | ||
{ | ||
public LocalDefinition? LocalMade; | ||
private string? _destReg; | ||
public TypeDefinition? AttributeType; | ||
public long OffsetInList; | ||
|
||
public LoadAttributeFromAttributeListAction(MethodAnalysis<Instruction> context, Instruction instruction, List<TypeDefinition> attributes) : base(context, instruction) | ||
{ | ||
var ptrSize = LibCpp2IlMain.Binary!.is32Bit ? 4 : 8; | ||
OffsetInList = instruction.MemoryDisplacement32 / ptrSize; | ||
|
||
AttributeType = attributes[(int) OffsetInList]; | ||
|
||
_destReg = Utils.GetRegisterNameNew(instruction.Op0Register); | ||
LocalMade = context.MakeLocal(AttributeType, reg: _destReg); | ||
} | ||
|
||
public override Mono.Cecil.Cil.Instruction[] ToILInstructions(MethodAnalysis<Instruction> context, ILProcessor processor) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
public override string? ToPsuedoCode() | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
_attributeType = attributes[(int) OffsetInList]; | ||
|
||
public override string ToTextSummary() | ||
{ | ||
return $"[!] Loads the attribute instance at offset {OffsetInList} which is of type {AttributeType}, and stores in new local {LocalMade} in {_destReg}"; | ||
var destReg = Utils.GetRegisterNameNew(instruction.Op0Register); | ||
LocalMade = context.MakeLocal(_attributeType, reg: destReg); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using System.Text; | ||
using Cpp2IL.Core.Analysis.Actions.Base; | ||
|
||
namespace Cpp2IL.Core.Analysis | ||
{ | ||
|
Oops, something went wrong.