예제 #1
0
		public static void CREATE_VMD_FROM_SELECTED_HEXEDITOR(string domain, List<long> allAddresses, int wordSize)
		{
			int allAddrCount = allAddresses.Count;
			if (wordSize > 1) //fills the gap caused by address spacing
				for (int addrPos = 0; addrPos < allAddrCount; addrPos++)
					for (int addedCount = 1; addedCount < wordSize; addedCount++)
					{
						long newAddr = allAddresses[addrPos] + addedCount;
						allAddresses.Add(newAddr);
					}

			var ordered = allAddresses.OrderBy(it => it).ToArray();
			bool contiguous = true;
			long? lastAddress = null;
			int i = 0;

			foreach (long item in ordered)
			{
				if (lastAddress != null) //not the first one
					if (i != (ordered.Length - 1)) //not the last one
						if (item != lastAddress.Value + 1) //checks expected address
							contiguous = false;

				lastAddress = item;
				i++;
			}

			string ToHexString(long n)
			{
				return $"{n:X}";
			}

			string text;
			if (contiguous)
			{
				text = $"{ToHexString(ordered[0])}-{ToHexString(ordered[ordered.Length - 1])}";
			}
			else
			{
				text = String.Join("\n", ordered.Select(it => ToHexString(it)));
			}

			VanguardCore.CreateVmdText(domain, text);

		}