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; var win32 = new Win32Emulator(program.SegmentMap, program.Platform, program.ImportReferences); var state = (X86State)program.Architecture.CreateProcessorState(); 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(Address.Ptr32(ic.Key), ic.Value); } return(program); }
public override Program Load(Address addrLoad) { // First load the file. This gives us a (writeable) image and // the packed entry point. var origLdr = this.originalImageLoader; var program = origLdr.Load(origLdr.PreferredBaseAddress); var rr = origLdr.Relocate(program, origLdr.PreferredBaseAddress); this.ImageMap = program.SegmentMap; this.Architecture = program.Architecture; var envEmu = program.Platform.CreateEmulator(program.SegmentMap, program.ImportReferences); var emu = program.Architecture.CreateEmulator(program.SegmentMap, envEmu); this.debugger = new Debugger(emu); this.scriptInterpreter = new OllyLang(Services, program.Architecture); 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 = envEmu.InitializeStack(emu, rr.EntryPoints[0].ProcessorState); LoadScript(Argument, scriptInterpreter.Script); emu.Start(); envEmu.TearDownStack(stackSeg); foreach (var ic in envEmu.InterceptedCalls) { program.InterceptedCalls.Add(ic.Key, ic.Value); } return(program); }
private void Given_Engine() { this.host = mr.Stub <IHost>(); engine = new OllyLang(null); engine.Host = host; engine.Debugger = new Debugger(null); }
private void Given_Engine() { this.host = new Mock <IHost>(); engine = new OllyLang(null); engine.Host = host.Object; engine.Debugger = new Debugger(null); }
public OllyScript(OllyLang interpreter) { this.interpreter = interpreter; this.IsLoaded = false; this.Log = false; this.Lines = new List <Line>(); this.Labels = new Dictionary <string, uint>(); }
private void Given_Engine() { this.host = new Mock <IHost>(); arch.Setup(a => a.MakeAddressFromConstant( It.IsAny <Constant>(), It.IsAny <bool>())) .Returns(new Func <Constant, bool, Address>((c, f) => Address.Ptr32((uint)c.ToUInt64()))); engine = new OllyLang(null, arch.Object) { Host = host.Object, Debugger = new Debugger(emu.Object), }; }