示例#1
0
        public REFERENCE(PROJECTINFORMATION ProjectInformation, XlBinaryReader Data)
        {
            this.NameRecord = new REFERENCENAME(ProjectInformation, Data);

            var peek = Data.PeekUInt16();

            if (peek == 0x002F)
            {
                this.ReferenceRecord = new REFERENCECONTROL(ProjectInformation, Data);
            }
            else if (peek == 0x0033)
            {
                // todo: Test this, documentation says 0x0033 is REFERENCECONTROL too but this seems odd
                this.ReferenceRecord = new REFERENCEORIGINAL(Data);
            }
            else if (peek == 0x000D)
            {
                this.ReferenceRecord = new REFERENCEREGISTERED(Data);
            }
            else if (peek == 0x000E)
            {
                this.ReferenceRecord = new REFERENCEPROJECT(ProjectInformation, Data);
            }
            else
            {
                throw new WrongValueException("peek", peek, "0x002F, 0x0033, 0x000D or 0x000E");
            }

            Validate();
        }
示例#2
0
        public MODULE(PROJECTINFORMATION ProjectInformation, XlBinaryReader Data)
        {
            this.NameRecord        = new MODULENAME(ProjectInformation, Data);
            this.NameUnicodeRecord = new MODULENAMEUNICODE(Data);
            this.StreamNameRecord  = new MODULESTREAMNAME(ProjectInformation, Data);
            this.DocStringRecord   = new MODULEDOCSTRING(Data);
            this.OffsetRecord      = new MODULEOFFSET(Data);
            this.HelpContextRecord = new MODULEHELPCONTEXT(Data);
            this.CookieRecord      = new MODULECOOKIE(Data);
            this.TypeRecord        = new MODULETYPE(Data);

            if (Data.PeekUInt16() == (UInt16)0x0025)
            {
                this.ReadOnlyRecord = new MODULEREADONLY(Data);
            }

            if (Data.PeekUInt16() == (UInt16)0x0028)
            {
                this.PrivateRecord = new MODULEPRIVATE(Data);
            }

            this.Terminator = Data.ReadUInt16();
            this.Reserved   = Data.ReadUInt32();

            Validate();
        }
        public REFERENCECONTROL(PROJECTINFORMATION ProjectInformation, XlBinaryReader Data)
        {
            this.Id                  = Data.ReadUInt16();
            this.SizeTwiddled        = Data.ReadUInt32();
            this.SizeOfLibidTwiddled = Data.ReadUInt32();
            this.LibidTwiddled       = Data.ReadBytes(this.SizeOfLibidTwiddled);
            this.Reserved1           = Data.ReadUInt32();
            this.Reserved2           = Data.ReadUInt16();

            UInt16 peek = Data.PeekUInt16();

            if (peek == (UInt16)0x0016)
            {
                // REFERENCENAME record
                this.NameRecordExtended = new REFERENCENAME(ProjectInformation, Data);
            }

            this.Reserved3           = Data.ReadUInt16();
            this.SizeExtended        = Data.ReadUInt32();
            this.SizeOfLibidExtended = Data.ReadUInt32();
            this.LibidExtended       = Data.ReadBytes(this.SizeOfLibidExtended);
            this.Reserved4           = Data.ReadUInt32();
            this.Reserved5           = Data.ReadUInt16();
            this.OriginalTypeLib     = Data.ReadGuid();
            this.Cookie = Data.ReadUInt32();

            Validate();
        }
示例#4
0
文件: VbaStorage.cs 项目: pepe57/vba
        public VbaStorage(CFStorage VBAStorage)
        {
            // DIR STREAM -------------------------
            CFStream thisWorkbookStream = VBAStorage.GetStream("dir");

            Byte[] compressedData = thisWorkbookStream.GetData();

            var reader    = new XlBinaryReader(ref compressedData);
            var container = new CompressedContainer(reader);

            // Decompress
            var buffer = new DecompressedBuffer();

            container.Decompress(buffer);
            Byte[] uncompressed = buffer.GetData();

            var uncompressedDataReader = new XlBinaryReader(ref uncompressed);

            this.DirStream = new DirStream(uncompressedDataReader);

            // MODULE STREAMS ----------------------------------------
            this.ModuleStreams = new Dictionary <string, ModuleStream>(DirStream.ModulesRecord.Modules.Length);
            foreach (var module in DirStream.ModulesRecord.Modules)
            {
                var streamName  = module.StreamNameRecord.GetStreamNameAsString();
                var stream      = VBAStorage.GetStream(streamName).GetData();
                var localreader = new XlBinaryReader(ref stream);

                var moduleStream = new ModuleStream(DirStream.InformationRecord, module, localreader);

                this.ModuleStreams.Add(streamName, moduleStream);
            }
        }
