private async Task <List <IShellItem> > ParseShellBags() { bool parseAllUsers = multiUserCheck.IsChecked.GetValueOrDefault(false); bool useRegistryHiveFiles = OfflineCheck.IsChecked.GetValueOrDefault(false); string osVersion = OSVersion.SelectedItem == null ? string.Empty : OSVersion.SelectedItem.ToString(); //potentially long running operation, operate in another thread. return(await Task.Run(() => { List <IShellItem> retList = new List <IShellItem>(); ConfigParser parser = new ConfigParser(locations.GUIDFileLocation, locations.OSFileLocation, locations.ScriptFileLocation); //perform offline shellbag parsing if (useRegistryHiveFiles) { parser.OsVersion = osVersion; string[] registryFilePaths = locations.OfflineFileLocations; foreach (string registryFile in registryFilePaths) { OfflineRegistryReader offlineReader = new OfflineRegistryReader(parser, registryFile); retList.AddRange(ShellBagParser.GetShellItems(offlineReader)); } } else //perform online shellbag parsing { OnlineRegistryReader onlineReader = new OnlineRegistryReader(parser, parseAllUsers); retList.AddRange(ShellBagParser.GetShellItems(onlineReader)); } return retList; })); }
public void GetShellItemsOfflineTest() { String registryFilePath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + @"\TestResource\NTUSER.DAT"; List <IShellItem> shellItems = ShellBagParser.GetShellItems(new OfflineRegistryReader(new OfflineMockConfigParser(), registryFilePath)); Assert.AreNotEqual(shellItems.Count, 0); //test for username presence in the shellItems foreach (IShellItem shellItem in shellItems) { Assert.AreEqual("Klayton", shellItem.GetAllProperties()["RegistryOwner"]); } }
public void GetShellItemsOnlineTest() { List <IShellItem> shellItems = ShellBagParser.GetShellItems(new OnlineRegistryReader(new MockConfigParser())); Assert.AreNotEqual(shellItems.Count, 0); }