/// <summary> /// Write a string resource to a binary stream. /// </summary> /// <param name="w">Binary stream.</param> internal void Write(BinaryWriter w) { // write the block info long headerPos = w.BaseStream.Position; // wLength w.Write((UInt16)_header.wLength); // wValueLength w.Write((UInt16)_header.wValueLength); // wType w.Write((UInt16)_header.wType); // szKey w.Write(Encoding.Unicode.GetBytes(_key)); // null terminator w.Write((UInt16)0); // pad fixed info ResourceUtil.PadToDWORD(w); long valuePos = w.BaseStream.Position; if (_value != null) { // value (always double-null-terminated) w.Write(Encoding.Unicode.GetBytes(_value)); } // wValueLength ResourceUtil.WriteAt(w, (w.BaseStream.Position - valuePos) / Marshal.SystemDefaultCharSize, headerPos + 2); // wLength ResourceUtil.WriteAt(w, w.BaseStream.Position - headerPos, headerPos); }
/// <summary> /// Write the hardware independent dictionary of language and code page identifier tables to a binary stream. /// </summary> /// <param name="w">Binary stream.</param> internal override void Write(BinaryWriter w) { long headerPos = w.BaseStream.Position; base.Write(w); Dictionary <string, VarTable> .Enumerator varsEnum = _vars.GetEnumerator(); while (varsEnum.MoveNext()) { varsEnum.Current.Value.Write(w); } ResourceUtil.WriteAt(w, w.BaseStream.Position - headerPos, headerPos); }
/// <summary> /// Write the string file-version resource to a binary stream. /// </summary> /// <param name="w">Binary stream.</param> internal override void Write(BinaryWriter w) { long headerPos = w.BaseStream.Position; base.Write(w); Dictionary <string, StringTable> .Enumerator stringsEnum = _strings.GetEnumerator(); while (stringsEnum.MoveNext()) { stringsEnum.Current.Value.Write(w); } ResourceUtil.WriteAt(w, w.BaseStream.Position - headerPos, headerPos); ResourceUtil.PadToDWORD(w); }
/// <summary> /// Write this version resource to a binary stream. /// </summary> /// <param name="w">Binary stream.</param> internal override void Write(BinaryWriter w) { long headerPos = w.BaseStream.Position; _header.Write(w); if (_fixedfileinfo != null) { _fixedfileinfo.Write(w); } Dictionary <string, ResourceTableHeader> .Enumerator resourceEnum = _resources.GetEnumerator(); while (resourceEnum.MoveNext()) { resourceEnum.Current.Value.Write(w); } ResourceUtil.WriteAt(w, w.BaseStream.Position - headerPos, headerPos); }
/// <summary> /// Write the string table to a binary stream. /// </summary> /// <param name="w">Binary stream.</param> /// <returns>Last unpadded position.</returns> internal override void Write(BinaryWriter w) { long headerPos = w.BaseStream.Position; base.Write(w); int total = _strings.Count; Dictionary <string, StringTableEntry> .Enumerator stringsEnum = _strings.GetEnumerator(); while (stringsEnum.MoveNext()) { stringsEnum.Current.Value.Write(w); ResourceUtil.WriteAt(w, w.BaseStream.Position - headerPos, headerPos); // total parent structure size must not include padding if (--total != 0) { ResourceUtil.PadToDWORD(w); } } }
/// <summary> /// Write the table of language and code page identifier pairs to a binary stream. /// </summary> /// <param name="w">Binary stream.</param> /// <returns>Last unpadded position.</returns> internal override void Write(BinaryWriter w) { long headerPos = w.BaseStream.Position; base.Write(w); Dictionary <UInt16, UInt16> .Enumerator languagesEnum = _languages.GetEnumerator(); long valuePos = w.BaseStream.Position; while (languagesEnum.MoveNext()) { // id w.Write((UInt16)languagesEnum.Current.Key); // code page w.Write((UInt16)languagesEnum.Current.Value); } ResourceUtil.WriteAt(w, w.BaseStream.Position - valuePos, headerPos + 2); ResourceUtil.PadToDWORD(w); ResourceUtil.WriteAt(w, w.BaseStream.Position - headerPos, headerPos); }