示例#1
0
        public void Gdwi_GlobalDataRecursiveStructs()
        {
            var bytes = new byte[] {
                0x17, 0x00, 0x21, 0x43, 0x00, 0x00, 0x21, 0x43,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            };

            Given_Program(Address.Ptr32(0x43210000), bytes);

            var ft = new FunctionType(
                null,
                PrimitiveType.Real32,
                new DataType[0],
                new string[0]);
            var str    = new StructureType("str", 0);
            var fields = new StructureField[] {
                new StructureField(0, new Pointer(ft, 4), "func"),
                new StructureField(4, new Pointer(str, 4), "next"),
            };

            str.Fields.AddRange(fields);
            Expect_ScannerGlobalData(0x43210017, ft);
            Expect_ScannerGlobalData(0x43210000, str);

            mr.ReplayAll();

            var gdwi = new GlobalDataWorkItem(scanner, program, program.ImageMap.BaseAddress, str);

            gdwi.Process();

            mr.VerifyAll();
        }
示例#2
0
        public void Gdwi_StructWithPadding()
        {
            var bytes = new byte[]
            {
                0x03, 0x00,             // Type field (halfword)
                0x00, 0x00,             // ...alignment padding

                0x08, 0x0, 0x21, 0x43,  // pointer to function

                0xC3,                   // function code.
            };

            Given_Program(Address.Ptr32(0x43210000), bytes);

            var ft = new FunctionType(
                new Identifier("", PrimitiveType.Real32, null),
                new Identifier[0]);
            var str = new StructureType();

            str.Fields.AddRange(new StructureField[]
            {
                new StructureField(0, PrimitiveType.Word16, "typeField"),
                // two-byte gap here.
                new StructureField(4, new Pointer(ft, 32), "pfn")
            });
            Expect_ScannerGlobalData(0x43210008, ft);
            mr.ReplayAll();

            var gdwi = new GlobalDataWorkItem(scanner, program, program.ImageMap.BaseAddress, str, null);

            gdwi.Process();

            mr.VerifyAll();
        }
示例#3
0
        public void Gdwi_GlobalDataRecursiveStructs()
        {
            var bytes = new byte[] {
                0x17, 0x00, 0x21, 0x43, 0x00, 0x00, 0x21, 0x43,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            };

            Given_Program(Address.Ptr32(0x43210000), bytes);

            var ft = FunctionType.Func(
                new Identifier("", PrimitiveType.Real32, null),
                new Identifier[0]);
            var str    = new StructureType("str", 0);
            var fields = new StructureField[] {
                new StructureField(0, new Pointer(ft, 32), "func"),
                new StructureField(4, new Pointer(str, 32), "next"),
            };

            str.Fields.AddRange(fields);
            Expect_ScannerGlobalData(0x43210017, ft);
            Expect_ScannerGlobalData(0x43210000, str);

            var gdwi = new GlobalDataWorkItem(scanner.Object, program, program.ImageMap.BaseAddress, str, null);

            gdwi.Process();

            scanner.Verify();
        }
示例#4
0
        public void Gdwi_GlobalData()
        {
            var bytes = new byte[] {
                0x48, 0x00, 0x21, 0x43, 0x00, 0x00, 0x00, 0x01, 0x53, 0x00, 0x21, 0x43,
                0x28, 0x00, 0x21, 0x43, 0x00, 0x00, 0x00, 0x02, 0x63, 0x00, 0x21, 0x43,
                0x38, 0x00, 0x21, 0x43, 0x00, 0x00, 0x00, 0x03, 0x73, 0x00, 0x21, 0x43,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            };

            Given_Program(Address.Ptr32(0x43210000), bytes);
            var project = new Project {
                Programs = { program }
            };

            var sSig2 = new SerializedSignature()
            {
                ReturnValue = new Argument_v1(null, new PrimitiveType_v1(Domain.Character, 1), null, false),
            };
            var ft1 = new FunctionType(
                null,
                PrimitiveType.Int32,
                new DataType[0],
                new string[0]);
            var ft2 = new FunctionType(
                null,
                PrimitiveType.Char,
                new DataType[0],
                new string[0]);
            var str    = new StructureType();
            var fields = new StructureField[] {
                new StructureField(0, new Pointer(ft1, 4), "A"),
                new StructureField(4, PrimitiveType.Int32, "B"),
                new StructureField(8, new Pointer(ft2, 4), "C"),
            };

            str.Fields.AddRange(fields);
            var elementType = new TypeReference("test", str);
            var arrayType   = new ArrayType(elementType, 3);

            Expect_ScannerGlobalData(0x43210048, ft1);
            Expect_ScannerGlobalData(0x43210053, ft2);
            Expect_ScannerGlobalData(0x43210028, ft1);
            Expect_ScannerGlobalData(0x43210063, ft2);
            Expect_ScannerGlobalData(0x43210038, ft1);
            Expect_ScannerGlobalData(0x43210073, ft2);
            mr.ReplayAll();

            var gdwi = new GlobalDataWorkItem(scanner, program, program.ImageMap.BaseAddress, arrayType);

            gdwi.Process();

            mr.VerifyAll();
        }
示例#5
0
        public void Gdwi_FunctionType()
        {
            Given_Program(Address.Ptr32(0x12340000), new byte[4]);
            var ft = new FunctionType(
                null,
                new Identifier("", PrimitiveType.Real32, null),
                new Identifier[0]);

            scanner.Expect(s => s.EnqueueUserProcedure(
                               Arg <Procedure_v1> .Matches(up => up.Address == "12340000")));
            mr.ReplayAll();

            var gdwi = new GlobalDataWorkItem(scanner, program, program.ImageMap.BaseAddress, ft);

            gdwi.Process();

            mr.VerifyAll();
        }
        public void Gdwi_FunctionType()
        {
            var addr = Address.Ptr32(0x12340000);

            Given_Program(addr, new byte[4]);
            var ft = new FunctionType(
                new Identifier("", PrimitiveType.Real32, null),
                new Identifier[0]);

            scanner.Expect(s => s.EnqueueUserProcedure(
                               Arg <Address> .Is.Equal(addr),
                               Arg <FunctionType> .Is.NotNull));
            mr.ReplayAll();

            var gdwi = new GlobalDataWorkItem(scanner, program, program.ImageMap.BaseAddress, ft);

            gdwi.Process();

            mr.VerifyAll();
        }
示例#7
0
        public void Gdwi_FunctionType()
        {
            var addr = Address.Ptr32(0x12340000);

            Given_Program(addr, new byte[4]);
            var ft = FunctionType.Func(
                new Identifier("", PrimitiveType.Real32, null),
                new Identifier[0]);

            scanner.Setup(s => s.EnqueueUserProcedure(
                              It.IsNotNull <IProcessorArchitecture>(),
                              addr,
                              It.IsNotNull <FunctionType>(),
                              It.IsAny <string>()))
            .Verifiable();

            var gdwi = new GlobalDataWorkItem(scanner.Object, program, program.ImageMap.BaseAddress, ft, null);

            gdwi.Process();

            scanner.Verify();
        }