ParentLocatorEntry.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using Utilities;
  11. namespace DiskAccessLibrary.VHD
  12. {
  13. public class ParentLocatorEntry
  14. {
  15. public const int Length = 24;
  16. public uint PlatformCode;
  17. public uint PlatformDataSpace;
  18. public uint PlatformDataLength;
  19. public uint Reserved;
  20. public ulong PlatformDataOffset;
  21. public ParentLocatorEntry()
  22. {
  23. }
  24. public ParentLocatorEntry(byte[] buffer, int offset)
  25. {
  26. PlatformCode = BigEndianConverter.ToUInt32(buffer, offset + 0);
  27. PlatformDataSpace = BigEndianConverter.ToUInt32(buffer, offset + 4);
  28. PlatformDataLength = BigEndianConverter.ToUInt32(buffer, offset + 8);
  29. Reserved = BigEndianConverter.ToUInt32(buffer, offset + 12);
  30. PlatformDataOffset = BigEndianConverter.ToUInt64(buffer, offset + 16);
  31. }
  32. public void WriteBytes(byte[] buffer, int offset)
  33. {
  34. BigEndianWriter.WriteUInt32(buffer, offset + 0, PlatformCode);
  35. BigEndianWriter.WriteUInt32(buffer, offset + 4, PlatformDataSpace);
  36. BigEndianWriter.WriteUInt32(buffer, offset + 8, PlatformDataLength);
  37. BigEndianWriter.WriteUInt32(buffer, offset + 12, Reserved);
  38. BigEndianWriter.WriteUInt64(buffer, offset + 16, PlatformDataOffset);
  39. }
  40. }
  41. }