コード例 #1
0
        byte[] GetData(ContextMenuEntryContext context)
        {
            var md = TVShowMethodInstructionsInHexEditorCommand.GetMemberDef(context) as MethodDef;

            if (md == null)
            {
                return(null);
            }
            return(GetData(md));
        }
コード例 #2
0
        static AddressReference GetAddressReference(ContextMenuEntryContext context)
        {
            if (ShowAddressReferenceInHexEditorCommand.IsVisibleInternal(context))
            {
                return(null);
            }
            if (TVShowMethodInstructionsInHexEditorCommand.IsVisibleInternal(context))
            {
                return(null);
            }

            var mappings = GetMappings(context);

            if (mappings == null || mappings.Count == 0)
            {
                return(null);
            }

            var method = mappings[0].MemberMapping.MethodDef;
            var mod    = mappings[0].MemberMapping.MethodDef.Module as ModuleDefMD;

            if (mod == null || string.IsNullOrEmpty(mod.Location))
            {
                return(null);
            }

            ulong addr = (ulong)method.RVA;
            ulong len;

            if (MethodAnnotations.Instance.IsBodyModified(method))
            {
                len = 0;
            }
            else if (mappings.Count == 1)
            {
                addr += (ulong)method.Body.HeaderSize + mappings[0].ILInstructionOffset.From;
                len   = mappings[0].ILInstructionOffset.To - mappings[0].ILInstructionOffset.From;
            }
            else
            {
                addr += (ulong)method.Body.HeaderSize + mappings[0].ILInstructionOffset.From;
                len   = 0;
            }

            return(new AddressReference(mod.Location, true, addr, len));
        }
コード例 #3
0
        static AddressReference GetAddressReference(ContextMenuEntryContext context)
        {
            var fd = TVShowMethodInstructionsInHexEditorCommand.GetMemberDef(context) as FieldDef;

            if (fd == null || fd.RVA == 0)
            {
                return(null);
            }
            var iv = fd.InitialValue;

            if (iv == null)
            {
                return(null);
            }

            var mod = fd.Module;

            return(new AddressReference(mod == null ? null : mod.Location, true, (ulong)fd.RVA, (ulong)iv.Length));
        }
コード例 #4
0
        internal static LengthAndOffset?GetMethodLengthAndOffset(ContextMenuEntryContext context)
        {
            var md = TVShowMethodInstructionsInHexEditorCommand.GetMemberDef(context) as MethodDef;

            if (md == null)
            {
                return(null);
            }
            var mod = md.Module;

            if (mod == null || !File.Exists(mod.Location))
            {
                return(null);
            }
            uint rva;
            long fileOffset;

            if (!md.GetRVA(out rva, out fileOffset))
            {
                return(null);
            }

            return(new LengthAndOffset(mod.Location, (ulong)fileOffset, InstructionUtils.GetTotalMethodBodyLength(md)));
        }