Ejemplo n.º 1
0
        public override Program Load(Address addrLoad)
        {
            // First load the file as a PE Executable. This gives us a (writeable) image and
            // the packed entry point.
            var pe      = CreatePeImageLoader();
            var program = pe.Load(pe.PreferredBaseAddress);
            var rr      = pe.Relocate(program, pe.PreferredBaseAddress);

            this.ImageMap     = program.SegmentMap;
            this.Architecture = (IntelArchitecture)program.Architecture;

            IPlatformEmulator win32 = program.Platform.CreateEmulator(program.SegmentMap, program.ImportReferences);
            var wxin32 = new Win32Emulator(program.SegmentMap, program.Platform, program.ImportReferences);
            var emu    = new X86Emulator((IntelArchitecture)program.Architecture, program.SegmentMap, win32);

            this.debugger                   = new Debugger(emu);
            this.scriptInterpreter          = new OllyLang(Services);
            this.scriptInterpreter.Host     = new Host(this, program.SegmentMap);
            this.scriptInterpreter.Debugger = this.debugger;
            emu.InstructionPointer          = rr.EntryPoints[0].Address;
            emu.BeforeStart                += emu_BeforeStart;
            emu.ExceptionRaised            += emu_ExceptionRaised;

            var stackSeg = InitializeStack(emu);

            LoadScript(Argument, scriptInterpreter.script);
            emu.Start();
            TearDownStack(stackSeg);

            foreach (var ic in win32.InterceptedCalls)
            {
                program.InterceptedCalls.Add(ic.Key, ic.Value);
            }
            return(program);
        }
Ejemplo n.º 2
0
 public X86Emulator(IntelArchitecture arch, LoadedImage loadedImage, IPlatformEmulator envEmulator)
 {
     this.arch = arch;
     this.img = loadedImage;
     this.Registers = new ulong[40];
     this.Valid = new bool[40];
     this.envEmulator = envEmulator;
 }
Ejemplo n.º 3
0
 public X86Emulator(IntelArchitecture arch, ImageMap imageMap, IPlatformEmulator envEmulator)
 {
     this.arch        = arch;
     this.map         = imageMap;
     this.Registers   = new ulong[40];
     this.Valid       = new bool[40];
     this.envEmulator = envEmulator;
 }
Ejemplo n.º 4
0
 public Mos6502Emulator(Mos6502Architecture arch, SegmentMap segmentMap, IPlatformEmulator envEmulator)
     : base(segmentMap)
 {
     this.arch        = arch;
     this.map         = segmentMap;
     this.envEmulator = envEmulator;
     this.regs        = new ushort[12];
 }
Ejemplo n.º 5
0
 public X86Emulator(IntelArchitecture arch, SegmentMap segmentMap, IPlatformEmulator envEmulator)
 {
     this.arch = arch;
     this.map = segmentMap;
     this.Registers = new ulong[40];
     this.Valid = new bool[40];
     this.envEmulator = envEmulator;
 }
Ejemplo n.º 6
0
 public PowerPcEmulator(PowerPcArchitecture arch, SegmentMap segmentMap, IPlatformEmulator envEmulator)
     : base(segmentMap)
 {
     this.arch         = arch;
     this.map          = segmentMap;
     this.envEmulator  = envEmulator;
     this.registerFile = new ulong[32];
 }
Ejemplo n.º 7
0
 public X86Emulator(IntelArchitecture arch, LoadedImage loadedImage, IPlatformEmulator envEmulator)
 {
     this.arch        = arch;
     this.img         = loadedImage;
     this.Registers   = new ulong[40];
     this.Valid       = new bool[40];
     this.envEmulator = envEmulator;
 }
Ejemplo n.º 8
0
 public override IProcessorEmulator CreateEmulator(SegmentMap segmentMap, IPlatformEmulator envEmulator)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 9
0
 public X86Protected32Emulator(IntelArchitecture arch, SegmentMap segmentMap, IPlatformEmulator envEmulator)
     : base(arch, segmentMap, envEmulator, X86.Registers.eip, X86.Registers.ecx)
 {
 }
Ejemplo n.º 10
0
 public override IProcessorEmulator CreateEmulator(SegmentMap segmentMap, IPlatformEmulator envEmulator)
 {
     return(mode.CreateEmulator(this, segmentMap, envEmulator));
 }
Ejemplo n.º 11
0
 public override IProcessorEmulator CreateEmulator(SegmentMap segmentMap, IPlatformEmulator envEmulator)
 => ProcessorModel.CreateEmulator(this, segmentMap, envEmulator);
Ejemplo n.º 12
0
 /// <summary>
 /// Creates an emulator for the target processor.
 /// </summary>
 /// <param name="arch">The architecture of the processor.</param>
 /// <param name="segmentMap">The memory of the program to be emulated.</param>
 /// <param name="envEmulator">Emulated environment.</param>
 /// <returns>The created emulator.</returns>
 public virtual IProcessorEmulator CreateEmulator(PICArchitecture arch, SegmentMap segmentMap, IPlatformEmulator envEmulator)
 => throw new NotImplementedException();
Ejemplo n.º 13
0
 public X86RealModeEmulator(IntelArchitecture arch, SegmentMap segmentMap, IPlatformEmulator envEmulator)
     : base(arch, segmentMap, envEmulator, X86.Registers.ip, X86.Registers.cx)
 {
 }
Ejemplo n.º 14
0
 public abstract IProcessorEmulator CreateEmulator(IntelArchitecture arch, SegmentMap segmentMap, IPlatformEmulator envEmulator);
Ejemplo n.º 15
0
 public override IProcessorEmulator CreateEmulator(IntelArchitecture arch, SegmentMap segmentMap, IPlatformEmulator envEmulator)
 {
     return(new X86Protected32Emulator(arch, segmentMap, envEmulator));
 }
Ejemplo n.º 16
0
 public abstract IProcessorEmulator CreateEmulator(SegmentMap segmentMap, IPlatformEmulator envEmulator);