public void Upsvc_Find_Match() { var image = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x12, 0x34, 0x00, 0x00 }; var le = mr.Stub <LoaderElement>(); le.Label = "LoaderKey"; le.TypeName = typeof(TestImageLoader).AssemblyQualifiedName; cfgSvc.Stub(c => c.GetImageLoaders()).Return(new List <LoaderElement> { le }); sc.AddService(typeof(IConfigurationService), cfgSvc); mr.ReplayAll(); var upSvc = new UnpackingService(sc); upSvc.Signatures.Add(new ImageSignature { Name = "LoaderKey", EntryPointPattern = "1234", }); var loader = upSvc.FindUnpackerBySignature("foo.exe", image, 4); Assert.IsInstanceOf <TestImageLoader>(loader); }
public void Upsvc_Find_Match() { var image = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x12, 0x34, 0x00, 0x00 }; Given_File("foo.exe.sufa-raw.ubj", new byte[] { 0x5B, 0x24, 0x6C, 0x23, 0x69, 0x00 }); var le = new Mock <LoaderDefinition>(); le.SetupAllProperties(); le.Object.Label = "LoaderKey"; le.Object.TypeName = typeof(TestImageLoader).AssemblyQualifiedName; cfgSvc.Setup(c => c.GetImageLoader("LoaderKey")).Returns(le.Object); sc.AddService <IConfigurationService>(cfgSvc.Object); var upSvc = new UnpackingService(sc); upSvc.Signatures.Add(new ImageSignature { Name = "LoaderKey", EntryPointPattern = "1234", }); var loader = upSvc.FindUnpackerBySignature( new NullImageLoader( sc, ImageLocation.FromUri("file:foo.exe"), image), 4); Assert.IsInstanceOf <TestImageLoader>(loader); }
public void Upsvc_LoadSuffixArray_LoadSuffixArrayIfpresent() { Given_File("foo.exe.sufa-raw.ubj", new byte[] { 0x5B, 0x24, 0x6C, 0x23, 0x69, 0x00 }); var upsvc = new UnpackingService(sc); upsvc.FindUnpackerBySignature(new NullImageLoader(sc, "foo.exe", new byte[0x1000]), 0x0100); }
public void Upsvc_LoadSuffixArray_CreateSuffixArrayIfpresent() { Given_NoFile("foo.exe.sufa-raw.ubj"); // , new byte[] { 0x5B, 0x24, 0x6C, 0x23, 0x69, 0x00 }); var stm = new MemoryStream(); fsSvc.Setup(f => f.CreateFileStream("foo.exe.sufa-raw.ubj", FileMode.Create, FileAccess.Write)) .Returns(stm); var upsvc = new UnpackingService(sc); upsvc.FindUnpackerBySignature(new NullImageLoader(sc, "foo.exe", new byte[0x4]), 0); Assert.AreEqual(new byte[] { 0x5B, 0x24, 0x6C, 0x23, 0x69, 0x04, 0x00, 0x00, 0x00, 0x003, 0x00, 0x00, 0x00, 0x002, 0x00, 0x00, 0x00, 0x001, 0x00, 0x00, 0x00, 0x000, }, stm.ToArray()); }