private byte[] CreateDestListBinaryFromDestListObj(JumpListFile JL, bool DeleteUnwanted = false) { byte[] DestListBinary = new byte[JL.DestListSize]; using (MemoryStream DestListStream = new MemoryStream(this.DestListObj.Header)) { DestListStream.Read(DestListBinary, 0x0, 0x20); } if (DeleteUnwanted) { int ExtraBytes = 0; int DestListStreamPosition = 0x20; foreach (DestListEntry DestListEntryObj in JL.DestListEntries) { if (!DestListEntryObj.PendingDelete) { using (MemoryStream DestListStream = new MemoryStream(DestListEntryObj.RawData)) { DestListStream.Read(DestListBinary, DestListStreamPosition, (int)DestListEntryObj.EntrySize); }; DestListStreamPosition += (int)DestListEntryObj.EntrySize; } else { ExtraBytes += (int)DestListEntryObj.EntrySize; } } byte[] NewDestListBinary = new byte[JL.DestListSize - ExtraBytes]; for (int i = 0; i < NewDestListBinary.Length; i++) { NewDestListBinary[i] = DestListBinary[i]; } DestListBinary = NewDestListBinary; } else { foreach (DestListEntry DestListEntryObj in JL.DestListEntries) { using (MemoryStream DestListStream = new MemoryStream(DestListEntryObj.RawData)) { DestListStream.Read(DestListBinary, (int)DestListEntryObj.EntryPosition, (int)DestListEntryObj.EntrySize); }; } } return DestListBinary; }
private bool ParseJumpList(string JumpListFilePath) { this.DestListObj = new DestList(); JumpListFile JumpListFileObj = new JumpListFile { FilePath = JumpListFilePath, FileName = System.IO.Path.GetFileName(JumpListFilePath) }; CompoundFile JumpListFileCompound = new CompoundFile(JumpListFilePath); CFStream JumpListDestListStream = JumpListFileCompound.RootStorage.GetStream("DestList"); JumpListFileObj.DestListSize = JumpListDestListStream.Size; List<DestListEntry> JumpListEntries = this.ParseDestList(JumpListDestListStream.GetData()); JumpListFileObj.DestListEntries = JumpListEntries; List<DestListEntry> JumpListEntriesToRemove = new List<DestListEntry>(); foreach (DestListEntry JumpListEntry in JumpListEntries) { CFStream JumpListEntryStream = null; bool err = false; try { try { JumpListEntryStream = JumpListFileCompound.RootStorage.GetStream(JumpListEntry.StreamNo); } catch (OpenMcdf.CFItemNotFound e) { this.ScrubberGUIInst.DebugPrint("Error (JumpList): List seems empty. List: " + JumpListFilePath + " StreamNo: " + JumpListEntry.StreamNo); JumpListFileCompound.Close(); JumpListEntriesToRemove.Add(JumpListEntry); err = true; continue; } JumpList JumpListObj = new JumpList { Name = JumpListEntry.StreamNo, Size = JumpListEntryStream.GetData().Length, DestListEntry = JumpListEntry }; JumpListFileObj.JumpLists.Add(JumpListObj); this.JumpListFiles = JumpListFileObj; if (!err) { JumpListFileObj.JumpLists.Add(JumpListObj); } this.JumpListFiles = JumpListFileObj; } catch (Exception e) { this.ScrubberGUIInst.DebugPrint(e.ToString()); continue; } }JumpListFileCompound.Close(); foreach (DestListEntry JumpListEntry in JumpListEntriesToRemove) { JumpListEntries.Remove(JumpListEntry); JumpListFileObj.DestListEntries.Remove(JumpListEntry); //File.Delete(JumpListFilePath); } if (JumpListEntries.Count == 0) return false; this._jumpListFiles.Add(JumpListFileObj); return true; }