Esempio n. 1
0
		/// <summary>
		///     Initializes a new instance of the <see cref="ExtractedResourcePointer" /> class.
		/// </summary>
		/// <param name="basePointer">The original location information for the resource.</param>
		public ExtractedResourcePointer(ResourcePointer basePointer)
		{
			OriginalPrimaryPageIndex = (basePointer.PrimaryPage != null) ? basePointer.PrimaryPage.Index : -1;
			PrimaryOffset = basePointer.PrimaryOffset;
			PrimaryUnknown = basePointer.PrimaryUnknown;
			OriginalSecondaryPageIndex = (basePointer.SecondaryPage != null) ? basePointer.SecondaryPage.Index : -1;
			SecondaryOffset = basePointer.SecondaryOffset;
			SecondaryUnknown = basePointer.SecondaryUnknown;
		}
		private StructureValueCollection SerializePointer(ResourcePointer pointer)
		{
			var result = new StructureValueCollection();
			result.SetInteger("primary page index", (pointer.PrimaryPage != null) ? (uint) pointer.PrimaryPage.Index : 0xFFFFFFFF);
			result.SetInteger("primary offset", (uint) pointer.PrimaryOffset);
			result.SetInteger("primary unknown", (uint) pointer.PrimaryUnknown);
			result.SetInteger("secondary page index",
				(pointer.SecondaryPage != null) ? (uint) pointer.SecondaryPage.Index : 0xFFFFFFFF);
			result.SetInteger("secondary offset", (uint) pointer.SecondaryOffset);
			result.SetInteger("secondary unknown", (uint) pointer.SecondaryUnknown);
			return result;
		}
		private ResourcePointer LoadPointer(StructureValueCollection values, IList<ResourcePage> pages)
		{
			var result = new ResourcePointer();
			var primaryPage = (int) values.GetInteger("primary page index");
			result.PrimaryPage = (primaryPage != -1) ? pages[primaryPage] : null;
			result.PrimaryOffset = (int) values.GetInteger("primary offset");
			result.PrimaryUnknown = (int) values.GetInteger("primary unknown");

			var secondaryPage = (int) values.GetInteger("secondary page index");
			result.SecondaryPage = (secondaryPage != -1) ? pages[secondaryPage] : null;
			result.SecondaryOffset = (int) values.GetInteger("secondary offset");
			result.SecondaryUnknown = (int) values.GetInteger("secondary unknown");

			return result;
		}