Пример #1
0
 public ArgumentSerializer(ProcedureSerializer procSer, IProcessorArchitecture arch, Frame frame, int retAddressOnStack)
 {
     this.procSer           = procSer;
     this.arch              = arch;
     this.frame             = frame;
     this.retAddressOnStack = retAddressOnStack;
 }
Пример #2
0
        public SystemService Build(IPlatform platform, TypeLibrary library)
        {
            SystemService svc = new SystemService();

            svc.Name = Name;
            if (this.SyscallInfo != null)
            {
                var syscallinfo = this.SyscallInfo.Build(platform);
                svc.SyscallInfo = syscallinfo;
            }
            else
            {
                svc.SyscallInfo = new SyscallInfo
                {
                    Vector = this.Ordinal
                };
            }
            if (svc.SyscallInfo.RegisterValues == null)
            {
                svc.SyscallInfo.RegisterValues = new RegValue[0];
            }
            var loader = new TypeLibraryDeserializer(platform, true, library);
            var sser   = new ProcedureSerializer(platform, loader, "stdapi");

            svc.Signature       = sser.Deserialize(Signature, platform.Architecture.CreateFrame());
            svc.Characteristics = Characteristics != null ? Characteristics : DefaultProcedureCharacteristics.Instance;
            return(svc);
        }
Пример #3
0
        public SystemService Build(IProcessorArchitecture arch)
        {
            SystemService svc = new SystemService();

            svc.Name               = Name;
            svc.SyscallInfo        = new SyscallInfo();
            svc.SyscallInfo.Vector = Convert.ToInt32(SyscallInfo.Vector, 16);
            if (SyscallInfo.RegisterValues != null)
            {
                svc.SyscallInfo.RegisterValues = new RegValue[SyscallInfo.RegisterValues.Length];
                for (int i = 0; i < SyscallInfo.RegisterValues.Length; ++i)
                {
                    svc.SyscallInfo.RegisterValues[i] = new RegValue
                    {
                        Register = arch.GetRegister(SyscallInfo.RegisterValues[i].Register),
                        Value    = Convert.ToInt32(SyscallInfo.RegisterValues[i].Value, 16),
                    };
                }
            }
            else
            {
                svc.SyscallInfo.RegisterValues = new RegValue[0];
            }
            TypeLibraryLoader   loader = new TypeLibraryLoader(arch, true);
            ProcedureSerializer sser   = arch.CreateProcedureSerializer(loader, "stdapi");

            svc.Signature       = sser.Deserialize(Signature, arch.CreateFrame());
            svc.Characteristics = Characteristics != null ? Characteristics : DefaultProcedureCharacteristics.Instance;
            return(svc);
        }
Пример #4
0
 public ArgumentSerializer(ProcedureSerializer procSer, IProcessorArchitecture arch, Frame frame, string callingConvention)
 {
     this.procSer = procSer;
     this.arch = arch;
     this.frame = frame;
     this.convention = callingConvention;
 }
Пример #5
0
 public ArgumentSerializer(ProcedureSerializer procSer, IProcessorArchitecture arch, Frame frame, string callingConvention)
 {
     this.procSer    = procSer;
     this.arch       = arch;
     this.frame      = frame;
     this.convention = callingConvention;
 }
Пример #6
0
 internal UserCallData GetUserCallData(ProcedureSerializer procSer)
 {
     return new UserCallData
     {
         Address = dlg.Address,
         NoReturn = dlg.NoReturn.Checked,
     };
 }
Пример #7
0
 private void Given_ArchitectureStub()
 {
     arch = mr.DynamicMock<IProcessorArchitecture>();
     platform = mr.DynamicMock<IPlatform>();
     platform.Stub(p => p.PointerType).Return(PrimitiveType.Pointer32);
     this.procSer = mr.StrictMock<ProcedureSerializer>(null, null, null);
     platform.Stub(p => p.CreateProcedureSerializer(null, null)).IgnoreArguments().Return(procSer);
     platform.Stub(p => p.Architecture).Return(arch);
 }
