本文整理汇总了C#中dnlib.DotNet.ModuleDefMD.GetTypes方法的典型用法代码示例。如果您正苦于以下问题:C# ModuleDefMD.GetTypes方法的具体用法?C# ModuleDefMD.GetTypes怎么用?C# ModuleDefMD.GetTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dnlib.DotNet.ModuleDefMD
的用法示例。
在下文中一共展示了ModuleDefMD.GetTypes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindAll
public static List<MethodDef> FindAll(ModuleDefMD module) {
var list = new List<MethodDef>();
foreach (var type in module.GetTypes()) {
foreach (var method in type.Methods) {
if (IsInvalidMethod(method))
list.Add(method);
}
}
return list;
}
示例2: Find
public static List<MethodDef> Find(ModuleDefMD module, IEnumerable<MethodDef> notInlinedMethods) {
var notInlinedMethodsDict = new Dictionary<MethodDef, bool>();
foreach (var method in notInlinedMethods)
notInlinedMethodsDict[method] = true;
var inlinedMethods = new List<MethodDef>();
foreach (var type in module.GetTypes()) {
foreach (var method in type.Methods) {
if (!notInlinedMethodsDict.ContainsKey(method) && CanInline(method))
inlinedMethods.Add(method);
}
}
return inlinedMethods;
}
示例3: 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;
}
示例4: Execute
public static void Execute(ModuleDefMD module)
{
int key = rand.Next(97, 122);
/* rand.GetBytes(byteKey);
var dataType = new TypeDefUser(module.GlobalType.Namespace, "", 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)byteKey.Length);
module.GlobalType.NestedTypes.Add(dataType);
var dataField = new FieldDefUser("", new FieldSig(dataType.ToTypeSig()))
{
IsStatic = true,
HasFieldRVA = true,
InitialValue = byteKey,
Access = FieldAttributes.CompilerControlled
};
module.GlobalType.Fields.Add(dataField);
RenameTask.Rename(dataField);*/
TypeDef stringInjType = NETUtils.ImportType(typeof(StringEncInj));
MethodDef stringDecMeth = NETUtils.GetMethodByName(stringInjType, "StringDec");
stringDecMeth.DeclaringType = null;
stringDecMeth.Body.Instructions[13].OpCode = OpCodes.Ldc_I4;
stringDecMeth.Body.Instructions[13].Operand = key;
RenameTask.Rename(stringDecMeth, true);
TypeDef cctor = module.GlobalType;
cctor.Methods.Add(stringDecMeth);
foreach (var method in module.GetTypes().SelectMany(type => type.Methods))
{
if (method != stringDecMeth && method.HasBody)
{
List<Instruction> stringInstr = method.Body.Instructions.Where(instr => instr.OpCode == OpCodes.Ldstr).ToList();
for (int i = 0; i < stringInstr.Count; i++)
{
int index = method.Body.Instructions.IndexOf(stringInstr[i]);
stringInstr[i].Operand = Ecrypt((string)stringInstr[i].Operand,key);
method.Body.Instructions.Insert(index + 1, Instruction.Create(OpCodes.Call, stringDecMeth));
}
}
}
}