Beispiel #1
0
 protected override void OnPhiVariableUsed(int instructionOffset, ClassHierarchyNode variableNode)
 {
     V_0 = this.offsetToInstruction.get_Item(instructionOffset);
     if (V_0.get_OpCode().get_Code() == 36 || V_0.get_OpCode().get_Code() == 37)
     {
         return;
     }
     V_1 = this.GetUseExpressionTypeNode(V_0, variableNode.get_Variable());
     if (V_0.get_OpCode().get_Code() == 68)
     {
         variableNode.AddSupertype(V_1);
         dummyVar0 = this.resultingGraph.Add(V_1);
         return;
     }
     if (!String.op_Equality(V_1.get_NodeType().get_FullName(), "System.Int32") || !this.OnlyPhiVariablesUsed(this.offsetToExpression.get_Item(V_0.get_Offset())))
     {
         variableNode.AddSupertype(V_1);
         dummyVar2 = this.resultingGraph.Add(V_1);
         return;
     }
     V_3 = this.GetUsedPhiVariableNodes(V_0.get_Offset());
     V_4 = 0;
     while (V_4 < V_3.get_Count())
     {
         V_5 = V_4 + 1;
         while (V_5 < V_3.get_Count())
         {
             V_3.get_Item(V_4).AddSupertype(V_3.get_Item(V_5));
             V_3.get_Item(V_5).AddSupertype(V_3.get_Item(V_4));
             V_5 = V_5 + 1;
         }
         V_4 = V_4 + 1;
     }
     if (this.IsArithmeticOperation(V_0.get_OpCode().get_Code()))
     {
         V_6 = 0;
         while (V_6 < V_3.get_Count())
         {
             dummyVar1 = this.notPossibleBooleanNodes.Add(V_3.get_Item(V_6));
             V_7       = this.GetTypeNode(this.typeSystem.get_Int32());
             if (!V_7.get_CanAssignTo().Contains(V_3.get_Item(V_6)))
             {
                 V_7.get_CanAssignTo().Add(V_3.get_Item(V_6));
                 V_3.get_Item(V_6).get_SubTypes().Add(V_7);
             }
             V_6 = V_6 + 1;
         }
     }
     return;
 }
        private void FixBlockExpressions(Dictionary <Expression, Expression> oldToNewValueMap)
        {
            V_1 = this.methodContext.get_Expressions().get_BlockExpressions().GetEnumerator();
            try
            {
                while (V_1.MoveNext())
                {
                    V_2 = V_1.get_Current();
                    V_3 = V_2.get_Value();
                    V_4 = 0;
                    while (V_4 < V_3.get_Count())
                    {
                        V_5 = V_3.get_Item(V_4);
                        if (V_5.get_CodeNodeType() == 24)
                        {
                            V_6 = V_5 as BinaryExpression;
                            if (V_6.get_IsAssignmentExpression() && V_6.get_Left().get_CodeNodeType() == 26 && this.inlinedOnSecondPass.Contains((V_6.get_Left() as VariableReferenceExpression).get_Variable().Resolve()))
                            {
                                goto Label1;
                            }
                            if (oldToNewValueMap.TryGetValue(V_6.get_Right(), out V_0))
                            {
                                V_6.set_Right(V_0);
                            }
                        }
                        if (oldToNewValueMap.TryGetValue(V_3.get_Item(V_4), out V_0))
                        {
                            V_3.set_Item(V_4, V_0);
                        }
Label0:
                        V_4 = V_4 + 1;
                    }
                }
            }
            finally
            {
                ((IDisposable)V_1).Dispose();
            }
            return;

Label1:
            stackVariable57 = V_4;
            V_4             = stackVariable57 - 1;
            V_3.RemoveAt(stackVariable57);
            goto Label0;
        }
Beispiel #3
0
		public BlockStatement Process(DecompilationContext context, BlockStatement body)
		{
			V_0 = context.get_MethodContext();
			V_1 = V_0.get_Expressions().get_BlockExpressions().get_Keys().GetEnumerator();
			try
			{
				while (V_1.MoveNext())
				{
					V_2 = V_1.get_Current();
					V_3 = V_0.get_Expressions().get_BlockExpressions().get_Item(V_2);
					V_6 = V_0.get_ControlFlowGraph().get_InstructionToBlockMapping().get_Item(V_2).get_Last().get_OpCode();
					V_4 = V_6.get_Code();
					if (V_4 == 57 || V_4 == 44 || V_4 == 56)
					{
						stackVariable27 = true;
					}
					else
					{
						stackVariable27 = V_4 == 43;
					}
					V_5 = stackVariable27;
					V_7 = 0;
					while (V_7 < V_3.get_Count())
					{
						V_3.set_Item(V_7, (Expression)this.Visit(V_3.get_Item(V_7)));
						V_7 = V_7 + 1;
					}
					if (!V_5)
					{
						continue;
					}
					V_3.set_Item(V_3.get_Count() - 1, (Expression)this.FixBranchingExpression(V_3.get_Item(V_3.get_Count() - 1), V_0.get_ControlFlowGraph().get_InstructionToBlockMapping().get_Item(V_2).get_Last()));
				}
			}
			finally
			{
				((IDisposable)V_1).Dispose();
			}
			return body;
		}
