예제 #1
0
        public bool Disassemble(Distorm.DecodeType decodeType)
        {
            if (this.Data.Length == 0)
            {
                return(false);
            }

            if (this.InstructionsDisassembled.Count != 0)
            {
                this.InstructionsDisassembled = Distorm.Disassemble(this.Data, (ulong)Address.ToInt64(), decodeType);
                if (this.InstructionsDisassembled.Count == 0)
                {
                    return(false);
                }
            }

            if (this.InstructionsDecomposed.Length != 0)
            {
                this.InstructionsDecomposed = Distorm.Decompose(this.Data, (ulong)Address.ToInt64(), decodeType);
                if (this.InstructionsDecomposed.Length == 0)
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
        /// <summary>
        /// Tests the DistormSimple.Disassemble function.
        /// </summary>
        /// <returns>Returns true if the test passed.</returns>
        public static bool DisassembleTest()
        {
            string expectedOutput = "push ebp\n" +
                                    "mov ebp, esp\n" +
                                    "mov eax, [ebp+0x8]\n" +
                                    "add eax, [ebp+0xc]\n" +
                                    "leave\n" +
                                    "ret\n";

            List <string> instructions = Distorm.Disassemble(Program.code);

            return(expectedOutput.Equals(string.Join("\n", instructions) + "\n"));
        }