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 OllyLangInterpreter(Services, program.Architecture); this.scriptInterpreter.Host = new OdbgScriptHost(this, program); 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 !); scriptInterpreter.Script = LoadScript(scriptInterpreter.Host, Argument !); emu.Start(); envEmu.TearDownStack(stackSeg); foreach (var ic in envEmu.InterceptedCalls) { program.InterceptedCalls.Add(ic.Key, ic.Value); } return(program); }
public OdbgScriptLoader(ImageLoader imageLoader) : base(imageLoader.Services, imageLoader.Filename, imageLoader.RawImage) { this.originalImageLoader = imageLoader; this.Architecture = null !; this.debugger = null !; this.scriptInterpreter = null !; this.ImageMap = null !; this.OriginalEntryPoint = null !; }
private void Given_Engine() { 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 OllyLangInterpreter(null, arch.Object) { Host = host.Object, Debugger = new Debugger(emu.Object), }; }