public void WriteTo(System.IO.BinaryWriter writer) { byte[] padding = new byte[]{}; LinkInfoHeaderSize = Marshal.SizeOf(LinkInfoSize) + Marshal.SizeOf(LinkInfoHeaderSize) + Marshal.SizeOf(typeof(int)) + Marshal.SizeOf(VolumeIDOffset) + Marshal.SizeOf(LocalBasePathOffset) + Marshal.SizeOf(CommonNetworkRelativeLinkOffset) + Marshal.SizeOf(CommonPathSuffixOffset); LinkInfoSize = LinkInfoHeaderSize + Encoding.Default.GetASCIIZSize(Item.CommonPathSuffix); VolumeIDHandler vidWriter = null; CommonNetworkRelativeLinkHandler cnrWriter = null; VolumeIDOffset = 0; LocalBasePathOffset = 0; CommonNetworkRelativeLinkOffset = 0; int nextBlockOffset = LinkInfoHeaderSize; if ((Item.LinkInfoFlags & (LinkInfoFlags.VolumeIDAndLocalBasePath | LinkInfoFlags.CommonNetworkRelativeLinkAndPathSuffix)) == (LinkInfoFlags.VolumeIDAndLocalBasePath | LinkInfoFlags.CommonNetworkRelativeLinkAndPathSuffix)) { padding = new byte[] {0}; LinkInfoSize += padding.Length; } if ((Item.LinkInfoFlags & LinkInfoFlags.VolumeIDAndLocalBasePath) != 0) { vidWriter = new VolumeIDHandler(Item.VolumeID); LinkInfoSize += vidWriter.ComputedSize + Encoding.Default.GetASCIIZSize(Item.LocalBasePath); VolumeIDOffset = nextBlockOffset; LocalBasePathOffset = VolumeIDOffset + vidWriter.ComputedSize; CommonPathSuffixOffset = LocalBasePathOffset + Encoding.Default.GetASCIIZSize(Item.LocalBasePath); nextBlockOffset = CommonPathSuffixOffset + padding.Length; } if ((Item.LinkInfoFlags & LinkInfoFlags.CommonNetworkRelativeLinkAndPathSuffix) != 0) { cnrWriter = new CommonNetworkRelativeLinkHandler(Item.CommonNetworkRelativeLink); LinkInfoSize += cnrWriter.ComputedSize; CommonNetworkRelativeLinkOffset = nextBlockOffset; CommonPathSuffixOffset = CommonNetworkRelativeLinkOffset + cnrWriter.ComputedSize; } writer.Write(LinkInfoSize); writer.Write(LinkInfoHeaderSize); writer.Write((int)Item.LinkInfoFlags); writer.Write(VolumeIDOffset); writer.Write(LocalBasePathOffset); writer.Write(CommonNetworkRelativeLinkOffset); writer.Write(CommonPathSuffixOffset); // TODO: Handle unicode strings and offsets // LocalBasePathOffsetUnicode = // CommonPathSuffixOffsetUnicode = // LinkInfoHeaderSize >= &H24 if (vidWriter != null) { vidWriter.WriteTo(writer); writer.WriteASCIIZ(Item.LocalBasePath, Encoding.Default); } if (padding.Length > 0) { writer.Write(padding); } if (cnrWriter != null) { cnrWriter.WriteTo(writer); } writer.WriteASCIIZ(Item.CommonPathSuffix, Encoding.Default); }
public void WriteTo(System.IO.BinaryWriter writer) { VolumeIDSize = ComputedSize; FormatChecker.CheckExpression(() => VolumeIDSize > MinimumVolumeIDSize); writer.Write(VolumeIDSize); writer.Write((int) Item.DriveType); writer.Write(Item.DriveSerialNumber); VolumeLabelOffset = Marshal.SizeOf(VolumeIDSize) + Marshal.SizeOf(typeof(int)) + Marshal.SizeOf(Item.DriveSerialNumber) + Marshal.SizeOf(VolumeLabelOffset); writer.Write(VolumeLabelOffset); // TODO: Handle unicode strings and offsets // VolumeLabelOffsetUnicode = // VolumeLabelOffset = &H14 writer.WriteASCIIZ(Item.VolumeLabel, Encoding.Default); }
public void WriteTo(System.IO.BinaryWriter writer) { CommonNetworkRelativeLinkSize = ComputedSize; FormatChecker.CheckExpression(() => CommonNetworkRelativeLinkSize >= MinimumCommonNetworkRelativeLinkSize); writer.Write(CommonNetworkRelativeLinkSize); writer.Write((int) Item.CommonNetworkRelativeLinkFlags); NetNameOffset = Marshal.SizeOf(ComputedSize) + Marshal.SizeOf(CommonNetworkRelativeLinkSize) + Marshal.SizeOf(typeof(int)) + Marshal.SizeOf(NetNameOffset) + Marshal.SizeOf(DeviceNameOffset); writer.Write(NetNameOffset); if ((Item.CommonNetworkRelativeLinkFlags & CommonNetworkRelativeLinkFlags.ValidDevice) != 0) { DeviceNameOffset = NetNameOffset + Encoding.Default.GetASCIIZSize(Item.NetName); } else { DeviceNameOffset = 0; } writer.Write(DeviceNameOffset); int nptvalue = 0; if ((Item.CommonNetworkRelativeLinkFlags & CommonNetworkRelativeLinkFlags.ValidNetType) != 0) { nptvalue = (int)Item.NetworkProviderType; } writer.Write(nptvalue); // TODO: Handle unicode strings and offsets // NetNameOffsetUnicode = // DeviceNameOffsetUnicode = // NetNameOffset > &H14 writer.WriteASCIIZ(Item.NetName, Encoding.Default); if (DeviceNameOffset > 0) { writer.WriteASCIIZ(Item.DeviceName, Encoding.Default); } }