本文整理汇总了C#中de4dot.blocks.Block类的典型用法代码示例。如果您正苦于以下问题:C# Block类的具体用法?C# Block怎么用?C# Block使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Block类属于de4dot.blocks命名空间,在下文中一共展示了Block类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: createCallResult
protected override CallResult createCallResult(IMethod method, MethodSpec gim, Block block, int callInstrIndex)
{
int methodId;
if (!methodTokenToId.TryGetValue(method.MDToken.ToInt32(), out methodId))
return null;
return new MyCallResult(block, callInstrIndex, methodId, gim);
}
开发者ID:n017,项目名称:ConfuserDeobfuscator,代码行数:7,代码来源:StringInliner.cs
示例2: Deobfuscate
protected override bool Deobfuscate(Block block)
{
bool modified = false;
constantsReader = null;
var instrs = block.Instructions;
for (int i = 0; i < instrs.Count; i++) {
bool ch = Deobfuscate1(block, i);
if (ch) {
modified = true;
continue;
}
ch = Deobfuscate2(block, i);
if (ch) {
modified = true;
continue;
}
ch = Deobfuscate3(block, i);
if (ch) {
modified = true;
continue;
}
}
return modified;
}
开发者ID:kakkerlakgly,项目名称:de4dot,代码行数:28,代码来源:ArrayBlockDeobfuscator.cs
示例3: createCallResult
protected override CallResult createCallResult(MethodReference method, Block block, int callInstrIndex)
{
int methodId;
if (!methodTokenToId.TryGetValue(method.MetadataToken.ToInt32(), out methodId))
return null;
return new MyCallResult(block, callInstrIndex, methodId);
}
开发者ID:ldh0227,项目名称:de4dot,代码行数:7,代码来源:StringDecrypter.cs
示例4: AddInitializeArrayCode
public void AddInitializeArrayCode(Block block, int start, int numToRemove, ITypeDefOrRef elementType, byte[] data) {
int index = start;
block.Replace(index++, numToRemove, Instruction.CreateLdcI4(data.Length / elementType.ToTypeSig().ElementType.GetPrimitiveSize()));
block.Insert(index++, OpCodes.Newarr.ToInstruction(elementType));
block.Insert(index++, OpCodes.Dup.ToInstruction());
block.Insert(index++, OpCodes.Ldtoken.ToInstruction((IField)Create(data)));
block.Insert(index++, OpCodes.Call.ToInstruction((IMethod)InitializeArrayMethod));
}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:8,代码来源:InitializedDataCreator.cs
示例5: addInitializeArrayCode
public void addInitializeArrayCode(Block block, int start, int numToRemove, TypeReference elementType, byte[] data)
{
int index = start;
block.replace(index++, numToRemove, DotNetUtils.createLdci4(data.Length / elementType.PrimitiveSize));
block.insert(index++, Instruction.Create(OpCodes.Newarr, elementType));
block.insert(index++, Instruction.Create(OpCodes.Dup));
block.insert(index++, Instruction.Create(OpCodes.Ldtoken, create(data)));
block.insert(index++, Instruction.Create(OpCodes.Call, InitializeArrayMethod));
}
开发者ID:Joelone,项目名称:de4dot,代码行数:9,代码来源:InitializedDataCreator.cs
示例6: deobfuscate
protected override bool deobfuscate(Block block)
{
bool changed = false;
instructionEmulator.init(blocks);
var instrs = block.Instructions;
for (int i = 0; i < instrs.Count; i++) {
var instr = instrs[i];
switch (instr.OpCode.Code) {
case Code.Ldarg:
case Code.Ldarg_0:
case Code.Ldarg_1:
case Code.Ldarg_2:
case Code.Ldarg_3:
case Code.Ldarg_S:
changed |= fixLoadInstruction(block, i, instructionEmulator.getArg(DotNetUtils.getParameter(args, instr.Instruction)));
break;
case Code.Ldloc:
case Code.Ldloc_0:
case Code.Ldloc_1:
case Code.Ldloc_2:
case Code.Ldloc_3:
case Code.Ldloc_S:
changed |= fixLoadInstruction(block, i, instructionEmulator.getLocal(DotNetUtils.getLocalVar(blocks.Locals, instr.Instruction)));
break;
case Code.Ldarga:
case Code.Ldarga_S:
instructionEmulator.makeArgUnknown((ParameterDefinition)instr.Operand);
break;
case Code.Ldloca:
case Code.Ldloca_S:
instructionEmulator.makeLocalUnknown((VariableDefinition)instr.Operand);
break;
}
try {
instructionEmulator.emulate(instr.Instruction);
}
catch (NullReferenceException) {
// Here if eg. invalid metadata token in a call instruction (operand is null)
break;
}
}
return changed;
}
开发者ID:n017,项目名称:NETDeob,代码行数:50,代码来源:ConstantsFolder.cs
示例7: Deobfuscate
protected override bool Deobfuscate(Block block) {
bool modified = false;
instructionEmulator.Initialize(blocks, allBlocks[0] == block);
var instrs = block.Instructions;
for (int i = 0; i < instrs.Count; i++) {
var instr = instrs[i];
switch (instr.OpCode.Code) {
case Code.Ldarg:
case Code.Ldarg_0:
case Code.Ldarg_1:
case Code.Ldarg_2:
case Code.Ldarg_3:
case Code.Ldarg_S:
modified |= FixLoadInstruction(block, i, instructionEmulator.GetArg(instr.Instruction.GetParameter(args)));
break;
case Code.Ldloc:
case Code.Ldloc_0:
case Code.Ldloc_1:
case Code.Ldloc_2:
case Code.Ldloc_3:
case Code.Ldloc_S:
modified |= FixLoadInstruction(block, i, instructionEmulator.GetLocal(instr.Instruction.GetLocal(blocks.Locals)));
break;
case Code.Ldarga:
case Code.Ldarga_S:
instructionEmulator.MakeArgUnknown((Parameter)instr.Operand);
break;
case Code.Ldloca:
case Code.Ldloca_S:
instructionEmulator.MakeLocalUnknown((Local)instr.Operand);
break;
}
try {
instructionEmulator.Emulate(instr.Instruction);
}
catch (NullReferenceException) {
// Here if eg. invalid metadata token in a call instruction (operand is null)
break;
}
}
return modified;
}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:49,代码来源:ConstantsFolder.cs
示例8: findCallMethod
static int findCallMethod(Block block, int index, bool keepLooking, Func<IMethod, bool> func)
{
var instrs = block.Instructions;
for (int i = index; i < instrs.Count; i++) {
var instr = instrs[i];
if (instr.OpCode.Code != Code.Call && instr.OpCode.Code != Code.Callvirt)
continue;
var calledMethod = instr.Operand as IMethod;
if (calledMethod != null && func(calledMethod))
return i;
if (!keepLooking)
return -1;
}
return -1;
}
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:16,代码来源:TamperProtectionRemover.cs
示例9: add
void add(Dictionary<Block, List<RemoveInfo>> removeInfos, Block block, int index, DelegateInfo di)
{
List<RemoveInfo> list;
if (!removeInfos.TryGetValue(block, out list))
removeInfos[block] = list = new List<RemoveInfo>();
list.Add(new RemoveInfo {
Index = index,
DelegateInfo = di,
});
}
开发者ID:Perplexity,项目名称:de4dot,代码行数:10,代码来源:ProxyDelegateFinderBase.cs
示例10: MyCallResult
public MyCallResult(Block block, int callEndIndex, IMethod method, MethodSpec gim)
: base(block, callEndIndex)
{
this.IMethod = method;
this.gim = gim;
}
开发者ID:n017,项目名称:ConfuserDeobfuscator,代码行数:6,代码来源:StringInliner.cs
示例11: removeDeadBlock
void removeDeadBlock(Block block)
{
var parent = block.Parent;
if (parent != null) // null if already dead
parent.removeDeadBlock(block);
}
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:6,代码来源:TamperProtectionRemover.cs
示例12: GetNopBlockTarget
static Block GetNopBlockTarget(Dictionary<Block, bool> nopBlocks, Block source, Block nopBlock) {
if (nopBlock == null || !nopBlocks.ContainsKey(nopBlock) || source == nopBlock.FallThrough)
return null;
if (nopBlock.Parent.BaseBlocks[0] == nopBlock)
return null;
var target = nopBlock.FallThrough;
if (nopBlock.Parent != target.Parent)
return null;
return target;
}
开发者ID:GodLesZ,项目名称:de4dot,代码行数:10,代码来源:Blocks.cs
示例13: GetArg
bool GetArg(IMethod method, Block block, ref object arg, ref int instrIndex) {
while (true) {
if (instrIndex < 0) {
// We're here if there were no cflow deobfuscation, or if there are two or
// more blocks branching to the decrypter method, or the two blocks can't be
// merged because one is outside the exception handler (eg. buggy obfuscator).
Logger.w("Could not find all arguments to method {0} ({1:X8})",
Utils.RemoveNewlines(method),
method.MDToken.ToInt32());
errors++;
return false;
}
var instr = block.Instructions[instrIndex--];
switch (instr.OpCode.Code) {
case Code.Ldc_I4:
case Code.Ldc_I8:
case Code.Ldc_R4:
case Code.Ldc_R8:
case Code.Ldstr:
arg = instr.Operand;
break;
case Code.Ldc_I4_S:
arg = (int)(sbyte)instr.Operand;
break;
case Code.Ldc_I4_0: arg = 0; break;
case Code.Ldc_I4_1: arg = 1; break;
case Code.Ldc_I4_2: arg = 2; break;
case Code.Ldc_I4_3: arg = 3; break;
case Code.Ldc_I4_4: arg = 4; break;
case Code.Ldc_I4_5: arg = 5; break;
case Code.Ldc_I4_6: arg = 6; break;
case Code.Ldc_I4_7: arg = 7; break;
case Code.Ldc_I4_8: arg = 8; break;
case Code.Ldc_I4_M1:arg = -1; break;
case Code.Ldnull: arg = null; break;
case Code.Nop:
continue;
case Code.Ldloc:
case Code.Ldloc_S:
case Code.Ldloc_0:
case Code.Ldloc_1:
case Code.Ldloc_2:
case Code.Ldloc_3:
GetLocalVariableValue(instr.Instruction.GetLocal(theMethod.Body.Variables), out arg);
break;
case Code.Ldfld:
case Code.Ldsfld:
arg = instr.Operand;
break;
default:
int pushes, pops;
instr.Instruction.CalculateStackUsage(false, out pushes, out pops);
if (!useUnknownArgs || pushes != 1) {
Logger.w("Could not find all arguments to method {0} ({1:X8}), instr: {2}",
Utils.RemoveNewlines(method),
method.MDToken.ToInt32(),
instr);
errors++;
return false;
}
for (int i = 0; i < pops; i++) {
if (!GetArg(method, block, ref arg, ref instrIndex))
return false;
}
arg = null;
break;
}
break;
}
return true;
}
开发者ID:GodLesZ,项目名称:de4dot,代码行数:79,代码来源:MethodReturnValueInliner.cs
示例14: CreateCallResult
// Returns null if method is not a method we should inline
protected abstract CallResult CreateCallResult(IMethod method, MethodSpec gim, Block block, int callInstrIndex);
开发者ID:GodLesZ,项目名称:de4dot,代码行数:2,代码来源:MethodReturnValueInliner.cs
示例15: MyCallResult
public MyCallResult(Block block, int callEndIndex, MethodReference method)
: base(block, callEndIndex)
{
this.methodKey = new MethodReferenceAndDeclaringTypeKey(method);
}
开发者ID:ldh0227,项目名称:de4dot,代码行数:5,代码来源:StringDecrypter.cs
示例16: remove
bool remove(Blocks blocks, Block block)
{
var instrs = block.Instructions;
const int numInstrsToRemove = 11;
if (instrs.Count < numInstrsToRemove)
return false;
int startIndex = instrs.Count - numInstrsToRemove;
int index = startIndex;
if (instrs[index++].OpCode.Code != Code.Ldtoken)
return false;
if (!checkCall(instrs[index++], "System.Type System.Type::GetTypeFromHandle(System.RuntimeTypeHandle)"))
return false;
if (!checkCall(instrs[index++], "System.Reflection.Assembly System.Type::get_Assembly()"))
return false;
if (!checkCall(instrs[index++], "System.Reflection.AssemblyName System.Reflection.Assembly::GetName()"))
return false;
if (!checkCall(instrs[index++], "System.Byte[] System.Reflection.AssemblyName::GetPublicKeyToken()"))
return false;
if (!checkCall(instrs[index++], "System.String System.Convert::ToBase64String(System.Byte[])"))
return false;
if (instrs[index++].OpCode.Code != Code.Ldstr)
return false;
if (!checkCall(instrs[index++], "System.String", "(System.String,System.String)"))
return false;
if (instrs[index++].OpCode.Code != Code.Ldstr)
return false;
if (!checkCall(instrs[index++], "System.Boolean System.String::op_Inequality(System.String,System.String)"))
return false;
if (!instrs[index++].isBrfalse())
return false;
var badBlock = block.FallThrough;
var goodblock = block.Targets[0];
if (badBlock == null)
return false;
if (badBlock == goodblock) {
// All of the bad block was removed by the cflow deobfuscator. It was just a useless
// calculation (div by zero).
block.replaceLastInstrsWithBranch(numInstrsToRemove, goodblock);
}
else if (badBlock.Sources.Count == 1) {
instrs = badBlock.Instructions;
if (instrs.Count != 12)
return false;
index = 0;
if (!instrs[index++].isLdcI4())
return false;
if (!instrs[index].isStloc())
return false;
var local = Instr.getLocalVar(blocks.Locals, instrs[index++]);
if (local == null)
return false;
if (!checkLdloc(blocks.Locals, instrs[index++], local))
return false;
if (!checkLdloc(blocks.Locals, instrs[index++], local))
return false;
if (instrs[index++].OpCode.Code != Code.Sub)
return false;
if (instrs[index++].OpCode.Code != Code.Conv_U1)
return false;
if (!checkStloc(blocks.Locals, instrs[index++], local))
return false;
if (!checkLdloc(blocks.Locals, instrs[index++], local))
return false;
if (!checkLdloc(blocks.Locals, instrs[index++], local))
return false;
if (instrs[index++].OpCode.Code != Code.Div)
return false;
if (instrs[index++].OpCode.Code != Code.Conv_U1)
return false;
if (!checkStloc(blocks.Locals, instrs[index++], local))
return false;
block.replaceLastInstrsWithBranch(numInstrsToRemove, goodblock);
badBlock.Parent.removeDeadBlock(badBlock);
}
else
return false;
return true;
}
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:83,代码来源:AntiStrongName.cs
示例17: findBadBlock
BlockInfo findBadBlock(Block last)
{
/*
* ldstr "........."
* newobj System.Security.SecurityException(string)
* throw
*/
var instrs = last.Instructions;
if (instrs.Count != 3)
return null;
Instr instr;
int start = 0;
int end = 0;
instr = instrs[end++];
if (instr.OpCode != OpCodes.Ldstr)
return null;
instr = instrs[end++];
if (instr.OpCode != OpCodes.Newobj)
return null;
var method = instr.Operand as IMethod;
if (method == null || method.ToString() != "System.Void System.Security.SecurityException::.ctor(System.String)")
return null;
instr = instrs[end++];
if (instr.OpCode != OpCodes.Throw)
return null;
end--;
return new BlockInfo {
Block = last,
Start = start,
End = end,
};
}
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:38,代码来源:TamperProtectionRemover.cs
示例18: FindBlocks
void FindBlocks(List<Block> instrToBlock, List<Block> allBlocks) {
Block block = null;
for (var i = 0; i < instructions.Count; i++) {
List<int> branchSources;
if (branches.TryGetValue(i, out branchSources) || block == null) {
block = new Block();
allBlocks.Add(block);
}
block.Add(new Instr(this.instructions[i]));
instrToBlock.Add(block);
}
}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:13,代码来源:InstructionListParser.cs
示例19: findProxyCall
BlockInstr findProxyCall(DelegateInfo di, Block block, int index, Dictionary<Block, bool> visited, int stack)
{
if (visited.ContainsKey(block))
return null;
if (index <= 0)
visited[block] = true;
var instrs = block.Instructions;
for (int i = index + 1; i < instrs.Count; i++) {
if (stack <= 0)
return null;
var instr = instrs[i];
DotNetUtils.updateStack(instr.Instruction, ref stack, false);
if (stack < 0)
return null;
if (instr.OpCode != OpCodes.Call && instr.OpCode != OpCodes.Callvirt)
continue;
var method = DotNetUtils.getMethod(module, instr.Operand as MethodReference);
if (method == null)
continue;
if (stack != (DotNetUtils.hasReturnValue(method) ? 1 : 0))
continue;
if (method.DeclaringType != di.field.DeclaringType)
continue;
return new BlockInstr {
Block = block,
Index = i,
};
}
if (stack <= 0)
return null;
foreach (var target in block.getTargets()) {
var info = findProxyCall(di, target, -1, visited, stack);
if (info != null)
return info;
}
return null;
}
开发者ID:Perplexity,项目名称:de4dot,代码行数:42,代码来源:ProxyDelegateFinderBase.cs
示例20: CallResult
public CallResult(Block block, int callEndIndex) {
this.block = block;
this.callEndIndex = callEndIndex;
}
开发者ID:GodLesZ,项目名称:de4dot,代码行数:4,代码来源:MethodReturnValueInliner.cs
注:本文中的de4dot.blocks.Block类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论