• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DotNet.FieldDef类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中dnlib.DotNet.FieldDef的典型用法代码示例。如果您正苦于以下问题:C# FieldDef类的具体用法?C# FieldDef怎么用?C# FieldDef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FieldDef类属于dnlib.DotNet命名空间,在下文中一共展示了FieldDef类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AnalyzedFieldTreeNode

		public AnalyzedFieldTreeNode(FieldDef analyzedField)
		{
			if (analyzedField == null)
				throw new ArgumentNullException("analyzedField");
			this.analyzedField = analyzedField;
			this.LazyLoading = true;
		}
开发者ID:nakijun,项目名称:dnSpy,代码行数:7,代码来源:AnalyzedFieldTreeNode.cs


示例2: AnalyzedFieldAccessTreeNode

		public AnalyzedFieldAccessTreeNode(FieldDef analyzedField, bool showWrites) {
			if (analyzedField == null)
				throw new ArgumentNullException("analyzedField");

			this.analyzedField = analyzedField;
			this.showWrites = showWrites;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:7,代码来源:AnalyzedFieldAccessTreeNode.cs


示例3: FieldAccessNode

		public FieldAccessNode(FieldDef analyzedField, bool showWrites) {
			if (analyzedField == null)
				throw new ArgumentNullException(nameof(analyzedField));

			this.analyzedField = analyzedField;
			this.showWrites = showWrites;
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:7,代码来源:FieldAccessNode.cs


示例4: GetMemberIcon

		static MemberIcon GetMemberIcon(FieldDef field)
		{
			var access = GetMemberAccess(field);

			if (field.DeclaringType.IsEnum && !field.IsSpecialName) {
				switch (access) {
				case MemberAccess.Public: return MemberIcon.EnumValue;
				case MemberAccess.Private: return MemberIcon.EnumValuePrivate;
				case MemberAccess.Protected: return MemberIcon.EnumValueProtected;
				case MemberAccess.Internal: return MemberIcon.EnumValueInternal;
				case MemberAccess.CompilerControlled: return MemberIcon.EnumValueCompilerControlled;
				case MemberAccess.ProtectedInternal: return MemberIcon.EnumValueProtectedInternal;
				default:
					Debug.Fail("Invalid MemberAccess");
					goto case MemberAccess.Public;
				}
			}

			if (field.IsLiteral || (field.IsInitOnly && IsDecimalConstant(field))) {
				switch (access) {
				case MemberAccess.Public: return MemberIcon.Literal;
				case MemberAccess.Private: return MemberIcon.LiteralPrivate;
				case MemberAccess.Protected: return MemberIcon.LiteralProtected;
				case MemberAccess.Internal: return MemberIcon.LiteralInternal;
				case MemberAccess.CompilerControlled: return MemberIcon.LiteralCompilerControlled;
				case MemberAccess.ProtectedInternal: return MemberIcon.LiteralProtectedInternal;
				default:
					Debug.Fail("Invalid MemberAccess");
					goto case MemberAccess.Public;
				}
			}
			else if (field.IsInitOnly) {
				switch (access) {
				case MemberAccess.Public: return MemberIcon.FieldReadOnly;
				case MemberAccess.Private: return MemberIcon.FieldReadOnlyPrivate;
				case MemberAccess.Protected: return MemberIcon.FieldReadOnlyProtected;
				case MemberAccess.Internal: return MemberIcon.FieldReadOnlyInternal;
				case MemberAccess.CompilerControlled: return MemberIcon.FieldReadOnlyCompilerControlled;
				case MemberAccess.ProtectedInternal: return MemberIcon.FieldReadOnlyProtectedInternal;
				default:
					Debug.Fail("Invalid MemberAccess");
					goto case MemberAccess.Public;
				}
			}
			else {
				switch (access) {
				case MemberAccess.Public: return MemberIcon.Field;
				case MemberAccess.Private: return MemberIcon.FieldPrivate;
				case MemberAccess.Protected: return MemberIcon.FieldProtected;
				case MemberAccess.Internal: return MemberIcon.FieldInternal;
				case MemberAccess.CompilerControlled: return MemberIcon.FieldCompilerControlled;
				case MemberAccess.ProtectedInternal: return MemberIcon.FieldProtectedInternal;
				default:
					Debug.Fail("Invalid MemberAccess");
					goto case MemberAccess.Public;
				}
			}
		}
开发者ID:nakijun,项目名称:dnSpy,代码行数:58,代码来源:FieldTreeNode.cs


示例5: Write

		public static ITextOutput Write(ITextOutput output, FieldDef field, Language language) {
			output.Write(UIUtils.CleanUpIdentifier(field.Name), TextTokenHelper.GetTextTokenType(field));
			output.WriteSpace();
			output.Write(':', TextTokenType.Operator);
			output.WriteSpace();
			language.TypeToString(output, field.FieldType.ToTypeDefOrRef(), false, field);
			field.MDToken.WriteSuffixString(output);
			return output;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:9,代码来源:FieldTreeNode.cs


示例6: FieldDefOptions

		public FieldDefOptions(FieldDef field) {
			this.Attributes = field.Attributes;
			this.Name = field.Name;
			this.FieldSig = field.FieldSig;
			this.FieldOffset = field.FieldOffset;
			this.MarshalType = field.MarshalType;
			this.RVA = field.RVA;
			this.InitialValue = field.InitialValue;
			this.ImplMap = field.ImplMap;
			this.Constant = field.Constant;
			this.CustomAttributes.AddRange(field.CustomAttributes);
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:12,代码来源:FieldDefOptions.cs


示例7: FieldDefOptions

		public FieldDefOptions(FieldDef field) {
			Attributes = field.Attributes;
			Name = field.Name;
			FieldSig = field.FieldSig;
			FieldOffset = field.FieldOffset;
			MarshalType = field.MarshalType;
			RVA = field.RVA;
			InitialValue = field.InitialValue;
			ImplMap = field.ImplMap;
			Constant = field.Constant;
			CustomAttributes.AddRange(field.CustomAttributes);
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:12,代码来源:FieldDefOptions.cs


示例8: CopyTo

		public FieldDef CopyTo(FieldDef field) {
			field.Attributes = this.Attributes;
			field.Name = this.Name ?? UTF8String.Empty;
			field.FieldSig = this.FieldSig;
			field.FieldOffset = this.FieldOffset;
			field.MarshalType = this.MarshalType;
			field.RVA = this.RVA;
			field.InitialValue = this.InitialValue;
			field.ImplMap = this.ImplMap;
			field.Constant = this.Constant;
			field.CustomAttributes.Clear();
			field.CustomAttributes.AddRange(CustomAttributes);
			return field;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:14,代码来源:FieldDefOptions.cs


示例9: GetCallInfo

		protected override void GetCallInfo(object context, FieldDef field, out IMethod calledMethod, out OpCode callOpcode) {
			var name = field.Name.String;
			callOpcode = OpCodes.Call;
			if (name.EndsWith("%", StringComparison.Ordinal)) {
				callOpcode = OpCodes.Callvirt;
				name = name.TrimEnd(new char[] { '%' });
			}
			byte[] value = Convert.FromBase64String(name);
			int methodIndex = BitConverter.ToInt32(value, 0);	// 0-based memberRef index
			var mr = module.ResolveMemberRef((uint)methodIndex + 1);
			if (mr == null || !mr.IsMethodRef)
				throw new ApplicationException(string.Format("Invalid MemberRef index: {0}", methodIndex));
			calledMethod = mr;
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:14,代码来源:ProxyCallFixer.cs


示例10: Execute

        public static void Execute(ModuleDefMD module)
        {
            cctor = module.GlobalType.FindStaticConstructor();
            Dictionary<FieldDef, Tuple<byte[], int>> fields = new Dictionary<FieldDef,Tuple<byte[], int>>();
            List<byte> data = new List<byte>();
            int count = 0;
            foreach (var method in  module.GetTypes().SelectMany(type => type.Methods))
            {
                if (method.HasBody)
                {
                    List<Instruction> stringInstr = method.Body.Instructions.Where(instr => instr.OpCode == OpCodes.Ldstr).ToList();
                    for (int i = 0; i < stringInstr.Count; i++)
                    {
                        byte[] stringByte = Encoding.UTF8.GetBytes(stringInstr[i].Operand as string);
                        data.AddRange(stringByte);
                        FieldDef field = CreateField(module);
                        fields.Add(field, Tuple.Create(stringByte, count));
                        method.DeclaringType.Fields.Add(field);
                        stringInstr[i].OpCode = OpCodes.Ldsfld;
                        stringInstr[i].Operand = field;
                        count++;
                    }
                }
            }
            staticFields = fields;
            data = Encrypt(data.ToArray()).ToList();
            var dataType = new TypeDefUser("", "", module.CorLibTypes.GetTypeRef("System", "ValueType"));
            RenameTask.Rename(dataType);
            dataType.Layout = TypeAttributes.ExplicitLayout;
            dataType.Visibility = TypeAttributes.NestedPrivate;
            dataType.IsSealed = true;
            dataType.ClassLayout = new ClassLayoutUser(1, (uint)data.Count);
            module.GlobalType.NestedTypes.Add(dataType);

            var dataField = new FieldDefUser("", new FieldSig(dataType.ToTypeSig()))
            {
                IsStatic = true,
                HasFieldRVA = true,
                InitialValue = data.ToArray(),
                Access = FieldAttributes.CompilerControlled
            };
            module.GlobalType.Fields.Add(dataField);
            GlobalDataField = dataField;
            RenameTask.Rename(dataField);
            NETUtils.listener.OnWriterEvent += OnWriterEvent;
        }
开发者ID:M3rcurio,项目名称:denvlib,代码行数:46,代码来源:StringEncodingTaskTest.cs


示例11: GetCallInfo

		protected override void GetCallInfo(object context, FieldDef field, out IMethod calledMethod, out OpCode callOpcode) {
			var ctx = (Context)context;

			switch (ctx.proxyCreatorType) {
			case ProxyCreatorType.CallOrCallvirt:
				callOpcode = field.IsFamilyOrAssembly ? OpCodes.Callvirt : OpCodes.Call;
				break;
			case ProxyCreatorType.CallCtor:
				callOpcode = OpCodes.Call;
				break;
			case ProxyCreatorType.Newobj:
				callOpcode = OpCodes.Newobj;
				break;
			default:
				throw new ApplicationException(string.Format("Invalid proxy creator type: {0}", ctx.proxyCreatorType));
			}

			calledMethod = module.ResolveToken(ctx.methodToken) as IMethod;
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:19,代码来源:ProxyCallFixer.cs


示例12: GetCallInfo

		protected override void GetCallInfo(object context, FieldDef field, out IMethod calledMethod, out OpCode callOpcode) {
			callOpcode = OpCodes.Call;
			string name = field.Name.String;

			uint memberRefRid = 0;
			for (int i = name.Length - 1; i >= 0; i--) {
				char c = name[i];
				if (c == '~') {
					callOpcode = OpCodes.Callvirt;
					break;
				}

				int val;
				if (specialCharsDict.TryGetValue(c, out val))
					memberRefRid = memberRefRid * (uint)specialChars.Length + (uint)val;
			}
			memberRefRid++;

			calledMethod = module.ResolveMemberRef(memberRefRid);
			if (calledMethod == null)
				Logger.w("Ignoring invalid method RID: {0:X8}, field: {1:X8}", memberRefRid, field.MDToken.ToInt32());
		}
开发者ID:GreenDamTan,项目名称:de4dot,代码行数:22,代码来源:ProxyCallFixer.cs


示例13: GetDecrypterInfo

		Info GetDecrypterInfo(MethodDef method, FieldDef delegateField) {
			try {
				int index = 0;
				var instrs = method.Body.Instructions;
				if (instrs[index].OpCode.Code != Code.Ldsfld)
					return null;
				var field = instrs[index++].Operand as FieldDef;
				if (field != delegateField)
					return null;

				if (!instrs[index].IsLdcI4())
					return null;
				int offset = instrs[index++].GetLdcI4Value();

				if (instrs[index].OpCode.Code != Code.Call && instrs[index].OpCode.Code != Code.Callvirt)
					return null;
				var calledMethod = instrs[index++].Operand as IMethod;
				if (calledMethod.Name != "Invoke")
					return null;

				if (instrs[index].OpCode.Code == Code.Unbox_Any)
					index++;

				if (instrs[index++].OpCode.Code != Code.Ret)
					return null;

				return new Info(method, offset);
			}
			catch (ArgumentOutOfRangeException) {
				return null;
			}
		}
开发者ID:GodLesZ,项目名称:de4dot,代码行数:32,代码来源:DecrypterBase.cs


示例14: DecompileField

		public override void DecompileField(FieldDef field, ITextOutput output, DecompilationOptions options)
		{
			output.WriteReference(IdentifierEscaper.Escape(field.FieldType.GetFullName()), field.FieldType.ToTypeDefOrRef(), TextTokenHelper.GetTextTokenType(field.FieldType));
			output.WriteSpace();
			output.WriteDefinition(IdentifierEscaper.Escape(field.Name), field, TextTokenHelper.GetTextTokenType(field), false);
			var c = field.Constant;
			if (c != null) {
				output.WriteSpace();
				output.Write('=', TextTokenType.Operator);
				output.WriteSpace();
				if (c.Value == null)
					output.Write("null", TextTokenType.Keyword);
				else {
					switch (c.Type) {
					case ElementType.Boolean:
						if (c.Value is bool)
							output.Write((bool)c.Value ? "true" : "false", TextTokenType.Keyword);
						else
							goto default;
						break;

					case ElementType.Char:
						output.Write(string.Format("'{0}'", c.Value), TextTokenType.Char);
						break;

					case ElementType.I1:
					case ElementType.U1:
					case ElementType.I2:
					case ElementType.U2:
					case ElementType.I4:
					case ElementType.U4:
					case ElementType.I8:
					case ElementType.U8:
					case ElementType.R4:
					case ElementType.R8:
					case ElementType.I:
					case ElementType.U:
						output.Write(string.Format("{0}", c.Value), TextTokenType.Number);
						break;

					case ElementType.String:
						output.Write(string.Format("{0}", c.Value), TextTokenType.String);
						break;

					default:
						output.Write(string.Format("{0}", c.Value), TextTokenType.Text);
						break;
					}
				}
			}
		}
开发者ID:nakijun,项目名称:dnSpy,代码行数:51,代码来源:ILAstLanguage.cs


示例15: Analyze

        void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, FieldDef field)
        {
            if (field.DeclaringType.IsVisibleOutside() &&
                (field.IsFamily || field.IsFamilyOrAssembly || field.IsPublic) &&
                !IsVisibleOutside(context, parameters, field))
                service.SetCanRename(field, false);

            else if (field.IsRuntimeSpecialName)
                service.SetCanRename(field, false);

            else if (parameters.GetParameter(context, field, "forceRen", false))
                return;

            else if (field.DeclaringType.IsSerializable && !field.IsNotSerialized)
                service.SetCanRename(field, false);

            else if (field.IsLiteral && field.DeclaringType.IsEnum)
                service.SetCanRename(field, false);
        }
开发者ID:huoxudong125,项目名称:ConfuserEx,代码行数:19,代码来源:AnalyzePhase.cs


示例16: DecompileField

 public override void DecompileField(FieldDef field, ITextOutput output, DecompilationOptions options)
 {
     var dis = CreateReflectionDisassembler(output, options, field);
     dis.DisassembleField(field);
 }
开发者ID:gsong2014,项目名称:dnSpy,代码行数:5,代码来源:ILLanguage.cs


示例17: IsVisible

		bool IsVisible(FieldDef fd, GenericInstSig git) {
			if (fd == null)
				return false;
			var fdDeclaringType = fd.DeclaringType;
			if (fdDeclaringType == null)
				return false;
			if (userType == fdDeclaringType)
				return true;

			switch (fd.Access) {
			case FieldAttributes.PrivateScope:
				// Private scope aka compiler controlled fields/methods can only be accessed
				// by a Field/Method token. This means they must be in the same module.
				return userType.Module == fdDeclaringType.Module;

			case FieldAttributes.Private:
				return false;

			case FieldAttributes.FamANDAssem:
				return IsSameAssemblyOrFriendAssembly(fdDeclaringType.Module) &&
					CheckFamily(fdDeclaringType, git);

			case FieldAttributes.Assembly:
				return IsSameAssemblyOrFriendAssembly(fdDeclaringType.Module);

			case FieldAttributes.Family:
				return CheckFamily(fdDeclaringType, git);

			case FieldAttributes.FamORAssem:
				return IsSameAssemblyOrFriendAssembly(fdDeclaringType.Module) ||
					CheckFamily(fdDeclaringType, git);

			case FieldAttributes.Public:
				return true;

			default:
				return false;
			}
		}
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:39,代码来源:AccessChecker.cs


示例18: GetFilterResult

 public override TreeViewNodeFilterResult GetFilterResult(FieldDef field)
 {
     bool isMatch = (flags & VisibleMembersFlags.FieldDef) != 0;
     if (!isMatch)
         return new TreeViewNodeFilterResult(FilterResult.Hidden, isMatch);
     return new TreeViewNodeFilterResult(FilterResult.Match, isMatch);
 }
开发者ID:BahNahNah,项目名称:dnSpy,代码行数:7,代码来源:FlagsTreeViewNodeFilter.cs


示例19: CanAccess

		/// <summary>
		/// Checks whether it can access a <see cref="FieldDef"/>
		/// </summary>
		/// <param name="fd">The field</param>
		/// <returns><c>true</c> if it has access to it, <c>false</c> if not, and <c>null</c>
		/// if we can't determine it (eg. we couldn't resolve a type or input was <c>null</c>)</returns>
		public bool? CanAccess(FieldDef fd) {
			return CanAccess(fd, null);
		}
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:9,代码来源:AccessChecker.cs


示例20: FindDelegateFieldV2_0_9_0

		static FieldDef FindDelegateFieldV2_0_9_0(TypeDef mainType, FieldDef decryptCallbackField) {
			if (decryptCallbackField == null)
				return null;
			var type = decryptCallbackField.FieldSig.GetFieldType().ToTypeDefOrRef() as TypeDef;
			if (type == null)
				return null;
			return FindDelegateField(mainType, "System.Boolean", string.Format("(System.Int32,System.Int32,System.Int32,System.Int32,System.Diagnostics.StackTrace,{0})", type.FullName));
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:8,代码来源:DynamicMethodsDecrypter.cs



注:本文中的dnlib.DotNet.FieldDef类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DotNet.FullNameCreator类代码示例发布时间:2022-05-26
下一篇:
C# DotNet.ExportedType类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap