private static void ReadBinFile(string path)
 {
     using (var VbaStorage = new VbaStorage(path))
     {
         PrintStorage(VbaStorage);
     }
 }
Exemple #2
0
        public VbProject(VbaProjectPart vbaProjectPart)
            : this()
        {
            if (vbaProjectPart == null)
            {
                throw new ArgumentNullException("vbaProjectPart");
            }

            var stream = GetVbaStreamFrom(vbaProjectPart);

            this.m_Storage = new VbaStorage(stream);
        }
Exemple #3
0
        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());
            }
        }
Exemple #5
0
        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));
 }
Exemple #7
0
 public VbProject(VbaStorage vbaStorage)
     : this()
 {
     this.m_Storage = vbaStorage;
 }