示例#5
0
        public PROJECTLCID(XlBinaryReader Data)
        {
            this.Id   = Data.ReadUInt16();
            this.Size = Data.ReadUInt32();
            this.Lcid = Data.ReadUInt32();

            Validate();
        }
        public PROJECTCODEPAGE(XlBinaryReader Data)
        {
            this.Id       = Data.ReadUInt16();
            this.Size     = Data.ReadUInt32();
            this.CodePage = Data.ReadUInt16();

            Validate();
        }
示例#7
0
        public MODULENAMEUNICODE(XlBinaryReader Data)
        {
            this.Id = Data.ReadUInt16();
            this.SizeOfModuleNameUnicode = Data.ReadUInt32();
            this.ModuleNameUnicode       = Data.ReadBytes(this.SizeOfModuleNameUnicode);

            Validate();
        }
        public PROJECTHELPCONTEXT(XlBinaryReader Data)
        {
            this.Id          = Data.ReadUInt16();
            this.Size        = Data.ReadUInt32();
            this.HelpContext = Data.ReadUInt32();

            Validate();
        }
        public PROJECTSYSKIND(XlBinaryReader Data)
        {
            this.Id      = Data.ReadUInt16();
            this.Size    = Data.ReadUInt32();
            this.SysKind = Data.ReadUInt32();

            Validate();
        }
        public PROJECTLIBFLAGS(XlBinaryReader Data)
        {
            this.Id              = Data.ReadUInt16();
            this.Size            = Data.ReadUInt32();
            this.ProjectLibFlags = Data.ReadUInt32();

            Validate();
        }
        public PROJECTCOOKIE(XlBinaryReader Data)
        {
            this.Id     = Data.ReadUInt16();
            this.Size   = Data.ReadUInt32();
            this.Cookie = Data.ReadUInt16();

            Validate();
        }
示例#12
0
        public REFERENCEORIGINAL(XlBinaryReader Data)
        {
            this.Id = Data.ReadUInt16();
            this.SizeOfLibidOriginal = Data.ReadUInt32();
            this.LibidOriginal       = Data.ReadBytes(this.SizeOfLibidOriginal);

            Validate();
        }
示例#13
0
        public PROJECTVERSION(XlBinaryReader Data)
        {
            this.Id           = Data.ReadUInt16();
            this.Reserved     = Data.ReadUInt32();
            this.VersionMajor = Data.ReadUInt32();
            this.VersionMinor = Data.ReadUInt16();

            Validate();
        }
        public PROJECTNAME(PROJECTINFORMATION parent, XlBinaryReader Data)
        {
            this.parent = parent;

            this.Id          = Data.ReadUInt16();
            this.Size        = Data.ReadUInt32();
            this.ProjectName = Data.ReadBytes((int)this.Size);

            Validate();
        }
示例#15
0
文件: MODULENAME.cs 项目: pepe57/vba
        public MODULENAME(PROJECTINFORMATION ProjectInformation, XlBinaryReader Data)
            : base(Data)
        {
            this.ProjectInformation = ProjectInformation;

            //this.Id = Data.ReadUInt16();
            //this.SizeOfModuleName = Data.ReadUInt32();
            //this.ModuleName = Data.ReadBytes(this.SizeOfModuleName);

            Validate();
        }
示例#16
0
        public REFERENCEREGISTERED(XlBinaryReader Data)
        {
            this.Id          = Data.ReadUInt16();
            this.Size        = Data.ReadUInt32();
            this.SizeOfLibid = Data.ReadUInt32();
            this.Libid       = Data.ReadBytes(this.SizeOfLibid);
            this.Reserved1   = Data.ReadUInt32();
            this.Reserved2   = Data.ReadUInt16();

            Validate();
        }
