Пример #1
0
 public void SlLookupType()
 {
     var slib = new SerializedLibrary
     {
         Types = new SerializedType[]
         {
             new SerializedTypedef { 
                 Name="int", 
                 DataType=new PrimitiveType_v1 { Domain = Decompiler.Core.Types.Domain.SignedInt, ByteSize = 4 }
             }
         }
     };
     var lib = TypeLibrary.Load(new IntelArchitecture(ProcessorMode.Protected32), slib);
     Assert.AreEqual(PrimitiveType.Int32, lib.LookupType("int"));
 }
Пример #2
0
		private void Verify(SerializedLibrary slib, string outputFile)
		{
			using (FileUnitTester fut = new FileUnitTester(outputFile))
			{
				XmlTextWriter writer = new FilteringXmlWriter(fut.TextWriter);
				writer.Formatting = Formatting.Indented;
                XmlSerializer ser = SerializedLibrary.CreateSerializer_v1(slib.GetType());
				ser.Serialize(writer, slib);

				fut.AssertFilesEqual();
			}
		}
Пример #3
0
		public void SlibWriteOneProcedure()
		{
			var slib = new SerializedLibrary();
			slib.Procedures.Add(MkMalloc());
			Verify(slib, "Core/SlibWriteOneProcedure.txt");
		}
Пример #4
0
 public static TypeLibrary Load(IProcessorArchitecture arch, SerializedLibrary slib)
 {
     var tlldr = new TypeLibraryLoader(arch, true);
     var tlib = tlldr.Load(slib);
     return tlib;
 }
Пример #5
0
        public void Tlldr_typedef_ptr_int()
        {
            Given_ArchitectureStub();
            Given_Arch_PointerDataType(PrimitiveType.Pointer32);
            mr.ReplayAll();

            var tlLdr = new TypeLibraryLoader(arch, true);
            var slib = new SerializedLibrary
            {
                Types = new SerializedType[]
                {
                    new SerializedTypedef { 
                        Name="pint", 
                        DataType= new PointerType_v1
                        {
                            DataType = new PrimitiveType_v1 { Domain = Domain.SignedInt, ByteSize=4 } 
                        }
                    }
                }
            };
            var lib = tlLdr.Load(slib);

            Assert.AreEqual("(ptr int32)", lib.LookupType("pint").ToString());
        }
Пример #6
0
        public void Tlldr_typedef_int()
        {
            Given_ArchitectureStub();
            mr.ReplayAll();

            var tlLdr = new TypeLibraryLoader(arch, true);
            var slib = new SerializedLibrary
            {
                Types = new SerializedType[]
                {
                    new SerializedTypedef { Name="int", DataType=new PrimitiveType_v1 { Domain = Domain.SignedInt, ByteSize=4 }}
                }
            };
            var lib = tlLdr.Load(slib);

            Assert.AreSame(PrimitiveType.Int32, lib.LookupType("int"));
        }
Пример #7
0
        public void Tlldr_bothordinalandname()
        {  
            Given_ArchitectureStub();
            mr.ReplayAll();
            var tlLDr = new TypeLibraryLoader(arch, true);
            var slib = new SerializedLibrary {
                Procedures = {
                    new Procedure_v1 {
                        Name="foo",
                        Ordinal=2,
                        Signature = new SerializedSignature {
                            ReturnValue = new Argument_v1 {
                                Type = new VoidType_v1()
                            }
                        }
                    }
                }
            };
            var lib = tlLDr.Load(slib);

            mr.VerifyAll();
            Assert.AreEqual(1, lib.ServicesByVector.Count);
            Assert.IsNotNull(lib.ServicesByVector[2]);
        }
Пример #8
0
        public void Tlldr_void_fn()
        {
            Given_ArchitectureStub();
            mr.ReplayAll();

            var tlLdr = new TypeLibraryLoader(arch, true);
            var slib = new SerializedLibrary
            {
                Procedures = {
                    new Procedure_v1 { 
                        Name="foo",
                        Signature = new SerializedSignature
                        {
                            Convention="__cdecl",
                            ReturnValue = new Argument_v1 {
                                Type = new VoidType_v1()
                            },
                        }
                    }
                }
            };
            var lib = tlLdr.Load(slib);

            mr.VerifyAll();
            Assert.AreEqual(
                "void foo()",
                lib.Lookup("foo").ToString("foo"));
        }