public void setStorageClsid(ClassID clsidStorage) { directory.setStorageClsid(clsidStorage); }
@Override public int addOlePackage(byte[] oleData, String label, String fileName, String command) throws IOException { // check if we were created by POIFS otherwise create a new dummy POIFS for storing the package data if (initDirectory()) { preserveNodes = true; } // get free MBD-Node int storageId = 0; DirectoryEntry oleDir = null; do { String storageStr = "MBD"+ HexDump.toHex(++storageId); if (!getDirectory().hasEntry(storageStr)) { oleDir = getDirectory().createDirectory(storageStr); oleDir.setStorageClsid(ClassIDPredefined.OLE_V1_PACKAGE.getClassID()); } } while (oleDir == null); Ole10Native.createOleMarkerEntry(oleDir); Ole10Native oleNative = new Ole10Native(label, fileName, command, oleData); ByteArrayOutputStream bos = new ByteArrayOutputStream(); oleNative.writeOut(bos); oleDir.createDocument(Ole10Native.OLE10_NATIVE, new ByteArrayInputStream(bos.toByteArray())); return storageId; }
/** * Copies an Entry into a target POIFS directory, recursively */ @Internal public static void copyNodeRecursively( Entry entry, DirectoryEntry target ) throws IOException { if ( entry.isDirectoryEntry() ) { DirectoryEntry dirEntry = (DirectoryEntry)entry; DirectoryEntry newTarget = target.createDirectory( entry.getName() ); newTarget.setStorageClsid( dirEntry.getStorageClsid() ); Iterator<Entry> entries = dirEntry.getEntries(); while ( entries.hasNext() ) { copyNodeRecursively( entries.next(), newTarget ); } } else { DocumentEntry dentry = (DocumentEntry) entry; DocumentInputStream dstream = new DocumentInputStream( dentry ); target.createDocument( dentry.getName(), dstream ); dstream.close(); } }
public void setStorageClsid(ClassID clsidStorage) { directory.setStorageClsid(clsidStorage); }
public void setStorageClsid(ClassID clsidStorage) { directory.setStorageClsid(clsidStorage); }
public void setStorageClsid(ClassID clsidStorage) { directory.setStorageClsid(clsidStorage); }
protected void sanitize(BleachSession session, DirectoryEntry rootIn, DirectoryEntry rootOut) { LOGGER.debug("Entries before: {}", rootIn.getEntryNames()); // Save the changes to a new file // Returns false if the entry should be removed Predicate<Entry> visitor = ((Predicate<Entry>) (e -> true)) .and(new MacroRemover(session)) .and(new ObjectRemover(session)) .and(new SummaryInformationSanitiser(session)); LOGGER.debug("Root ClassID: {}", rootIn.getStorageClsid()); // https://blogs.msdn.microsoft.com/heaths/2006/02/27/identifying-windows-installer-file-types/ rootOut.setStorageClsid(rootIn.getStorageClsid()); rootIn .getEntries() .forEachRemaining( entry -> { if (!visitor.test(entry)) { return; } copyNodesRecursively(session, entry, rootOut); }); LOGGER.debug("Entries after: {}", rootOut.getEntryNames()); // Save the changes to a new file }
newTarget.setStorageClsid(dirEntry.getStorageClsid());
@Override public int addOlePackage(byte[] oleData, String label, String fileName, String command) throws IOException { // check if we were created by POIFS otherwise create a new dummy POIFS for storing the package data if (initDirectory()) { preserveNodes = true; } // get free MBD-Node int storageId = 0; DirectoryEntry oleDir = null; do { String storageStr = "MBD"+ HexDump.toHex(++storageId); if (!getDirectory().hasEntry(storageStr)) { oleDir = getDirectory().createDirectory(storageStr); oleDir.setStorageClsid(ClassIDPredefined.OLE_V1_PACKAGE.getClassID()); } } while (oleDir == null); Ole10Native.createOleMarkerEntry(oleDir); Ole10Native oleNative = new Ole10Native(label, fileName, command, oleData); ByteArrayOutputStream bos = new ByteArrayOutputStream(); oleNative.writeOut(bos); oleDir.createDocument(Ole10Native.OLE10_NATIVE, new ByteArrayInputStream(bos.toByteArray())); return storageId; }
/** * Copies an Entry into a target POIFS directory, recursively */ @Internal public static void copyNodeRecursively( Entry entry, DirectoryEntry target ) throws IOException { if ( entry.isDirectoryEntry() ) { DirectoryEntry dirEntry = (DirectoryEntry)entry; DirectoryEntry newTarget = target.createDirectory( entry.getName() ); newTarget.setStorageClsid( dirEntry.getStorageClsid() ); Iterator<Entry> entries = dirEntry.getEntries(); while ( entries.hasNext() ) { copyNodeRecursively( entries.next(), newTarget ); } } else { DocumentEntry dentry = (DocumentEntry) entry; DocumentInputStream dstream = new DocumentInputStream( dentry ); target.createDocument( dentry.getName(), dstream ); dstream.close(); } }
if (!root.hasEntry(storageStr)) { oleDir = root.createDirectory(storageStr); oleDir.setStorageClsid(PACKAGE.getClassID());