Пример #1
0
        private bool TryResolveMethodFromTarget(ClrObject obj, out ClrMethod methodDescriptor)
        {
            methodDescriptor = null;
            var target     = obj.GetRefFld("_target");
            var _methodPtr = (ulong)(long)obj.GetSimpleFld <object>("_methodPtr");

            // TODO: Handle empty types types ?
            if (_methodPtr == 0 || target.IsNullObj || target.Type == null)
            {
                return(false);
            }
            methodDescriptor = target.Type.Methods.FirstOrDefault(methodInfo => methodInfo.NativeCode == _methodPtr);

            return(methodDescriptor != null);
        }
Пример #2
0
        private bool TryReadMethodPtr(ClrObject obj, [CanBeNull] out ClrMethod methodDescriptor)
        {
            methodDescriptor = null;
            ClrRuntime rn = obj.Type.Heap.Runtime;

            try
            {
                var _methodPtr = (ulong)(long)obj.GetSimpleFld <object>("_methodPtr");
                if (_methodPtr == 0)
                {
                    return(false);
                }
                byte[] commandOpCode = ReadBytes(_methodPtr, rn, 1);

                return((commandOpCode[0] == 0xE9) && TryProcessNearJump(_methodPtr, rn, out methodDescriptor) &&
                       (methodDescriptor != null));
            }
            catch (Exception)
            {
                return(false);
            }
        }