示例#1
0
        private void DoAnalyze()
        {
            dasm.Analyze(mzFile.EntryPoint);
            X86Codec.Decoder decoder = new X86Codec.Decoder();

            // Display status.
            txtStatus.Text = string.Format(
                "{3} segments, {0} procedures, {4} xrefs, {1} instructions, {2} errors",
                dasm.Image.Procedures.Count,
                "?", // lvListing.Items.Count,
                dasm.Image.Errors.Count,
                0 /* segStat.Count */,
                dasm.Image.CrossReferences.Count);
        }
示例#2
0
        private void TestDecode(
            byte[] image,
            Pointer startAddress,
            Pointer baseAddress)
        {
            DecoderContext options = new DecoderContext();
            options.AddressSize = CpuSize.Use16Bit;
            options.OperandSize = CpuSize.Use16Bit;

            X86Codec.Decoder decoder = new X86Codec.Decoder();

            Pointer ip = startAddress;
            for (int index = startAddress - baseAddress; index < image.Length; )
            {
                Instruction instruction = null;
                try
                {
                    instruction = decoder.Decode(image, index, ip, options);
                }
                catch (InvalidInstructionException ex)
                {
                    if (MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OKCancel)
                        == DialogResult.Cancel)
                    {
                        throw;
                    }
                    break;
                }
            #if false
                // Output address.
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("0000:{0:X4}  ", index - startAddress);

                // Output binary code. */
                for (int i = 0; i < 8; i++)
                {
                    if (i < instruction.EncodedLength)
                        sb.AppendFormat("{0:x2} ", image[index + i]);
                    else
                        sb.Append("   ");
                }

                // Output the instruction.
                string s = instruction.ToString();
                if (s.StartsWith("*"))
                    throw new InvalidOperationException("Cannot format instruction.");
                sb.Append(s);

                System.Diagnostics.Debug.WriteLine(sb.ToString());
            #else
                DisplayInstruction(instruction);
            #endif
                index += instruction.EncodedLength;
                ip += instruction.EncodedLength;
            }
        }
示例#3
0
        private void TestDecode(
            byte[] image,
            Pointer startAddress,
            Pointer baseAddress)
        {
            DecoderContext options = new DecoderContext();

            options.AddressSize = CpuSize.Use16Bit;
            options.OperandSize = CpuSize.Use16Bit;

            X86Codec.Decoder decoder = new X86Codec.Decoder();

            Pointer ip = startAddress;

            for (int index = startAddress - baseAddress; index < image.Length;)
            {
                Instruction instruction = null;
                try
                {
                    instruction = decoder.Decode(image, index, ip, options);
                }
                catch (InvalidInstructionException ex)
                {
                    if (MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OKCancel)
                        == DialogResult.Cancel)
                    {
                        throw;
                    }
                    break;
                }
#if false
                // Output address.
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("0000:{0:X4}  ", index - startAddress);

                // Output binary code. */
                for (int i = 0; i < 8; i++)
                {
                    if (i < instruction.EncodedLength)
                    {
                        sb.AppendFormat("{0:x2} ", image[index + i]);
                    }
                    else
                    {
                        sb.Append("   ");
                    }
                }

                // Output the instruction.
                string s = instruction.ToString();
                if (s.StartsWith("*"))
                {
                    throw new InvalidOperationException("Cannot format instruction.");
                }
                sb.Append(s);

                System.Diagnostics.Debug.WriteLine(sb.ToString());
#else
                DisplayInstruction(instruction);
#endif
                index += instruction.EncodedLength;
                ip    += instruction.EncodedLength;
            }
        }
示例#4
0
        private void DoAnalyze()
        {
            dasm.Analyze(mzFile.EntryPoint);
            X86Codec.Decoder decoder = new X86Codec.Decoder();

            // Display status.
            txtStatus.Text = string.Format(
                "{3} segments, {0} procedures, {4} xrefs, {1} instructions, {2} errors",
                dasm.Image.Procedures.Count,
                "?", // lvListing.Items.Count,
                dasm.Image.Errors.Count,
                0 /* segStat.Count */,
                dasm.Image.CrossReferences.Count);
        }