public KeyMapEntry(VirtualStreamReader reader) : base(reader, KME_LENGTH) { //ignore the first 4 bytes reader.ReadBytes(4); //Primary KCM this.kcm1 = reader.ReadInt16(); //Secondary KCM this.kcm2 = reader.ReadInt16(); //Key Action Type this.kt = (ActionType)reader.ReadInt16(); //read the params switch (this.kt) { case ActionType.ktCid: this.paramCid = new CommandIdentifier(reader); break; case ActionType.ktChar: this.paramChar = (char)reader.ReadInt32(); break; default: reader.ReadBytes(4); break; } }
public CustomToolbarWrapper(VirtualStreamReader reader) : base(reader, ByteStructure.VARIABLE_LENGTH) { long startPos = reader.BaseStream.Position; //skip the first 7 bytes byte[] skipped = reader.ReadBytes(7); this.cbTBD = reader.ReadInt16(); this.cCust = reader.ReadInt16(); this.cbDTBC = reader.ReadInt32(); this.rTBDC = new List <ToolbarControl>(); int rTbdcEndPos = (int)(reader.BaseStream.Position + cbDTBC); while (reader.BaseStream.Position < rTbdcEndPos) { this.rTBDC.Add(new ToolbarControl(reader)); } reader.BaseStream.Seek(rTbdcEndPos, System.IO.SeekOrigin.Begin); this.rCustomizations = new List <ToolbarCustomization>(); for (int i = 0; i < cCust; i++) { this.rCustomizations.Add(new ToolbarCustomization(reader)); } long endPos = reader.BaseStream.Position; //read the raw bytes reader.BaseStream.Seek(startPos - 1, System.IO.SeekOrigin.Begin); this._rawBytes = reader.ReadBytes((int)(endPos - startPos + 1)); }
private void processLinkInfoStream(string linkStream) { try { VirtualStreamReader reader = new VirtualStreamReader(_docStorage.GetStream(linkStream)); //there are two versions of the Link string, one contains ANSI characters, the other contains //unicode characters. //Both strings seem not to be standardized: //The length prefix is a character count EXCLUDING the terminating zero //Read the ANSI version Int16 cch = reader.ReadInt16(); byte[] str = reader.ReadBytes(cch); this.Link = Encoding.ASCII.GetString(str); //skip the terminating zero of the ANSI string //even if the characters are ANSI chars, the terminating zero has 2 bytes reader.ReadBytes(2); //skip the next 4 bytes (flags?) reader.ReadBytes(4); //Read the Unicode version cch = reader.ReadInt16(); str = reader.ReadBytes(cch * 2); this.Link = Encoding.Unicode.GetString(str); //skip the terminating zero of the Unicode string reader.ReadBytes(2); } catch (StreamNotFoundException) { } }
public MacroData(VirtualStreamReader reader) : base(reader, MCD_LENGTH) { //first 2 bytes are reserved reader.ReadBytes(2); this.ibst = reader.ReadInt16(); this.ibstName = reader.ReadInt16(); //last 18 bytes are reserved reader.ReadBytes(18); }
public BreakDescriptor(VirtualStreamReader reader, int length) : base(reader, length) { this.ipgd = reader.ReadInt16(); this.itxbxs = this.ipgd; this.dcpDepend = reader.ReadInt16(); int flag = (int)reader.ReadInt16(); this.icol = (UInt16)Utils.BitmaskToInt(flag, 0x00FF); this.fTableBreak = Utils.BitmaskToBool(flag, 0x0100); this.fColumnBreak = Utils.BitmaskToBool(flag, 0x0200); this.fMarked = Utils.BitmaskToBool(flag, 0x0400); this.fUnk = Utils.BitmaskToBool(flag, 0x0800); this.fTextOverflow = Utils.BitmaskToBool(flag, 0x1000); }
public ListTable(FileInformationBlock fib, VirtualStream tableStream) { if (fib.lcbPlfLst > 0) { var reader = new VirtualStreamReader(tableStream); reader.BaseStream.Seek(fib.fcPlfLst, System.IO.SeekOrigin.Begin); //the ListTable is not a real plex: //it starts with a count, followed by the array of LSTF structs, //followed by the array of LVLF structs //read count short count = reader.ReadInt16(); //read the LSTF structs for (int i = 0; i < count; i++) { this.Add(new ListData(reader, ByteStructure.VARIABLE_LENGTH)); } //read the LVLF structs for (int i = 0; i < count; i++) { var lstf = this[i]; for (int j = 0; j < lstf.rglvl.Length; j++) { lstf.rglvl[j] = new ListLevel(reader, ByteStructure.VARIABLE_LENGTH); } } } }
private void parse(VirtualStream stream, int fc) { stream.Seek(fc, System.IO.SeekOrigin.Begin); var reader = new VirtualStreamReader(stream); this.lcb = reader.ReadInt32(); this.cbHeader = reader.ReadInt16(); reader.ReadBytes(62); this.binData = reader.ReadBytes(this.lcb - this.cbHeader); }
public CommentAuthorTable(FileInformationBlock fib, VirtualStream tableStream) { tableStream.Seek(fib.fcGrpXstAtnOwners, System.IO.SeekOrigin.Begin); VirtualStreamReader reader = new VirtualStreamReader(tableStream); while (tableStream.Position < (fib.fcGrpXstAtnOwners + fib.lcbGrpXstAtnOwners)) { Int16 cch = reader.ReadInt16(); this.Add(Encoding.Unicode.GetString(reader.ReadBytes(cch * 2))); } }
private long searchTerminationZero(VirtualStreamReader reader) { long strStart = reader.BaseStream.Position; while (reader.ReadInt16() != 0) { ; } long pos = reader.BaseStream.Position; reader.BaseStream.Seek(strStart, System.IO.SeekOrigin.Begin); return(pos); }
public Plex(int structureLength, VirtualStream tableStream, uint fc, uint lcb) { tableStream.Seek((long)fc, System.IO.SeekOrigin.Begin); var reader = new VirtualStreamReader(tableStream); int n = 0; if (structureLength > 0) { //this PLEX contains CPs and Elements n = ((int)lcb - CP_LENGTH) / (structureLength + CP_LENGTH); } else { //this PLEX only contains CPs n = ((int)lcb - CP_LENGTH) / CP_LENGTH; } //read the n + 1 CPs this.CharacterPositions = new List <int>(); for (int i = 0; i < n + 1; i++) { this.CharacterPositions.Add(reader.ReadInt32()); } //read the n structs this.Elements = new List <T>(); var genericType = typeof(T); if (genericType == typeof(short)) { this.Elements = new List <T>(); for (int i = 0; i < n; i++) { short value = reader.ReadInt16(); var genericValue = (T)Convert.ChangeType(value, typeof(T)); this.Elements.Add(genericValue); } } else if (structureLength > 0) { for (int i = 0; i < n; i++) { var constructor = genericType.GetConstructor(new Type[] { typeof(VirtualStreamReader), typeof(int) }); object value = constructor.Invoke(new object[] { reader, structureLength }); var genericValue = (T)Convert.ChangeType(value, typeof(T)); this.Elements.Add(genericValue); } } }
public ToolbarCustomization(VirtualStreamReader reader) : base(reader, ByteStructure.VARIABLE_LENGTH) { this.tbidForTBD = reader.ReadInt32(); reader.ReadBytes(2); this.ctbds = reader.ReadInt16(); //read the cutomization data if (this.tbidForTBD == 0) { this.customToolbar = new CustomToolbar(reader); } else { this.customToolbarDeltas = new List <ToolbarDelta>(); for (int i = 0; i < this.ctbds; i++) { this.customToolbarDeltas.Add(new ToolbarDelta(reader)); } } }
public BookmarkFirst(VirtualStreamReader reader, int length) : base(reader, length) { this.ibkl = reader.ReadInt16(); this.bkc = reader.ReadInt16(); }
private void parse(VirtualStream stream, Int32 fc) { stream.Seek(fc, System.IO.SeekOrigin.Begin); VirtualStreamReader reader = new VirtualStreamReader(stream); Int32 lcb = reader.ReadInt32(); if (lcb > 0) { UInt16 cbHeader = reader.ReadUInt16(); this.mfp = new MetafilePicture(); this.mfp.mm = reader.ReadInt16(); this.mfp.xExt = reader.ReadInt16(); this.mfp.yExt = reader.ReadInt16(); this.mfp.hMf = reader.ReadInt16(); if (this.mfp.mm > 98) { this.rcWinMf = reader.ReadBytes(14); //dimensions this.dxaGoal = reader.ReadInt16(); this.dyaGoal = reader.ReadInt16(); this.mx = reader.ReadUInt16(); this.my = reader.ReadUInt16(); //cropping this.dxaCropLeft = reader.ReadInt16(); this.dyaCropTop = reader.ReadInt16(); this.dxaCropRight = reader.ReadInt16(); this.dyaCropBottom = reader.ReadInt16(); Int16 brcl = reader.ReadInt16(); //borders this.brcTop = new BorderCode(reader.ReadBytes(4)); this.brcLeft = new BorderCode(reader.ReadBytes(4)); this.brcBottom = new BorderCode(reader.ReadBytes(4)); this.brcRight = new BorderCode(reader.ReadBytes(4)); this.dxaOrigin = reader.ReadInt16(); this.dyaOrigin = reader.ReadInt16(); this.cProps = reader.ReadInt16(); //Parse the OfficeDrawing Stuff Record r = Record.ReadRecord(reader); if (r is ShapeContainer) { this.ShapeContainer = (ShapeContainer)r; long pos = reader.BaseStream.Position; if (pos < (fc + lcb)) { Record rec = Record.ReadRecord(reader); if (rec.GetType() == typeof(BlipStoreEntry)) { this.BlipStoreEntry = (BlipStoreEntry)rec; } } } } } }
void Parse(StructuredStorageReader reader, int fibFC) { this.Storage = reader; this.WordDocumentStream = reader.GetStream("WordDocument"); //parse FIB this.WordDocumentStream.Seek(fibFC, System.IO.SeekOrigin.Begin); this.FIB = new FileInformationBlock(new VirtualStreamReader(this.WordDocumentStream)); //check the file version if ((int)this.FIB.nFib != 0) { if (this.FIB.nFib < FileInformationBlock.FibVersion.Fib1997Beta) { throw new ByteParseException("Could not parse the file because it was created by an unsupported application (Word 95 or older)."); } } else { if (this.FIB.nFibNew < FileInformationBlock.FibVersion.Fib1997Beta) { throw new ByteParseException("Could not parse the file because it was created by an unsupported application (Word 95 or older)."); } } //get the streams this.TableStream = reader.GetStream(this.FIB.fWhichTblStm ? "1Table" : "0Table"); try { this.DataStream = reader.GetStream("Data"); } catch (StreamNotFoundException) { this.DataStream = null; } //Read all needed STTBs this.RevisionAuthorTable = new StringTable(typeof(string), this.TableStream, this.FIB.fcSttbfRMark, this.FIB.lcbSttbfRMark); this.FontTable = new StringTable(typeof(FontFamilyName), this.TableStream, this.FIB.fcSttbfFfn, this.FIB.lcbSttbfFfn); this.BookmarkNames = new StringTable(typeof(string), this.TableStream, this.FIB.fcSttbfBkmk, this.FIB.lcbSttbfBkmk); this.AutoTextNames = new StringTable(typeof(string), this.TableStream, this.FIB.fcSttbfGlsy, this.FIB.lcbSttbfGlsy); //this.ProtectionUsers = new StringTable(typeof(String), this.TableStream, this.FIB.fcSttbProtUser, this.FIB.lcbSttbProtUser); // this.UserVariables = new StwStructure(this.TableStream, this.FIB.fcStwUser, this.FIB.lcbStwUser); //Read all needed PLCFs this.AnnotationsReferencePlex = new Plex <AnnotationReferenceDescriptor>(30, this.TableStream, this.FIB.fcPlcfandRef, this.FIB.lcbPlcfandRef); this.TextboxBreakPlex = new Plex <BreakDescriptor>(6, this.TableStream, this.FIB.fcPlcfTxbxBkd, this.FIB.lcbPlcfTxbxBkd); this.TextboxBreakPlexHeader = new Plex <BreakDescriptor>(6, this.TableStream, this.FIB.fcPlcfTxbxHdrBkd, this.FIB.lcbPlcfTxbxHdrBkd); this.OfficeDrawingPlex = new Plex <FileShapeAddress>(26, this.TableStream, this.FIB.fcPlcSpaMom, this.FIB.lcbPlcSpaMom); this.OfficeDrawingPlexHeader = new Plex <FileShapeAddress>(26, this.TableStream, this.FIB.fcPlcSpaHdr, this.FIB.lcbPlcSpaHdr); this.SectionPlex = new Plex <SectionDescriptor>(12, this.TableStream, this.FIB.fcPlcfSed, this.FIB.lcbPlcfSed); this.BookmarkStartPlex = new Plex <BookmarkFirst>(4, this.TableStream, this.FIB.fcPlcfBkf, this.FIB.lcbPlcfBkf); this.EndnoteReferencePlex = new Plex <short>(2, this.TableStream, this.FIB.fcPlcfendRef, this.FIB.lcbPlcfendRef); this.FootnoteReferencePlex = new Plex <short>(2, this.TableStream, this.FIB.fcPlcffndRef, this.FIB.lcbPlcffndRef); // PLCFs without types this.BookmarkEndPlex = new Plex <Exception>(0, this.TableStream, this.FIB.fcPlcfBkl, this.FIB.lcbPlcfBkl); this.AutoTextPlex = new Plex <Exception>(0, this.TableStream, this.FIB.fcPlcfGlsy, this.FIB.lcbPlcfGlsy); //read the FKPs this.AllPapxFkps = FormattedDiskPagePAPX.GetAllPAPXFKPs(this.FIB, this.WordDocumentStream, this.TableStream, this.DataStream); this.AllChpxFkps = FormattedDiskPageCHPX.GetAllCHPXFKPs(this.FIB, this.WordDocumentStream, this.TableStream); //read custom tables this.DocumentProperties = new DocumentProperties(this.FIB, this.TableStream); this.Styles = new StyleSheet(this.FIB, this.TableStream, this.DataStream); this.ListTable = new ListTable(this.FIB, this.TableStream); this.ListFormatOverrideTable = new ListFormatOverrideTable(this.FIB, this.TableStream); this.OfficeArtContent = new OfficeArtContent(this.FIB, this.TableStream); this.HeaderAndFooterTable = new HeaderAndFooterTable(this); this.AnnotationReferenceExtraTable = new AnnotationReferenceExtraTable(this.FIB, this.TableStream); this.CommandTable = new CommandTable(this.FIB, this.TableStream); this.AnnotationOwners = new AnnotationOwnerList(this.FIB, this.TableStream); //parse the piece table and construct a list that contains all chars this.PieceTable = new PieceTable(this.FIB, this.TableStream); this.Text = this.PieceTable.GetAllChars(this.WordDocumentStream); //build a dictionaries of all PAPX this.AllPapx = new Dictionary <int, ParagraphPropertyExceptions>(); for (int i = 0; i < this.AllPapxFkps.Count; i++) { for (int j = 0; j < this.AllPapxFkps[i].grppapx.Length; j++) { this.AllPapx.Add(this.AllPapxFkps[i].rgfc[j], this.AllPapxFkps[i].grppapx[j]); } } //build a dictionary of all SEPX this.AllSepx = new Dictionary <int, SectionPropertyExceptions>(); for (int i = 0; i < this.SectionPlex.Elements.Count; i++) { //Read the SED var sed = (SectionDescriptor)this.SectionPlex.Elements[i]; int cp = this.SectionPlex.CharacterPositions[i + 1]; //Get the SEPX var wordReader = new VirtualStreamReader(this.WordDocumentStream); this.WordDocumentStream.Seek(sed.fcSepx, System.IO.SeekOrigin.Begin); short cbSepx = wordReader.ReadInt16(); var sepx = new SectionPropertyExceptions(wordReader.ReadBytes(cbSepx - 2)); this.AllSepx.Add(cp, sepx); } //read the Glossary if (this.FIB.pnNext > 0) { this.Glossary = new WordDocument(this.Storage, (int)(this.FIB.pnNext * 512)); } }
//***************************************************************************************** // CONSTRUCTOR //***************************************************************************************** public FileInformationBlock(VirtualStreamReader reader) { UInt16 flag16 = 0; byte flag8 = 0; //read the FIB base this.wIdent = reader.ReadUInt16(); this.nFib = (FibVersion)reader.ReadUInt16(); reader.ReadBytes(2); this.lid = reader.ReadUInt16(); this.pnNext = reader.ReadInt16(); flag16 = reader.ReadUInt16(); this.fDot = Utils.BitmaskToBool((int)flag16, 0x0001); this.fGlsy = Utils.BitmaskToBool((int)flag16, 0x0002); this.fComplex = Utils.BitmaskToBool((int)flag16, 0x0002); this.fHasPic = Utils.BitmaskToBool((int)flag16, 0x0008); this.cQuickSaves = (UInt16)(((int)flag16 & 0x00F0) >> 4); this.fEncrypted = Utils.BitmaskToBool((int)flag16, 0x0100); this.fWhichTblStm = Utils.BitmaskToBool((int)flag16, 0x0200); this.fReadOnlyRecommended = Utils.BitmaskToBool((int)flag16, 0x0400); this.fWriteReservation = Utils.BitmaskToBool((int)flag16, 0x0800); this.fExtChar = Utils.BitmaskToBool((int)flag16, 0x1000); this.fLoadOverwrite = Utils.BitmaskToBool((int)flag16, 0x2000); this.fFarEast = Utils.BitmaskToBool((int)flag16, 0x4000); this.fCrypto = Utils.BitmaskToBool((int)flag16, 0x8000); this.nFibBack = reader.ReadUInt16(); this.lKey = reader.ReadInt32(); this.envr = reader.ReadByte(); flag8 = reader.ReadByte(); this.fMac = Utils.BitmaskToBool((int)flag8, 0x01); this.fEmptySpecial = Utils.BitmaskToBool((int)flag8, 0x02); this.fLoadOverridePage = Utils.BitmaskToBool((int)flag8, 0x04); this.fFutureSavedUndo = Utils.BitmaskToBool((int)flag8, 0x08); this.fWord97Saved = Utils.BitmaskToBool((int)flag8, 0x10); reader.ReadBytes(4); this.fcMin = reader.ReadInt32(); this.fcMac = reader.ReadInt32(); this.csw = reader.ReadUInt16(); //read the RgW97 reader.ReadBytes(26); this.lidFE = reader.ReadInt16(); this.cslw = reader.ReadUInt16(); //read the RgLW97 this.cbMac = reader.ReadInt32(); reader.ReadBytes(8); this.ccpText = reader.ReadInt32(); this.ccpFtn = reader.ReadInt32(); this.ccpHdr = reader.ReadInt32(); reader.ReadBytes(4); this.ccpAtn = reader.ReadInt32(); this.ccpEdn = reader.ReadInt32(); this.ccpTxbx = reader.ReadInt32(); this.ccpHdrTxbx = reader.ReadInt32(); reader.ReadBytes(44); this.cbRgFcLcb = reader.ReadUInt16(); if (this.nFib >= FibVersion.Fib1997Beta) { //Read the FibRgFcLcb97 this.fcStshfOrig = reader.ReadUInt32(); this.lcbStshfOrig = reader.ReadUInt32(); this.fcStshf = reader.ReadUInt32(); this.lcbStshf = reader.ReadUInt32(); this.fcPlcffndRef = reader.ReadUInt32(); this.lcbPlcffndRef = reader.ReadUInt32(); this.fcPlcffndTxt = reader.ReadUInt32(); this.lcbPlcffndTxt = reader.ReadUInt32(); this.fcPlcfandRef = reader.ReadUInt32(); this.lcbPlcfandRef = reader.ReadUInt32(); this.fcPlcfandTxt = reader.ReadUInt32(); this.lcbPlcfandTxt = reader.ReadUInt32(); this.fcPlcfSed = reader.ReadUInt32(); this.lcbPlcfSed = reader.ReadUInt32(); this.fcPlcPad = reader.ReadUInt32(); this.lcbPlcPad = reader.ReadUInt32(); this.fcPlcfPhe = reader.ReadUInt32(); this.lcbPlcfPhe = reader.ReadUInt32(); this.fcSttbfGlsy = reader.ReadUInt32(); this.lcbSttbfGlsy = reader.ReadUInt32(); this.fcPlcfGlsy = reader.ReadUInt32(); this.lcbPlcfGlsy = reader.ReadUInt32(); this.fcPlcfHdd = reader.ReadUInt32(); this.lcbPlcfHdd = reader.ReadUInt32(); this.fcPlcfBteChpx = reader.ReadUInt32(); this.lcbPlcfBteChpx = reader.ReadUInt32(); this.fcPlcfBtePapx = reader.ReadUInt32(); this.lcbPlcfBtePapx = reader.ReadUInt32(); this.fcPlcfSea = reader.ReadUInt32(); this.lcbPlcfSea = reader.ReadUInt32(); this.fcSttbfFfn = reader.ReadUInt32(); this.lcbSttbfFfn = reader.ReadUInt32(); this.fcPlcfFldMom = reader.ReadUInt32(); this.lcbPlcfFldMom = reader.ReadUInt32(); this.fcPlcfFldHdr = reader.ReadUInt32(); this.lcbPlcfFldHdr = reader.ReadUInt32(); this.fcPlcfFldFtn = reader.ReadUInt32(); this.lcbPlcfFldFtn = reader.ReadUInt32(); this.fcPlcfFldAtn = reader.ReadUInt32(); this.lcbPlcfFldAtn = reader.ReadUInt32(); this.fcPlcfFldMcr = reader.ReadUInt32(); this.lcbPlcfFldMcr = reader.ReadUInt32(); this.fcSttbfBkmk = reader.ReadUInt32(); this.lcbSttbfBkmk = reader.ReadUInt32(); this.fcPlcfBkf = reader.ReadUInt32(); this.lcbPlcfBkf = reader.ReadUInt32(); this.fcPlcfBkl = reader.ReadUInt32(); this.lcbPlcfBkl = reader.ReadUInt32(); this.fcCmds = reader.ReadUInt32(); this.lcbCmds = reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); this.fcSttbfMcr = reader.ReadUInt32(); this.lcbSttbfMcr = reader.ReadUInt32(); this.fcPrDrvr = reader.ReadUInt32(); this.lcbPrDrvr = reader.ReadUInt32(); this.fcPrEnvPort = reader.ReadUInt32(); this.lcbPrEnvPort = reader.ReadUInt32(); this.fcPrEnvLand = reader.ReadUInt32(); this.lcbPrEnvLand = reader.ReadUInt32(); this.fcWss = reader.ReadUInt32(); this.lcbWss = reader.ReadUInt32(); this.fcDop = reader.ReadUInt32(); this.lcbDop = reader.ReadUInt32(); this.fcSttbfAssoc = reader.ReadUInt32(); this.lcbSttbfAssoc = reader.ReadUInt32(); this.fcClx = reader.ReadUInt32(); this.lcbClx = reader.ReadUInt32(); this.fcPlcfPgdFtn = reader.ReadUInt32(); this.lcbPlcfPgdFtn = reader.ReadUInt32(); this.fcAutosaveSource = reader.ReadUInt32(); this.lcbAutosaveSource = reader.ReadUInt32(); this.fcGrpXstAtnOwners = reader.ReadUInt32(); this.lcbGrpXstAtnOwners = reader.ReadUInt32(); this.fcSttbfAtnBkmk = reader.ReadUInt32(); this.lcbSttbfAtnBkmk = reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); this.fcPlcSpaMom = reader.ReadUInt32(); this.lcbPlcSpaMom = reader.ReadUInt32(); this.fcPlcSpaHdr = reader.ReadUInt32(); this.lcbPlcSpaHdr = reader.ReadUInt32(); this.fcPlcfAtnBkf = reader.ReadUInt32(); this.lcbPlcfAtnBkf = reader.ReadUInt32(); this.fcPlcfAtnBkl = reader.ReadUInt32(); this.lcbPlcfAtnBkl = reader.ReadUInt32(); this.fcPms = reader.ReadUInt32(); this.lcbPms = reader.ReadUInt32(); this.fcFormFldSttbs = reader.ReadUInt32(); this.lcbFormFldSttbs = reader.ReadUInt32(); this.fcPlcfendRef = reader.ReadUInt32(); this.lcbPlcfendRef = reader.ReadUInt32(); this.fcPlcfendTxt = reader.ReadUInt32(); this.lcbPlcfendTxt = reader.ReadUInt32(); this.fcPlcfFldEdn = reader.ReadUInt32(); this.lcbPlcfFldEdn = reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); this.fcDggInfo = reader.ReadUInt32(); this.lcbDggInfo = reader.ReadUInt32(); this.fcSttbfRMark = reader.ReadUInt32(); this.lcbSttbfRMark = reader.ReadUInt32(); this.fcSttbfCaption = reader.ReadUInt32(); this.lcbSttbfCaption = reader.ReadUInt32(); this.fcSttbfAutoCaption = reader.ReadUInt32(); this.lcbSttbfAutoCaption = reader.ReadUInt32(); this.fcPlcfWkb = reader.ReadUInt32(); this.lcbPlcfWkb = reader.ReadUInt32(); this.fcPlcfSpl = reader.ReadUInt32(); this.lcbPlcfSpl = reader.ReadUInt32(); this.fcPlcftxbxTxt = reader.ReadUInt32(); this.lcbPlcftxbxTxt = reader.ReadUInt32(); this.fcPlcfFldTxbx = reader.ReadUInt32(); this.lcbPlcfFldTxbx = reader.ReadUInt32(); this.fcPlcfHdrtxbxTxt = reader.ReadUInt32(); this.lcbPlcfHdrtxbxTxt = reader.ReadUInt32(); this.fcPlcffldHdrTxbx = reader.ReadUInt32(); this.lcbPlcffldHdrTxbx = reader.ReadUInt32(); this.fcStwUser = reader.ReadUInt32(); this.lcbStwUser = reader.ReadUInt32(); this.fcSttbTtmbd = reader.ReadUInt32(); this.lcbSttbTtmbd = reader.ReadUInt32(); this.fcCookieData = reader.ReadUInt32(); this.lcbCookieData = reader.ReadUInt32(); this.fcPgdMotherOldOld = reader.ReadUInt32(); this.lcbPgdMotherOldOld = reader.ReadUInt32(); this.fcBkdMotherOldOld = reader.ReadUInt32(); this.lcbBkdMotherOldOld = reader.ReadUInt32(); this.fcPgdFtnOldOld = reader.ReadUInt32(); this.lcbPgdFtnOldOld = reader.ReadUInt32(); this.fcBkdFtnOldOld = reader.ReadUInt32(); this.lcbBkdFtnOldOld = reader.ReadUInt32(); this.fcPgdEdnOldOld = reader.ReadUInt32(); this.lcbPgdEdnOldOld = reader.ReadUInt32(); this.fcBkdEdnOldOld = reader.ReadUInt32(); this.lcbBkdEdnOldOld = reader.ReadUInt32(); this.fcSttbfIntlFld = reader.ReadUInt32(); this.lcbSttbfIntlFld = reader.ReadUInt32(); this.fcRouteSlip = reader.ReadUInt32(); this.lcbRouteSlip = reader.ReadUInt32(); this.fcSttbSavedBy = reader.ReadUInt32(); this.lcbSttbSavedBy = reader.ReadUInt32(); this.fcSttbFnm = reader.ReadUInt32(); this.lcbSttbFnm = reader.ReadUInt32(); this.fcPlfLst = reader.ReadUInt32(); this.lcbPlfLst = reader.ReadUInt32(); this.fcPlfLfo = reader.ReadUInt32(); this.lcbPlfLfo = reader.ReadUInt32(); this.fcPlcfTxbxBkd = reader.ReadUInt32(); this.lcbPlcfTxbxBkd = reader.ReadUInt32(); this.fcPlcfTxbxHdrBkd = reader.ReadUInt32(); this.lcbPlcfTxbxHdrBkd = reader.ReadUInt32(); this.fcDocUndoWord9 = reader.ReadUInt32(); this.lcbDocUndoWord9 = reader.ReadUInt32(); this.fcRgbUse = reader.ReadUInt32(); this.lcbRgbUse = reader.ReadUInt32(); this.fcUsp = reader.ReadUInt32(); this.lcbUsp = reader.ReadUInt32(); this.fcUskf = reader.ReadUInt32(); this.lcbUskf = reader.ReadUInt32(); this.fcPlcupcRgbUse = reader.ReadUInt32(); this.lcbPlcupcRgbUse = reader.ReadUInt32(); this.fcPlcupcUsp = reader.ReadUInt32(); this.lcbPlcupcUsp = reader.ReadUInt32(); this.fcSttbGlsyStyle = reader.ReadUInt32(); this.lcbSttbGlsyStyle = reader.ReadUInt32(); this.fcPlgosl = reader.ReadUInt32(); this.lcbPlgosl = reader.ReadUInt32(); this.fcPlcocx = reader.ReadUInt32(); this.lcbPlcocx = reader.ReadUInt32(); this.fcPlcfBteLvc = reader.ReadUInt32(); this.lcbPlcfBteLvc = reader.ReadUInt32(); this.dwLowDateTime = reader.ReadUInt32(); this.dwHighDateTime = reader.ReadUInt32(); this.fcPlcfLvcPre10 = reader.ReadUInt32(); this.lcbPlcfLvcPre10 = reader.ReadUInt32(); this.fcPlcfAsumy = reader.ReadUInt32(); this.lcbPlcfAsumy = reader.ReadUInt32(); this.fcPlcfGram = reader.ReadUInt32(); this.lcbPlcfGram = reader.ReadUInt32(); this.fcSttbListNames = reader.ReadUInt32(); this.lcbSttbListNames = reader.ReadUInt32(); this.fcSttbfUssr = reader.ReadUInt32(); this.lcbSttbfUssr = reader.ReadUInt32(); } if (this.nFib >= FibVersion.Fib2000) { //Read also the FibRgFcLcb2000 this.fcPlcfTch = reader.ReadUInt32(); this.lcbPlcfTch = reader.ReadUInt32(); this.fcRmdThreading = reader.ReadUInt32(); this.lcbRmdThreading = reader.ReadUInt32(); this.fcMid = reader.ReadUInt32(); this.lcbMid = reader.ReadUInt32(); this.fcSttbRgtplc = reader.ReadUInt32(); this.lcbSttbRgtplc = reader.ReadUInt32(); this.fcMsoEnvelope = reader.ReadUInt32(); this.lcbMsoEnvelope = reader.ReadUInt32(); this.fcPlcfLad = reader.ReadUInt32(); this.lcbPlcfLad = reader.ReadUInt32(); this.fcRgDofr = reader.ReadUInt32(); this.lcbRgDofr = reader.ReadUInt32(); this.fcPlcosl = reader.ReadUInt32(); this.lcbPlcosl = reader.ReadUInt32(); this.fcPlcfCookieOld = reader.ReadUInt32(); this.lcbPlcfCookieOld = reader.ReadUInt32(); this.fcPgdMotherOld = reader.ReadUInt32(); this.lcbPgdMotherOld = reader.ReadUInt32(); this.fcBkdMotherOld = reader.ReadUInt32(); this.lcbBkdMotherOld = reader.ReadUInt32(); this.fcPgdFtnOld = reader.ReadUInt32(); this.lcbPgdFtnOld = reader.ReadUInt32(); this.fcBkdFtnOld = reader.ReadUInt32(); this.lcbBkdFtnOld = reader.ReadUInt32(); this.fcPgdEdnOld = reader.ReadUInt32(); this.lcbPgdEdnOld = reader.ReadUInt32(); this.fcBkdEdnOld = reader.ReadUInt32(); this.lcbBkdEdnOld = reader.ReadUInt32(); } if (this.nFib >= FibVersion.Fib2002) { //Read also the fibRgFcLcb2002 reader.ReadUInt32(); reader.ReadUInt32(); this.fcPlcfPgp = reader.ReadUInt32(); this.lcbPlcfPgp = reader.ReadUInt32(); this.fcPlcfuim = reader.ReadUInt32(); this.lcbPlcfuim = reader.ReadUInt32(); this.fcPlfguidUim = reader.ReadUInt32(); this.lcbPlfguidUim = reader.ReadUInt32(); this.fcAtrdExtra = reader.ReadUInt32(); this.lcbAtrdExtra = reader.ReadUInt32(); this.fcPlrsid = reader.ReadUInt32(); this.lcbPlrsid = reader.ReadUInt32(); this.fcSttbfBkmkFactoid = reader.ReadUInt32(); this.lcbSttbfBkmkFactoid = reader.ReadUInt32(); this.fcPlcfBkfFactoid = reader.ReadUInt32(); this.lcbPlcfBkfFactoid = reader.ReadUInt32(); this.fcPlcfcookie = reader.ReadUInt32(); this.lcbPlcfcookie = reader.ReadUInt32(); this.fcPlcfBklFactoid = reader.ReadUInt32(); this.lcbPlcfBklFactoid = reader.ReadUInt32(); this.fcFactoidData = reader.ReadUInt32(); this.lcbFactoidData = reader.ReadUInt32(); this.fcDocUndo = reader.ReadUInt32(); this.lcbDocUndo = reader.ReadUInt32(); this.fcSttbfBkmkFcc = reader.ReadUInt32(); this.lcbSttbfBkmkFcc = reader.ReadUInt32(); this.fcPlcfBkfFcc = reader.ReadUInt32(); this.lcbPlcfBkfFcc = reader.ReadUInt32(); this.fcPlcfBklFcc = reader.ReadUInt32(); this.lcbPlcfBklFcc = reader.ReadUInt32(); this.fcSttbfbkmkBPRepairs = reader.ReadUInt32(); this.lcbSttbfbkmkBPRepairs = reader.ReadUInt32(); this.fcPlcfbkfBPRepairs = reader.ReadUInt32(); this.lcbPlcfbkfBPRepairs = reader.ReadUInt32(); this.fcPlcfbklBPRepairs = reader.ReadUInt32(); this.lcbPlcfbklBPRepairs = reader.ReadUInt32(); this.fcPmsNew = reader.ReadUInt32(); this.lcbPmsNew = reader.ReadUInt32(); this.fcODSO = reader.ReadUInt32(); this.lcbODSO = reader.ReadUInt32(); this.fcPlcfpmiOldXP = reader.ReadUInt32(); this.lcbPlcfpmiOldXP = reader.ReadUInt32(); this.fcPlcfpmiNewXP = reader.ReadUInt32(); this.lcbPlcfpmiNewXP = reader.ReadUInt32(); this.fcPlcfpmiMixedXP = reader.ReadUInt32(); this.lcbPlcfpmiMixedXP = reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); this.fcPlcffactoid = reader.ReadUInt32(); this.lcbPlcffactoid = reader.ReadUInt32(); this.fcPlcflvcOldXP = reader.ReadUInt32(); this.lcbPlcflvcOldXP = reader.ReadUInt32(); this.fcPlcflvcNewXP = reader.ReadUInt32(); this.lcbPlcflvcNewXP = reader.ReadUInt32(); this.fcPlcflvcMixedXP = reader.ReadUInt32(); this.lcbPlcflvcMixedXP = reader.ReadUInt32(); } if (this.nFib >= FibVersion.Fib2003) { //Read also the fibRgFcLcb2003 this.fcHplxsdr = reader.ReadUInt32(); this.lcbHplxsdr = reader.ReadUInt32(); this.fcSttbfBkmkSdt = reader.ReadUInt32(); this.lcbSttbfBkmkSdt = reader.ReadUInt32(); this.fcPlcfBkfSdt = reader.ReadUInt32(); this.lcbPlcfBkfSdt = reader.ReadUInt32(); this.fcPlcfBklSdt = reader.ReadUInt32(); this.lcbPlcfBklSdt = reader.ReadUInt32(); this.fcCustomXForm = reader.ReadUInt32(); this.lcbCustomXForm = reader.ReadUInt32(); this.fcSttbfBkmkProt = reader.ReadUInt32(); this.lcbSttbfBkmkProt = reader.ReadUInt32(); this.fcPlcfBkfProt = reader.ReadUInt32(); this.lcbPlcfBkfProt = reader.ReadUInt32(); this.fcPlcfBklProt = reader.ReadUInt32(); this.lcbPlcfBklProt = reader.ReadUInt32(); this.fcSttbProtUser = reader.ReadUInt32(); this.lcbSttbProtUser = reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); this.fcPlcfpmiOld = reader.ReadUInt32(); this.lcbPlcfpmiOld = reader.ReadUInt32(); this.fcPlcfpmiOldInline = reader.ReadUInt32(); this.lcbPlcfpmiOldInline = reader.ReadUInt32(); this.fcPlcfpmiNew = reader.ReadUInt32(); this.lcbPlcfpmiNew = reader.ReadUInt32(); this.fcPlcfpmiNewInline = reader.ReadUInt32(); this.lcbPlcfpmiNewInline = reader.ReadUInt32(); this.fcPlcflvcOld = reader.ReadUInt32(); this.lcbPlcflvcOld = reader.ReadUInt32(); this.fcPlcflvcOldInline = reader.ReadUInt32(); this.lcbPlcflvcOldInline = reader.ReadUInt32(); this.fcPlcflvcNew = reader.ReadUInt32(); this.lcbPlcflvcNew = reader.ReadUInt32(); this.fcPlcflvcNewInline = reader.ReadUInt32(); this.lcbPlcflvcNewInline = reader.ReadUInt32(); this.fcPgdMother = reader.ReadUInt32(); this.lcbPgdMother = reader.ReadUInt32(); this.fcBkdMother = reader.ReadUInt32(); this.lcbBkdMother = reader.ReadUInt32(); this.fcAfdMother = reader.ReadUInt32(); this.lcbAfdMother = reader.ReadUInt32(); this.fcPgdFtn = reader.ReadUInt32(); this.lcbPgdFtn = reader.ReadUInt32(); this.fcBkdFtn = reader.ReadUInt32(); this.lcbBkdFtn = reader.ReadUInt32(); this.fcAfdFtn = reader.ReadUInt32(); this.lcbAfdFtn = reader.ReadUInt32(); this.fcPgdEdn = reader.ReadUInt32(); this.lcbPgdEdn = reader.ReadUInt32(); this.fcBkdEdn = reader.ReadUInt32(); this.lcbBkdEdn = reader.ReadUInt32(); this.fcAfdEdn = reader.ReadUInt32(); this.lcbAfdEdn = reader.ReadUInt32(); this.fcAfd = reader.ReadUInt32(); this.lcbAfd = reader.ReadUInt32(); } if (this.nFib >= FibVersion.Fib2007) { //Read also the fibRgFcLcb2007 this.fcPlcfmthd = reader.ReadUInt32(); this.lcbPlcfmthd = reader.ReadUInt32(); this.fcSttbfBkmkMoveFrom = reader.ReadUInt32(); this.lcbSttbfBkmkMoveFrom = reader.ReadUInt32(); this.fcPlcfBkfMoveFrom = reader.ReadUInt32(); this.lcbPlcfBkfMoveFrom = reader.ReadUInt32(); this.fcPlcfBklMoveFrom = reader.ReadUInt32(); this.lcbPlcfBklMoveFrom = reader.ReadUInt32(); this.fcSttbfBkmkMoveTo = reader.ReadUInt32(); this.lcbSttbfBkmkMoveTo = reader.ReadUInt32(); this.fcPlcfBkfMoveTo = reader.ReadUInt32(); this.lcbPlcfBkfMoveTo = reader.ReadUInt32(); this.fcPlcfBklMoveTo = reader.ReadUInt32(); this.lcbPlcfBklMoveTo = reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); this.fcSttbfBkmkArto = reader.ReadUInt32(); this.lcbSttbfBkmkArto = reader.ReadUInt32(); this.fcPlcfBkfArto = reader.ReadUInt32(); this.lcbPlcfBkfArto = reader.ReadUInt32(); this.fcPlcfBklArto = reader.ReadUInt32(); this.lcbPlcfBklArto = reader.ReadUInt32(); this.fcArtoData = reader.ReadUInt32(); this.lcbArtoData = reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); this.fcOssTheme = reader.ReadUInt32(); this.lcbOssTheme = reader.ReadUInt32(); this.fcColorSchemeMapping = reader.ReadUInt32(); this.lcbColorSchemeMapping = reader.ReadUInt32(); } this.cswNew = reader.ReadUInt16(); if (this.cswNew != 0) { //Read the FibRgCswNew this.nFibNew = (FibVersion)reader.ReadUInt16(); this.cQuickSavesNew = reader.ReadUInt16(); } }
public ToolbarControl(VirtualStreamReader reader) : base(reader, ByteStructure.VARIABLE_LENGTH) { //HEADER START this.bSignature = reader.ReadByte(); this.bVersion = reader.ReadByte(); int bFlagsTCR = (int)reader.ReadByte(); this.fHidden = Utils.BitmaskToBool(bFlagsTCR, 0x01); this.fBeginGroup = Utils.BitmaskToBool(bFlagsTCR, 0x02); this.fOwnLine = Utils.BitmaskToBool(bFlagsTCR, 0x04); this.fNoCustomize = Utils.BitmaskToBool(bFlagsTCR, 0x08); this.fSaveDxy = Utils.BitmaskToBool(bFlagsTCR, 0x10); this.fBeginLine = Utils.BitmaskToBool(bFlagsTCR, 0x40); this.tct = (ToolbarControlType)reader.ReadByte(); this.tcid = reader.ReadInt16(); this.tbct = reader.ReadInt32(); this.bPriority = reader.ReadByte(); if (this.fSaveDxy) { this.width = reader.ReadUInt16(); this.height = reader.ReadUInt16(); } //HEADER END //cid if (this.tcid != 0x01 && this.tcid != 0x1051) { this.cid = reader.ReadBytes(4); } //DATA START if (this.tct != ToolbarControlType.ActiveX) { //general control info byte flags = reader.ReadByte(); this.fSaveText = Utils.BitmaskToBool((int)flags, 0x01); this.fSaveMiscUIStrings = Utils.BitmaskToBool((int)flags, 0x02); this.fSaveMiscCustom = Utils.BitmaskToBool((int)flags, 0x04); this.fDisabled = Utils.BitmaskToBool((int)flags, 0x04); if (this.fSaveText) { this.customText = Utils.ReadWString(reader.BaseStream); } if (this.fSaveMiscUIStrings) { this.descriptionText = Utils.ReadWString(reader.BaseStream); this.tooltip = Utils.ReadWString(reader.BaseStream); } if (this.fSaveMiscCustom) { this.helpFile = Utils.ReadWString(reader.BaseStream); this.idHelpContext = reader.ReadInt32(); this.tag = Utils.ReadWString(reader.BaseStream); this.onAction = Utils.ReadWString(reader.BaseStream); this.param = Utils.ReadWString(reader.BaseStream); this.tbcu = reader.ReadByte(); this.tbmg = reader.ReadByte(); } //control specific info switch (this.tct) { case ToolbarControlType.Button: case ToolbarControlType.ExpandingGrid: //TBCB Specific int bFlags = (int)reader.ReadByte(); int state = Utils.BitmaskToInt(bFlags, 0x03); bool fAccelerator = Utils.BitmaskToBool(bFlags, 0x04); bool fCustomBitmap = Utils.BitmaskToBool(bFlags, 0x08); bool fCustomBtnFace = Utils.BitmaskToBool(bFlags, 0x10); bool fHyperlinkType = Utils.BitmaskToBool(bFlags, 0x20); if (fCustomBitmap) { ToolbarControlBitmap icon = new ToolbarControlBitmap(reader); ToolbarControlBitmap iconMask = new ToolbarControlBitmap(reader); } if (fCustomBtnFace) { UInt16 iBtnFace = reader.ReadUInt16(); } if (fAccelerator) { string wstrAcc = Utils.ReadWString(reader.BaseStream); } break; case ToolbarControlType.Popup: case ToolbarControlType.ButtonPopup: case ToolbarControlType.SplitButtonPopup: case ToolbarControlType.SplitButtonMRUPopup: //TBC Menu Specific Int32 tbid = reader.ReadInt32(); string name = Utils.ReadWString(reader.BaseStream); break; case ToolbarControlType.Edit: case ToolbarControlType.ComboBox: case ToolbarControlType.GraphicCombo: case ToolbarControlType.Dropdown: case ToolbarControlType.SplitDropDown: case ToolbarControlType.OCXDropDown: case ToolbarControlType.GraphicDropDown: //TBC Combo Dropdown Specific if (this.tcid == 1) { Int16 cwstrItems = reader.ReadInt16(); string wstrList = Utils.ReadWString(reader.BaseStream); Int16 cwstrMRU = reader.ReadInt16(); Int16 iSel = reader.ReadInt16(); Int16 cLines = reader.ReadInt16(); Int16 dxWidth = reader.ReadInt16(); string wstrEdit = Utils.ReadWString(reader.BaseStream); } break; default: //no control Specific Info break; } } }
public CommandTable(FileInformationBlock fib, VirtualStream tableStream) { tableStream.Seek(fib.fcCmds, System.IO.SeekOrigin.Begin); VirtualStreamReader reader = new VirtualStreamReader(tableStream); //byte[] bytes = reader.ReadBytes((int)fib.lcbCmds); this.MacroDatas = new List <MacroData>(); this.KeyMapEntries = new List <KeyMapEntry>(); this.MacroNames = new Dictionary <int, string>(); //skip the version reader.ReadByte(); //parse the commandtable while (reader.BaseStream.Position < (fib.fcCmds + fib.lcbCmds) && !breakWhile) { //read the type byte ch = reader.ReadByte(); switch (ch) { case 0x1: //it's a PlfMcd int iMacMcd = reader.ReadInt32(); for (int i = 0; i < iMacMcd; i++) { this.MacroDatas.Add(new MacroData(reader)); } break; case 0x2: //it's a PlfAcd //skip the ACDs int iMacAcd = reader.ReadInt32(); reader.ReadBytes(iMacAcd * 4); break; case 0x3: //Keymap Entries int iMacKme = reader.ReadInt32(); for (int i = 0; i < iMacKme; i++) { this.KeyMapEntries.Add(new KeyMapEntry(reader)); } break; case 0x4: //Keymap Entries int iMacKmeInvalid = reader.ReadInt32(); for (int i = 0; i < iMacKmeInvalid; i++) { this.KeyMapEntries.Add(new KeyMapEntry(reader)); } break; case 0x10: //it's a TcgSttbf this.CommandStringTable = new StringTable(typeof(String), reader); break; case 0x11: //it's a MacroNames table int iMacMn = reader.ReadInt16(); for (int i = 0; i < iMacMn; i++) { Int16 ibst = reader.ReadInt16(); Int16 cch = reader.ReadInt16(); this.MacroNames[ibst] = Encoding.Unicode.GetString(reader.ReadBytes(cch * 2)); //skip the terminating zero reader.ReadBytes(2); } break; case 0x12: //it's a CTBWRAPPER structure this.CustomToolbars = new CustomToolbarWrapper(reader); break; default: breakWhile = true; break; } } }