Пример #8
0
		public void Setup()
		{
            var sc = new ServiceContainer();
            sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
			arch = new IntelArchitecture(ProcessorMode.Real);
            platform = new MsdosPlatform(sc, arch);
			sigser = new X86ProcedureSerializer(
                arch, 
                new TypeLibraryDeserializer(platform, true, new TypeLibrary()),
                "stdapi");
            argser = new ArgumentSerializer(sigser, arch, arch.CreateFrame(), null);
		}
Пример #9
0
 public ArgumentDeserializer(
     ProcedureSerializer procSer,
     IProcessorArchitecture arch,
     Frame frame,
     int retAddressOnStack,
     int stackAlign)
 {
     this.procSer           = procSer;
     this.arch              = arch;
     this.frame             = frame;
     this.retAddressOnStack = retAddressOnStack;
     this.stackAlignment    = stackAlign;
 }
Пример #10
0
 public ArgumentDeserializer(
     ProcedureSerializer procSer, 
     IProcessorArchitecture arch, 
     Frame frame, 
     int retAddressOnStack,
     int stackAlign)
 {
     this.procSer = procSer;
     this.arch = arch;
     this.frame = frame;
     this.retAddressOnStack = retAddressOnStack;
     this.stackAlignment = stackAlign;
 }
Пример #11
0
        public SystemService Build(IPlatform platform, TypeLibrary library)
        {
            SystemService svc = new SystemService();

            svc.Name               = Name;
            svc.SyscallInfo        = new SyscallInfo();
            svc.SyscallInfo.Vector = SyscallInfo != null
                ? Convert.ToInt32(SyscallInfo.Vector, 16)
                : this.Ordinal;

            if (SyscallInfo != null)
            {
                if (SyscallInfo.RegisterValues != null)
                {
                    svc.SyscallInfo.RegisterValues = new RegValue[SyscallInfo.RegisterValues.Length];
                    for (int i = 0; i < SyscallInfo.RegisterValues.Length; ++i)
                    {
                        svc.SyscallInfo.RegisterValues[i] = new RegValue
                        {
                            Register = platform.Architecture.GetRegister(SyscallInfo.RegisterValues[i].Register),
                            Value    = Convert.ToInt32(SyscallInfo.RegisterValues[i].Value, 16),
                        };
                    }
                }
                if (SyscallInfo.StackValues != null)
                {
                    svc.SyscallInfo.StackValues = SyscallInfo.StackValues.Select(sv =>
                                                                                 new StackValue
                    {
                        Offset = Convert.ToInt32(sv.Offset, 16),
                        Value  = Convert.ToInt32(sv.Value, 16)
                    }).ToArray();
                }
            }
            if (svc.SyscallInfo.RegisterValues == null)
            {
                svc.SyscallInfo.RegisterValues = new RegValue[0];
            }
            var loader = new TypeLibraryDeserializer(platform, true, library);
            var sser   = new ProcedureSerializer(platform, loader, "stdapi");

            svc.Signature       = sser.Deserialize(Signature, platform.Architecture.CreateFrame());
            svc.Characteristics = Characteristics != null ? Characteristics : DefaultProcedureCharacteristics.Instance;
            return(svc);
        }
Пример #12
0
 public void Setup()
 {
     mr = new MockRepository();
     var sc = new ServiceContainer();
     sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
     arch = new X86ArchitectureReal();
     platform = new MsdosPlatform(sc, arch);
     sigser = mr.Stub<ProcedureSerializer>(
         arch,
         new TypeLibraryDeserializer(platform, true, new TypeLibrary()),
         "stdapi");
     argser = new ArgumentDeserializer(
         sigser,
         arch,
         arch.CreateFrame(),
         // It's possible that old, hand-written assembler passes
         // arguments on unaligned offsets
         13,
         4);
     mr.ReplayAll();
 }
Пример #13
0
 public UserCallData GetUserCallData(ProcedureSerializer procSer)
 {
     return interactor.GetUserCallData(procSer);
 }
Пример #14
0
		public void Setup()
		{
			arch = new IntelArchitecture(ProcessorMode.Real);
			sigser = new X86ProcedureSerializer(arch, new TypeLibraryLoader(arch, true), "stdapi");
            argser = new ArgumentSerializer(sigser, arch, arch.CreateFrame(), null);
		}