/// <summary> /// Using the image of the program under investigation, find an /// unpacker capable of unpacking it, and returns a new <see cref="ImageLoader"/> /// instance. /// </summary> /// <param name="loader">Raw image loader.</param> /// <param name="entryPointOffset">Offset of the program entry point.</param> /// <returns>If an unpacker was found, returns a new wrapping ImageLoader. Otherwise /// the original loader is returned.</returns> public ProgramImageLoader FindUnpackerBySignature(ProgramImageLoader loader, uint entryPointOffset) { var listener = Services.RequireService <DecompilerEventListener>(); // $TODO: the code below triggers the creation of the suffix array // The suffix array is currently unused but the algorithm that generates it scales poorly // making Reko unable to load certain EXE files (due to the endless wait times) // EnsureSuffixArray(filename + ".sufa-raw.ubj", image); var signature = Signatures.Where(s => Matches(s, loader.RawImage, entryPointOffset)).FirstOrDefault(); if (signature == null || signature.Name == null) { return(loader); } listener.Info("Signature of '{0}' detected.", signature.Name); var le = Services.RequireService <IConfigurationService>().GetImageLoader(signature.Name); //$REVIEW: all of themn? if (le == null || le.TypeName == null) { return(loader); } var unpacker = Loader.CreateOuterImageLoader <ProgramImageLoader>(Services, le.TypeName, loader); if (unpacker == null) { listener.Warn("Unable to create loader for '{0}'.", signature.Name); return(loader); } listener.Info("Using loader for '{0}'.", signature.Name); unpacker.Argument = le.Argument; return(unpacker); }
public OdbgScriptLoader(ProgramImageLoader imageLoader) : base(imageLoader.Services, imageLoader.ImageLocation, imageLoader.RawImage) { this.originalImageLoader = imageLoader; this.Architecture = null !; this.debugger = null !; this.scriptInterpreter = null !; this.ImageMap = null !; this.OriginalEntryPoint = null !; }