diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj
index 381d9d8d9..884520177 100644
--- a/Artemis/Artemis/Artemis.csproj
+++ b/Artemis/Artemis/Artemis.csproj
@@ -255,6 +255,18 @@
..\packages\squirrel.windows.1.4.4\lib\Net45\NuGet.Squirrel.dll
True
+
+ ..\packages\Pcap.Net.x64.1.0.4.1\lib\net45\PcapDotNet.Base.dll
+
+
+ ..\packages\Pcap.Net.x64.1.0.4.1\lib\net45\PcapDotNet.Core.dll
+
+
+ ..\packages\Pcap.Net.x64.1.0.4.1\lib\net45\PcapDotNet.Core.Extensions.dll
+
+
+ ..\packages\Pcap.Net.x64.1.0.4.1\lib\net45\PcapDotNet.Packets.dll
+
..\packages\Process.NET.1.0.8\lib\Process.NET.dll
True
@@ -471,15 +483,6 @@
UnrealTournamentView.xaml
-
-
-
-
-
-
-
-
-
WoWView.xaml
@@ -487,7 +490,6 @@
-
@@ -1098,6 +1100,7 @@
+
diff --git a/Artemis/Artemis/Managers/ModuleManager.cs b/Artemis/Artemis/Managers/ModuleManager.cs
index 59088bd1c..d6e5cf1ec 100644
--- a/Artemis/Artemis/Managers/ModuleManager.cs
+++ b/Artemis/Artemis/Managers/ModuleManager.cs
@@ -24,10 +24,7 @@ namespace Artemis.Managers
Modules = new List(moduleModels.Where(m => !m.IsOverlay && !m.IsBoundToProcess));
OverlayModules = new List(moduleModels.Where(m => m.IsOverlay));
- // Exclude WoW if needed
- ProcessModules = _generalSettings.GamestatePort == 62575
- ? new List(moduleModels.Where(m => m.IsBoundToProcess))
- : new List(moduleModels.Where(m => m.IsBoundToProcess && m.Name != "WoW"));
+ ProcessModules = new List(moduleModels.Where(m => m.IsBoundToProcess));
_logger.Info("Intialized ModuleManager");
}
diff --git a/Artemis/Artemis/Modules/Games/WoW/Data/Int128.cs b/Artemis/Artemis/Modules/Games/WoW/Data/Int128.cs
deleted file mode 100644
index 4a66ecc0f..000000000
--- a/Artemis/Artemis/Modules/Games/WoW/Data/Int128.cs
+++ /dev/null
@@ -1,2256 +0,0 @@
-using System;
-using System.ComponentModel;
-using System.Globalization;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Text;
-using Microsoft.SqlServer.Server;
-
-namespace Artemis.Modules.Games.WoW.Data
-{
- namespace WowSharp.Client.Patchables
- {
- ///
- /// Represents a 128-bit signed integer.
- ///
-#if !WINDOWS_PHONE && !SILVERLIGHT
- [Serializable]
-#endif
- [StructLayout(LayoutKind.Sequential)]
- [TypeConverter(typeof(Int128Converter))]
- public struct Int128 : IComparable, IComparable, IEquatable, IConvertible, IFormattable
-#if !WINDOWS_PHONE && !SILVERLIGHT
- , IBinarySerialize
-#endif
- {
- private ulong _hi;
- private ulong _lo;
-
- private const ulong HiNeg = 0x8000000000000000;
-
- ///
- /// Gets a value that represents the number 0 (zero).
- ///
- public static Int128 Zero = GetZero();
-
- ///
- /// Represents the largest possible value of an Int128.
- ///
- public static Int128 MaxValue = GetMaxValue();
-
- ///
- /// Represents the smallest possible value of an Int128.
- ///
- public static Int128 MinValue = GetMinValue();
-
- private static Int128 GetMaxValue()
- {
- return new Int128(long.MaxValue, ulong.MaxValue);
- }
-
- private static Int128 GetMinValue()
- {
- return new Int128(HiNeg, 0);
- }
-
- private static Int128 GetZero()
- {
- return new Int128();
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The value.
- public Int128(byte value)
- {
- _hi = 0;
- _lo = value;
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// if set to true [value].
- public Int128(bool value)
- {
- _hi = 0;
- _lo = (ulong) (value ? 1 : 0);
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The value.
- public Int128(char value)
- {
- _hi = 0;
- _lo = value;
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The value.
- public Int128(decimal value)
- {
- if (value < 0)
- {
- var n = -new Int128(-value);
- _hi = n._hi;
- _lo = n._lo;
- return;
- }
-
- var bits = decimal.GetBits(value);
- _hi = (uint) bits[2];
- _lo = (uint) bits[0] | ((ulong) bits[1] << 32);
-
- var scale = (bits[3] >> 16) & 31;
- if (scale > 0)
- {
- var i = new Int128(_hi, _lo);
- for (var s = 0; s < scale; s++)
- i = i/10;
- _hi = i._hi;
- _lo = i._lo;
- }
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The value.
- public Int128(double value)
- : this((decimal) value)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The value.
- public Int128(float value)
- : this((decimal) value)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The value.
- public Int128(short value)
- : this((int) value)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The value.
- public Int128(int value)
- : this((long) value)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The value.
- public Int128(long value)
- {
- if (value < 0)
- {
- // long.MinValue = -long.MinValue
- if (value == long.MinValue)
- {
- _hi = HiNeg;
- _lo = HiNeg;
- return;
- }
-
- var n = -new Int128(-value);
- _hi = n._hi;
- _lo = n._lo;
- return;
- }
-
- _hi = 0;
- _lo = (ulong) value;
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The value.
- public Int128(sbyte value)
- : this((long) value)
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The value.
- public Int128(ushort value)
- {
- _hi = 0;
- _lo = value;
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The value.
- public Int128(uint value)
- {
- _hi = 0;
- _lo = value;
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The value.
- public Int128(ulong value)
- {
- _hi = 0;
- _lo = value;
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The value.
- public Int128(Guid value)
- : this(value.ToByteArray())
- {
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The value.
- public Int128(byte[] value)
- {
- if (value == null)
- throw new ArgumentNullException("value");
-
- if (value.Length != 16)
- throw new ArgumentException(null, "value");
-
- _hi = BitConverter.ToUInt64(value, 8);
- _lo = BitConverter.ToUInt64(value, 0);
- }
-
- public Int128(ulong hi, ulong lo)
- {
- _hi = hi;
- _lo = lo;
- }
-
- ///
- /// Initializes a new instance of the struct.
- ///
- /// The sign.
- /// The ints.
- public Int128(int sign, uint[] ints)
- {
- if (ints == null)
- throw new ArgumentNullException("ints");
-
- var lo = new byte[8];
- var hi = new byte[8];
-
- if (ints.Length > 0)
- {
- Array.Copy(BitConverter.GetBytes(ints[0]), 0, lo, 0, 4);
- if (ints.Length > 1)
- {
- Array.Copy(BitConverter.GetBytes(ints[1]), 0, lo, 4, 4);
- if (ints.Length > 2)
- {
- Array.Copy(BitConverter.GetBytes(ints[2]), 0, hi, 0, 4);
- if (ints.Length > 3)
- Array.Copy(BitConverter.GetBytes(ints[3]), 0, hi, 4, 4);
- }
- }
- }
-
- _lo = BitConverter.ToUInt64(lo, 0);
- _hi = BitConverter.ToUInt64(hi, 0);
-
- if (sign < 0)
- _hi |= HiNeg;
- else
- _hi &= ~HiNeg;
- }
-
- ///
- /// Gets a number that indicates the sign (negative, positive, or zero) of the current Int128 object.
- ///
- /// A number that indicates the sign of the Int128 object
- public int Sign
- {
- get
- {
- if ((_hi == 0) && (_lo == 0))
- return 0;
-
- return (_hi & HiNeg) == 0 ? 1 : -1;
- }
- }
-
- ///
- /// Returns a hash code for this instance.
- ///
- ///
- /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
- ///
- public override int GetHashCode()
- {
- return _hi.GetHashCode() ^ _lo.GetHashCode();
- }
-
- ///
- /// Returns a value indicating whether this instance is equal to a specified object.
- ///
- /// An object to compare with this instance.
- ///
- /// true if obj has the same value as this instance; otherwise, false.
- ///
- public override bool Equals(object obj)
- {
- return base.Equals(obj);
- }
-
- ///
- /// Returns a value indicating whether this instance is equal to a specified Int64 value.
- ///
- /// The obj.
- ///
- /// true if obj has the same value as this instance; otherwise, false.
- ///
- public bool Equals(Int128 obj)
- {
- return (_hi == obj._hi) && (_lo == obj._lo);
- }
-
- ///
- /// Returns a that represents this instance.
- ///
- ///
- /// A that represents this instance.
- ///
- public override string ToString()
- {
- return ToString(null, null);
- }
-
- ///
- /// Returns a that represents this instance.
- ///
- /// The format. Only x, X, g, G, d, D are supported.
- ///
- /// A that represents this instance.
- ///
- public string ToString(string format)
- {
- return ToString(format, null);
- }
-
- ///
- /// Returns a that represents this instance.
- ///
- /// The format. Only x, X, g, G, d, D are supported.
- /// An object that supplies culture-specific formatting information about this instance.
- ///
- /// A that represents this instance.
- ///
- public string ToString(string format, IFormatProvider formatProvider)
- {
- if (formatProvider == null)
- formatProvider = CultureInfo.CurrentCulture;
-
- if (!string.IsNullOrEmpty(format))
- {
- var ch = format[0];
- if ((ch == 'x') || (ch == 'X'))
- {
- int min;
- int.TryParse(format.Substring(1).Trim(), out min);
- return ToHexaString(ch == 'X', min);
- }
-
- if ((ch != 'G') && (ch != 'g') && (ch != 'D') && (ch != 'd'))
- throw new NotSupportedException("Not supported format: " + format);
- }
-
- return ToString((NumberFormatInfo) formatProvider.GetFormat(typeof(NumberFormatInfo)));
- }
-
- private string ToHexaString(bool caps, int min)
- {
- var sb = new StringBuilder();
- var x = caps ? "X" : "x";
- if ((min < 0) || (min > 16) || (_hi != 0))
- {
- sb.Append(min > 16 ? _hi.ToString(x + (min - 16)) : _hi.ToString(x));
- sb.Append(_lo.ToString(x + "16"));
- }
- else
- {
- sb.Append(_lo.ToString(x + min));
- }
- return sb.ToString();
- }
-
- private string ToString(NumberFormatInfo info)
- {
- if (Sign == 0)
- return "0";
-
- var sb = new StringBuilder();
- var ten = new Int128(10);
- var current = this;
- current._hi &= ~HiNeg;
- Int128 r;
- while (true)
- {
- current = DivRem(current, ten, out r);
- if ((r._lo > 0) || (current.Sign != 0) || (sb.Length == 0))
- {
-#if !WINDOWS_PHONE && !SILVERLIGHT
- sb.Insert(0, (char) ('0' + r._lo));
-#else
- sb.Insert(0, new[] { (char)('0' + r._lo) });
-#endif
- }
- if (current.Sign == 0)
- break;
- }
-
- var s = sb.ToString();
- if ((Sign < 0) && (s != "0"))
- return info.NegativeSign + s;
-
- return s;
- }
-
- ///
- /// Returns the for this instance.
- ///
- ///
- /// The enumerated constant that is the of the class or value type that implements
- /// this interface.
- ///
- TypeCode IConvertible.GetTypeCode()
- {
- return TypeCode.Object;
- }
-
- ///
- /// Converts the value of this instance to an equivalent Boolean value using the specified culture-specific formatting
- /// information.
- ///
- ///
- /// An interface implementation that supplies
- /// culture-specific formatting information.
- ///
- ///
- /// A Boolean value equivalent to the value of this instance.
- ///
- bool IConvertible.ToBoolean(IFormatProvider provider)
- {
- return (bool) this;
- }
-
- ///
- /// Converts the value of this instance to an equivalent 8-bit unsigned integer using the specified culture-specific
- /// formatting information.
- ///
- ///
- /// An interface implementation that supplies
- /// culture-specific formatting information.
- ///
- ///
- /// An 8-bit unsigned integer equivalent to the value of this instance.
- ///
- byte IConvertible.ToByte(IFormatProvider provider)
- {
- return (byte) this;
- }
-
- ///
- /// Converts the value of this instance to an equivalent Unicode character using the specified culture-specific
- /// formatting information.
- ///
- ///
- /// An interface implementation that supplies
- /// culture-specific formatting information.
- ///
- ///
- /// A Unicode character equivalent to the value of this instance.
- ///
- char IConvertible.ToChar(IFormatProvider provider)
- {
- return (char) this;
- }
-
- ///
- /// Converts the value of this instance to an equivalent using the specified
- /// culture-specific formatting information.
- ///
- ///
- /// An interface implementation that supplies
- /// culture-specific formatting information.
- ///
- ///
- /// A instance equivalent to the value of this instance.
- ///
- DateTime IConvertible.ToDateTime(IFormatProvider provider)
- {
- throw new InvalidCastException();
- }
-
- ///
- /// Converts the value of this instance to an equivalent number using the specified
- /// culture-specific formatting information.
- ///
- ///
- /// An interface implementation that supplies
- /// culture-specific formatting information.
- ///
- ///
- /// A number equivalent to the value of this instance.
- ///
- decimal IConvertible.ToDecimal(IFormatProvider provider)
- {
- return (decimal) this;
- }
-
- ///
- /// Converts the value of this instance to an equivalent double-precision floating-point number using the specified
- /// culture-specific formatting information.
- ///
- ///
- /// An interface implementation that supplies
- /// culture-specific formatting information.
- ///
- ///
- /// A double-precision floating-point number equivalent to the value of this instance.
- ///
- double IConvertible.ToDouble(IFormatProvider provider)
- {
- return (double) this;
- }
-
- ///
- /// Converts the value of this instance to an equivalent 16-bit signed integer using the specified culture-specific
- /// formatting information.
- ///
- ///
- /// An interface implementation that supplies
- /// culture-specific formatting information.
- ///
- ///
- /// An 16-bit signed integer equivalent to the value of this instance.
- ///
- short IConvertible.ToInt16(IFormatProvider provider)
- {
- return (short) this;
- }
-
- ///
- /// Converts the value of this instance to an equivalent 32-bit signed integer using the specified culture-specific
- /// formatting information.
- ///
- ///
- /// An interface implementation that supplies
- /// culture-specific formatting information.
- ///
- ///
- /// An 32-bit signed integer equivalent to the value of this instance.
- ///
- int IConvertible.ToInt32(IFormatProvider provider)
- {
- return (int) this;
- }
-
- ///
- /// Converts the value of this instance to an equivalent 64-bit signed integer using the specified culture-specific
- /// formatting information.
- ///
- ///
- /// An interface implementation that supplies
- /// culture-specific formatting information.
- ///
- ///
- /// An 64-bit signed integer equivalent to the value of this instance.
- ///
- long IConvertible.ToInt64(IFormatProvider provider)
- {
- return (int) this;
- }
-
- ///
- /// Converts the value of this instance to an equivalent 8-bit signed integer using the specified culture-specific
- /// formatting information.
- ///
- ///
- /// An interface implementation that supplies
- /// culture-specific formatting information.
- ///
- ///
- /// An 8-bit signed integer equivalent to the value of this instance.
- ///
- sbyte IConvertible.ToSByte(IFormatProvider provider)
- {
- return (sbyte) this;
- }
-
- ///
- /// Converts the value of this instance to an equivalent single-precision floating-point number using the specified
- /// culture-specific formatting information.
- ///
- ///
- /// An interface implementation that supplies
- /// culture-specific formatting information.
- ///
- ///
- /// A single-precision floating-point number equivalent to the value of this instance.
- ///
- float IConvertible.ToSingle(IFormatProvider provider)
- {
- return (float) this;
- }
-
- ///
- /// Returns a that represents this instance.
- ///
- /// The provider.
- ///
- /// A that represents this instance.
- ///
- string IConvertible.ToString(IFormatProvider provider)
- {
- return ToString(null, provider);
- }
-
- ///
- /// Converts the numeric value to an equivalent object. The return value indicates whether the conversion succeeded.
- ///
- /// The target conversion type.
- /// An object that supplies culture-specific information about the conversion.
- ///
- /// When this method returns, contains the value that is equivalent to the numeric value, if the
- /// conversion succeeded, or is null if the conversion failed. This parameter is passed uninitialized.
- ///
- /// true if this value was converted successfully; otherwise, false.
- public bool TryConvert(Type conversionType, IFormatProvider provider, out object value)
- {
- if (conversionType == typeof(bool))
- {
- value = (bool) this;
- return true;
- }
-
- if (conversionType == typeof(byte))
- {
- value = (byte) this;
- return true;
- }
-
- if (conversionType == typeof(char))
- {
- value = (char) this;
- return true;
- }
-
- if (conversionType == typeof(decimal))
- {
- value = (decimal) this;
- return true;
- }
-
- if (conversionType == typeof(double))
- {
- value = (double) this;
- return true;
- }
-
- if (conversionType == typeof(short))
- {
- value = (short) this;
- return true;
- }
-
- if (conversionType == typeof(int))
- {
- value = (int) this;
- return true;
- }
-
- if (conversionType == typeof(long))
- {
- value = (long) this;
- return true;
- }
-
- if (conversionType == typeof(sbyte))
- {
- value = (sbyte) this;
- return true;
- }
-
- if (conversionType == typeof(float))
- {
- value = (float) this;
- return true;
- }
-
- if (conversionType == typeof(string))
- {
- value = ToString(null, provider);
- return true;
- }
-
- if (conversionType == typeof(ushort))
- {
- value = (ushort) this;
- return true;
- }
-
- if (conversionType == typeof(uint))
- {
- value = (uint) this;
- return true;
- }
-
- if (conversionType == typeof(ulong))
- {
- value = (ulong) this;
- return true;
- }
-
- if (conversionType == typeof(byte[]))
- {
- value = ToByteArray();
- return true;
- }
-
- if (conversionType == typeof(Guid))
- {
- value = new Guid(ToByteArray());
- return true;
- }
-
- value = null;
- return false;
- }
-
- ///
- /// Converts the string representation of a number to its Int128 equivalent.
- ///
- /// A string that contains a number to convert.
- ///
- /// A value that is equivalent to the number specified in the value parameter.
- ///
- public static Int128 Parse(string value)
- {
- return Parse(value, NumberStyles.Integer, NumberFormatInfo.CurrentInfo);
- }
-
- ///
- /// Converts the string representation of a number in a specified style format to its Int128 equivalent.
- ///
- /// A string that contains a number to convert.
- /// A bitwise combination of the enumeration values that specify the permitted format of value.
- ///
- /// A value that is equivalent to the number specified in the value parameter.
- ///
- public static Int128 Parse(string value, NumberStyles style)
- {
- return Parse(value, style, NumberFormatInfo.CurrentInfo);
- }
-
- ///
- /// Converts the string representation of a number in a culture-specific format to its Int128 equivalent.
- ///
- /// A string that contains a number to convert.
- /// An object that provides culture-specific formatting information about value.
- ///
- /// A value that is equivalent to the number specified in the value parameter.
- ///
- public static Int128 Parse(string value, IFormatProvider provider)
- {
- return Parse(value, NumberStyles.Integer, NumberFormatInfo.GetInstance(provider));
- }
-
- ///
- /// Converts the string representation of a number in a specified style and culture-specific format to its Int128
- /// equivalent.
- ///
- /// A string that contains a number to convert.
- /// A bitwise combination of the enumeration values that specify the permitted format of value.
- /// An object that provides culture-specific formatting information about value.
- /// A value that is equivalent to the number specified in the value parameter.
- public static Int128 Parse(string value, NumberStyles style, IFormatProvider provider)
- {
- Int128 result;
- if (!TryParse(value, style, provider, out result))
- throw new ArgumentException(null, "value");
-
- return result;
- }
-
- ///
- /// Tries to convert the string representation of a number to its Int128 equivalent, and returns a value that indicates
- /// whether the conversion succeeded..
- ///
- /// The string representation of a number.
- ///
- /// When this method returns, contains the Int128 equivalent to the number that is contained in value,
- /// or Int128.Zero if the conversion failed. This parameter is passed uninitialized.
- ///
- ///
- /// true if the value parameter was converted successfully; otherwise, false.
- ///
- public static bool TryParse(string value, out Int128 result)
- {
- return TryParse(value, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result);
- }
-
- ///
- /// Tries to convert the string representation of a number in a specified style and culture-specific format to its
- /// Int128 equivalent, and returns a value that indicates whether the conversion succeeded..
- ///
- ///
- /// The string representation of a number. The string is interpreted using the style specified by
- /// style.
- ///
- ///
- /// A bitwise combination of enumeration values that indicates the style elements that can be present
- /// in value. A typical value to specify is NumberStyles.Integer.
- ///
- /// An object that supplies culture-specific formatting information about value.
- ///
- /// When this method returns, contains the Int128 equivalent to the number that is contained in value,
- /// or Int128.Zero if the conversion failed. This parameter is passed uninitialized.
- ///
- /// true if the value parameter was converted successfully; otherwise, false.
- public static bool TryParse(string value, NumberStyles style, IFormatProvider provider, out Int128 result)
- {
- result = Zero;
- if (string.IsNullOrEmpty(value))
- return false;
-
- if (value.StartsWith("x", StringComparison.OrdinalIgnoreCase))
- {
- style |= NumberStyles.AllowHexSpecifier;
- value = value.Substring(1);
- }
- else if (value.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
- {
- style |= NumberStyles.AllowHexSpecifier;
- value = value.Substring(2);
- }
-
- if ((style & NumberStyles.AllowHexSpecifier) == NumberStyles.AllowHexSpecifier)
- return TryParseHex(value, out result);
-
- return TryParseNum(value, out result);
- }
-
- private static bool TryParseHex(string value, out Int128 result)
- {
- if (value.Length > 32)
- throw new OverflowException();
-
- result = Zero;
- var hi = false;
- var pos = 0;
- for (var i = value.Length - 1; i >= 0; i--)
- {
- var ch = value[i];
- ulong b;
- if ((ch >= '0') && (ch <= '9'))
- b = (ulong) (ch - '0');
- else if ((ch >= 'A') && (ch <= 'F'))
- b = (ulong) (ch - 'A' + 10);
- else if ((ch >= 'a') && (ch <= 'f'))
- b = (ulong) (ch - 'a' + 10);
- else
- return false;
-
- if (hi)
- {
- result._hi |= b << pos;
- pos += 4;
- }
- else
- {
- result._lo |= b << pos;
- pos += 4;
- if (pos == 64)
- {
- pos = 0;
- hi = true;
- }
- }
- }
- return true;
- }
-
- private static bool TryParseNum(string value, out Int128 result)
- {
- result = Zero;
- foreach (var ch in value)
- {
- byte b;
- if ((ch >= '0') && (ch <= '9'))
- b = (byte) (ch - '0');
- else
- return false;
-
- result = 10*result;
- result += b;
- }
- return true;
- }
-
- ///
- /// Converts the value of this instance to an of the specified
- /// that has an equivalent value, using the specified culture-specific formatting
- /// information.
- ///
- /// The to which the value of this instance is converted.
- ///
- /// An interface implementation that supplies
- /// culture-specific formatting information.
- ///
- ///
- /// An instance of type whose value is equivalent to
- /// the value of this instance.
- ///
- public object ToType(Type conversionType, IFormatProvider provider)
- {
- object value;
- if (TryConvert(conversionType, provider, out value))
- return value;
-
- throw new InvalidCastException();
- }
-
- ///
- /// Converts the value of this instance to an equivalent 16-bit unsigned integer using the specified culture-specific
- /// formatting information.
- ///
- ///
- /// An interface implementation that supplies
- /// culture-specific formatting information.
- ///
- ///
- /// An 16-bit unsigned integer equivalent to the value of this instance.
- ///
- ushort IConvertible.ToUInt16(IFormatProvider provider)
- {
- if (_hi != 0)
- throw new OverflowException();
-
- return Convert.ToUInt16(_lo);
- }
-
- ///
- /// Converts the value of this instance to an equivalent 32-bit unsigned integer using the specified culture-specific
- /// formatting information.
- ///
- ///
- /// An interface implementation that supplies
- /// culture-specific formatting information.
- ///
- ///
- /// An 32-bit unsigned integer equivalent to the value of this instance.
- ///
- uint IConvertible.ToUInt32(IFormatProvider provider)
- {
- if (_hi != 0)
- throw new OverflowException();
-
- return Convert.ToUInt32(_lo);
- }
-
- ///
- /// Converts the value of this instance to an equivalent 64-bit unsigned integer using the specified culture-specific
- /// formatting information.
- ///
- ///
- /// An interface implementation that supplies
- /// culture-specific formatting information.
- ///
- ///
- /// An 64-bit unsigned integer equivalent to the value of this instance.
- ///
- ulong IConvertible.ToUInt64(IFormatProvider provider)
- {
- if (_hi != 0)
- throw new OverflowException();
-
- return _lo;
- }
-
- ///
- /// Compares the current instance with another object of the same type and returns an integer that indicates whether
- /// the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
- ///
- /// An object to compare with this instance.
- ///
- /// A value that indicates the relative order of the objects being compared. The return value has these meanings: Value
- /// Meaning Less than zero This instance is less than . Zero This instance is equal to
- /// . Greater than zero This instance is greater than .
- ///
- ///
- /// is not the same type as this instance.
- ///
- int IComparable.CompareTo(object obj)
- {
- return Compare(this, obj);
- }
-
- ///
- /// Compares two Int128 values and returns an integer that indicates whether the first value is less than, equal to, or
- /// greater than the second value.
- ///
- /// The first value to compare.
- /// The second value to compare.
- /// A signed integer that indicates the relative values of left and right, as shown in the following table.
- public static int Compare(Int128 left, object right)
- {
- if (right is Int128)
- return Compare(left, (Int128) right);
-
- // NOTE: this could be optimized type per type
- if (right is bool)
- return Compare(left, new Int128((bool) right));
-
- if (right is byte)
- return Compare(left, new Int128((byte) right));
-
- if (right is char)
- return Compare(left, new Int128((char) right));
-
- if (right is decimal)
- return Compare(left, new Int128((decimal) right));
-
- if (right is double)
- return Compare(left, new Int128((double) right));
-
- if (right is short)
- return Compare(left, new Int128((short) right));
-
- if (right is int)
- return Compare(left, new Int128((int) right));
-
- if (right is long)
- return Compare(left, new Int128((long) right));
-
- if (right is sbyte)
- return Compare(left, new Int128((sbyte) right));
-
- if (right is float)
- return Compare(left, new Int128((float) right));
-
- if (right is ushort)
- return Compare(left, new Int128((ushort) right));
-
- if (right is uint)
- return Compare(left, new Int128((uint) right));
-
- if (right is ulong)
- return Compare(left, new Int128((ulong) right));
-
- var bytes = right as byte[];
- if ((bytes != null) && (bytes.Length != 16))
- return Compare(left, new Int128(bytes));
-
- if (right is Guid)
- return Compare(left, new Int128((Guid) right));
-
- throw new ArgumentException();
- }
-
- ///
- /// Converts an Int128 value to a byte array.
- ///
- /// The value of the current Int128 object converted to an array of bytes.
- public byte[] ToByteArray()
- {
- var bytes = new byte[16];
- Buffer.BlockCopy(BitConverter.GetBytes(_lo), 0, bytes, 0, 8);
- Buffer.BlockCopy(BitConverter.GetBytes(_hi), 0, bytes, 8, 8);
- return bytes;
- }
-
- ///
- /// Compares two 128-bit signed integer values and returns an integer that indicates whether the first value is less
- /// than, equal to, or greater than the second value.
- ///
- /// The first value to compare.
- /// The second value to compare.
- ///
- /// A signed number indicating the relative values of this instance and value.
- ///
- public static int Compare(Int128 left, Int128 right)
- {
- if (left.Sign < 0)
- {
- if (right.Sign >= 0)
- return -1;
-
- var xhi = left._hi & ~HiNeg;
- var yhi = right._hi & ~HiNeg;
- if (xhi != yhi)
- return -xhi.CompareTo(yhi);
-
- return -left._lo.CompareTo(right._lo);
- }
-
- if (right.Sign < 0)
- return 1;
-
- if (left._hi != right._hi)
- return left._hi.CompareTo(right._hi);
-
- return left._lo.CompareTo(right._lo);
- }
-
- ///
- /// Compares this instance to a specified 128-bit signed integer and returns an indication of their relative values.
- ///
- /// An integer to compare.
- /// A signed number indicating the relative values of this instance and value.
- public int CompareTo(Int128 value)
- {
- return Compare(this, value);
- }
-
- ///
- /// Performs an implicit conversion from to .
- ///
- /// if set to true [value].
- ///
- /// The result of the conversion.
- ///
- public static implicit operator Int128(bool value)
- {
- return new Int128(value);
- }
-
- ///
- /// Performs an implicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static implicit operator Int128(byte value)
- {
- return new Int128(value);
- }
-
- ///
- /// Performs an implicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static implicit operator Int128(char value)
- {
- return new Int128(value);
- }
-
- ///
- /// Performs an explicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static explicit operator Int128(decimal value)
- {
- return new Int128(value);
- }
-
- ///
- /// Performs an explicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static explicit operator Int128(double value)
- {
- return new Int128(value);
- }
-
- ///
- /// Performs an implicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static implicit operator Int128(short value)
- {
- return new Int128(value);
- }
-
- ///
- /// Performs an implicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static implicit operator Int128(int value)
- {
- return new Int128(value);
- }
-
- ///
- /// Performs an implicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static implicit operator Int128(long value)
- {
- return new Int128(value);
- }
-
- ///
- /// Performs an implicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static implicit operator Int128(sbyte value)
- {
- return new Int128(value);
- }
-
- ///
- /// Performs an explicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static explicit operator Int128(float value)
- {
- return new Int128(value);
- }
-
- ///
- /// Performs an implicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static implicit operator Int128(ushort value)
- {
- return new Int128(value);
- }
-
- ///
- /// Performs an implicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static implicit operator Int128(uint value)
- {
- return new Int128(value);
- }
-
- ///
- /// Performs an implicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static implicit operator Int128(ulong value)
- {
- return new Int128(value);
- }
-
- ///
- /// Performs an explicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static explicit operator bool(Int128 value)
- {
- return value.Sign != 0;
- }
-
- ///
- /// Performs an explicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static explicit operator byte(Int128 value)
- {
- if (value.Sign == 0)
- return 0;
-
- if ((value.Sign < 0) || (value._lo > 0xFF))
- throw new OverflowException();
-
- return (byte) value._lo;
- }
-
- ///
- /// Performs an explicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static explicit operator char(Int128 value)
- {
- if (value.Sign == 0)
- return (char) 0;
-
- if ((value.Sign < 0) || (value._lo > 0xFFFF))
- throw new OverflowException();
-
- return (char) (ushort) value._lo;
- }
-
- ///
- /// Performs an explicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static explicit operator decimal(Int128 value)
- {
- if (value.Sign == 0)
- return 0;
-
- return new decimal((int) (value._lo & 0xFFFFFFFF), (int) (value._lo >> 32),
- (int) (value._hi & 0xFFFFFFFF),
- value.Sign < 0, 0);
- }
-
- ///
- /// Performs an explicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static explicit operator double(Int128 value)
- {
- if (value.Sign == 0)
- return 0;
-
- double d;
- var nfi = CultureInfo.InvariantCulture.NumberFormat;
- if (!double.TryParse(value.ToString(nfi), NumberStyles.Number, nfi, out d))
- throw new OverflowException();
-
- return d;
- }
-
- ///
- /// Performs an explicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static explicit operator float(Int128 value)
- {
- if (value.Sign == 0)
- return 0;
-
- float f;
- var nfi = CultureInfo.InvariantCulture.NumberFormat;
- if (!float.TryParse(value.ToString(nfi), NumberStyles.Number, nfi, out f))
- throw new OverflowException();
-
- return f;
- }
-
- ///
- /// Performs an explicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static explicit operator short(Int128 value)
- {
- if (value.Sign == 0)
- return 0;
-
- if (value._lo > 0x8000)
- throw new OverflowException();
-
- if ((value._lo == 0x8000) && (value.Sign > 0))
- throw new OverflowException();
-
- return (short) ((int) value._lo*value.Sign);
- }
-
- ///
- /// Performs an explicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static explicit operator int(Int128 value)
- {
- if (value.Sign == 0)
- return 0;
-
- if (value._lo > 0x80000000)
- throw new OverflowException();
-
- if ((value._lo == 0x80000000) && (value.Sign > 0))
- throw new OverflowException();
-
- return (int) value._lo*value.Sign;
- }
-
- ///
- /// Performs an explicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static explicit operator long(Int128 value)
- {
- if (value.Sign == 0)
- return 0;
-
- if (value._lo > long.MaxValue)
- throw new OverflowException();
-
- return (long) value._lo*value.Sign;
- }
-
- ///
- /// Performs an explicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static explicit operator uint(Int128 value)
- {
- if (value.Sign == 0)
- return 0;
-
- if ((value.Sign < 0) || (value._lo > uint.MaxValue))
- throw new OverflowException();
-
- return (uint) value._lo;
- }
-
- ///
- /// Performs an explicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static explicit operator ushort(Int128 value)
- {
- if (value.Sign == 0)
- return 0;
-
- if ((value.Sign < 0) || (value._lo > ushort.MaxValue))
- throw new OverflowException();
-
- return (ushort) value._lo;
- }
-
- ///
- /// Performs an explicit conversion from to .
- ///
- /// The value.
- ///
- /// The result of the conversion.
- ///
- public static explicit operator ulong(Int128 value)
- {
- if ((value.Sign < 0) || (value._hi != 0))
- throw new OverflowException();
-
- return value._lo;
- }
-
- ///
- /// Implements the operator >.
- ///
- /// The x.
- /// The y.
- ///
- /// The result of the operator.
- ///
- public static bool operator >(Int128 left, Int128 right)
- {
- return Compare(left, right) > 0;
- }
-
- ///
- /// Implements the operator <.
- ///
- /// The x.
- /// The y.
- ///
- /// The result of the operator.
- ///
- public static bool operator <(Int128 left, Int128 right)
- {
- return Compare(left, right) < 0;
- }
-
- ///
- /// Implements the operator >=.
- ///
- /// The x.
- /// The y.
- ///
- /// The result of the operator.
- ///
- public static bool operator >=(Int128 left, Int128 right)
- {
- return Compare(left, right) >= 0;
- }
-
- ///
- /// Implements the operator <=.
- ///
- /// The x.
- /// The y.
- ///
- /// The result of the operator.
- ///
- public static bool operator <=(Int128 left, Int128 right)
- {
- return Compare(left, right) <= 0;
- }
-
- ///
- /// Implements the operator !=.
- ///
- /// The x.
- /// The y.
- ///
- /// The result of the operator.
- ///
- public static bool operator !=(Int128 left, Int128 right)
- {
- return Compare(left, right) != 0;
- }
-
- ///
- /// Implements the operator ==.
- ///
- /// The x.
- /// The y.
- ///
- /// The result of the operator.
- ///
- public static bool operator ==(Int128 left, Int128 right)
- {
- return Compare(left, right) == 0;
- }
-
- ///
- /// Implements the operator +.
- ///
- /// The value.
- ///
- /// The result of the operator.
- ///
- public static Int128 operator +(Int128 value)
- {
- return value;
- }
-
- ///
- /// Implements the operator -.
- ///
- /// The value.
- ///
- /// The result of the operator.
- ///
- public static Int128 operator -(Int128 value)
- {
- return Negate(value);
- }
-
- ///
- /// Negates a specified Int128 value.
- ///
- /// The value to negate.
- /// The result of the value parameter multiplied by negative one (-1).
- public static Int128 Negate(Int128 value)
- {
- var neg = value;
- var sign = value.Sign;
- if (sign < 0)
- neg._hi &= ~HiNeg;
- else
- neg._hi |= HiNeg;
- return neg;
- }
-
- ///
- /// Gets the absolute value this object.
- ///
- /// The absolute value.
- public Int128 ToAbs()
- {
- return Abs(this);
- }
-
- ///
- /// Gets the absolute value of an Int128 object.
- ///
- /// A number.
- ///
- /// The absolute value.
- ///
- public static Int128 Abs(Int128 value)
- {
- if (value.Sign < 0)
- return -value;
-
- return value;
- }
-
- ///
- /// Implements the operator +.
- ///
- /// The x.
- /// The y.
- ///
- /// The result of the operator.
- ///
- public static Int128 operator +(Int128 left, Int128 right)
- {
- var add = left;
- add._hi += right._hi;
- add._lo += right._lo;
- if (add._lo < left._lo)
- add._hi++;
- return add;
- }
-
- ///
- /// Implements the operator -.
- ///
- /// The x.
- /// The y.
- ///
- /// The result of the operator.
- ///
- public static Int128 operator -(Int128 left, Int128 right)
- {
- return left + -right;
- }
-
- ///
- /// Adds two Int128 values and returns the result.
- ///
- /// The first value to add.
- /// The second value to add.
- /// The sum of left and right.
- public static Int128 Add(Int128 left, Int128 right)
- {
- return left + right;
- }
-
- ///
- /// Subtracts one Int128 value from another and returns the result.
- ///
- /// The value to subtract from (the minuend).
- /// The value to subtract (the subtrahend).
- /// The result of subtracting right from left.
- public static Int128 Subtract(Int128 left, Int128 right)
- {
- return left - right;
- }
-
- ///
- /// Divides one Int128 value by another and returns the result.
- ///
- /// The value to be divided.
- /// The value to divide by.
- /// The quotient of the division.
- public static Int128 Divide(Int128 dividend, Int128 divisor)
- {
- Int128 integer;
- return DivRem(dividend, divisor, out integer);
- }
-
- ///
- /// Divides one Int128 value by another, returns the result, and returns the remainder in an output parameter.
- ///
- /// The value to be divided.
- /// The value to divide by.
- ///
- /// When this method returns, contains an Int128 value that represents the remainder from the
- /// division. This parameter is passed uninitialized.
- ///
- ///
- /// The quotient of the division.
- ///
- public static Int128 DivRem(Int128 dividend, Int128 divisor, out Int128 remainder)
- {
- if (divisor == 0)
- throw new DivideByZeroException();
-
- uint[] quotient;
- uint[] rem;
- DivRem(dividend.ToUIn32Array(), divisor.ToUIn32Array(), out quotient, out rem);
- remainder = new Int128(1, rem);
- return new Int128(dividend.Sign*divisor.Sign, quotient);
- }
-
- private static void DivRem(uint[] dividend, uint[] divisor, out uint[] quotient, out uint[] remainder)
- {
- const ulong hiBit = 0x100000000;
- var divisorLen = GetLength(divisor);
- var dividendLen = GetLength(dividend);
- if (divisorLen <= 1)
- {
- ulong rem = 0;
- var div = divisor[0];
- quotient = new uint[dividendLen];
- remainder = new uint[1];
- for (var i = dividendLen - 1; i >= 0; i--)
- {
- rem *= hiBit;
- rem += dividend[i];
- var q = rem/div;
- rem -= q*div;
- quotient[i] = (uint) q;
- }
- remainder[0] = (uint) rem;
- return;
- }
-
- if (dividendLen >= divisorLen)
- {
- var shift = GetNormalizeShift(divisor[divisorLen - 1]);
- var normDividend = new uint[dividendLen + 1];
- var normDivisor = new uint[divisorLen];
- Normalize(dividend, dividendLen, normDividend, shift);
- Normalize(divisor, divisorLen, normDivisor, shift);
- quotient = new uint[dividendLen - divisorLen + 1];
- for (var j = dividendLen - divisorLen; j >= 0; j--)
- {
- var dx = hiBit*normDividend[j + divisorLen] + normDividend[j + divisorLen - 1];
- var qj = dx/normDivisor[divisorLen - 1];
- dx -= qj*normDivisor[divisorLen - 1];
- do
- {
- if ((qj < hiBit) &&
- (qj*normDivisor[divisorLen - 2] <= dx*hiBit + normDividend[j + divisorLen - 2]))
- break;
-
- qj -= 1L;
- dx += normDivisor[divisorLen - 1];
- } while (dx < hiBit);
-
- long di = 0;
- long dj;
- var index = 0;
- while (index < divisorLen)
- {
- var dqj = normDivisor[index]*qj;
- dj = normDividend[index + j] - (uint) dqj - di;
- normDividend[index + j] = (uint) dj;
- dqj = dqj >> 32;
- dj = dj >> 32;
- di = (long) dqj - dj;
- index++;
- }
-
- dj = normDividend[j + divisorLen] - di;
- normDividend[j + divisorLen] = (uint) dj;
- quotient[j] = (uint) qj;
-
- if (dj < 0)
- {
- quotient[j]--;
- ulong sum = 0;
- for (index = 0; index < divisorLen; index++)
- {
- sum = normDivisor[index] + normDividend[j + index] + sum;
- normDividend[j + index] = (uint) sum;
- sum = sum >> 32;
- }
- sum += normDividend[j + divisorLen];
- normDividend[j + divisorLen] = (uint) sum;
- }
- }
- remainder = Unnormalize(normDividend, shift);
- return;
- }
-
- quotient = new uint[0];
- remainder = dividend;
- }
-
- private static int GetLength(uint[] uints)
- {
- var index = uints.Length - 1;
- while ((index >= 0) && (uints[index] == 0))
- index--;
- return index + 1;
- }
-
- private static int GetNormalizeShift(uint ui)
- {
- var shift = 0;
- if ((ui & 0xffff0000) == 0)
- {
- ui = ui << 16;
- shift += 16;
- }
-
- if ((ui & 0xff000000) == 0)
- {
- ui = ui << 8;
- shift += 8;
- }
-
- if ((ui & 0xf0000000) == 0)
- {
- ui = ui << 4;
- shift += 4;
- }
-
- if ((ui & 0xc0000000) == 0)
- {
- ui = ui << 2;
- shift += 2;
- }
-
- if ((ui & 0x80000000) == 0)
- shift++;
- return shift;
- }
-
- private static uint[] Unnormalize(uint[] normalized, int shift)
- {
- var len = GetLength(normalized);
- var unormalized = new uint[len];
- if (shift > 0)
- {
- var rshift = 32 - shift;
- uint r = 0;
- for (var i = len - 1; i >= 0; i--)
- {
- unormalized[i] = (normalized[i] >> shift) | r;
- r = normalized[i] << rshift;
- }
- }
- else
- {
- for (var j = 0; j < len; j++)
- unormalized[j] = normalized[j];
- }
- return unormalized;
- }
-
- private static void Normalize(uint[] unormalized, int len, uint[] normalized, int shift)
- {
- int i;
- uint n = 0;
- if (shift > 0)
- {
- var rshift = 32 - shift;
- for (i = 0; i < len; i++)
- {
- normalized[i] = (unormalized[i] << shift) | n;
- n = unormalized[i] >> rshift;
- }
- }
- else
- {
- i = 0;
- while (i < len)
- {
- normalized[i] = unormalized[i];
- i++;
- }
- }
-
- while (i < normalized.Length)
- normalized[i++] = 0;
-
- if (n != 0)
- normalized[len] = n;
- }
-
- ///
- /// Performs integer division on two Int128 values and returns the remainder.
- ///
- /// The value to be divided.
- /// The value to divide by.
- /// The remainder after dividing dividend by divisor.
- public static Int128 Remainder(Int128 dividend, Int128 divisor)
- {
- Int128 remainder;
- DivRem(dividend, divisor, out remainder);
- return remainder;
- }
-
- ///
- /// Implements the operator %.
- ///
- /// The dividend.
- /// The divisor.
- ///
- /// The result of the operator.
- ///
- public static Int128 operator %(Int128 dividend, Int128 divisor)
- {
- return Remainder(dividend, divisor);
- }
-
- ///
- /// Implements the operator /.
- ///
- /// The dividend.
- /// The divisor.
- ///
- /// The result of the operator.
- ///
- public static Int128 operator /(Int128 dividend, Int128 divisor)
- {
- return Divide(dividend, divisor);
- }
-
- ///
- /// Converts an int128 value to an unsigned long array.
- ///
- ///
- /// The value of the current Int128 object converted to an array of unsigned integers.
- ///
- public ulong[] ToUIn64Array()
- {
- return new[] {_hi, _lo};
- }
-
- ///
- /// Converts an int128 value to an unsigned integer array.
- ///
- /// The value of the current Int128 object converted to an array of unsigned integers.
- public uint[] ToUIn32Array()
- {
- var ints = new uint[4];
- var lob = BitConverter.GetBytes(_lo);
- var hib = BitConverter.GetBytes(_hi);
-
- Buffer.BlockCopy(lob, 0, ints, 0, 4);
- Buffer.BlockCopy(lob, 4, ints, 4, 4);
- Buffer.BlockCopy(hib, 0, ints, 8, 4);
- Buffer.BlockCopy(hib, 4, ints, 12, 4);
- return ints;
- }
-
- ///
- /// Returns the product of two Int128 values.
- ///
- /// The first number to multiply.
- /// The second number to multiply.
- /// The product of the left and right parameters.
- public static Int128 Multiply(Int128 left, Int128 right)
- {
- var xInts = left.ToUIn32Array();
- var yInts = right.ToUIn32Array();
- var mulInts = new uint[8];
-
- for (var i = 0; i < xInts.Length; i++)
- {
- var index = i;
- ulong remainder = 0;
- foreach (var yi in yInts)
- {
- remainder = remainder + (ulong) xInts[i]*yi + mulInts[index];
- mulInts[index++] = (uint) remainder;
- remainder = remainder >> 32;
- }
-
- while (remainder != 0)
- {
- remainder += mulInts[index];
- mulInts[index++] = (uint) remainder;
- remainder = remainder >> 32;
- }
- }
- return new Int128(left.Sign*right.Sign, mulInts);
- }
-
- ///
- /// Implements the operator *.
- ///
- /// The x.
- /// The y.
- ///
- /// The result of the operator.
- ///
- public static Int128 operator *(Int128 left, Int128 right)
- {
- return Multiply(left, right);
- }
-
- ///
- /// Implements the operator >>.
- ///
- /// The value.
- /// The shift.
- /// The result of the operator.
- public static Int128 operator >>(Int128 value, int shift)
- {
- if (shift == 0)
- return value;
-
- if (shift < 0)
- return value << -shift;
-
- shift = shift%128;
-
- var shifted = new Int128();
-
- if (shift > 63)
- {
- shifted._lo = value._hi >> (shift - 64);
- shifted._hi = 0;
- }
- else
- {
- shifted._hi = value._hi >> shift;
- shifted._lo = (value._hi << (64 - shift)) | (value._lo >> shift);
- }
- return shifted;
- }
-
- ///
- /// Implements the operator <<.
- ///
- /// The value.
- /// The shift.
- /// The result of the operator.
- public static Int128 operator <<(Int128 value, int shift)
- {
- if (shift == 0)
- return value;
-
- if (shift < 0)
- return value >> -shift;
-
- shift = shift%128;
-
- var shifted = new Int128();
-
- if (shift > 63)
- {
- shifted._hi = value._lo << (shift - 64);
- shifted._lo = 0;
- }
- else
- {
- var ul = value._lo >> (64 - shift);
- shifted._hi = ul | (value._hi << shift);
- shifted._lo = value._lo << shift;
- }
- return shifted;
- }
-
- ///
- /// Implements the operator |.
- ///
- /// The left.
- /// The right.
- /// The result of the operator.
- public static Int128 operator |(Int128 left, Int128 right)
- {
- if (left == 0)
- return right;
-
- if (right == 0)
- return left;
-
- var result = left;
- result._hi |= right._hi;
- result._lo |= right._lo;
- return result;
- }
-
- ///
- /// Implements the operator ~.
- ///
- /// The left.
- /// The right.
- /// The result of the operator.
- public static Int128 operator ~(Int128 value)
- {
- Int128 result = 0;
- result._hi = ~value._hi;
- result._lo = ~value._lo;
- return result;
- }
-
- ///
- /// Implements the operator &.
- ///
- /// The left.
- /// The right.
- /// The result of the operator.
- public static Int128 operator &(Int128 left, Int128 right)
- {
- if ((left == 0) || (right == 0))
- return Zero;
-
- var result = left;
- result._hi &= right._hi;
- result._lo &= right._lo;
- return result;
- }
-
-#if !WINDOWS_PHONE && !SILVERLIGHT
- void IBinarySerialize.Read(BinaryReader reader)
- {
- if (reader == null)
- throw new ArgumentNullException("reader");
-
- _hi = reader.ReadUInt64();
- _lo = reader.ReadUInt64();
- }
-
- void IBinarySerialize.Write(BinaryWriter writer)
- {
- if (writer == null)
- throw new ArgumentNullException("writer");
-
- writer.Write(_hi);
- writer.Write(_lo);
- }
-#endif
-
- ///
- /// Converts a String type to a Int128 type, and vice versa.
- ///
- public class Int128Converter : TypeConverter
- {
- ///
- /// Returns whether this converter can convert an object of the given type to the type of this converter, using the
- /// specified context.
- ///
- /// An that provides a format context.
- /// A that represents the type you want to convert from.
- ///
- /// true if this converter can perform the conversion; otherwise, false.
- ///
- public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
- {
- if (sourceType == typeof(string))
- return true;
-
- return base.CanConvertFrom(context, sourceType);
- }
-
- ///
- /// Converts the given object to the type of this converter, using the specified context and culture information.
- ///
- /// An that provides a format context.
- /// The to use as the current culture.
- /// The to convert.
- ///
- /// An that represents the converted value.
- ///
- ///
- /// The conversion cannot be performed.
- ///
- public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
- {
- if (value != null)
- {
- Int128 i;
- if (TryParse(string.Format("{0}", value), out i))
- return i;
- }
- return new Int128();
- }
-
- ///
- /// Returns whether this converter can convert the object to the specified type, using the specified context.
- ///
- /// An that provides a format context.
- /// A that represents the type you want to convert to.
- ///
- /// true if this converter can perform the conversion; otherwise, false.
- ///
- public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
- {
- if (destinationType == typeof(string))
- return true;
-
- return base.CanConvertTo(context, destinationType);
- }
-
- ///
- /// Converts the given value object to the specified type, using the specified context and culture information.
- ///
- /// An that provides a format context.
- ///
- /// A . If null is passed, the current culture is
- /// assumed.
- ///
- /// The to convert.
- /// The to convert the parameter to.
- ///
- /// An that represents the converted value.
- ///
- ///
- /// The parameter is null.
- ///
- ///
- /// The conversion cannot be performed.
- ///
- public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value,
- Type destinationType)
- {
- if (destinationType == typeof(string))
- return string.Format("{0}", value);
-
- return base.ConvertTo(context, culture, value, destinationType);
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/WoW/Data/WoWEnums.cs b/Artemis/Artemis/Modules/Games/WoW/Data/WoWEnums.cs
deleted file mode 100644
index 24fa676fa..000000000
--- a/Artemis/Artemis/Modules/Games/WoW/Data/WoWEnums.cs
+++ /dev/null
@@ -1,157 +0,0 @@
-namespace Artemis.Modules.Games.WoW.Data
-{
- public static class WoWEnums
- {
- public enum GuidType : byte
- {
- Null = 0,
- Uniq = 1,
- Player = 2,
- Item = 3,
- StaticDoor = 4,
- Transport = 5,
- Conversation = 6,
- Creature = 7,
- Vehicle = 8,
- Pet = 9,
- GameObject = 10,
- DynamicObject = 11,
- AreaTrigger = 12,
- Corpse = 13,
- LootObject = 14,
- SceneObject = 15,
- Scenario = 16,
- AiGroup = 17,
- DynamicDoor = 18,
- ClientActor = 19,
- Vignette = 20,
- CallForHelp = 21,
- AiResource = 22,
- AiLock = 23,
- AiLockTicket = 24,
- ChatChannel = 25,
- Party = 26,
- Guild = 27,
- WowAccount = 28,
- BNetAccount = 29,
- GmTask = 30,
- MobileSession = 31,
- RaidGroup = 32,
- Spell = 33,
- Mail = 34,
- WebObj = 35,
- LfgObject = 36,
- LfgList = 37,
- UserRouter = 38,
- PvpQueueGroup = 39,
- UserClient = 40,
- PetBattle = 41,
- UniqueUserClient = 42,
- BattlePet = 43
- }
-
- public enum ObjectType
- {
- Object = 0,
- Item = 1,
- Container = 2,
- Unit = 3,
- Player = 4,
- GameObject = 5,
- DynamicObject = 6,
- Corpse = 7,
- AreaTrigger = 8,
- SceneObject = 9,
- Conversation = 10
- }
-
- public enum PowerType
- {
- Mana = 0,
- Rage = 1,
- Focus = 2,
- Energy = 3,
- Happiness = 4,
- RunicPower = 5,
- Runes = 6,
- Health = 7,
- Maelstrom = 11,
- Insanity = 13,
- Fury = 17,
- Pain = 18,
- UNKNOWN
- }
-
- public enum Reaction
- {
- Hostile = 1,
- Neutral = 3,
- Friendly = 4
- }
-
- public enum ShapeshiftForm
- {
- Normal = 0,
- Cat = 1,
- TreeOfLife = 2,
- Travel = 3,
- Aqua = 4,
- Bear = 5,
- Ambient = 6,
- Ghoul = 7,
- DireBear = 8,
- CreatureBear = 14,
- CreatureCat = 15,
- GhostWolf = 16,
- BattleStance = 17,
- DefensiveStance = 18,
- BerserkerStance = 19,
- EpicFlightForm = 27,
- Shadow = 28,
- Stealth = 30,
- Moonkin = 31,
- SpiritOfRedemption = 32
- }
-
- public enum WoWClass
- {
- None = 0,
- Warrior = 1,
- Paladin = 2,
- Hunter = 3,
- Rogue = 4,
- Priest = 5,
- DeathKnight = 6,
- Shaman = 7,
- Mage = 8,
- Warlock = 9,
- Druid = 11
- }
-
- public enum WoWRace
- {
- Human = 1,
- Orc = 2,
- Dwarf = 3,
- NightElf = 4,
- Undead = 5,
- Tauren = 6,
- Gnome = 7,
- Troll = 8,
- Goblin = 9,
- BloodElf = 10,
- Draenei = 11,
- FelOrc = 12,
- Naga = 13,
- Broken = 14,
- Skeleton = 15,
- Worgen = 22
- }
-
- public enum WoWType
- {
- Player,
- Npc
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/WoW/Data/WoWNameCache.cs b/Artemis/Artemis/Modules/Games/WoW/Data/WoWNameCache.cs
deleted file mode 100644
index 78677f117..000000000
--- a/Artemis/Artemis/Modules/Games/WoW/Data/WoWNameCache.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using System;
-using System.Text;
-using Process.NET;
-
-namespace Artemis.Modules.Games.WoW.Data
-{
- public class WoWNameCache
- {
- public WoWNameCache(ProcessSharp process, IntPtr baseAddress)
- {
- Process = process;
- CurrentCacheAddress = process.Native.MainModule.BaseAddress + baseAddress.ToInt32();
- }
-
- public ProcessSharp Process { get; set; }
-
- public IntPtr CurrentCacheAddress { get; set; }
-
- public WoWDetails GetNameByGuid(Guid searchGuid)
- {
- var current = Process.Memory.Read(CurrentCacheAddress);
- var index = 0;
- while (current != IntPtr.Zero)
- {
- var guid = Process.Memory.Read(current + 0x20);
- if (guid.Equals(searchGuid))
- {
- var pRace = Process.Memory.Read(current + 0x88);
- var pClass = Process.Memory.Read(current + 0x90);
- var pName = Process.Memory.Read(current + 0x31, Encoding.ASCII, 48);
-
- var name = new WoWDetails(guid, pRace, pClass, WoWEnums.WoWType.Player, pName);
- return name;
- }
-
- if (index > 20000)
- return null;
-
- index++;
- current = Process.Memory.Read(current);
- }
- return null;
- }
- }
-
- public class WoWDetails
- {
- public WoWDetails(Guid guid, int race, int @class, WoWEnums.WoWType type, string name)
- {
- Guid = guid;
- Race = (WoWEnums.WoWRace) race;
- Class = (WoWEnums.WoWClass) @class;
- Type = type;
- Name = name;
- }
-
- public Guid Guid { get; set; }
- public WoWEnums.WoWRace Race { get; set; }
- public WoWEnums.WoWClass Class { get; set; }
- public WoWEnums.WoWType Type { get; set; }
- public string Name { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/WoW/Data/WoWObject.cs b/Artemis/Artemis/Modules/Games/WoW/Data/WoWObject.cs
deleted file mode 100644
index a8db9114c..000000000
--- a/Artemis/Artemis/Modules/Games/WoW/Data/WoWObject.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-using System;
-using System.Text;
-using Newtonsoft.Json;
-using Process.NET;
-
-namespace Artemis.Modules.Games.WoW.Data
-{
- public class WoWObject
- {
- private readonly bool _readPointer;
-
- public WoWObject(IProcess process, IntPtr baseAddress, bool readPointer = false)
- {
- Process = process;
- BaseAddress = baseAddress;
- _readPointer = readPointer;
-
- Guid = ReadField(0x00);
- }
-
- [JsonIgnore]
- public IntPtr BaseAddress { get; set; }
-
- [JsonIgnore]
- public IProcess Process { get; set; }
-
- public Guid Guid { get; set; }
-
- [JsonIgnore]
- public WoWStructs.ObjectData Data { get; set; }
-
- public T ReadField(int offset)
- {
- var address = GetAddress();
- if (address == IntPtr.Zero)
- return default(T);
-
- var ptr = Process.Memory.Read(address + 0x10);
- return Process.Memory.Read(ptr + offset);
- }
-
- public T ReadField(Enum offset)
- {
- var address = GetAddress();
- if (address == IntPtr.Zero)
- return default(T);
-
- var ptr = Process.Memory.Read(address + 0x10);
- return Process.Memory.Read(ptr + Convert.ToInt32(offset));
- }
-
- private IntPtr GetAddress()
- {
- return _readPointer
- ? Process.Memory.Read(Process.Native.MainModule.BaseAddress + BaseAddress.ToInt32())
- : BaseAddress;
- }
-
- public WoWDetails GetNpcDetails()
- {
- var address = GetAddress();
- if (address == IntPtr.Zero)
- return null;
-
- var npcCachePtr = Process.Memory.Read(address + 0x1760);
- if (npcCachePtr == IntPtr.Zero)
- return null;
-
- var npcName = Process.Memory.Read(Process.Memory.Read(npcCachePtr + 0x00A0), Encoding.ASCII, 48);
- return new WoWDetails(Guid, 0, 0, WoWEnums.WoWType.Npc, npcName);
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/WoW/Data/WoWObjectManager.cs b/Artemis/Artemis/Modules/Games/WoW/Data/WoWObjectManager.cs
deleted file mode 100644
index e47ff61ec..000000000
--- a/Artemis/Artemis/Modules/Games/WoW/Data/WoWObjectManager.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Runtime.InteropServices;
-using Process.NET;
-
-namespace Artemis.Modules.Games.WoW.Data
-{
- public class WoWObjectManager
- {
- public WoWObjectManager(IProcess process, IntPtr baseAddress)
- {
- Process = process;
- CurrentManagerAddress = process.Native.MainModule.BaseAddress + baseAddress.ToInt32();
- }
-
- public IProcess Process { get; set; }
-
- public IntPtr CurrentManagerAddress { get; set; }
-
- public Dictionary WoWObjects { get; set; }
-
- public IntPtr GetFirstObject()
- {
- var mgr = GetCurrentManager();
- return mgr.VisibleObjects.m_fulllist.baseClass.m_terminator.m_next;
- }
-
- public WoWStructs.CurrentManager GetCurrentManager()
- {
- return Process.Memory.Read(Process.Memory.Read(CurrentManagerAddress));
- }
-
- public IntPtr GetNextObjectFromCurrent(IntPtr current)
- {
- var mgr = GetCurrentManager();
-
- return Process.Memory.Read(
- current + mgr.VisibleObjects.m_fulllist.baseClass.m_linkoffset + IntPtr.Size);
- }
-
- public void Update()
- {
- WoWObjects.Clear();
- var wowObjects = EnumVisibleObjects();
- foreach (var wowObject in wowObjects)
- WoWObjects[wowObject.Data.Guid] = wowObject;
-
- OnObjectsUpdated(WoWObjects);
- }
-
- public event EventHandler> ObjectsUpdated;
-
- // Loop through the games object list.
- public IEnumerable EnumVisibleObjects()
- {
- var first = GetFirstObject();
- var typeOffset = Marshal.OffsetOf(typeof(WoWStructs.ObjectData), "ObjectType").ToInt32();
-
- while (((first.ToInt64() & 1) == 0) && (first != IntPtr.Zero))
- {
- var type = (WoWEnums.ObjectType) Process.Memory.Read(first + typeOffset);
-
- // Fix below with other object types as added.
- // ReSharper disable once SwitchStatementMissingSomeCases
- switch (type)
- {
- case WoWEnums.ObjectType.Object:
- yield return new WoWObject(Process, first);
- break;
- case WoWEnums.ObjectType.Container:
- break;
- case WoWEnums.ObjectType.Unit:
- yield return new WoWUnit(Process, first);
- break;
- case WoWEnums.ObjectType.Player:
- yield return new WoWPlayer(Process, first, new IntPtr(0x179A6E0));
- break;
- default:
- yield return new WoWObject(Process, first);
- break;
- }
-
- first = GetNextObjectFromCurrent(first);
- }
- }
-
- protected virtual void OnObjectsUpdated(Dictionary e)
- {
- ObjectsUpdated?.Invoke(this, e);
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/WoW/Data/WoWOffsets.cs b/Artemis/Artemis/Modules/Games/WoW/Data/WoWOffsets.cs
deleted file mode 100644
index b4037a419..000000000
--- a/Artemis/Artemis/Modules/Games/WoW/Data/WoWOffsets.cs
+++ /dev/null
@@ -1,368 +0,0 @@
-namespace Artemis.Modules.Games.WoW.Data
-{
- internal static class WoWOffsets
- {
- internal enum AreaTriggerData
- {
- OverrideScaleCurve = 0x30, // Size: 0x7, Flags: 0x201
- ExtraScaleCurve = 0x4C, // Size: 0x7, Flags: 0x201
- Caster = 0x68, // Size: 0x4, Flags: 0x1
- Duration = 0x78, // Size: 0x1, Flags: 0x1
- TimeToTarget = 0x7C, // Size: 0x1, Flags: 0x201
- TimeToTargetScale = 0x80, // Size: 0x1, Flags: 0x201
- TimeToTargetExtraScale = 0x84, // Size: 0x1, Flags: 0x201
- SpellId = 0x88, // Size: 0x1, Flags: 0x1
- SpellVisualId = 0x8C, // Size: 0x1, Flags: 0x80
- BoundsRadius2D = 0x90, // Size: 0x1, Flags: 0x280
- DecalPropertiesId = 0x94 // Size: 0x1, Flags: 0x1
- }
-
- internal enum ContainerData
- {
- Slots = 0x150, // Size: 0x90, Flags: 0x1
- NumSlots = 0x390 // Size: 0x1, Flags: 0x1
- }
-
- internal enum ConversationData
- {
- LastLineDuration = 0x30 // Size: 0x1, Flags: 0x80
- }
-
- internal enum CorpseData
- {
- Owner = 0x30, // Size: 0x4, Flags: 0x1
- PartyGuid = 0x40, // Size: 0x4, Flags: 0x1
- DisplayId = 0x50, // Size: 0x1, Flags: 0x1
- Items = 0x54, // Size: 0x13, Flags: 0x1
- SkinId = 0xA0, // Size: 0x1, Flags: 0x1
- FacialHairStyleId = 0xA4, // Size: 0x1, Flags: 0x1
- Flags = 0xA8, // Size: 0x1, Flags: 0x1
- DynamicFlags = 0xAC, // Size: 0x1, Flags: 0x80
- FactionTemplate = 0xB0, // Size: 0x1, Flags: 0x1
- CustomDisplayOption = 0xB4 // Size: 0x1, Flags: 0x1
- }
-
- internal enum DynamicObjectData
- {
- Caster = 0x30, // Size: 0x4, Flags: 0x1
- TypeAndVisualId = 0x40, // Size: 0x1, Flags: 0x80
- SpellId = 0x44, // Size: 0x1, Flags: 0x1
- Radius = 0x48, // Size: 0x1, Flags: 0x1
- CastTime = 0x4C // Size: 0x1, Flags: 0x1
- }
-
- internal enum GameObjectData
- {
- CreatedBy = 0x30, // Size: 0x4, Flags: 0x1
- DisplayId = 0x40, // Size: 0x1, Flags: 0x280
- Flags = 0x44, // Size: 0x1, Flags: 0x201
- ParentRotation = 0x48, // Size: 0x4, Flags: 0x1
- FactionTemplate = 0x58, // Size: 0x1, Flags: 0x1
- Level = 0x5C, // Size: 0x1, Flags: 0x1
- PercentHealth = 0x60, // Size: 0x1, Flags: 0x201
- SpellVisualId = 0x64, // Size: 0x1, Flags: 0x281
- StateSpellVisualId = 0x68, // Size: 0x1, Flags: 0x280
- StateAnimId = 0x6C, // Size: 0x1, Flags: 0x280
- StateAnimKitId = 0x70, // Size: 0x1, Flags: 0x280
- StateWorldEffectId = 0x74 // Size: 0x4, Flags: 0x280
- }
-
- internal enum ItemData
- {
- Owner = 0x30, // Size: 0x4, Flags: 0x1
- ContainedIn = 0x40, // Size: 0x4, Flags: 0x1
- Creator = 0x50, // Size: 0x4, Flags: 0x1
- GiftCreator = 0x60, // Size: 0x4, Flags: 0x1
- StackCount = 0x70, // Size: 0x1, Flags: 0x4
- Expiration = 0x74, // Size: 0x1, Flags: 0x4
- SpellCharges = 0x78, // Size: 0x5, Flags: 0x4
- DynamicFlags = 0x8C, // Size: 0x1, Flags: 0x1
- Enchantment = 0x90, // Size: 0x27, Flags: 0x1
- PropertySeed = 0x12C, // Size: 0x1, Flags: 0x1
- RandomPropertiesId = 0x130, // Size: 0x1, Flags: 0x1
- Durability = 0x134, // Size: 0x1, Flags: 0x4
- MaxDurability = 0x138, // Size: 0x1, Flags: 0x4
- CreatePlayedTime = 0x13C, // Size: 0x1, Flags: 0x1
- ModifiersMask = 0x140, // Size: 0x1, Flags: 0x4
- Context = 0x144, // Size: 0x1, Flags: 0x1
- ArtifactXp = 0x148, // Size: 0x1, Flags: 0x4
- ItemAppearanceModId = 0x14C // Size: 0x1, Flags: 0x4
- }
-
- internal enum KeyBinding
- {
- NumKeyBindings = 0x1700030, // -0x17C0
- First = 0xC8,
- Next = 0xB8,
- Key = 0x30,
- Command = 0x58
- }
-
- internal enum ObjectData
- {
- Guid = 0x0, // Size: 0x4, Flags: 0x1
- Data = 0x10, // Size: 0x4, Flags: 0x1
- Type = 0x20, // Size: 0x1, Flags: 0x1
- EntryId = 0x24, // Size: 0x1, Flags: 0x80
- DynamicFlags = 0x28, // Size: 0x1, Flags: 0x280
- Scale = 0x2C // Size: 0x1, Flags: 0x1
- }
-
- internal enum PlayerData
- {
- DuelArbiter = 0x360, // Size: 0x4, Flags: 0x1
- WowAccount = 0x370, // Size: 0x4, Flags: 0x1
- LootTargetGuid = 0x380, // Size: 0x4, Flags: 0x1
- PlayerFlags = 0x390, // Size: 0x1, Flags: 0x1
- PlayerFlagsEx = 0x394, // Size: 0x1, Flags: 0x1
- GuildRankId = 0x398, // Size: 0x1, Flags: 0x1
- GuildDeleteDate = 0x39C, // Size: 0x1, Flags: 0x1
- GuildLevel = 0x3A0, // Size: 0x1, Flags: 0x1
- HairColorId = 0x3A4, // Size: 0x1, Flags: 0x1
- CustomDisplayOption = 0x3A8, // Size: 0x1, Flags: 0x1
- Inebriation = 0x3AC, // Size: 0x1, Flags: 0x1
- ArenaFaction = 0x3B0, // Size: 0x1, Flags: 0x1
- DuelTeam = 0x3B4, // Size: 0x1, Flags: 0x1
- GuildTimeStamp = 0x3B8, // Size: 0x1, Flags: 0x1
- QuestLog = 0x3BC, // Size: 0x320, Flags: 0x20
- VisibleItems = 0x103C, // Size: 0x26, Flags: 0x1
- PlayerTitle = 0x10D4, // Size: 0x1, Flags: 0x1
- FakeInebriation = 0x10D8, // Size: 0x1, Flags: 0x1
- VirtualPlayerRealm = 0x10DC, // Size: 0x1, Flags: 0x1
- CurrentSpecId = 0x10E0, // Size: 0x1, Flags: 0x1
- TaxiMountAnimKitId = 0x10E4, // Size: 0x1, Flags: 0x1
- AvgItemLevel = 0x10E8, // Size: 0x4, Flags: 0x1
- CurrentBattlePetBreedQuality = 0x10F8, // Size: 0x1, Flags: 0x1
- Prestige = 0x10FC, // Size: 0x1, Flags: 0x1
- HonorLevel = 0x1100, // Size: 0x1, Flags: 0x1
- InvSlots = 0x1104, // Size: 0x2EC, Flags: 0x2
- FarsightObject = 0x1CB4, // Size: 0x4, Flags: 0x2
- SummonedBattlePetGuid = 0x1CC4, // Size: 0x4, Flags: 0x2
- KnownTitles = 0x1CD4, // Size: 0xC, Flags: 0x2
- Coinage = 0x1D04, // Size: 0x2, Flags: 0x2
- Xp = 0x1D0C, // Size: 0x1, Flags: 0x2
- NextLevelXp = 0x1D10, // Size: 0x1, Flags: 0x2
- Skill = 0x1D14, // Size: 0x1C0, Flags: 0x2
- CharacterPoints = 0x2414, // Size: 0x1, Flags: 0x2
- MaxTalentTiers = 0x2418, // Size: 0x1, Flags: 0x2
- TrackCreatureMask = 0x241C, // Size: 0x1, Flags: 0x2
- TrackResourceMask = 0x2420, // Size: 0x1, Flags: 0x2
- MainhandExpertise = 0x2424, // Size: 0x1, Flags: 0x2
- OffhandExpertise = 0x2428, // Size: 0x1, Flags: 0x2
- RangedExpertise = 0x242C, // Size: 0x1, Flags: 0x2
- CombatRatingExpertise = 0x2430, // Size: 0x1, Flags: 0x2
- BlockPercentage = 0x2434, // Size: 0x1, Flags: 0x2
- DodgePercentage = 0x2438, // Size: 0x1, Flags: 0x2
- ParryPercentage = 0x243C, // Size: 0x1, Flags: 0x2
- CritPercentage = 0x2440, // Size: 0x1, Flags: 0x2
- RangedCritPercentage = 0x2444, // Size: 0x1, Flags: 0x2
- OffhandCritPercentage = 0x2448, // Size: 0x1, Flags: 0x2
- SpellCritPercentage = 0x244C, // Size: 0x1, Flags: 0x2
- ShieldBlock = 0x2450, // Size: 0x1, Flags: 0x2
- ShieldBlockCritPercentage = 0x2454, // Size: 0x1, Flags: 0x2
- Mastery = 0x2458, // Size: 0x1, Flags: 0x2
- Speed = 0x245C, // Size: 0x1, Flags: 0x2
- Lifesteal = 0x2460, // Size: 0x1, Flags: 0x2
- Avoidance = 0x2464, // Size: 0x1, Flags: 0x2
- Sturdiness = 0x2468, // Size: 0x1, Flags: 0x2
- Versatility = 0x246C, // Size: 0x1, Flags: 0x2
- VersatilityBonus = 0x2470, // Size: 0x1, Flags: 0x2
- PvpPowerDamage = 0x2474, // Size: 0x1, Flags: 0x2
- PvpPowerHealing = 0x2478, // Size: 0x1, Flags: 0x2
- ExploredZones = 0x247C, // Size: 0x100, Flags: 0x2
- RestInfo = 0x287C, // Size: 0x4, Flags: 0x2
- ModDamageDonePos = 0x288C, // Size: 0x7, Flags: 0x2
- ModDamageDoneNeg = 0x28A8, // Size: 0x7, Flags: 0x2
- ModDamageDonePercent = 0x28C4, // Size: 0x7, Flags: 0x2
- ModHealingDonePos = 0x28E0, // Size: 0x1, Flags: 0x2
- ModHealingPercent = 0x28E4, // Size: 0x1, Flags: 0x2
- ModHealingDonePercent = 0x28E8, // Size: 0x1, Flags: 0x2
- ModPeriodicHealingDonePercent = 0x28EC, // Size: 0x1, Flags: 0x2
- WeaponDmgMultipliers = 0x28F0, // Size: 0x3, Flags: 0x2
- WeaponAtkSpeedMultipliers = 0x28FC, // Size: 0x3, Flags: 0x2
- ModSpellPowerPercent = 0x2908, // Size: 0x1, Flags: 0x2
- ModResiliencePercent = 0x290C, // Size: 0x1, Flags: 0x2
- OverrideSpellPowerByApPercent = 0x2910, // Size: 0x1, Flags: 0x2
- OverrideApBySpellPowerPercent = 0x2914, // Size: 0x1, Flags: 0x2
- ModTargetResistance = 0x2918, // Size: 0x1, Flags: 0x2
- ModTargetPhysicalResistance = 0x291C, // Size: 0x1, Flags: 0x2
- LocalFlags = 0x2920, // Size: 0x1, Flags: 0x2
- NumRespecs = 0x2924, // Size: 0x1, Flags: 0x2
- SelfResSpell = 0x2928, // Size: 0x1, Flags: 0x2
- PvpMedals = 0x292C, // Size: 0x1, Flags: 0x2
- BuybackPrice = 0x2930, // Size: 0xC, Flags: 0x2
- BuybackTimestamp = 0x2960, // Size: 0xC, Flags: 0x2
- YesterdayHonorableKills = 0x2990, // Size: 0x1, Flags: 0x2
- LifetimeHonorableKills = 0x2994, // Size: 0x1, Flags: 0x2
- WatchedFactionIndex = 0x2998, // Size: 0x1, Flags: 0x2
- CombatRatings = 0x299C, // Size: 0x20, Flags: 0x2
- PvpInfo = 0x2A1C, // Size: 0x24, Flags: 0x2
- MaxLevel = 0x2AAC, // Size: 0x1, Flags: 0x2
- ScalingPlayerLevelDelta = 0x2AB0, // Size: 0x1, Flags: 0x2
- MaxCreatureScalingLevel = 0x2AB4, // Size: 0x1, Flags: 0x2
- NoReagentCostMask = 0x2AB8, // Size: 0x4, Flags: 0x2
- PetSpellPower = 0x2AC8, // Size: 0x1, Flags: 0x2
- Researching = 0x2ACC, // Size: 0xA, Flags: 0x2
- ProfessionSkillLine = 0x2AF4, // Size: 0x2, Flags: 0x2
- UiHitModifier = 0x2AFC, // Size: 0x1, Flags: 0x2
- UiSpellHitModifier = 0x2B00, // Size: 0x1, Flags: 0x2
- HomeRealmTimeOffset = 0x2B04, // Size: 0x1, Flags: 0x2
- ModPetHaste = 0x2B08, // Size: 0x1, Flags: 0x2
- OverrideSpellsId = 0x2B0C, // Size: 0x1, Flags: 0x402
- LfgBonusFactionId = 0x2B10, // Size: 0x1, Flags: 0x2
- LootSpecId = 0x2B14, // Size: 0x1, Flags: 0x2
- OverrideZonePvpType = 0x2B18, // Size: 0x1, Flags: 0x402
- BagSlotFlags = 0x2B1C, // Size: 0x4, Flags: 0x2
- BankBagSlotFlags = 0x2B2C, // Size: 0x7, Flags: 0x2
- InsertItemsLeftToRight = 0x2B48, // Size: 0x1, Flags: 0x2
- QuestCompleted = 0x2B4C, // Size: 0x36B, Flags: 0x2
- Honor = 0x38F8, // Size: 0x1, Flags: 0x2
- HonorNextLevel = 0x38FC // Size: 0x1, Flags: 0x2
- }
-
- internal enum SceneObjectData
- {
- ScriptPackageId = 0x30, // Size: 0x1, Flags: 0x1
- RndSeedVal = 0x34, // Size: 0x1, Flags: 0x1
- CreatedBy = 0x38, // Size: 0x4, Flags: 0x1
- SceneType = 0x48 // Size: 0x1, Flags: 0x1
- }
-
- internal enum Unit
- {
- CurrentCastId = 0x1B98,
- CurrentChanneledId = 0x1BB8,
- AuraTable = 0x1D10,
- AuraCount = 0x2390,
- AuraSize = 0x68,
- ClientRace = 0x2670,
- DisplayData = 0x1718
- }
-
- // Note: Invalid possibly!
- internal enum UnitAuras : uint
- {
- AuraCount1 = 0x2390,
- AuraCount2 = 0x1D10,
- AuraTable1 = 0x1D14,
- AuraTable2 = 0x1D18,
- AuraSize = 0x68,
-
- OwnerGuid = 0x40,
- AuraSpellId = 0x50,
- //AuraFlags = 0x54, //Not exactly sure here.
- //AuraLevel = 0x58, //Not exactly sure here.
- AuraStack = 0x59,
- TimeLeft = 0x60,
- //In case I need it:
- DruidEclipse = 0x2694
- }
-
- // Below is all of the World of Warcraft in-game object field offsets.
- // Commenting is not used on purpose and enums below should remain internal.
- internal enum UnitData
- {
- Charm = 0x30, // Size: 0x4, Flags: 0x1
- Summon = 0x40, // Size: 0x4, Flags: 0x1
- Critter = 0x50, // Size: 0x4, Flags: 0x2
- CharmedBy = 0x60, // Size: 0x4, Flags: 0x1
- SummonedBy = 0x70, // Size: 0x4, Flags: 0x1
- CreatedBy = 0x80, // Size: 0x4, Flags: 0x1
- DemonCreator = 0x90, // Size: 0x4, Flags: 0x1
- Target = 0xA0, // Size: 0x4, Flags: 0x1
- BattlePetCompanionGuid = 0xB0, // Size: 0x4, Flags: 0x1
- BattlePetDbid = 0xC0, // Size: 0x2, Flags: 0x1
- ChannelObject = 0xC8, // Size: 0x4, Flags: 0x201
- ChannelSpell = 0xD8, // Size: 0x1, Flags: 0x201
- ChannelSpellXSpellVisual = 0xDC, // Size: 0x1, Flags: 0x201
- SummonedByHomeRealm = 0xE0, // Size: 0x1, Flags: 0x1
- Sex = 0xE4, // Size: 0x1, Flags: 0x1
- DisplayPower = 0xE8, // Size: 0x1, Flags: 0x1
- OverrideDisplayPowerId = 0xEC, // Size: 0x1, Flags: 0x1
- Health = 0xF0, // Size: 0x2, Flags: 0x1
- Power = 0xF8, // Size: 0x6, Flags: 0x401
- TertiaryPower = 0xFC,
- SecondaryPower = 0x100,
- MaxHealth = 0x110, // Size: 0x2, Flags: 0x1
- MaxPower = 0x118, // Size: 0x6, Flags: 0x1
- PowerRegenFlatModifier = 0x130, // Size: 0x6, Flags: 0x46
- PowerRegenInterruptedFlatModifier = 0x148, // Size: 0x6, Flags: 0x46
- Level = 0x160, // Size: 0x1, Flags: 0x1
- EffectiveLevel = 0x164, // Size: 0x1, Flags: 0x1
- ScalingLevelMin = 0x168, // Size: 0x1, Flags: 0x1
- ScalingLevelMax = 0x16C, // Size: 0x1, Flags: 0x1
- ScalingLevelDelta = 0x170, // Size: 0x1, Flags: 0x1
- FactionTemplate = 0x174, // Size: 0x1, Flags: 0x1
- VirtualItems = 0x178, // Size: 0x6, Flags: 0x1
- Flags = 0x190, // Size: 0x1, Flags: 0x201
- Flags2 = 0x194, // Size: 0x1, Flags: 0x201
- Flags3 = 0x198, // Size: 0x1, Flags: 0x201
- AuraState = 0x19C, // Size: 0x1, Flags: 0x1
- AttackRoundBaseTime = 0x1A0, // Size: 0x2, Flags: 0x1
- RangedAttackRoundBaseTime = 0x1A8, // Size: 0x1, Flags: 0x2
- BoundingRadius = 0x1AC, // Size: 0x1, Flags: 0x1
- CombatReach = 0x1B0, // Size: 0x1, Flags: 0x1
- DisplayId = 0x1B4, // Size: 0x1, Flags: 0x280
- NativeDisplayId = 0x1B8, // Size: 0x1, Flags: 0x201
- MountDisplayId = 0x1BC, // Size: 0x1, Flags: 0x201
- MinDamage = 0x1C0, // Size: 0x1, Flags: 0x16
- MaxDamage = 0x1C4, // Size: 0x1, Flags: 0x16
- MinOffHandDamage = 0x1C8, // Size: 0x1, Flags: 0x16
- MaxOffHandDamage = 0x1CC, // Size: 0x1, Flags: 0x16
- AnimTier = 0x1D0, // Size: 0x1, Flags: 0x1
- PetNumber = 0x1D4, // Size: 0x1, Flags: 0x1
- PetNameTimestamp = 0x1D8, // Size: 0x1, Flags: 0x1
- PetExperience = 0x1DC, // Size: 0x1, Flags: 0x4
- PetNextLevelExperience = 0x1E0, // Size: 0x1, Flags: 0x4
- ModCastingSpeed = 0x1E4, // Size: 0x1, Flags: 0x1
- ModSpellHaste = 0x1E8, // Size: 0x1, Flags: 0x1
- ModHaste = 0x1EC, // Size: 0x1, Flags: 0x1
- ModRangedHaste = 0x1F0, // Size: 0x1, Flags: 0x1
- ModHasteRegen = 0x1F4, // Size: 0x1, Flags: 0x1
- ModTimeRate = 0x1F8, // Size: 0x1, Flags: 0x1
- CreatedBySpell = 0x1FC, // Size: 0x1, Flags: 0x1
- NpcFlags = 0x200, // Size: 0x2, Flags: 0x81
- EmoteState = 0x208, // Size: 0x1, Flags: 0x1
- Stats = 0x20C, // Size: 0x4, Flags: 0x6
- StatPosBuff = 0x21C, // Size: 0x4, Flags: 0x6
- StatNegBuff = 0x22C, // Size: 0x4, Flags: 0x6
- Resistances = 0x23C, // Size: 0x7, Flags: 0x16
- ResistanceBuffModsPositive = 0x258, // Size: 0x7, Flags: 0x6
- ResistanceBuffModsNegative = 0x274, // Size: 0x7, Flags: 0x6
- ModBonusArmor = 0x290, // Size: 0x1, Flags: 0x6
- BaseMana = 0x294, // Size: 0x1, Flags: 0x1
- BaseHealth = 0x298, // Size: 0x1, Flags: 0x6
- ShapeshiftForm = 0x29C, // Size: 0x1, Flags: 0x1
- AttackPower = 0x2A0, // Size: 0x1, Flags: 0x6
- AttackPowerModPos = 0x2A4, // Size: 0x1, Flags: 0x6
- AttackPowerModNeg = 0x2A8, // Size: 0x1, Flags: 0x6
- AttackPowerMultiplier = 0x2AC, // Size: 0x1, Flags: 0x6
- RangedAttackPower = 0x2B0, // Size: 0x1, Flags: 0x6
- RangedAttackPowerModPos = 0x2B4, // Size: 0x1, Flags: 0x6
- RangedAttackPowerModNeg = 0x2B8, // Size: 0x1, Flags: 0x6
- RangedAttackPowerMultiplier = 0x2BC, // Size: 0x1, Flags: 0x6
- SetAttackSpeedAura = 0x2C0, // Size: 0x1, Flags: 0x6
- MinRangedDamage = 0x2C4, // Size: 0x1, Flags: 0x6
- MaxRangedDamage = 0x2C8, // Size: 0x1, Flags: 0x6
- PowerCostModifier = 0x2CC, // Size: 0x7, Flags: 0x6
- PowerCostMultiplier = 0x2E8, // Size: 0x7, Flags: 0x6
- MaxHealthModifier = 0x304, // Size: 0x1, Flags: 0x6
- HoverHeight = 0x308, // Size: 0x1, Flags: 0x1
- MinItemLevelCutoff = 0x30C, // Size: 0x1, Flags: 0x1
- MinItemLevel = 0x310, // Size: 0x1, Flags: 0x1
- MaxItemLevel = 0x314, // Size: 0x1, Flags: 0x1
- WildBattlePetLevel = 0x318, // Size: 0x1, Flags: 0x1
- BattlePetCompanionNameTimestamp = 0x31C, // Size: 0x1, Flags: 0x1
- InteractSpellId = 0x320, // Size: 0x1, Flags: 0x1
- StateSpellVisualId = 0x324, // Size: 0x1, Flags: 0x280
- StateAnimId = 0x328, // Size: 0x1, Flags: 0x280
- StateAnimKitId = 0x32C, // Size: 0x1, Flags: 0x280
- StateWorldEffectId = 0x330, // Size: 0x4, Flags: 0x280
- ScaleDuration = 0x340, // Size: 0x1, Flags: 0x1
- LooksLikeMountId = 0x344, // Size: 0x1, Flags: 0x1
- LooksLikeCreatureId = 0x348, // Size: 0x1, Flags: 0x1
- LookAtControllerId = 0x34C, // Size: 0x1, Flags: 0x1
- LookAtControllerTarget = 0x350 // Size: 0x4, Flags: 0x1
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/WoW/Data/WoWPlayer.cs b/Artemis/Artemis/Modules/Games/WoW/Data/WoWPlayer.cs
deleted file mode 100644
index b7eba53bb..000000000
--- a/Artemis/Artemis/Modules/Games/WoW/Data/WoWPlayer.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Linq;
-using Process.NET;
-
-namespace Artemis.Modules.Games.WoW.Data
-{
- public class WoWPlayer : WoWUnit
- {
- private readonly IntPtr _targetIntPtr;
-
- public WoWPlayer(IProcess process, IntPtr baseAddress, IntPtr targetIntPtr, bool readPointer = false)
- : base(process, baseAddress, readPointer)
- {
- _targetIntPtr = targetIntPtr;
- }
-
- public WoWObject GetTarget(WoWObjectManager manager)
- {
- var targetGuid = Process.Memory.Read(Process.Native.MainModule.BaseAddress + _targetIntPtr.ToInt32());
- return manager.EnumVisibleObjects().FirstOrDefault(o => o.Guid == targetGuid);
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/WoW/Data/WoWStructs.cs b/Artemis/Artemis/Modules/Games/WoW/Data/WoWStructs.cs
deleted file mode 100644
index b16179265..000000000
--- a/Artemis/Artemis/Modules/Games/WoW/Data/WoWStructs.cs
+++ /dev/null
@@ -1,181 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-using Artemis.Modules.Games.WoW.Data.WowSharp.Client.Patchables;
-
-namespace Artemis.Modules.Games.WoW.Data
-{
- public static class WoWStructs
- {
- [StructLayout(LayoutKind.Explicit)]
- public struct ObjectData
- {
- // x32 : x64
- [FieldOffset(0)] private readonly IntPtr vtable; // 0x00 0x00
- [FieldOffset(10)] public IntPtr Descriptors; // 0x04 0x10
- [FieldOffset(18)] private readonly IntPtr unk1; // 0x08 0x18
- [FieldOffset(20)] public int ObjectType; // 0x0C 0x20
- [FieldOffset(24)] private readonly IntPtr unk3; // 0x10 0x24
- [FieldOffset(28)] private readonly IntPtr unk4; // 0x14 0x28
- [FieldOffset(30)] private readonly IntPtr unk5; // 0x18 0x30
- [FieldOffset(38)] private readonly IntPtr unk6; // 0x1C 0x38
- [FieldOffset(40)] private readonly IntPtr unk7; // 0x20 0x40
- [FieldOffset(48)] private readonly IntPtr unk8; // 0x24 0x48
- [FieldOffset(50)] public Guid Guid; // 0x28 0x50
- }
-
- public struct Guid
- {
- private readonly Int128 _mGuid;
-
- public static readonly Guid Zero = new Guid(0);
-
- public Guid(Int128 guid)
- {
- _mGuid = guid;
- }
-
- public override string ToString()
- {
- // ReSharper disable once SwitchStatementMissingSomeCases
- switch (Type)
- {
- case WoWEnums.GuidType.Creature:
- case WoWEnums.GuidType.Vehicle:
- case WoWEnums.GuidType.Pet:
- case WoWEnums.GuidType.GameObject:
- case WoWEnums.GuidType.AreaTrigger:
- case WoWEnums.GuidType.DynamicObject:
- case WoWEnums.GuidType.Corpse:
- case WoWEnums.GuidType.LootObject:
- case WoWEnums.GuidType.SceneObject:
- case WoWEnums.GuidType.Scenario:
- case WoWEnums.GuidType.AiGroup:
- case WoWEnums.GuidType.DynamicDoor:
- case WoWEnums.GuidType.Vignette:
- case WoWEnums.GuidType.Conversation:
- case WoWEnums.GuidType.CallForHelp:
- case WoWEnums.GuidType.AiResource:
- case WoWEnums.GuidType.AiLock:
- case WoWEnums.GuidType.AiLockTicket:
- return $"{Type}-{SubType}-{RealmId}-{MapId}-{ServerId}-{Id}-{CreationBits:X10}";
- case WoWEnums.GuidType.Player:
- return $"{Type}-{RealmId}-{(ulong) (_mGuid >> 64):X8}";
- case WoWEnums.GuidType.Item:
- return $"{Type}-{RealmId}-{(uint) ((_mGuid >> 18) & 0xFFFFFF)}-{(ulong) (_mGuid >> 64):X10}";
- //case GuidType.ClientActor:
- // return String.Format("{0}-{1}-{2}", Type, RealmId, CreationBits);
- //case GuidType.Transport:
- //case GuidType.StaticDoor:
- // return String.Format("{0}-{1}-{2}", Type, RealmId, CreationBits);
- default:
- return $"{Type}-{_mGuid:X32}";
- }
- }
-
- public override bool Equals(object obj)
- {
- if (obj is Guid)
- return _mGuid == ((Guid) obj)._mGuid;
- return false;
- }
-
- public override int GetHashCode()
- {
- return _mGuid.GetHashCode();
- }
-
- public WoWEnums.GuidType Type => (WoWEnums.GuidType) (byte) ((_mGuid >> 58) & 0x3F);
-
- public byte SubType => (byte) ((_mGuid >> 120) & 0x3F);
-
- public ushort RealmId => (ushort) ((_mGuid >> 42) & 0x1FFF);
-
- public ushort ServerId => (ushort) ((_mGuid >> 104) & 0x1FFF);
-
- public ushort MapId => (ushort) ((_mGuid >> 29) & 0x1FFF);
-
- // Creature, Pet, Vehicle
- public uint Id => (uint) ((_mGuid >> 6) & 0x7FFFFF);
-
- public ulong CreationBits => (ulong) ((_mGuid >> 64) & 0xFFFFFFFFFF);
- }
-
- #region Manager
-
- // Region is here due to the large amount of structs-
- // the CurremtManager struct depends on.
- [StructLayout(LayoutKind.Sequential)]
- public struct CurrentManager
- {
- public TsHashTable VisibleObjects; // m_objects
- public TsHashTable LazyCleanupObjects; // m_lazyCleanupObjects
-
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 13)]
- // m_lazyCleanupFifo, m_freeObjects, m_visibleObjects, m_reenabledObjects, whateverObjects...
- public TsExplicitList[] Links; // Links[13] has all objects stored in VisibleObjects it seems
-
-#if !X64
- public int Unknown1; // wtf is that and why x86 only?
-#endif
- public Int128 ActivePlayer;
- public int MapId;
- public IntPtr ClientConnection;
- public IntPtr MovementGlobals;
- public int Unk1;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct Ts
- {
- public IntPtr vtable;
- public uint m_alloc;
- public uint m_count;
- public IntPtr m_data; //TSExplicitList* m_data;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct TsExplicitList
- {
- public TsList baseClass;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct TsFixedArray
- {
- public Ts baseClass;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct TsGrowableArray
- {
- public TsFixedArray baseclass;
- public uint m_chunk;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct TsHashTable
- {
- public IntPtr vtable;
- public TsExplicitList m_fulllist;
- public int m_fullnessIndicator;
- public TsGrowableArray m_slotlistarray;
- public int m_slotmask;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct TsLink
- {
- public IntPtr m_prevlink; //TSLink *m_prevlink
- public IntPtr m_next; // C_OBJECTHASH *m_next
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct TsList
- {
- public int m_linkoffset;
- public TsLink m_terminator;
- }
-
- #endregion;
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/WoW/Data/WoWUnit.cs b/Artemis/Artemis/Modules/Games/WoW/Data/WoWUnit.cs
deleted file mode 100644
index c0c0f45bd..000000000
--- a/Artemis/Artemis/Modules/Games/WoW/Data/WoWUnit.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-using Process.NET;
-using static Artemis.Modules.Games.WoW.Data.WoWEnums;
-using static Artemis.Modules.Games.WoW.Data.WoWOffsets;
-
-namespace Artemis.Modules.Games.WoW.Data
-{
- public class WoWUnit : WoWObject
- {
- public WoWUnit(IProcess process, IntPtr baseAddress, bool readPointer = false)
- : base(process, baseAddress, readPointer)
- {
- }
-
- public int Health => ReadField(UnitData.Health);
- public int MaxHealth => ReadField(UnitData.MaxHealth);
- public int Power => ReadField(UnitData.Power);
- public int SecondaryPower => ReadField(UnitData.SecondaryPower);
- public int TertiaryPower => ReadField(UnitData.TertiaryPower);
- public int MaxPower => ReadField(UnitData.MaxPower);
- public PowerType PowerType => (PowerType) ReadField(UnitData.DisplayPower);
- public int Level => ReadField(UnitData.Level);
-
- public WoWDetails Details { get; set; }
-
- public void UpdateDetails(WoWNameCache nameCache)
- {
- Details = GetNpcDetails() ?? nameCache.GetNameByGuid(Guid);
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/WoW/WoWAddresses.cs b/Artemis/Artemis/Modules/Games/WoW/WoWAddresses.cs
deleted file mode 100644
index 487eeab04..000000000
--- a/Artemis/Artemis/Modules/Games/WoW/WoWAddresses.cs
+++ /dev/null
@@ -1,256 +0,0 @@
-namespace Artemis.Modules.Games.WoW
-{
- public static class WoWAddresses
- {
- public enum ActivateSettings
- {
- Activate_Offset = 0x34,
- AutoDismount_Activate_Pointer = 0xe56850,
- AutoInteract_Activate_Pointer = 0xe56848,
- AutoLoot_Activate_Pointer = 0xe56868,
- AutoSelfCast_Activate_Pointer = 0xe56874
- }
-
- public enum Battleground
- {
- MaxBattlegroundId = 0xec3fdc,
- PvpExitWindow = 0xec4198,
- StatPvp = 0xc3c03c
- }
-
- public enum Chat
- {
- chatBufferPos = 0xeb1bf0,
- chatBufferStart = 0xe58190,
- msgFormatedChat = 0x65,
- NextMessage = 0x17e8
- }
-
- public enum ClickToMove
- {
- CTM = 0xddf8f0,
- CTM_PUSH = 0xddf8ac,
- CTM_X = 0xddf918,
- CTM_Y = 0xddf91c,
- CTM_Z = 0xddf920
- }
-
- public enum CorpsePlayer
- {
- X = 0xe57894,
- Y = 0xe57898,
- Z = 0xe5789c
- }
-
- public enum DBC
- {
- FactionTemplate = 0,
- ItemClass = 0xd173c0,
- ItemSubClass = 0,
- Lock = 0,
- Map = 0xd291a0,
- QuestPOIPoint = 0xd1e950,
- ResearchSite = 0xd1d2d0,
- SpellCategories = 0,
- Unknown = 0xf35428
- }
-
- public enum EventsListener
- {
- BaseEvents = 0xcb2474,
- EventOffsetCount = 0x48,
- EventOffsetName = 0x18,
- EventsCount = 0xcb2470
- }
-
- public enum Fishing
- {
- BobberHasMoved = 0xf8
- }
-
- public enum FunctionWow
- {
- CGUnit_C__InitializeTrackingState = 0x30623b,
- CGUnit_C__Interact = 0x524ff,
- CGWorldFrame__Intersect = 0x5e46ab,
- ClntObjMgrGetActivePlayerObj = 0x816d7,
- FrameScript__GetLocalizedText = 0x300b48,
- FrameScript_ExecuteBuffer = 0xa6772,
- IsOutdoors = 0,
- Spell_C_HandleTerrainClick = 0x2b76ff,
- strlen = 0x74fcb0,
- UnitCanAttack = 0,
- WowClientDB2__GetRowPointer = 0x20c775
- }
-
- public enum GameInfo
- {
- AreaId = 0xc32c2c,
- buildWoWVersionString = 0xd002a8,
- gameState = 0xe56a49,
- GetTime = 0xcb2150,
- isLoading = 0xca59b0,
- LastHardwareAction = 0xd0e090,
- MapTextureId = 0xc3bd28,
- SubAreaId = 0xc32c24,
- subZoneMap = 0xe56a68,
- TextBoxActivated = 0xbbe9ac,
- zoneMap = 0xe56a64
- }
-
- public enum GameObject
- {
- CachedCastBarCaption = 12,
- CachedData0 = 20,
- CachedIconName = 8,
- CachedName = 180,
- CachedQuestItem1 = 0x9c,
- CachedSize = 0x98,
- DBCacheRow = 620,
- GAMEOBJECT_FIELD_X = 0x138,
- GAMEOBJECT_FIELD_Y = 0x13c,
- GAMEOBJECT_FIELD_Z = 320,
- PackedRotationQuaternion = 0x150,
- TransformationMatrice = 0x278
- }
-
- public enum Hooking
- {
- DX_DEVICE = 0xcc523c,
- DX_DEVICE_IDX = 0x2508,
- ENDSCENE_IDX = 0xa8
- }
-
- public enum Login
- {
- realmName = 0xf35e16
- }
-
- public enum MovementFlagsOffsets
- {
- Offset1 = 0x124,
- Offset2 = 0x40
- }
-
- public enum ObjectManager
- {
- continentId = 0x108,
- firstObject = 0xd8,
- localGuid = 0xf8,
- nextObject = 0x44,
- objectGUID = 0x30,
- objectTYPE = 0x10
- }
-
- public enum Party
- {
- NumOfPlayers = 200,
- NumOfPlayersSuBGroup = 0xcc,
- PartyOffset = 0xeb5458,
- PlayerGuid = 0x10
- }
-
- public enum PetBattle
- {
- IsInBattle = 0xba8a10
- }
-
- public enum Player
- {
- LocalPlayerSpellsOnCooldown = 0xd372b8,
- petGUID = 0xec7158,
- playerName = 0xf35e20,
- RetrieveCorpseWindow = 0xe576f4,
- RuneStartCooldown = 0xf18aa8,
- SkillMaxValue = 0x400,
- SkillValue = 0x200
- }
-
- public enum PlayerNameStore
- {
- PlayerNameNextOffset = 20,
- PlayerNameStorePtr = 0xd0b4e0,
- PlayerNameStringOffset = 0x11
- }
-
- public enum PowerIndex
- {
- Multiplicator = 0x10,
- PowerIndexArrays = 0xddf914
- }
-
- public enum Quests
- {
- QuestGiverStatus = 0xf4
- }
-
- public enum SpellBook
- {
- FirstTalentBookPtr = 0xeb52ec,
- KnownAllSpells = 0xeb5130,
- MountBookMountsPtr = 0xeb5194,
- MountBookNumMounts = 0xeb5190,
- NextTalentBookPtr = 0xeb52e4,
- SpellBookNumSpells = 0xeb5134,
- SpellBookSpellsPtr = 0xeb5138,
- SpellDBCMaxIndex = 0x30d40,
- TalentBookOverrideSpellId = 0x1c,
- TalentBookSpellId = 20
- }
-
- public enum UnitBaseGetUnitAura
- {
- AuraSize = 0x58,
- AuraStructCasterLevel = 0x3a,
- AuraStructCount = 0x39,
- AuraStructCreatorGuid = 0x20,
- AuraStructDuration = 60,
- AuraStructFlag = 0x34,
- AuraStructMask = 0x35,
- AuraStructSpellEndTime = 0x40,
- AuraStructSpellId = 0x30,
- AuraStructUnk1 = 0x3b,
- AuraStructUnk2 = 0x44,
- AuraTable1 = 0x1150,
- AuraTable2 = 0x580
- }
-
- public enum UnitField
- {
- CachedIsBoss = 0x60,
- CachedModelId1 = 0x6c,
- CachedName = 0x80,
- CachedQuestItem1 = 60,
- CachedSubName = 0,
- CachedTypeFlag = 0x24,
- CachedUnitClassification = 0x2c,
- CanInterrupt = 0xfc4,
- CanInterruptOffset = 0xe02ea0,
- CanInterruptOffset2 = 0xe02ea4,
- CanInterruptOffset3 = 0xe02ea8,
- CastingSpellEndTime = 0x108c,
- CastingSpellID = 0x1064,
- CastingSpellStartTime = 0x1088,
- ChannelSpellEndTime = 0x1098,
- ChannelSpellID = 0x1090,
- ChannelSpellStartTime = 0x1094,
- DBCacheRow = 0xc80,
- TransportGUID = 0xae8,
- UNIT_FIELD_R = 0xb08,
- UNIT_FIELD_X = 0xaf8,
- UNIT_FIELD_Y = 0xafc,
- UNIT_FIELD_Z = 0xb00
- }
-
- public enum VMT
- {
- CGUnit_C__GetFacing = 0x35
- }
-
- public class ObjectManagerClass
- {
- public static uint clientConnection;
- public static uint sCurMgr;
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/WoW/WoWDataModel.cs b/Artemis/Artemis/Modules/Games/WoW/WoWDataModel.cs
index 3edf73ecc..e64e8b39f 100644
--- a/Artemis/Artemis/Modules/Games/WoW/WoWDataModel.cs
+++ b/Artemis/Artemis/Modules/Games/WoW/WoWDataModel.cs
@@ -1,11 +1,159 @@
-using Artemis.Modules.Abstract;
-using Artemis.Modules.Games.WoW.Data;
+using System;
+using System.Collections.Generic;
+using Artemis.Modules.Abstract;
+using Castle.Components.DictionaryAdapter;
+using Newtonsoft.Json.Linq;
namespace Artemis.Modules.Games.WoW
{
public class WoWDataModel : ModuleDataModel
{
+ public WoWDataModel()
+ {
+ Player = new WoWUnit();
+ Target = new WoWUnit();
+ }
+
public WoWUnit Player { get; set; }
public WoWUnit Target { get; set; }
+ public string Realm { get; set; }
+ public string Zone { get; set; }
+ public string SubZone { get; set; }
}
-}
\ No newline at end of file
+
+ public class WoWUnit
+ {
+ public WoWUnit()
+ {
+ Buffs = new List();
+ Debuffs = new EditableList();
+ }
+
+ public string Name { get; set; }
+ public int Level { get; set; }
+ public int Health { get; set; }
+ public int MaxHealth { get; set; }
+ public int Power { get; set; }
+ public int MaxPower { get; set; }
+ public WoWPowerType PowerType { get; set; }
+ public WoWClass Class { get; set; }
+ public WoWRace Race { get; set; }
+ public WoWGender Gender { get; set; }
+ public List Buffs { get; set; }
+ public List Debuffs { get; set; }
+
+ public void ApplyJson(JObject json)
+ {
+ if (json["name"] == null)
+ return;
+
+ Name = json["name"].Value();
+ Level = json["level"].Value();
+ Class = (WoWClass) Enum.Parse(typeof(WoWClass), json["class"].Value().Replace(" ", ""));
+ Race = (WoWRace) Enum.Parse(typeof(WoWRace), json["race"].Value().Replace(" ", ""));
+ Gender = json["gender"].Value() == 3 ? WoWGender.Female : WoWGender.Male;
+ }
+
+ public void ApplyStateJson(JObject json)
+ {
+ Health = json["health"].Value();
+ MaxHealth = json["maxHealth"].Value();
+ PowerType = (WoWPowerType) Enum.Parse(typeof(WoWPowerType), json["powerType"].Value().ToString(), true);
+ Power = json["power"].Value();
+ MaxPower = json["maxPower"].Value();
+
+ Buffs.Clear();
+ foreach (var auraJson in json["buffs"].Children())
+ {
+ var aura = new WoWAura();
+ aura.ApplyJson(auraJson);
+ Buffs.Add(aura);
+ }
+ Debuffs.Clear();
+ foreach (var auraJson in json["debuffs"].Children())
+ {
+ var aura = new WoWAura();
+ aura.ApplyJson(auraJson);
+ Debuffs.Add(aura);
+ }
+ }
+ }
+
+ public class WoWAura
+ {
+ public string Name { get; set; }
+ public int Id { get; set; }
+ public string Caster { get; set; }
+ public int Stacks { get; set; }
+ public TimeSpan Duration { get; set; }
+ public TimeSpan Expires { get; set; }
+
+ public void ApplyJson(JToken buffJson)
+ {
+ Name = buffJson["name"].Value();
+ Id = buffJson["spellID"].Value();
+ Caster = buffJson["caster"].Value();
+ Stacks = buffJson["count"].Value();
+
+ // TODO: Duration
+ }
+ }
+
+ public enum WoWPowerType
+ {
+ Mana = 0,
+ Rage = 1,
+ Focus = 2,
+ Energy = 3,
+ ComboPoints = 4,
+ Runes = 5,
+ RunicPower = 6,
+ SoulShards = 7,
+ LunarPower = 8,
+ HolyPower = 9,
+ AlternatePower = 10,
+ Maelstrom = 11,
+ Chi = 12,
+ Insanity = 13,
+ ArcaneCharges = 16
+ }
+
+ public enum WoWClass
+ {
+ Warrior,
+ Paladin,
+ Hunter,
+ Rogue,
+ Priest,
+ DeathKnight,
+ Shaman,
+ Mage,
+ Warlock,
+ Druid,
+ Monk,
+ DemonHunter
+ }
+
+ public enum WoWRace
+ {
+ Human,
+ Orc,
+ Dwarf,
+ NightElf,
+ Undead,
+ Tauren,
+ Gnome,
+ Troll,
+ BloodElf,
+ Draenei,
+ Goblin,
+ Worgen,
+ Pandaren
+ }
+
+ public enum WoWGender
+ {
+ Male,
+ Female
+ }
+}
diff --git a/Artemis/Artemis/Modules/Games/WoW/WoWModel.cs b/Artemis/Artemis/Modules/Games/WoW/WoWModel.cs
index c50926dfa..3c31d23a0 100644
--- a/Artemis/Artemis/Modules/Games/WoW/WoWModel.cs
+++ b/Artemis/Artemis/Modules/Games/WoW/WoWModel.cs
@@ -1,21 +1,22 @@
using System;
+using System.Collections.Generic;
using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
using Artemis.DAL;
using Artemis.Managers;
using Artemis.Modules.Abstract;
-using Artemis.Modules.Games.WoW.Data;
-using Artemis.Settings;
-using Artemis.Utilities.Memory;
-using Process.NET;
-using Process.NET.Memory;
+using Newtonsoft.Json.Linq;
+using PcapDotNet.Core;
+using PcapDotNet.Packets;
namespace Artemis.Modules.Games.WoW
{
public class WoWModel : ModuleModel
{
- private readonly GamePointersCollection _pointer;
- private ProcessSharp _process;
-
+ private readonly Regex _rgx;
+ private PacketCommunicator _communicator;
public WoWModel(DeviceManager deviceManager, LuaManager luaManager) : base(deviceManager, luaManager)
{
@@ -23,94 +24,119 @@ namespace Artemis.Modules.Games.WoW
DataModel = new WoWDataModel();
ProcessNames.Add("Wow-64");
- // Currently WoW is locked behind a hidden trigger (obviously not that hidden since you're reading this)
- // It is using memory reading and lets first try to contact Blizzard
- var settings = SettingsProvider.Load();
- Settings.IsEnabled = settings.GamestatePort == 62575 && Settings.IsEnabled;
-
- _pointer = SettingsProvider.Load().WorldOfWarcraft;
- //_pointer = new GamePointersCollection
- //{
- // Game = "WorldOfWarcraft",
- // GameVersion = "7.0.3.22810",
- // GameAddresses = new List
- // {
- // new GamePointer
- // {
- // Description = "ObjectManager",
- // BasePointer = new IntPtr(0x1578070)
- // },
- // new GamePointer
- // {
- // Description = "LocalPlayer",
- // BasePointer = new IntPtr(0x169DF10)
- // },
- // new GamePointer
- // {
- // Description = "NameCache",
- // BasePointer = new IntPtr(0x151DCE8)
- // },
- // new GamePointer
- // {
- // Description = "TargetGuid",
- // BasePointer = new IntPtr(0x179C940)
- // }
- // }
- //};
- //var res = JsonConvert.SerializeObject(_pointer, Formatting.Indented);
+ _rgx = new Regex("(artemis)\\((.*?)\\)", RegexOptions.Compiled);
}
public override string Name => "WoW";
public override bool IsOverlay => false;
public override bool IsBoundToProcess => true;
+
+ public override void Enable()
+ {
+ // Start scanning WoW packets
+ // Retrieve the device list from the local machine
+ IList allDevices = LivePacketDevice.AllLocalMachine;
+
+ if (allDevices.Count == 0)
+ {
+ Logger.Warn("No interfaces found! Can't scan WoW packets.");
+ return;
+ }
+
+ // Take the selected adapter
+ PacketDevice selectedDevice = allDevices.First();
+
+ // Open the device
+ _communicator = selectedDevice.Open(65536, PacketDeviceOpenAttributes.Promiscuous, 100);
+ Logger.Debug("Listening on " + selectedDevice.Description + " for WoW packets");
+
+ // Compile the filter
+ using (var filter = _communicator.CreateFilter("tcp"))
+ {
+ // Set the filter
+ _communicator.SetFilter(filter);
+ }
+
+ Task.Run(() => ReceivePackets());
+ base.Enable();
+ }
+
+ private void ReceivePackets()
+ {
+ // start the capture
+ try
+ {
+ _communicator.ReceivePackets(0, PacketHandler);
+ }
+ catch (InvalidOperationException)
+ {
+ // ignored, happens on shutdown
+ }
+ }
+
+ private void PacketHandler(Packet packet)
+ {
+ // Ignore duplicates
+ if (packet.Ethernet.IpV4.Udp.SourcePort == 3724)
+ return;
+
+ var str = Encoding.Default.GetString(packet.Buffer);
+ if (str.ToLower().Contains("artemis"))
+ {
+ var match = _rgx.Match(str);
+ if (match.Groups.Count != 3)
+ return;
+
+ Logger.Debug("[{0}] {1}", packet.Ethernet.IpV4.Udp.SourcePort, match.Groups[2].Value);
+ // Get the command and argument
+ var parts = match.Groups[2].Value.Split('|');
+ HandleGameData(parts[0], parts[1]);
+ }
+ }
+
+ private void HandleGameData(string command, string data)
+ {
+ var json = JObject.Parse(data);
+ var dataModel = (WoWDataModel) DataModel;
+ switch (command)
+ {
+ case "player":
+ ParsePlayer(json, dataModel);
+ break;
+ case "target":
+ ParseTarget(json, dataModel);
+ break;
+ case "playerState":
+ ParsePlayerState(json, dataModel);
+ break;
+ }
+ }
+
+ private void ParsePlayer(JObject json, WoWDataModel dataModel)
+ {
+ dataModel.Player.ApplyJson(json);
+ }
+
+ private void ParseTarget(JObject json, WoWDataModel dataModel)
+ {
+ dataModel.Target.ApplyJson(json);
+ }
+
+ private void ParsePlayerState(JObject json, WoWDataModel dataModel)
+ {
+ dataModel.Player.ApplyStateJson(json);
+ }
+
public override void Dispose()
{
+ _communicator.Break();
+ _communicator.Dispose();
base.Dispose();
-
- _process?.Dispose();
- _process = null;
}
public override void Update()
{
- if (_process == null)
- {
- var tempProcess = MemoryHelpers.GetProcessIfRunning(ProcessNames[0]);
- if (tempProcess == null)
- return;
-
- _process = new ProcessSharp(tempProcess, MemoryType.Remote);
- }
-
- if (ProfileModel == null || DataModel == null || _process == null)
- return;
-
- var dataModel = (WoWDataModel) DataModel;
-
- var objectManager = new WoWObjectManager(_process,
- _pointer.GameAddresses.First(a => a.Description == "ObjectManager").BasePointer);
- var nameCache = new WoWNameCache(_process,
- _pointer.GameAddresses.First(a => a.Description == "NameCache").BasePointer);
- var player = new WoWPlayer(_process,
- _pointer.GameAddresses.First(a => a.Description == "LocalPlayer").BasePointer,
- _pointer.GameAddresses.First(a => a.Description == "TargetGuid").BasePointer, true);
-
- dataModel.Player = player;
- if (dataModel.Player != null && dataModel.Player.Guid != Guid.Empty)
- {
- dataModel.Player.UpdateDetails(nameCache);
- var target = player.GetTarget(objectManager);
- if (target == null)
- return;
-
- dataModel.Target = new WoWUnit(target.Process, target.BaseAddress);
- dataModel.Target.UpdateDetails(nameCache);
- }
- else
- {
- dataModel.Target = null;
- }
}
}
-}
\ No newline at end of file
+}
diff --git a/Artemis/Artemis/ViewModels/GamesViewModel.cs b/Artemis/Artemis/ViewModels/GamesViewModel.cs
index 68a5d6041..21914d534 100644
--- a/Artemis/Artemis/ViewModels/GamesViewModel.cs
+++ b/Artemis/Artemis/ViewModels/GamesViewModel.cs
@@ -1,9 +1,6 @@
using System.Collections.Generic;
using System.Linq;
-using Artemis.DAL;
-using Artemis.Managers;
using Artemis.Modules.Abstract;
-using Artemis.Settings;
using Artemis.ViewModels.Abstract;
namespace Artemis.ViewModels
@@ -16,18 +13,7 @@ namespace Artemis.ViewModels
{
DisplayName = "Games";
- // Currently WoW is locked behind a hidden trigger (obviously not that hidden since you're reading this)
- // It is using memory reading and lets first try to contact Blizzard
- if (SettingsProvider.Load().GamestatePort == 62575)
- {
- _vms = moduleViewModels.Where(m => m.ModuleModel.IsBoundToProcess)
- .OrderBy(g => g.DisplayName).ToList();
- }
- else
- {
- _vms = moduleViewModels.Where(m => m.ModuleModel.IsBoundToProcess && m.DisplayName != "WoW")
- .OrderBy(g => g.DisplayName).ToList();
- }
+ _vms = moduleViewModels.Where(m => m.ModuleModel.IsBoundToProcess).OrderBy(g => g.DisplayName).ToList();
}
protected override void OnActivate()
@@ -37,4 +23,4 @@ namespace Artemis.ViewModels
Items.AddRange(_vms);
}
}
-}
\ No newline at end of file
+}
diff --git a/Artemis/Artemis/lib/SDKDLL.dll b/Artemis/Artemis/lib/SDKDLL.dll
index a71619198..057316385 100644
Binary files a/Artemis/Artemis/lib/SDKDLL.dll and b/Artemis/Artemis/lib/SDKDLL.dll differ
diff --git a/Artemis/Artemis/packages.config b/Artemis/Artemis/packages.config
index d4e1ed0f9..cf23b3b03 100644
--- a/Artemis/Artemis/packages.config
+++ b/Artemis/Artemis/packages.config
@@ -24,6 +24,7 @@
+