public LdftnAnnotation(IMethodDescriptor method) : base(VMCalls.LDFTN, VMType.Pointer) { Function = null; Signature = null; Method = method; }
public ModelBindingCommandHandler( Delegate handlerDelegate, IMethodDescriptor methodDescriptor) { _handlerDelegate = handlerDelegate ?? throw new ArgumentNullException(nameof(handlerDelegate)); _methodDescriptor = methodDescriptor ?? throw new ArgumentNullException(nameof(methodDescriptor)); }
internal ParameterDescriptor( ParameterInfo parameterInfo, IMethodDescriptor parent) { Parent = parent; _parameterInfo = parameterInfo; }
public LdftnAnnotation(IMethodDescriptor method, bool isVirtual) : base(VMCalls.LDFTN, VMType.Pointer) { Function = null; Signature = null; Method = method; IsVirtual = isVirtual; }
public ModelBindingCommandHandler( MethodInfo handlerMethodInfo, IMethodDescriptor methodDescriptor, object?invocationTarget) : this(handlerMethodInfo, methodDescriptor) { _invocationTarget = invocationTarget; }
/// <inheritdoc /> public int GetHashCode(IMethodDescriptor obj) { unchecked { int hashCode = obj.Name == null ? 0 : obj.Name.GetHashCode(); hashCode = (hashCode * 397) ^ GetHashCode(obj.DeclaringType); hashCode = (hashCode * 397) ^ GetHashCode(obj.Signature); return(hashCode); } }
private readonly bool _enforceExplicitBinding = false; // We have not exposed this because we anticipate changing how explicit/implicit binding is defined. public ModelBindingCommandHandler( MethodInfo handlerMethodInfo, IMethodDescriptor methodDescriptor) { _handlerMethodInfo = handlerMethodInfo ?? throw new ArgumentNullException(nameof(handlerMethodInfo)); _invocationTargetBinder = _handlerMethodInfo.IsStatic ? null : new ModelBinder(_handlerMethodInfo.DeclaringType); _methodDescriptor = methodDescriptor ?? throw new ArgumentNullException(nameof(methodDescriptor)); }
public static void DiscoverMethod(string[] args, Logger Log) { foreach (var Type in ModuleDefinition.FromFile(args[0]).GetAllTypes()) { foreach (var Method in Type.Methods) { if (Method.Name == args[1] && Method.Parameters.Count == int.Parse(args[2])) { DecMethod = Method; Log.Info($"Decryption Method Found Params : {DecMethod.Resolve().Parameters.Count} :D"); } } } }
/// <summary> /// Verifies and inserts an instruction into the collection that references a method. /// </summary> /// <param name="index">The zero-based index at which the instruction should be inserted at.</param> /// <param name="code">The method opcode.</param> /// <param name="method">The method referenced by the instruction.</param> /// <returns>The created instruction.</returns> /// <exception cref="InvalidCilInstructionException"> /// Occurs when the provided operation is not a method opcode. /// </exception> /// <exception cref="ArgumentNullException"> /// Occurs when <paramref name="method"/> is null. /// </exception> public CilInstruction Insert(int index, CilOpCode code, IMethodDescriptor method) { if (code.OperandType != CilOperandType.InlineMethod && code.OperandType != CilOperandType.InlineTok) { throw new InvalidCilInstructionException(code); } if (method is null) { throw new ArgumentNullException(nameof(method)); } return(InsertAndReturn(index, code, method)); }
public IList <CilExpression> RecompileCallArguments( IMethodDescriptor method, IList <ILExpression> arguments, VMECallOpCode opCode, ITypeDescriptor constrainedType = null) { var methodSig = method.Signature; var result = new List <CilExpression>(); // Emit arguments. for (var i = 0; i < arguments.Count; i++) { // Recompile argument. var cilArgument = (CilExpression)arguments[i].AcceptVisitor(Recompiler); // Figure out expected argument type. TypeSignature argumentType; if (methodSig.HasThis && opCode != VMECallOpCode.NEWOBJ) { // Instance method invocation. if (i == 0) { // First parameter is the object instance that this method is called on (implicit this parameter). argumentType = constrainedType?.ToTypeSignature() ?? method.DeclaringType.ToTypeSignature(); // Calls on instance methods of value types need the this parameter to be passed on by-ref. if (argumentType.IsValueType) { argumentType = new ByReferenceTypeSignature(argumentType); } } else { argumentType = methodSig.ParameterTypes[i - 1]; } } else { // Static method invocation. argumentType = methodSig.ParameterTypes[i]; } cilArgument.ExpectedType = argumentType.InstantiateGenericTypes(GenericContext); result.Add(cilArgument); } return(result); }
/// <inheritdoc /> public bool Equals(IMethodDescriptor x, IMethodDescriptor y) { if (ReferenceEquals(x, y)) { return(true); } if (ReferenceEquals(x, null) || ReferenceEquals(y, null)) { return(false); } if (x is MethodSpecification specification) { return(Equals(specification, y as MethodSpecification)); } return(x.Name == y.Name && Equals(x.DeclaringType, y.DeclaringType) && Equals(x.Signature, y.Signature)); }
private static int DetermineVarPushCount(CilInstruction instruction) { var signature = instruction.Operand switch { IMethodDescriptor method => method.Signature, StandAloneSignature standAloneSig => standAloneSig.Signature as MethodSignature, _ => null }; if (signature == null) { return(0); } if (!signature.ReturnType.IsTypeOf("System", "Void") || instruction.OpCode.Code == CilCode.Newobj) { return(1); } return(0); }
/// <summary> /// Do Proxy Signature. /// </summary> /// <param name="IsNewobj"> Ditermine If The Processed Instruction Is CilOpCodes.NewObj. </param> /// <param name="Method"> Method to Call. </param> /// <returns> Proxy Method Sig. </returns> private static MethodSignature GetSignature(bool IsNewobj, IMethodDescriptor Method) { // Get Return Type. var _returntype = IsNewobj ? Method.DeclaringType.ToTypeSignature() : Method.Signature.ReturnType; // Assign Params Type. IList <TypeSignature> _params = new List <TypeSignature>(); /// Inserting TypeSigs From <param name="Method"/> Sig. foreach (var _tsig in Method.Signature.ParameterTypes) { _params.Add(_tsig); } // If Method Is HasThis Insert Object Sig. if (Method.Signature.HasThis && !IsNewobj) { _params.Insert(0, _importer.ImportTypeSignature(Method.Resolve().Parameters.ThisParameter.ParameterType)); } // Finally Return Maded Sig. return(MethodSignature.CreateStatic(_returntype, _params)); }
public static void DiscoverMethod(string[] args, Logger Log, bool IsMD, string MDToken) { var Temp = ModuleDefinition.FromFile(args[0]); if (IsMD) { DecMethod = (IMethodDescriptor)Temp.LookupMember(new MetadataToken((uint)Convert.ToInt32(MDToken, 16))); Log.Info($"Decryption Method Found Params : {DecMethod.Resolve().Parameters.Count} :D"); return; } foreach (var Type in Temp.GetAllTypes()) { foreach (var Method in Type.Methods) { if (Method.Name == args[1] && Method.Parameters.Count == int.Parse(args[2])) { DecMethod = Method; Log.Info($"Decryption Method Found Params : {DecMethod.Resolve().Parameters.Count} :D"); } } } }
private static int DetermineVarPopCount(CilInstruction instruction, bool isVoid) { var opCode = instruction.OpCode; var signature = instruction.Operand switch { IMethodDescriptor method => method.Signature, StandAloneSignature standAloneSig => standAloneSig.Signature as MethodSignature, _ => null }; if (signature == null) { if (opCode.Code == CilCode.Ret) { return(isVoid ? 0 : 1); } } else { int count = signature.GetTotalParameterCount(); switch (opCode.Code) { case CilCode.Newobj: // NewObj produces instead of consumes the this parameter. count--; break; case CilCode.Calli: // Calli consumes an extra parameter (the address to call). count++; break; } return(count); } return(0); }
protected virtual object Create(Type type, string name, IContract contract) { IMethodDescriptor create = this.Reflection().FindDescriptor("GenericCreate").Close(type) as IMethodDescriptor; return(create.Invoke(this, name, contract)); }
/// <inheritdoc /> public ICliValue Invoke(IMethodDescriptor method, IEnumerable <ICliValue> arguments) { return(CreateReturnValue(method.Signature)); }
public IConcreteValue Invoke(IMethodDescriptor method, IEnumerable <IConcreteValue> arguments) { LastInvokedMethod = method; return(_original.Invoke(method, arguments)); }
public CilInstruction Add(CilOpCode code, IMethodDescriptor method) => Insert(Count, code, method);
public ModelBindingCommandHandler( MethodInfo handlerMethodInfo, IMethodDescriptor methodDescriptor) : this(handlerMethodInfo, methodDescriptor, null) { }
/// <summary> /// Creates a new successful method devirtualization result. /// </summary> /// <param name="method">The resolved method.</param> public MethodDevirtualizationResult(IMethodDescriptor method) { ResultingMethod = method ?? throw new ArgumentNullException(nameof(method)); Exception = null; ResultingMethodSignature = null; }
public ECallAnnotation(IMethodDescriptor method, VMECallOpCode opCode) : base(VMCalls.ECALL, method.Signature.ReturnType.ToVMType()) { Method = method; OpCode = opCode; }