Beispiel #4
0
 private bool TryBuildIfConstruct(ConditionLogicalConstruct condition, DominatorTree dominatorTree, DFSTree dfsTree)
 {
     V_0             = condition.get_FalseSuccessor();
     V_1             = condition.get_TrueSuccessor();
     V_2             = dominatorTree.GetDominanceFrontier(V_0);
     V_3             = dominatorTree.GetDominanceFrontier(V_1);
     stackVariable15 = this.CheckSuccessor(condition, V_1, V_2, dfsTree);
     if (stackVariable15 == null)
     {
         dummyVar0       = stackVariable15;
         stackVariable15 = this.CheckSuccessor(condition, V_0, V_3, dfsTree);
     }
     V_4 = new HashSet <ISingleEntrySubGraph>(V_3);
     V_4.IntersectWith(V_2);
     if (stackVariable15 == null && V_2.get_Count() > 0 && V_3.get_Count() > 0 && V_4.get_Count() == 0)
     {
         return(false);
     }
     V_5 = this.GetBlockBody(dominatorTree, V_1, condition);
     V_6 = this.GetBlockBody(dominatorTree, V_0, condition);
     if (V_5 == null && V_6 == null)
     {
         return(false);
     }
     if (V_5 == null)
     {
         condition.Negate(this.typeSystem);
         stackVariable86 = V_1;
         V_1             = V_0;
         V_0             = stackVariable86;
         V_5             = V_6;
         V_6             = null;
     }
     if (V_6 == null && !this.CheckSuccessors(V_5, V_0))
     {
         return(false);
     }
     if (this.ShouldInvertIfAndRemoveElse(V_5, V_1, V_6, V_0))
     {
         condition.Negate(this.typeSystem);
         stackVariable73 = V_1;
         V_1             = V_0;
         V_0             = stackVariable73;
         stackVariable75 = V_5;
         V_5             = V_6;
         V_6             = stackVariable75;
         V_6             = null;
     }
     if (V_6 != null && !this.HasSuccessors(V_5))
     {
         stackVariable61    = V_1.get_FirstBlock().get_TheBlock();
         stackVariable63    = new Code[2];
         stackVariable63[0] = 41;
         stackVariable63[1] = 119;
         if (this.SubtreeEndsInInstructionCode(stackVariable61, stackVariable63))
         {
             V_6 = null;
         }
     }
     V_7 = new BlockLogicalConstruct(V_1, V_5);
     if (V_6 != null)
     {
         stackVariable46 = new BlockLogicalConstruct(V_0, V_6);
     }
     else
     {
         stackVariable46 = null;
     }
     this.UpdateDominatorTree(dominatorTree, IfLogicalConstruct.GroupInIfConstruct(condition, V_7, stackVariable46));
     return(true);
 }
Beispiel #5
0
 private bool WriteSecurityAttribute(ModuleDefinition module, bool isAssemblyDeclaration, SecurityAttribute attribute, SecurityDeclaration securityDeclaration, out bool wroteArgument, bool skipTheNewLine = false, bool isReturnValueAttribute = false)
 {
     this.genericWriter.WriteToken(this.get_OpeningBracket());
     if (!isAssemblyDeclaration)
     {
         if (isReturnValueAttribute)
         {
             this.WriteReturnValueAttributeKeyword();
         }
     }
     else
     {
         this.genericWriter.WriteKeyword(this.genericWriter.get_KeyWordWriter().get_Assembly());
         this.genericWriter.Write(":");
         this.genericWriter.WriteSpace();
     }
     if (attribute.get_AttributeType().get_Name().EndsWith("Attribute"))
     {
         stackVariable19 = attribute.get_AttributeType().get_Name().Remove(attribute.get_AttributeType().get_Name().LastIndexOf("Attribute"));
     }
     else
     {
         stackVariable19 = attribute.get_AttributeType().get_Name();
     }
     V_0 = stackVariable19;
     this.genericWriter.WriteNamespaceIfTypeInCollision(attribute.get_AttributeType());
     this.genericWriter.WriteReference(V_0, attribute.get_AttributeType());
     this.genericWriter.WriteToken("(");
     V_1 = securityDeclaration.GetSecurityActionTypeReference(module);
     if (V_1.get_IsDefinition())
     {
         stackVariable38 = V_1 as TypeDefinition;
     }
     else
     {
         stackVariable38 = V_1.Resolve();
     }
     V_2 = stackVariable38;
     if (V_2 != null && V_2.get_IsEnum())
     {
         V_3 = EnumValueToFieldCombinationMatcher.GetEnumFieldDefinitionByValue(V_2.get_Fields(), (Int32)securityDeclaration.get_Action(), V_2.get_CustomAttributes());
         if (V_3.get_Count() == 0)
         {
             this.WriteSecurityAttributeAction(securityDeclaration.get_Action());
         }
         else
         {
             V_4 = 0;
             while (V_4 < V_3.get_Count())
             {
                 this.genericWriter.WriteReferenceAndNamespaceIfInCollision(V_3.get_Item(V_4).get_DeclaringType());
                 this.genericWriter.WriteToken(".");
                 this.genericWriter.WriteEnumValueField(V_3.get_Item(V_4));
                 if (V_4 + 1 < V_3.get_Count())
                 {
                     this.genericWriter.WriteSpace();
                     this.genericWriter.WriteBitwiseOr();
                     this.genericWriter.WriteSpace();
                 }
                 V_4 = V_4 + 1;
             }
         }
     }
     wroteArgument = true;
     if (attribute.get_HasFields() || attribute.get_HasProperties())
     {
         V_5 = attribute.get_AttributeType().Resolve();
         if (attribute.get_HasProperties())
         {
             wroteArgument = this.WriteAttributeNamedArgs(V_5, attribute.get_Properties(), false, wroteArgument);
         }
         if (attribute.get_HasFields())
         {
             dummyVar0 = this.WriteAttributeNamedArgs(V_5, attribute.get_Fields(), true, wroteArgument);
         }
     }
     this.genericWriter.WriteToken(")");
     this.genericWriter.WriteToken(this.get_ClosingBracket());
     if (!skipTheNewLine)
     {
         this.genericWriter.WriteLine();
     }
     return(wroteArgument);
 }