示例#17
0
        private _VBA_PROJECTStream ReadVbaProjectStream(CFStorage VBAStorage)
        {
            CFStream stream = VBAStorage.GetStream("_VBA_PROJECT");

            Byte[] uncompressedData = stream.GetData();

            var dataReader = new XlBinaryReader(ref uncompressedData);
            var result     = new _VBA_PROJECTStream(dataReader);

            return(result);
        }
示例#18
0
        public PROJECTHELPFILEPATH(PROJECTINFORMATION parent, XlBinaryReader Data)
        {
            this.parent = parent;

            this.Id = Data.ReadUInt16();
            this.SizeOfHelpFile1 = Data.ReadUInt32();
            this.HelpFile1       = Data.ReadBytes(this.SizeOfHelpFile1);
            this.Reserved        = Data.ReadUInt16();
            this.SizeOfHelpFile2 = Data.ReadUInt32();
            this.HelpFile2       = Data.ReadBytes(this.SizeOfHelpFile2);

            Validate();
        }
        public PROJECTCONSTANTS(PROJECTINFORMATION parent, XlBinaryReader Data)
        {
            this.parent = parent;

            this.Id = Data.ReadUInt16();
            this.SizeOfConstants        = Data.ReadUInt32();
            this.Constants              = Data.ReadBytes(this.SizeOfConstants);
            this.Reserved               = Data.ReadUInt16();
            this.SizeOfConstantsUnicode = Data.ReadUInt32();
            this.ConstantsUnicode       = Data.ReadBytes(this.SizeOfConstantsUnicode);

            Validate();
        }
示例#20
0
        public _VBA_PROJECTStream(XlBinaryReader data)
        {
            this.Reserved1 = data.ReadUInt16();
            this.Version   = data.ReadUInt16();
            this.Reserved2 = data.ReadByte();
            this.Reserved3 = data.ReadUInt16();

            int PerformanceCacheLength = data.Length - 7;

            this.PerformanceCache = data.ReadBytes(PerformanceCacheLength);

            Validate();
        }
示例#21
0
        public MODULESTREAMNAME(PROJECTINFORMATION ProjectInformation, XlBinaryReader Data)
        {
            this.ProjectInformation = ProjectInformation;

            this.Id = Data.ReadUInt16();
            this.SizeOfStreamName        = Data.ReadUInt32();
            this.StreamName              = Data.ReadBytes(this.SizeOfStreamName);
            this.Reserved                = Data.ReadUInt16();
            this.SizeOfStreamNameUnicode = Data.ReadUInt32();
            this.StreamNameUnicode       = Data.ReadBytes(this.SizeOfStreamNameUnicode);

            Validate();
        }
示例#22
0
        protected virtual void AutoReadMembers(XlBinaryReader Reader)
        {
            Type type            = thisType;
            var  autoReadMembers = type.GetMembers().Where(mi => Attribute.IsDefined(mi, typeof(AutoReadAttribute))).OrderBy(mi => mi.GetCustomAttribute <AutoReadAttribute>().Order);

            foreach (var member in autoReadMembers)
            {
                AutoReadAttribute attr = member.GetCustomAttribute <AutoReadAttribute>();
                var value = attr.AutoReadValue(Reader, this, member);

                ReflectionHelper.SetValue(this, member, value);
            }
        }
示例#23
0
        public PROJECTDOCSTRING(PROJECTINFORMATION parent, XlBinaryReader Data)
        {
            this.parent = parent;

            this.Id = Data.ReadUInt16();
            this.SizeOfDocString        = Data.ReadUInt32();
            this.DocString              = Data.ReadBytes(Convert.ToInt32(this.SizeOfDocString));
            this.Reserved               = Data.ReadUInt16();
            this.SizeOfDocStringUnicode = Data.ReadUInt32();
            this.DocStringUnicode       = Data.ReadBytes(Convert.ToInt32(this.SizeOfDocStringUnicode));

            Validate();
        }
