private static void ReadBinFile(string path) { using (var VbaStorage = new VbaStorage(path)) { PrintStorage(VbaStorage); } }
public VbProject(VbaProjectPart vbaProjectPart) : this() { if (vbaProjectPart == null) { throw new ArgumentNullException("vbaProjectPart"); } var stream = GetVbaStreamFrom(vbaProjectPart); this.m_Storage = new VbaStorage(stream); }
public void Dispose() { if (m_spreadsheetDisposable != null) { m_spreadsheetDisposable.Dispose(); m_spreadsheetDisposable = null; } if (m_Storage != null) { m_Storage.Dispose(); m_Storage = null; } }
private static void PrintStorage(VbaStorage VbaStorage) { if (VbaStorage == null) { throw new ArgumentNullException("VbaStorage"); } Console.WriteLine("- - - VbaStorage - - -"); Console.WriteLine("Project name: {0}", VbaStorage.DirStream.InformationRecord.NameRecord.GetProjectNameAsString()); Console.WriteLine("Project docstring: {0}", VbaStorage.DirStream.InformationRecord.DocStringRecord.GetDocStringAsString()); Console.WriteLine("Project constants: {0}", VbaStorage.DirStream.InformationRecord.ConstantsRecord.GetConstantsAsString()); foreach (KeyValuePair <string, ModuleStream> ms in VbaStorage.ModuleStreams) { Console.WriteLine("\tModule stream: {0}", ms.Key); Console.WriteLine("Source code:"); Console.WriteLine(ms.Value.GetUncompressedSourceCodeAsString()); } }
static void Main(string[] args) { string filename = @"H:\test.vbaProject.bin"; var VbaStorage = new VbaStorage(filename); Console.WriteLine("- - - INFO - - -"); Console.WriteLine("Project name: {0}", VbaStorage.DirStream.InformationRecord.NameRecord.GetProjectNameAsString()); Console.WriteLine("Project docstring: {0}", VbaStorage.DirStream.InformationRecord.DocStringRecord.GetDocStringAsString()); Console.WriteLine("Project constants: {0}", VbaStorage.DirStream.InformationRecord.ConstantsRecord.GetConstantsAsString()); foreach (KeyValuePair <string, ModuleStream> ms in VbaStorage.ModuleStreams) { Console.WriteLine("\tModule stream: {0}", ms.Key); Console.WriteLine("Source code:"); Console.WriteLine(ms.Value.GetUncompressedSourceCodeAsString()); } /* * CompoundFile cf = new CompoundFile(filename); * var root = cf.RootStorage; * //root.VisitEntries(Visit, false); * * // Read (compressed data) * CFStream thisWorkbookStream = root.GetStorage("VBA").GetStream("dir"); * Byte[] compressedData = thisWorkbookStream.GetData(); * File.WriteAllBytes("CompressedDirStream.bin", compressedData); * var reader = new XlBinaryReader(ref compressedData); * var container = new CompressedContainer(reader); * * // Decompress * var buffer = new DecompressedBuffer(); * container.Decompress(buffer); * Byte[] uncompressed = buffer.GetData(); * File.WriteAllBytes("UncompressedDirStream.bin", uncompressed); * * * var uncompressedDataReader = new XlBinaryReader(ref uncompressed); * var dirStream = new DirStream(uncompressedDataReader); * * //var uncompressedData = container.Uncompress(); * * * * // ProcessDirStream(uncompressedData); * * Console.WriteLine("- - - INFO - - -"); * Console.WriteLine("Project name: {0}", dirStream.InformationRecord.NameRecord.GetProjectNameAsString()); * Console.WriteLine("Project docstring: {0}", dirStream.InformationRecord.DocStringRecord.GetDocStringAsString()); * Console.WriteLine("Project constants: {0}", dirStream.InformationRecord.ConstantsRecord.GetConstantsAsString()); * Console.WriteLine("Modules"); * foreach(var module in dirStream.ModulesRecord.Modules) * { * Console.WriteLine(); * Console.WriteLine("-------------------------"); * Console.WriteLine(); * * Console.WriteLine("\tName: {0} (stream {1})", module.NameRecord.GetModuleNameAsString(), module.StreamNameRecord.GetStreamNameAsString()); * * var streamName = module.StreamNameRecord.GetStreamNameAsString(); * var stream = root.GetStorage("VBA").GetStream(streamName).GetData(); * var localreader = new XlBinaryReader(ref stream); * * var moduleStream = new ModuleStream(dirStream.InformationRecord, module, localreader); * * Console.WriteLine("Source code:"); * Console.WriteLine(moduleStream.GetUncompressedSourceCodeAsString()); * * Console.WriteLine("got stream"); * }*/ Console.WriteLine("done"); Console.ReadKey(); }
public static VbProject ToVbProject(this VbaStorage vbaStorage) { return(new VbProject(vbaStorage)); }
public VbProject(VbaStorage vbaStorage) : this() { this.m_Storage = vbaStorage; }