Esempio n. 1
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog ofd = new OpenFileDialog()) {
                ofd.Filter = "Application|*.exe";
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    fasm = FacelessAssembly.Create(ofd.FileName);
                    tvCallStack.Nodes.Clear();
                    lbLoadedAssemblies.Items.Clear();

                    currentNode = new TreeNode(fasm.CurrentMethodName)
                    {
                        ForeColor = Color.DarkMagenta
                    };
                    tvCallStack.Nodes.Add(currentNode);

                    fasm.OnInstruction          += Fasm_OnInstruction;
                    fasm.OnException            += Fasm_OnException;
                    fasm.OnExternalCall         += Fasm_OnExternalCall;
                    fasm.OnInternalCall         += Fasm_OnInternalCall;
                    fasm.OnExternalAssemblyLoad += Fasm_OnExternalAssemblyLoad;

                    Run();
                }
            }
        }
Esempio n. 2
0
        private bool Fasm_OnExternalCall(FacelessAssembly sender, IMethodDefOrRef method, object[] args)
        {
            var node = new TreeNode(method.FullName);

            node.ForeColor = Color.DarkMagenta;
            currentNode.Nodes.Add(node);

            if (cbExternalCallBreakpoint.Checked && args.Length > 0)
            {
                using (var frm = new frmEditCall(method.FullName, args)) {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        for (int i = 0; i < args.Length; i++)
                        {
                            args[i] = frm.Args[i];
                        }
                    }
                }
                Stop();
            }

            var argsNode = new TreeNode("args");

            foreach (var a in args)
            {
                argsNode.Nodes.Add(a.ToString());
            }
            node.Nodes.Add(argsNode);
            node.ForeColor = Color.Black;


            return(true);
        }
Esempio n. 3
0
 private void Fasm_OnException(FacelessAssembly sender, Exception ex)
 {
     Console.ForegroundColor = ConsoleColor.Red;
     Console.WriteLine("[{0}]: {1}", ex.GetType().Name, ex.Message);
     Console.WriteLine(ex.ToString());
     Console.ResetColor();
     Stop();
 }
Esempio n. 4
0
        private bool Fasm_OnInternalCall(FacelessAssembly sender, IMethodDefOrRef method, FacelessValue[] args)
        {
            var newNode = new TreeNode(method.FullName);

            var argsNode = new TreeNode("args");

            foreach (var a in args)
            {
                argsNode.Nodes.Add(a.ToString());
            }
            newNode.Nodes.Add(argsNode);

            currentNode.Nodes.Add(newNode);
            currentNode.ForeColor = Color.Black;

            currentNode           = newNode;
            currentNode.ForeColor = Color.DarkMagenta;
            return(true);
        }
Esempio n. 5
0
        private bool Fasm_OnInstruction(FacelessAssembly sender, dnlib.DotNet.Emit.Instruction instruction)
        {
            if (cbPrintInstructions.Checked)
            {
                Console.WriteLine(">\t{0}\t({1}) {2}", instruction.OpCode, instruction.Operand?.GetType().Name ?? "null", instruction.Operand);
            }


            if (instruction.OpCode.Code == dnlib.DotNet.Emit.Code.Ret)
            {
                if (currentNode?.Tag is bool)
                {
                    currentNode.ForeColor            = Color.Green;
                    cbExternalCallBreakpoint.Checked = (bool)currentNode.Tag;
                }
                else
                {
                    currentNode.ForeColor = Color.Black;
                }
                currentNode = currentNode.Parent;
            }

            return(true);
        }
Esempio n. 6
0
 private bool Fasm_OnExternalAssemblyLoad(FacelessAssembly sender, IAssembly assemblyToLoad)
 {
     lbLoadedAssemblies.Items.Add(assemblyToLoad.FullName);
     return(true);
 }