示例#24
0
        public REFERENCENAME(PROJECTINFORMATION ProjectInformation, XlBinaryReader Data)
        {
            this.ProjectInformation = ProjectInformation;

            this.Id                = Data.ReadUInt16();
            this.SizeOfName        = Data.ReadUInt32();
            this.Name              = Data.ReadBytes(this.SizeOfName);
            this.Reserved          = Data.ReadUInt16();
            this.SizeOfNameUnicode = Data.ReadUInt32();
            this.NameUnicode       = Data.ReadBytes(this.SizeOfNameUnicode);

            Validate();
        }
        public ModuleStream(PROJECTINFORMATION ProjectInformation, MODULE module, XlBinaryReader Data)
        {
            this.ProjectInformation = ProjectInformation;

            this.PerformanceCache = Data.ReadBytes(module.OffsetRecord.TextOffset);

            Byte[] rest      = Data.GetUnreadData();
            var    reader    = new XlBinaryReader(ref rest);
            var    container = new CompressedContainer(reader);
            var    buffer    = new DecompressedBuffer();

            container.Decompress(buffer);
            this.UncompressedSourceCode = buffer.GetData();
        }
        public PROJECTREFERENCES(PROJECTINFORMATION ProjectInformation, XlBinaryReader Data)
        {
            var result = new List <REFERENCE>();

            // Read without progressing the pointer.
            // 0x000F indicates the beginning of a PROJECTMODULES Record, so we're done once we encounter that.
            while (Data.PeekUInt16() != 0x000F)
            {
                var reference = new REFERENCE(ProjectInformation, Data);
                result.Add(reference);
            }

            this.ReferenceArray = result.ToArray();
        }
示例#27
0
 public object AutoReadValue(XlBinaryReader Reader, object TargetObject, MemberInfo member)
 {
     if (!this.IsArray)
     {
         Type type = ReflectionHelper.GetTypeOf(member);
         return(Reader.Read(type));
     }
     else
     {
         var  arraySize   = this.CalculateArraySize(TargetObject, member);
         Type type        = ReflectionHelper.GetTypeOf(member);
         Type elementType = type.GetElementType();
         return(Reader.ReadArray(elementType, arraySize));
     }
 }
示例#28
0
        public REFERENCEPROJECT(PROJECTINFORMATION ProjectInformation, XlBinaryReader Data)
        {
            this.ProjectInformation = ProjectInformation;

            this.Id   = Data.ReadUInt16();
            this.Size = Data.ReadUInt32();
            this.SizeOfLibidAbsolute = Data.ReadUInt32();
            this.LibidAbsolute       = Data.ReadBytes(this.SizeOfLibidAbsolute);
            this.SizeOfLibidRelative = Data.ReadUInt32();
            this.LibidRelative       = Data.ReadBytes(this.SizeOfLibidRelative);
            this.MajorVersion        = Data.ReadUInt32();
            this.MinorVersion        = Data.ReadUInt16();

            Validate();
        }
示例#29
0
        public PROJECTINFORMATION(XlBinaryReader Data)
        {
            this.SysKindRecord      = new PROJECTSYSKIND(Data);
            this.LcidRecord         = new PROJECTLCID(Data);
            this.LcidInvokeRecord   = new PROJECTLCIDINVOKE(Data);
            this.CodePageRecord     = new PROJECTCODEPAGE(Data);
            this.NameRecord         = new PROJECTNAME(this, Data);
            this.DocStringRecord    = new PROJECTDOCSTRING(this, Data);
            this.HelpFilePathRecord = new PROJECTHELPFILEPATH(this, Data);
            this.HelpContextRecord  = new PROJECTHELPCONTEXT(Data);
            this.LibFlagsRecord     = new PROJECTLIBFLAGS(Data);
            this.VersionRecord      = new PROJECTVERSION(Data);
            this.ConstantsRecord    = new PROJECTCONSTANTS(this, Data);

            Validate();
        }
示例#30
0
        public PROJECTMODULES(PROJECTINFORMATION ProjectInformation, XlBinaryReader Data)
        {
            this.Id    = Data.ReadUInt16();
            this.Size  = Data.ReadUInt32();
            this.Count = Data.ReadUInt16();
            this.ProjectCookieRecord = new PROJECTCOOKIE(Data);

            // Read Modules
            this.Modules = new MODULE[this.Count];
            for (int i = 0; i < this.Count; i++)
            {
                var module = new MODULE(ProjectInformation, Data);
                this.Modules[i] = module;
            }

            Validate();
        }