aboutsummaryrefslogtreecommitdiff
path: root/runtime/VMProtect.Runtime/Tests
diff options
context:
space:
mode:
authorjmpoep <OriginalEntryPoint@qq.com>2023-12-07 16:51:07 +0800
committerjmpoep <OriginalEntryPoint@qq.com>2023-12-07 16:51:07 +0800
commit28008a746a31abb7909dd86cb0cd413ac8943b0b (patch)
treea30b74b8cad548048c3c1551d652828ab76fa9bd /runtime/VMProtect.Runtime/Tests
downloadvmprotect-3.5.1-master.tar
vmprotect-3.5.1-master.tar.gz
vmprotect-3.5.1-master.tar.bz2
vmprotect-3.5.1-master.zip
first commitHEADmaster
Diffstat (limited to 'runtime/VMProtect.Runtime/Tests')
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/LicensingManagerTests.cs122
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/LoaderTests.cs47
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/MsilToVmTestCompiler.cs100
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/Properties/AssemblyInfo.cs35
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/ElementedTypeHelper.cs172
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/MyBuffer.cs569
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/MyBufferReader.cs563
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/MyCollection.cs361
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/SdMetadataTokens.cs288
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/SdTemplateStuff.cs180
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/SimpleTypeHelper.cs26
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/StringDecryptor.cs648
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/TypeCompatibility.cs54
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VariantBase.cs2621
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VariantFactory.cs165
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmExecutor.cs7505
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmInstrCodesDb.cs899
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmMethodHeader.cs42
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmPosParser.cs96
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmStreamWrapper.cs116
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTest1.cs110
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTestCombine.cs1715
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTestProject.csproj159
-rw-r--r--runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTestProject.csproj.bak133
24 files changed, 16726 insertions, 0 deletions
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/LicensingManagerTests.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/LicensingManagerTests.cs
new file mode 100644
index 0000000..015a0a1
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/LicensingManagerTests.cs
@@ -0,0 +1,122 @@
+using System;
+using System.Collections.Generic;
+using System.Security.Cryptography;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using VMProtect;
+
+namespace UnitTestProject
+{
+ [TestClass]
+ public class LicensingManagerTests
+ {
+ private class Data
+ {
+ public void PushByte(byte b) { _data.Add(b); }
+ //void PushDWord(int d) { PushBuff(BitConverter.GetBytes(d)); }
+ /*void PushQWord(ulong q) { PushBuff(&q, sizeof(q)); }
+ void PushWord(ushort w) { PushBuff(&w, sizeof(w)); }*/
+ public void PushBuff(byte[] buff)
+ {
+ _data.AddRange(buff);
+ }
+ /*public void InsertByte(int position, byte value)
+ {
+ _data.Insert(position, value);
+ }*/
+
+ /*uint32_t ReadDWord(size_t nPosition) const
+ {
+ return *reinterpret_cast<const uint32_t *>(&m_vData[nPosition]);
+ }*/
+
+ public void WriteDWord(int position, int value)
+ {
+ foreach (var b in BitConverter.GetBytes(value))
+ {
+ _data[position++] = b;
+ }
+ }
+
+ public int Size => _data.Count;
+ //public void clear() { _data.Clear(); }
+ //public bool empty() { return _data.Count == 0; }
+ //void resize(int size) { _data.resize(size); }
+ //void resize(int size, uint8_t value) { m_vData.resize(size, value); }
+ public byte[] ToArray() { return _data.ToArray(); }
+
+ private readonly List<byte> _data;
+
+ public Data(int sz)
+ {
+ _data = new List<byte>(new byte[sz]);
+ }
+ }
+
+ [TestMethod]
+ public void ParseSerial()
+ {
+ //var key = new byte[] {1, 2, 3, 4, 5, 6, 7, 8};
+ var data = new Data(sizeof(uint) * (int)LicensingManager.Fields.Count);
+
+ var publicExp = Convert.FromBase64String("AAEAAQ==");
+ var modulus = Convert.FromBase64String("pwUqwaM8IOukyx06Lvi5YNQ70JE7pwg7K+pmM/vCe1CUseHKFM1v1m11geDjVsAt38AnaiFs3JhtTs80ySCIxOSyvMw6Cd52k6N6dn7LAx1mxQLJLhYeMMJYbplMHnMLwYN0+IO58OVbEqRyaJV2ExolnK2EYZL7QRXujGY7/sOoOMF3p6GsWJK6kkBJICIoL9hHWBQMO6/9rmls/+EhaWuP80Vx0+H2OlrQ58K+TJeyE393cvb4QufiEPpCNaB50Klee9QUnsjSW/bTnmGn4Bi5+cowRbawUY73Q5I58fMAXiH9ueDPuNMR9YKDgW9GxunLmYkbuwqIp/v7kw3cfMBM0ihhB0B8UhjyAMAGLzJWX3H/H6Zrz41g9PbPjTAxfsTaCrxoqjaTaO4zk9YsI//VX9Fhivcy913SevBpNandziGfYH/oHW2xDy9AfwkE1wuIBlLj7c/k8U1YmmRAmkoCzlmB7EU4ClNltboh1uARUQ6wW30upppnuYhGkTy7");
+ var black = Convert.FromBase64String("A7zybXsboP8UVQ4x8mCSPVlm4W8G2gMbKOiLDFIX28dpdl6AzdqGCxIeiXRfaPBgeGeyL1BB+3pLVJ9SGkjc/BXy1hYkjJCwacADVEWoR14blpa3hdx+R/WHe8uhS9ShV1hxviIKRt4UJbIjyqH7tMu2p8KuVbB0IwM0dFPnVujgNmNN2/BeOQl/RFMmD+TpLzFHetvt0Dx7rk8MKINv3SoyL97QWNvwCbL35JIZN5DtMdZ3MfO/fxz/1kSTNbccciqEljRiC74zMsNz2LNkf1hwxES96yGBsd2oOTe+DJx43j8iZ7UD75iwIGKoPxysOYnHTewT2ofK9d6SMl4rIyxt6TI+KzXppRyhVieHtEIo9/NIm7ABnkLTJvy4tjFftPocJP3E5v9ra8YBQ2y3PKz04BkesCeKiVPyBqy9phxHtjKpIimlm73GSfDMVZ+xgLsn/Ui6XSW8kB8ai+rEA1KFosfmsVPASiuXJAHJaNfY4ULKZWOfGcoPDh1KjhmFq7INiQaMy+rml/EiKv4p9k3vomv41ll5IoIVkxZaMY8Gtkl5UYWWJUMlJgphM9+LOkWCLX1fm7ZUiJbfHkmVTTFZ6SxhxoeO73yovFdt37I/17tbM0jjQjC1Q172ZPQmWPBP2NaPTXglJdkSKWYWw8pG6EJh+eRrfZ1USmdkU2TI0FUDSwJ2F2RSkObaDx4WFrBz0xddLmEl0XEJaQI/TTRZk5hQB/20NPzavgiAQ39p62LR7hZTqnR4zshiFv2sChe4x2p4XzBx4NKx1Zw6QaZrfwX47R3dc2K80jHIisj9Ltnr3qUgr5S0Nbp6+8BKB6RFcPuPAi24SVh7e5KgvoKNB/FzJqZnE9FCiryEeRbRwU26g3l+orZTM/jm1niFKlgrvdRweVqVza4JBnbeTGF2t8PstMH6Vx4+gpoJWyoQY6acm5MSFyl2DLXCcd6MmoRyp30Ge209zoOjj7c5PGRYxjiiUO04gaGhh7YyUp7VTHmd2llSQaKhsyw/7k3OqEKTinSRmdiDNsmfp8fOqtd388jGyhME6zzda8u1Ex6uvHkrk2arjVSeQk3XED4ZPqyRbLDZYGZcp9HheDdciX56rK39NTXetOWN8p4KW6aMa91EUTaCiafQVhO6dYzO+1ybRjOR7ND7nOnt9zUEerzNbIkCFT6uGTqtue0FZe4Zxunlv9D1mA4266xWfZfIPSzXD2cVAerBjr2BtYHOolDP1dRu1JcPwXGxOMiDL76x1NghovHsQxlwcfWT9CO+ywvhEkiwirt0UsTbACSslWD2sNLTdQ1aLNkqM9FjJzN7uKHk/J4OZtmNFRsxxZUvWYKYb/+q93FEsbMr5YfSPLlezvf6fL3k6tSKB5sFuk/rsgeBQYOwUGIKDRc8c0yNd8kEXOxvmzCGEv2/95Lh7XxXEUaHYKki7TR73v+H6pIiYmTOHg/Z9F4OjzHxb6HIUq6bzNywpzguJjBKqhnoRfJMwBr9P3NQ+CU5VaBXwxTlMWtW9Ihou7a+Hio34w2YGYdtr8BzMjT03VrAOtLH4V0HZj/UTAkTFaGDK/bdOAYXH/fz9GVBVU94hB86ii4e9ulYanZkiRJMDwTlNTup5jRVAR7/nM4H0Q0evDGRo7k4IP5CtLb6fg==");
+
+ data.WriteDWord((int)LicensingManager.Fields.PublicExpOffset * sizeof(uint), data.Size);
+ data.WriteDWord((int)LicensingManager.Fields.PublicExpSize * sizeof(uint), publicExp.Length);
+ data.PushBuff(publicExp);
+
+ data.WriteDWord((int)LicensingManager.Fields.ModulusOffset * sizeof(uint), data.Size);
+ data.WriteDWord((int)LicensingManager.Fields.ModulusSize * sizeof(uint), modulus.Length);
+ data.PushBuff(modulus);
+
+ data.WriteDWord((int)LicensingManager.Fields.BlacklistOffset * sizeof(uint), data.Size);
+ data.WriteDWord((int)LicensingManager.Fields.BlacklistSize * sizeof(uint), black.Length);
+ data.PushBuff(black);
+
+ var crcPos = data.Size;
+ data.WriteDWord((int)LicensingManager.Fields.CRCOffset * sizeof(uint), crcPos);
+ var size = crcPos + 16;
+
+ using (var hash = new SHA1Managed())
+ {
+ var p = hash.ComputeHash(data.ToArray());
+ for (var i = crcPos; i < size; i++)
+ {
+ data.PushByte(p[i - crcPos]);
+ }
+ }
+
+ var licensingManager = new LicensingManager(data.ToArray());
+ Assert.AreEqual(SerialState.Blacklisted, licensingManager.SetSerialNumber("H2GfYz579KQ5poUTxKRWsUd7o+1XSwaJrK7CmwG15rNuo3Wa+vy660rJkRaWTrELbyyIe2k15973P13WJvxDR8myQCMi8Pv9D9k9iblCTAZL9vOcX55g2Vk4i+x+DEDn601kjvkL7RvHug1SYq6GqKm4dnApwlGvbnSebSDwrhh0E5g9I/XA5pa7hQUQwcBoXq6A7e7Blj8FbJ1JBdYUJY7RavgFE9KYfTXn5ceCwPr0gR3A++W66amQdxWnFxyyOFwfCPuZDk+LCgqqAgMyj5PRPcLA3nanXLDLPGva1wa1EEP0qvx6yCSpDURP94GxQGY1xjPlZagbuLaYyWn7bb/sLsYNXVHE1a+YNFORn890tbZ1D6i+wTEa254oF3yKa5GYTQmRWJQR+OXqaTK/wNG4y8dAUisOmQpevrSrD7pQj7ZLGOChmw+KWB6SozSHtIMY665ji9tMP8mq8OUSVSZ9N9q3Zh/xnW0W8sGck5IzTr3JtT0a3iOXSYfijpmy"));
+ Assert.AreEqual(SerialState.Blacklisted, licensingManager.GetSerialNumberState());
+ var snd = new SerialNumberData();
+ Assert.IsTrue(licensingManager.GetSerialNumberData(snd));
+ Assert.AreEqual("", snd.EMail); //a20071234@163.com
+ Assert.AreEqual("", snd.UserName); //Su Ying
+ Assert.AreEqual(DateTime.MaxValue, snd.Expires);
+ Assert.AreEqual(DateTime.MaxValue, snd.MaxBuild);
+ Assert.AreEqual(0, snd.RunningTime);
+ Assert.AreEqual(SerialState.Blacklisted, snd.State);
+ Assert.AreEqual(0, snd.UserData.Length);
+
+ Assert.AreEqual(SerialState.Success, licensingManager.SetSerialNumber("V5z/4JRVkIhN/D7KkHUBfM2ww3VMxq4r7SgRViTG840294nBiqLer9QUyuX/oyS5sxwzgtMruYYK2n8PvrilVRhFj3rgoK67V + 0 / kJxNmypnWY + PbNurXbimp8KfTF6aOydLQyo26M2iRJhnPCXXInXB4QMi5dPNf41cdVelwt + C5hSfV7zPeJZRLbWv + AMScBJEmy1AW3AWUokfHUMSonq75LxBc3jLnDESz8UGTNWrIXSEiRjrueszSM7uGEmWemUjS + MzgL + F + DfsKNTc2KTEctprxQmxcJZsN4rZS0q8UJo3eA0HXgrrFlxYkLqgcq + 8 / 018W3l79nR17ZDQsUuJFfrElY8F6OGtbis2j9YyCszcWoKQLB3bSgWrKXPAlrEN4VuxMk0wbq + sYZLIt / npAmFheE7wHhnN1PubK84BpQFZKnkrIrsC43PJ2ss2WOQl / vqTxhTbbDyPEE69NW8R + fUanth5sglfableZjt4WH + hwgiGL + D8wHQlWgT7"));
+ Assert.AreEqual(SerialState.Success, licensingManager.GetSerialNumberState());
+ Assert.IsTrue(licensingManager.GetSerialNumberData(snd));
+ Assert.AreEqual("jleber@onvisionnetworks.com", snd.EMail);
+ Assert.AreEqual("Onvision Networks Limited", snd.UserName);
+ Assert.AreEqual(DateTime.MaxValue, snd.Expires);
+ Assert.AreEqual(new DateTime(2017, 4, 11), snd.MaxBuild);
+ Assert.AreEqual(0, snd.RunningTime);
+ Assert.AreEqual(SerialState.Success, snd.State);
+ Assert.AreEqual(1, snd.UserData.Length);
+ CollectionAssert.AreEqual(snd.UserData, new byte[] {4});
+ }
+
+ /*[TestMethod]
+ public void ParseSerialTimeLimitedHWID()
+ {
+ //TODO
+ }*/
+ }
+} \ No newline at end of file
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/LoaderTests.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/LoaderTests.cs
new file mode 100644
index 0000000..5ad8afa
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/LoaderTests.cs
@@ -0,0 +1,47 @@
+using System.Runtime.InteropServices;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using VMProtect;
+
+namespace UnitTestProject
+{
+ [TestClass]
+ public class LoaderTests
+ {
+ [TestMethod]
+ public void LzmaDecode()
+ {
+ byte[] properties =
+ {
+ 0x5d, 0, 0, 0, 1 // 5 bytes props
+ };
+ byte[] src =
+ {
+ 0x00, 0x4e, 0x3a, 0x46, 0xeb, 0xe0, 0x06, 0x71, 0xc9, 0xe1,
+ 0xe6, 0x37, 0xfd, 0x9b, 0xb6, 0xd0, 0x76, 0x3f, 0xc8, 0x73,
+ 0xee, 0x11, 0xb6, 0x41, 0xaa, 0xb1, 0x7b, 0x7b, 0xef, 0xc6,
+ 0x9f, 0xff, 0xf6, 0x1d, 0x28, 0x00 //36 bytes packed
+ };
+ byte [] dstExpected = { 0x9c, 0xe9, 0x57, 0xbe, 0x00, 0x00, 0xc3, 0xe9, 0x24, 0x2c, 0x01, 0x00, 0xe9, 0xef, 0x65, 0x00, 0x00, 0xe9, 0xc0, 0x41, 0x06, 0x00, 0xc3, 0x56, 0x57 };
+ var pinnedSrc = GCHandle.Alloc(src, GCHandleType.Pinned);
+ uint dstSize = 65536;
+ var dstPtr = Marshal.AllocHGlobal((int)dstSize);
+ try
+ {
+ dstSize = int.MaxValue;
+ uint srcSize /*= (uint)src.Length*/;
+ var res = Loader.LzmaDecode(dstPtr, pinnedSrc.AddrOfPinnedObject(), properties, ref dstSize, out srcSize);
+ Assert.AreEqual(true, res);
+ Assert.AreEqual(dstExpected.Length, (int)dstSize);
+ var dst = new byte[dstSize];
+ Marshal.Copy(dstPtr, dst, 0, (int)dstSize);
+ CollectionAssert.AreEqual(dstExpected, dst);
+ Assert.AreEqual(src.Length, (int)srcSize);
+ }
+ finally
+ {
+ pinnedSrc.Free();
+ Marshal.FreeHGlobal(dstPtr);
+ }
+ }
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/MsilToVmTestCompiler.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/MsilToVmTestCompiler.cs
new file mode 100644
index 0000000..1e205c5
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/MsilToVmTestCompiler.cs
@@ -0,0 +1,100 @@
+using System;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Runtime.ExceptionServices;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace UnitTestProject
+{
+ public abstract class MsilToVmTestCompiler
+ {
+ public enum LongEnum : long { Eval1 = 1, Evalm1 = -1 }
+ public enum ULongEnum : ulong { Evalm1 = 0xFFFFFFFFFFFFFFFF }
+ public enum ByteEnum : byte {}
+ public enum SByteEnum : sbyte { }
+ public enum IntEnum /*: int*/ { }
+ public enum UIntEnum : uint { }
+ public enum ShortEnum : short { }
+ public enum UShortEnum : ushort { }
+
+ public static byte[] GetIlBytes(DynamicMethod dynamicMethod)
+ {
+ // ReSharper disable once PossibleNullReferenceException
+ var resolver = typeof(DynamicMethod).GetField("m_resolver", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(dynamicMethod);
+ if (resolver == null) throw new ArgumentException("The dynamic method's IL has not been finalized.");
+ // ReSharper disable once PossibleNullReferenceException
+ return (byte[])resolver.GetType().GetField("m_code", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(resolver);
+ }
+
+ public abstract Stream CreateVmStream(Type rt, ParameterInfo[] pi, Type[] locals, byte[] ilBytes);
+
+ public enum InvokeTestCombineError
+ {
+ NoError,
+ NoErrorByStdEx, // текущий стандарт ECMA-335 оставляет некоторые сценарии как "неопределенное поведение", но их можно определить
+ VmOtherExceptionExpected,
+ VmOtherTypeExpected,
+ VmOtherValueExpected,
+ Cnt
+ };
+ // dyn/vm обязаны что-то возвратить, либо выбросить исключение
+ // (в тестах не должно быть методов, возвращающих void, null или исключение в качестве retVal)
+ [HandleProcessCorruptedStateExceptions]
+ public InvokeTestCombineError InvokeTestCombine(DynamicMethod dyn, object[] parameters, out object dynRet, out object vmRet, out string err)
+ {
+ Type exceptionType = null;
+ err = "";
+ try
+ {
+ dynRet = dyn.Invoke(null, parameters);
+ Assert.IsNotNull(dynRet);
+ Assert.IsInstanceOfType(dynRet, dyn.ReturnType);
+ }
+ catch (Exception e)
+ {
+ Assert.IsInstanceOfType(e, typeof(TargetInvocationException));
+ Assert.IsNotNull(e.InnerException);
+ exceptionType = e.InnerException.GetType();
+ dynRet = e.InnerException;
+ }
+ var vmStream = CreateVmStream(dyn.ReturnType, dyn.GetBaseDefinition().GetParameters(),
+ //FIXME dyn.GetMethodBody().LocalVariables.Select(o => o.LocalType).ToArray(),
+ new Type[] {},
+ GetIlBytes(dyn));
+ try
+ {
+ vmRet = Invoke(parameters, vmStream);
+ if(exceptionType != null)
+ {
+ err = $"VmOtherExceptionExpected: {exceptionType.FullName}, actual: {vmRet}";
+ return InvokeTestCombineError.VmOtherExceptionExpected;
+ }
+ if (vmRet == null || vmRet.GetType() != dyn.ReturnType)
+ {
+ err = $"VmOtherTypeExpected: {dyn.ReturnType.FullName}, actual: {((vmRet != null) ? vmRet.GetType().FullName : "null")}";
+ return InvokeTestCombineError.VmOtherTypeExpected;
+ }
+ }
+ catch (Exception e)
+ {
+ vmRet = e;
+ if (e.GetType() != exceptionType)
+ {
+ err = $"VmOtherExceptionExpected: {((exceptionType != null) ? exceptionType.FullName : dynRet)}, actual: {e.GetType().FullName}";
+ return InvokeTestCombineError.VmOtherExceptionExpected;
+ }
+ return InvokeTestCombineError.NoError;
+ }
+ if (dynRet.Equals(vmRet))
+ {
+ return InvokeTestCombineError.NoError;
+ }
+ err = $"VmOtherValueExpected: {dynRet}, actual: {vmRet}";
+ return InvokeTestCombineError.VmOtherValueExpected;
+ }
+
+ public abstract object Invoke(object[] parameters, Stream vmStream);
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/Properties/AssemblyInfo.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..cb78989
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("UnitTestProject")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("UnitTestProject")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("aefca063-245a-4d50-a5a3-82188ce677fa")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/ElementedTypeHelper.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/ElementedTypeHelper.cs
new file mode 100644
index 0000000..b1dc170
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/ElementedTypeHelper.cs
@@ -0,0 +1,172 @@
+using System;
+using System.Diagnostics;
+
+namespace UnitTestProject.RefVm
+{
+ // Token: 0x02000048 RID: 72
+ internal static class ElementedTypeHelper // \u0008\u2005
+ {
+ // Token: 0x06000307 RID: 775 RVA: 0x000148D8 File Offset: 0x00012AD8
+ public static Type TryGoToElementType(Type t) // \u0002
+ {
+ if (t.IsByRef || t.IsArray || t.IsPointer)
+ {
+ return TryGoToElementType(t.GetElementType());
+ }
+ return t;
+ }
+
+ // Token: 0x06000308 RID: 776 RVA: 0x00014900 File Offset: 0x00012B00
+ public static Type TryGoToPointerOrReferenceElementType(Type t) // \u0003
+ {
+ if (t.HasElementType && !t.IsArray)
+ {
+ t = t.GetElementType();
+ }
+ return t;
+ }
+
+ // Token: 0x06000309 RID: 777 RVA: 0x00014920 File Offset: 0x00012B20
+ public static MyCollection<ElementedTypeDescrItem> NestedElementTypes(Type type) // \u0002
+ {
+ var collection = new MyCollection<ElementedTypeDescrItem>();
+ while (true)
+ {
+ Debug.Assert(type != null, "type != null");
+ if(type == null) return collection;
+ if (type.IsArray)
+ {
+ collection.PushBack(new ElementedTypeDescrItem
+ {
+ K = ElementedTypeDescrItem.Kind.Array1,
+ ArrayRank = type.GetArrayRank()
+ });
+ }
+ else if (type.IsByRef)
+ {
+ collection.PushBack(new ElementedTypeDescrItem
+ {
+ K = ElementedTypeDescrItem.Kind.ByRef2
+ });
+ }
+ else
+ {
+ if (!type.IsPointer)
+ {
+ break;
+ }
+ collection.PushBack(new ElementedTypeDescrItem
+ {
+ K = ElementedTypeDescrItem.Kind.Ponter0
+ });
+ }
+ type = type.GetElementType();
+ }
+ return collection;
+ }
+
+ // Token: 0x0600030A RID: 778 RVA: 0x000149B0 File Offset: 0x00012BB0
+ public static MyCollection<ElementedTypeDescrItem> NestedElementTypes(string text) // \u0002
+ {
+ var collection = new MyCollection<ElementedTypeDescrItem>();
+ while (true)
+ {
+ if (text.EndsWith(StringDecryptor.GetString(-1550346966) /* & */, StringComparison.Ordinal))
+ {
+ collection.PushBack(new ElementedTypeDescrItem
+ {
+ K = ElementedTypeDescrItem.Kind.ByRef2
+ });
+ text = text.Substring(0, text.Length - 1);
+ }
+ else if (text.EndsWith(StringDecryptor.GetString(-1550346958) /* * */, StringComparison.Ordinal))
+ {
+ collection.PushBack(new ElementedTypeDescrItem
+ {
+ K = ElementedTypeDescrItem.Kind.Ponter0
+ });
+ text = text.Substring(0, text.Length - 1);
+ }
+ else if (text.EndsWith(StringDecryptor.GetString(-1550346950) /* [] */, StringComparison.Ordinal))
+ {
+ collection.PushBack(new ElementedTypeDescrItem
+ {
+ K = ElementedTypeDescrItem.Kind.Array1,
+ ArrayRank = 1
+ });
+ text = text.Substring(0, text.Length - 2);
+ }
+ else
+ {
+ if (!text.EndsWith(StringDecryptor.GetString(-1550346811) /* ,] */, StringComparison.Ordinal))
+ {
+ return collection;
+ }
+ var rank = 1;
+ var remainLen = -1;
+ for (var i = text.Length - 2; i >= 0; i--)
+ {
+ var c = text[i];
+ if (c != ',')
+ {
+ if (c != '[')
+ {
+ throw new InvalidOperationException(StringDecryptor.GetString(-1550346804) /* VM-3012 */);
+ }
+ remainLen = i;
+ i = -1;
+ }
+ else
+ {
+ rank++;
+ }
+ }
+ if (remainLen < 0)
+ {
+ throw new InvalidOperationException(StringDecryptor.GetString(-1550346790) /* VM-3014 */);
+ }
+ text = text.Substring(0, remainLen);
+ collection.PushBack(new ElementedTypeDescrItem
+ {
+ K = ElementedTypeDescrItem.Kind.Array1,
+ ArrayRank = rank
+ });
+ }
+ }
+ }
+
+ // Token: 0x0600030B RID: 779 RVA: 0x00014B30 File Offset: 0x00012D30
+ public static Type PopType(Type type, MyCollection<ElementedTypeDescrItem> descr) // \u0002
+ {
+ while (descr.Count > 0)
+ {
+ var p = descr.PopBack();
+ switch (p.K)
+ {
+ case ElementedTypeDescrItem.Kind.Ponter0:
+ type = type.MakePointerType();
+ break;
+ case ElementedTypeDescrItem.Kind.Array1:
+ type = (p.ArrayRank == 1) ? type.MakeArrayType() : type.MakeArrayType(p.ArrayRank);
+ break;
+ case ElementedTypeDescrItem.Kind.ByRef2:
+ type = type.MakeByRefType();
+ break;
+ }
+ }
+ return type;
+ }
+ }
+
+ // Token: 0x02000054 RID: 84
+ internal struct ElementedTypeDescrItem // \u000E\u2005
+ {
+ internal enum Kind { Ponter0, Array1, ByRef2 }
+
+ // Token: 0x04000183 RID: 387
+ public Kind K; // \u0002
+
+ // Token: 0x04000184 RID: 388
+ public int ArrayRank; // \u0003
+ }
+} \ No newline at end of file
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/MyBuffer.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/MyBuffer.cs
new file mode 100644
index 0000000..6fd4104
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/MyBuffer.cs
@@ -0,0 +1,569 @@
+using System;
+using System.IO;
+using System.Runtime.InteropServices;
+
+namespace UnitTestProject.RefVm
+{
+ // Token: 0x02000024 RID: 36
+ internal sealed class MyBuffer : IDisposable // \u0005\u2007
+ {
+ // Token: 0x060000F2 RID: 242 RVA: 0x000051C8 File begin: 0x000033C8
+ public MyBuffer() : this(0)
+ {
+ }
+
+ // Token: 0x060000F3 RID: 243 RVA: 0x000051D4 File begin: 0x000033D4
+ public MyBuffer(int sz)
+ {
+ if (sz < 0)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ _data = new byte[sz];
+ _size = sz;
+ _internal = true;
+ _writable = true;
+ _begin = 0;
+ _valid = true;
+ }
+
+ // Token: 0x060000F4 RID: 244 RVA: 0x00005220 File begin: 0x00003420
+ public MyBuffer(byte[] src) : this(src, true)
+ {
+ }
+
+ // Token: 0x060000F5 RID: 245 RVA: 0x0000522C File begin: 0x0000342C
+ public MyBuffer(byte[] src, bool writable)
+ {
+ if (src == null)
+ {
+ throw new ArgumentNullException();
+ }
+ _data = src;
+ _end = (_size = src.Length);
+ _writable = writable;
+ _begin = 0;
+ _valid = true;
+ }
+
+ // Token: 0x060000F6 RID: 246 RVA: 0x00005278 File begin: 0x00003478
+ public MyBuffer(byte[] src, int begin, int count) : this(src, begin, count, true)
+ {
+ }
+
+ // Token: 0x060000F7 RID: 247 RVA: 0x00005284 File begin: 0x00003484
+ public MyBuffer(byte[] src, int begin, int count, bool writable)
+ {
+ if (src == null)
+ {
+ throw new ArgumentNullException();
+ }
+ if (begin < 0)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (count < 0)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (src.Length - begin < count)
+ {
+ throw new ArgumentException();
+ }
+ _data = src;
+ _cursor = begin;
+ _begin = begin;
+ _end = (_size = begin + count);
+ _writable = writable;
+ _internal = false;
+ _valid = true;
+ }
+
+ // Token: 0x060000F8 RID: 248 RVA: 0x00005304 File begin: 0x00003504
+ public bool IsValid() // \u0002
+ {
+ return _valid;
+ }
+
+ // Token: 0x060000F9 RID: 249 RVA: 0x0000530C File begin: 0x0000350C
+ public bool IsValid2() // \u0003
+ {
+ return _valid;
+ }
+
+ // Token: 0x060000FA RID: 250 RVA: 0x00005314 File begin: 0x00003514
+ public bool IsWritable() // \u0005
+ {
+ return _writable;
+ }
+
+ // Token: 0x060000FB RID: 251 RVA: 0x0000531C File begin: 0x0000351C
+ public void DoDispose() // \u0002
+ {
+ Dispose(true);
+ // ReSharper disable once GCSuppressFinalizeForTypeWithoutDestructor
+ GC.SuppressFinalize(this);
+ }
+
+ // Token: 0x060000FC RID: 252 RVA: 0x0000532C File begin: 0x0000352C
+ public void Dispose()
+ {
+ Dispose(false);
+ }
+
+ // Token: 0x060000FD RID: 253 RVA: 0x00005334 File begin: 0x00003534
+ private void Dispose(bool disposing) // \u0002
+ {
+ if (!_disposed)
+ {
+ if (disposing)
+ {
+ _valid = false;
+ _writable = false;
+ _internal = false;
+ }
+ _disposed = true;
+ }
+ }
+
+ // Token: 0x060000FE RID: 254 RVA: 0x00005360 File begin: 0x00003560
+ private bool Expand(int newSize) // \u0002
+ {
+ if (newSize < 0)
+ {
+ throw new IOException();
+ }
+ if (newSize > _size)
+ {
+ if (newSize < 256)
+ {
+ newSize = 256;
+ }
+ if (newSize < _size * 2)
+ {
+ newSize = _size * 2;
+ }
+ ExpandExact(newSize);
+ return true;
+ }
+ return false;
+ }
+
+ // Token: 0x060000FF RID: 255 RVA: 0x000053B0 File begin: 0x000035B0
+ public void DoNothing() // \u0003
+ {}
+
+ // Token: 0x06000100 RID: 256 RVA: 0x000053B4 File begin: 0x000035B4
+ internal byte[] Data() // \u0002
+ {
+ return _data;
+ }
+
+ // Token: 0x06000101 RID: 257 RVA: 0x000053BC File begin: 0x000035BC
+ internal void GetRanges(out int begin, out int end) // \u0002
+ {
+ if (!_valid)
+ {
+ throw new Exception();
+ }
+ begin = _begin;
+ end = _end;
+ }
+
+ // Token: 0x06000102 RID: 258 RVA: 0x000053DC File begin: 0x000035DC
+ internal int GetCursor() // \u0002
+ {
+ if (!_valid)
+ {
+ throw new Exception();
+ }
+ return _cursor;
+ }
+
+ // Token: 0x06000103 RID: 259 RVA: 0x000053F4 File begin: 0x000035F4
+ public int SkipBytes(int cnt) // \u0002
+ {
+ if (!_valid)
+ {
+ throw new Exception();
+ }
+ var num = _end - _cursor;
+ if (num > cnt)
+ {
+ num = cnt;
+ }
+ if (num < 0)
+ {
+ num = 0;
+ }
+ _cursor += num;
+ return num;
+ }
+
+ // Token: 0x06000104 RID: 260 RVA: 0x00005438 File begin: 0x00003638
+ public int Capacity() // \u0003
+ {
+ if (!_valid)
+ {
+ throw new Exception();
+ }
+ return _size - _begin;
+ }
+
+ // Token: 0x06000105 RID: 261 RVA: 0x00005458 File begin: 0x00003658
+ public void ExpandExact(int newSize) // \u0002
+ {
+ if (!_valid)
+ {
+ throw new Exception();
+ }
+ if (newSize != _size)
+ {
+ if (!_internal)
+ {
+ throw new Exception();
+ }
+ if (newSize < _end)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (newSize > 0)
+ {
+ var dst = new byte[newSize];
+ if (_end > 0)
+ {
+ Buffer.BlockCopy(_data, 0, dst, 0, _end);
+ }
+ _data = dst;
+ }
+ else
+ {
+ _data = null;
+ }
+ _size = newSize;
+ }
+ }
+
+ // Token: 0x06000106 RID: 262 RVA: 0x000054D8 File begin: 0x000036D8
+ public long UsedSize() // \u0002
+ {
+ if (!_valid)
+ {
+ throw new Exception();
+ }
+ return _end - _begin;
+ }
+
+ // Token: 0x06000107 RID: 263 RVA: 0x000054F8 File begin: 0x000036F8
+ public long GetPos() // \u0003
+ {
+ if (!_valid)
+ {
+ throw new Exception();
+ }
+ return _cursor - _begin;
+ }
+
+ // Token: 0x06000108 RID: 264 RVA: 0x00005518 File begin: 0x00003718
+ public void SetPos(long newPos) // \u0002
+ {
+ if (!_valid)
+ {
+ throw new Exception();
+ }
+ if (newPos < 0L)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (newPos > 2147483647L)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ _cursor = _begin + (int)newPos;
+ }
+
+ // Token: 0x06000109 RID: 265 RVA: 0x00005554 File begin: 0x00003754
+ public int Read([In] [Out] byte[] dest, int offset, int cnt) // \u0002
+ {
+ if (!_valid)
+ {
+ throw new Exception();
+ }
+ if (dest == null)
+ {
+ throw new ArgumentNullException();
+ }
+ if (offset < 0)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (cnt < 0)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (dest.Length - offset < cnt)
+ {
+ throw new ArgumentException();
+ }
+ var num = _end - _cursor;
+ if (num > cnt)
+ {
+ num = cnt;
+ }
+ if (num <= 0)
+ {
+ return 0;
+ }
+ if (num <= 8)
+ {
+ var num2 = num;
+ while (--num2 >= 0)
+ {
+ dest[offset + num2] = _data[_cursor + num2];
+ }
+ }
+ else
+ {
+ Buffer.BlockCopy(_data, _cursor, dest, offset, num);
+ }
+ _cursor += num;
+ return num;
+ }
+
+ // Token: 0x0600010A RID: 266 RVA: 0x00005600 File begin: 0x00003800
+ public int ReadByte() // \u0005
+ {
+ if (!_valid)
+ {
+ throw new Exception();
+ }
+ if (_cursor >= _end)
+ {
+ return -1;
+ }
+ var num = _cursor;
+ _cursor = num + 1;
+ return _data[num];
+ }
+
+ // Token: 0x0600010B RID: 267 RVA: 0x00005644 File begin: 0x00003844
+ public long Seek(long distance, SeekOrigin org) // \u0002
+ {
+ if (!_valid)
+ {
+ throw new Exception();
+ }
+ if (distance > 2147483647L)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ switch (org)
+ {
+ case SeekOrigin.Begin:
+ if (distance < 0L)
+ {
+ throw new IOException();
+ }
+ _cursor = _begin + (int)distance;
+ break;
+ case SeekOrigin.Current:
+ if (distance + _cursor < _begin)
+ {
+ throw new IOException();
+ }
+ _cursor += (int)distance;
+ break;
+ case SeekOrigin.End:
+ if (_end + distance < _begin)
+ {
+ throw new IOException();
+ }
+ _cursor = _end + (int)distance;
+ break;
+ default:
+ throw new ArgumentException();
+ }
+ return _cursor;
+ }
+
+ // Token: 0x0600010C RID: 268 RVA: 0x00005700 File begin: 0x00003900
+ public void LazyShrink(long newCount) // \u0003
+{
+ if (!_writable)
+ {
+ throw new Exception();
+ }
+ if (newCount > 2147483647L)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (newCount < 0L || newCount > 2147483647 - _begin)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ var num = _begin + (int)newCount;
+ if (!Expand(num) && num > _end)
+ {
+ Array.Clear(_data, _end, num - _end);
+ }
+ _end = num;
+ if (_cursor > num)
+ {
+ _cursor = num;
+ }
+ }
+
+ // Token: 0x0600010D RID: 269 RVA: 0x00005794 File begin: 0x00003994
+ public byte[] ToArray() // \u0003
+ {
+ var array = new byte[_end - _begin];
+ Buffer.BlockCopy(_data, _begin, array, 0, _end - _begin);
+ return array;
+ }
+
+ // Token: 0x0600010E RID: 270 RVA: 0x000057D8 File begin: 0x000039D8
+ public void Write(byte[] src, int offset, int cnt) // \u0002
+ {
+ if (!_valid)
+ {
+ throw new Exception();
+ }
+ if (!_writable)
+ {
+ throw new Exception();
+ }
+ if (src == null)
+ {
+ throw new ArgumentNullException();
+ }
+ if (offset < 0)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (cnt < 0)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (src.Length - offset < cnt)
+ {
+ throw new ArgumentException();
+ }
+ var num = _cursor + cnt;
+ if (num < 0)
+ {
+ throw new IOException();
+ }
+ if (num > _end)
+ {
+ var flag = _cursor > _end;
+ if (num > _size && Expand(num))
+ {
+ flag = false;
+ }
+ if (flag)
+ {
+ Array.Clear(_data, _end, num - _end);
+ }
+ _end = num;
+ }
+ if (cnt <= 8)
+ {
+ while (--cnt >= 0)
+ {
+ _data[_cursor + cnt] = src[offset + cnt];
+ }
+ }
+ else
+ {
+ Buffer.BlockCopy(src, offset, _data, _cursor, cnt);
+ }
+ _cursor = num;
+ }
+
+ // Token: 0x0600010F RID: 271 RVA: 0x000058D0 File begin: 0x00003AD0
+ public void AppendByte(byte b) // \u0002
+ {
+ if (!_valid)
+ {
+ throw new Exception();
+ }
+ if (!_writable)
+ {
+ throw new Exception();
+ }
+ if (_cursor >= _end)
+ {
+ var num = _cursor + 1;
+ var flag = _cursor > _end;
+ if (num >= _size && Expand(num))
+ {
+ flag = false;
+ }
+ if (flag)
+ {
+ Array.Clear(_data, _end, _cursor - _end);
+ }
+ _end = num;
+ }
+ _data[_cursor] = b;
+ _cursor++;
+ }
+
+ // Token: 0x06000110 RID: 272 RVA: 0x00005974 File begin: 0x00003B74
+ public void WriteTo(Stream s) // \u0002
+ {
+ if (!_valid)
+ {
+ throw new Exception();
+ }
+ if (s == null)
+ {
+ throw new ArgumentNullException();
+ }
+ s.Write(_data, _begin, _end - _begin);
+ }
+
+ // Token: 0x06000111 RID: 273 RVA: 0x000059AC File begin: 0x00003BAC
+ internal int ReadInt32() // \u0008
+ {
+ if (!_valid)
+ {
+ throw new Exception();
+ }
+ var num = _cursor += 4;
+ if (num > _end)
+ {
+ _cursor = _end;
+ throw new Exception();
+ }
+ return _data[num - 2] | _data[num - 3] << 24 | _data[num - 1] << 8 | _data[num - 4] << 16;
+ }
+
+ // Token: 0x04000034 RID: 52
+ private byte[] _data; // \u0002
+
+ // Token: 0x04000035 RID: 53
+ private readonly int _begin; // \u0003
+
+ // Token: 0x04000036 RID: 54
+ private int _cursor; // \u0005
+
+ // Token: 0x04000037 RID: 55
+ private int _end; // \u0008
+
+ // Token: 0x04000038 RID: 56
+ private int _size; // \u0006
+
+ // Token: 0x04000039 RID: 57
+ private bool _internal; // \u000E
+
+ // Token: 0x0400003A RID: 58
+ private bool _writable; // \u000F
+
+ // Token: 0x0400003B RID: 59
+ private bool _valid; // \u0002\u2000
+
+ // Token: 0x0400003C RID: 60
+ private bool _disposed; // \u0003\u2000
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/MyBufferReader.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/MyBufferReader.cs
new file mode 100644
index 0000000..58226bb
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/MyBufferReader.cs
@@ -0,0 +1,563 @@
+using System;
+using System.IO;
+using System.Text;
+using forms_cil;
+
+namespace UnitTestProject.RefVm
+{
+ // Token: 0x0200000A RID: 10
+ internal sealed class MyBufferReader : IDisposable // \u0002\u2007
+ {
+ // Token: 0x0400000C RID: 12
+ private MyBuffer _src; // \u0002
+
+ // Token: 0x0400000D RID: 13
+ private byte[] _inputRawBuf; // \u0003
+
+ // Token: 0x0400000E RID: 14
+ private Decoder _decoder; // \u0005
+
+ // Token: 0x0400000F RID: 15
+ private byte[] _inputCharRawBuf; // \u0008
+
+ // Token: 0x04000010 RID: 16
+ private char[] _inputCharsDecoded; // \u0006
+
+ // Token: 0x04000011 RID: 17
+ private char[] _stringChunk; // \u000E
+
+ // Token: 0x04000012 RID: 18
+ private readonly int _maxCharsIn128Bytes; // \u000F
+
+ // Token: 0x04000013 RID: 19
+ private readonly bool _isUnicode; // \u0002\u2000
+
+ // Token: 0x04000014 RID: 20
+ private readonly bool _alwaysTrue; // \u0003\u2000
+
+ // Token: 0x06000034 RID: 52 RVA: 0x000027C8 File Offset: 0x000009C8
+ public MyBufferReader(MyBuffer src) : this(src, new UTF8Encoding())
+ {
+ }
+
+ // Token: 0x06000035 RID: 53 RVA: 0x000027D8 File Offset: 0x000009D8
+ private MyBufferReader(MyBuffer src, Encoding encoding)
+ {
+ if (src == null)
+ {
+ throw new ArgumentNullException();
+ }
+ if (encoding == null)
+ {
+ throw new ArgumentNullException();
+ }
+ if (!src.IsValid())
+ {
+ throw new ArgumentException();
+ }
+ _src = src;
+ _decoder = encoding.GetDecoder();
+ _maxCharsIn128Bytes = encoding.GetMaxCharCount(128);
+ var num = encoding.GetMaxByteCount(1);
+ if (num < 16)
+ num = 16;
+ _inputRawBuf = new byte[num];
+ _stringChunk = null;
+ _inputCharRawBuf = null;
+ _isUnicode = (encoding is UnicodeEncoding);
+ _alwaysTrue = (_src != null);
+ }
+
+ // Token: 0x06000036 RID: 54 RVA: 0x00002878 File Offset: 0x00000A78
+ public MyBuffer GetBuffer() // \u0002
+ {
+ return _src;
+ }
+
+ // Token: 0x06000037 RID: 55 RVA: 0x00002880 File Offset: 0x00000A80
+ public void Dispose() // \u0002
+ {
+ DoDispose(true);
+ }
+
+ // Token: 0x06000038 RID: 56 RVA: 0x0000288C File Offset: 0x00000A8C
+ private void DoDispose(bool disposing) // \u0002
+ {
+ if (disposing)
+ _src?.DoDispose();
+ _src = null;
+ _inputRawBuf = null;
+ _decoder = null;
+ _inputCharRawBuf = null;
+ _inputCharsDecoded = null;
+ _stringChunk = null;
+ }
+
+ // Token: 0x06000039 RID: 57 RVA: 0x000028E0 File Offset: 0x00000AE0
+ void IDisposable.Dispose() // \u0002\u2007\u2008\u2000\u2002\u200A\u0003
+ {
+ DoDispose(true);
+ }
+
+ // Token: 0x0600003A RID: 58 RVA: 0x000028EC File Offset: 0x00000AEC
+ public int PeekUnicodeChar() // \u0002
+ {
+ SrcPrecondition();
+ if (!_src.IsValid2())
+ {
+ return -1;
+ }
+ var pos = _src.GetPos();
+ var ret = SafeReadUnicodeChar();
+ _src.SetPos(pos);
+ return ret;
+ }
+
+ // Token: 0x06000051 RID: 81 RVA: 0x00002FE8 File Offset: 0x000011E8
+ private void SrcPrecondition() // \u0005
+ {
+ if (_src == null)
+ {
+ throw new Exception();
+ }
+ }
+
+ // Token: 0x0600003B RID: 59 RVA: 0x0000292C File Offset: 0x00000B2C
+ public int SafeReadUnicodeChar() // \u0003
+ {
+ SrcPrecondition();
+ return ReadUnicodeChar();
+ }
+
+ // Token: 0x0600004E RID: 78 RVA: 0x00002E38 File Offset: 0x00001038
+ private int ReadUnicodeChar() // \u0005
+ {
+ var charCnt = 0;
+ var savedPos = 0L;
+ if (_src.IsValid2())
+ {
+ savedPos = _src.GetPos();
+ }
+ if (_inputCharRawBuf == null)
+ {
+ _inputCharRawBuf = new byte[128];
+ }
+ if (_inputCharsDecoded == null)
+ {
+ _inputCharsDecoded = new char[1];
+ }
+ while (charCnt == 0)
+ {
+ var bytesToRead = _isUnicode ? 2 : 1;
+ var b = _src.ReadByte();
+ _inputCharRawBuf[0] = (byte)b;
+ if (b == -1)
+ {
+ bytesToRead = 0;
+ }
+ if (bytesToRead == 2)
+ {
+ b = _src.ReadByte();
+ _inputCharRawBuf[1] = (byte)b;
+ if (b == -1)
+ {
+ bytesToRead = 1;
+ }
+ }
+ if (bytesToRead == 0)
+ {
+ return -1;
+ }
+ try
+ {
+ charCnt = _decoder.GetChars(_inputCharRawBuf, 0, bytesToRead, _inputCharsDecoded, 0);
+ }
+ catch
+ {
+ if (_src.IsValid2())
+ {
+ _src.Seek(savedPos - _src.GetPos(), SeekOrigin.Current);
+ }
+ throw;
+ }
+ }
+ if (charCnt == 0)
+ {
+ return -1;
+ }
+ return _inputCharsDecoded[0];
+ }
+
+ // Token: 0x06000053 RID: 83 RVA: 0x0000305C File Offset: 0x0000125C
+ private void ReadToRawBuf(int cnt) // \u0002
+ {
+ SrcPrecondition();
+ var offset = 0;
+ int bytesRead;
+ if (cnt != 1)
+ {
+ while (true)
+ {
+ bytesRead = _src.Read(_inputRawBuf, offset, cnt - offset);
+ if (bytesRead == 0)
+ break;
+ offset += bytesRead;
+ if (offset >= cnt)
+ return;
+ }
+ throw new Exception();
+ }
+ bytesRead = _src.ReadByte();
+ if (bytesRead == -1)
+ {
+ throw new Exception();
+ }
+ _inputRawBuf[0] = (byte)bytesRead;
+ }
+
+ // Token: 0x0600003C RID: 60 RVA: 0x0000293C File Offset: 0x00000B3C
+ public bool ReadByteInternal() // \u0002
+ {
+ ReadToRawBuf(1);
+ return _inputRawBuf[0] > 0;
+ }
+
+ // Token: 0x0600003D RID: 61 RVA: 0x00002950 File Offset: 0x00000B50
+ public byte ReadByte() // \u0002
+ {
+ SrcPrecondition();
+ var b = _src.ReadByte();
+ if (b == -1)
+ {
+ throw new Exception();
+ }
+ return (byte)b;
+ }
+
+ // Token: 0x0600003E RID: 62 RVA: 0x00002970 File Offset: 0x00000B70
+ public sbyte ReadSbyte() // \u0002
+ {
+ ReadToRawBuf(1);
+ return (sbyte)_inputRawBuf[0];
+ }
+
+ // Token: 0x0600003F RID: 63 RVA: 0x00002984 File Offset: 0x00000B84
+ public char ReadChar() // \u0002
+ {
+ var c = SafeReadUnicodeChar();
+ if (c == -1)
+ {
+ throw new Exception();
+ }
+ return (char)c;
+ }
+
+ // Token: 0x06000040 RID: 64 RVA: 0x00002998 File Offset: 0x00000B98
+ public short ReadShort() // \u0002
+ {
+ ReadToRawBuf(2);
+ return (short)(_inputRawBuf[0] | _inputRawBuf[1] << 8);
+ }
+
+ // Token: 0x06000041 RID: 65 RVA: 0x000029B8 File Offset: 0x00000BB8
+ public ushort ReadUshort() // \u0002
+ {
+ ReadToRawBuf(2);
+ return (ushort)(_inputRawBuf[0] | _inputRawBuf[1] << 8);
+ }
+
+ // Token: 0x06000042 RID: 66 RVA: 0x000029D8 File Offset: 0x00000BD8
+ public uint ReadUint() // \u0002
+ {
+ ReadToRawBuf(4);
+ return (uint)(_inputRawBuf[0] | _inputRawBuf[1] << 8 | _inputRawBuf[2] << 16 | _inputRawBuf[3] << 24);
+ }
+
+ // Token: 0x06000043 RID: 67 RVA: 0x00002A0C File Offset: 0x00000C0C
+ public long ReadLong() // \u0002
+ {
+ ReadToRawBuf(8);
+ var num = (uint)(_inputRawBuf[0] | _inputRawBuf[1] << 8 | _inputRawBuf[2] << 16 | _inputRawBuf[3] << 24);
+ return (long)((ulong)(_inputRawBuf[4] | _inputRawBuf[5] << 8 | _inputRawBuf[6] << 16 | _inputRawBuf[7] << 24) << 32 | num);
+ }
+
+ // Token: 0x06000044 RID: 68 RVA: 0x00002A80 File Offset: 0x00000C80
+ public ulong ReadUlong() // \u0002
+ {
+ ReadToRawBuf(8);
+ var num = (uint)(_inputRawBuf[0] | _inputRawBuf[1] << 8 | _inputRawBuf[2] << 16 | _inputRawBuf[3] << 24);
+ return (ulong)(_inputRawBuf[4] | _inputRawBuf[5] << 8 | _inputRawBuf[6] << 16 | _inputRawBuf[7] << 24) << 32 | num;
+ }
+
+ // Token: 0x06000045 RID: 69 RVA: 0x00002AF4 File Offset: 0x00000CF4
+ private BinaryReader ReaderFor(int cnt) // \u0002
+ {
+ ReadToRawBuf(cnt);
+ return new BinaryReader(new MemoryStream(_inputRawBuf, 0, cnt, false));
+ }
+
+ // Token: 0x06000046 RID: 70 RVA: 0x00002B10 File Offset: 0x00000D10
+ public float ReadFloat() // \u0002
+ {
+ var r = ReaderFor(4);
+ var result = r.ReadSingle();
+ r.Close();
+ return result;
+ }
+
+ // Token: 0x06000047 RID: 71 RVA: 0x00002B34 File Offset: 0x00000D34
+ public double ReadDouble() // \u0002
+ {
+ var r = ReaderFor(8);
+ var result = r.ReadDouble();
+ r.Close();
+ return result;
+ }
+
+ // Token: 0x06000048 RID: 72 RVA: 0x00002B58 File Offset: 0x00000D58
+ private static decimal CreateDecimal(int lo, int mid, int hi, int scaleNeg) // \u0002
+ {
+ var isNegative = (scaleNeg & -2147483648) != 0;
+ var scale = (byte)(scaleNeg >> 16);
+ return new decimal(lo, mid, hi, isNegative, scale);
+ }
+
+ // Token: 0x06000049 RID: 73 RVA: 0x00002B80 File Offset: 0x00000D80
+ internal static decimal CreateDecimal(byte[] b) // b
+ {
+ var lo = b[0] | b[1] << 8 | b[2] << 16 | b[3] << 24;
+ var mid = b[4] | b[5] << 8 | b[6] << 16 | b[7] << 24;
+ var hi = b[8] | b[9] << 8 | b[10] << 16 | b[11] << 24;
+ var scaleNeg = b[12] | b[13] << 8 | b[14] << 16 | b[15] << 24;
+ return CreateDecimal(lo, mid, hi, scaleNeg);
+ }
+
+ // Token: 0x0600004A RID: 74 RVA: 0x00002BFC File Offset: 0x00000DFC
+ public decimal ReadDecimal() // \u0002
+ {
+ ReadToRawBuf(16);
+ return CreateDecimal(_inputRawBuf);
+ }
+
+ // Token: 0x0600004B RID: 75 RVA: 0x00002C14 File Offset: 0x00000E14
+ public string ReadString() // \u0002
+ {
+ var totalRead = 0;
+ SrcPrecondition();
+ var strLen = Read28Bit();
+ if (strLen < 0)
+ {
+ throw new IOException();
+ }
+ if (strLen == 0)
+ {
+ return string.Empty;
+ }
+ if (_inputCharRawBuf == null)
+ {
+ _inputCharRawBuf = new byte[128];
+ }
+ if (_stringChunk == null)
+ {
+ _stringChunk = new char[_maxCharsIn128Bytes];
+ }
+ StringBuilder stringBuilder = null;
+ while (true)
+ {
+ var needChunkCnt = (strLen - totalRead > 128) ? 128 : (strLen - totalRead);
+ var realChunkRead = _src.Read(_inputCharRawBuf, 0, needChunkCnt);
+ if (realChunkRead == 0)
+ {
+ break;
+ }
+ var chars = _decoder.GetChars(_inputCharRawBuf, 0, realChunkRead, _stringChunk, 0);
+ if (totalRead == 0 && realChunkRead == strLen)
+ {
+ return new string(_stringChunk, 0, chars);
+ }
+ if (stringBuilder == null)
+ {
+ stringBuilder = new StringBuilder(strLen);
+ }
+ stringBuilder.Append(_stringChunk, 0, chars);
+ totalRead += realChunkRead;
+ if (totalRead >= strLen)
+ {
+ return stringBuilder.ToString();
+ }
+ }
+ throw new Exception();
+ }
+
+ // Token: 0x0600004C RID: 76 RVA: 0x00002D08 File Offset: 0x00000F08
+ public int Read(char[] dest, int offset, int cnt) // \u0002
+ {
+ if (dest == null)
+ {
+ throw new ArgumentNullException(StringDecryptor.GetString(-1550347170), /* \u0002 */
+ StringDecryptor.GetString(-1550347157) /* ArgumentNull_Buffer */);
+ }
+ if (offset < 0)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (cnt < 0)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (dest.Length - offset < cnt)
+ {
+ throw new ArgumentException();
+ }
+ SrcPrecondition();
+ return DoRead(dest, offset, cnt);
+ }
+
+ // Token: 0x0600004D RID: 77 RVA: 0x00002D64 File Offset: 0x00000F64
+ private int DoRead(char[] dest, int offset, int cnt) // \u0003
+ {
+ var remainCharsToRead = cnt;
+ if (_inputCharRawBuf == null)
+ {
+ _inputCharRawBuf = new byte[128];
+ }
+ while (remainCharsToRead > 0)
+ {
+ var chunkSize = remainCharsToRead;
+ if (_isUnicode)
+ {
+ chunkSize <<= 1;
+ }
+ if (chunkSize > 128)
+ {
+ chunkSize = 128;
+ }
+ int chars;
+ if (_alwaysTrue)
+ {
+ var byteIndex = _src.GetCursor();
+ chunkSize = _src.SkipBytes(chunkSize);
+ if (chunkSize == 0)
+ {
+ return cnt - remainCharsToRead;
+ }
+ chars = _decoder.GetChars(_src.Data(), byteIndex, chunkSize, dest, offset);
+ }
+ else
+ {
+ chunkSize = _src.Read(_inputCharRawBuf, 0, chunkSize);
+ if (chunkSize == 0)
+ {
+ return cnt - remainCharsToRead;
+ }
+ chars = _decoder.GetChars(_inputCharRawBuf, 0, chunkSize, dest, offset);
+ }
+ remainCharsToRead -= chars;
+ offset += chars;
+ }
+ return cnt;
+ }
+
+
+ // Token: 0x0600004F RID: 79 RVA: 0x00002F54 File Offset: 0x00001154
+ public char[] ReadChars(int cnt) // \u0002
+ {
+ SrcPrecondition();
+ if (cnt < 0)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ var ret = new char[cnt];
+ var realLength = DoRead(ret, 0, cnt);
+ if (realLength != cnt)
+ {
+ var shrinked = new char[realLength];
+ Buffer.BlockCopy(ret, 0, shrinked, 0, 2 * realLength);
+ ret = shrinked;
+ }
+ return ret;
+ }
+
+ // Token: 0x06000050 RID: 80 RVA: 0x00002F9C File Offset: 0x0000119C
+ public int Read(byte[] dest, int offset, int cnt) // dest
+ {
+ if (dest == null)
+ {
+ throw new ArgumentNullException();
+ }
+ if (offset < 0)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (cnt < 0)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (dest.Length - offset < cnt)
+ {
+ throw new ArgumentException();
+ }
+ SrcPrecondition();
+ return _src.Read(dest, offset, cnt);
+ }
+
+ // Token: 0x06000052 RID: 82 RVA: 0x00002FF8 File Offset: 0x000011F8
+ public byte[] ReadBytes(int cnt) // \u0002
+ {
+ if (cnt < 0)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ SrcPrecondition();
+ var ret = new byte[cnt];
+ var offset = 0;
+ do
+ {
+ var chunkSize = _src.Read(ret, offset, cnt);
+ if (chunkSize == 0)
+ {
+ break;
+ }
+ offset += chunkSize;
+ cnt -= chunkSize;
+ }
+ while (cnt > 0);
+ if (offset != ret.Length)
+ {
+ var shrinked = new byte[offset];
+ Buffer.BlockCopy(ret, 0, shrinked, 0, offset);
+ ret = shrinked;
+ }
+ return ret;
+ }
+
+ // Token: 0x06000054 RID: 84 RVA: 0x000030C0 File Offset: 0x000012C0
+ internal int Read28Bit() // \u0008
+ {
+ var ret = 0;
+ var bitCnt = 0;
+ while (bitCnt != 35)
+ {
+ var b = ReadByte();
+ ret |= (b & 127) << bitCnt;
+ bitCnt += 7;
+ if ((b & 128) == 0)
+ {
+ return ret;
+ }
+ }
+ throw new FormatException();
+ }
+
+ // Token: 0x06000055 RID: 85 RVA: 0x00003100 File Offset: 0x00001300
+ public int ReadInt32() // \u0006
+ {
+ if (_alwaysTrue)
+ {
+ return _src.ReadInt32();
+ }
+ ReadToRawBuf(4);
+ return _inputRawBuf[3] << 8 | _inputRawBuf[1] << 24 | _inputRawBuf[0] << 16 | _inputRawBuf[2];
+ }
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/MyCollection.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/MyCollection.cs
new file mode 100644
index 0000000..38766d7
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/MyCollection.cs
@@ -0,0 +1,361 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Threading;
+
+namespace UnitTestProject.RefVm
+{
+ // Token: 0x02000006 RID: 6
+ internal static class EmptyArray<T> // \u0002\u2003
+ {
+ // Token: 0x04000004 RID: 4
+ public static readonly T[] Data = new T[0];
+ }
+
+ // Token: 0x02000022 RID: 34
+ internal sealed class MyCollection<T> : IEnumerable<T>, ICollection // \u0005\u2006
+ {
+ // Token: 0x0400002C RID: 44
+ internal T[] Data; // \u0002
+
+ // Token: 0x0400002E RID: 46
+ internal int ChangeCounter; // \u0005
+
+ // Token: 0x0400002F RID: 47
+ private object _sync; // \u0008
+
+ // Token: 0x060000DA RID: 218 RVA: 0x00004B9C File Offset: 0x00002D9C
+ public MyCollection()
+ {
+ Data = EmptyArray<T>.Data;
+ Count = 0;
+ ChangeCounter = 0;
+ }
+
+ // Token: 0x060000DB RID: 219 RVA: 0x00004BC0 File Offset: 0x00002DC0
+ public MyCollection(int capacity)
+ {
+ if (capacity < 0)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ Data = new T[capacity];
+ Count = 0;
+ ChangeCounter = 0;
+ }
+
+ // Token: 0x060000DC RID: 220 RVA: 0x00004BEC File Offset: 0x00002DEC
+ public MyCollection(IEnumerable<T> src)
+ {
+ if (src == null)
+ {
+ throw new ArgumentNullException();
+ }
+ var collection = src as ICollection<T>;
+ if (collection != null)
+ {
+ var count = collection.Count;
+ Data = new T[count];
+ collection.CopyTo(Data, 0);
+ Count = count;
+ return;
+ }
+ Count = 0;
+ Data = new T[4];
+ foreach (var i in Data)
+ {
+ PushBack(i);
+ }
+ }
+
+ // Token: 0x0400002D RID: 45
+ // Token: 0x17000006 RID: 6
+ // (get) Token: 0x060000DD RID: 221 RVA: 0x00004C88 File Offset: 0x00002E88
+ public int Count { get; private set; } // \u0003
+
+ // Token: 0x060000DE RID: 222 RVA: 0x00004C90 File Offset: 0x00002E90
+ bool ICollection.IsSynchronized => false; // \u0005\u2006\u2008\u2000\u2002\u200A\u0002
+
+ // Token: 0x060000DF RID: 223 RVA: 0x00004C94 File Offset: 0x00002E94
+ object ICollection.SyncRoot // \u0005\u2006\u2008\u2000\u2002\u200A\u0002
+ {
+ get
+ {
+ if (_sync == null)
+ {
+ Interlocked.CompareExchange(ref _sync, new object(), null);
+ }
+ return _sync;
+ }
+ }
+
+ // Token: 0x060000E0 RID: 224 RVA: 0x00004CB8 File Offset: 0x00002EB8
+ public void Clear() // \u0002
+ {
+ Array.Clear(Data, 0, Count);
+ Count = 0;
+ ChangeCounter++;
+ }
+
+ // Token: 0x060000E1 RID: 225 RVA: 0x00004CE4 File Offset: 0x00002EE4
+ public bool Contains(T what) // \u0002
+ {
+ var num = Count;
+ var @default = EqualityComparer<T>.Default;
+ while (num-- > 0)
+ {
+ if (what == null)
+ {
+ if (Data[num] == null)
+ {
+ return true;
+ }
+ }
+ else if (Data[num] != null && @default.Equals(Data[num], what))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // Token: 0x060000E2 RID: 226 RVA: 0x00004D50 File Offset: 0x00002F50
+ public void CopyTo(T[] dest, int offset) // \u0003
+ {
+ if (dest == null)
+ {
+ throw new ArgumentNullException(StringDecryptor.GetString(-1550346880) /* \u0002 */);
+ }
+ if (offset < 0 || offset > dest.Length)
+ {
+ throw new ArgumentOutOfRangeException(StringDecryptor.GetString(-1550346867) /* \u0003 */,
+ StringDecryptor.GetString(-1550346858) /* arrayIndex < 0 || arrayIndex > array.Length */);
+ }
+ if (dest.Length - offset < Count)
+ {
+ throw new ArgumentException(StringDecryptor.GetString(-1550347192) /* Invalid Off Len */);
+ }
+ Array.Copy(Data, 0, dest, offset, Count);
+ Array.Reverse(dest, offset, Count);
+ }
+
+ // Token: 0x060000E3 RID: 227 RVA: 0x00004DD4 File Offset: 0x00002FD4
+ void ICollection.CopyTo(Array dest, int offset) // \u0005\u2006\u2008\u2000\u2002\u200A\u0002
+ {
+ if (dest == null)
+ {
+ throw new ArgumentNullException();
+ }
+ if (dest.Rank != 1)
+ {
+ throw new ArgumentException();
+ }
+ if (dest.GetLowerBound(0) != 0)
+ {
+ throw new ArgumentException();
+ }
+ if (offset < 0 || offset > dest.Length)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (dest.Length - offset < Count)
+ {
+ throw new ArgumentException();
+ }
+ try
+ {
+ Array.Copy(Data, 0, dest, offset, Count);
+ Array.Reverse(dest, offset, Count);
+ }
+ catch (ArrayTypeMismatchException)
+ {
+ throw new ArgumentException();
+ }
+ }
+
+ // Token: 0x060000E4 RID: 228 RVA: 0x00004E6C File Offset: 0x0000306C
+ public MyEnumerator<T> GetEnumerator() // \u0005
+ {
+ return new MyEnumerator<T>(this);
+ }
+
+ // Token: 0x060000E5 RID: 229 RVA: 0x00004E74 File Offset: 0x00003074
+ IEnumerator<T> IEnumerable<T>.GetEnumerator() // \u0005\u2006\u2008\u2000\u2002\u200A\u0008
+ {
+ return new MyEnumerator<T>(this);
+ }
+
+ // Token: 0x060000E6 RID: 230 RVA: 0x00004E84 File Offset: 0x00003084
+ IEnumerator IEnumerable.GetEnumerator() // \u0005\u2006\u2008\u2000\u2002\u200A\u0002
+ {
+ return new MyEnumerator<T>(this);
+ }
+
+ // Token: 0x060000E7 RID: 231 RVA: 0x00004E94 File Offset: 0x00003094
+ public void Shrink() // \u0003
+ {
+ var num = (int)(Data.Length * 0.9);
+ if (Count < num)
+ {
+ var destinationArray = new T[Count];
+ Array.Copy(Data, 0, destinationArray, 0, Count);
+ Data = destinationArray;
+ ChangeCounter++;
+ }
+ }
+
+ // Token: 0x060000E8 RID: 232 RVA: 0x00004EF4 File Offset: 0x000030F4
+ public T PeekBack() // \u0006
+ {
+ if (Count == 0)
+ {
+ throw new InvalidOperationException();
+ }
+ return Data[Count - 1];
+ }
+
+ // Token: 0x060000E9 RID: 233 RVA: 0x00004F18 File Offset: 0x00003118
+ public T PopBack() // \u000E
+ {
+ if (Count == 0)
+ {
+ throw new InvalidOperationException();
+ }
+ ChangeCounter++;
+ var ret = Data[--Count];
+ Data[Count] = default(T);
+ return ret;
+ }
+
+ // Token: 0x060000EA RID: 234 RVA: 0x00004F78 File Offset: 0x00003178
+ public void PushBack(T obj) // \u000F
+ {
+ if (Count == Data.Length)
+ {
+ var destinationArray = new T[(Data.Length == 0) ? 4 : (2 * Data.Length)];
+ Array.Copy(Data, 0, destinationArray, 0, Count);
+ Data = destinationArray;
+ }
+ var num = Count;
+ Count = num + 1;
+ Data[num] = obj;
+ ChangeCounter++;
+ }
+
+ // Token: 0x060000EB RID: 235 RVA: 0x00004FF8 File Offset: 0x000031F8
+ public T[] Reverse() // \u0002\u2000
+ {
+ var array = new T[Count];
+ for (var i = 0; i < Count; i++)
+ {
+ array[i] = Data[Count - i - 1];
+ }
+ return array;
+ }
+
+ // Token: 0x02000023 RID: 35
+ public struct MyEnumerator<T1> : IEnumerator<T1> // \u0002
+ {
+ // Token: 0x060000EC RID: 236 RVA: 0x00005040 File Offset: 0x00003240
+ internal MyEnumerator(MyCollection<T1> src)
+ {
+ _src = src;
+ _changeCounter = _src.ChangeCounter;
+ _curPos = -2;
+ _current = default(T1);
+ }
+
+ // Token: 0x060000ED RID: 237 RVA: 0x00005070 File Offset: 0x00003270
+ public void Dispose()
+ {
+ _curPos = -1;
+ }
+
+ // Token: 0x060000EE RID: 238 RVA: 0x0000507C File Offset: 0x0000327C
+ public bool MoveNext()
+ {
+ if (_changeCounter != _src.ChangeCounter)
+ {
+ throw new InvalidOperationException(StringDecryptor.GetString(-1550346776) /* EnumFailedVersion */);
+ }
+ if (_curPos == -2)
+ {
+ _curPos = _src.Count - 1;
+ if (_curPos < 0) return false;
+ _current = _src.Data[_curPos];
+ return true;
+ }
+ if (_curPos == -1)
+ {
+ return false;
+ }
+ if (--_curPos >= 0)
+ {
+ _current = _src.Data[_curPos];
+ return true;
+ }
+ _current = default(T1);
+ return false;
+ }
+
+ // Token: 0x17000007 RID: 7
+ // (get) Token: 0x060000EF RID: 239 RVA: 0x00005144 File Offset: 0x00003344
+ public T1 Current
+ {
+ get
+ {
+ if (_curPos == -2)
+ {
+ throw new InvalidOperationException();
+ }
+ if (_curPos == -1)
+ {
+ throw new InvalidOperationException();
+ }
+ return _current;
+ }
+ }
+
+ // Token: 0x060000F0 RID: 240 RVA: 0x0000516C File Offset: 0x0000336C
+ object IEnumerator.Current // \u0002\u2008\u2000\u2002\u200A\u0002
+ {
+ get
+ {
+ if (_curPos == -2)
+ {
+ throw new InvalidOperationException();
+ }
+ if (_curPos == -1)
+ {
+ throw new InvalidOperationException();
+ }
+ return _current;
+ }
+ }
+
+ // Token: 0x060000F1 RID: 241 RVA: 0x00005198 File Offset: 0x00003398
+ void IEnumerator.Reset() // \u0002\u2008\u2000\u2002\u200A\u0002
+ {
+ if (_changeCounter != _src.ChangeCounter)
+ {
+ throw new InvalidOperationException();
+ }
+ _curPos = -2;
+ _current = default(T1);
+ }
+
+ // Token: 0x04000030 RID: 48
+ private readonly MyCollection<T1> _src; // \u0002
+
+ // Token: 0x04000031 RID: 49
+ private int _curPos; // \u0003
+
+ // Token: 0x04000032 RID: 50
+ private readonly int _changeCounter; // \u0005
+
+ // Token: 0x04000033 RID: 51
+ private T1 _current; // \u0008
+ }
+ }
+}
+
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/SdMetadataTokens.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/SdMetadataTokens.cs
new file mode 100644
index 0000000..aaf7291
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/SdMetadataTokens.cs
@@ -0,0 +1,288 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Text;
+
+namespace UnitTestProject.RefVm
+{
+ // Token: 0x02000063 RID: 99
+ internal static class SdMetadataTokens // \u000F\u2009
+ {
+ // Token: 0x06000399 RID: 921 RVA: 0x00015D18 File Offset: 0x00013F18
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ internal static long GetLong() // \u0002
+ {
+ if (Assembly.GetCallingAssembly() != typeof(SdMetadataTokens).Assembly || !CheckStack())
+ {
+ return 0L;
+ }
+ long result;
+ lock (Obj)
+ {
+ var num = Obj.GetLong7();
+ if (num == 0L)
+ {
+ var executingAssembly = Assembly.GetExecutingAssembly();
+ var list = new List<byte>();
+ AssemblyName assemblyName;
+ try
+ {
+ assemblyName = executingAssembly.GetName();
+ }
+ catch
+ {
+ assemblyName = new AssemblyName(executingAssembly.FullName);
+ }
+ var array = assemblyName.GetPublicKeyToken();
+ if (array != null && array.Length == 0)
+ {
+ array = null;
+ }
+ if (array != null)
+ {
+ list.AddRange(array);
+ }
+ list.AddRange(Encoding.Unicode.GetBytes(assemblyName.Name));
+ var num2 = 0x02000063; //GetMdt(typeof(SdMetadataTokens));
+ var num3 = Class1.M();
+ list.Add((byte)(num2 >> 24));
+ list.Add((byte)(num3 >> 16));
+ list.Add((byte)(num2 >> 8));
+ list.Add((byte)num3);
+ list.Add((byte)(num2 >> 16));
+ list.Add((byte)(num3 >> 8));
+ list.Add((byte)num2);
+ list.Add((byte)(num3 >> 24));
+ var count = list.Count;
+ var num4 = 0uL;
+ for (var num5 = 0; num5 != count; num5++)
+ {
+ num4 += list[num5];
+ num4 += num4 << 20;
+ num4 ^= num4 >> 12;
+ list[num5] = 0;
+ }
+ num4 += num4 << 6;
+ num4 ^= num4 >> 22;
+ num4 += num4 << 30;
+ num = (long)num4;
+ num ^= 7895633081549295753L;
+ Obj.SetLong(num);
+ }
+ result = num;
+ }
+ return result;
+ }
+
+ // Token: 0x0600039A RID: 922 RVA: 0x00015EE0 File Offset: 0x000140E0
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool CheckStack() // \u0002
+ {
+ return CheckStackImpl();
+ }
+
+ // Token: 0x0600039B RID: 923 RVA: 0x00015EEC File Offset: 0x000140EC
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool CheckStackImpl() // \u0003
+ {
+ var stackTrace = new StackTrace();
+ var frame = stackTrace.GetFrame(3);
+ var methodBase = frame?.GetMethod();
+ var type = methodBase?.DeclaringType;
+ return type != typeof(RuntimeMethodHandle) && type != null && type.Assembly == typeof(SdMetadataTokens).Assembly;
+ }
+
+ // Token: 0x0600039C RID: 924 RVA: 0x00015F50 File Offset: 0x00014150
+ // ReSharper disable once UnusedMember.Local
+ private static int GetMdt(Type t) // \u0002
+ {
+ return t.MetadataToken;
+ }
+
+ // Token: 0x0400019A RID: 410
+ // \u0002
+ private static readonly Class7 Obj = new Class7();
+
+ // Token: 0x02000064 RID: 100
+ public sealed class Class1 // \u0002\u2007\u2007\u2009\u2002\u2006\u2003\u2003\u2002\u2004\u2007\u200A\u2009\u200A\u2008\u200A\u2000\u2003\u200B\u2007\u200A\u2008\u200A\u2003\u2006\u200B
+ {
+ // Token: 0x0600039E RID: 926 RVA: 0x00015F60 File Offset: 0x00014160
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ internal static int M()
+ {
+ return Class2.M3(Class2.M2(0x02000067 /*GetMdt(typeof(Class4))*/, Class2.M3(0x02000064 /*GetMdt(typeof(Class1))*/, 0x02000066 /*GetMdt(typeof(Class3))*/)), Class5.M1());
+ }
+ }
+
+ // Token: 0x02000065 RID: 101
+ private static class Class2 // \u0002\u200A\u2003\u2000\u2002\u2000\u2007\u2008\u2004\u2006\u2007\u2003\u2007\u2004\u2000\u2003\u2009\u2007\u2003\u2006\u2007\u2008\u200A
+ {
+ // Token: 0x0600039F RID: 927 RVA: 0x00015FB0 File Offset: 0x000141B0
+ internal static int M1(int p1, int p2) // \u0002
+ {
+ return p1 ^ p2 - -~~- -~~- -~~-1683504797;
+ }
+
+ // Token: 0x060003A0 RID: 928 RVA: 0x00015FC8 File Offset: 0x000141C8
+ internal static int M2(int p1, int p2) // \u0003
+ {
+ return p1 - -~-~-~~- -~~-1670271084 ^ p2 + -~-~-~~-~-~699406271;
+ }
+
+ // Token: 0x060003A1 RID: 929 RVA: 0x00015FF0 File Offset: 0x000141F0
+ internal static int M3(int p1, int p2) // \u0005
+ {
+ return p1 ^ p2 - -~~-~-~- -~~-1466097638 ^ p1 - p2;
+ }
+ }
+
+ // Token: 0x02000066 RID: 102
+ public sealed class Class3 // \u0003\u2001\u2003\u2009\u2009\u2008\u2006\u2006\u2006\u200A\u2003\u2006\u2005\u2005\u2009\u200B\u2009\u200A\u2003\u2007
+ {
+ // Token: 0x060003A3 RID: 931 RVA: 0x00016014 File Offset: 0x00014214
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ internal static int M1() // \u0002
+ {
+ return Class2.M2(Class2.M2(Class6.M1(), Class2.M1(0x02000066 /*GetMdt(typeof(Class3))*/, Class4.M1())), 0x02000068 /*GetMdt(typeof(Class5))*/);
+ }
+ }
+
+ // Token: 0x02000067 RID: 103
+ public sealed class Class4 // \u0003\u2007\u2006\u2000\u2001\u2003\u2006\u200B\u2003\u2009\u200B\u2008\u200A\u2008\u2004\u2005\u2006\u200A\u2008\u2000\u2000\u200B\u2008\u200A
+ {
+ // Token: 0x060003A5 RID: 933 RVA: 0x00016058 File Offset: 0x00014258
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ internal static int M1() // \u0002
+ {
+ return Class2.M1(0x02000069 /*GetMdt(typeof(Class6))*/, 0x0200006B /*GetMdt(typeof(Class8))*/ ^ Class2.M2(0x02000067 /*GetMdt(typeof(Class4))*/, Class2.M3(0x02000068 /*GetMdt(typeof(Class5))*/, Class8.M1())));
+ }
+ }
+
+ // Token: 0x02000068 RID: 104
+ public sealed class Class5 // \u0005\u2006\u200A\u2004\u200B\u2005\u200B\u2004\u2005\u2002\u2000\u2001\u2002\u2004\u2000\u2002\u2007\u2003\u2009\u200B\u2007\u200A\u200B\u2000\u2008\u2002\u2003\u2002
+ {
+ // Token: 0x060003A7 RID: 935 RVA: 0x000160C0 File Offset: 0x000142C0
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ internal static int M1() // \u0002
+ {
+ return Class2.M1(0x02000068 /*GetMdt(typeof(Class5))*/, Class2.M3(Class2.M2(0x02000066 /*GetMdt(typeof(Class3))*/, 0x02000064 /*GetMdt(typeof(Class1))*/), Class2.M3(0x02000069 /*GetMdt(typeof(Class6))*/ ^ -~-~~- -~~-1251689633, Class3.M1())));
+ }
+ }
+
+ // Token: 0x02000069 RID: 105
+ public sealed class Class6 // \u0008\u2007\u2007\u2004\u2006\u2006\u200A\u2009\u2005\u2006\u2008\u200A\u2000\u200A\u2008\u2002\u2009\u2003\u2006\u2008\u2000\u2005\u2004\u200A\u2004\u2008\u2008\u2001\u2004\u200B
+ {
+ // Token: 0x060003A9 RID: 937 RVA: 0x0001613C File Offset: 0x0001433C
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ internal static int M1() // \u0002
+ {
+ return Class2.M3(Class2.M1(Class4.M1() ^ ~-~- -~~- -~~-527758448, 0x0200006B /*GetMdt(typeof(Class8))*/), Class2.M2(0x02000064 /*GetMdt(typeof(Class1))*/ ^ 0x02000068 /*GetMdt(typeof(Class5))*/, -~~- -~-~~1892236202));
+ }
+ }
+
+ // Token: 0x0200006A RID: 106
+ internal sealed class Class7 // \u000F\u2005\u2007\u2007\u2009\u2009\u2002\u2004\u2008\u2009\u2002\u2000\u2000\u2009\u2009\u200B\u2008\u2004\u2003\u200B\u200A\u2002\u2002\u2003\u2006\u2007\u2000\u2006\u2002\u2003
+ {
+ // Token: 0x060003AA RID: 938 RVA: 0x000161AC File Offset: 0x000143AC
+ internal Class7()
+ {
+ SetLong(0L);
+ }
+
+ // Token: 0x060003AB RID: 939 RVA: 0x000161BC File Offset: 0x000143BC
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public long GetLong7() // \u0002
+ {
+ if (Assembly.GetCallingAssembly() != typeof(Class7).Assembly)
+ {
+ return 2918384L;
+ }
+ if (!CheckStack())
+ {
+ return 2918384L;
+ }
+ var array = new[]
+ {
+ 0,
+ 0,
+ 0,
+ -~~- -~-~~1688528055
+ };
+ array[1] = ~-~- -~~-~1937298816;
+ array[2] = ~-~- -~-~~-~-2131774929;
+ array[0] = ~-~-~- -~~-~859851913;
+ var num = _i1;
+ var num2 = _i2;
+ var num3 = -~-~-~~-~1640531528;
+ var num4 = -~-~~- -~~-~957401312;
+ for (var num5 = 0; num5 != 32; num5++)
+ {
+ num2 -= (num << 4 ^ num >> 5) + num ^ num4 + array[num4 >> 11 & 3];
+ num4 -= num3;
+ num -= (num2 << 4 ^ num2 >> 5) + num2 ^ num4 + array[num4 & 3];
+ }
+ for (var num6 = 0; num6 != 4; num6++)
+ {
+ array[num6] = 0;
+ }
+ var num7 = ((ulong)num2 << 32);
+ var n = (ulong)_i1;
+ return (long)(num7 | n);
+ }
+
+ // Token: 0x060003AC RID: 940 RVA: 0x000162D8 File Offset: 0x000144D8
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ internal void SetLong(long p) // \u0002
+ {
+ if (Assembly.GetCallingAssembly() != typeof(Class7).Assembly)
+ {
+ return;
+ }
+ if (!CheckStack())
+ {
+ return;
+ }
+ var array = new int[4];
+ array[1] = -~~-~- -~~-~1937298817;
+ array[0] = -~~-~-~-~859851914;
+ array[2] = ~-~- -~~-~-2131774930;
+ array[3] = -~-~~-~- -~~1688528054;
+ var num = -~-~~- -~-~~1640531529;
+ var num2 = (int)p;
+ var num3 = (int)(p >> 32);
+ var num4 = 0;
+ for (var num5 = 0; num5 != 32; num5++)
+ {
+ num2 += (num3 << 4 ^ num3 >> 5) + num3 ^ num4 + array[num4 & 3];
+ num4 += num;
+ num3 += (num2 << 4 ^ num2 >> 5) + num2 ^ num4 + array[num4 >> 11 & 3];
+ }
+ for (var num6 = 0; num6 != 4; num6++)
+ {
+ array[num6] = 0;
+ }
+ _i1 = num2;
+ _i2 = num3;
+ }
+
+ // Token: 0x0400019B RID: 411
+ private int _i1; // \u0002
+
+ // Token: 0x0400019C RID: 412
+ private int _i2; // \u0003
+ }
+
+ // Token: 0x0200006B RID: 107
+ public sealed class Class8 // \u000F\u200A\u2002\u2009\u2000\u2009\u2003\u200A\u2005\u2001\u2002\u2002\u2003\u200B\u2000\u2009\u2003\u2009\u2009\u2001\u2002\u200B\u2000\u200A
+ {
+ // Token: 0x060003AE RID: 942 RVA: 0x000163DC File Offset: 0x000145DC
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ internal static int M1()
+ {
+ return Class2.M3(0x0200006B /*GetMdt(typeof(Class8))*/, Class2.M1(0x02000064 /*GetMdt(typeof(Class1))*/, Class2.M2(0x02000067 /*GetMdt(typeof(Class4))*/, Class2.M3(0x02000069 /*GetMdt(typeof(Class6))*/, Class2.M1(0x02000066 /*GetMdt(typeof(Class3))*/, 0x02000068 /*GetMdt(typeof(Class5))*/)))));
+ }
+ }
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/SdTemplateStuff.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/SdTemplateStuff.cs
new file mode 100644
index 0000000..16f2acf
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/SdTemplateStuff.cs
@@ -0,0 +1,180 @@
+using System;
+using System.Threading;
+
+namespace forms_cil
+{
+ // Token: 0x02000057 RID: 87
+ internal interface I4 // \u000E\u2008
+ {
+ // Token: 0x06000346 RID: 838
+ bool I4M(); // \u000E\u2008\u2008\u2000\u2002\u200A\u0002
+
+ // Token: 0x06000347 RID: 839
+ object M2(); // \u000E\u2008\u2008\u2000\u2002\u200A\u0002
+
+ // Token: 0x06000348 RID: 840
+ void M3(); // \u000E\u2008\u2008\u2000\u2002\u200A\u0002
+ }
+
+ // Token: 0x02000062 RID: 98
+ internal interface I5 // \u000F\u2008
+ {
+ // Token: 0x06000397 RID: 919
+ void I5M(); // \u000F\u2008\u2008\u2000\u2002\u200A\u0002
+ }
+
+ // Token: 0x0200000C RID: 12
+ internal interface I1<out T> : I4, I5 // \u0002\u2009
+ {
+ // Token: 0x06000057 RID: 87
+ T I1M(); // \u000E\u2008\u2008\u2000\u2002\u200A\u0002
+ }
+
+ // Token: 0x0200004B RID: 75
+ internal interface I3 // \u0008\u2008
+ {
+ // Token: 0x0600031E RID: 798
+ I4 M1(); // \u0008\u2008\u2008\u2000\u2002\u200A\u0002
+ }
+
+ // Token: 0x0200003C RID: 60
+ internal interface I2<out T> : I3 // \u0006\u2008
+ {
+ // Token: 0x060002CD RID: 717
+ I1<T> I2M(); // \u0008\u2008\u2008\u2000\u2002\u200A\u0002
+ }
+
+ // Token: 0x02000025 RID: 37
+ internal static class SdTemplateStuff // \u0005\u2008
+ {
+ // Token: 0x02000026 RID: 38
+ internal sealed class C : I2<int>, I1<int> // \u0002
+ {
+ // Token: 0x06000112 RID: 274 RVA: 0x00005A28 File Offset: 0x00003C28
+ public C(int val)
+ {
+ _i2 = val;
+ _i5 = Thread.CurrentThread.ManagedThreadId;
+ }
+
+ // Token: 0x06000113 RID: 275 RVA: 0x00005A48 File Offset: 0x00003C48
+ void I5.I5M()
+ {
+ }
+
+ // Token: 0x06000114 RID: 276 RVA: 0x00005A4C File Offset: 0x00003C4C
+ bool I4.I4M()
+ {
+ switch (_i2)
+ {
+ case 0:
+ _i2 = -1;
+ _i3 = -1496196691;
+ _i2 = 1;
+ return true;
+ case 1:
+ _i2 = -1;
+ _i3 = _i8 ^ 70939052;
+ _i2 = 2;
+ return true;
+ case 2:
+ _i2 = -1;
+ _i3 = _i8 ^ -1812634754;
+ _i2 = 3;
+ return true;
+ case 3:
+ _i2 = -1;
+ _i3 = -5623460;
+ _i2 = 4;
+ return true;
+ case 4:
+ _i2 = -1;
+ _i3 = 401181880;
+ _i2 = 5;
+ return true;
+ case 5:
+ _i2 = -1;
+ _i3 = 2075948002;
+ _i2 = 6;
+ return true;
+ case 6:
+ _i2 = -1;
+ _i3 = _i8 ^ 70939052;
+ _i2 = 7;
+ return true;
+ case 7:
+ _i2 = -1;
+ _i3 = -783689628;
+ _i2 = 8;
+ return true;
+ case 8:
+ _i2 = -1;
+ _i3 = _i8 ^ 70939052;
+ _i2 = 9;
+ return true;
+ case 9:
+ _i2 = -1;
+ return false;
+ default:
+ return false;
+ }
+ }
+
+ // Token: 0x06000115 RID: 277 RVA: 0x00005BA8 File Offset: 0x00003DA8
+ int I1<int>.I1M()
+ {
+ return _i3;
+ }
+
+ // Token: 0x06000116 RID: 278 RVA: 0x00005BB0 File Offset: 0x00003DB0
+ void I4.M3()
+ {
+ throw new NotSupportedException();
+ }
+
+ // Token: 0x06000117 RID: 279 RVA: 0x00005BB8 File Offset: 0x00003DB8
+ object I4.M2()
+ {
+ return _i3;
+ }
+
+ // Token: 0x06000118 RID: 280 RVA: 0x00005BC8 File Offset: 0x00003DC8
+ I1<int> I2<int>.I2M()
+ {
+ C ret;
+ if (_i2 == -2 && _i5 == Thread.CurrentThread.ManagedThreadId)
+ {
+ _i2 = 0;
+ ret = this;
+ }
+ else
+ {
+ ret = new C(0);
+ }
+ ret._i8 = I6;
+ return ret;
+ }
+
+ // Token: 0x06000119 RID: 281 RVA: 0x00005C10 File Offset: 0x00003E10
+ I4 I3.M1()
+ {
+ return ((I2<int>)this).I2M();
+ }
+
+ // Token: 0x0400003D RID: 61
+ private int _i2; // \u0002
+
+ // Token: 0x0400003E RID: 62
+ private int _i3; // \u0003
+
+ // Token: 0x0400003F RID: 63
+ private readonly int _i5; // \u0005
+
+ // Token: 0x04000040 RID: 64
+ private int _i8; // \u0008
+
+ // Token: 0x04000041 RID: 65
+ public int I6; // \u0006
+ }
+ }
+} \ No newline at end of file
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/SimpleTypeHelper.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/SimpleTypeHelper.cs
new file mode 100644
index 0000000..a062c9e
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/SimpleTypeHelper.cs
@@ -0,0 +1,26 @@
+using System;
+
+namespace UnitTestProject.RefVm
+{
+ // Token: 0x02000009 RID: 9
+ static class SimpleTypeHelper // \u0002\u2006
+ {
+ // Token: 0x06000033 RID: 51 RVA: 0x000027AC File Offset: 0x000009AC
+ public static bool IsNullableGeneric(Type t) // \u0002
+ {
+ return t.IsGenericType && t.GetGenericTypeDefinition() == NullableType; // \u0003
+ }
+
+ // Token: 0x04000008 RID: 8
+ public static readonly Type ObjectType = typeof(object); // \u0002
+
+ // Token: 0x04000009 RID: 9
+ private static readonly Type NullableType = typeof(Nullable<>); // \u0003
+
+ // Token: 0x0400000A RID: 10
+ public static readonly Type TypedReferenceType = typeof(TypedReference); // \u0005
+
+ // Token: 0x0400000B RID: 11
+ public static readonly Type EnumType = typeof(Enum); // \u0008
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/StringDecryptor.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/StringDecryptor.cs
new file mode 100644
index 0000000..f27827b
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/StringDecryptor.cs
@@ -0,0 +1,648 @@
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Text;
+using forms_cil;
+
+// Token: 0x0200003D RID: 61
+namespace UnitTestProject.RefVm
+{
+ public static class StringDecryptor // \u0006\u2009
+ {
+ private static BinStreamReader _binStreamReader; // \u0003
+ private static readonly DecryptedStrings DecryptedStringsGlobal; // \u0002
+ private static byte[] _commonKey; // \u0005
+ private static short _keyLength; // \u0008
+ private static readonly Enum1 Enum1Dummy; // \u0003\u2000
+ private static int _int1Dummy; // \u0002\u2000
+ private static int _int2Dummy; // \u000F
+ private static int _int3Dummy; // \u0006
+ private static byte[] _pkt; // \u000E
+
+ // Token: 0x060002CE RID: 718 RVA: 0x00013060 File Offset: 0x00011260
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static StringDecryptor()
+ {
+ var num = -42518532;
+ var num2 = num ^ 1885636661;
+ DecryptedStringsGlobal = new DecryptedStrings(1970604170 + num + num2 /*9*/);
+
+ var num3 = 2;
+ var stackTrace = new StackTrace(num3, false);
+ num3 -= 2;
+ var frame = stackTrace.GetFrame(num3);
+ var index = num3;
+ if (frame == null)
+ {
+ stackTrace = new StackTrace();
+ index = 1;
+ frame = stackTrace.GetFrame(index);
+ }
+ var num4 = ~- -~~-~-~(1341405001 ^ num ^ num2) ^ -~~- -~-~~(2095196650 + num - num2);
+ var methodBase = frame?.GetMethod();
+ if (frame != null)
+ {
+ num4 ^= ~- -~~-~-~(num ^ -1658751032 ^ num2);
+ }
+ var type = methodBase?.DeclaringType;
+ if (type == typeof(RuntimeMethodHandle))
+ {
+ Enum1Dummy = (Enum1)(4 | (int)Enum1Dummy);
+ num4 ^= 1970604898 + num + num2 + num3;
+ }
+ else if (type == null)
+ {
+ if (CheckStack(stackTrace, index))
+ {
+ num4 ^= ~-~- -~~-~(-1970628130 - num - num2) - num3;
+ Enum1Dummy = (Enum1)(16 | (int)Enum1Dummy);
+ }
+ else
+ {
+ num4 ^= ~- -~~-~-~(num ^ -1885608078 ^ num2);
+ Enum1Dummy = (Enum1)(1 | (int)Enum1Dummy);
+ }
+ }
+ else
+ {
+ num4 ^= ~-~- -~~-~(1885542988 - num + num2) - num3;
+ Enum1Dummy = (Enum1)(16 | (int)Enum1Dummy);
+ }
+ _int1Dummy += num4;
+ }
+
+ // Token: 0x060002CF RID: 719 RVA: 0x000131D4 File Offset: 0x000113D4
+ public static string GetString(int id) // \u0002
+ {
+ lock (DecryptedStringsGlobal)
+ {
+ return DecryptedStringsGlobal[id] ?? DecryptString(id, true);
+ }
+ }
+ public static void SetString(int id, string val) // for unit tests
+ {
+ lock (DecryptedStringsGlobal)
+ {
+ DecryptedStringsGlobal[id] = val;
+ }
+ }
+
+ // Token: 0x060002D0 RID: 720 RVA: 0x00013224 File Offset: 0x00011424
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static string DecryptString(int id, bool dummy) // \u0002
+ {
+ var num = 1500675437;
+ var num2 = 1065028357 - num;
+ byte[] key;
+ string str;
+ int num6;
+ if (_binStreamReader == null)
+ {
+ var executingAssembly = Assembly.GetExecutingAssembly();
+ _int3Dummy |= num ^ -1084071305 ^ num2;
+ var stringBuilder = new StringBuilder();
+ var num3 = -1821765671 - num + num2;
+ stringBuilder.Append((char)(num3 >> 16)).Append((char)num3);
+ num3 = 1822175277 + num ^ num2;
+ stringBuilder.Append((char)(num3 >> 16)).Append((char)num3);
+ num3 = (1619914499 ^ num) + num2;
+ stringBuilder.Append((char)num3).Append((char)(num3 >> 16));
+ num3 = 1602104074 - num - num2;
+ stringBuilder.Append((char)num3).Append((char)(num3 >> 16));
+ num3 = (num ^ 1619980037) + num2;
+ stringBuilder.Append((char)num3).Append((char)(num3 >> 16));
+ num3 = num + -1398984659 - num2;
+ stringBuilder.Append((char)num3).Append((char)(num3 >> 16));
+ var manifestResourceStream = executingAssembly.GetManifestResourceStream(/* added by ursoft */ "forms_cil." +
+ stringBuilder.ToString()
+ /* added by ursoft */.GetHashCode().ToString());
+ var num4 = 2;
+ var stackTrace = new StackTrace(num4, false);
+ _int3Dummy ^= (1082521283 ^ num) + num2 | num4;
+ num4 -= 2;
+ var frame = stackTrace.GetFrame(num4);
+ var index = num4;
+ if (frame == null)
+ {
+ stackTrace = new StackTrace();
+ index = 1;
+ frame = stackTrace.GetFrame(index);
+ }
+ var methodBase = frame?.GetMethod();
+ _int3Dummy ^= num4 + (num + -1936322645 ^ num2);
+ var type = methodBase?.DeclaringType;
+ if (frame == null)
+ {
+ _int3Dummy ^= 1065247672 - num - num2;
+ }
+ var flag = type == typeof(RuntimeMethodHandle);
+ _int3Dummy ^= (num ^ 1082461797) + num2;
+ if (!flag)
+ {
+ flag = type == null;
+ if (flag)
+ {
+ if (CheckStack(stackTrace, index))
+ {
+ flag = false;
+ }
+ else
+ {
+ _int3Dummy ^= 1065247640 - num - num2;
+ }
+ }
+ }
+ if (flag)
+ {
+ _int3Dummy ^= 32;
+ }
+ _int3Dummy ^= (num ^ 1082521251) + num2 | num4 + 1;
+ _binStreamReader = new BinStreamReader(manifestResourceStream);
+ var commonKeyLength = (short)(_binStreamReader.ReadHeaderInt16() ^ ~(short)-(short)-(short)~(short)~(short)-(short)~(short)-(short)~(short)-(short)~(short)(-1065050389 + num ^ num2));
+ if (commonKeyLength == 0)
+ {
+ _keyLength = (short)(_binStreamReader.ReadHeaderInt16() ^ -(short)~(short)~(short)-(short)-(short)~(short)~(short)-(short)-(short)~(short)~(short)((-1082482306 ^ num) - num2));
+ }
+ else
+ {
+ _commonKey = _binStreamReader.Read(commonKeyLength);
+ }
+ var assembly = executingAssembly;
+ var assemblyName = SafeAssemblyName(assembly);
+ _pkt = SafeAssemblyPkt(assemblyName);
+ num6 = _int1Dummy;
+ _int1Dummy = 0;
+ var num7 = SdMetadataTokens.GetLong();
+ num6 ^= (int)(uint)num7;
+ num6 ^= -888987382 - num + num2;
+ var num8 = num6;
+ var num9 = num8;
+ var num10 = 0;
+ var num11 = num9 ^ -1693408934 + num - num2;
+ var num12 = num11 * (1936327810 - num + num2) % ((num ^ -1092770072) - num2);
+ var num13 = num12;
+ var obj = ((I2<int>)new SdTemplateStuff.C(-1065028359 + num | num2)
+ {
+ I6 = num13
+ }).I2M();
+ try
+ {
+ while (obj.I4M())
+ {
+ var num14 = obj.I1M();
+ num12 ^= num10 - num14 << 2;
+ num10 += num12 >> 3;
+ }
+ }
+ finally
+ {
+ obj?.I5M();
+ }
+ num6 ^= ~- -~-~~- -~~(num ^ 1140387705 ^ num2);
+ var num15 = num12;
+ num6 = num15 + num6;
+ _int2Dummy = num6;
+ _int3Dummy = (_int3Dummy & -1667887203 + num - num2) ^ (num ^ 1082519937) + num2;
+ if ((Enum1Dummy & (Enum1)(-~~- -~-~~(1936322518 - num ^ num2))) == 0)
+ {
+ _int3Dummy = (-1082440641 ^ num) - num2;
+ }
+ }
+ else
+ {
+ num6 = _int2Dummy;
+ }
+ if (_int3Dummy == 1936366479 - num + num2)
+ {
+ return new string(new[] { (char)((-1082462051 ^ num) - num2), '0', (char)(num + -1065028269 + num2) });
+ }
+ var num16 = id ^ -1010833342 ^ num ^ num2 ^ num6;
+ num16 ^= -1459130838 - num + num2;
+ _binStreamReader.GetStream().Position = num16;
+ if (_commonKey != null)
+ {
+ key = _commonKey;
+ }
+ else
+ {
+ short keyLength;
+ if (_keyLength == -1)
+ {
+ keyLength = (short)(_binStreamReader.ReadHeaderInt32() ^ num + -1936293566 - num2 ^ num16);
+ }
+ else
+ {
+ keyLength = _keyLength;
+ }
+ if (keyLength == 0)
+ {
+ key = null;
+ }
+ else
+ {
+ key = _binStreamReader.Read(keyLength);
+ for (var i = 0; i != key.Length; i = 1 + i)
+ {
+ key[i] ^= (byte)(_int2Dummy >> ((3 & i) << 3));
+ }
+ }
+ }
+ var stringHeader = _binStreamReader.ReadHeaderInt32() ^ num16 ^ -~~-~-~-~((num ^ -1882046960) + num2) ^ num6;
+ if (stringHeader != (1936322515 - num | num2))
+ {
+ var flagAnsi = (stringHeader & 211161131 + num - num2) != 0;
+ var flagCompressed = (stringHeader & (-8713467 - num ^ num2)) != 0;
+ var flagSecure = (stringHeader & (1619332869 ^ num) + num2) != 0;
+ stringHeader &= num + -1870334726 ^ num2;
+ var packedStringBuf = _binStreamReader.Read(stringHeader);
+ // ReSharper disable once PossibleNullReferenceException
+ var key1 = key[1];
+ var length = packedStringBuf.Length;
+ var key1XorLen = (byte)(11 + length ^ 7 + key1);
+ var keysXorLen = (uint)((key[0] | key[2] << 8) + (key1XorLen << 3));
+ ushort keysXorLenLowWord = 0;
+ for (var index = 0; index < length; ++index)
+ {
+ if ((index & 1) == 0)
+ {
+ keysXorLen = keysXorLen * (uint)((num ^ -1082544904) - num2) + (uint)(num + -1933863442 ^ num2);
+ keysXorLenLowWord = (ushort)(keysXorLen >> 16);
+ }
+ var keysXorLenLowByte = (byte)keysXorLenLowWord;
+ keysXorLenLowWord = (ushort)(keysXorLenLowWord >> 8);
+ var inByte = packedStringBuf[index];
+ packedStringBuf[index] = (byte)(inByte ^ key1 ^ 3 + key1XorLen ^ keysXorLenLowByte);
+ key1XorLen = inByte;
+ }
+ if (_pkt != null != (_int3Dummy != (-1085052045 ^ num) - num2))
+ {
+ for (var j = 0; j < stringHeader; j = 1 + j)
+ {
+ // ReSharper disable once PossibleNullReferenceException
+ var b5 = _pkt[7 & j];
+ b5 = (byte)(b5 << 3 | b5 >> 5);
+ packedStringBuf[j] ^= b5;
+ }
+ }
+ var num23 = _int3Dummy - 12;
+ int unpackedLength;
+ byte[] unpackedStringBuf;
+ if (!flagCompressed)
+ {
+ unpackedLength = stringHeader;
+ unpackedStringBuf = packedStringBuf;
+ }
+ else
+ {
+ unpackedLength = packedStringBuf[2] | packedStringBuf[0] << 16 | packedStringBuf[3] << 8 | packedStringBuf[1] << 24;
+ unpackedStringBuf = new byte[unpackedLength];
+ Unpack(packedStringBuf, 4, unpackedStringBuf);
+ }
+ if (flagAnsi && num23 == (num + -1935832971 ^ num2))
+ {
+ var chArray = new char[unpackedLength];
+ for (var k = 0; k < unpackedLength; k++)
+ {
+ chArray[k] = (char)unpackedStringBuf[k];
+ }
+ str = new string(chArray);
+ }
+ else
+ {
+ str = Encoding.Unicode.GetString(unpackedStringBuf, 0, unpackedStringBuf.Length);
+ }
+ num23 += (-1082461318 ^ num) - num2 + (3 & num23) << 5;
+ if (num23 != (1065521775 - num ^ num2))
+ {
+ var num25 = stringHeader + id ^ -1935385949 + num - num2 ^ (num23 & (-1082460680 ^ num ^ num2));
+ var stringBuilder = new StringBuilder();
+ var num3 = 1065028445 - num - num2;
+ stringBuilder.Append((char)(byte)num3);
+ str = num25.ToString(stringBuilder.ToString());
+ }
+ if (!flagSecure & dummy)
+ {
+ str = string.Intern(str);
+ DecryptedStringsGlobal[id] = str;
+ if (DecryptedStringsGlobal.GetCachedPairs() == (num + -1936322454 ^ num2))
+ {
+ _binStreamReader.Close();
+ _binStreamReader = null;
+ _commonKey = null;
+ _pkt = null;
+ }
+ }
+ return str;
+ }
+ var refId = _binStreamReader.Read(4);
+ id = -64102883 ^ num ^ num2 ^ num6;
+ id = (refId[2] | refId[3] << 16 | refId[0] << 8 | refId[1] << 24) ^ -id;
+ str = DecryptedStringsGlobal[id];
+ return str;
+ }
+
+ // Token: 0x060002D1 RID: 721 RVA: 0x00013A28 File Offset: 0x00011C28
+ private static AssemblyName SafeAssemblyName(Assembly a) // \u0002
+ {
+ AssemblyName result;
+ try
+ {
+ result = a.GetName();
+ }
+ catch
+ {
+ result = new AssemblyName(a.FullName);
+ }
+ return result;
+ }
+
+ // Token: 0x060002D2 RID: 722 RVA: 0x00013A60 File Offset: 0x00011C60
+ private static byte[] SafeAssemblyPkt(AssemblyName an) // \u0002
+ {
+ var array = an.GetPublicKeyToken();
+ if (array != null && array.Length == 0)
+ {
+ array = null;
+ }
+ return array;
+ }
+
+ // Token: 0x060002D3 RID: 723 RVA: 0x00013A80 File Offset: 0x00011C80
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static bool CheckStack(StackTrace st, int idx) // \u0002
+ {
+ var a = st.GetFrame(idx + 1)?.GetMethod()?.DeclaringType?.Assembly;
+ if (a != null)
+ {
+ var assemblyName = SafeAssemblyName(a);
+ var array = SafeAssemblyPkt(assemblyName);
+ if (array != null && array.Length == 8 && array[0] == 183 && array[7] == 137)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // Token: 0x060002D4 RID: 724 RVA: 0x00013AF0 File Offset: 0x00011CF0
+ private static void Unpack(byte[] packedStringBuf, int idxPacked, byte[] unpackedStringBuf) // \u0002
+ {
+ var idxUnpacked = 0;
+ var packedBlockHeader = 0;
+ var byteMask = 0x80;
+ var unpackLen = unpackedStringBuf.Length;
+ while (idxUnpacked < unpackLen)
+ {
+ byteMask <<= 1;
+ if (byteMask == 0x100)
+ {
+ byteMask = 1;
+ packedBlockHeader = packedStringBuf[idxPacked++];
+ }
+ if ((packedBlockHeader & byteMask) == 0)
+ {
+ unpackedStringBuf[idxUnpacked++] = packedStringBuf[idxPacked++];
+ continue;
+ }
+ var knownWordLen = (packedStringBuf[idxPacked] >> 2) + 3;
+ var knownWordOffset = ((packedStringBuf[idxPacked] << 8) | packedStringBuf[idxPacked + 1]) & 0x3ff;
+ idxPacked += 2;
+ var knownWordIdx = idxUnpacked - knownWordOffset;
+ if (knownWordIdx < 0)
+ return;
+ while (--knownWordLen >= 0 && idxUnpacked < unpackLen)
+ {
+ unpackedStringBuf[idxUnpacked++] = unpackedStringBuf[knownWordIdx++];
+ }
+ }
+ }
+
+ // Token: 0x0200003E RID: 62
+ internal sealed class BinStreamReader // \u0003\u2002\u200A\u2008\u2008\u200B\u2002\u2006\u2002\u2009\u2009\u2006\u2004\u2006\u2002\u2007\u2006\u2003\u2001\u2007\u2003\u200A\u2009\u200B\u2003\u2001
+ {
+ private byte[] _header; // \u0003
+ private Stream _stream; // \u0002
+
+ // Token: 0x060002D5 RID: 725 RVA: 0x00013B94 File Offset: 0x00011D94
+ public BinStreamReader(Stream stream)
+ {
+ _stream = stream;
+ _header = new byte[4];
+ }
+
+ // Token: 0x060002D6 RID: 726 RVA: 0x00013BB0 File Offset: 0x00011DB0
+ public Stream GetStream() // \u0002
+ {
+ return _stream;
+ }
+
+ // Token: 0x060002D7 RID: 727 RVA: 0x00013BB8 File Offset: 0x00011DB8
+ public short ReadHeaderInt16() // \u0002
+ {
+ ReadHeader(2);
+ return (short) (_header[0] | (_header[1] << 8));
+ }
+
+ // Token: 0x060002D8 RID: 728 RVA: 0x00013BD8 File Offset: 0x00011DD8
+ public int ReadHeaderInt32() // \u0002
+ {
+ ReadHeader(4);
+ return _header[0] | (_header[1] << 8) | (_header[2] << 0x10) | (_header[3] << 0x18);
+ }
+
+ // Token: 0x060002D9 RID: 729 RVA: 0x00013C0C File Offset: 0x00011E0C
+ private void ThrowEOS() // \u0002
+ {
+ throw new EndOfStreamException();
+ }
+
+ // Token: 0x060002DA RID: 730 RVA: 0x00013C14 File Offset: 0x00011E14
+ private void ReadHeader(int headerSize) // \u0002
+ {
+ var offset = 0;
+ int read;
+ if (headerSize == 1)
+ {
+ read = _stream.ReadByte();
+ if (read == -1)
+ ThrowEOS();
+ _header[0] = (byte) read;
+ }
+ else
+ {
+ do
+ {
+ read = _stream.Read(_header, offset, headerSize - offset);
+ if (read == 0)
+ ThrowEOS();
+ offset += read;
+ } while (offset < headerSize);
+ }
+ }
+
+ // Token: 0x060002DB RID: 731 RVA: 0x00013C74 File Offset: 0x00011E74
+ public void Close() // \u0003
+ {
+ var stream = _stream;
+ _stream = null;
+ stream?.Close();
+ _header = null;
+ }
+
+ // Token: 0x060002DC RID: 732 RVA: 0x00013CA0 File Offset: 0x00011EA0
+ public byte[] Read(int bytesCount) // \u0002
+ {
+ if (bytesCount < 0)
+ throw new ArgumentOutOfRangeException();
+ var buffer = new byte[bytesCount];
+ var offset = 0;
+ do
+ {
+ var read = _stream.Read(buffer, offset, bytesCount);
+ if (read == 0)
+ break;
+ offset += read;
+ bytesCount -= read;
+ } while (bytesCount > 0);
+ if (offset != buffer.Length)
+ {
+ var dst = new byte[offset];
+ Buffer.BlockCopy(buffer, 0, dst, 0, offset);
+ buffer = dst;
+ }
+ return buffer;
+ }
+ }
+
+ // Token: 0x0200003F RID: 63
+ internal sealed class DecryptedStrings // \u0005\u2001\u2007\u200B\u2000\u2008\u2008\u2000\u2000\u2006\u2004\u2008\u200B\u2002\u2006\u200B\u2001\u200B\u2003\u2004\u2001\u2004
+ {
+ private int _cachedPairs; // \u0003
+ private Pair[] _arr; // \u0002
+
+ // Token: 0x060002DD RID: 733 RVA: 0x00013CFC File Offset: 0x00011EFC
+ public DecryptedStrings()
+ {
+ _arr = new Pair[0x10];
+ }
+
+ // Token: 0x060002DE RID: 734 RVA: 0x00013D14 File Offset: 0x00011F14
+ public DecryptedStrings(int capacityHint)
+ {
+ var capacity = 0x10;
+ capacityHint = capacityHint << 1;
+ while ((capacity < capacityHint) && (capacity > 0))
+ {
+ capacity = capacity << 1;
+ }
+ if (capacity < 0)
+ {
+ capacity = 0x10;
+ }
+ _arr = new Pair[capacity];
+ }
+
+ // Token: 0x060002DF RID: 735 RVA: 0x00013D54 File Offset: 0x00011F54
+ public int GetCachedPairs()
+ {
+ return _cachedPairs;
+ }
+
+ // Token: 0x060002E0 RID: 736 RVA: 0x00013D5C File Offset: 0x00011F5C
+ private void GrowCache() // \u0002
+ {
+ var length = _arr.Length;
+ var newLength = length * 2;
+ if (newLength > 0)
+ {
+ var newArr = new Pair[newLength];
+ var cnt = 0;
+ for (var i = 0; i < length; i++)
+ {
+ if (_arr[i].val != null)
+ {
+ var index = _arr[i].id & (newLength - 1);
+ while (true)
+ {
+ if (newArr[index].val == null)
+ {
+ newArr[index].val = _arr[i].val;
+ newArr[index].id = _arr[i].id;
+ cnt++;
+ break;
+ }
+ index++;
+ if (index >= newLength)
+ index = 0;
+ }
+ }
+ }
+ _arr = newArr;
+ _cachedPairs = cnt;
+ }
+ }
+
+ public string this[int id]
+ {
+ // Token: 0x060002E1 RID: 737 RVA: 0x00013E10 File Offset: 0x00012010
+ get // \u0002
+ {
+ var length = _arr.Length;
+ var index = id & (length - 1);
+ do
+ {
+ if (_arr[index].id == id || _arr[index].val == null)
+ return _arr[index].val;
+ index++;
+ if (index >= length)
+ index = 0;
+ } while (true);
+ }
+ // Token: 0x060002E2 RID: 738 RVA: 0x00013E6C File Offset: 0x0001206C
+ set // \u0002
+ {
+ var length = _arr.Length;
+ var halfLength = length >> 1;
+ var index = id & (length - 1);
+ do
+ {
+ var emptySlot = _arr[index].val == null;
+ if (_arr[index].id == id || emptySlot)
+ {
+ _arr[index].val = value;
+ if (emptySlot)
+ {
+ _arr[index].id = id;
+ _cachedPairs++;
+ if (_cachedPairs > halfLength)
+ GrowCache();
+ }
+ break;
+ }
+ index++;
+ if (index >= length)
+ index = 0;
+ } while (true);
+ }
+ }
+
+ // Token: 0x02000040 RID: 64
+ [StructLayout(LayoutKind.Sequential)]
+ private struct Pair // \u0002
+ {
+ public int id;
+ public string val;
+ }
+ }
+
+ // Token: 0x02000041 RID: 65
+ [Flags]
+ internal enum Enum1
+ {
+
+ }
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/TypeCompatibility.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/TypeCompatibility.cs
new file mode 100644
index 0000000..af9b155
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/TypeCompatibility.cs
@@ -0,0 +1,54 @@
+using System;
+
+namespace UnitTestProject.RefVm
+{
+ // Token: 0x02000055 RID: 85
+ internal static class TypeCompatibility // \u000E\u2006
+ {
+ // Token: 0x06000341 RID: 833 RVA: 0x000152D4 File Offset: 0x000134D4
+ public static bool Check(Type t1, Type t2) // t1
+ {
+ if (t1 == t2)
+ {
+ return true;
+ }
+ if (t1 == null || t2 == null)
+ {
+ return false;
+ }
+ if (t1.IsByRef)
+ {
+ return t2.IsByRef && Check(t1.GetElementType(), t2.GetElementType());
+ }
+ if (t2.IsByRef)
+ {
+ return false;
+ }
+ if (t1.IsPointer)
+ {
+ return t2.IsPointer && Check(t1.GetElementType(), t2.GetElementType());
+ }
+ if (t2.IsPointer)
+ {
+ return false;
+ }
+ if (t1.IsArray)
+ {
+ return t2.IsArray && t1.GetArrayRank() == t2.GetArrayRank() && Check(t1.GetElementType(), t2.GetElementType());
+ }
+ if (t2.IsArray)
+ {
+ return false;
+ }
+ if (t1.IsGenericType && !t1.IsGenericTypeDefinition)
+ {
+ t1 = t1.GetGenericTypeDefinition();
+ }
+ if (t2.IsGenericType && !t2.IsGenericTypeDefinition)
+ {
+ t2 = t2.GetGenericTypeDefinition();
+ }
+ return t1 == t2;
+ }
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VariantBase.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VariantBase.cs
new file mode 100644
index 0000000..0e60298
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VariantBase.cs
@@ -0,0 +1,2621 @@
+using System;
+using System.Linq;
+using System.Reflection;
+
+namespace UnitTestProject.RefVm
+{
+ // Token: 0x02000059 RID: 89
+ internal abstract class VariantBase // \u000F
+ {
+ // Token: 0x0600034A RID: 842
+ public abstract object GetValueAbstract(); // \u000F\u2008\u2000\u2002\u200A\u0002
+
+ // Token: 0x0600034B RID: 843
+ public abstract void SetValueAbstract(object o); // \u000F\u2008\u2000\u2002\u200A\u0002
+
+ // Token: 0x0600034C RID: 844
+ public enum Vtc
+ {
+ Tc0VariantBaseHolder,
+ Tc1Bool,
+ Tc2Array,
+ Tc3Method,
+ Tc4FieldInfo,
+ Tc5Enum,
+ Tc6Char,
+ Tc7Ulong,
+ Tc8Float,
+ Tc9Uint,
+ Tc10Ushort,
+ Tc11ValueType,
+ Tc12Sbyte,
+ Tc13UIntPtr,
+ Tc14Byte,
+ Tc15Short,
+ Tc16String,
+ Tc17IntPtr,
+ Tc18Object,
+ Tc19Int,
+ Tc20MdArrayValue,
+ Tc21Double,
+ Tc22SdArrayValue,
+ Tc23LocalsIdxHolder,
+ Tc24Long
+ }
+
+ public abstract Vtc GetTypeCode(); // \u000F\u2008\u2000\u2002\u200A\u0002
+
+ // Token: 0x0600034D RID: 845
+ public abstract VariantBase CopyFrom(VariantBase t); // \u000F\u2008\u2000\u2002\u200A\u0002
+
+ // Token: 0x0600034E RID: 846
+ public abstract VariantBase Clone(); // \u000F\u2008\u2000\u2002\u200A\u0002
+
+ // Token: 0x0600034F RID: 847 RVA: 0x000153EC File Offset: 0x000135EC
+ public virtual bool IsAddr() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return false;
+ }
+
+ // Token: 0x06000350 RID: 848 RVA: 0x000153F0 File Offset: 0x000135F0
+ public Type GetVariantType() // \u0002
+ {
+ return _type;
+ }
+
+ // Token: 0x06000351 RID: 849 RVA: 0x000153F8 File Offset: 0x000135F8
+ public void SetVariantType(Type val) // \u0002
+ {
+ _type = val;
+ }
+
+ // Token: 0x04000186 RID: 390
+ private Type _type; // \u0002
+
+ // bug was fixed and unit tested (было превращение Enum в число без учета переполнения)
+ public static long SignedLongFromEnum(EnumVariant src)
+ {
+ var val = src.GetValue();
+ switch (Convert.GetTypeCode(val))
+ {
+ /*case TypeCode.SByte:
+ case TypeCode.Int16:
+ case TypeCode.Int32:
+ case TypeCode.Int64:*/
+ default:
+ return Convert.ToInt64(val);
+ case TypeCode.Byte:
+ case TypeCode.UInt16:
+ case TypeCode.UInt32:
+ case TypeCode.UInt64:
+ return (long)Convert.ToUInt64(val);
+ }
+ }
+
+ public static VariantBase SignedVariantFromEnum(EnumVariant src)
+ {
+ var val = src.GetValue();
+ switch (Convert.GetTypeCode(val))
+ {
+ case TypeCode.SByte:
+ case TypeCode.Int16:
+ case TypeCode.Int32:
+ var i = Convert.ToInt32(val);
+ var reti = new IntVariant();
+ reti.SetValue(i);
+ return reti;
+ case TypeCode.Int64:
+ var l = Convert.ToInt64(val);
+ var retl = new LongVariant();
+ retl.SetValue(l);
+ return retl;
+ case TypeCode.Byte:
+ case TypeCode.UInt16:
+ case TypeCode.UInt32:
+ var u = Convert.ToUInt32(val);
+ var retu = new IntVariant();
+ retu.SetValue((int)u);
+ return retu;
+ //case TypeCode.UInt64:
+ default:
+ var ul = Convert.ToUInt64(val);
+ var retul = new LongVariant();
+ retul.SetValue((long)ul);
+ return retul;
+ }
+ }
+ }
+ // Token: 0x02000003 RID: 3
+ internal sealed class ArrayVariant : VariantBase // \u0002\u2000
+ {
+ // Token: 0x06000009 RID: 9 RVA: 0x000021A8 File Offset: 0x000003A8
+ public Array GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x0600000A RID: 10 RVA: 0x000021B0 File Offset: 0x000003B0
+ public void SetValue(Array val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x0600000B RID: 11 RVA: 0x000021BC File Offset: 0x000003BC
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x0600000C RID: 12 RVA: 0x000021C4 File Offset: 0x000003C4
+ public override void SetValueAbstract(object o) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetValue((Array)o);
+ }
+
+ // Token: 0x0600000D RID: 13 RVA: 0x000021D4 File Offset: 0x000003D4
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new ArrayVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetType());
+ return ret;
+ }
+
+ // Token: 0x0600000E RID: 14 RVA: 0x000021F4 File Offset: 0x000003F4
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc2Array;
+ }
+
+ // Token: 0x0600000F RID: 15 RVA: 0x000021F8 File Offset: 0x000003F8
+ public override VariantBase CopyFrom(VariantBase src) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(src.GetVariantType());
+ var num = src.GetTypeCode();
+ if (num != Vtc.Tc2Array)
+ {
+ if (num != Vtc.Tc18Object)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ SetValue((Array)((ObjectVariant)src).GetValue());
+ }
+ else
+ {
+ SetValue(((ArrayVariant)src).GetValue());
+ }
+ return this;
+ }
+
+ // Token: 0x04000001 RID: 1
+ private Array _value; // \u0002
+ }
+
+ // Token: 0x0200002B RID: 43
+ internal sealed class ObjectVariant : VariantBase // \u0006\u2002
+ {
+ // Token: 0x0600013E RID: 318 RVA: 0x00006458 File Offset: 0x00004658
+ public object GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x0600013F RID: 319 RVA: 0x00006460 File Offset: 0x00004660
+ public void SetValue(object val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x06000140 RID: 320 RVA: 0x0000646C File Offset: 0x0000466C
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x06000141 RID: 321 RVA: 0x00006474 File Offset: 0x00004674
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetValue(val);
+ }
+
+ // Token: 0x06000142 RID: 322 RVA: 0x00006480 File Offset: 0x00004680
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc18Object;
+ }
+
+ // Token: 0x06000143 RID: 323 RVA: 0x00006484 File Offset: 0x00004684
+ public override VariantBase CopyFrom(VariantBase src) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(src.GetVariantType());
+ SetValue(src.GetValueAbstract());
+ return this;
+ }
+
+ // Token: 0x06000144 RID: 324 RVA: 0x000064AC File Offset: 0x000046AC
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new ObjectVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x0400004E RID: 78
+ private object _value;
+ }
+
+ // Token: 0x02000004 RID: 4
+ internal sealed class ShortVariant : VariantBase
+ {
+ // Token: 0x06000011 RID: 17 RVA: 0x00002260 File Offset: 0x00000460
+ public short GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x06000012 RID: 18 RVA: 0x00002268 File Offset: 0x00000468
+ public void SetValue(short val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x06000013 RID: 19 RVA: 0x00002274 File Offset: 0x00000474
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x06000014 RID: 20 RVA: 0x00002284 File Offset: 0x00000484
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ if (val is int)
+ {
+ SetValue((short)(int)val);
+ return;
+ }
+ if (val is long)
+ {
+ SetValue((short)(long)val);
+ return;
+ }
+ if (val is ushort)
+ {
+ SetValue((short)(ushort)val);
+ return;
+ }
+ if (val is uint)
+ {
+ SetValue((short)(uint)val);
+ return;
+ }
+ if (val is ulong)
+ {
+ SetValue((short)(ulong)val);
+ return;
+ }
+ if (val is float)
+ {
+ SetValue((short)(float)val);
+ return;
+ }
+ if (val is double)
+ {
+ SetValue((short)(double)val);
+ return;
+ }
+ SetValue(Convert.ToInt16(val));
+ }
+
+ // Token: 0x06000015 RID: 21 RVA: 0x00002338 File Offset: 0x00000538
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new ShortVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x06000016 RID: 22 RVA: 0x00002358 File Offset: 0x00000558
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc15Short;
+ }
+
+ // Token: 0x06000017 RID: 23 RVA: 0x0000235C File Offset: 0x0000055C
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ switch (val.GetTypeCode())
+ {
+ case Vtc.Tc1Bool:
+ SetValue(Convert.ToByte(((BoolVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc5Enum:
+ SetValue(Convert.ToInt16(((EnumVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc7Ulong:
+ SetValue((short)((UlongVariant)val).GetValue());
+ return this;
+ case Vtc.Tc8Float:
+ SetValue((short)((FloatVariant)val).GetValue());
+ return this;
+ case Vtc.Tc9Uint:
+ SetValue((short)((UintVariant)val).GetValue());
+ return this;
+ case Vtc.Tc10Ushort:
+ SetValue((short)((UshortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc12Sbyte:
+ SetValue(((SbyteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc14Byte:
+ SetValue(((ByteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc15Short:
+ SetValue(((ShortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc17IntPtr:
+ SetValue((short)(int)((IntPtrVariant)val).GetValue());
+ return this;
+ case Vtc.Tc18Object:
+ SetValue(Convert.ToInt16(((ObjectVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc19Int:
+ SetValue((short)((IntVariant)val).GetValue());
+ return this;
+ case Vtc.Tc21Double:
+ SetValue((short)((DoubleVariant)val).GetValue());
+ return this;
+ case Vtc.Tc24Long:
+ SetValue((short)((LongVariant)val).GetValue());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x04000002 RID: 2
+ private short _value; // \u0002
+ }
+
+ // Token: 0x02000005 RID: 5
+ internal sealed class MethodVariant : VariantBase // \u0002\u2002
+ {
+ // Token: 0x06000019 RID: 25 RVA: 0x00002538 File Offset: 0x00000738
+ public MethodBase GetValue() //\u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x0600001A RID: 26 RVA: 0x00002540 File Offset: 0x00000740
+ public void SetValue(MethodBase val) //\u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x0600001B RID: 27 RVA: 0x0000254C File Offset: 0x0000074C
+ public IntPtr GetFunctionPointer() // \u0002
+ {
+ return GetValue().MethodHandle.GetFunctionPointer();
+ }
+
+ // Token: 0x0600001C RID: 28 RVA: 0x0000256C File Offset: 0x0000076C
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x0600001D RID: 29 RVA: 0x00002574 File Offset: 0x00000774
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetValue((MethodBase)val);
+ }
+
+ // Token: 0x0600001E RID: 30 RVA: 0x00002584 File Offset: 0x00000784
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc3Method;
+ }
+
+ // Token: 0x0600001F RID: 31 RVA: 0x00002588 File Offset: 0x00000788
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ var num = val.GetTypeCode();
+ if (num == Vtc.Tc3Method)
+ {
+ SetValue(((MethodVariant)val).GetValue());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x06000020 RID: 32 RVA: 0x000025C8 File Offset: 0x000007C8
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new MethodVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x04000003 RID: 3
+ private MethodBase _value;
+ }
+
+ // Token: 0x02000008 RID: 8
+ internal sealed class StringVariant : VariantBase // \u0002\u2005
+ {
+ // Token: 0x0600002B RID: 43 RVA: 0x000026BC File Offset: 0x000008BC
+ public string GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x0600002C RID: 44 RVA: 0x000026C4 File Offset: 0x000008C4
+ public void SetValue(string val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x0600002D RID: 45 RVA: 0x000026D0 File Offset: 0x000008D0
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x0600002E RID: 46 RVA: 0x000026D8 File Offset: 0x000008D8
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetValue((string)val);
+ }
+
+ // Token: 0x0600002F RID: 47 RVA: 0x000026E8 File Offset: 0x000008E8
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc16String;
+ }
+
+ // Token: 0x06000030 RID: 48 RVA: 0x000026EC File Offset: 0x000008EC
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ var num = val.GetTypeCode();
+ if (num != Vtc.Tc16String)
+ {
+ if (num != Vtc.Tc18Object)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ SetValue((string)((ObjectVariant)val).GetValue());
+ }
+ else
+ {
+ SetValue(((StringVariant)val).GetValue());
+ }
+ return this;
+ }
+
+ // Token: 0x06000031 RID: 49 RVA: 0x0000274C File Offset: 0x0000094C
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new StringVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x04000007 RID: 7
+ private string _value;
+ }
+
+ // Token: 0x0200000F RID: 15
+ internal sealed class BoolVariant : VariantBase // \u0003\u2000
+ {
+ // Token: 0x06000062 RID: 98 RVA: 0x00003470 File Offset: 0x00001670
+ public bool GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x06000063 RID: 99 RVA: 0x00003478 File Offset: 0x00001678
+ public void SetValue(bool val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x06000064 RID: 100 RVA: 0x00003484 File Offset: 0x00001684
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x06000065 RID: 101 RVA: 0x00003494 File Offset: 0x00001694
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetValue(Convert.ToBoolean(val));
+ }
+
+ // Token: 0x06000066 RID: 102 RVA: 0x000034A4 File Offset: 0x000016A4
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc1Bool;
+ }
+
+ // Token: 0x06000067 RID: 103 RVA: 0x000034A8 File Offset: 0x000016A8
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ switch (val.GetTypeCode())
+ {
+ case Vtc.Tc1Bool:
+ SetValue(((BoolVariant)val).GetValue());
+ return this;
+ case Vtc.Tc5Enum:
+ SetValue(Convert.ToBoolean(((EnumVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc7Ulong:
+ SetValue(Convert.ToBoolean(((UlongVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc9Uint:
+ SetValue(Convert.ToBoolean(((UintVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc10Ushort:
+ SetValue(Convert.ToBoolean(((UshortVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc12Sbyte:
+ SetValue(Convert.ToBoolean(((SbyteVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc13UIntPtr:
+ SetValue(Convert.ToBoolean(((UIntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc14Byte:
+ SetValue(Convert.ToBoolean(((ByteVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc15Short:
+ SetValue(Convert.ToBoolean(((ShortVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc17IntPtr:
+ SetValue(Convert.ToBoolean(((IntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc18Object:
+ SetValue(Convert.ToBoolean(((UIntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc19Int:
+ SetValue(Convert.ToBoolean(((IntVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc24Long:
+ SetValue(Convert.ToBoolean(((LongVariant)val).GetValue()));
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x06000068 RID: 104 RVA: 0x00003694 File Offset: 0x00001894
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new BoolVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x04000017 RID: 23
+ private bool _value;
+ }
+
+ // Token: 0x02000010 RID: 16
+ internal sealed class IntVariant : VariantBase // \u0003\u2001
+ {
+ // Token: 0x0600006A RID: 106 RVA: 0x000036BC File Offset: 0x000018BC
+ public int GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x0600006B RID: 107 RVA: 0x000036C4 File Offset: 0x000018C4
+ public void SetValue(int val) // \u0002
+ {
+
+ _value = val;
+ }
+
+ // Token: 0x0600006C RID: 108 RVA: 0x000036D0 File Offset: 0x000018D0
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x0600006D RID: 109 RVA: 0x000036E0 File Offset: 0x000018E0
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ if (val is long)
+ {
+ SetValue((int)((long)val));
+ return;
+ }
+ if (val is ushort)
+ {
+ SetValue((ushort)val);
+ return;
+ }
+ if (val is uint)
+ {
+ SetValue((int)((uint)val));
+ return;
+ }
+ if (val is ulong)
+ {
+ SetValue((int)((ulong)val));
+ return;
+ }
+ if (val is float)
+ {
+ SetValue((int)((float)val));
+ return;
+ }
+ if (val is double)
+ {
+ SetValue((int)((double)val));
+ return;
+ }
+ SetValue(Convert.ToInt32(val));
+ }
+
+ // Token: 0x0600006E RID: 110 RVA: 0x0000377C File Offset: 0x0000197C
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new IntVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x0600006F RID: 111 RVA: 0x0000379C File Offset: 0x0000199C
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc19Int;
+ }
+
+ // Token: 0x06000070 RID: 112 RVA: 0x000037A0 File Offset: 0x000019A0
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ switch (val.GetTypeCode())
+ {
+ case Vtc.Tc1Bool:
+ SetValue(Convert.ToByte(((BoolVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc5Enum:
+ SetValue(Convert.ToInt32(((EnumVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc7Ulong:
+ SetValue((int)((UlongVariant)val).GetValue());
+ return this;
+ case Vtc.Tc8Float:
+ SetValue((int)((FloatVariant)val).GetValue());
+ return this;
+ case Vtc.Tc9Uint:
+ SetValue((int)((UintVariant)val).GetValue());
+ return this;
+ case Vtc.Tc10Ushort:
+ SetValue(((UshortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc12Sbyte:
+ SetValue(((SbyteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc13UIntPtr:
+ SetValue((int)((uint)((UIntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc14Byte:
+ SetValue(((ByteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc15Short:
+ SetValue(((ShortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc17IntPtr:
+ SetValue((int)((IntPtrVariant)val).GetValue());
+ return this;
+ case Vtc.Tc18Object:
+ SetValue(Convert.ToInt32(((UIntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc19Int:
+ SetValue(((IntVariant)val).GetValue());
+ return this;
+ case Vtc.Tc21Double:
+ SetValue((int)((DoubleVariant)val).GetValue());
+ return this;
+ case Vtc.Tc24Long:
+ SetValue(Convert.ToInt32(((LongVariant)val).GetValue()));
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x04000018 RID: 24
+ private int _value;
+ }
+
+ // Token: 0x02000011 RID: 17
+ internal sealed class IntPtrVariant : VariantBase // \u0003\u2002
+ {
+ // Token: 0x06000072 RID: 114 RVA: 0x00003998 File Offset: 0x00001B98
+ public IntPtr GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x06000073 RID: 115 RVA: 0x000039A0 File Offset: 0x00001BA0
+ public void SetValue(IntPtr val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x06000074 RID: 116 RVA: 0x000039AC File Offset: 0x00001BAC
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new IntPtrVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x06000075 RID: 117 RVA: 0x000039CC File Offset: 0x00001BCC
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x06000076 RID: 118 RVA: 0x000039DC File Offset: 0x00001BDC
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetValue((IntPtr)val);
+ }
+
+ // Token: 0x06000077 RID: 119 RVA: 0x000039EC File Offset: 0x00001BEC
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc17IntPtr;
+ }
+
+ // Token: 0x06000078 RID: 120 RVA: 0x000039F0 File Offset: 0x00001BF0
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ switch (val.GetTypeCode())
+ {
+ case Vtc.Tc3Method:
+ {
+ var mv = (MethodVariant)val;
+ SetValue(mv.GetFunctionPointer());
+ return this;
+ }
+ case Vtc.Tc5Enum:
+ SetValue(new IntPtr(Convert.ToInt64(((EnumVariant)val).GetValue())));
+ return this;
+ case Vtc.Tc7Ulong:
+ SetValue((IntPtr)((long)((UlongVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc8Float:
+ SetValue((IntPtr)((long)((FloatVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc9Uint:
+ SetValue((IntPtr)((long)((UintVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc10Ushort:
+ SetValue((IntPtr)((int)((UshortVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc12Sbyte:
+ SetValue((IntPtr)((SbyteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc14Byte:
+ SetValue((IntPtr)((int)((ByteVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc15Short:
+ SetValue((IntPtr)((ShortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc17IntPtr:
+ SetValue(((IntPtrVariant)val).GetValue());
+ return this;
+ case Vtc.Tc18Object:
+ SetValue((IntPtr)((UIntPtrVariant)val).GetValue().ToUInt64());
+ return this;
+ case Vtc.Tc19Int:
+ SetValue((IntPtr)((IntVariant)val).GetValue());
+ return this;
+ case Vtc.Tc21Double:
+ SetValue((IntPtr)((long)((DoubleVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc24Long:
+ SetValue((IntPtr)((LongVariant)val).GetValue());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x04000019 RID: 25
+ private IntPtr _value;
+ }
+
+ // Token: 0x02000014 RID: 20
+ internal sealed class ValueTypeVariant : VariantBase // \u0003\u2005
+ {
+ // Token: 0x06000086 RID: 134 RVA: 0x00003CF0 File Offset: 0x00001EF0
+ public ValueTypeVariant(object val)
+ {
+ if (val != null && !(val is ValueType))
+ {
+ throw new ArgumentException();
+ }
+ _value = val;
+ }
+
+ // Token: 0x06000087 RID: 135 RVA: 0x00003D10 File Offset: 0x00001F10
+ public object GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x06000088 RID: 136 RVA: 0x00003D18 File Offset: 0x00001F18
+ public void SetValue(object val) // \u0002
+ {
+ if (val != null && !(val is ValueType))
+ {
+ throw new ArgumentException();
+ }
+ _value = val;
+ }
+
+ // Token: 0x06000089 RID: 137 RVA: 0x00003D34 File Offset: 0x00001F34
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x0600008A RID: 138 RVA: 0x00003D3C File Offset: 0x00001F3C
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetValue(val);
+ }
+
+ // Token: 0x0600008B RID: 139 RVA: 0x00003D48 File Offset: 0x00001F48
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc11ValueType;
+ }
+
+ // Token: 0x0600008C RID: 140 RVA: 0x00003D4C File Offset: 0x00001F4C
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ var num = val.GetTypeCode();
+ if (num != Vtc.Tc11ValueType)
+ {
+ if (num != Vtc.Tc18Object)
+ {
+ SetValue(val.GetTypeCode());
+ }
+ else
+ {
+ SetValue(((UIntPtrVariant)val).GetValue());
+ }
+ }
+ else if (GetValue() != null)
+ {
+ var obj = ((ValueTypeVariant)val).GetValue();
+ var type = GetValue().GetType();
+ // ReSharper disable once UseMethodIsInstanceOfType
+ if (obj != null && !type.IsPrimitive && !type.IsEnum && type.IsAssignableFrom(obj.GetType()))
+ {
+ var fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags.GetField | BindingFlags.SetField);
+ foreach (var fieldInfo in fields)
+ {
+ fieldInfo.SetValue(GetValue(), fieldInfo.GetValue(obj));
+ }
+ }
+ else
+ {
+ SetValue(obj);
+ }
+ }
+ else
+ {
+ SetValue(((ValueTypeVariant)val).GetValue());
+ }
+ return this;
+ }
+
+ // Token: 0x0600008D RID: 141 RVA: 0x00003E38 File Offset: 0x00002038
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new ValueTypeVariant(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x0400001D RID: 29
+ private object _value;
+ }
+
+ // Token: 0x0200001C RID: 28
+ internal sealed class CharVariant : VariantBase // \u0005\u2000
+ {
+ // Token: 0x060000A9 RID: 169 RVA: 0x000042D0 File Offset: 0x000024D0
+ public char GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x060000AA RID: 170 RVA: 0x000042D8 File Offset: 0x000024D8
+ public void SetValue(char val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x060000AB RID: 171 RVA: 0x000042E4 File Offset: 0x000024E4
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x060000AC RID: 172 RVA: 0x000042F4 File Offset: 0x000024F4
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetValue(Convert.ToChar(val));
+ }
+
+ // Token: 0x060000AD RID: 173 RVA: 0x00004304 File Offset: 0x00002504
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc6Char;
+ }
+
+ // Token: 0x060000AE RID: 174 RVA: 0x00004308 File Offset: 0x00002508
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ switch (val.GetTypeCode())
+ {
+ case Vtc.Tc1Bool:
+ SetValue(Convert.ToChar(((BoolVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc5Enum:
+ SetValue(Convert.ToChar(((EnumVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc6Char:
+ SetValue(((CharVariant)val).GetValue());
+ return this;
+ case Vtc.Tc7Ulong:
+ SetValue((char)((UlongVariant)val).GetValue());
+ return this;
+ case Vtc.Tc9Uint:
+ SetValue((char)((UintVariant)val).GetValue());
+ return this;
+ case Vtc.Tc10Ushort:
+ SetValue((char)((UshortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc12Sbyte:
+ SetValue((char)((SbyteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc13UIntPtr:
+ SetValue((char)((uint)((UIntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc14Byte:
+ SetValue((char)((ByteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc15Short:
+ SetValue((char)((ShortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc17IntPtr:
+ SetValue((char)((int)((IntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc18Object:
+ SetValue(Convert.ToChar(((UIntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc19Int:
+ SetValue((char)((IntVariant)val).GetValue());
+ return this;
+ case Vtc.Tc24Long:
+ SetValue((char)((LongVariant)val).GetValue());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x060000AF RID: 175 RVA: 0x000044E0 File Offset: 0x000026E0
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new CharVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x04000026 RID: 38
+ private char _value;
+ }
+
+ // Token: 0x0200001D RID: 29
+ internal sealed class LongVariant : VariantBase // \u0005\u2001
+ {
+ // Token: 0x060000B1 RID: 177 RVA: 0x00004508 File Offset: 0x00002708
+ public long GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x060000B2 RID: 178 RVA: 0x00004510 File Offset: 0x00002710
+ public void SetValue(long val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x060000B3 RID: 179 RVA: 0x0000451C File Offset: 0x0000271C
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x060000B4 RID: 180 RVA: 0x0000452C File Offset: 0x0000272C
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ if (val is ulong)
+ {
+ SetValue((long)((ulong)val));
+ return;
+ }
+ if (val is float)
+ {
+ SetValue((long)((float)val));
+ return;
+ }
+ if (val is double)
+ {
+ SetValue((long)((double)val));
+ return;
+ }
+ SetValue(Convert.ToInt64(val));
+ }
+
+ // Token: 0x060000B5 RID: 181 RVA: 0x00004588 File Offset: 0x00002788
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new LongVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x060000B6 RID: 182 RVA: 0x000045A8 File Offset: 0x000027A8
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc24Long;
+ }
+
+ // Token: 0x060000B7 RID: 183 RVA: 0x000045AC File Offset: 0x000027AC
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ switch (val.GetTypeCode())
+ {
+ case Vtc.Tc1Bool:
+ SetValue(Convert.ToByte(((BoolVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc5Enum:
+ SetValue(Convert.ToInt64(((EnumVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc7Ulong:
+ SetValue((long)((UlongVariant)val).GetValue());
+ return this;
+ case Vtc.Tc8Float:
+ SetValue((long)((FloatVariant)val).GetValue());
+ return this;
+ case Vtc.Tc9Uint:
+ SetValue(((UintVariant)val).GetValue());
+ return this;
+ case Vtc.Tc10Ushort:
+ SetValue(((UshortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc12Sbyte:
+ SetValue(((SbyteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc13UIntPtr:
+ SetValue((long)((ulong)((UIntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc14Byte:
+ SetValue(((ByteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc15Short:
+ SetValue(((ShortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc17IntPtr:
+ SetValue((long)((IntPtrVariant)val).GetValue());
+ return this;
+ case Vtc.Tc18Object:
+ SetValue(Convert.ToInt64(((UIntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc19Int:
+ SetValue(((IntVariant)val).GetValue());
+ return this;
+ case Vtc.Tc21Double:
+ SetValue((long)((DoubleVariant)val).GetValue());
+ return this;
+ case Vtc.Tc24Long:
+ SetValue(((LongVariant)val).GetValue());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x04000027 RID: 39
+ private long _value;
+ }
+
+ // Token: 0x0200001E RID: 30
+ internal sealed class UIntPtrVariant : VariantBase // \u0005\u2002
+ {
+ // Token: 0x060000B9 RID: 185 RVA: 0x000047A4 File Offset: 0x000029A4
+ public UIntPtr GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x060000BA RID: 186 RVA: 0x000047AC File Offset: 0x000029AC
+ public void SetValue(UIntPtr val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x060000BB RID: 187 RVA: 0x000047B8 File Offset: 0x000029B8
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new UIntPtrVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x060000BC RID: 188 RVA: 0x000047D8 File Offset: 0x000029D8
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x060000BD RID: 189 RVA: 0x000047E8 File Offset: 0x000029E8
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetValue((UIntPtr)val);
+ }
+
+ // Token: 0x060000BE RID: 190 RVA: 0x000047F8 File Offset: 0x000029F8
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc13UIntPtr;
+ }
+
+ // Token: 0x060000BF RID: 191 RVA: 0x000047FC File Offset: 0x000029FC
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ switch (val.GetTypeCode())
+ {
+ case Vtc.Tc5Enum:
+ SetValue(new UIntPtr(Convert.ToUInt64(((EnumVariant)val).GetValue())));
+ return this;
+ case Vtc.Tc7Ulong:
+ SetValue((UIntPtr)((UlongVariant)val).GetValue());
+ return this;
+ case Vtc.Tc8Float:
+ SetValue((UIntPtr)((ulong)((FloatVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc9Uint:
+ SetValue((UIntPtr)((UintVariant)val).GetValue());
+ return this;
+ case Vtc.Tc10Ushort:
+ SetValue((UIntPtr)((UshortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc13UIntPtr:
+ SetValue(((UIntPtrVariant)val).GetValue());
+ return this;
+ case Vtc.Tc14Byte:
+ SetValue((UIntPtr)((ByteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc18Object:
+ SetValue(((UIntPtrVariant)val).GetValue());
+ return this;
+ case Vtc.Tc19Int:
+ SetValue((UIntPtr)((ulong)((IntVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc21Double:
+ SetValue((UIntPtr)((ulong)((DoubleVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc24Long:
+ SetValue((UIntPtr)((ulong)((LongVariant)val).GetValue()));
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x04000028 RID: 40
+ private UIntPtr _value;
+ }
+
+ // Token: 0x02000029 RID: 41
+ internal sealed class DoubleVariant : VariantBase // \u0006\u2000
+ {
+ // Token: 0x0600012E RID: 302 RVA: 0x00005F98 File Offset: 0x00004198
+ public double GetValue()
+ {
+ return _value;
+ }
+
+ // Token: 0x0600012F RID: 303 RVA: 0x00005FA0 File Offset: 0x000041A0
+ public void SetValue(double val)
+ {
+ _value = val;
+ }
+
+ // Token: 0x06000130 RID: 304 RVA: 0x00005FAC File Offset: 0x000041AC
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x06000131 RID: 305 RVA: 0x00005FBC File Offset: 0x000041BC
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetValue(Convert.ToDouble(val));
+ }
+
+ // Token: 0x06000132 RID: 306 RVA: 0x00005FCC File Offset: 0x000041CC
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new DoubleVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x06000133 RID: 307 RVA: 0x00005FEC File Offset: 0x000041EC
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc21Double;
+ }
+
+ // Token: 0x06000134 RID: 308 RVA: 0x00005FF0 File Offset: 0x000041F0
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ switch (val.GetTypeCode())
+ {
+ case Vtc.Tc7Ulong:
+ SetValue(((UlongVariant)val).GetValue());
+ return this;
+ case Vtc.Tc8Float:
+ SetValue(((FloatVariant)val).GetValue());
+ return this;
+ case Vtc.Tc9Uint:
+ SetValue(((UintVariant)val).GetValue());
+ return this;
+ case Vtc.Tc10Ushort:
+ SetValue(((UshortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc12Sbyte:
+ SetValue(((SbyteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc14Byte:
+ SetValue(((ByteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc15Short:
+ SetValue(((ShortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc18Object:
+ SetValue((double)((UIntPtrVariant)val).GetValue());
+ return this;
+ case Vtc.Tc19Int:
+ SetValue(((IntVariant)val).GetValue());
+ return this;
+ case Vtc.Tc21Double:
+ SetValue(((DoubleVariant)val).GetValue());
+ return this;
+ case Vtc.Tc24Long:
+ SetValue(((LongVariant)val).GetValue());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x0400004C RID: 76
+ private double _value;
+ }
+
+ // Token: 0x0200002A RID: 42
+ internal sealed class UshortVariant : VariantBase // \u0006\u2001
+ {
+ // Token: 0x06000136 RID: 310 RVA: 0x00006164 File Offset: 0x00004364
+ public ushort GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x06000137 RID: 311 RVA: 0x0000616C File Offset: 0x0000436C
+ public void SetValue(ushort val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x06000138 RID: 312 RVA: 0x00006178 File Offset: 0x00004378
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x06000139 RID: 313 RVA: 0x00006188 File Offset: 0x00004388
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ if (val is short)
+ {
+ SetValue((ushort)((short)val));
+ return;
+ }
+ if (val is int)
+ {
+ SetValue((ushort)((int)val));
+ return;
+ }
+ if (val is long)
+ {
+ SetValue((ushort)((long)val));
+ return;
+ }
+ if (val is uint)
+ {
+ SetValue((ushort)((uint)val));
+ return;
+ }
+ if (val is ulong)
+ {
+ SetValue((ushort)((ulong)val));
+ return;
+ }
+ if (val is float)
+ {
+ SetValue((ushort)((float)val));
+ return;
+ }
+ if (val is double)
+ {
+ SetValue((ushort)((double)val));
+ return;
+ }
+ SetValue(Convert.ToUInt16(val));
+ }
+
+ // Token: 0x0600013A RID: 314 RVA: 0x0000623C File Offset: 0x0000443C
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new UshortVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x0600013B RID: 315 RVA: 0x0000625C File Offset: 0x0000445C
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc10Ushort;
+ }
+
+ // Token: 0x0600013C RID: 316 RVA: 0x00006260 File Offset: 0x00004460
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ switch (val.GetTypeCode())
+ {
+ case Vtc.Tc1Bool:
+ SetValue(Convert.ToByte(((BoolVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc5Enum:
+ SetValue(Convert.ToUInt16(((EnumVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc7Ulong:
+ SetValue((ushort)((UlongVariant)val).GetValue());
+ return this;
+ case Vtc.Tc8Float:
+ SetValue((ushort)((FloatVariant)val).GetValue());
+ return this;
+ case Vtc.Tc9Uint:
+ SetValue((ushort)((UintVariant)val).GetValue());
+ return this;
+ case Vtc.Tc10Ushort:
+ SetValue(((UshortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc12Sbyte:
+ SetValue((ushort)((SbyteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc13UIntPtr:
+ SetValue((ushort)((uint)((UIntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc14Byte:
+ SetValue(((ByteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc15Short:
+ SetValue((ushort)((ShortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc17IntPtr:
+ SetValue((ushort)((int)((IntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc18Object:
+ SetValue(Convert.ToUInt16(((UIntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc19Int:
+ SetValue((ushort)((IntVariant)val).GetValue());
+ return this;
+ case Vtc.Tc21Double:
+ SetValue((ushort)((DoubleVariant)val).GetValue());
+ return this;
+ case Vtc.Tc24Long:
+ SetValue((ushort)((LongVariant)val).GetValue());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x0400004D RID: 77
+ private ushort _value;
+ }
+
+ // Token: 0x02000043 RID: 67
+ internal sealed class EnumVariant : VariantBase // \u0008\u2000
+ {
+ // Token: 0x060002E6 RID: 742 RVA: 0x00013F1C File Offset: 0x0001211C
+ public EnumVariant(Enum val)
+ {
+ if (val == null)
+ {
+ throw new ArgumentException();
+ }
+ _value = val;
+ }
+
+ // Token: 0x060002E7 RID: 743 RVA: 0x00013F34 File Offset: 0x00012134
+ public Enum GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x060002E8 RID: 744 RVA: 0x00013F3C File Offset: 0x0001213C
+ public void SetValue(Enum val) // \u0002
+ {
+ if (val == null)
+ {
+ throw new ArgumentException();
+ }
+ _value = val;
+ }
+
+ // Token: 0x060002E9 RID: 745 RVA: 0x00013F50 File Offset: 0x00012150
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x060002EA RID: 746 RVA: 0x00013F58 File Offset: 0x00012158
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetValue((Enum)Enum.Parse(GetValue().GetType(), val.ToString()));
+ }
+
+ // Token: 0x060002EB RID: 747 RVA: 0x00013F88 File Offset: 0x00012188
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc5Enum;
+ }
+
+ // Token: 0x060002EC RID: 748 RVA: 0x00013F8C File Offset: 0x0001218C
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ var num = val.GetTypeCode();
+ switch (num)
+ {
+ case Vtc.Tc5Enum:
+ {
+ var type = _value.GetType();
+ var @enum = ((EnumVariant)val).GetValue();
+ if (@enum.GetType() == type)
+ {
+ SetValue(@enum);
+ return this;
+ }
+ SetValue((Enum)Enum.ToObject(type, @enum));
+ return this;
+ }
+ case Vtc.Tc6Char:
+ case Vtc.Tc8Float:
+ case Vtc.Tc11ValueType:
+ case Vtc.Tc13UIntPtr:
+ case Vtc.Tc16String:
+ case Vtc.Tc17IntPtr:
+ break;
+ case Vtc.Tc7Ulong:
+ SetValue((Enum)Enum.ToObject(_value.GetType(), ((UlongVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc9Uint:
+ SetValue((Enum)Enum.ToObject(_value.GetType(), ((UintVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc10Ushort:
+ SetValue((Enum)Enum.ToObject(_value.GetType(), ((UshortVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc12Sbyte:
+ SetValue((Enum)Enum.ToObject(_value.GetType(), ((SbyteVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc14Byte:
+ SetValue((Enum)Enum.ToObject(_value.GetType(), ((ByteVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc15Short:
+ SetValue((Enum)Enum.ToObject(_value.GetType(), ((ShortVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc18Object:
+ SetValue((Enum)Enum.ToObject(_value.GetType(), ((UIntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc19Int:
+ SetValue((Enum)Enum.ToObject(_value.GetType(), ((IntVariant)val).GetValue()));
+ return this;
+ default:
+ if (num == Vtc.Tc24Long)
+ {
+ SetValue((Enum)Enum.ToObject(_value.GetType(), ((LongVariant)val).GetValue()));
+ return this;
+ }
+ break;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x060002ED RID: 749 RVA: 0x000141C0 File Offset: 0x000123C0
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new EnumVariant(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x04000172 RID: 370
+ private Enum _value;
+ }
+
+ // Token: 0x02000044 RID: 68
+ internal sealed class SbyteVariant : VariantBase // \u0008\u2001
+ {
+ // Token: 0x060002EF RID: 751 RVA: 0x000141E4 File Offset: 0x000123E4
+ public sbyte GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x060002F0 RID: 752 RVA: 0x000141EC File Offset: 0x000123EC
+ public void SetValue(sbyte val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x060002F1 RID: 753 RVA: 0x000141F8 File Offset: 0x000123F8
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x060002F2 RID: 754 RVA: 0x00014208 File Offset: 0x00012408
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ if (val is byte)
+ {
+ SetValue((sbyte)((byte)val));
+ return;
+ }
+ if (val is short)
+ {
+ SetValue((sbyte)((short)val));
+ return;
+ }
+ if (val is int)
+ {
+ SetValue((sbyte)((int)val));
+ return;
+ }
+ if (val is long)
+ {
+ SetValue((sbyte)((long)val));
+ return;
+ }
+ if (val is ushort)
+ {
+ SetValue((sbyte)((ushort)val));
+ return;
+ }
+ if (val is uint)
+ {
+ SetValue((sbyte)((uint)val));
+ return;
+ }
+ if (val is ulong)
+ {
+ SetValue((sbyte)((ulong)val));
+ return;
+ }
+ if (val is float)
+ {
+ SetValue((sbyte)((float)val));
+ return;
+ }
+ if (val is double)
+ {
+ SetValue((sbyte)((double)val));
+ return;
+ }
+ SetValue(Convert.ToSByte(val));
+ }
+
+ // Token: 0x060002F3 RID: 755 RVA: 0x000142E8 File Offset: 0x000124E8
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new SbyteVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x060002F4 RID: 756 RVA: 0x00014308 File Offset: 0x00012508
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc12Sbyte;
+ }
+
+ // Token: 0x060002F5 RID: 757 RVA: 0x0001430C File Offset: 0x0001250C
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ switch (val.GetTypeCode())
+ {
+ case Vtc.Tc1Bool:
+ SetValue(Convert.ToSByte(((BoolVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc5Enum:
+ SetValue(Convert.ToSByte(((EnumVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc7Ulong:
+ SetValue((sbyte)((UlongVariant)val).GetValue());
+ return this;
+ case Vtc.Tc8Float:
+ SetValue((sbyte)((FloatVariant)val).GetValue());
+ return this;
+ case Vtc.Tc9Uint:
+ SetValue((sbyte)((UintVariant)val).GetValue());
+ return this;
+ case Vtc.Tc10Ushort:
+ SetValue((sbyte)((UshortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc12Sbyte:
+ SetValue(((SbyteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc14Byte:
+ SetValue((sbyte)((ByteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc15Short:
+ SetValue((sbyte)((ShortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc17IntPtr:
+ SetValue((sbyte)((int)((IntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc18Object:
+ SetValue(Convert.ToSByte(((UIntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc19Int:
+ SetValue((sbyte)((IntVariant)val).GetValue());
+ return this;
+ case Vtc.Tc21Double:
+ SetValue((sbyte)((DoubleVariant)val).GetValue());
+ return this;
+ case Vtc.Tc24Long:
+ SetValue((sbyte)((LongVariant)val).GetValue());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x04000173 RID: 371
+ private sbyte _value;
+ }
+
+ // Token: 0x0200004E RID: 78
+ internal sealed class FloatVariant : VariantBase // \u000E\u2000
+ {
+ // Token: 0x06000326 RID: 806 RVA: 0x00014CA4 File Offset: 0x00012EA4
+ public float GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x06000327 RID: 807 RVA: 0x00014CAC File Offset: 0x00012EAC
+ public void SetValue(float val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x06000328 RID: 808 RVA: 0x00014CB8 File Offset: 0x00012EB8
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x06000329 RID: 809 RVA: 0x00014CC8 File Offset: 0x00012EC8
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetValue(Convert.ToSingle(val));
+ }
+
+ // Token: 0x0600032A RID: 810 RVA: 0x00014CD8 File Offset: 0x00012ED8
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new FloatVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x0600032B RID: 811 RVA: 0x00014CF8 File Offset: 0x00012EF8
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc8Float;
+ }
+
+ // Token: 0x0600032C RID: 812 RVA: 0x00014CFC File Offset: 0x00012EFC
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ switch (val.GetTypeCode())
+ {
+ case Vtc.Tc5Enum:
+ SetValue(Convert.ToSingle(((EnumVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc7Ulong:
+ SetValue(((UlongVariant)val).GetValue());
+ return this;
+ case Vtc.Tc8Float:
+ SetValue(((FloatVariant)val).GetValue());
+ return this;
+ case Vtc.Tc9Uint:
+ SetValue(((UintVariant)val).GetValue());
+ return this;
+ case Vtc.Tc10Ushort:
+ SetValue(((UshortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc12Sbyte:
+ SetValue(((SbyteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc14Byte:
+ SetValue(((ByteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc15Short:
+ SetValue(((ShortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc18Object:
+ SetValue((float)((UIntPtrVariant)val).GetValue());
+ return this;
+ case Vtc.Tc19Int:
+ SetValue(((IntVariant)val).GetValue());
+ return this;
+ case Vtc.Tc21Double:
+ SetValue((float)((DoubleVariant)val).GetValue());
+ return this;
+ case Vtc.Tc24Long:
+ SetValue(((LongVariant)val).GetValue());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x0400017E RID: 382
+ private float _value;
+ }
+
+ // Token: 0x0200004F RID: 79
+ internal sealed class UintVariant : VariantBase // \u000E\u2001
+ {
+ // Token: 0x0600032E RID: 814 RVA: 0x00014E94 File Offset: 0x00013094
+ public uint GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x0600032F RID: 815 RVA: 0x00014E9C File Offset: 0x0001309C
+ public void SetValue(uint val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x06000330 RID: 816 RVA: 0x00014EA8 File Offset: 0x000130A8
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x06000331 RID: 817 RVA: 0x00014EB8 File Offset: 0x000130B8
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ if (val is short)
+ {
+ SetValue((uint)((short)val));
+ return;
+ }
+ if (val is int)
+ {
+ SetValue((uint)((int)val));
+ return;
+ }
+ if (val is long)
+ {
+ SetValue((uint)((long)val));
+ return;
+ }
+ if (val is ulong)
+ {
+ SetValue((uint)((ulong)val));
+ return;
+ }
+ if (val is float)
+ {
+ SetValue((uint)((float)val));
+ return;
+ }
+ if (val is double)
+ {
+ SetValue((uint)((double)val));
+ return;
+ }
+ SetValue(Convert.ToUInt32(val));
+ }
+
+ // Token: 0x06000332 RID: 818 RVA: 0x00014F54 File Offset: 0x00013154
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new UintVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x06000333 RID: 819 RVA: 0x00014F74 File Offset: 0x00013174
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc9Uint;
+ }
+
+ // Token: 0x06000334 RID: 820 RVA: 0x00014F78 File Offset: 0x00013178
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ switch (val.GetTypeCode())
+ {
+ case Vtc.Tc1Bool:
+ SetValue(Convert.ToByte(((BoolVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc5Enum:
+ SetValue(Convert.ToUInt32(((EnumVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc7Ulong:
+ SetValue((uint)((UlongVariant)val).GetValue());
+ return this;
+ case Vtc.Tc8Float:
+ SetValue((uint)((FloatVariant)val).GetValue());
+ return this;
+ case Vtc.Tc9Uint:
+ SetValue(((UintVariant)val).GetValue());
+ return this;
+ case Vtc.Tc10Ushort:
+ SetValue(((UshortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc12Sbyte:
+ SetValue((uint)((SbyteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc13UIntPtr:
+ SetValue((uint)((UIntPtrVariant)val).GetValue());
+ return this;
+ case Vtc.Tc14Byte:
+ SetValue(((ByteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc15Short:
+ SetValue((uint)((ShortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc17IntPtr:
+ SetValue((uint)((int)((IntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc18Object:
+ SetValue(Convert.ToUInt32(((UIntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc19Int:
+ SetValue((uint)((IntVariant)val).GetValue());
+ return this;
+ case Vtc.Tc21Double:
+ SetValue((uint)((DoubleVariant)val).GetValue());
+ return this;
+ case Vtc.Tc24Long:
+ SetValue((uint)((LongVariant)val).GetValue());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x0400017F RID: 383
+ private uint _value;
+ }
+
+ // Token: 0x0200005A RID: 90
+ internal sealed class ByteVariant : VariantBase // \u000F\u2000
+ {
+ // Token: 0x06000353 RID: 851 RVA: 0x0001540C File Offset: 0x0001360C
+ public byte GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x06000354 RID: 852 RVA: 0x00015414 File Offset: 0x00013614
+ public void SetValue(byte val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x06000355 RID: 853 RVA: 0x00015420 File Offset: 0x00013620
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new ByteVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x06000356 RID: 854 RVA: 0x00015440 File Offset: 0x00013640
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x06000357 RID: 855 RVA: 0x00015450 File Offset: 0x00013650
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ if (val is short)
+ {
+ SetValue((byte)((short)val));
+ return;
+ }
+ if (val is int)
+ {
+ SetValue((byte)((int)val));
+ return;
+ }
+ if (val is long)
+ {
+ SetValue((byte)((long)val));
+ return;
+ }
+ if (val is ushort)
+ {
+ SetValue((byte)((ushort)val));
+ return;
+ }
+ if (val is uint)
+ {
+ SetValue((byte)((uint)val));
+ return;
+ }
+ if (val is ulong)
+ {
+ SetValue((byte)((ulong)val));
+ return;
+ }
+ if (val is float)
+ {
+ SetValue((byte)((float)val));
+ return;
+ }
+ if (val is double)
+ {
+ SetValue((byte)((double)val));
+ return;
+ }
+ SetValue(Convert.ToByte(val));
+ }
+
+ // Token: 0x06000358 RID: 856 RVA: 0x0001551C File Offset: 0x0001371C
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc14Byte;
+ }
+
+ // Token: 0x06000359 RID: 857 RVA: 0x00015520 File Offset: 0x00013720
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ switch (val.GetTypeCode())
+ {
+ case Vtc.Tc1Bool:
+ SetValue(Convert.ToByte(((BoolVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc5Enum:
+ SetValue(Convert.ToByte(((EnumVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc7Ulong:
+ SetValue((byte)((UlongVariant)val).GetValue());
+ return this;
+ case Vtc.Tc8Float:
+ SetValue((byte)((FloatVariant)val).GetValue());
+ return this;
+ case Vtc.Tc9Uint:
+ SetValue((byte)((UintVariant)val).GetValue());
+ return this;
+ case Vtc.Tc10Ushort:
+ SetValue((byte)((UshortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc12Sbyte:
+ SetValue((byte)((SbyteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc13UIntPtr:
+ SetValue((byte)((uint)((UIntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc14Byte:
+ SetValue(((ByteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc15Short:
+ SetValue((byte)((ShortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc17IntPtr:
+ SetValue((byte)((int)((IntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc18Object:
+ SetValue(Convert.ToByte(((UIntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc19Int:
+ SetValue((byte)((IntVariant)val).GetValue());
+ return this;
+ case Vtc.Tc21Double:
+ SetValue((byte)((DoubleVariant)val).GetValue());
+ return this;
+ case Vtc.Tc24Long:
+ SetValue((byte)((LongVariant)val).GetValue());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x04000187 RID: 391
+ private byte _value;
+ }
+
+ // Token: 0x0200005B RID: 91
+ internal sealed class UlongVariant : VariantBase // \u000F\u2001
+ {
+ // Token: 0x0600035B RID: 859 RVA: 0x00015718 File Offset: 0x00013918
+ public ulong GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x0600035C RID: 860 RVA: 0x00015720 File Offset: 0x00013920
+ public void SetValue(ulong val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x0600035D RID: 861 RVA: 0x0001572C File Offset: 0x0001392C
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetValue();
+ }
+
+ // Token: 0x0600035E RID: 862 RVA: 0x0001573C File Offset: 0x0001393C
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ if (val is short)
+ {
+ SetValue((ulong)(short)val);
+ return;
+ }
+ if (val is int)
+ {
+ SetValue((ulong)(int)val);
+ return;
+ }
+ if (val is long)
+ {
+ SetValue((ulong)((long)val));
+ return;
+ }
+ if (val is float)
+ {
+ SetValue((ulong)((float)val));
+ return;
+ }
+ if (val is double)
+ {
+ SetValue((ulong)((double)val));
+ return;
+ }
+ SetValue(Convert.ToUInt64(val));
+ }
+
+ // Token: 0x0600035F RID: 863 RVA: 0x000157C4 File Offset: 0x000139C4
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new UlongVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x06000360 RID: 864 RVA: 0x000157E4 File Offset: 0x000139E4
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc7Ulong;
+ }
+
+ // Token: 0x06000361 RID: 865 RVA: 0x000157E8 File Offset: 0x000139E8
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ switch (val.GetTypeCode())
+ {
+ case Vtc.Tc1Bool:
+ SetValue(Convert.ToByte(((BoolVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc5Enum:
+ SetValue(Convert.ToUInt64(((EnumVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc7Ulong:
+ SetValue(((UlongVariant)val).GetValue());
+ return this;
+ case Vtc.Tc8Float:
+ SetValue((ulong)((FloatVariant)val).GetValue());
+ return this;
+ case Vtc.Tc9Uint:
+ SetValue(((UintVariant)val).GetValue());
+ return this;
+ case Vtc.Tc10Ushort:
+ SetValue(((UshortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc12Sbyte:
+ SetValue((ulong)((SbyteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc13UIntPtr:
+ SetValue((ulong)((UIntPtrVariant)val).GetValue());
+ return this;
+ case Vtc.Tc14Byte:
+ SetValue(((ByteVariant)val).GetValue());
+ return this;
+ case Vtc.Tc15Short:
+ SetValue((ulong)((ShortVariant)val).GetValue());
+ return this;
+ case Vtc.Tc17IntPtr:
+ SetValue((ulong)((long)((IntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc18Object:
+ SetValue(Convert.ToUInt64(((UIntPtrVariant)val).GetValue()));
+ return this;
+ case Vtc.Tc19Int:
+ SetValue((ulong)((IntVariant)val).GetValue());
+ return this;
+ case Vtc.Tc21Double:
+ SetValue((ulong)((DoubleVariant)val).GetValue());
+ return this;
+ case Vtc.Tc24Long:
+ SetValue((ulong)((LongVariant)val).GetValue());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x04000188 RID: 392
+ private ulong _value;
+ }
+
+ // Token: 0x0200005C RID: 92
+ internal abstract class ReferenceVariantBase : VariantBase // \u000F\u2002
+ {
+ // Token: 0x06000363 RID: 867 RVA: 0x000159E0 File Offset: 0x00013BE0
+ public override object GetValueAbstract() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ throw new InvalidOperationException();
+ }
+
+ // Token: 0x06000364 RID: 868 RVA: 0x000159E8 File Offset: 0x00013BE8
+ public override void SetValueAbstract(object val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ throw new InvalidOperationException();
+ }
+
+ // Token: 0x06000365 RID: 869 RVA: 0x000159F0 File Offset: 0x00013BF0
+ public override bool IsAddr() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return true;
+ }
+ }
+
+ // Token: 0x02000007 RID: 7
+ internal sealed class FieldInfoVariant : ReferenceVariantBase // \u0002\u2004
+ {
+ // Token: 0x06000023 RID: 35 RVA: 0x00002600 File Offset: 0x00000800
+ public object GetObject() // \u0002
+ {
+ return _obj;
+ }
+
+ // Token: 0x06000024 RID: 36 RVA: 0x00002608 File Offset: 0x00000808
+ public void SetObject(object val) // \u0002
+ {
+ _obj = val;
+ }
+
+ // Token: 0x06000025 RID: 37 RVA: 0x00002614 File Offset: 0x00000814
+ public FieldInfo GetValue() // \u0002
+ {
+ return _field;
+ }
+
+ // Token: 0x06000026 RID: 38 RVA: 0x0000261C File Offset: 0x0000081C
+ public void SetValue(FieldInfo val) // \u0002
+ {
+ _field = val;
+ }
+
+ // Token: 0x06000027 RID: 39 RVA: 0x00002628 File Offset: 0x00000828
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc4FieldInfo;
+ }
+
+ // Token: 0x06000028 RID: 40 RVA: 0x0000262C File Offset: 0x0000082C
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ var num = val.GetTypeCode();
+ if (num == Vtc.Tc4FieldInfo)
+ {
+ SetObject(((FieldInfoVariant)val).GetObject());
+ SetValue(((FieldInfoVariant)val).GetValue());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x06000029 RID: 41 RVA: 0x0000267C File Offset: 0x0000087C
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new FieldInfoVariant();
+ ret.SetObject(_obj);
+ ret.SetValue(_field);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x04000005 RID: 5
+ private object _obj; // \u0002
+
+ // Token: 0x04000006 RID: 6
+ private FieldInfo _field; // \u0003
+ }
+
+ // Token: 0x02000012 RID: 18
+ internal sealed class VariantBaseHolder : ReferenceVariantBase // \u0003\u2003
+ {
+ // Token: 0x0600007A RID: 122 RVA: 0x00003BF0 File Offset: 0x00001DF0
+ public VariantBase GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x0600007B RID: 123 RVA: 0x00003BF8 File Offset: 0x00001DF8
+ public void SetValue(VariantBase val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x0600007C RID: 124 RVA: 0x00003C04 File Offset: 0x00001E04
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc0VariantBaseHolder;
+ }
+
+ // Token: 0x0600007D RID: 125 RVA: 0x00003C08 File Offset: 0x00001E08
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ if (val.GetTypeCode() == Vtc.Tc0VariantBaseHolder)
+ {
+ SetValue(((VariantBaseHolder)val).GetValue());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x0600007E RID: 126 RVA: 0x00003C48 File Offset: 0x00001E48
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new VariantBaseHolder();
+ ret.SetValue(GetValue());
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x0400001A RID: 26
+ private VariantBase _value;
+ }
+
+ // Token: 0x02000020 RID: 32
+ internal sealed class LocalsIdxHolderVariant : ReferenceVariantBase // \u0005\u2004
+ {
+ // Token: 0x060000C6 RID: 198 RVA: 0x000049A8 File Offset: 0x00002BA8
+ public int GetValue() // \u0002
+ {
+ return _value;
+ }
+
+ // Token: 0x060000C7 RID: 199 RVA: 0x000049B0 File Offset: 0x00002BB0
+ public void SetValue(int val) // \u0002
+ {
+ _value = val;
+ }
+
+ // Token: 0x060000C8 RID: 200 RVA: 0x000049BC File Offset: 0x00002BBC
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc23LocalsIdxHolder;
+ }
+
+ // Token: 0x060000C9 RID: 201 RVA: 0x000049C0 File Offset: 0x00002BC0
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ var num = val.GetTypeCode();
+ if (num == Vtc.Tc23LocalsIdxHolder)
+ {
+ SetValue(((LocalsIdxHolderVariant)val).GetValue());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x060000CA RID: 202 RVA: 0x00004A00 File Offset: 0x00002C00
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new LocalsIdxHolderVariant();
+ ret.SetValue(_value);
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x04000029 RID: 41
+ private int _value;
+ }
+
+ // Token: 0x02000046 RID: 70
+ internal abstract class ArrayValueVariantBase : ReferenceVariantBase // \u0008\u2003
+ {
+ // Token: 0x060002F9 RID: 761 RVA: 0x00014788 File Offset: 0x00012988
+ public Type GetHeldType() // \u0002
+ {
+ return _type;
+ }
+
+ // Token: 0x060002FA RID: 762 RVA: 0x00014790 File Offset: 0x00012990
+ public void SetHeldType(Type val) // \u0002
+ {
+ _type = val;
+ }
+
+ // Token: 0x060002FB RID: 763
+ public abstract object GetValue(); // \u0008\u2003\u2008\u2000\u2002\u200A\u0002
+
+ // Token: 0x060002FC RID: 764
+ public abstract void SetValue(object val); // \u0008\u2003\u2008\u2000\u2002\u200A\u0002
+
+ // Token: 0x060002FD RID: 765
+ public abstract bool IsEqual(ArrayValueVariantBase val); // \u0008\u2003\u2008\u2000\u2002\u200A\u0002
+
+ // Token: 0x04000174 RID: 372
+ private Type _type;
+ }
+
+ // Token: 0x02000053 RID: 83
+ internal static class IntArrayComparison // \u000E\u2004
+ {
+ // Token: 0x06000340 RID: 832 RVA: 0x00015294 File Offset: 0x00013494
+ public static bool Execute(int[] a1, int[] a2) // \u0002
+ {
+ if (a1 == a2)
+ {
+ return true;
+ }
+ if (a1 == null || a2 == null)
+ {
+ return false;
+ }
+ if (a1.Length != a2.Length)
+ {
+ return false;
+ }
+ return !a1.Where((t, i) => t != a2[i]).Any();
+ }
+ }
+
+ // Token: 0x0200002D RID: 45
+ internal sealed class MdArrayValueVariant : ArrayValueVariantBase // \u0006\u2004
+ {
+ // Token: 0x0600014F RID: 335 RVA: 0x000065AC File Offset: 0x000047AC
+ public Array GetArray() // \u0002
+ {
+ return _array;
+ }
+
+ // Token: 0x06000150 RID: 336 RVA: 0x000065B4 File Offset: 0x000047B4
+ public void SetArray(Array val) // \u0002
+ {
+ _array = val;
+ }
+
+ // Token: 0x06000151 RID: 337 RVA: 0x000065C0 File Offset: 0x000047C0
+ public int[] GetIndexes() // \u0002
+ {
+ return _indexes;
+ }
+
+ // Token: 0x06000152 RID: 338 RVA: 0x000065C8 File Offset: 0x000047C8
+ public void SetIndexes(int[] val) // \u0002
+ {
+ _indexes = val;
+ }
+
+ // Token: 0x06000153 RID: 339 RVA: 0x000065D4 File Offset: 0x000047D4
+ public override object GetValue() // \u0008\u2003\u2008\u2000\u2002\u200A\u0002
+ {
+ return GetArray().GetValue(GetIndexes());
+ }
+
+ // Token: 0x06000154 RID: 340 RVA: 0x000065E8 File Offset: 0x000047E8
+ public override void SetValue(object val) // \u0008\u2003\u2008\u2000\u2002\u200A\u0002
+ {
+ GetArray().SetValue(val, GetIndexes());
+ }
+
+ // Token: 0x06000155 RID: 341 RVA: 0x000065FC File Offset: 0x000047FC
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new MdArrayValueVariant();
+ ret.SetArray(GetArray());
+ ret.SetIndexes(GetIndexes());
+ ret.SetHeldType(GetHeldType());
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x06000156 RID: 342 RVA: 0x00006640 File Offset: 0x00004840
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc20MdArrayValue;
+ }
+
+ // Token: 0x06000157 RID: 343 RVA: 0x00006644 File Offset: 0x00004844
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ var num = val.GetTypeCode();
+ if (num == Vtc.Tc20MdArrayValue)
+ {
+ var src = (MdArrayValueVariant)val;
+ SetArray(src.GetArray());
+ SetIndexes(src.GetIndexes());
+ SetHeldType(src.GetHeldType());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x06000158 RID: 344 RVA: 0x000066A0 File Offset: 0x000048A0
+ public override bool IsEqual(ArrayValueVariantBase val) // \u0008\u2003\u2008\u2000\u2002\u200A\u0002
+ {
+ var peer = (MdArrayValueVariant)val;
+ return GetArray() == peer.GetArray() && IntArrayComparison.Execute(GetIndexes(), peer.GetIndexes());
+ }
+
+ // Token: 0x04000050 RID: 80
+ private Array _array; // \u0002
+
+ // Token: 0x04000051 RID: 81
+ private int[] _indexes; // \u0003
+ }
+
+ // Token: 0x02000052 RID: 82
+ internal sealed class SdArrayValueVariant : ArrayValueVariantBase // \u000E\u2003
+ {
+ // Token: 0x06000336 RID: 822 RVA: 0x0001516C File Offset: 0x0001336C
+ public Array GetArray() // \u0002
+ {
+ return _array;
+ }
+
+ // Token: 0x06000337 RID: 823 RVA: 0x00015174 File Offset: 0x00013374
+ public void SetArray(Array val) // \u0002
+ {
+ _array = val;
+ }
+
+ // Token: 0x06000338 RID: 824 RVA: 0x00015180 File Offset: 0x00013380
+ public long GetIndex() // \u0002
+ {
+ return _index;
+ }
+
+ // Token: 0x06000339 RID: 825 RVA: 0x00015188 File Offset: 0x00013388
+ public void SetIndex(long idx) // \u0002
+ {
+ _index = idx;
+ }
+
+ // Token: 0x0600033A RID: 826 RVA: 0x00015194 File Offset: 0x00013394
+ public override object GetValue() // \u0008\u2003\u2008\u2000\u2002\u200A\u0002
+ {
+ return _array.GetValue(_index);
+ }
+
+ // Token: 0x0600033B RID: 827 RVA: 0x000151A8 File Offset: 0x000133A8
+ public override void SetValue(object val) // \u0008\u2003\u2008\u2000\u2002\u200A\u0002
+ {
+ _array.SetValue(val, _index);
+ }
+
+ // Token: 0x0600033C RID: 828 RVA: 0x000151BC File Offset: 0x000133BC
+ public override Vtc GetTypeCode() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ return Vtc.Tc22SdArrayValue;
+ }
+
+ // Token: 0x0600033D RID: 829 RVA: 0x000151C0 File Offset: 0x000133C0
+ public override VariantBase CopyFrom(VariantBase val) // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ SetVariantType(val.GetVariantType());
+ var num = val.GetTypeCode();
+ if (num == Vtc.Tc22SdArrayValue)
+ {
+ var src = (SdArrayValueVariant)val;
+ SetArray(src.GetArray());
+ SetIndex(src.GetIndex());
+ SetHeldType(src.GetHeldType());
+ return this;
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Token: 0x0600033E RID: 830 RVA: 0x0001521C File Offset: 0x0001341C
+ public override VariantBase Clone() // \u000F\u2008\u2000\u2002\u200A\u0002
+ {
+ var ret = new SdArrayValueVariant();
+ ret.SetArray(_array);
+ ret.SetIndex(_index);
+ ret.SetHeldType(GetHeldType());
+ ret.SetVariantType(GetVariantType());
+ return ret;
+ }
+
+ // Token: 0x0600033F RID: 831 RVA: 0x00015260 File Offset: 0x00013460
+ public override bool IsEqual(ArrayValueVariantBase val) // \u0008\u2003\u2008\u2000\u2002\u200A\u0002
+ {
+ var peer = (SdArrayValueVariant)val;
+ return GetIndex() == peer.GetIndex() && GetArray() == peer.GetArray();
+ }
+
+ // Token: 0x04000181 RID: 385
+ private Array _array; // \u0002
+
+ // Token: 0x04000182 RID: 386
+ private long _index; // \u0003
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VariantFactory.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VariantFactory.cs
new file mode 100644
index 0000000..c43bbd4
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VariantFactory.cs
@@ -0,0 +1,165 @@
+using System;
+using System.Runtime.Serialization;
+
+namespace UnitTestProject.RefVm
+{
+ // Token: 0x02000045 RID: 69
+ internal static class VariantFactory // \u0008\u2002
+ {
+ // Token: 0x060002F6 RID: 758 RVA: 0x000144E0 File Offset: 0x000126E0
+ private static bool IsDerivedFrom<T>(Type obj) // \u0002
+ {
+ var typeFromHandle = typeof(T);
+ return obj == typeFromHandle || obj.IsSubclassOf(typeFromHandle);
+ }
+
+ // Token: 0x060002F7 RID: 759 RVA: 0x00014508 File Offset: 0x00012708
+ public static VariantBase Convert(object src, Type t) // \u0002
+ {
+ var ret = src as VariantBase;
+ if (ret != null)
+ {
+ return ret;
+ }
+ if (t == null)
+ {
+ if (src == null)
+ {
+ return new ObjectVariant();
+ }
+ t = src.GetType();
+ }
+ t = ElementedTypeHelper.TryGoToPointerOrReferenceElementType(t);
+ if (t == SimpleTypeHelper.ObjectType)
+ {
+ ret = new ObjectVariant();
+ if (src != null && src.GetType() != SimpleTypeHelper.ObjectType)
+ {
+ ret.SetVariantType(src.GetType());
+ }
+ }
+ else if (IsDerivedFrom<Array>(t))
+ {
+ ret = new ArrayVariant();
+ }
+ else if (IsDerivedFrom<string>(t))
+ {
+ ret = new StringVariant();
+ }
+ else if (IsDerivedFrom<IntPtr>(t))
+ {
+ ret = new IntPtrVariant();
+ }
+ else if (IsDerivedFrom<UIntPtr>(t))
+ {
+ ret = new UIntPtrVariant();
+ }
+ else if (IsDerivedFrom<ulong>(t))
+ {
+ ret = new UlongVariant();
+ }
+ else if (IsDerivedFrom<uint>(t))
+ {
+ ret = new UintVariant();
+ }
+ else if (IsDerivedFrom<ushort>(t))
+ {
+ ret = new UshortVariant();
+ }
+ else if (IsDerivedFrom<long>(t))
+ {
+ ret = new LongVariant();
+ }
+ else if (IsDerivedFrom<int>(t))
+ {
+ ret = new IntVariant();
+ }
+ else if (IsDerivedFrom<short>(t))
+ {
+ ret = new ShortVariant();
+ }
+ else if (IsDerivedFrom<byte>(t))
+ {
+ ret = new ByteVariant();
+ }
+ else if (IsDerivedFrom<sbyte>(t))
+ {
+ ret = new SbyteVariant();
+ }
+ else if (IsDerivedFrom<double>(t))
+ {
+ ret = new DoubleVariant();
+ }
+ else if (IsDerivedFrom<float>(t))
+ {
+ ret = new FloatVariant();
+ }
+ else if (IsDerivedFrom<bool>(t))
+ {
+ ret = new BoolVariant();
+ }
+ else if (IsDerivedFrom<char>(t))
+ {
+ ret = new CharVariant();
+ }
+ else if (SimpleTypeHelper.IsNullableGeneric(t))
+ {
+ var ov = new ObjectVariant();
+ ov.SetVariantType(t);
+ ret = ov;
+ }
+ else
+ {
+ if (IsDerivedFrom<Enum>(t))
+ {
+ Enum e;
+ if (src == null)
+ {
+ e = (Enum)Activator.CreateInstance(t);
+ }
+ else if (t == SimpleTypeHelper.EnumType && src is Enum)
+ {
+ e = (Enum)src;
+ }
+ else
+ {
+ e = (Enum)Enum.ToObject(t, src);
+ }
+ return new EnumVariant(e);
+ }
+ if (IsDerivedFrom<ValueType>(t))
+ {
+ if (src == null)
+ {
+ var vt = (t == SimpleTypeHelper.TypedReferenceType) ?
+ FormatterServices.GetSafeUninitializedObject(SimpleTypeHelper.TypedReferenceType) :
+ Activator.CreateInstance(t);
+ ret = new ValueTypeVariant(vt);
+ }
+ else
+ {
+ if (src.GetType() != t)
+ {
+ try
+ {
+ src = System.Convert.ChangeType(src, t);
+ }
+ catch
+ {
+ // ignored
+ }
+ }
+ ret = new ValueTypeVariant(src);
+ }
+ return ret;
+ }
+ ret = new ObjectVariant();
+ }
+ if (src != null)
+ {
+ ret.SetValueAbstract(src);
+ }
+ return ret;
+ }
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmExecutor.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmExecutor.cs
new file mode 100644
index 0000000..7174a43
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmExecutor.cs
@@ -0,0 +1,7505 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Runtime.InteropServices;
+using System.Runtime.Serialization;
+using System.Threading;
+
+// ReSharper disable InconsistentNaming
+// ReSharper disable UnusedMember.Local
+// ReSharper disable UnusedParameter.Local
+// ReSharper disable MemberCanBePrivate.Global
+// ReSharper disable EmptyGeneralCatchClause
+// ReSharper disable RedundantCast
+// ReSharper disable PossibleNullReferenceException
+// ReSharper disable AssignNullToNotNullAttribute
+// ReSharper disable UnusedMember.Global
+
+namespace UnitTestProject.RefVm
+{
+ // Token: 0x02000032 RID: 50
+ public class VmExecutor // \u0006\u2007
+ {
+ #region subclasses
+
+ // Token: 0x02000033 RID: 51
+ [Serializable]
+ private sealed class CatchBlockComparer // \u0002
+ {
+ // Token: 0x060002B0 RID: 688 RVA: 0x00012EB4 File Offset: 0x000110B4
+ internal int Compare(CatchBlock v1, CatchBlock v2) // \u0002
+ {
+ if (v1.ExcTypeId == v2.ExcTypeId)
+ {
+ return v2.Start.CompareTo(v1.Start);
+ }
+ return v1.ExcTypeId.CompareTo(v2.ExcTypeId);
+ }
+
+ // Token: 0x04000155 RID: 341
+ public static readonly CatchBlockComparer Instance = new CatchBlockComparer(); // \u0002
+
+ // Token: 0x04000156 RID: 342
+ public static Comparison<CatchBlock> MyComparison; // \u0003
+ }
+
+ // Token: 0x02000038 RID: 56
+ private sealed class StringTypePair // \u0006
+ {
+ // Token: 0x060002C0 RID: 704 RVA: 0x00013020 File Offset: 0x00011220
+ // Token: 0x060002C1 RID: 705 RVA: 0x00013028 File Offset: 0x00011228
+ // Token: 0x0400015D RID: 349
+ public string Str { get; set; } // \u0002
+
+ // Token: 0x060002C3 RID: 707 RVA: 0x0001303C File Offset: 0x0001123C
+ // Token: 0x060002C2 RID: 706 RVA: 0x00013034 File Offset: 0x00011234
+ // Token: 0x0400015E RID: 350
+ public Type T { get; set; } // \u0002
+ }
+
+ // Token: 0x02000039 RID: 57
+ // (Invoke) Token: 0x060002C5 RID: 709
+ private delegate object DynamicExecutor(object obj, object[] args); // \u0008
+
+ // Token: 0x0200003A RID: 58
+ // (Invoke) Token: 0x060002C9 RID: 713
+ internal delegate void VmInstrImpl(VariantBase t); // \u000E
+
+ // Token: 0x0200003B RID: 59
+ private sealed class VmInstr // \u000F
+ {
+ // Token: 0x060002CC RID: 716 RVA: 0x00013048 File Offset: 0x00011248
+ public VmInstr(VmInstrInfo id, VmInstrImpl func)
+ {
+ Id = id;
+ Func = func;
+ }
+
+ // Token: 0x0400015F RID: 351
+ public readonly VmInstrInfo Id; // \u0002
+
+ // Token: 0x04000160 RID: 352
+ public readonly VmInstrImpl Func; // \u0003
+ }
+
+ // Token: 0x02000037 RID: 55
+ private sealed class ExcHandlerFrame // \u0005
+ {
+ // Token: 0x060002BB RID: 699 RVA: 0x00012FF0 File Offset: 0x000111F0
+ // Token: 0x060002BC RID: 700 RVA: 0x00012FF8 File Offset: 0x000111F8
+ // Token: 0x0400015B RID: 347
+ public uint Pos { get; set; }
+
+ // Token: 0x060002BD RID: 701 RVA: 0x00013004 File Offset: 0x00011204
+ // Token: 0x060002BE RID: 702 RVA: 0x0001300C File Offset: 0x0001120C
+ // Token: 0x0400015C RID: 348
+ public object Exception { get; set; }
+ }
+
+ // Token: 0x02000034 RID: 52
+ internal struct MethodBaseAndVirtual : IEquatable<MethodBaseAndVirtual> // \u0002\u2000
+ {
+ public MethodBaseAndVirtual(MethodBase mb, bool isVirtual)
+ {
+ Val = mb;
+ IsVirtual = isVirtual;
+ }
+
+ // Token: 0x060002B1 RID: 689 RVA: 0x00012EF8 File Offset: 0x000110F8
+ // Token: 0x060002B2 RID: 690 RVA: 0x00012F00 File Offset: 0x00011100
+ // Token: 0x04000157 RID: 343
+ public MethodBase Val /* \u0002 */ { get; }
+
+ // Token: 0x060002B3 RID: 691 RVA: 0x00012F0C File Offset: 0x0001110C
+ // Token: 0x060002B4 RID: 692 RVA: 0x00012F14 File Offset: 0x00011114
+ // Token: 0x04000158 RID: 344
+ public bool IsVirtual /* \u0003 */ { get; }
+
+ // Token: 0x060002B5 RID: 693 RVA: 0x00012F20 File Offset: 0x00011120
+ public override int GetHashCode()
+ {
+ return Val.GetHashCode() ^ IsVirtual.GetHashCode();
+ }
+
+ // Token: 0x060002B6 RID: 694 RVA: 0x00012F48 File Offset: 0x00011148
+ public override bool Equals(object o)
+ {
+ if (o is MethodBaseAndVirtual)
+ {
+ return Equals((MethodBaseAndVirtual)o);
+ }
+ return false;
+ }
+
+ // Token: 0x060002B7 RID: 695 RVA: 0x00012F70 File Offset: 0x00011170
+ public bool Equals(MethodBaseAndVirtual val)
+ {
+ return IsVirtual == val.IsVirtual && Val == val.Val;
+ }
+ }
+
+ // Token: 0x02000035 RID: 53
+ private struct BoolHolder // \u0003
+ {
+ // Token: 0x04000159 RID: 345
+ public bool Val; // \u0002
+ }
+
+ // Token: 0x02000036 RID: 54
+ private sealed class IntToTypeComparer<T> : IComparer<KeyValuePair<int, T>> // \u0003\u2000
+ {
+ // Token: 0x060002B8 RID: 696 RVA: 0x00012F94 File Offset: 0x00011194
+ public IntToTypeComparer(Comparison<T> c)
+ {
+ _c = c;
+ }
+
+ // Token: 0x060002B9 RID: 697 RVA: 0x00012FA4 File Offset: 0x000111A4
+ public int Compare(KeyValuePair<int, T> v1, KeyValuePair<int, T> v2)
+ {
+ var num = _c(v1.Value, v2.Value);
+ if (num == 0)
+ {
+ return v2.Key.CompareTo(v1.Key);
+ }
+ return num;
+ }
+
+ // Token: 0x0400015A RID: 346
+ private readonly Comparison<T> _c;
+ }
+
+ // Token: 0x0200000B RID: 11
+ private static class HiByte // \u0002\u2008
+ {
+ // Token: 0x06000056 RID: 86 RVA: 0x00003154 File Offset: 0x00001354
+ public static int Extract(int src) // \u0002
+ {
+ return src & -16777216; // 0xFF000000
+ }
+ }
+
+ #endregion
+
+ #region members
+ // Token: 0x04000132 RID: 306
+ private static readonly Type MethodBaseType = typeof(MethodBase); // \u0002\u2001
+
+ // Token: 0x04000133 RID: 307
+ private VmMethodHeader _methodHeader; // \u000E
+
+ // Token: 0x04000134 RID: 308
+ private readonly MyCollection<VariantBase> _evalStack = new MyCollection<VariantBase>(); // \u0003\u2003
+
+ // Token: 0x04000135 RID: 309
+ private readonly Dictionary<int, object> AllMetadataById = new Dictionary<int, object>(); // \u0006\u2003
+
+ // Token: 0x04000136 RID: 310
+ private readonly VmInstrCodesDb _instrCodesDb; // \u0006\u2001
+
+ // Token: 0x04000137 RID: 311
+ private object _exception; // \u0006\u2002
+
+ // Token: 0x04000138 RID: 312
+ private readonly Dictionary<MethodBase, object> _mbDynamicLock = new Dictionary<MethodBase, object>(); // \u0008\u2002
+
+ // Token: 0x04000139 RID: 313
+ private BinaryReader _srcVirtualizedStreamReader; // \u0002\u2000
+
+ // Token: 0x0400013A RID: 314
+ private Type _currentClass; // \u000F\u2001
+
+ // Token: 0x0400013B RID: 315
+ private static readonly Type AssemblyType = typeof(Assembly); // \u0002\u2003
+
+ // Token: 0x0400013C RID: 316
+ private readonly Dictionary<MethodBase, int> _mbCallCnt = new Dictionary<MethodBase, int>(256); // \u0006
+
+ // Token: 0x0400013D RID: 317
+ private Stream _srcVirtualizedStream; // \u000F\u2000
+
+ // Token: 0x0400013E RID: 318
+ private object[] _callees; // \u0005\u2000
+
+ // Token: 0x0400013F RID: 319
+ private readonly MyCollection<ExcHandlerFrame> _ehStack = new MyCollection<ExcHandlerFrame>(); // \u000F
+
+ // Token: 0x04000140 RID: 320
+ private VariantBase[] _localVariables; // \u0003\u2002
+
+ // Token: 0x04000141 RID: 321
+ private readonly Dictionary<MethodBaseAndVirtual, DynamicExecutor> _dynamicExecutors = new Dictionary<MethodBaseAndVirtual, DynamicExecutor>(256); // \u0002\u2002
+
+ // Token: 0x04000142 RID: 322
+ private bool _retFound; // \u0005\u2003
+
+ // Token: 0x04000143 RID: 323
+ private MyBufferReader _myBufferReader; // \u0002
+
+ // Token: 0x04000144 RID: 324
+ private Type[] _classGenericArgs; // \u0003
+
+ // Token: 0x04000145 RID: 325
+ private readonly Module _module; // \u0008\u2001
+
+ // Token: 0x04000146 RID: 326
+ private long _myBufferPos; // \u0005
+
+ // Token: 0x04000147 RID: 327
+ private byte[] _methodBody; // \u0008
+
+ // Token: 0x04000148 RID: 328
+ private static readonly Type ObjectArrayType = typeof(object[]); // \u000E\u2001
+
+ // Token: 0x04000149 RID: 329
+ private static readonly Dictionary<MethodBase, DynamicMethod> DynamicMethods = new Dictionary<MethodBase, DynamicMethod>(); // \u000E\u2003
+
+ // Token: 0x0400014A RID: 330
+ private bool _wasException; // \u0008\u2000
+
+ // Token: 0x0400014B RID: 331
+ private Type[] _methodGenericArgs; // \u0005\u2001
+
+ // Token: 0x0400014C RID: 332
+ private CatchBlock[] _catchBlocks; // \u000F\u2003
+
+ // Token: 0x0400014D RID: 333
+ private static readonly object InterlockedLock = new object(); // \u0008\u2003
+
+ // Token: 0x0400014E RID: 334
+ private uint? _storedPos; // \u000E\u2000
+
+ // Token: 0x0400014F RID: 335
+ private const bool _alwaysFalse = false; // \u000F\u2002
+
+ // Token: 0x04000150 RID: 336
+ private Dictionary<int, VmInstr> _vmInstrDb; // \u000E\u2002
+
+ // Token: 0x04000151 RID: 337
+ private VariantBase[] _variantOutputArgs; // \u0005\u2002
+
+ // Token: 0x04000152 RID: 338
+ private const bool _alwaysTrue = true; // \u0003\u2001
+
+ // Token: 0x04000153 RID: 339
+ private static readonly Type IntPtrType = typeof(IntPtr); // \u0003\u2000
+
+ // Token: 0x04000154 RID: 340
+ private static readonly Type VoidType = typeof(void); // \u0006\u2000
+
+ #endregion
+
+ // Token: 0x0600016C RID: 364 RVA: 0x00007958 File Offset: 0x00005B58
+ public VmExecutor(VmInstrCodesDb instrCodesDb, Module m)
+ {
+ _instrCodesDb = instrCodesDb;
+ _module = m;
+ Init();
+ }
+
+ // Token: 0x060001B6 RID: 438 RVA: 0x000092E0 File Offset: 0x000074E0
+ private void Init() // \u000F
+ {
+ if (!_instrCodesDb.IsInitialized())
+ {
+ lock (_instrCodesDb)
+ {
+ if (!_instrCodesDb.IsInitialized())
+ {
+ _vmInstrDb = CreateVmInstrDb();
+ DoNothing();
+ _instrCodesDb.SetInitialized(true);
+ }
+ }
+ }
+ if (_vmInstrDb == null)
+ {
+ _vmInstrDb = CreateVmInstrDb();
+ }
+ }
+
+ // Token: 0x060001BD RID: 445 RVA: 0x00009534 File Offset: 0x00007734
+ private void DoNothing() // \u0006
+ {}
+
+ // Token: 0x06000239 RID: 569 RVA: 0x0000F9C4 File Offset: 0x0000DBC4
+ private VariantBase PopVariant() // \u0002
+ {
+ return _evalStack.PopBack();
+ }
+
+ // Token: 0x060002A0 RID: 672 RVA: 0x000127D8 File Offset: 0x000109D8
+ private long PopLong() // \u0002
+ {
+ var top = PopVariant();
+ switch (top.GetTypeCode())
+ {
+ case VariantBase.Vtc.Tc5Enum: return VariantBase.SignedLongFromEnum((EnumVariant)top); // bug was fixed and unit tested (Convert.ToInt64(((EnumVariant)top).GetValue());)
+ case VariantBase.Vtc.Tc13UIntPtr: return (long)((UIntPtrVariant)top).GetValue().ToUInt64();
+ case VariantBase.Vtc.Tc17IntPtr: return ((IntPtrVariant)top).GetValue().ToInt64();
+ case VariantBase.Vtc.Tc19Int: return ((IntVariant)top).GetValue();
+ }
+ throw new Exception(StringDecryptor.GetString(-1550345551) /* Unexpected value on the stack. */);
+ }
+
+ // Token: 0x060001A1 RID: 417 RVA: 0x00008CC4 File Offset: 0x00006EC4
+ private void Ldelem(Type t) // \u0002
+ {
+ var index = PopLong();
+ var array = (Array)PopVariant().GetValueAbstract();
+ PushVariant(VariantFactory.Convert(array.GetValue(index), t));
+ }
+
+ // Token: 0x0600020C RID: 524 RVA: 0x0000C528 File Offset: 0x0000A728
+ private void Ldelem_(VariantBase vTypeId) // \u0006\u200A\u2000
+ {
+ var typeId = ((IntVariant)vTypeId).GetValue();
+ var type = GetTypeById(typeId);
+ Ldelem(type);
+ }
+
+ // Token: 0x060002A5 RID: 677 RVA: 0x00012A80 File Offset: 0x00010C80
+ private void PushVariant(VariantBase obj) // \u0008\u2000\u2001
+ {
+ if (obj == null)
+ {
+ throw new ArgumentNullException(StringDecryptor.GetString(-1550345950) /* obj */);
+ }
+ VariantBase push;
+ if (obj.GetVariantType() != null)
+ {
+ push = obj;
+ }
+ else
+ {
+ switch (obj.GetTypeCode())
+ {
+ case VariantBase.Vtc.Tc1Bool:
+ {
+ var tmp = new IntVariant();
+ tmp.SetValue(((BoolVariant)obj).GetValue() ? 1 : 0);
+ tmp.SetVariantType(obj.GetVariantType());
+ push = tmp;
+ break;
+ }
+ case VariantBase.Vtc.Tc6Char:
+ {
+ var tmp = new IntVariant();
+ tmp.SetValue(((CharVariant)obj).GetValue());
+ tmp.SetVariantType(obj.GetVariantType());
+ push = tmp;
+ break;
+ }
+ case VariantBase.Vtc.Tc7Ulong:
+ {
+ var tmp = new LongVariant();
+ tmp.SetValue((long)((UlongVariant)obj).GetValue());
+ tmp.SetVariantType(obj.GetVariantType());
+ push = tmp;
+ break;
+ }
+ case VariantBase.Vtc.Tc8Float:
+ {
+ var tmp = new FloatVariant();
+ tmp.SetValue(((FloatVariant)obj).GetValue());
+ tmp.SetVariantType(obj.GetVariantType());
+ push = tmp;
+ break;
+ }
+ case VariantBase.Vtc.Tc9Uint:
+ {
+ var tmp = new IntVariant();
+ tmp.SetValue((int)((UintVariant)obj).GetValue());
+ tmp.SetVariantType(obj.GetVariantType());
+ push = tmp;
+ break;
+ }
+ case VariantBase.Vtc.Tc10Ushort:
+ {
+ var tmp = new IntVariant();
+ tmp.SetValue(((UshortVariant)obj).GetValue());
+ tmp.SetVariantType(obj.GetVariantType());
+ push = tmp;
+ break;
+ }
+ case VariantBase.Vtc.Tc12Sbyte:
+ {
+ var tmp = new IntVariant();
+ tmp.SetValue(((SbyteVariant)obj).GetValue());
+ tmp.SetVariantType(obj.GetVariantType());
+ push = tmp;
+ break;
+ }
+ case VariantBase.Vtc.Tc14Byte:
+ {
+ var tmp = new IntVariant();
+ tmp.SetValue(((ByteVariant)obj).GetValue());
+ tmp.SetVariantType(obj.GetVariantType());
+ push = tmp;
+ break;
+ }
+ case VariantBase.Vtc.Tc15Short:
+ {
+ var tmp = new IntVariant();
+ tmp.SetValue(((ShortVariant)obj).GetValue());
+ tmp.SetVariantType(obj.GetVariantType());
+ push = tmp;
+ break;
+ }
+ case VariantBase.Vtc.Tc18Object:
+ {
+ var abs = obj.GetValueAbstract();
+ if (abs == null)
+ {
+ push = obj;
+ break;
+ }
+ var type = abs.GetType();
+ if (type.HasElementType && !type.IsArray)
+ {
+ type = type.GetElementType();
+ }
+ if (type != null && !type.IsValueType && !type.IsEnum)
+ {
+ push = obj;
+ break;
+ }
+ push = VariantFactory.Convert(abs, type);
+ break;
+ }
+ case VariantBase.Vtc.Tc17IntPtr:
+ case VariantBase.Vtc.Tc13UIntPtr:
+ if(IntPtr.Size == 4)
+ {
+ var tmp = new IntVariant();
+ tmp.CopyFrom(obj);
+ tmp.SetVariantType(obj.GetVariantType());
+ push = tmp;
+ }
+ else
+ {
+ var tmp = new LongVariant();
+ tmp.CopyFrom(obj);
+ tmp.SetVariantType(obj.GetVariantType());
+ push = tmp;
+ }
+ break;
+ default:
+ push = obj;
+ break;
+ }
+ }
+ _evalStack.PushBack(push);
+ }
+
+ // Token: 0x0600027D RID: 637 RVA: 0x00011C24 File Offset: 0x0000FE24
+ private void Conv_ovf_i4_un_(VariantBase dummy) // \u0003\u200B
+ {
+ Conv_i4(true, false);
+ }
+
+ // Token: 0x06000283 RID: 643 RVA: 0x00011E9C File Offset: 0x0001009C
+ public static void Sort<T>(T[] arr, Comparison<T> c) // \u0002
+ {
+ var array = new KeyValuePair<int, T>[arr.Length];
+ for (var i = 0; i < arr.Length; i++)
+ {
+ array[i] = new KeyValuePair<int, T>(i, arr[i]);
+ }
+ Array.Sort(array, arr, new IntToTypeComparer<T>(c));
+ }
+
+ // Token: 0x060001BE RID: 446 RVA: 0x00009538 File Offset: 0x00007738
+ private void SortCatchBlocks() // \u0003\u2000
+ {
+ if (CatchBlockComparer.MyComparison == null)
+ {
+ CatchBlockComparer.MyComparison = CatchBlockComparer.Instance.Compare;
+ }
+ Sort(_catchBlocks, CatchBlockComparer.MyComparison);
+ }
+
+ // Token: 0x0600016D RID: 365 RVA: 0x000079C8 File Offset: 0x00005BC8
+ public VmExecutor(VmInstrCodesDb instrCodesDb, Stream virtualizedStream = null) : this(instrCodesDb, typeof(VmExecutor).Module) // \u0006\u2007
+ {
+ _srcVirtualizedStream = virtualizedStream;
+ }
+
+ // Token: 0x0600023C RID: 572 RVA: 0x0000FA0C File Offset: 0x0000DC0C
+ public object Invoke(Stream virtualizedStream, string pos, object[] args) // \u0002
+ {
+ // ReSharper disable once IntroduceOptionalParameters.Global
+ return Invoke(virtualizedStream, pos, args, null, null, null);
+ }
+
+ // Token: 0x0600017A RID: 378 RVA: 0x00007DCC File Offset: 0x00005FCC
+ public object Invoke(Stream virtualizedStream, string pos, object[] args, Type[] methodGenericArgs, Type[] classGenericArgs, object[] callees) // \u0002
+ {
+ _srcVirtualizedStream = virtualizedStream;
+ Seek(pos, virtualizedStream);
+ return Invoke(args, methodGenericArgs, classGenericArgs, callees);
+ }
+
+ // Token: 0x060001C5 RID: 453 RVA: 0x00009A34 File Offset: 0x00007C34
+ private Type GetTypeById(int id) // \u0002
+ {
+ Type result;
+ lock (AllMetadataById)
+ {
+ var flag = true;
+ object o;
+ if (AllMetadataById.TryGetValue(id, out o))
+ {
+ result = (Type)o;
+ }
+ else
+ {
+ var token = ReadToken(id);
+ if (token.IsVm == 0)
+ {
+ var type = _module.ResolveType(token.MetadataToken);
+ AllMetadataById.Add(id, type);
+ result = type;
+ }
+ else
+ {
+ var vmToken = (VmClassTokenInfo)token.VmToken;
+ if (vmToken.IsOuterClassGeneric)
+ {
+ if (vmToken.OuterClassGenericMethodIdx!= -1)
+ {
+ result = _methodGenericArgs[vmToken.OuterClassGenericMethodIdx];
+ }
+ else
+ {
+ if (vmToken.OuterClassGenericClassIdx== -1)
+ {
+ throw new Exception();
+ }
+ result = _classGenericArgs[vmToken.OuterClassGenericClassIdx];
+ }
+ result = ElementedTypeHelper.PopType(result, ElementedTypeHelper.NestedElementTypes(vmToken.ClassName));
+ }
+ else
+ {
+ var className = vmToken.ClassName.Replace("\u0005 ,", "forms_cil.Trial,"); //TODO: в общем случае это лишнее
+ result = Type.GetType(className);
+ if (result == null)
+ {
+ var num = className.IndexOf(',');
+ var shortClassName = className.Substring(0, num);
+ var asmName = className.Substring(num + 1, className.Length - num - 1).Trim();
+ var assemblies = AppDomain.CurrentDomain.GetAssemblies();
+ foreach (var assembly in assemblies)
+ {
+ string value = null;
+ try
+ {
+ value = assembly.Location;
+ }
+ catch (NotSupportedException)
+ {
+ }
+ if (string.IsNullOrEmpty(value) && assembly.FullName.Equals(asmName, StringComparison.Ordinal))
+ {
+ result = assembly.GetType(shortClassName);
+ if (result != null)
+ {
+ break;
+ }
+ }
+ }
+ if (result == null && shortClassName.StartsWith(StringDecryptor.GetString(-1550345235) /* <PrivateImplementationDetails>< */, StringComparison.Ordinal) && shortClassName.Contains(StringDecryptor.GetString(-1550345325) /* . */))
+ {
+ try
+ {
+ var types = Assembly.Load(asmName).GetTypes();
+ foreach (var t in types.Where(type3 => type3.FullName == shortClassName))
+ {
+ result = t;
+ break;
+ }
+ }
+ // ReSharper disable once EmptyGeneralCatchClause
+ catch
+ {
+ }
+ }
+ }
+ if (vmToken.IsGeneric)
+ {
+ var array = new Type[vmToken.GenericArguments.Length];
+ for (var j = 0; j < vmToken.GenericArguments.Length; j++)
+ {
+ array[j] = GetTypeById(vmToken.GenericArguments[j].MetadataToken);
+ }
+ var genericTypeDefinition = ElementedTypeHelper.TryGoToElementType(result).GetGenericTypeDefinition();
+ var c = ElementedTypeHelper.NestedElementTypes(result);
+ result = ElementedTypeHelper.PopType(genericTypeDefinition.MakeGenericType(array), c);
+ flag = false;
+ }
+ if (flag)
+ {
+ AllMetadataById.Add(id, result);
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ // Token: 0x060001A6 RID: 422 RVA: 0x00008DAC File Offset: 0x00006FAC
+ public object Invoke(object[] args, Type[] methodGenericArgs, Type[] classGenericArgs, object[] callees) // \u0002
+ {
+ if (args == null)
+ {
+ args = EmptyArray<object>.Data;
+ }
+ if (methodGenericArgs == null)
+ {
+ methodGenericArgs = Type.EmptyTypes;
+ }
+ if (classGenericArgs == null)
+ {
+ classGenericArgs = Type.EmptyTypes;
+ }
+ _callees = callees;
+ _methodGenericArgs = methodGenericArgs;
+ _classGenericArgs = classGenericArgs;
+ _variantOutputArgs = ArgsToVariantOutputArgs(args);
+ _localVariables = CreateLocalVariables();
+ object result;
+ try
+ {
+ using (var b = new MyBuffer(_methodBody))
+ {
+ using (_myBufferReader = new MyBufferReader(b))
+ {
+ _retFound = false;
+ _storedPos = null;
+ _evalStack.Clear();
+ InternalInvoke();
+ }
+ }
+ var retType = GetTypeById(_methodHeader.ReturnTypeId);
+ if (retType != VoidType && _evalStack.Count > 0)
+ {
+ var pop = PopVariant();
+ try
+ {
+ result = VariantFactory.Convert(null, retType).CopyFrom(pop).GetValueAbstract();
+ }
+ catch (Exception)
+ {
+ result = pop.GetValueAbstract(); // example: ckfinite with no numeric
+ //throw;
+ }
+ }
+ else
+ {
+ result = null;
+ }
+ }
+ finally
+ {
+ for (var i = 0; i < _methodHeader.ArgsTypeToOutput.Length; i++)
+ {
+ var argTypeToOutput = _methodHeader.ArgsTypeToOutput[i];
+ if (argTypeToOutput.IsOutput)
+ {
+ var argOutValue = (VariantBaseHolder)_variantOutputArgs[i];
+ var argType = GetTypeById(argTypeToOutput.TypeId);
+ args[i] = VariantFactory.Convert(null, argType.GetElementType()).CopyFrom(argOutValue.GetValue()).GetValueAbstract();
+ }
+ }
+ _callees = null;
+ _variantOutputArgs = null;
+ _localVariables = null;
+ }
+ return result;
+ }
+
+ // Token: 0x06000269 RID: 617 RVA: 0x00010F7C File Offset: 0x0000F17C
+ private void Seek(string pos, Stream virtualizedStream) // \u0002
+ {
+ Seek(0L, virtualizedStream, pos);
+ }
+
+ // Token: 0x0600025C RID: 604 RVA: 0x00010B38 File Offset: 0x0000ED38
+ private void DoNothing(BinaryReader dummy) // \u0002
+ {
+ }
+
+ // Token: 0x06000250 RID: 592 RVA: 0x000106EC File Offset: 0x0000E8EC
+ private static CatchBlock ReadCatchBlock(BinaryReader r) // \u0002
+ {
+ return new CatchBlock
+ {
+ Kind = r.ReadByte(),
+ ExcTypeId = r.ReadInt32(),
+ Pos = r.ReadUInt32(),
+ PosKind4 = r.ReadUInt32(),
+ Start = r.ReadUInt32(),
+ Len = r.ReadUInt32()
+ };
+ }
+
+ // Token: 0x060001FC RID: 508 RVA: 0x0000BD50 File Offset: 0x00009F50
+ private static CatchBlock[] ReadCatchBlocks(BinaryReader r) // \u0002
+ {
+ var num = (int)r.ReadInt16();
+ var array = new CatchBlock[num];
+ for (var i = 0; i < num; i++)
+ {
+ array[i] = ReadCatchBlock(r);
+ }
+ return array;
+ }
+
+ // Token: 0x060001BF RID: 447 RVA: 0x00009564 File Offset: 0x00007764
+ private static byte[] ReadByteArray(BinaryReader r) // \u0002
+ {
+ var num = r.ReadInt32();
+ var array = new byte[num];
+ r.Read(array, 0, num);
+ return array;
+ }
+
+ // Token: 0x060001C1 RID: 449 RVA: 0x000096E4 File Offset: 0x000078E4
+ public void Seek(long parsedPos, Stream virtualizedStream, string pos) // \u0002
+ {
+ var input = new VmStreamWrapper(virtualizedStream, VmXorKey());
+ _srcVirtualizedStreamReader = new BinaryReader(input);
+ var baseStream = _srcVirtualizedStreamReader.BaseStream;
+ lock (baseStream)
+ {
+ if (pos != null)
+ {
+ parsedPos = ParsePos(pos);
+ }
+ _srcVirtualizedStreamReader.BaseStream.Seek(parsedPos, SeekOrigin.Begin);
+ DoNothing(_srcVirtualizedStreamReader);
+ _methodHeader = ReadMethodHeader(_srcVirtualizedStreamReader);
+ _catchBlocks = ReadCatchBlocks(_srcVirtualizedStreamReader);
+ SortCatchBlocks();
+ _methodBody = ReadByteArray(_srcVirtualizedStreamReader);
+ }
+ }
+
+ // Token: 0x06000203 RID: 515 RVA: 0x0000C164 File Offset: 0x0000A364
+ private long ParsePos(string pos) // \u0002
+ {
+ using (var memoryStream = new MemoryStream(VmPosParser.Parse(pos)))
+ {
+ return new BinaryReader(new VmStreamWrapper(memoryStream, PosXorKey())).ReadInt64();
+ }
+ }
+
+ // Token: 0x060001B5 RID: 437 RVA: 0x000092D8 File Offset: 0x000074D8
+ private int PosXorKey() // \u0002
+ {
+ return -2023764088;
+ }
+
+ // Token: 0x0600017B RID: 379 RVA: 0x00007DEC File Offset: 0x00005FEC
+ public static int VmXorKey() // \u0003
+ {
+ return 1783652397;
+ }
+
+ // Token: 0x060001E7 RID: 487 RVA: 0x0000B0F8 File Offset: 0x000092F8
+ private LocalVarType ReadLocalVarType(BinaryReader r) // \u0002
+ {
+ return new LocalVarType { TypeId = r.ReadInt32() };
+ }
+
+ // Token: 0x060001AB RID: 427 RVA: 0x00008FF8 File Offset: 0x000071F8
+ private LocalVarType[] ReadLocalVarTypes(BinaryReader r) // \u0002
+ {
+ var array = new LocalVarType[r.ReadInt16()];
+ for (var i = 0; i < array.Length; i++)
+ {
+ array[i] = ReadLocalVarType(r);
+ }
+ return array;
+ }
+
+ // Token: 0x0600023B RID: 571 RVA: 0x0000F9E0 File Offset: 0x0000DBE0
+ private ArgTypeToOutput ReadArgTypeToOutput(BinaryReader r) // \u0002
+ {
+ var ret = new ArgTypeToOutput
+ {
+ TypeId = r.ReadInt32(),
+ IsOutput = r.ReadBoolean()
+ };
+ return ret;
+ }
+
+ // Token: 0x06000287 RID: 647 RVA: 0x00012138 File Offset: 0x00010338
+ private ArgTypeToOutput[] ReadArgsTypeToOutput(BinaryReader r) // \u0002
+ {
+ var array = new ArgTypeToOutput[r.ReadInt16()];
+ for (var i = 0; i < array.Length; i++)
+ {
+ array[i] = ReadArgTypeToOutput(r);
+ }
+ return array;
+ }
+
+ // Token: 0x06000216 RID: 534 RVA: 0x0000C790 File Offset: 0x0000A990
+ private VmMethodHeader ReadMethodHeader(BinaryReader src) // \u0002
+ {
+ var ret = new VmMethodHeader
+ {
+ ClassId = src.ReadInt32(),
+ ReturnTypeId = src.ReadInt32(),
+ LocalVarTypes = ReadLocalVarTypes(src),
+ Flags = src.ReadByte(),
+ Name = src.ReadString(),
+ ArgsTypeToOutput = ReadArgsTypeToOutput(src)
+ };
+ return ret;
+ }
+
+ // Token: 0x06000266 RID: 614 RVA: 0x00010C54 File Offset: 0x0000EE54
+ private void Shr_un_(VariantBase dummy) // \u000F\u2001
+ {
+ PushVariant(Shift(false, false));
+ }
+
+ // Token: 0x06000176 RID: 374 RVA: 0x00007CAC File Offset: 0x00005EAC
+ private void Shr_(VariantBase dummy) // \u0005\u2007\u2000
+ {
+ PushVariant(Shift(false, true));
+ }
+
+ private VariantBase Xor(VariantBase org_v1, VariantBase org_v2)
+ {
+ VariantBase v1, v2;
+ var tc = CommonType(org_v1, org_v2, out v1, out v2, true);
+ VariantBase ret;
+ switch (tc)
+ {
+ case VariantBase.Vtc.Tc9Uint:
+ uint uv1 = ((UintVariant)v1).GetValue(), uv2 = ((UintVariant)v2).GetValue();
+ var uvret = new UintVariant();
+ ret = uvret;
+ uvret.SetValue(uv1 ^ uv2);
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ int iv1 = ((IntVariant)v1).GetValue(), iv2 = ((IntVariant)v2).GetValue();
+ var ivret = new IntVariant();
+ ret = ivret;
+ ivret.SetValue(iv1 ^ iv2);
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ {
+ /*double dv1 = ((DoubleVariant)v1).GetValue(), dv2 = ((DoubleVariant)v2).GetValue(); // естественный алгоритм
+ long lv1 = (dv1 < 0) ? (long)dv1 : (long)(ulong)dv1;
+ long lv2 = (dv2 < 0) ? (long)dv2 : (long)(ulong)dv2;
+ var dvret = new DoubleVariant();
+ ret = dvret;
+ var l64 = (ulong) lv1 ^ (ulong) lv2;
+ if (l64 >> 32 == UInt32.MaxValue) l64 &= UInt32.MaxValue;
+ dvret.SetValue(l64);*/
+ var dvret = new DoubleVariant();
+ ret = dvret;
+ dvret.SetValue((4 == IntPtr.Size) ? Double.NaN : (double)0); // иногда у фреймворка бывает мусор, но чаще эти значения...
+ }
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ {
+ /*float fv1 = ((FloatVariant) v1).GetValue(), fv2 = ((FloatVariant) v2).GetValue(); // естественный алгоритм
+ long lv1 = (fv1 < 0) ? (long)fv1 : (long)(ulong)fv1;
+ long lv2 = (fv2 < 0) ? (long)fv2 : (long)(ulong)fv2;
+ var fvret = new FloatVariant();
+ ret = fvret;
+ var l64 = (ulong)lv1 ^ (ulong)lv2;
+ if (l64 >> 32 == UInt32.MaxValue) l64 &= UInt32.MaxValue;
+ fvret.SetValue(l64);*/
+ var fvret = new FloatVariant();
+ ret = fvret;
+ fvret.SetValue((4 == IntPtr.Size) ? float.NaN : (float)0.0); // иногда у фреймворка бывает мусор, но чаще эти значения...
+ }
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ {
+ long lv1 = ((LongVariant)v1).GetValue(), lv2 = ((LongVariant)v2).GetValue();
+ var lvret = new LongVariant();
+ ret = lvret;
+ lvret.SetValue(lv1 ^ lv2);
+ }
+ break;
+ case VariantBase.Vtc.Tc7Ulong:
+ ulong ulv1 = ((UlongVariant)v1).GetValue(), ulv2 = ((UlongVariant)v2).GetValue();
+ var ulvret = new UlongVariant();
+ ret = ulvret;
+ ulvret.SetValue(ulv1 ^ ulv2);
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(IntPtr), new[] { typeof(object), typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_1);
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(OpCodes.Xor);
+ gen.Emit(OpCodes.Ret);
+ ret = new IntPtrVariant();
+ ((IntPtrVariant)ret).SetValue(((IntPtr)dyn.Invoke(null, new[] { org_v1.GetValueAbstract(), org_v2.GetValueAbstract() })));
+ break;
+ }
+ return ret;
+ }
+
+ // Token: 0x0600026C RID: 620 RVA: 0x00010FC8 File Offset: 0x0000F1C8
+ private void Xor_(VariantBase dummy) // \u0008\u2001\u2000
+ {
+ var v1 = PopVariant();
+ var v2 = PopVariant();
+ PushVariant(Xor(v2, v1));
+ }
+
+ // Token: 0x06000189 RID: 393 RVA: 0x00008244 File Offset: 0x00006444
+ private void Shl_(VariantBase dummy) // \u0006\u2002\u2001
+ {
+ PushVariant(Shift(true, true));
+ }
+
+ VariantBase.Vtc CommonTypeShift(VariantBase org_val, VariantBase org_shift, out VariantBase val, out VariantBase shift, bool signed)
+ {
+ val = org_val.Clone();
+ shift = org_shift.Clone();
+ var tcval = UnderlyingTypeCode(ref val);
+ var tcsh = UnderlyingTypeCode(ref shift);
+ if (tcval == VariantBase.Vtc.Tc18Object || tcsh == VariantBase.Vtc.Tc18Object)
+ return VariantBase.Vtc.Tc18Object;
+ shift = new LongVariant();
+ long lsh = 0;
+ switch (org_shift.GetTypeCode())
+ {
+ case VariantBase.Vtc.Tc5Enum:
+ lsh = VariantBase.SignedLongFromEnum((EnumVariant) org_shift);
+ break;
+ case VariantBase.Vtc.Tc13UIntPtr:
+ lsh = (long)((UIntPtrVariant)org_shift).GetValue().ToUInt64();
+ break;
+ case VariantBase.Vtc.Tc17IntPtr:
+ lsh = ((IntPtrVariant)org_shift).GetValue().ToInt64();
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ lsh = ((IntVariant)org_shift).GetValue();
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ lsh = ((LongVariant)org_shift).GetValue();
+ break;
+ }
+ shift.SetValueAbstract(lsh);
+ VariantBase.Vtc ret = tcval;
+ if (!signed)
+ {
+ val = AsUnsigned(val);
+ }
+ if (!signed) switch (ret)
+ {
+ case VariantBase.Vtc.Tc19Int:
+ return VariantBase.Vtc.Tc9Uint;
+ case VariantBase.Vtc.Tc24Long:
+ return VariantBase.Vtc.Tc7Ulong;
+ }
+ return ret;
+ }
+
+ private VariantBase Shift(bool left, bool signed)
+ {
+ VariantBase val, shift;
+
+ var org_shift = PopVariant();
+ var org_val = PopVariant();
+ var tc = CommonTypeShift(org_val, org_shift, out val, out shift, signed);
+ var sh = (int)(long)shift.GetValueAbstract();
+ VariantBase ret;
+ switch (tc)
+ {
+ case VariantBase.Vtc.Tc9Uint:
+ uint uv1 = ((UintVariant)val).GetValue();
+ var uvret = new UintVariant();
+ ret = uvret;
+ if (left)
+ {
+ uvret.SetValue(uv1 << sh);
+ }
+ else
+ {
+ uvret.SetValue(uv1 >> sh);
+ }
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ int iv1 = ((IntVariant)val).GetValue();
+ var ivret = new IntVariant();
+ ret = ivret;
+ if (left)
+ {
+ ivret.SetValue(iv1 << sh);
+ }
+ else
+ {
+ ivret.SetValue(iv1 >> sh);
+ }
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ /*double dv1 = ((DoubleVariant)val).GetValue(), dv2 = ((DoubleVariant)shift).GetValue();
+ var dvret = new DoubleVariant();
+ ret = dvret;
+ var dmul = left ? 2 : 0.5;
+ dvret.SetValue(dv1 * Math.Pow(dmul, dv2));
+ break;*/
+ case VariantBase.Vtc.Tc8Float:
+ /*float fv1 = ((FloatVariant)val).GetValue(), fv2 = ((FloatVariant)shift).GetValue();
+ var fvret = new FloatVariant();
+ ret = fvret;
+ var fmul = left ? 2f : 0.5f;
+ fvret.SetValue(fv1 * (float)Math.Pow(fmul, fv2));
+ break;*/
+ throw new InvalidProgramException();
+ case VariantBase.Vtc.Tc24Long:
+ long lv1 = ((LongVariant)val).GetValue();
+ var lvret = new LongVariant();
+ ret = lvret;
+ if (left)
+ {
+ lvret.SetValue(lv1 << sh);
+ }
+ else
+ {
+ lvret.SetValue(lv1 >> sh);
+ }
+ break;
+ case VariantBase.Vtc.Tc7Ulong:
+ ulong ulv1 = ((UlongVariant)val).GetValue();
+ var ulvret = new UlongVariant();
+ ret = ulvret;
+ if (left)
+ {
+ ulvret.SetValue(ulv1 << sh);
+ }
+ else
+ {
+ ulvret.SetValue(ulv1 >> sh);
+ }
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(IntPtr), new[] { typeof(object), typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_1);
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(signed ? (left ? OpCodes.Shl : OpCodes.Shr) : OpCodes.Shr_Un);
+ gen.Emit(OpCodes.Ret);
+ ret = new IntPtrVariant();
+ ((IntPtrVariant)ret).SetValue(((IntPtr)dyn.Invoke(null, new[] { org_val.GetValueAbstract(), org_shift.GetValueAbstract() })));
+ break;
+ }
+ return ret;
+ }
+
+ // Token: 0x06000173 RID: 371 RVA: 0x00007BE0 File Offset: 0x00005DE0
+ private void Initblk_(VariantBase dummy) // \u0002\u2002\u2000
+ {
+ throw new NotSupportedException(StringDecryptor.GetString(-1550345287) /* Initblk not supported. */);
+ }
+
+ // Token: 0x0600020A RID: 522 RVA: 0x0000C508 File Offset: 0x0000A708
+ private void Localloc_(VariantBase dummy) // \u0008\u200A\u2000
+ {
+ throw new NotSupportedException(StringDecryptor.GetString(-1550345866) /* Localloc not supported. */);
+ }
+
+ // Token: 0x06000212 RID: 530 RVA: 0x0000C73C File Offset: 0x0000A93C
+ private void Refanyval_(VariantBase dummy) // \u0005\u200A\u2000
+ {
+ throw new NotSupportedException(StringDecryptor.GetString(-1550345900) /* Refanyval is not supported. */);
+ }
+
+ // Token: 0x06000237 RID: 567 RVA: 0x0000F984 File Offset: 0x0000DB84
+ private void Refanytype_(VariantBase dummy) // \u000F\u2005
+ {
+ throw new NotSupportedException(StringDecryptor.GetString(-1550345460) /* Refanytype is not supported. */);
+ }
+
+ // Token: 0x0600029C RID: 668 RVA: 0x000126CC File Offset: 0x000108CC
+ private void Cpblk_(VariantBase dummy) // \u0002\u2006
+ {
+ throw new NotSupportedException(StringDecryptor.GetString(-1550345423) /* Cpblk not supported. */);
+ }
+
+ // Token: 0x060001CA RID: 458 RVA: 0x00009E68 File Offset: 0x00008068
+ private void Cpobj_(VariantBase dummy) // \u0008\u2009
+ {
+ throw new NotSupportedException(StringDecryptor.GetString(-1550345317) /* Cpobj is not supported. */);
+ }
+
+ // Token: 0x060001D2 RID: 466 RVA: 0x0000A338 File Offset: 0x00008538
+ private void Arglist_(VariantBase dummy) // \u000F\u2002\u2001
+ {
+ throw new NotSupportedException(StringDecryptor.GetString(-1550345940) /* Arglist is not supported. */);
+ }
+
+ // Token: 0x06000187 RID: 391 RVA: 0x00008224 File Offset: 0x00006424
+ private void Mkrefany_(VariantBase dummy) // \u0002\u2007
+ {
+ throw new NotSupportedException(StringDecryptor.GetString(-1550345270) /* Mkrefany is not supported. */);
+ }
+
+ // Token: 0x0600017E RID: 382 RVA: 0x00007ECC File Offset: 0x000060CC
+ private static BindingFlags BF(bool isStatic) // \u0002
+ {
+ var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic;
+ if (isStatic)
+ {
+ bindingFlags |= BindingFlags.Static;
+ }
+ else
+ {
+ bindingFlags |= BindingFlags.Instance;
+ }
+ return bindingFlags;
+ }
+
+ // Token: 0x06000192 RID: 402 RVA: 0x000084F4 File Offset: 0x000066F4
+ private void Ldc_i4_0_(VariantBase dummy) // \u0005\u2001
+ {
+ var iv = new IntVariant();
+ iv.SetValue(0);
+ PushVariant(iv);
+ }
+
+ // Token: 0x0600028F RID: 655 RVA: 0x0001235C File Offset: 0x0001055C
+ private void Ldc_i4_1_(VariantBase dummy) // \u0002\u2005\u2000
+ {
+ var iv = new IntVariant();
+ iv.SetValue(1);
+ PushVariant(iv);
+ }
+
+ // Token: 0x0600022F RID: 559 RVA: 0x0000F8C8 File Offset: 0x0000DAC8
+ private void Ldc_i4_2_(VariantBase dummy) // \u0005
+ {
+ var iv = new IntVariant();
+ iv.SetValue(2);
+ PushVariant(iv);
+ }
+
+ // Token: 0x06000174 RID: 372 RVA: 0x00007BF4 File Offset: 0x00005DF4
+ private void Ldc_i4_3_(VariantBase dummy) // \u0008\u2006\u2000
+ {
+ var iv = new IntVariant();
+ iv.SetValue(3);
+ PushVariant(iv);
+ }
+
+ // Token: 0x06000262 RID: 610 RVA: 0x00010BEC File Offset: 0x0000EDEC
+ private void Ldc_i4_4_(VariantBase dummy) // \u000F\u2009\u2000
+ {
+ var iv = new IntVariant();
+ iv.SetValue(4);
+ PushVariant(iv);
+ }
+
+ // Token: 0x060001B3 RID: 435 RVA: 0x000092B4 File Offset: 0x000074B4
+ private void Ldc_i4_5_(VariantBase dummy) // \u0008\u2004\u2000
+ {
+ var iv = new IntVariant();
+ iv.SetValue(5);
+ PushVariant(iv);
+ }
+
+ // Token: 0x06000231 RID: 561 RVA: 0x0000F900 File Offset: 0x0000DB00
+ private void Ldc_i4_6_(VariantBase dummy) // \u0006\u2009\u2000
+ {
+ var iv = new IntVariant();
+ iv.SetValue(6);
+ PushVariant(iv);
+ }
+
+ // Token: 0x0600026A RID: 618 RVA: 0x00010F88 File Offset: 0x0000F188
+ private void Ldc_i4_7_(VariantBase dummy) // \u0003\u2003\u2000
+ {
+ var iv = new IntVariant();
+ iv.SetValue(7);
+ PushVariant(iv);
+ }
+
+ // Token: 0x060001A9 RID: 425 RVA: 0x00008FA8 File Offset: 0x000071A8
+ private void Ldc_i4_8_(VariantBase dummy) // \u000E\u2001
+ {
+ var iv = new IntVariant();
+ iv.SetValue(8);
+ PushVariant(iv);
+ }
+
+ // Token: 0x0600016F RID: 367 RVA: 0x00007A58 File Offset: 0x00005C58
+ private void Unbox_(VariantBase vTypeId) // \u0005\u2003\u2000
+ {
+ var type = GetTypeById(((IntVariant)vTypeId).GetValue());
+ var val = VariantFactory.Convert(PopVariant().GetValueAbstract(), type);
+ PushVariant(val);
+ }
+
+ // Token: 0x06000207 RID: 519 RVA: 0x0000C228 File Offset: 0x0000A428
+ private VmTokenInfo ReadVmToken(BinaryReader reader) // \u0002
+ {
+ switch (reader.ReadByte())
+ {
+ case (byte)VmTokenInfo.Kind.Class0:
+ {
+ var ret = new VmClassTokenInfo
+ {
+ OuterClassGenericMethodIdx = reader.ReadInt32(),
+ OuterClassGenericClassIdx = reader.ReadInt32(),
+ IsOuterClassGeneric = reader.ReadBoolean(),
+ ClassName = reader.ReadString(),
+ IsGeneric = reader.ReadBoolean(),
+ GenericArguments = new UniversalTokenInfo[(int) reader.ReadInt16()]
+ };
+ for (var i = 0; i < ret.GenericArguments.Length; i++)
+ {
+ ret.GenericArguments[i] = new UniversalTokenInfo
+ {
+ IsVm = 1,
+ MetadataToken = reader.ReadInt32()
+ };
+ }
+ return ret;
+ }
+ case (byte)VmTokenInfo.Kind.Field1:
+ return new VmFieldTokenInfo
+ {
+ Class = new UniversalTokenInfo
+ {
+ IsVm = 1,
+ MetadataToken = reader.ReadInt32()
+ },
+ Name = reader.ReadString(),
+ IsStatic = reader.ReadBoolean()
+ };
+ case (byte)VmTokenInfo.Kind.Method2:
+ {
+ var ret = new VmMethodTokenInfo
+ {
+ Class = new UniversalTokenInfo
+ {
+ IsVm = 1,
+ MetadataToken = reader.ReadInt32()
+ },
+ Flags = reader.ReadByte(),
+ Name = reader.ReadString(),
+ ReturnType = new UniversalTokenInfo
+ {
+ IsVm = 1,
+ MetadataToken = reader.ReadInt32()
+ },
+ Parameters = new UniversalTokenInfo[(int)reader.ReadInt16()]
+ };
+ for (var j = 0; j < ret.Parameters.Length; j++)
+ {
+ ret.Parameters[j] = new UniversalTokenInfo
+ {
+ IsVm = 1,
+ MetadataToken = reader.ReadInt32()
+ };
+ }
+ var gaCnt = (int)reader.ReadInt16();
+ ret.GenericArguments = new UniversalTokenInfo[gaCnt];
+ for (var k = 0; k < gaCnt; k++)
+ {
+ ret.GenericArguments[k] = new UniversalTokenInfo
+ {
+ IsVm = 1,
+ MetadataToken = reader.ReadInt32()
+ };
+ }
+ return ret;
+ }
+ case (byte)VmTokenInfo.Kind.String3:
+ return new VmStringTokenInfo { Value = reader.ReadString() };
+ case (byte)VmTokenInfo.Kind.MethodRef4:
+ return new VmMethodRefTokenInfo
+ {
+ Flags = reader.ReadInt32(),
+ Pos = reader.ReadInt32()
+ };
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ }
+
+ // Token: 0x06000175 RID: 373 RVA: 0x00007C08 File Offset: 0x00005E08
+ private UniversalTokenInfo ReadToken(int pos) // u0002
+ {
+ if (_srcVirtualizedStreamReader == null)
+ {
+ throw new InvalidOperationException();
+ }
+ var baseStream = _srcVirtualizedStreamReader.BaseStream;
+ UniversalTokenInfo result;
+ lock (baseStream)
+ {
+ _srcVirtualizedStreamReader.BaseStream.Seek(pos, SeekOrigin.Begin);
+ result = new UniversalTokenInfo {IsVm = _srcVirtualizedStreamReader.ReadByte()};
+ if (result.IsVm == 0)
+ {
+ result.MetadataToken = _srcVirtualizedStreamReader.ReadInt32();
+ }
+ else
+ {
+ result.VmToken = ReadVmToken(_srcVirtualizedStreamReader);
+ }
+ }
+ return result;
+ }
+
+ // Token: 0x06000248 RID: 584 RVA: 0x000102AC File Offset: 0x0000E4AC
+ private string Ldstr(int strToken) // \u0002
+ {
+ string result;
+ lock (AllMetadataById)
+ {
+ object stored;
+ if (AllMetadataById.TryGetValue(strToken, out stored))
+ {
+ result = (string)stored;
+ }
+ else
+ {
+ var tokenInfo = ReadToken(strToken);
+ if (tokenInfo.IsVm == 0)
+ {
+ result = _module.ResolveString(tokenInfo.MetadataToken);
+ }
+ else
+ {
+ var text = ((VmStringTokenInfo)tokenInfo.VmToken).Value;
+ AllMetadataById.Add(strToken, text);
+ result = text;
+ }
+ }
+ }
+ return result;
+ }
+
+ // Token: 0x0600019C RID: 412 RVA: 0x00008B34 File Offset: 0x00006D34
+ private void Ldstr_(VariantBase strToken) // \u000E\u2000\u2001
+ {
+ var tok = ((IntVariant)strToken).GetValue();
+ var text = Ldstr(tok);
+ var val = new StringVariant();
+ val.SetValue(text);
+ PushVariant(val);
+ }
+
+ // Token: 0x06000170 RID: 368 RVA: 0x00007A94 File Offset: 0x00005C94
+ private VariantBase ReadOperand(MyBufferReader r, VmOperandType operandType) // \u0002
+ {
+ switch (operandType)
+ {
+ case VmOperandType.Ot0UInt:
+ {
+ var ret = new UintVariant();
+ ret.SetValue(r.ReadUint());
+ return ret;
+ }
+ case VmOperandType.Ot1UShort:
+ case VmOperandType.Ot3UShort:
+ {
+ var ret = new UshortVariant();
+ ret.SetValue(r.ReadUshort());
+ return ret;
+ }
+ case VmOperandType.Ot2Byte:
+ case VmOperandType.Ot8Byte:
+ {
+ var ret = new ByteVariant();
+ ret.SetValue(r.ReadByte());
+ return ret;
+ }
+ case VmOperandType.Ot4Double:
+ {
+ var ret = new DoubleVariant();
+ ret.SetValue(r.ReadDouble());
+ return ret;
+ }
+ case VmOperandType.Ot5Int:
+ case VmOperandType.Ot12Int:
+ {
+ var ret = new IntVariant();
+ ret.SetValue(r.ReadInt32());
+ return ret;
+ }
+ case VmOperandType.Ot6SByte:
+ {
+ var ret = new SbyteVariant();
+ ret.SetValue(r.ReadSbyte());
+ return ret;
+ }
+ case VmOperandType.Ot7Long:
+ {
+ var ret = new LongVariant();
+ ret.SetValue(r.ReadLong());
+ return ret;
+ }
+ case VmOperandType.Ot9IntArr:
+ {
+ var num = r.ReadInt32();
+ var array = new IntVariant[num];
+ for (var i = 0; i < num; i++)
+ {
+ var item = new IntVariant();
+ item.SetValue(r.ReadInt32());
+ array[i] = item;
+ }
+ var ret = new ArrayVariant();
+ ret.SetValue(array);
+ return ret;
+ }
+ case VmOperandType.Ot10Float:
+ {
+ var ret = new FloatVariant();
+ ret.SetValue(r.ReadFloat());
+ return ret;
+ }
+ case VmOperandType.Ot11Nope:
+ return null;
+ default:
+ throw new Exception(StringDecryptor.GetString(-1550347123) /* Unknown operand type. */);
+ }
+ }
+
+ // Token: 0x06000279 RID: 633 RVA: 0x0001184C File Offset: 0x0000FA4C
+ enum ComparisonKind { EQ, NEQ, GT, LE, LT, GE }
+ private static bool UniCompare(VariantBase v1, VariantBase v2, ComparisonKind ck, bool unsignedNanBranch) // \u0008 - bug fixed (метод переписан)
+ {
+ // from stack: enum double single long int
+ var t1 = v1.GetTypeCode();
+ if (t1 == VariantBase.Vtc.Tc5Enum)
+ {
+ var vv1 = VariantBase.SignedVariantFromEnum((EnumVariant)v1);
+ return UniCompare(vv1, v2, ck, unsignedNanBranch);
+ }
+ var t2 = v2.GetTypeCode();
+ if (t2 == VariantBase.Vtc.Tc5Enum)
+ {
+ var vv2 = VariantBase.SignedVariantFromEnum((EnumVariant)v2);
+ return UniCompare(v1, vv2, ck, unsignedNanBranch);
+ }
+ if (t1 == VariantBase.Vtc.Tc18Object || t2 == VariantBase.Vtc.Tc18Object)
+ {
+ if (ck == ComparisonKind.EQ) return v1.GetValueAbstract().Equals(v2.GetValueAbstract());
+ if (ck == ComparisonKind.NEQ) return !v1.GetValueAbstract().Equals(v2.GetValueAbstract());
+ return false;
+ }
+ if (t1 == VariantBase.Vtc.Tc21Double || t2 == VariantBase.Vtc.Tc21Double)
+ {
+ var d1 = (t1 == VariantBase.Vtc.Tc21Double) ? ((DoubleVariant)v1).GetValue() : Convert.ToDouble(v1.GetValueAbstract());
+ var d2 = (t2 == VariantBase.Vtc.Tc21Double) ? ((DoubleVariant)v2).GetValue() : Convert.ToDouble(v2.GetValueAbstract());
+ if (unsignedNanBranch) unsignedNanBranch = (double.IsNaN(d1) || double.IsNaN(d2));
+ switch (ck)
+ {
+ case ComparisonKind.EQ:
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return (d1 == d2) || unsignedNanBranch;
+ case ComparisonKind.GT:
+ return (d1 > d2) || unsignedNanBranch;
+ case ComparisonKind.NEQ:
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return (d1 != d2) || unsignedNanBranch;
+ case ComparisonKind.LE:
+ return (d1 <= d2) || unsignedNanBranch;
+ case ComparisonKind.LT:
+ return (d1 < d2) || unsignedNanBranch;
+ case ComparisonKind.GE:
+ return (d1 >= d2) || unsignedNanBranch;
+ }
+ }
+ if (t1 == VariantBase.Vtc.Tc8Float || t2 == VariantBase.Vtc.Tc8Float)
+ {
+ var d1 = (t1 == VariantBase.Vtc.Tc8Float) ? ((FloatVariant)v1).GetValue() : Convert.ToSingle(v1.GetValueAbstract());
+ var d2 = (t2 == VariantBase.Vtc.Tc8Float) ? ((FloatVariant)v2).GetValue() : Convert.ToSingle(v2.GetValueAbstract());
+ if (unsignedNanBranch) unsignedNanBranch = (float.IsNaN(d1) || float.IsNaN(d2));
+ switch (ck)
+ {
+ case ComparisonKind.EQ:
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return (d1 == d2) || unsignedNanBranch;
+ case ComparisonKind.GT:
+ return (d1 > d2) || unsignedNanBranch;
+ case ComparisonKind.NEQ:
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return (d1 != d2) || unsignedNanBranch;
+ case ComparisonKind.LE:
+ return (d1 <= d2) || unsignedNanBranch;
+ case ComparisonKind.LT:
+ return (d1 < d2) || unsignedNanBranch;
+ case ComparisonKind.GE:
+ return (d1 >= d2) || unsignedNanBranch;
+ }
+ }
+ if (t1 == VariantBase.Vtc.Tc24Long || t2 == VariantBase.Vtc.Tc24Long)
+ {
+ var d1 = (t1 == VariantBase.Vtc.Tc24Long) ? ((LongVariant)v1).GetValue() : (unsignedNanBranch ? Convert.ToInt64((uint)(int)v1.GetValueAbstract()) : Convert.ToInt64(v1.GetValueAbstract()));
+ var d2 = (t2 == VariantBase.Vtc.Tc24Long) ? ((LongVariant)v2).GetValue() : (unsignedNanBranch ? Convert.ToInt64((uint)(int)v2.GetValueAbstract()) : Convert.ToInt64(v2.GetValueAbstract()));
+ switch (ck)
+ {
+ case ComparisonKind.EQ:
+ return d1 == d2;
+ case ComparisonKind.GT:
+ if(unsignedNanBranch) return (ulong)d1 > (ulong)d2;
+ return d1 > d2;
+ case ComparisonKind.NEQ:
+ if (unsignedNanBranch) return (ulong)d1 != (ulong)d2;
+ return d1 != d2;
+ case ComparisonKind.LE:
+ if (unsignedNanBranch) return (ulong)d1 <= (ulong)d2;
+ return d1 <= d2;
+ case ComparisonKind.LT:
+ if (unsignedNanBranch) return (ulong)d1 < (ulong)d2;
+ return d1 < d2;
+ case ComparisonKind.GE:
+ if (unsignedNanBranch) return (ulong)d1 >= (ulong)d2;
+ return d1 >= d2;
+ }
+ }
+ if (t1 == VariantBase.Vtc.Tc19Int || t2 == VariantBase.Vtc.Tc19Int)
+ {
+ switch (ck)
+ {
+ case ComparisonKind.EQ:
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return ((IntVariant)v1).GetValue() == ((IntVariant)v2).GetValue();
+ case ComparisonKind.GT:
+ if (unsignedNanBranch) return (uint)((IntVariant)v1).GetValue() > (uint)((IntVariant)v2).GetValue();
+ return ((IntVariant)v1).GetValue() > ((IntVariant)v2).GetValue();
+ case ComparisonKind.NEQ:
+ if (unsignedNanBranch) return (uint)((IntVariant)v1).GetValue() != (uint)((IntVariant)v2).GetValue();
+ return ((IntVariant)v1).GetValue() != ((IntVariant)v2).GetValue();
+ case ComparisonKind.LE:
+ if (unsignedNanBranch) return (uint)((IntVariant)v1).GetValue() <= (uint)((IntVariant)v2).GetValue();
+ return ((IntVariant)v1).GetValue() <= ((IntVariant)v2).GetValue();
+ case ComparisonKind.LT:
+ if (unsignedNanBranch) return (uint)((IntVariant)v1).GetValue() < (uint)((IntVariant)v2).GetValue();
+ return ((IntVariant)v1).GetValue() < ((IntVariant)v2).GetValue();
+ //case ComparisonKind.GE:
+ default:
+ if (unsignedNanBranch) return (uint)((IntVariant)v1).GetValue() >= (uint)((IntVariant)v2).GetValue();
+ return ((IntVariant)v1).GetValue() >= ((IntVariant)v2).GetValue();
+ }
+ }
+ return false;
+ }
+
+ // Token: 0x0600017F RID: 383 RVA: 0x00007EEC File Offset: 0x000060EC
+ private void Ldelema_(VariantBase vTypeId) // \u000F\u2002
+ {
+ var type = GetTypeById(((IntVariant)vTypeId).GetValue());
+ var idx = PopLong();
+ var array = (Array)PopVariant().GetValueAbstract();
+ var val = new SdArrayValueVariant();
+ val.SetArray(array);
+ val.SetHeldType(type);
+ val.SetIndex(idx);
+ PushVariant(val);
+ }
+
+ // Token: 0x06000252 RID: 594 RVA: 0x00010780 File Offset: 0x0000E980
+ private void Ldelem_ref_(VariantBase dummy) // \u000F\u2003\u2000
+ {
+ Ldelem(SimpleTypeHelper.ObjectType);
+ }
+
+ // Token: 0x06000178 RID: 376 RVA: 0x00007D38 File Offset: 0x00005F38
+ private static void SerializeCrossDomain(Exception ex) // \u0002
+ {
+ if (ex == null)
+ {
+ return;
+ }
+ try
+ {
+ var type = ex.GetType();
+ if (type.IsSerializable)
+ {
+ var context = new StreamingContext(StreamingContextStates.CrossAppDomain);
+ var om = new ObjectManager(null, context);
+ var info = new SerializationInfo(type, new FormatterConverter());
+ ex.GetObjectData(info, context);
+ om.RegisterObject(ex, 1L, info);
+ om.DoFixups();
+ }
+ }
+ catch
+ {
+ }
+ }
+
+ // Token: 0x060001DF RID: 479 RVA: 0x0000ABCC File Offset: 0x00008DCC
+ private static void Throw(object ex) // \u0003
+ {
+ throw (Exception)ex;
+ }
+
+ // Token: 0x0600024D RID: 589 RVA: 0x000105A0 File Offset: 0x0000E7A0
+ private static void ThrowStoreCrossDomain(object ex) // \u0002
+ {
+ SerializeCrossDomain(ex as Exception);
+ Throw(ex);
+ }
+
+ // Token: 0x06000293 RID: 659 RVA: 0x00012398 File Offset: 0x00010598
+ private static VariantBase SubLong(VariantBase v1, VariantBase v2, bool bChecked, bool bUnsigned) // \u0005
+ {
+ var lvret = new LongVariant();
+ if (!bUnsigned)
+ {
+ var l1 = ((LongVariant)v1).GetValue();
+ var l2 = ((LongVariant)v2).GetValue();
+ long lret;
+ if (bChecked)
+ {
+ lret = checked(l1 - l2);
+ }
+ else
+ {
+ lret = l1 - l2;
+ }
+ lvret.SetValue(lret);
+ return lvret;
+ }
+ var u1 = (ulong)((LongVariant)v1).GetValue();
+ var u2 = (ulong)((LongVariant)v2).GetValue();
+ ulong uret;
+ if (bChecked)
+ {
+ uret = checked(u1 - u2);
+ }
+ else
+ {
+ uret = u1 - u2;
+ }
+ lvret.SetValue((long)uret);
+ return lvret;
+ }
+
+ private VariantBase Sub(bool ovf, bool signed)
+ {
+ VariantBase v1, v2;
+ var org_v2 = PopVariant();
+ var org_v1 = PopVariant();
+ var tc = CommonType(org_v1, org_v2, out v1, out v2, signed);
+ VariantBase ret;
+ switch (tc)
+ {
+ case VariantBase.Vtc.Tc9Uint:
+ uint uv1 = ((UintVariant)v1).GetValue(), uv2 = ((UintVariant)v2).GetValue();
+ var uvret = new UintVariant();
+ ret = uvret;
+ if (ovf)
+ {
+ uint uiv;
+ checked
+ {
+ uiv = uv1 - uv2;
+ }
+ uvret.SetValue(uiv);
+ }
+ else
+ {
+ uvret.SetValue(uv1 - uv2);
+ }
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ int iv1 = ((IntVariant)v1).GetValue(), iv2 = ((IntVariant)v2).GetValue();
+ var ivret = new IntVariant();
+ ret = ivret;
+ if (ovf)
+ {
+ checked
+ {
+ ivret.SetValue(iv1 - iv2);
+ }
+ }
+ else
+ {
+ ivret.SetValue(iv1 - iv2);
+ }
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ double dv1 = ((DoubleVariant)v1).GetValue(), dv2 = ((DoubleVariant)v2).GetValue();
+ var dvret = new DoubleVariant();
+ ret = dvret;
+ dvret.SetValue(dv1 - dv2);
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ float fv1 = ((FloatVariant)v1).GetValue(), fv2 = ((FloatVariant)v2).GetValue();
+ var fvret = new FloatVariant();
+ ret = fvret;
+ fvret.SetValue(fv1 - fv2);
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ long lv1 = ((LongVariant)v1).GetValue(), lv2 = ((LongVariant)v2).GetValue();
+ var lvret = new LongVariant();
+ ret = lvret;
+ if (ovf)
+ {
+ checked
+ {
+ lvret.SetValue(lv1 - lv2);
+ }
+ }
+ else
+ {
+ lvret.SetValue(lv1 - lv2);
+ }
+ break;
+ case VariantBase.Vtc.Tc7Ulong:
+ ulong ulv1 = ((UlongVariant)v1).GetValue(), ulv2 = ((UlongVariant)v2).GetValue();
+ var ulvret = new UlongVariant();
+ ret = ulvret;
+ if (ovf)
+ {
+ ulong ulv;
+ checked
+ {
+ ulv = ulv1 - ulv2;
+ }
+ ulvret.SetValue(ulv);
+ }
+ else
+ {
+ ulvret.SetValue(ulv1 - ulv2);
+ }
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(IntPtr), new[] { typeof(object), typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_1);
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(signed ? (ovf ? OpCodes.Sub_Ovf : OpCodes.Sub) : OpCodes.Sub_Ovf_Un);
+ gen.Emit(OpCodes.Ret);
+ ret = new IntPtrVariant();
+ ((IntPtrVariant)ret).SetValue(((IntPtr)dyn.Invoke(null, new[] { org_v1.GetValueAbstract(), org_v2.GetValueAbstract() })));
+ break;
+ }
+ return ret;
+ }
+
+ // Token: 0x0600026B RID: 619 RVA: 0x00010F9C File Offset: 0x0000F19C
+ private void Sub_ovf_un_(VariantBase dummy) // \u0005\u2006\u2000
+ {
+ PushVariant(Sub(true, false));
+ }
+
+ // Token: 0x060001A8 RID: 424 RVA: 0x00008F7C File Offset: 0x0000717C
+ private void Sub_ovf_(VariantBase dummy) // \u0005\u2008
+ {
+ PushVariant(Sub(true, true));
+ }
+
+ // Token: 0x0600021C RID: 540 RVA: 0x0000C84C File Offset: 0x0000AA4C
+ private void Sub_(VariantBase dummy) // \u0006\u200A
+ {
+ PushVariant(Sub(false, true));
+ }
+
+ // Token: 0x06000271 RID: 625 RVA: 0x00011144 File Offset: 0x0000F344
+ private static VariantBase MulLong(VariantBase v1, VariantBase v2, bool bChecked, bool bUnsigned) // \u0003
+ {
+ var lvret = new LongVariant();
+ if (!bUnsigned)
+ {
+ var l1 = ((LongVariant)v1).GetValue();
+ var l2 = ((LongVariant)v2).GetValue();
+ long lret;
+ if (bChecked)
+ {
+ lret = checked(l1 * l2);
+ }
+ else
+ {
+ lret = l1 * l2;
+ }
+ lvret.SetValue(lret);
+ return lvret;
+ }
+ var u1 = (ulong)((LongVariant)v1).GetValue();
+ var u2 = (ulong)((LongVariant)v2).GetValue();
+ ulong uret;
+ if (bChecked)
+ {
+ uret = checked(u1 * u2);
+ }
+ else
+ {
+ uret = u1 * u2;
+ }
+ lvret.SetValue((long)uret);
+ return lvret;
+ }
+
+ private VariantBase Mul(bool ovf, bool signed)
+ {
+ VariantBase v1, v2;
+ var org_v2 = PopVariant();
+ var org_v1 = PopVariant();
+ var tc = CommonType(org_v1, org_v2, out v1, out v2, signed);
+ VariantBase ret;
+ switch (tc)
+ {
+ case VariantBase.Vtc.Tc9Uint:
+ uint uv1 = ((UintVariant)v1).GetValue(), uv2 = ((UintVariant)v2).GetValue();
+ var uvret = new UintVariant();
+ ret = uvret;
+ if (ovf)
+ {
+ uint uiv;
+ checked
+ {
+ uiv = uv1 * uv2;
+ }
+ uvret.SetValue(uiv);
+ }
+ else
+ {
+ uvret.SetValue(uv1 * uv2);
+ }
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ int iv1 = ((IntVariant)v1).GetValue(), iv2 = ((IntVariant)v2).GetValue();
+ var ivret = new IntVariant();
+ ret = ivret;
+ if (ovf)
+ {
+ checked
+ {
+ ivret.SetValue(iv1 * iv2);
+ }
+ }
+ else
+ {
+ ivret.SetValue(iv1 * iv2);
+ }
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ double dv1 = ((DoubleVariant)v1).GetValue(), dv2 = ((DoubleVariant)v2).GetValue();
+ var dvret = new DoubleVariant();
+ ret = dvret;
+ dvret.SetValue(dv1 * dv2);
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ float fv1 = ((FloatVariant)v1).GetValue(), fv2 = ((FloatVariant)v2).GetValue();
+ var fvret = new FloatVariant();
+ ret = fvret;
+ fvret.SetValue(fv1 * fv2);
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ long lv1 = ((LongVariant)v1).GetValue(), lv2 = ((LongVariant)v2).GetValue();
+ var lvret = new LongVariant();
+ ret = lvret;
+ if (ovf)
+ {
+ checked
+ {
+ lvret.SetValue(lv1 * lv2);
+ }
+ }
+ else
+ {
+ lvret.SetValue(lv1 * lv2);
+ }
+ break;
+ case VariantBase.Vtc.Tc7Ulong:
+ ulong ulv1 = ((UlongVariant)v1).GetValue(), ulv2 = ((UlongVariant)v2).GetValue();
+ var ulvret = new UlongVariant();
+ ret = ulvret;
+ if (ovf)
+ {
+ ulong ulv;
+ checked
+ {
+ ulv = ulv1 * ulv2;
+ }
+ ulvret.SetValue(ulv);
+ }
+ else
+ {
+ ulvret.SetValue(ulv1 * ulv2);
+ }
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(IntPtr), new[] { typeof(object), typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_1);
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(signed ? (ovf ? OpCodes.Mul_Ovf : OpCodes.Mul) : OpCodes.Mul_Ovf_Un);
+ gen.Emit(OpCodes.Ret);
+ ret = new IntPtrVariant();
+ ((IntPtrVariant)ret).SetValue(((IntPtr)dyn.Invoke(null, new[] { org_v1.GetValueAbstract(), org_v2.GetValueAbstract() })));
+ break;
+ }
+ return ret;
+ }
+
+ // Token: 0x06000181 RID: 385 RVA: 0x00007F88 File Offset: 0x00006188
+ private void Mul_ovf_un_(VariantBase dummy) // \u0005\u2007
+ {
+ PushVariant(Mul(true, false));
+ }
+
+ // Token: 0x060001E1 RID: 481 RVA: 0x0000ABDC File Offset: 0x00008DDC
+ private void Mul_(VariantBase dummy) // \u0006\u2001\u2001
+ {
+ PushVariant(Mul(false, true));
+ }
+
+ // Token: 0x060001A0 RID: 416 RVA: 0x00008C98 File Offset: 0x00006E98
+ private void Mul_ovf_(VariantBase dummy) // \u0008\u2000\u2000
+ {
+ PushVariant(Mul(true, true));
+ }
+
+ VariantBase.Vtc CommonType(VariantBase org_v1, VariantBase org_v2, out VariantBase v1, out VariantBase v2, bool signed)
+ {
+ v1 = org_v1.Clone();
+ v2 = org_v2.Clone();
+ var tc1 = UnderlyingTypeCode(ref v1);
+ var tc2 = UnderlyingTypeCode(ref v2);
+ if (tc1 == VariantBase.Vtc.Tc18Object || tc2 == VariantBase.Vtc.Tc18Object)
+ return VariantBase.Vtc.Tc18Object;
+ VariantBase.Vtc ret = tc1;
+ if (!signed)
+ {
+ v1 = AsUnsigned(v1);
+ v2 = AsUnsigned(v2);
+ }
+ if(tc1 != tc2) switch (tc1)
+ {
+ case VariantBase.Vtc.Tc19Int:
+ switch (tc2)
+ {
+ case VariantBase.Vtc.Tc24Long:
+ {
+ ret = tc2;
+ var new_v1 = signed ? (VariantBase)new LongVariant() : new UlongVariant();
+ new_v1.CopyFrom(v1);
+ v1 = new_v1;
+ }
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ {
+ ret = tc2;
+ var new_v1 = new DoubleVariant();
+ new_v1.CopyFrom(v1);
+ v1 = new_v1;
+ }
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ {
+ ret = tc2;
+ var new_v1 = new FloatVariant();
+ new_v1.CopyFrom(v1);
+ v1 = new_v1;
+ }
+ break;
+ }
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ switch (tc2)
+ {
+ case VariantBase.Vtc.Tc19Int:
+ {
+ var new_v2 = signed ? (VariantBase)new LongVariant() : new UlongVariant();
+ new_v2.CopyFrom(v2);
+ v2 = new_v2;
+ }
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ {
+ ret = tc2;
+ var new_v1 = new DoubleVariant();
+ new_v1.CopyFrom(v1);
+ v1 = new_v1;
+ }
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ {
+ ret = tc2;
+ var new_v1 = new FloatVariant();
+ new_v1.CopyFrom(v1);
+ v1 = new_v1;
+ }
+ break;
+ }
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ switch (tc2)
+ {
+ case VariantBase.Vtc.Tc19Int:
+ case VariantBase.Vtc.Tc24Long:
+ case VariantBase.Vtc.Tc8Float:
+ {
+ var new_v2 = new DoubleVariant();
+ new_v2.CopyFrom(v2);
+ v2 = new_v2;
+ }
+ break;
+ }
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ switch (tc2)
+ {
+ case VariantBase.Vtc.Tc19Int:
+ case VariantBase.Vtc.Tc24Long:
+ {
+ var new_v2 = new FloatVariant();
+ new_v2.CopyFrom(v2);
+ v2 = new_v2;
+ }
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ {
+ ret = tc2;
+ var new_v1 = new DoubleVariant();
+ new_v1.CopyFrom(v1);
+ v1 = new_v1;
+ }
+ break;
+ }
+ break;
+ }
+ if(!signed) switch (ret)
+ {
+ case VariantBase.Vtc.Tc19Int:
+ return VariantBase.Vtc.Tc9Uint;
+ case VariantBase.Vtc.Tc24Long:
+ return VariantBase.Vtc.Tc7Ulong;
+ }
+ return ret;
+ }
+
+ private VariantBase.Vtc UnderlyingTypeCode(ref VariantBase v)
+ {
+ var ret = v.GetTypeCode();
+ if (ret == VariantBase.Vtc.Tc5Enum)
+ {
+ v = VariantBase.SignedVariantFromEnum((EnumVariant) v);
+ ret = Marshal.SizeOf(v.GetValueAbstract()) == 4 ? VariantBase.Vtc.Tc19Int : VariantBase.Vtc.Tc24Long;
+ }
+ return ret;
+ }
+
+ private VariantBase AsUnsigned(VariantBase v)
+ {
+ var tc = v.GetTypeCode();
+ var ret = v;
+ switch (tc)
+ {
+ case VariantBase.Vtc.Tc19Int:
+ ret = new UintVariant();
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ ret = new UlongVariant();
+ break;
+ }
+ ret.CopyFrom(v);
+ return ret;
+ }
+
+ private VariantBase Add(bool ovf, bool signed)
+ {
+ VariantBase v1, v2;
+ var org_v2 = PopVariant();
+ var org_v1 = PopVariant();
+ var tc = CommonType(org_v1, org_v2, out v1, out v2, signed);
+ VariantBase ret;
+ switch (tc)
+ {
+ case VariantBase.Vtc.Tc9Uint:
+ uint uv1 = ((UintVariant)v1).GetValue(), uv2 = ((UintVariant)v2).GetValue();
+ var uvret = new UintVariant();
+ ret = uvret;
+ if (ovf)
+ {
+ uint uiv;
+ checked
+ {
+ uiv = uv1 + uv2;
+ }
+ uvret.SetValue(uiv);
+ }
+ else
+ {
+ uvret.SetValue(uv1 + uv2);
+ }
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ int iv1 = ((IntVariant)v1).GetValue(), iv2 = ((IntVariant)v2).GetValue();
+ var ivret = new IntVariant();
+ ret = ivret;
+ if (ovf)
+ {
+ checked
+ {
+ ivret.SetValue(iv1 + iv2);
+ }
+ }
+ else
+ {
+ ivret.SetValue(iv1 + iv2);
+ }
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ double dv1 = ((DoubleVariant)v1).GetValue(), dv2 = ((DoubleVariant)v2).GetValue();
+ var dvret = new DoubleVariant();
+ ret = dvret;
+ dvret.SetValue(dv1 + dv2);
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ float fv1 = ((FloatVariant)v1).GetValue(), fv2 = ((FloatVariant)v2).GetValue();
+ var fvret = new FloatVariant();
+ ret = fvret;
+ fvret.SetValue(fv1 + fv2);
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ long lv1 = ((LongVariant)v1).GetValue(), lv2 = ((LongVariant)v2).GetValue();
+ var lvret = new LongVariant();
+ ret = lvret;
+ if (ovf)
+ {
+ checked
+ {
+ lvret.SetValue(lv1 + lv2);
+ }
+ }
+ else
+ {
+ lvret.SetValue(lv1 + lv2);
+ }
+ break;
+ case VariantBase.Vtc.Tc7Ulong:
+ ulong ulv1 = ((UlongVariant)v1).GetValue(), ulv2 = ((UlongVariant)v2).GetValue();
+ var ulvret = new UlongVariant();
+ ret = ulvret;
+ if (ovf)
+ {
+ ulong ulv;
+ checked
+ {
+ ulv = ulv1 + ulv2;
+ }
+ ulvret.SetValue(ulv);
+ }
+ else
+ {
+ ulvret.SetValue(ulv1 + ulv2);
+ }
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(IntPtr), new[] { typeof(object), typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_1);
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(signed ? (ovf ? OpCodes.Add_Ovf : OpCodes.Add) : OpCodes.Add_Ovf_Un);
+ gen.Emit(OpCodes.Ret);
+ ret = new IntPtrVariant();
+ ((IntPtrVariant)ret).SetValue(((IntPtr)dyn.Invoke(null, new[] { org_v1.GetValueAbstract(), org_v2.GetValueAbstract() })));
+ break;
+ }
+ return ret;
+ }
+
+ // Token: 0x0600022D RID: 557 RVA: 0x0000F880 File Offset: 0x0000DA80
+ private void Add_ovf_(VariantBase dummy) // \u0008\u2001
+ {
+ PushVariant(Add(true, true));
+ }
+
+ // Token: 0x06000238 RID: 568 RVA: 0x0000F998 File Offset: 0x0000DB98
+ private void Add_(VariantBase dummy) // \u0002\u2004
+ {
+ PushVariant(Add(false, true));
+ }
+
+ // Token: 0x0600029B RID: 667 RVA: 0x000126A0 File Offset: 0x000108A0
+ private void Add_ovf_un_(VariantBase dummy) // \u0002\u2004\u2000
+ {
+ PushVariant(Add(true, false));
+ }
+
+ private VariantBase Or(VariantBase org_v1, VariantBase org_v2)
+ {
+ VariantBase v1, v2;
+ var tc = CommonType(org_v1, org_v2, out v1, out v2, true);
+ VariantBase ret;
+ switch (tc)
+ {
+ case VariantBase.Vtc.Tc9Uint:
+ uint uv1 = ((UintVariant)v1).GetValue(), uv2 = ((UintVariant)v2).GetValue();
+ var uvret = new UintVariant();
+ ret = uvret;
+ uvret.SetValue(uv1 | uv2);
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ int iv1 = ((IntVariant)v1).GetValue(), iv2 = ((IntVariant)v2).GetValue();
+ var ivret = new IntVariant();
+ ret = ivret;
+ ivret.SetValue(iv1 | iv2);
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ {
+ /*double dv1 = ((DoubleVariant)v1).GetValue(), dv2 = ((DoubleVariant)v2).GetValue(); // естественный алгоритм
+ long lv1 = (dv1 < 0) ? (long)dv1 : (long)(ulong)dv1;
+ long lv2 = (dv2 < 0) ? (long)dv2 : (long)(ulong)dv2;
+ var dvret = new DoubleVariant();
+ ret = dvret;
+ var l64 = (ulong) lv1 | (ulong) lv2;
+ if (l64 >> 32 == UInt32.MaxValue) l64 &= UInt32.MaxValue;
+ dvret.SetValue(l64);*/
+ var dvret = new DoubleVariant();
+ ret = dvret;
+ dvret.SetValue((4 == IntPtr.Size) ? Double.NaN : (double)0); // иногда у фреймворка бывает мусор, но чаще эти значения...
+ }
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ {
+ /*float fv1 = ((FloatVariant) v1).GetValue(), fv2 = ((FloatVariant) v2).GetValue(); // естественный алгоритм
+ long lv1 = (fv1 < 0) ? (long)fv1 : (long)(ulong)fv1;
+ long lv2 = (fv2 < 0) ? (long)fv2 : (long)(ulong)fv2;
+ var fvret = new FloatVariant();
+ ret = fvret;
+ var l64 = (ulong)lv1 | (ulong)lv2;
+ if (l64 >> 32 == UInt32.MaxValue) l64 &= UInt32.MaxValue;
+ fvret.SetValue(l64);*/
+ var fvret = new FloatVariant();
+ ret = fvret;
+ fvret.SetValue((4 == IntPtr.Size) ? float.NaN : (float)0.0); // иногда у фреймворка бывает мусор, но чаще эти значения...
+ }
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ {
+ long lv1 = ((LongVariant)v1).GetValue(), lv2 = ((LongVariant)v2).GetValue();
+ var lvret = new LongVariant();
+ ret = lvret;
+ lvret.SetValue(lv1 | lv2);
+ }
+ break;
+ case VariantBase.Vtc.Tc7Ulong:
+ ulong ulv1 = ((UlongVariant)v1).GetValue(), ulv2 = ((UlongVariant)v2).GetValue();
+ var ulvret = new UlongVariant();
+ ret = ulvret;
+ ulvret.SetValue(ulv1 | ulv2);
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(IntPtr), new[] { typeof(object), typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_1);
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(OpCodes.Or);
+ gen.Emit(OpCodes.Ret);
+ ret = new IntPtrVariant();
+ ((IntPtrVariant)ret).SetValue(((IntPtr)dyn.Invoke(null, new[] { org_v1.GetValueAbstract(), org_v2.GetValueAbstract() })));
+ break;
+ }
+ return ret;
+ }
+
+ // Token: 0x0600020F RID: 527 RVA: 0x0000C598 File Offset: 0x0000A798
+ private void Or_(VariantBase dummy) // \u0006\u2002\u2000
+ {
+ var v2 = PopVariant();
+ var v1 = PopVariant();
+ PushVariant(Or(v1, v2));
+ }
+
+ // Token: 0x060001D8 RID: 472 RVA: 0x0000A718 File Offset: 0x00008918
+ private void Throw_(VariantBase dummy) // \u0006\u2005\u2000
+ {
+ ThrowStoreCrossDomain(PopVariant().GetValueAbstract());
+ }
+
+ private VariantBase Rem(bool signed)
+ {
+ VariantBase v1, v2;
+ var org_v2 = PopVariant();
+ var org_v1 = PopVariant();
+ VariantBase ret;
+ var tc = CommonType(org_v1, org_v2, out v1, out v2, signed);
+ if (IsFloating(org_v1) && org_v1.GetType() == org_v2.GetType() && !signed)
+ {
+ if (IntPtr.Size == 8) throw new InvalidProgramException();
+ if (tc == VariantBase.Vtc.Tc21Double)
+ {
+ ret = new DoubleVariant();
+ ret.SetValueAbstract(double.NaN);
+ }
+ else /*if (tc == VariantBase.Vtc.Tc8Float)*/
+ {
+ ret = new FloatVariant();
+ ret.SetValueAbstract(float.NaN);
+ }
+ }
+ else switch (tc)
+ {
+ case VariantBase.Vtc.Tc9Uint:
+ uint uv1 = ((UintVariant)v1).GetValue(), uv2 = ((UintVariant)v2).GetValue();
+ var uvret = new UintVariant();
+ ret = uvret;
+ uvret.SetValue(uv1 % uv2);
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ int iv1 = ((IntVariant)v1).GetValue(), iv2 = ((IntVariant)v2).GetValue();
+ var ivret = new IntVariant();
+ ret = ivret;
+ ivret.SetValue(iv1 % iv2);
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ double dv1 = ((DoubleVariant)v1).GetValue(), dv2 = ((DoubleVariant)v2).GetValue();
+ var dvret = new DoubleVariant();
+ ret = dvret;
+ if (Math.Abs(dv2) < double.Epsilon && org_v1.GetType() != org_v2.GetType()) throw new DivideByZeroException();
+ dvret.SetValue(dv1 % dv2);
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ float fv1 = ((FloatVariant)v1).GetValue(), fv2 = ((FloatVariant)v2).GetValue();
+ var fvret = new FloatVariant();
+ ret = fvret;
+ if (Math.Abs(fv2) < float.Epsilon && org_v1.GetType() != org_v2.GetType()) throw new DivideByZeroException();
+ fvret.SetValue(fv1 % fv2);
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ long lv1 = ((LongVariant)v1).GetValue(), lv2 = ((LongVariant)v2).GetValue();
+ var lvret = new LongVariant();
+ ret = lvret;
+ lvret.SetValue(lv1 % lv2);
+ break;
+ case VariantBase.Vtc.Tc7Ulong:
+ ulong ulv1 = ((UlongVariant)v1).GetValue(), ulv2 = ((UlongVariant)v2).GetValue();
+ var ulvret = new UlongVariant();
+ ret = ulvret;
+ ulvret.SetValue(ulv1 % ulv2);
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(IntPtr), new[] { typeof(object), typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_1);
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(signed ? OpCodes.Rem : OpCodes.Rem_Un);
+ gen.Emit(OpCodes.Ret);
+ ret = new IntPtrVariant();
+ ((IntPtrVariant)ret).SetValue(((IntPtr)dyn.Invoke(null, new[] { org_v1.GetValueAbstract(), org_v2.GetValueAbstract() })));
+ break;
+ }
+ return ret;
+ }
+
+ // Token: 0x060001CC RID: 460 RVA: 0x00009EAC File Offset: 0x000080AC
+ private void Rem_(VariantBase dummy) // \u0006\u2000\u2001
+ {
+ PushVariant(Rem(true));
+ }
+
+ // Token: 0x060001FA RID: 506 RVA: 0x0000BC3C File Offset: 0x00009E3C
+ private void Rem_un_(VariantBase dummy) // \u0006\u200B\u2000
+ {
+ PushVariant(Rem(false));
+ }
+
+ // Token: 0x06000254 RID: 596 RVA: 0x00010824 File Offset: 0x0000EA24
+ private static VariantBase Neg(VariantBase v) // \u0002
+ {
+ if (v.GetTypeCode() == VariantBase.Vtc.Tc19Int)
+ {
+ var i = ((IntVariant)v).GetValue();
+ var ivret = new IntVariant();
+ ivret.SetValue(-i);
+ return ivret;
+ }
+ if (v.GetTypeCode() == VariantBase.Vtc.Tc24Long)
+ {
+ var l = ((LongVariant)v).GetValue();
+ var lvret = new LongVariant();
+ lvret.SetValue(-l);
+ return lvret;
+ }
+ if (v.GetTypeCode() == VariantBase.Vtc.Tc21Double)
+ {
+ var dvret = new DoubleVariant();
+ dvret.SetValue(-((DoubleVariant)v).GetValue());
+ return dvret;
+ }
+ if (v.GetTypeCode() != VariantBase.Vtc.Tc5Enum)
+ {
+ throw new InvalidOperationException();
+ }
+ var underlyingType = Enum.GetUnderlyingType(v.GetValueAbstract().GetType());
+ if (underlyingType == typeof(long) || underlyingType == typeof(ulong))
+ {
+ var lvret = new LongVariant();
+ lvret.SetValue(Convert.ToInt64(v.GetValueAbstract()));
+ return Neg(lvret);
+ }
+ var ivret2 = new IntVariant();
+ ivret2.SetValue(Convert.ToInt32(v.GetValueAbstract()));
+ return Neg(ivret2);
+ }
+
+ // Token: 0x060001F8 RID: 504 RVA: 0x0000BA00 File Offset: 0x00009C00
+ private void Neg_(VariantBase dummy) // \u0006\u2007
+ {
+ var v = PopVariant();
+ PushVariant(Neg(v));
+ }
+
+ // Token: 0x06000242 RID: 578 RVA: 0x0000FE38 File Offset: 0x0000E038
+ private static VariantBase DivLong(VariantBase v1, VariantBase v2, bool bUnsigned) // \u0003
+ {
+ var lvret = new LongVariant();
+ if (!bUnsigned)
+ {
+ var l1 = ((LongVariant)v1).GetValue();
+ var l2 = ((LongVariant)v2).GetValue();
+ lvret.SetValue(l1 / l2);
+ return lvret;
+ }
+ var u1 = (ulong)((LongVariant)v1).GetValue();
+ var u2 = (ulong)((LongVariant)v2).GetValue();
+ lvret.SetValue((long)(u1 / u2));
+ return lvret;
+ }
+
+ private VariantBase Div(bool signed)
+ {
+ VariantBase v1, v2;
+ var org_v2 = PopVariant();
+ var org_v1 = PopVariant();
+ VariantBase ret;
+ var tc = CommonType(org_v1, org_v2, out v1, out v2, signed);
+ if (IsFloating(org_v1) && org_v1.GetType() == org_v2.GetType() && !signed)
+ {
+ if (IntPtr.Size == 8) throw new InvalidProgramException();
+ if(tc == VariantBase.Vtc.Tc21Double)
+ {
+ ret = new DoubleVariant();
+ ret.SetValueAbstract(double.NaN);
+ } else /*if (tc == VariantBase.Vtc.Tc8Float)*/
+ {
+ ret = new FloatVariant();
+ ret.SetValueAbstract(float.NaN);
+ }
+ } else switch (tc)
+ {
+ case VariantBase.Vtc.Tc9Uint:
+ uint uv1 = ((UintVariant)v1).GetValue(), uv2 = ((UintVariant)v2).GetValue();
+ var uvret = new UintVariant();
+ ret = uvret;
+ uvret.SetValue(uv1 / uv2);
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ int iv1 = ((IntVariant)v1).GetValue(), iv2 = ((IntVariant)v2).GetValue();
+ var ivret = new IntVariant();
+ ret = ivret;
+ ivret.SetValue(iv1 / iv2);
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ double dv1 = ((DoubleVariant)v1).GetValue(), dv2 = ((DoubleVariant)v2).GetValue();
+ var dvret = new DoubleVariant();
+ ret = dvret;
+ if(Math.Abs(dv2) < double.Epsilon && org_v1.GetType() != org_v2.GetType()) throw new DivideByZeroException();
+ dvret.SetValue(dv1 / dv2);
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ float fv1 = ((FloatVariant)v1).GetValue(), fv2 = ((FloatVariant)v2).GetValue();
+ var fvret = new FloatVariant();
+ ret = fvret;
+ if (Math.Abs(fv2) < float.Epsilon && org_v1.GetType() != org_v2.GetType()) throw new DivideByZeroException();
+ fvret.SetValue(fv1 / fv2);
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ long lv1 = ((LongVariant)v1).GetValue(), lv2 = ((LongVariant)v2).GetValue();
+ var lvret = new LongVariant();
+ ret = lvret;
+ lvret.SetValue(lv1 / lv2);
+ break;
+ case VariantBase.Vtc.Tc7Ulong:
+ ulong ulv1 = ((UlongVariant)v1).GetValue(), ulv2 = ((UlongVariant)v2).GetValue();
+ var ulvret = new UlongVariant();
+ ret = ulvret;
+ ulvret.SetValue(ulv1 / ulv2);
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(IntPtr), new[] { typeof(object), typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_1);
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(signed ? OpCodes.Div : OpCodes.Div_Un);
+ gen.Emit(OpCodes.Ret);
+ ret = new IntPtrVariant();
+ ((IntPtrVariant)ret).SetValue(((IntPtr)dyn.Invoke(null, new[] { org_v1.GetValueAbstract(), org_v2.GetValueAbstract() })));
+ break;
+ }
+ return ret;
+ }
+
+ // Token: 0x060001F0 RID: 496 RVA: 0x0000B664 File Offset: 0x00009864
+ private void Div_(VariantBase dummy) // \u0002\u2009
+ {
+ PushVariant(Div(true));
+ }
+
+ // Token: 0x0600017C RID: 380 RVA: 0x00007DF4 File Offset: 0x00005FF4
+ private void Div_un_(VariantBase dummy) // \u000E\u200B
+ {
+ PushVariant(Div(false));
+ }
+
+ // Token: 0x0600026D RID: 621 RVA: 0x00010FF4 File Offset: 0x0000F1F4
+ private static void EmitLdc(ILGenerator gen, int val) // \u0002
+ {
+ switch (val)
+ {
+ case -1:
+ gen.Emit(OpCodes.Ldc_I4_M1);
+ return;
+ case 0:
+ gen.Emit(OpCodes.Ldc_I4_0);
+ return;
+ case 1:
+ gen.Emit(OpCodes.Ldc_I4_1);
+ return;
+ case 2:
+ gen.Emit(OpCodes.Ldc_I4_2);
+ return;
+ case 3:
+ gen.Emit(OpCodes.Ldc_I4_3);
+ return;
+ case 4:
+ gen.Emit(OpCodes.Ldc_I4_4);
+ return;
+ case 5:
+ gen.Emit(OpCodes.Ldc_I4_5);
+ return;
+ case 6:
+ gen.Emit(OpCodes.Ldc_I4_6);
+ return;
+ case 7:
+ gen.Emit(OpCodes.Ldc_I4_7);
+ return;
+ case 8:
+ gen.Emit(OpCodes.Ldc_I4_8);
+ return;
+ default:
+ if (val > -129 && val < 128)
+ {
+ gen.Emit(OpCodes.Ldc_I4_S, (sbyte)val);
+ return;
+ }
+ gen.Emit(OpCodes.Ldc_I4, val);
+ return;
+ }
+ }
+
+ // Token: 0x06000264 RID: 612 RVA: 0x00010C28 File Offset: 0x0000EE28
+ private static void EnsureClass(ILGenerator gen, Type t) // \u0003
+ {
+ if (t == SimpleTypeHelper.ObjectType)
+ {
+ return;
+ }
+ gen.Emit(OpCodes.Castclass, t);
+ }
+
+ // Token: 0x06000277 RID: 631 RVA: 0x0001180C File Offset: 0x0000FA0C
+ private static void EnsureType(ILGenerator gen, Type t) // \u0005
+ {
+ if (t.IsValueType || ElementedTypeHelper.TryGoToElementType(t).IsGenericParameter)
+ {
+ gen.Emit(OpCodes.Unbox_Any, t);
+ return;
+ }
+ EnsureClass(gen, t);
+ }
+
+ // Token: 0x06000217 RID: 535 RVA: 0x0000C7EC File Offset: 0x0000A9EC
+ private static void EnsureBoxed(ILGenerator gen, Type t) // \u0002
+ {
+ if (t.IsValueType || ElementedTypeHelper.TryGoToElementType(t).IsGenericParameter)
+ {
+ gen.Emit(OpCodes.Box, t);
+ }
+ }
+
+ // Token: 0x0600023E RID: 574 RVA: 0x0000FA54 File Offset: 0x0000DC54
+ private DynamicExecutor DynamicFor(MethodBase mb, bool mayVirtual) // \u0002
+ {
+ DynamicMethod dynamicMethod; /*= null;
+ if (_alwaysFalse && (!mb.IsConstructor || !typeof(Delegate).IsAssignableFrom(mb.DeclaringType)))
+ {
+ dynamicMethod = new DynamicMethod(string.Empty, SimpleTypeHelper.ObjectType, new Type[]
+ {
+ SimpleTypeHelper.ObjectType,
+ ObjectArrayType
+ }, true);
+ }
+ if (dynamicMethod == null)*/
+ {
+ dynamicMethod = new DynamicMethod(string.Empty, SimpleTypeHelper.ObjectType, new[]
+ {
+ SimpleTypeHelper.ObjectType,
+ ObjectArrayType
+ }, typeof(VmExecutor).Module, true);
+ }
+ var iLGenerator = dynamicMethod.GetILGenerator();
+ var parameters = mb.GetParameters();
+ var array = new Type[parameters.Length];
+ var flag = false;
+ for (var i = 0; i < parameters.Length; i++)
+ {
+ var type = parameters[i].ParameterType;
+ if (type.IsByRef)
+ {
+ flag = true;
+ type = type.GetElementType();
+ }
+ array[i] = type;
+ }
+ var array2 = new LocalBuilder[array.Length];
+ if (array2.Length != 0)
+ {
+ dynamicMethod.InitLocals = true;
+ }
+ for (var j = 0; j < array.Length; j++)
+ {
+ array2[j] = iLGenerator.DeclareLocal(array[j]);
+ }
+ for (var k = 0; k < array.Length; k++)
+ {
+ iLGenerator.Emit(OpCodes.Ldarg_1);
+ EmitLdc(iLGenerator, k);
+ iLGenerator.Emit(OpCodes.Ldelem_Ref);
+ EnsureType(iLGenerator, array[k]);
+ iLGenerator.Emit(OpCodes.Stloc, array2[k]);
+ }
+ if (flag)
+ {
+ iLGenerator.BeginExceptionBlock();
+ }
+ if (!mb.IsStatic && !mb.IsConstructor)
+ {
+ iLGenerator.Emit(OpCodes.Ldarg_0);
+ var declaringType = mb.DeclaringType;
+ if (declaringType.IsValueType)
+ {
+ iLGenerator.Emit(OpCodes.Unbox, declaringType);
+ mayVirtual = false;
+ }
+ else
+ {
+ EnsureClass(iLGenerator, declaringType);
+ }
+ }
+ for (var l = 0; l < array.Length; l++)
+ {
+ iLGenerator.Emit(parameters[l].ParameterType.IsByRef ? OpCodes.Ldloca_S : OpCodes.Ldloc, array2[l]);
+ }
+ if (mb.IsConstructor)
+ {
+ iLGenerator.Emit(OpCodes.Newobj, (ConstructorInfo)mb);
+ EnsureBoxed(iLGenerator, mb.DeclaringType);
+ }
+ else
+ {
+ var methodInfo = (MethodInfo)mb;
+ if (!mayVirtual || mb.IsStatic)
+ {
+ iLGenerator.EmitCall(OpCodes.Call, methodInfo, null);
+ }
+ else
+ {
+ iLGenerator.EmitCall(OpCodes.Callvirt, methodInfo, null);
+ }
+ if (methodInfo.ReturnType == VoidType)
+ {
+ iLGenerator.Emit(OpCodes.Ldnull);
+ }
+ else
+ {
+ EnsureBoxed(iLGenerator, methodInfo.ReturnType);
+ }
+ }
+ if (flag)
+ {
+ var local = iLGenerator.DeclareLocal(SimpleTypeHelper.ObjectType);
+ iLGenerator.Emit(OpCodes.Stloc, local);
+ iLGenerator.BeginFinallyBlock();
+ for (var m = 0; m < array.Length; m++)
+ {
+ if (parameters[m].ParameterType.IsByRef)
+ {
+ iLGenerator.Emit(OpCodes.Ldarg_1);
+ EmitLdc(iLGenerator, m);
+ iLGenerator.Emit(OpCodes.Ldloc, array2[m]);
+ if (array2[m].LocalType.IsValueType || ElementedTypeHelper.TryGoToElementType(array2[m].LocalType).IsGenericParameter)
+ {
+ iLGenerator.Emit(OpCodes.Box, array2[m].LocalType);
+ }
+ iLGenerator.Emit(OpCodes.Stelem_Ref);
+ }
+ }
+ iLGenerator.EndExceptionBlock();
+ iLGenerator.Emit(OpCodes.Ldloc, local);
+ }
+ iLGenerator.Emit(OpCodes.Ret);
+ return (DynamicExecutor)dynamicMethod.CreateDelegate(typeof(DynamicExecutor));
+ }
+
+ // Token: 0x06000209 RID: 521 RVA: 0x0000C4D0 File Offset: 0x0000A6D0
+ private static bool HasByRefParameter(MethodBase mb) // \u0002
+ {
+ return mb.GetParameters().Any(t => t.ParameterType.IsByRef);
+ }
+
+ // Token: 0x060001D9 RID: 473 RVA: 0x0000A72C File Offset: 0x0000892C
+ private object Invoke(MethodBase mb, object obj, object[] args) // \u0002
+ {
+ if (mb.IsConstructor)
+ {
+ // ReSharper disable once AssignNullToNotNullAttribute
+ return Activator.CreateInstance(mb.DeclaringType, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, args, null);
+ }
+ return mb.Invoke(obj, args);
+ }
+
+ // Token: 0x06000286 RID: 646 RVA: 0x00011EFC File Offset: 0x000100FC
+ private object InvokeDynamic(MethodBase mb, object obj, object[] args, bool mayVirtual) // \u0002
+ {
+ /*if (!_alwaysTrue)
+ {
+ return Invoke(mb, obj, args);
+ }*/
+ var key = new MethodBaseAndVirtual(mb, mayVirtual);
+ DynamicExecutor executor;
+ lock (_dynamicExecutors)
+ {
+ _dynamicExecutors.TryGetValue(key, out executor);
+ }
+ if (executor == null)
+ {
+ bool needFaster;
+ lock (_mbCallCnt)
+ {
+ int num;
+ _mbCallCnt.TryGetValue(mb, out num);
+ needFaster = num >= 50;
+ if (!needFaster)
+ {
+ _mbCallCnt[mb] = num + 1;
+ }
+ }
+ if (!needFaster && !mayVirtual && obj == null && !mb.IsStatic && !mb.IsConstructor)
+ {
+ needFaster = true;
+ }
+ if (!needFaster && HasByRefParameter(mb))
+ {
+ needFaster = true;
+ }
+ if (!needFaster)
+ {
+ return Invoke(mb, obj, args);
+ }
+ lock (_mbDynamicLock)
+ {
+ while (_mbDynamicLock.ContainsKey(mb))
+ {
+ Monitor.Wait(_mbDynamicLock);
+ }
+ _mbDynamicLock[mb] = null;
+ }
+ try
+ {
+ lock (_dynamicExecutors)
+ {
+ _dynamicExecutors.TryGetValue(key, out executor);
+ }
+ if (executor == null)
+ {
+ executor = DynamicFor(mb, mayVirtual);
+ lock (_dynamicExecutors)
+ {
+ _dynamicExecutors[key] = executor;
+ }
+ }
+ lock (_mbCallCnt)
+ {
+ _mbCallCnt.Remove(mb);
+ }
+ }
+ finally
+ {
+ lock (_mbDynamicLock)
+ {
+ _mbDynamicLock.Remove(mb);
+ Monitor.PulseAll(_mbDynamicLock);
+ }
+ }
+ }
+ return executor(obj, args);
+ }
+
+ // Token: 0x0600028D RID: 653 RVA: 0x000122A4 File Offset: 0x000104A4
+ private VariantBase FetchByAddr(VariantBase addr) // \u0003
+ {
+ if (!addr.IsAddr())
+ {
+ throw new ArgumentException();
+ }
+ var num = addr.GetTypeCode();
+ if (num == VariantBase.Vtc.Tc0VariantBaseHolder)
+ {
+ return ((VariantBaseHolder)addr).GetValue();
+ }
+ if (num != VariantBase.Vtc.Tc4FieldInfo)
+ {
+ switch (num)
+ {
+ case VariantBase.Vtc.Tc20MdArrayValue:
+ case VariantBase.Vtc.Tc22SdArrayValue:
+ {
+ var avv = (ArrayValueVariantBase)addr;
+ return VariantFactory.Convert(avv.GetValue(), avv.GetHeldType());
+ }
+ case VariantBase.Vtc.Tc23LocalsIdxHolder:
+ return _localVariables[((LocalsIdxHolderVariant)addr).GetValue()];
+ }
+ throw new ArgumentOutOfRangeException();
+ }
+ var fiv = (FieldInfoVariant)addr;
+ return VariantFactory.Convert(fiv.GetValue().GetValue(fiv.GetObject()), null);
+ }
+
+ // Token: 0x06000186 RID: 390 RVA: 0x00008150 File Offset: 0x00006350
+ private FieldInfo ResolveField(int id) // \u0002
+ {
+ FieldInfo result;
+ lock (AllMetadataById)
+ {
+ object md;
+ if (AllMetadataById.TryGetValue(id, out md))
+ {
+ result = (FieldInfo)md;
+ }
+ else
+ {
+ var U0003U2008 = ReadToken(id);
+ if (U0003U2008.IsVm == 0)
+ {
+ result = _module.ResolveField(U0003U2008.MetadataToken);
+ }
+ else
+ {
+ var u000Fu2006 = (VmFieldTokenInfo)U0003U2008.VmToken;
+ var expr_70 = GetTypeById(u000Fu2006.Class.MetadataToken);
+ var bindingAttr = BF(u000Fu2006.IsStatic);
+ var field = expr_70.GetField(u000Fu2006.Name, bindingAttr);
+ if (!expr_70.IsGenericType)
+ {
+ AllMetadataById.Add(id, field);
+ }
+ result = field;
+ }
+ }
+ }
+ return result;
+ }
+
+ // Token: 0x06000177 RID: 375 RVA: 0x00007CD8 File Offset: 0x00005ED8
+ private void Ldflda_(VariantBase vFieldId) // \u0003\u2009
+ {
+ var fieldInfo = ResolveField(((IntVariant)vFieldId).GetValue());
+ var reference = PopVariant();
+ var obj = reference.IsAddr() ? FetchByAddr(reference).GetValueAbstract() : reference.GetValueAbstract();
+ var val = new FieldInfoVariant();
+ val.SetValue(fieldInfo);
+ val.SetObject(obj);
+ PushVariant(val);
+ }
+
+ // Token: 0x0600018F RID: 399 RVA: 0x0000840C File Offset: 0x0000660C
+ private void Ldsflda_(VariantBase vFieldId) // \u000E\u2002
+ {
+ var fieldInfo = ResolveField(((IntVariant)vFieldId).GetValue());
+ var val = new FieldInfoVariant();
+ val.SetValue(fieldInfo);
+ PushVariant(val);
+ }
+
+ // Token: 0x0600017D RID: 381 RVA: 0x00007E20 File Offset: 0x00006020
+ private void Ldtoken_(VariantBase vToken) // \u0005\u2002\u2000
+ {
+ var t = ReadToken(((IntVariant)vToken).GetValue());
+ object obj;
+ if (t.IsVm == 0)
+ {
+ obj = ResolveNativeToken(t.MetadataToken);
+ }
+ else
+ {
+ switch (t.VmToken.TokenKind())
+ {
+ case VmTokenInfo.Kind.Class0:
+ obj = GetTypeById(((IntVariant)vToken).GetValue()).TypeHandle;
+ break;
+ case VmTokenInfo.Kind.Field1:
+ obj = ResolveField(((IntVariant)vToken).GetValue()).FieldHandle;
+ break;
+ case VmTokenInfo.Kind.Method2:
+ obj = FindMethodById(((IntVariant)vToken).GetValue()).MethodHandle;
+ break;
+ default:
+ throw new InvalidOperationException();
+ }
+ }
+ var push = new ObjectVariant();
+ push.SetValue(obj);
+ PushVariant(push);
+ }
+
+ // Token: 0x06000206 RID: 518 RVA: 0x0000C1C8 File Offset: 0x0000A3C8
+ private void Ldfld_(VariantBase vFieldId) // \u0005\u2003\u2001
+ {
+ var fieldInfo = ResolveField(((IntVariant)vFieldId).GetValue());
+ var reference = PopVariant();
+ if (reference.IsAddr())
+ {
+ reference = FetchByAddr(reference);
+ }
+ var obj = reference.GetValueAbstract();
+ if (obj == null)
+ {
+ throw new NullReferenceException();
+ }
+ PushVariant(VariantFactory.Convert(fieldInfo.GetValue(obj), fieldInfo.FieldType));
+ }
+
+ // Token: 0x06000225 RID: 549 RVA: 0x0000F2CC File Offset: 0x0000D4CC
+ private void Ldsfld_(VariantBase vFieldId) // \u000F\u2004\u2000
+ {
+ var fieldInfo = ResolveField(((IntVariant)vFieldId).GetValue());
+ PushVariant(VariantFactory.Convert(fieldInfo.GetValue(null), fieldInfo.FieldType));
+ }
+
+ // Token: 0x0600024A RID: 586 RVA: 0x0001034C File Offset: 0x0000E54C
+ private void Newobj_(VariantBase vCtrId) // \u0002\u200A
+ {
+ var num = ((IntVariant)vCtrId).GetValue();
+ var methodBase = FindMethodById(num);
+ var declaringType = methodBase.DeclaringType;
+ var parameters = methodBase.GetParameters();
+ var expr_2A = parameters.Length;
+ var array = new object[expr_2A];
+ var dictionary = new Dictionary<int, VariantBase>();
+ for (var i = expr_2A - 1; i >= 0; i--)
+ {
+ var u000F = PopVariant();
+ if (u000F.IsAddr())
+ {
+ dictionary.Add(i, u000F);
+ u000F = FetchByAddr(u000F);
+ }
+ if (u000F.GetVariantType() != null)
+ {
+ u000F = VariantFactory.Convert(null, u000F.GetVariantType()).CopyFrom(u000F);
+ }
+ var u000F2 = VariantFactory.Convert(null, parameters[i].ParameterType).CopyFrom(u000F);
+ array[i] = u000F2.GetValueAbstract();
+ }
+ object obj;
+ try
+ {
+ obj = InvokeDynamic(methodBase, null, array, false);
+ }
+ catch (TargetInvocationException ex)
+ {
+ var expr_C2 = ex.InnerException ?? ex;
+ SerializeCrossDomain(expr_C2);
+ throw expr_C2;
+ }
+ foreach (var current in dictionary)
+ {
+ AssignByReference(current.Value, VariantFactory.Convert(array[current.Key], null));
+ }
+ PushVariant(VariantFactory.Convert(obj, declaringType));
+ }
+
+ // Token: 0x06000227 RID: 551 RVA: 0x0000F3B4 File Offset: 0x0000D5B4
+ private void AssignByReference(VariantBase refDest, VariantBase val) // \u0002
+ {
+ switch (refDest.GetTypeCode())
+ {
+ case VariantBase.Vtc.Tc0VariantBaseHolder:
+ ((VariantBaseHolder)refDest).GetValue().CopyFrom(val);
+ return;
+ case VariantBase.Vtc.Tc4FieldInfo:
+ var refFieldInfoDest = (FieldInfoVariant)refDest;
+ var fieldInfo = refFieldInfoDest.GetValue();
+ fieldInfo.SetValue(refFieldInfoDest.GetObject(), VariantFactory.Convert(val.GetValueAbstract(), fieldInfo.FieldType).GetValueAbstract());
+ return;
+ case VariantBase.Vtc.Tc20MdArrayValue:
+ case VariantBase.Vtc.Tc22SdArrayValue:
+ var refArrayValueDest = (ArrayValueVariantBase)refDest;
+ refArrayValueDest.SetValue(VariantFactory.Convert(val.GetValueAbstract(), refArrayValueDest.GetHeldType()).GetValueAbstract());
+ return;
+ case VariantBase.Vtc.Tc23LocalsIdxHolder:
+ _localVariables[((LocalsIdxHolderVariant)refDest).GetValue()].CopyFrom(val);
+ return;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ }
+
+ // Token: 0x060001E5 RID: 485 RVA: 0x0000AD10 File Offset: 0x00008F10
+ private void Invoke(MethodBase mb, bool mayVirtual) // \u0002
+ {
+ if (!mayVirtual && IsCompatible(mb))
+ {
+ mb = GenerateDynamicCall(mb, false);
+ }
+ var parameters = mb.GetParameters();
+ var num = parameters.Length;
+ var poppedArgs = new VariantBase[num];
+ var args = new object[num];
+ var wasLocked = default(BoolHolder);
+ try
+ {
+ LockIfInterlocked(ref wasLocked, mb, mayVirtual);
+ for (var i = num - 1; i >= 0; i--)
+ {
+ var u000F = PopVariant();
+ poppedArgs[i] = u000F;
+ if (u000F.IsAddr())
+ {
+ u000F = FetchByAddr(u000F);
+ }
+ if (u000F.GetVariantType() != null)
+ {
+ u000F = VariantFactory.Convert(null, u000F.GetVariantType()).CopyFrom(u000F);
+ }
+ var u000F2 = VariantFactory.Convert(null, parameters[i].ParameterType).CopyFrom(u000F);
+ args[i] = u000F2.GetValueAbstract();
+ }
+ VariantBase u000F3 = null;
+ if (!mb.IsStatic)
+ {
+ u000F3 = PopVariant();
+ if (u000F3?.GetVariantType() != null)
+ {
+ u000F3 = VariantFactory.Convert(null, u000F3.GetVariantType()).CopyFrom(u000F3);
+ }
+ }
+ object obj = null;
+ try
+ {
+ if (mb.IsConstructor)
+ {
+ obj = Activator.CreateInstance(mb.DeclaringType, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, args, null);
+ if (u000F3 != null && !u000F3.IsAddr())
+ {
+ throw new InvalidOperationException();
+ }
+ AssignByReference(u000F3, VariantFactory.Convert(obj, mb.DeclaringType));
+ }
+ else
+ {
+ object poppedThis = null;
+ if (u000F3 != null)
+ {
+ var u000F4 = u000F3;
+ if (u000F3.IsAddr())
+ {
+ u000F4 = FetchByAddr(u000F3);
+ }
+ poppedThis = u000F4.GetValueAbstract();
+ }
+ try
+ {
+ if (!InvokeFilter(mb, poppedThis, ref obj, args))
+ {
+ if (mayVirtual && !mb.IsStatic && poppedThis == null)
+ {
+ throw new NullReferenceException();
+ }
+ if (!AlwaysFalse(mb, poppedThis, poppedArgs, args, mayVirtual, ref obj))
+ {
+ obj = InvokeDynamic(mb, poppedThis, args, mayVirtual);
+ }
+ }
+ if (u000F3 != null && u000F3.IsAddr())
+ {
+ AssignByReference(u000F3, VariantFactory.Convert(poppedThis, mb.DeclaringType));
+ }
+ }
+ catch (TargetInvocationException ex)
+ {
+ var cause = ex.InnerException ?? ex;
+ SerializeCrossDomain(cause);
+ throw cause;
+ }
+ }
+ }
+ finally
+ {
+ for (var j = 0; j < poppedArgs.Length; j++)
+ {
+ var u000F5 = poppedArgs[j];
+ if (u000F5.IsAddr())
+ {
+ var obj3 = args[j];
+ AssignByReference(u000F5, VariantFactory.Convert(obj3, null));
+ }
+ }
+ }
+ var methodInfo = mb as MethodInfo;
+ if (methodInfo != null)
+ {
+ var returnType = methodInfo.ReturnType;
+ if (returnType != VoidType)
+ {
+ PushVariant(VariantFactory.Convert(obj, returnType));
+ }
+ }
+ }
+ finally
+ {
+ UnlockInterlockedIfAny(ref wasLocked);
+ }
+ }
+
+ // Token: 0x060001FD RID: 509 RVA: 0x0000BD88 File Offset: 0x00009F88
+ private void DoJmp(int pos, Type[] methodGenericArgs, Type[] classGenericArgs, bool mayVirtual) // \u0002
+ {
+ _srcVirtualizedStreamReader.BaseStream.Seek(pos, SeekOrigin.Begin);
+ DoNothing(_srcVirtualizedStreamReader);
+ var u0006 = ReadMethodHeader(_srcVirtualizedStreamReader);
+ var num = u0006.ArgsTypeToOutput.Length;
+ var array = new object[num];
+ var array2 = new VariantBase[num];
+ if (_currentClass != null & mayVirtual)
+ {
+ var num2 = u0006.IsStatic() ? 0 : 1;
+ var array3 = new Type[num - num2];
+ for (var i = num - 1; i >= num2; i--)
+ {
+ array3[i] = GetTypeById(u0006.ArgsTypeToOutput[i].TypeId);
+ }
+ var method = _currentClass.GetMethod(u0006.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.GetProperty | BindingFlags.SetProperty, null, array3, null);
+ _currentClass = null;
+ if (method != null)
+ {
+ Invoke(method, true);
+ return;
+ }
+ }
+ for (var j = num - 1; j >= 0; j--)
+ {
+ var u000F = PopVariant();
+ array2[j] = u000F;
+ if (u000F.IsAddr())
+ {
+ u000F = FetchByAddr(u000F);
+ }
+ if (u000F.GetVariantType() != null)
+ {
+ u000F = VariantFactory.Convert(null, u000F.GetVariantType()).CopyFrom(u000F);
+ }
+ var u000F2 = VariantFactory.Convert(null, GetTypeById(u0006.ArgsTypeToOutput[j].TypeId)).CopyFrom(u000F);
+ array[j] = u000F2.GetValueAbstract();
+ if (j == 0 & mayVirtual && !u0006.IsStatic() && array[j] == null)
+ {
+ throw new NullReferenceException();
+ }
+ }
+ var u0006u2007 = new VmExecutor(_instrCodesDb);
+ var callees = new object[]
+ {
+ _module.Assembly
+ };
+ object obj;
+ try
+ {
+ obj = u0006u2007.Invoke(_srcVirtualizedStream, pos, array, methodGenericArgs, classGenericArgs, callees);
+ }
+ finally
+ {
+ for (var k = 0; k < array2.Length; k++)
+ {
+ var u000F3 = array2[k];
+ if (u000F3.IsAddr())
+ {
+ var obj2 = array[k];
+ AssignByReference(u000F3, VariantFactory.Convert(obj2, null));
+ }
+ }
+ }
+ var type = u0006u2007.GetTypeById(u0006u2007._methodHeader.ReturnTypeId);
+ if (type != VoidType)
+ {
+ PushVariant(VariantFactory.Convert(obj, type));
+ }
+ }
+
+ // Token: 0x0600027A RID: 634 RVA: 0x00011994 File Offset: 0x0000FB94
+ private void JmpToRef(VmMethodRefTokenInfo mref) // \u0002
+ {
+ //var arg_18_0 = (U0008U2007)U0003U2008.Get_u0005();
+ var methodBase = FindMethodById(mref.Pos, ReadToken(mref.Pos));
+ //methodBase.GetParameters();
+ var num = mref.Flags;
+ var mayVirtual = (num & 1073741824) != 0;
+ num &= -1073741825;
+ var methodGenericArgs = _methodGenericArgs;
+ var classGenericArgs = _classGenericArgs;
+ try
+ {
+ _methodGenericArgs = methodBase is ConstructorInfo ? Type.EmptyTypes : methodBase.GetGenericArguments();
+ _classGenericArgs = methodBase.DeclaringType.GetGenericArguments();
+ DoJmp(num, _methodGenericArgs, _classGenericArgs, mayVirtual);
+ }
+ finally
+ {
+ _methodGenericArgs = methodGenericArgs;
+ _classGenericArgs = classGenericArgs;
+ }
+ }
+
+ // Token: 0x060001EE RID: 494 RVA: 0x0000B5FC File Offset: 0x000097FC
+ private void Jmp_(VariantBase vPos) // \u0008\u200B\u2000
+ {
+ var pos = ((IntVariant)vPos).GetValue();
+ var arg_29_0 = (pos & -2147483648) != 0;
+ var mayVirtual = (pos & 1073741824) != 0;
+ pos &= 1073741823;
+ if (arg_29_0)
+ {
+ DoJmp(pos, null, null, mayVirtual);
+ return;
+ }
+ JmpToRef((VmMethodRefTokenInfo)ReadToken(pos).VmToken);
+ }
+
+ // Token: 0x06000199 RID: 409 RVA: 0x00008660 File Offset: 0x00006860
+ private void Calli_(VariantBase dummy) // \u0003\u2002
+ {
+ var methodBase = ((MethodVariant)PopVariant()).GetValue();
+ Invoke(methodBase, false);
+ }
+
+ // Token: 0x06000184 RID: 388 RVA: 0x000080F4 File Offset: 0x000062F4
+ private void Call_(VariantBase vMethodId) // \u000E\u2003
+ {
+ var methodBase = FindMethodById(((IntVariant)vMethodId).GetValue());
+ foreach (var arg in _variantOutputArgs)
+ {
+ PushVariant(arg);
+ }
+ Invoke(methodBase, false);
+ }
+
+ // Token: 0x06000191 RID: 401 RVA: 0x0000845C File Offset: 0x0000665C
+ private void Callvirt_(VariantBase vMethodId) // \u000E\u2005
+ {
+ var methodBase = FindMethodById(((IntVariant)vMethodId).GetValue());
+ if (_currentClass != null)
+ {
+ var pars = methodBase.GetParameters();
+ var types = new Type[pars.Length];
+ var num = 0;
+ foreach (var parameterInfo in pars)
+ {
+ types[num++] = parameterInfo.ParameterType;
+ }
+ var method = _currentClass.GetMethod(methodBase.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.GetProperty | BindingFlags.SetProperty, null, types, null);
+ if (method != null)
+ {
+ methodBase = method;
+ }
+ _currentClass = null;
+ }
+ Invoke(methodBase, true);
+ }
+
+ // Token: 0x060001CE RID: 462 RVA: 0x0000A1A0 File Offset: 0x000083A0
+ private void Invoke(VariantBase vMethodId) // \u000E\u200A
+ {
+ var methodBase = FindMethodById(((IntVariant)vMethodId).GetValue());
+ Invoke(methodBase, false);
+ }
+
+ // Token: 0x06000205 RID: 517 RVA: 0x0000C1A8 File Offset: 0x0000A3A8
+ [DebuggerNonUserCode]
+ private MethodBase FindMethodById(int methodId) // \u0002
+ {
+ return FindMethodById(methodId, ReadToken(methodId));
+ }
+
+ // Token: 0x06000171 RID: 369 RVA: 0x00007BBC File Offset: 0x00005DBC
+ private object Invoke(Stream srcVirtualizedStream, int pos, object[] args, Type[] methodGenericArgs, Type[] classGenericArgs, object[] callees) // \u0002
+ {
+ _srcVirtualizedStream = srcVirtualizedStream;
+ Seek(pos, srcVirtualizedStream, null);
+ return Invoke(args, methodGenericArgs, classGenericArgs, callees);
+ }
+
+ // Token: 0x06000172 RID: 370 RVA: 0x00007BDC File Offset: 0x00005DDC
+ private bool AlwaysFalse(MethodBase mb, object poppedThis, VariantBase[] poppedArgs, object[] args, bool mayVirtual, ref object obj) // \u0002
+ {
+ return false;
+ }
+
+ // Token: 0x06000179 RID: 377 RVA: 0x00007DA8 File Offset: 0x00005FA8
+ private void Leave_(VariantBase vTarget) // \u0006\u200B
+ {
+ OnException(null, ((UintVariant)vTarget).GetValue());
+ }
+
+ // Token: 0x06000180 RID: 384 RVA: 0x00007F48 File Offset: 0x00006148
+ private void Castclass_(VariantBase vTypeId) // \u0005\u2003
+ {
+ var type = GetTypeById(((IntVariant)vTypeId).GetValue());
+ var obj = PopVariant();
+ if (Isinst(obj, type))
+ {
+ PushVariant(obj);
+ return;
+ }
+ throw new InvalidCastException();
+ }
+
+ // Token: 0x06000185 RID: 389 RVA: 0x00008144 File Offset: 0x00006344
+ private void Ldc_i4_s_(VariantBase val) // \u000E\u2003\u2000
+ {
+ PushVariant(val);
+ }
+
+ // Token: 0x0600018B RID: 395 RVA: 0x0000827C File Offset: 0x0000647C
+ private void Stelem_i2_(VariantBase dummy) // \u000E\u200A\u2000
+ {
+ var obj = PopVariant().GetValueAbstract();
+ var idx = PopLong();
+ var array = (Array)PopVariant().GetValueAbstract();
+ var elementType = array.GetType().GetElementType();
+ checked
+ {
+ if (elementType == typeof(short))
+ {
+ ((short[])array)[(int)(IntPtr)idx] = (short)VariantFactory.Convert(obj, typeof(short)).GetValueAbstract();
+ return;
+ }
+ if (elementType == typeof(ushort))
+ {
+ ((ushort[])array)[(int)(IntPtr)idx] = (ushort)VariantFactory.Convert(obj, typeof(ushort)).GetValueAbstract();
+ return;
+ }
+ if (elementType == typeof(char))
+ {
+ ((char[])array)[(int)(IntPtr)idx] = (char)VariantFactory.Convert(obj, typeof(char)).GetValueAbstract();
+ return;
+ }
+ if (elementType.IsEnum)
+ {
+ Stelem(elementType, obj, idx, array);
+ return;
+ }
+ Stelem(typeof(short), obj, idx, array);
+ }
+ }
+
+ // Token: 0x0600018E RID: 398 RVA: 0x00008404 File Offset: 0x00006604
+ private void Stind_i_(VariantBase dummy) // \u000F\u2006
+ {
+ Stind();
+ }
+
+ // Token: 0x06000190 RID: 400 RVA: 0x00008440 File Offset: 0x00006640
+ private void Ldloc_0_(VariantBase dummy) // \u0006
+ {
+ PushVariant(_localVariables[0].Clone());
+ }
+
+ // Token: 0x06000193 RID: 403 RVA: 0x00008508 File Offset: 0x00006708
+ private void And_(VariantBase dummy) // \u000F\u200B\u2000
+ {
+ PushVariant(And(PopVariant(), PopVariant()));
+ }
+
+ // Token: 0x06000194 RID: 404 RVA: 0x00008534 File Offset: 0x00006734
+ private void Bge_un_(VariantBase vpos) // \u0006\u2009
+ {
+ var v2 = PopVariant();
+ if (UniCompare(PopVariant(), v2, ComparisonKind.GE, true))
+ {
+ JumpToPos(((UintVariant)vpos).GetValue());
+ }
+ }
+
+ // Token: 0x06000198 RID: 408 RVA: 0x00008628 File Offset: 0x00006828
+ private void Blt_un_(VariantBase vpos) // \u0006\u2006\u2000
+ {
+ var v2 = PopVariant();
+ if (UniCompare(PopVariant(), v2, ComparisonKind.LT, true))
+ {
+ JumpToPos(((UintVariant)vpos).GetValue());
+ }
+ }
+
+ // Token: 0x06000234 RID: 564 RVA: 0x0000F934 File Offset: 0x0000DB34
+ private void Bge_(VariantBase vpos) // \u0002\u200B
+ {
+ var v2 = PopVariant();
+ if (UniCompare(PopVariant(), v2, ComparisonKind.GE, false))
+ {
+ JumpToPos(((UintVariant)vpos).GetValue());
+ }
+ }
+
+ // Token: 0x060002AB RID: 683 RVA: 0x00012D80 File Offset: 0x00010F80
+ private void Blt_(VariantBase vpos) // \u0003\u2001
+ {
+ var v2 = PopVariant();
+ if (UniCompare(PopVariant(), v2, ComparisonKind.LT, false))
+ {
+ JumpToPos(((UintVariant)vpos).GetValue());
+ }
+ }
+
+ // Token: 0x0600023D RID: 573 RVA: 0x0000FA1C File Offset: 0x0000DC1C
+ private void Bgt_(VariantBase vpos) // \u000F\u2000\u2001
+ {
+ var v2 = PopVariant();
+ if (UniCompare(PopVariant(), v2, ComparisonKind.GT, false))
+ {
+ JumpToPos(((UintVariant)vpos).GetValue());
+ }
+ }
+
+ // Token: 0x060001A3 RID: 419 RVA: 0x00008D10 File Offset: 0x00006F10
+ private void Bgt_un_(VariantBase vpos) // \u0005\u2004
+ {
+ var v2 = PopVariant();
+ if (UniCompare(PopVariant(), v2, ComparisonKind.GT, true))
+ {
+ JumpToPos(((UintVariant)vpos).GetValue());
+ }
+ }
+
+ // Token: 0x06000261 RID: 609 RVA: 0x00010BB4 File Offset: 0x0000EDB4
+ private void Bne_un_(VariantBase vpos) // \u000F\u2007
+ {
+ var v2 = PopVariant();
+ if (UniCompare(PopVariant(), v2, ComparisonKind.NEQ, true))
+ {
+ JumpToPos(((UintVariant)vpos).GetValue());
+ }
+ }
+
+ // Token: 0x0600029D RID: 669 RVA: 0x000126E0 File Offset: 0x000108E0
+ private void Beq_(VariantBase vpos) // \u0002\u2007\u2000
+ {
+ var v2 = PopVariant();
+ if (UniCompare(PopVariant(), v2, ComparisonKind.EQ, false))
+ {
+ JumpToPos(((UintVariant)vpos).GetValue());
+ }
+ }
+
+ // Token: 0x060001B9 RID: 441 RVA: 0x000093F8 File Offset: 0x000075F8
+ private void Ble_un_(VariantBase vpos) // \u0003\u2007\u2000
+ {
+ var v2 = PopVariant();
+ var v1 = PopVariant();
+ if (UniCompare(v1, v2, ComparisonKind.LE, true))
+ {
+ JumpToPos(((UintVariant)vpos).GetValue());
+ }
+ }
+
+ private static bool IsFloating(VariantBase v)
+ {
+ return v.GetTypeCode() == VariantBase.Vtc.Tc21Double || v.GetTypeCode() == VariantBase.Vtc.Tc8Float;
+ }
+ // Token: 0x06000297 RID: 663 RVA: 0x0001253C File Offset: 0x0001073C
+ private void Ble_(VariantBase vpos) // \u0002\u2003\u2000
+ {
+ var v2 = PopVariant();
+ var v1 = PopVariant();
+ if (UniCompare(v1, v2, ComparisonKind.LE, false))
+ {
+ JumpToPos(((UintVariant)vpos).GetValue());
+ }
+ }
+
+ // Token: 0x06000228 RID: 552 RVA: 0x0000F480 File Offset: 0x0000D680
+ private void Brfalse_(VariantBase vpos) // \u0002\u2002
+ {
+ var val = PopVariant();
+ var num = val.GetTypeCode();
+ bool flag;
+ switch (num)
+ {
+ case VariantBase.Vtc.Tc5Enum:
+ flag = !Convert.ToBoolean(((EnumVariant)val).GetValue());
+ break;
+ case VariantBase.Vtc.Tc13UIntPtr:
+ flag = ((UIntPtrVariant)val).GetValue() == UIntPtr.Zero;
+ break;
+ case VariantBase.Vtc.Tc17IntPtr:
+ flag = ((IntPtrVariant)val).GetValue() == IntPtr.Zero;
+ break;
+ case VariantBase.Vtc.Tc18Object:
+ flag = ((ObjectVariant)val).GetValue() == null;
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ flag = ((IntVariant)val).GetValue() == 0;
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ flag = ((LongVariant)val).GetValue() == 0L;
+ break;
+ default:
+ flag = val.GetValueAbstract() == null;
+ break;
+ }
+ if (flag)
+ {
+ JumpToPos(((UintVariant)vpos).GetValue());
+ }
+ }
+
+ // Token: 0x06000274 RID: 628 RVA: 0x00011488 File Offset: 0x0000F688
+ private void ExecuteExceptionHandler() // \u0005
+ {
+ if (_ehStack.Count == 0)
+ {
+ if (_wasException)
+ {
+ _myBufferPos = _myBufferReader.GetBuffer().GetPos();
+ ThrowStoreCrossDomain(_exception);
+ }
+ return;
+ }
+ var ehFrame = _ehStack.PopBack();
+ if (ehFrame.Exception != null)
+ {
+ var toStack = new ObjectVariant();
+ toStack.SetValueAbstract(ehFrame.Exception);
+ PushVariant(toStack);
+ }
+ else
+ {
+ _evalStack.Clear();
+ }
+ JumpToPos(ehFrame.Pos);
+ }
+
+ // Token: 0x060001F2 RID: 498 RVA: 0x0000B6C8 File Offset: 0x000098C8
+ private void Switch_(VariantBase vSwitchPosArray) // \u0002\u200A\u2000
+ {
+ var vidx = PopVariant();
+ uint idx;
+ switch (vidx.GetTypeCode())
+ {
+ case VariantBase.Vtc.Tc5Enum:
+ idx = (uint)Convert.ToInt64(vidx.GetValueAbstract());
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ idx = (uint)((IntVariant)vidx).GetValue();
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ idx = (uint)((LongVariant)vidx).GetValue();
+ break;
+ default:
+ throw new InvalidOperationException();
+ }
+ var switchPosArray = (IntVariant[])((ArrayVariant)vSwitchPosArray).GetValue();
+ if (idx >= (ulong)switchPosArray.Length)
+ {
+ return;
+ }
+ JumpToPos((uint)switchPosArray[(int)idx].GetValue());
+ }
+
+ // Token: 0x060001FB RID: 507 RVA: 0x0000BC68 File Offset: 0x00009E68
+ private void Brtrue_(VariantBase vpos) // \u0008\u2007
+ {
+ var val = PopVariant();
+ var num = val.GetTypeCode();
+ bool flag;
+ switch (num)
+ {
+ case VariantBase.Vtc.Tc5Enum:
+ flag = Convert.ToBoolean(((EnumVariant)val).GetValue());
+ break;
+ case VariantBase.Vtc.Tc13UIntPtr:
+ flag = ((UIntPtrVariant)val).GetValue() != UIntPtr.Zero;
+ break;
+ case VariantBase.Vtc.Tc17IntPtr:
+ flag = ((IntPtrVariant)val).GetValue() != IntPtr.Zero;
+ break;
+ case VariantBase.Vtc.Tc18Object:
+ flag = ((ObjectVariant)val).GetValue() != null;
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ flag = ((IntVariant)val).GetValue() != 0;
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ flag = ((LongVariant)val).GetValue() != 0L;
+ break;
+ default:
+ flag = val.GetValueAbstract() != null;
+ break;
+ }
+ if (flag)
+ {
+ JumpToPos(((UintVariant)vpos).GetValue());
+ }
+ }
+
+ // Token: 0x06000214 RID: 532 RVA: 0x0000C764 File Offset: 0x0000A964
+ private void Br_(VariantBase vpos) // \u0005\u2008\u2000
+ {
+ JumpToPos(((UintVariant)vpos).GetValue());
+ }
+
+ private void Conv_r_un_(VariantBase dummy)
+ {
+ var pop = PopVariant();
+ double val;
+ switch (pop.GetTypeCode())
+ {
+ case VariantBase.Vtc.Tc5Enum:
+ var v = VariantBase.SignedVariantFromEnum((EnumVariant)pop).GetValueAbstract();
+ if (Marshal.SizeOf(v) < 8)
+ val = (double)(uint)Convert.ToInt32(v);
+ else
+ val = (double)(ulong)Convert.ToInt64(v);
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ val = (double)(uint)((IntVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ val = ((DoubleVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ val = (double)((FloatVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ val = (double)(ulong)((LongVariant)pop).GetValue();
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(double), new[] { typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(OpCodes.Conv_R_Un);
+ gen.Emit(OpCodes.Ret);
+ val = (double)dyn.Invoke(null, new[] { pop.GetValueAbstract() });
+ break;
+ }
+ var push = new DoubleVariant();
+ push.SetValue(val);
+ PushVariant(push);
+ }
+
+ private void Conv_r(OpCode oc, Func<object, double> F)
+ {
+ var pop = PopVariant();
+ double val;
+ switch (pop.GetTypeCode())
+ {
+ case VariantBase.Vtc.Tc5Enum:
+ var v = VariantBase.SignedVariantFromEnum((EnumVariant)pop).GetValueAbstract();
+ val = F(Marshal.SizeOf(v) < 8 ? Convert.ToInt32(v) : Convert.ToInt64(v));
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ val = F(((IntVariant)pop).GetValue());
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ val = F(((DoubleVariant)pop).GetValue());
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ val = F(((FloatVariant)pop).GetValue());
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ val = F(((LongVariant)pop).GetValue());
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(double), new[] { typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(oc);
+ gen.Emit(OpCodes.Ret);
+ val = (double)dyn.Invoke(null, new[] { pop.GetValueAbstract() });
+ break;
+ }
+ var push = new DoubleVariant();
+ push.SetValue(val);
+ PushVariant(push);
+ }
+ private void Conv_r4_(VariantBase dummy)
+ {
+ Conv_r(OpCodes.Conv_R4, o => (double)(float)Convert.ChangeType(o, typeof(float)));
+ }
+ private void Conv_r8_(VariantBase dummy)
+ {
+ Conv_r(OpCodes.Conv_R8, o => (double)Convert.ChangeType(o, typeof(double)));
+ }
+
+ // Token: 0x06000196 RID: 406 RVA: 0x00008600 File Offset: 0x00006800
+ private void Ldind_i4_(VariantBase dummy) // \u0002\u2001\u2000
+ {
+ Ldind(typeof(int));
+ }
+
+ // Token: 0x06000197 RID: 407 RVA: 0x00008614 File Offset: 0x00006814
+ private void Ldind_u1_(VariantBase dummy) // \u000E
+ {
+ Ldind(typeof(byte));
+ }
+
+ // Token: 0x0600019A RID: 410 RVA: 0x00008688 File Offset: 0x00006888
+ private void Isinst_(VariantBase vTypeId) // \u000F\u2007\u2000
+ {
+ var type = GetTypeById(((IntVariant)vTypeId).GetValue());
+ var obj = PopVariant();
+ if (Isinst(obj, type))
+ {
+ PushVariant(obj);
+ return;
+ }
+ PushVariant(new ObjectVariant());
+ }
+
+ // Token: 0x0600019D RID: 413 RVA: 0x00008B68 File Offset: 0x00006D68
+ private void Initobj_(VariantBase vTypeId) // \u0005\u2005\u2000
+ {
+ var type = GetTypeById(((IntVariant)vTypeId).GetValue());
+ var dest = PopVariant();
+ if (!type.IsValueType)
+ {
+ AssignByReference(dest, new ObjectVariant());
+ return;
+ }
+ var obj = FetchByAddr(dest).GetValueAbstract();
+ if (SimpleTypeHelper.IsNullableGeneric(type))
+ {
+ var val = new ObjectVariant();
+ val.SetVariantType(type);
+ AssignByReference(dest, val);
+ return;
+ }
+ var fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
+ foreach (var fieldInfo in fields)
+ {
+ fieldInfo.SetValue(obj, CreateValueTypeInstance(fieldInfo.FieldType));
+ }
+ }
+
+ // Token: 0x0600019E RID: 414 RVA: 0x00008C08 File Offset: 0x00006E08
+ private void Ldarg_s_(VariantBase vidx) // \u000E\u2000
+ {
+ var idx = (ByteVariant)vidx;
+ PushVariant(_variantOutputArgs[idx.GetValue()].Clone());
+ }
+
+ // Token: 0x06000244 RID: 580 RVA: 0x00010160 File Offset: 0x0000E360
+ private void Ldarga_s_(VariantBase vidx) // \u0008\u2001\u2001
+ {
+ var idx = (ByteVariant)vidx;
+ var push = new VariantBaseHolder();
+ push.SetValue(_variantOutputArgs[idx.GetValue()]);
+ PushVariant(push);
+ }
+
+ // Token: 0x06000255 RID: 597 RVA: 0x00010910 File Offset: 0x0000EB10
+ private void Ldarga_(VariantBase vidx) // \u0006\u2001
+ {
+ var idx = (UshortVariant)vidx;
+ var push = new VariantBaseHolder();
+ push.SetValue(_variantOutputArgs[idx.GetValue()]);
+ PushVariant(push);
+ }
+
+ // Token: 0x0600019F RID: 415 RVA: 0x00008C38 File Offset: 0x00006E38
+ private void Endfilter_(VariantBase dummy) // \u000F\u2001\u2000
+ {
+ if (((IntVariant)PopVariant()).GetValue() != 0)
+ {
+ _ehStack.PushBack(new ExcHandlerFrame
+ {
+ Pos = (uint)_myBufferReader.GetBuffer().GetPos(),
+ Exception = _exception
+ });
+ _wasException = false;
+ }
+ ExecuteExceptionHandler();
+ }
+
+ // Token: 0x060001A2 RID: 418 RVA: 0x00008CFC File Offset: 0x00006EFC
+ private void Ldind_r4_(VariantBase dummy) // \u0008\u2009\u2000
+ {
+ Ldind(typeof(float));
+ }
+
+ // Token: 0x060001A4 RID: 420 RVA: 0x00008D48 File Offset: 0x00006F48
+ private void Stsfld_(VariantBase vFieldId) // \u000F\u2008
+ {
+ var fieldInfo = ResolveField(((IntVariant)vFieldId).GetValue());
+ var val = VariantFactory.Convert(PopVariant().GetValueAbstract(), fieldInfo.FieldType);
+ fieldInfo.SetValue(null, val.GetValueAbstract());
+ }
+
+ // Token: 0x060001A5 RID: 421 RVA: 0x00008D90 File Offset: 0x00006F90
+ private void Ldloc_3_(VariantBase dummy) // \u0003\u2001\u2001
+ {
+ PushVariant(_localVariables[3].Clone());
+ }
+
+ // Token: 0x060001A7 RID: 423 RVA: 0x00008F68 File Offset: 0x00007168
+ private void Stelem_r8_(VariantBase dummy) // \u000E\u2006\u2000
+ {
+ Stelem(typeof(double));
+ }
+
+ // Token: 0x060001AA RID: 426 RVA: 0x00008FBC File Offset: 0x000071BC
+ private void Ceq_(VariantBase dummy) // \u0006\u2008
+ {
+ var iv = new IntVariant();
+ iv.SetValue(UniCompare(PopVariant(), PopVariant(), ComparisonKind.EQ, false) ? 1 : 0);
+ PushVariant(iv);
+ }
+
+ // Token: 0x060001AC RID: 428 RVA: 0x00009030 File Offset: 0x00007230
+ private void Stelem_i4_(VariantBase dummy) // \u000E\u2001\u2000
+ {
+ var obj = PopVariant().GetValueAbstract();
+ var idx = PopLong();
+ var array = (Array)PopVariant().GetValueAbstract();
+ var elementType = array.GetType().GetElementType();
+ checked
+ {
+ if (elementType == typeof(int))
+ {
+ ((int[])array)[(int)(IntPtr)idx] = (int)VariantFactory.Convert(obj, typeof(int)).GetValueAbstract();
+ return;
+ }
+ if (elementType == typeof(uint))
+ {
+ ((uint[])array)[(int)(IntPtr)idx] = (uint)VariantFactory.Convert(obj, typeof(uint)).GetValueAbstract();
+ return;
+ }
+ if (elementType.IsEnum)
+ {
+ Stelem(elementType, obj, idx, array);
+ return;
+ }
+ Stelem(typeof(int), obj, idx, array);
+ }
+ }
+
+ // Token: 0x060001AD RID: 429 RVA: 0x00009100 File Offset: 0x00007300
+ private void Stind_i1_(VariantBase dummy) // \u0005\u2000\u2000
+ {
+ Stind();
+ }
+
+ // Token: 0x060001AF RID: 431 RVA: 0x00009114 File Offset: 0x00007314
+ private object ResolveNativeToken(int token) // \u0002
+ {
+ var num = HiByte.Extract(token);
+ object result;
+ if (num > 67108864)
+ {
+ if (num <= 167772160)
+ {
+ if (num != 100663296)
+ {
+ if (num != 167772160)
+ {
+ throw new InvalidOperationException();
+ }
+ try
+ {
+ result = _module.ModuleHandle.ResolveFieldHandle(token);
+ return result;
+ }
+ catch
+ {
+ try
+ {
+ result = _module.ModuleHandle.ResolveMethodHandle(token);
+ }
+ catch
+ {
+ throw new InvalidOperationException();
+ }
+ return result;
+ }
+ }
+ }
+ else
+ {
+ if (num == 452984832)
+ {
+ result = _module.ModuleHandle.ResolveTypeHandle(token);
+ return result;
+ }
+ if (num != 721420288)
+ {
+ throw new InvalidOperationException();
+ }
+ }
+ result = _module.ModuleHandle.ResolveMethodHandle(token);
+ return result;
+ }
+ if (num != 16777216 && num != 33554432)
+ {
+ if (num != 67108864)
+ {
+ throw new InvalidOperationException();
+ }
+ result = _module.ModuleHandle.ResolveFieldHandle(token);
+ return result;
+ }
+ result = _module.ModuleHandle.ResolveTypeHandle(token);
+ return result;
+ }
+
+ // Token: 0x060001B0 RID: 432 RVA: 0x0000923C File Offset: 0x0000743C
+ private void Ldloc_2_(VariantBase dummy) // \u0008\u2008
+ {
+ PushVariant(_localVariables[2].Clone());
+ }
+
+ // Token: 0x060001B1 RID: 433 RVA: 0x00009258 File Offset: 0x00007458
+ private void Constrained_(VariantBase vTypeId) // \u0002\u2000\u2000
+ {
+ _currentClass = GetTypeById(((IntVariant)vTypeId).GetValue());
+ }
+
+ // Token: 0x060001B2 RID: 434 RVA: 0x00009280 File Offset: 0x00007480
+ private void Ldftn_(VariantBase vMethodId) // \U0003\U2008
+ {
+ var methodBase = FindMethodById(((IntVariant)vMethodId).GetValue());
+ var push = new MethodVariant();
+ push.SetValue(methodBase);
+ PushVariant(push);
+ }
+
+ // Token: 0x060001B4 RID: 436 RVA: 0x000092C8 File Offset: 0x000074C8
+ private void Ldnull_(VariantBase dummy) // \u0005\u2002\u2001
+ {
+ PushVariant(new ObjectVariant());
+ }
+
+ private void Conv_ovf_u8_un_(VariantBase dummy)
+ {
+ Conv_u8(true, false);
+ }
+
+ // Token: 0x060001B8 RID: 440 RVA: 0x000093F0 File Offset: 0x000075F0
+ private void Stind_i2_(VariantBase dummy) // \u0003\u2000\u2000
+ {
+ Stind();
+ }
+
+ private void Conv_ovf_u2_un_(VariantBase dummy)
+ {
+ Conv_u2(true, false);
+ }
+
+ private void Conv_u2(bool ovf, bool signed)
+ {
+ var pop = PopVariant();
+ ushort val;
+ switch (pop.GetTypeCode())
+ {
+ case VariantBase.Vtc.Tc5Enum:
+ if (ovf)
+ {
+ var v = VariantBase.SignedVariantFromEnum((EnumVariant)pop).GetValueAbstract();
+ if (signed)
+ val = Convert.ToUInt16(v);
+ else
+ val = Convert.ToUInt16((ulong)Convert.ToInt64(v));
+ break;
+ }
+ val = (ushort)VariantBase.SignedLongFromEnum((EnumVariant)pop);
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ if (ovf && !signed)
+ {
+ val = Convert.ToUInt16((uint)((IntVariant)pop).GetValue());
+ break;
+ }
+ val = ovf ? Convert.ToUInt16(((IntVariant)pop).GetValue()) : (ushort)((IntVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ if (ovf)
+ {
+ val = checked((ushort) ((DoubleVariant) pop).GetValue());
+ break;
+ }
+ val = (ushort)((DoubleVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ if (ovf)
+ {
+ val = checked((ushort)((FloatVariant)pop).GetValue());
+ break;
+ }
+ val = (ushort)((FloatVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ if (ovf)
+ {
+ if (signed)
+ val = checked((ushort)((LongVariant)pop).GetValue());
+ else
+ val = Convert.ToUInt16((ulong)((LongVariant)pop).GetValue());
+ break;
+ }
+ val = (ushort)((LongVariant)pop).GetValue();
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(ushort), new[] { typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(signed ? (ovf ? OpCodes.Conv_Ovf_U2 : OpCodes.Conv_U2) : OpCodes.Conv_Ovf_U2_Un);
+ gen.Emit(OpCodes.Ret);
+ val = (ushort)dyn.Invoke(null, new[] { pop.GetValueAbstract() });
+ break;
+ }
+ var push = new UshortVariant();
+ push.SetValue(val);
+ PushVariant(push);
+ }
+
+ // Token: 0x060001AE RID: 430 RVA: 0x00009108 File Offset: 0x00007308
+ private void Conv_ovf_u2_(VariantBase dummy) // \u0008\u2005\u2000
+ {
+ Conv_u2(true, true);
+ }
+
+ // Token: 0x06000292 RID: 658 RVA: 0x0001238C File Offset: 0x0001058C
+ private void Conv_u2_(VariantBase dummy) // \u000F\u2002\u2000
+ {
+ Conv_u2(false, true);
+ }
+
+ private void Conv_u1(bool ovf, bool signed)
+ {
+ var pop = PopVariant();
+ byte val;
+ switch (pop.GetTypeCode())
+ {
+ case VariantBase.Vtc.Tc5Enum:
+ if (ovf)
+ {
+ var v = VariantBase.SignedVariantFromEnum((EnumVariant)pop).GetValueAbstract();
+ val = signed ? Convert.ToByte(v) : Convert.ToByte((ulong)Convert.ToInt64(v));
+ break;
+ }
+ val = (byte)VariantBase.SignedLongFromEnum((EnumVariant)pop);
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ if (ovf && !signed)
+ {
+ val = Convert.ToByte((uint)((IntVariant)pop).GetValue());
+ break;
+ }
+ val = ovf ? Convert.ToByte(((IntVariant)pop).GetValue()) : (byte)((IntVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ if (ovf)
+ {
+ val = signed ? checked((byte)((DoubleVariant)pop).GetValue()) : Convert.ToByte(((DoubleVariant)pop).GetValue());
+ break;
+ }
+ val = (byte)((DoubleVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ if (ovf)
+ {
+ val = checked((byte)((FloatVariant)pop).GetValue());
+ break;
+ }
+ val = (byte)((FloatVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ if (ovf)
+ {
+ val = checked((byte)((LongVariant)pop).GetValue());
+ break;
+ }
+ val = (byte)((LongVariant)pop).GetValue();
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(byte), new[] { typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(signed ? (ovf ? OpCodes.Conv_Ovf_U1 : OpCodes.Conv_U1) : OpCodes.Conv_Ovf_U1_Un);
+ gen.Emit(OpCodes.Ret);
+ val = (byte)dyn.Invoke(null, new[] { pop.GetValueAbstract() });
+ break;
+ }
+ var push = new ByteVariant();
+ push.SetValue(val);
+ PushVariant(push);
+ }
+
+ // Token: 0x06000182 RID: 386 RVA: 0x00007FB4 File Offset: 0x000061B4
+ private void Conv_ovf_i1_(VariantBase dummy) // \u0008\u2004
+ {
+ Conv_i1(true, true);
+ }
+
+ // Token: 0x06000188 RID: 392 RVA: 0x00008238 File Offset: 0x00006438
+ private void Conv_u4_(VariantBase dummy) // \u0008\u2003\u2001
+ {
+ Conv_u4(false, true);
+ }
+
+ // Token: 0x0600018A RID: 394 RVA: 0x00008270 File Offset: 0x00006470
+ private void Conv_ovf_i_(VariantBase dummy) // \u0008\u2003\u2000
+ {
+ Conv_i(true, true);
+ }
+
+ // Token: 0x060001CF RID: 463 RVA: 0x0000A1CC File Offset: 0x000083CC
+ private void Conv_i_(VariantBase dummy) // \u0008\u2005
+ {
+ Conv_i(false, true);
+ }
+
+ // Token: 0x060001FF RID: 511 RVA: 0x0000BFC8 File Offset: 0x0000A1C8
+ private void Conv_u4(bool ovf, bool signed) // \u0005
+ {
+ var pop = PopVariant();
+ uint val;
+ switch (pop.GetTypeCode())
+ {
+ case VariantBase.Vtc.Tc5Enum:
+ if (ovf)
+ {
+ var v = VariantBase.SignedVariantFromEnum((EnumVariant) pop).GetValueAbstract();
+ if (signed || Marshal.SizeOf(v) < 8)
+ val = signed ? Convert.ToUInt32(v) : (uint)Convert.ToInt32(v);
+ else
+ val = Convert.ToUInt32(Convert.ToUInt64(v));
+ break;
+ }
+ val = (uint)VariantBase.SignedLongFromEnum((EnumVariant)pop);
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ if (ovf && signed)
+ {
+ val = checked((uint)((IntVariant)pop).GetValue());
+ break;
+ }
+ val = (uint)((IntVariant)pop).GetValue(); // err fixed and unit tested by ursoft (was ushort)
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ if (ovf)
+ {
+ val = checked((uint)((DoubleVariant)pop).GetValue());
+ break;
+ }
+ val = (uint)((DoubleVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ if (ovf)
+ {
+ val = checked((uint)((FloatVariant)pop).GetValue());
+ break;
+ }
+ val = (uint)((FloatVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ if (ovf)
+ {
+ val = checked((uint)((LongVariant)pop).GetValue());
+ break;
+ }
+ val = (uint)((LongVariant)pop).GetValue();
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(UInt32), new []{ typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(signed ? (ovf ? OpCodes.Conv_Ovf_U4 : OpCodes.Conv_U4) : OpCodes.Conv_Ovf_U4_Un);
+ gen.Emit(OpCodes.Ret);
+ val = (uint) dyn.Invoke(null, new[] {pop.GetValueAbstract()});
+ break;
+ }
+ var push = new IntVariant();
+ push.SetValue((int)val);
+ PushVariant(push);
+ }
+ private void Conv_i4(bool ovf, bool signed)
+ {
+ var pop = PopVariant();
+ int val;
+ switch (pop.GetTypeCode())
+ {
+ case VariantBase.Vtc.Tc5Enum:
+ if (ovf)
+ {
+ var v = VariantBase.SignedVariantFromEnum((EnumVariant)pop).GetValueAbstract();
+ if (signed)
+ val = Convert.ToInt32(v);
+ else
+ val = Convert.ToInt32((ulong)Convert.ToInt64(v));
+ break;
+ }
+ val = (int)VariantBase.SignedLongFromEnum((EnumVariant)pop);
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ if (ovf && !signed)
+ {
+ val = Convert.ToInt32((uint)((IntVariant)pop).GetValue());
+ break;
+ }
+ val = ((IntVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ if (ovf)
+ {
+ val = checked((int)((DoubleVariant)pop).GetValue());
+ break;
+ }
+ val = (int)((DoubleVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ if (ovf)
+ {
+ val = checked((int)((FloatVariant)pop).GetValue());
+ break;
+ }
+ val = (int)((FloatVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ if (ovf)
+ {
+ if(signed)
+ val = checked((int)((LongVariant)pop).GetValue());
+ else
+ val = Convert.ToInt32((ulong)((LongVariant)pop).GetValue());
+ break;
+ }
+ val = (int)((LongVariant)pop).GetValue();
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(Int32), new[] { typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(signed ? (ovf ? OpCodes.Conv_Ovf_I4 : OpCodes.Conv_I4) : OpCodes.Conv_Ovf_I4_Un);
+ gen.Emit(OpCodes.Ret);
+ val = (int)dyn.Invoke(null, new[] { pop.GetValueAbstract() });
+ break;
+ }
+ var push = new IntVariant();
+ push.SetValue(val);
+ PushVariant(push);
+ }
+
+ // Token: 0x06000294 RID: 660 RVA: 0x00012414 File Offset: 0x00010614
+ private void Conv_ovf_u4_(VariantBase dummy) // \u000F\u200A
+ {
+ Conv_u4(true, true);
+ }
+
+ // Token: 0x06000200 RID: 512 RVA: 0x0000C0B0 File Offset: 0x0000A2B0
+ private void Conv_ovf_u1_(VariantBase dummy) // \u0008\u2007\u2000
+ {
+ Conv_u1(true, true);
+ }
+
+ private void Conv_ovf_i2_un_(VariantBase dummy)
+ {
+ Conv_i2(true, false);
+ }
+
+ private void Conv_i2(bool ovf, bool signed)
+ {
+ var pop = PopVariant();
+ short val;
+ switch (pop.GetTypeCode())
+ {
+ case VariantBase.Vtc.Tc5Enum:
+ if (ovf)
+ {
+ var v = VariantBase.SignedVariantFromEnum((EnumVariant)pop).GetValueAbstract();
+ if (signed)
+ val = Convert.ToInt16(v);
+ else
+ val = Convert.ToInt16((ulong)Convert.ToInt64(v));
+ break;
+ }
+ val = (short)VariantBase.SignedLongFromEnum((EnumVariant)pop);
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ if (ovf && !signed)
+ {
+ val = Convert.ToInt16((uint)((IntVariant)pop).GetValue());
+ break;
+ }
+ val = ovf ? Convert.ToInt16(((IntVariant)pop).GetValue()) : (short)((IntVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ if (ovf)
+ {
+ val = signed ? checked((short)((DoubleVariant)pop).GetValue()) :
+ (IntPtr.Size == 4 ? Convert.ToInt16(Convert.ToUInt16((long)((DoubleVariant)pop).GetValue())) :
+ Convert.ToInt16((long)((DoubleVariant)pop).GetValue()));
+ break;
+ }
+ val = (short)((DoubleVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ if (ovf)
+ {
+ val = signed ? checked((short)((FloatVariant)pop).GetValue()) :
+ (IntPtr.Size == 4 ? Convert.ToInt16(Convert.ToUInt16((long)((FloatVariant)pop).GetValue())) :
+ Convert.ToInt16((long)((FloatVariant)pop).GetValue()));
+ break;
+ }
+ val = (short)((FloatVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ if (ovf)
+ {
+ if (signed)
+ val = checked((short)((LongVariant)pop).GetValue());
+ else
+ val = Convert.ToInt16((ulong)((LongVariant)pop).GetValue());
+ break;
+ }
+ val = (short)((LongVariant)pop).GetValue();
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(short), new[] { typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(signed ? (ovf ? OpCodes.Conv_Ovf_I2 : OpCodes.Conv_I2) : OpCodes.Conv_Ovf_I2_Un);
+ gen.Emit(OpCodes.Ret);
+ val = (short)dyn.Invoke(null, new[] { pop.GetValueAbstract() });
+ break;
+ }
+ var push = new ShortVariant();
+ push.SetValue(val);
+ PushVariant(push);
+ }
+
+ // Token: 0x060001FE RID: 510 RVA: 0x0000BFBC File Offset: 0x0000A1BC
+ private void Conv_i2_(VariantBase dummy) // \u0006\u2001\u2000
+ {
+ Conv_i2(false, true);
+ }
+
+ // Token: 0x060002A8 RID: 680 RVA: 0x00012D2C File Offset: 0x00010F2C
+ private void Conv_ovf_i4_(VariantBase dummy) // \u000F\u2000\u2000
+ {
+ Conv_i4(true, true);
+ }
+
+ private void Conv_i8(bool ovf, bool signed)
+ {
+ var pop = PopVariant();
+ long val;
+ switch (pop.GetTypeCode())
+ {
+ case VariantBase.Vtc.Tc5Enum:
+ var v = VariantBase.SignedVariantFromEnum((EnumVariant)pop).GetValueAbstract();
+ if (!signed && ovf && Marshal.SizeOf(v) > 4)
+ val = checked((long)(ulong)Convert.ToInt64(v));
+ else
+ val = (signed || Marshal.SizeOf(v) > 4) ? Convert.ToInt64(v) :
+ (uint)(ulong)Convert.ToInt64(v);
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ int iv = ((IntVariant)pop).GetValue();
+ if (signed)
+ val = iv;
+ else
+ val = (long)(uint)iv;
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ if (ovf)
+ {
+ val = checked((long)((DoubleVariant)pop).GetValue());
+ break;
+ }
+ val = (long)((DoubleVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ if (ovf)
+ {
+ val = checked((long)((FloatVariant)pop).GetValue());
+ break;
+ }
+ val = (long)((FloatVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ if (ovf)
+ {
+ if (signed)
+ val = ((LongVariant)pop).GetValue();
+ else
+ val = Convert.ToInt64((ulong)((LongVariant)pop).GetValue());
+ break;
+ }
+ val = ((LongVariant)pop).GetValue();
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(long), new[] { typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(signed ? (ovf ? OpCodes.Conv_Ovf_I8 : OpCodes.Conv_I8) : OpCodes.Conv_Ovf_I8_Un);
+ gen.Emit(OpCodes.Ret);
+ val = (long)dyn.Invoke(null, new[] { pop.GetValueAbstract() });
+ break;
+ }
+ var push = new LongVariant();
+ push.SetValue(val);
+ PushVariant(push);
+ }
+
+ // Token: 0x06000219 RID: 537 RVA: 0x0000C824 File Offset: 0x0000AA24
+ private void Conv_ovf_i8_(VariantBase dummy) // \u0008\u2002\u2000
+ {
+ Conv_i8(true, true);
+ }
+
+ private void Conv_i1(bool ovf, bool signed)
+ {
+ var pop = PopVariant();
+ sbyte val;
+ switch (pop.GetTypeCode())
+ {
+ case VariantBase.Vtc.Tc5Enum:
+ if (ovf)
+ {
+ var v = VariantBase.SignedVariantFromEnum((EnumVariant)pop).GetValueAbstract();
+ val = signed ? Convert.ToSByte(v) : Convert.ToSByte((ulong)Convert.ToInt64(v));
+ break;
+ }
+ val = (sbyte)VariantBase.SignedLongFromEnum((EnumVariant)pop);
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ if (ovf && !signed)
+ {
+ val = Convert.ToSByte((uint)((IntVariant)pop).GetValue());
+ break;
+ }
+ val = ovf ? Convert.ToSByte(((IntVariant)pop).GetValue()) : (sbyte)((IntVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ if (ovf)
+ {
+ val = signed ? checked((sbyte)((DoubleVariant)pop).GetValue()) :
+ (IntPtr.Size == 4 ? Convert.ToSByte(Convert.ToByte(((DoubleVariant)pop).GetValue())) :
+ Convert.ToSByte((long)((DoubleVariant)pop).GetValue()));
+ break;
+ }
+ val = (sbyte)((DoubleVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ if (ovf)
+ {
+ val = signed ? checked((sbyte)((FloatVariant)pop).GetValue()) :
+ (IntPtr.Size == 4 ? Convert.ToSByte(Convert.ToByte(((FloatVariant)pop).GetValue())) :
+ Convert.ToSByte((long)((FloatVariant)pop).GetValue()));
+ break;
+ }
+ val = (sbyte)((FloatVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ if (ovf)
+ {
+ if (signed)
+ val = checked((sbyte)((LongVariant)pop).GetValue());
+ else
+ val = Convert.ToSByte((ulong)((LongVariant)pop).GetValue());
+ break;
+ }
+ val = (sbyte)((LongVariant)pop).GetValue();
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(SByte), new[] { typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(signed ? (ovf ? OpCodes.Conv_Ovf_I1 : OpCodes.Conv_I1) : OpCodes.Conv_Ovf_I1_Un);
+ gen.Emit(OpCodes.Ret);
+ val = (sbyte)dyn.Invoke(null, new[] { pop.GetValueAbstract() });
+ break;
+ }
+ var push = new SbyteVariant();
+ push.SetValue(val);
+ PushVariant(push);
+ }
+
+ // Token: 0x060002A6 RID: 678 RVA: 0x00012CD0 File Offset: 0x00010ED0
+ private void Conv_i1_(VariantBase dummy) // \u000E\u2006
+ {
+ Conv_i1(false, true);
+ }
+
+ // Token: 0x06000285 RID: 645 RVA: 0x00011EF0 File Offset: 0x000100F0
+ private void Conv_ovf_i2_(VariantBase dummy) // \u0002\u2000\u2001
+ {
+ Conv_i2(true, true);
+ }
+
+ // Token: 0x0600018D RID: 397 RVA: 0x000083F8 File Offset: 0x000065F8
+ private void Conv_u_(VariantBase dummy) // \u000F\u2003\u2001
+ {
+ Conv_u(false, true);
+ }
+
+ // Token: 0x060001EF RID: 495 RVA: 0x0000B658 File Offset: 0x00009858
+ private void Conv_ovf_u_(VariantBase dummy) // \u0002\u2000
+ {
+ Conv_u(true, true);
+ }
+
+ // Token: 0x06000215 RID: 533 RVA: 0x0000C784 File Offset: 0x0000A984
+ private void Conv_u1_(VariantBase dummy) // \u0008\u2002
+ {
+ Conv_u1(false, true);
+ }
+
+ // Token: 0x06000211 RID: 529 RVA: 0x0000C690 File Offset: 0x0000A890
+ private void Conv_ovf_i_un_(VariantBase dummy) // \u000F
+ {
+ Conv_i(true, false);
+ }
+
+ // Token: 0x06000229 RID: 553 RVA: 0x0000F56C File Offset: 0x0000D76C
+ private void Conv_i4_(VariantBase dummy) // \u0003\u2005\u2000
+ {
+ Conv_i4(false, true);
+ }
+
+ private void Conv_ovf_i8_un_(VariantBase dummy)
+ {
+ Conv_i8(true, false);
+ }
+
+ // Token: 0x06000253 RID: 595 RVA: 0x00010790 File Offset: 0x0000E990
+ private void Conv_ovf_u4_un_(VariantBase dummy) // \u0002\u2009\u2000
+ {
+ Conv_u4(true, false);
+ }
+
+ // Token: 0x06000284 RID: 644 RVA: 0x00011EE4 File Offset: 0x000100E4
+ private void Conv_i8_(VariantBase dummy) // \u0003\u2006\u2000
+ {
+ Conv_i8(false, true);
+ }
+
+ // Token: 0x0600028A RID: 650 RVA: 0x000121B8 File Offset: 0x000103B8
+ private void Conv_ovf_u_un_(VariantBase dummy) // \u000F\u200B
+ {
+ Conv_u(true, false);
+ }
+
+ private unsafe void Conv_i(bool ovf, bool signed)
+ {
+ var pop = PopVariant();
+ var push = new IntPtrVariant();
+ long val;
+ var tc = pop.GetTypeCode();
+ if (tc == VariantBase.Vtc.Tc21Double || tc == VariantBase.Vtc.Tc8Float)
+ signed = true;
+ long maxVal = long.MaxValue, minVal = signed ? long.MinValue : 0;
+ if (IntPtr.Size == 4)
+ {
+ maxVal = signed ? Int32.MaxValue : UInt32.MaxValue;
+ minVal = signed ? Int32.MinValue : 0;
+ }
+ switch (tc)
+ {
+ case VariantBase.Vtc.Tc5Enum:
+ var v = VariantBase.SignedVariantFromEnum((EnumVariant)pop).GetValueAbstract();
+ if (IntPtr.Size == 4)
+ {
+ if (ovf) val = Convert.ToInt32(v);
+ else val = (int)Convert.ToInt64(v);
+ }
+ else
+ {
+ val = (signed || Marshal.SizeOf(v) > 4 || !ovf) ? Convert.ToInt64(v) :
+ (uint)(ulong)Convert.ToInt64(v);
+ }
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ int iv = ((IntVariant) pop).GetValue();
+ if (IntPtr.Size == 4 || signed)
+ val = iv;
+ else
+ val = (long)(uint)iv;
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ {
+ double dv = ((DoubleVariant)pop).GetValue();
+ if (dv <= maxVal && dv >= minVal)
+ val = (long)dv;
+ else
+ {
+ if (ovf) throw new OverflowException();
+ val = (IntPtr.Size == 4) ? Int32.MinValue : Int64.MinValue; // не мусор ли?
+ }
+ }
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ {
+ double dv = (double) ((FloatVariant) pop).GetValue();
+ if (dv <= maxVal && dv >= minVal)
+ val = (long) dv;
+ else
+ {
+ if (ovf) throw new OverflowException();
+ val = (IntPtr.Size == 4) ? Int32.MinValue : Int64.MinValue; // не мусор ли?
+ }
+ }
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ val = ((LongVariant)pop).GetValue();
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(IntPtr), new[] { typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(signed ? (ovf ? OpCodes.Conv_Ovf_I : OpCodes.Conv_I) : OpCodes.Conv_Ovf_I_Un);
+ gen.Emit(OpCodes.Ret);
+ push.SetValue(((IntPtr)dyn.Invoke(null, new[] { pop.GetValueAbstract() })));
+ PushVariant(push);
+ return;
+ }
+ if ((ovf == false) || (val <= maxVal && val >= minVal))
+ {
+ push.SetValue(new IntPtr((void*)val));
+ PushVariant(push);
+ } else throw new OverflowException();
+ }
+ private unsafe void Conv_u(bool ovf, bool signed)
+ {
+ var pop = PopVariant();
+ var push = new UIntPtrVariant();
+ ulong val, maxVal = (IntPtr.Size == 4) ? UInt32.MaxValue : UInt64.MaxValue;
+ var tc = pop.GetTypeCode();
+ switch (tc)
+ {
+ case VariantBase.Vtc.Tc5Enum:
+ var v = VariantBase.SignedVariantFromEnum((EnumVariant)pop).GetValueAbstract();
+ if (IntPtr.Size == 4)
+ {
+ if (ovf) val = signed ?
+ Convert.ToUInt64(v) :
+ (Marshal.SizeOf(v) > 4) ? (ulong)Convert.ToInt64(v) : (uint)Convert.ToInt32(v);
+ else val = (uint)Convert.ToInt64(v);
+ }
+ else
+ {
+ val = (Marshal.SizeOf(v) > 4) ?
+ ((ovf && signed) ? Convert.ToUInt64(Convert.ToInt64(v)) : (ulong)Convert.ToInt64(v)) :
+ ((ovf && signed) ? Convert.ToUInt32(Convert.ToInt32(v)) : (uint)Convert.ToInt32(v));
+ }
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ int iv = ((IntVariant)pop).GetValue();
+ if (ovf && signed && iv < 0) throw new OverflowException();
+ val = (uint)iv;
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ {
+ double dv = ((DoubleVariant)pop).GetValue();
+ if (ovf && signed && dv < 0) throw new OverflowException();
+ if (dv <= maxVal && (signed || dv >= 0))
+ val = (ulong)dv;
+ else
+ {
+ if (ovf) throw new OverflowException();
+ val = 0; // мусор, индульгируем
+ }
+ }
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ {
+ double dv = (double)((FloatVariant)pop).GetValue();
+ if (ovf && signed && dv < 0) throw new OverflowException();
+ if (dv <= maxVal && (signed || dv >= 0))
+ val = (ulong)dv;
+ else
+ {
+ if (ovf) throw new OverflowException();
+ val = 0; // мусор, индульгируем
+ }
+ }
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ long lv = ((LongVariant)pop).GetValue();
+ if (ovf && signed && lv < 0) throw new OverflowException();
+ val = (ulong) lv;
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(UIntPtr), new[] { typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(signed ? (ovf ? OpCodes.Conv_Ovf_U : OpCodes.Conv_U) : OpCodes.Conv_Ovf_U_Un);
+ gen.Emit(OpCodes.Ret);
+ push.SetValue(((UIntPtr)dyn.Invoke(null, new[] { pop.GetValueAbstract() })));
+ PushVariant(push);
+ return;
+ }
+ if ((ovf == false) || (val <= maxVal))
+ {
+ push.SetValue(new UIntPtr((void*)val));
+ PushVariant(push);
+ }
+ else throw new OverflowException();
+ }
+
+ private void Conv_u8(bool ovf, bool signed)
+ {
+ var pop = PopVariant();
+ ulong val;
+ switch (pop.GetTypeCode())
+ {
+ case VariantBase.Vtc.Tc5Enum:
+ var v = VariantBase.SignedVariantFromEnum((EnumVariant)pop).GetValueAbstract();
+ if(ovf && signed)
+ val = Convert.ToUInt64(v);
+ else
+ if (Marshal.SizeOf(v) > 4)
+ val = (ulong)Convert.ToInt64(v);
+ else
+ val = (uint)(ulong)Convert.ToInt64(v);
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ int iv = ((IntVariant)pop).GetValue();
+ val = ovf ? (signed ? checked((uint)iv) : (uint)iv) : (uint)iv;
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ if (ovf)
+ {
+ val = checked((ulong)((DoubleVariant)pop).GetValue());
+ break;
+ }
+ val = (ulong)((DoubleVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ if (ovf)
+ {
+ val = checked((ulong)((FloatVariant)pop).GetValue());
+ break;
+ }
+ val = (ulong)((FloatVariant)pop).GetValue();
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ if (ovf && signed)
+ val = Convert.ToUInt64(((LongVariant)pop).GetValue());
+ else
+ val = (ulong)((LongVariant)pop).GetValue();
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(ulong), new[] { typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(signed ? (ovf ? OpCodes.Conv_Ovf_U8 : OpCodes.Conv_U8) : OpCodes.Conv_Ovf_U8_Un);
+ gen.Emit(OpCodes.Ret);
+ val = (ulong)dyn.Invoke(null, new[] { pop.GetValueAbstract() });
+ break;
+ }
+ var push = new UlongVariant();
+ push.SetValue(val);
+ PushVariant(push);
+ }
+
+ // Token: 0x06000204 RID: 516 RVA: 0x0000C19C File Offset: 0x0000A39C
+ private void Conv_u8_(VariantBase dummy) // \u0003\u2005
+ {
+ Conv_u8(false, true);
+ }
+
+ // Token: 0x0600020E RID: 526 RVA: 0x0000C58C File Offset: 0x0000A78C
+ private void Conv_ovf_u8_(VariantBase dummy) // \u0008\u2008\u2000
+ {
+ Conv_u8(true, true);
+ }
+
+ // Token: 0x06000208 RID: 520 RVA: 0x0000C43C File Offset: 0x0000A63C
+ private void Conv_ovf_i1_un_(VariantBase dummy) // \u0008
+ {
+ Conv_i1(true, false);
+ }
+
+ private void Conv_ovf_u1_un_(VariantBase dummy)
+ {
+ Conv_u1(true, false);
+ }
+
+ // Token: 0x060001BB RID: 443 RVA: 0x000094E0 File Offset: 0x000076E0
+ private void _u0006u2003u2001(VariantBase dummy) // \u0006\u2003\u2001
+ {
+ }
+
+ // Token: 0x060001BC RID: 444 RVA: 0x000094E4 File Offset: 0x000076E4
+ private VariantBase[] CreateLocalVariables() // u0002
+ {
+ var array = _methodHeader.LocalVarTypes;
+ var num = array.Length;
+ var ret = new VariantBase[num];
+ for (var i = 0; i < num; i++)
+ {
+ ret[i] = VariantFactory.Convert(null, GetTypeById(array[i].TypeId));
+ }
+ return ret;
+ }
+
+ // Token: 0x060001C0 RID: 448 RVA: 0x0000958C File Offset: 0x0000778C
+ private MethodBase FindGenericMethod(VmMethodTokenInfo what) // \u0002
+ {
+ var type = GetTypeById(what.Class.MetadataToken);
+ var bindingAttr = BF(what.IsStatic());
+ var arg_32_0 = type.GetMember(what.Name, bindingAttr);
+ var array = arg_32_0;
+ var methodInfo = (from MethodInfo methodInfo2 in array
+ where methodInfo2.IsGenericMethodDefinition
+ let parameters = methodInfo2.GetParameters()
+ where
+ parameters.Length == what.Parameters.Length &&
+ methodInfo2.GetGenericArguments().Length == what.GenericArguments.Length &&
+ AreCompatible(methodInfo2.ReturnType, what.ReturnType)
+ where !parameters.Where((t1, j) => !AreCompatible(t1.ParameterType, what.Parameters[j])).Any()
+ select methodInfo2).FirstOrDefault();
+ if (methodInfo == null)
+ {
+ throw new Exception(string.Format(StringDecryptor.GetString(-1550347247) /* Cannot bind method: {0}.{1} */, type.Name, what.Name));
+ }
+ var array2 = new Type[what.GenericArguments.Length];
+ for (var k = 0; k < array2.Length; k++)
+ {
+ array2[k] = GetTypeById(what.GenericArguments[k].MetadataToken);
+ }
+ return methodInfo.MakeGenericMethod(array2);
+ }
+
+ // Token: 0x060001C2 RID: 450 RVA: 0x000097A0 File Offset: 0x000079A0
+ private bool InvokeFilter(MethodBase mb, object obj, ref object result, object[] args) // \u0002
+ {
+ var declaringType = mb.DeclaringType;
+ if (declaringType == null)
+ {
+ return false;
+ }
+ if (SimpleTypeHelper.IsNullableGeneric(declaringType))
+ {
+ if (string.Equals(mb.Name, StringDecryptor.GetString(-1550345611) /* get_HasValue */, StringComparison.Ordinal))
+ {
+ result = obj != null;
+ }
+ else if (string.Equals(mb.Name, StringDecryptor.GetString(-1550345722) /* get_Value */, StringComparison.Ordinal))
+ {
+ if (obj == null)
+ {
+ //return ((bool?)null).Value;
+ throw new InvalidOperationException();
+ }
+ result = obj;
+ }
+ else if (mb.Name.Equals(StringDecryptor.GetString(-1550345706) /* GetValueOrDefault */, StringComparison.Ordinal))
+ {
+ if (obj == null)
+ {
+ /*u0005 =*/ Activator.CreateInstance(Nullable.GetUnderlyingType(mb.DeclaringType));
+ }
+ result = obj;
+ }
+ else
+ {
+ if (obj != null || mb.IsStatic)
+ {
+ return false;
+ }
+ result = null;
+ }
+ return true;
+ }
+ if (declaringType == SimpleTypeHelper.TypedReferenceType)
+ {
+ var name = mb.Name;
+ var i = args.Length;
+ if (i != 1)
+ {
+ if (i == 2)
+ {
+ if (name == StringDecryptor.GetString(-1550345495) /* SetTypedReference */)
+ {
+ TypedReference.SetTypedReference((TypedReference)args[0], args[1]);
+ return true;
+ }
+ }
+ }
+ else
+ {
+ if (name == StringDecryptor.GetString(-1550345682) /* GetTargetType */)
+ {
+ result = TypedReference.GetTargetType((TypedReference)args[0]);
+ return true;
+ }
+ if (name == StringDecryptor.GetString(-1550345534) /* TargetTypeToken */)
+ {
+ result = TypedReference.TargetTypeToken((TypedReference)args[0]);
+ return true;
+ }
+ if (name == StringDecryptor.GetString(-1550345512) /* ToObject */)
+ {
+ result = TypedReference.ToObject((TypedReference)args[0]);
+ return true;
+ }
+ }
+ }
+ else if (declaringType == AssemblyType)
+ {
+ if (_callees != null && mb.Name == StringDecryptor.GetString(-1550345599) /* GetCallingAssembly */)
+ {
+ var array = _callees;
+ foreach (var t in array)
+ {
+ var assembly = t as Assembly;
+ if (assembly != null)
+ {
+ result = assembly;
+ return true;
+ }
+ }
+ }
+ }
+ else if (declaringType == MethodBaseType)
+ {
+ if (mb.Name == StringDecryptor.GetString(-1550345576) /* GetCurrentMethod */)
+ {
+ if (_callees != null)
+ {
+ var array = _callees;
+ foreach (var t in array)
+ {
+ var methodBase = t as MethodBase;
+ if (methodBase != null)
+ {
+ result = methodBase;
+ return true;
+ }
+ }
+ }
+ result = MethodBase.GetCurrentMethod();
+ return true;
+ }
+ }
+ else if (declaringType.IsArray && declaringType.GetArrayRank() >= 2)
+ {
+ return RefToMdArrayItem(mb, obj, ref result, args);
+ }
+ return false;
+ }
+
+ // Token: 0x060001C3 RID: 451 RVA: 0x000099F8 File Offset: 0x00007BF8
+ private void Ldloca_s_(VariantBase vLocIdx) // \u0005\u2001\u2001
+ {
+ var push = new LocalsIdxHolderVariant();
+ push.SetValue(((ByteVariant)vLocIdx).GetValue());
+ PushVariant(push);
+ }
+
+ // Token: 0x060001C4 RID: 452 RVA: 0x00009A24 File Offset: 0x00007C24
+ private void Ldind_i_(VariantBase dummy) // \u000E\u2004\u2000
+ {
+ Ldind(IntPtrType);
+ }
+
+ // Token: 0x060001C6 RID: 454 RVA: 0x00009D14 File Offset: 0x00007F14
+ private void Stloc_(VariantBase vidx) // \u0008\u2006
+ {
+ var idx = (UshortVariant)vidx;
+ PopToLocal(idx.GetValue());
+ }
+
+ // Token: 0x060001C7 RID: 455 RVA: 0x00009D34 File Offset: 0x00007F34
+ private void Stfld_(VariantBase vFieldId) // \u0005\u200B
+ {
+ var fieldInfo = ResolveField(((IntVariant)vFieldId).GetValue());
+ var val = PopVariant();
+ var objRef = PopVariant();
+ var obj = objRef.IsAddr() ? FetchByAddr(objRef).GetValueAbstract() : objRef.GetValueAbstract();
+ if (obj == null)
+ {
+ throw new NullReferenceException();
+ }
+ fieldInfo.SetValue(obj, VariantFactory.Convert(val.GetValueAbstract(), fieldInfo.FieldType).GetValueAbstract());
+ if (objRef.IsAddr() && /*obj != null && */ obj.GetType().IsValueType)
+ {
+ AssignByReference(objRef, VariantFactory.Convert(obj, null));
+ }
+ }
+
+ // Token: 0x060001C8 RID: 456 RVA: 0x00009DD0 File Offset: 0x00007FD0
+ /*private void u000Fu2004(VariantBase dummy) // \u000F\u2004
+ {
+ }*/
+
+ // Token: 0x060001CB RID: 459 RVA: 0x00009E7C File Offset: 0x0000807C
+ private void Ldloc_s_(VariantBase vidx) // \u0002
+ {
+ var idx = (ByteVariant)vidx;
+ PushVariant(_localVariables[idx.GetValue()].Clone());
+ }
+
+ // Token: 0x060001D1 RID: 465 RVA: 0x0000A328 File Offset: 0x00008528
+ private void Stelem_ref_(VariantBase dummy) // \u0008\u200A
+ {
+ Stelem(SimpleTypeHelper.ObjectType);
+ }
+
+ // Token: 0x060001D3 RID: 467 RVA: 0x0000A34C File Offset: 0x0000854C
+ private void Ldelem_u2_(VariantBase dummy) // \u000E\u2003\u2001
+ {
+ Ldelem(typeof(ushort));
+ }
+
+ // Token: 0x060001D5 RID: 469 RVA: 0x0000A620 File Offset: 0x00008820
+ private void Stind_i4_(VariantBase dummy) // \u0006\u2003\u2000
+ {
+ Stind();
+ }
+
+ // Token: 0x060001D6 RID: 470 RVA: 0x0000A628 File Offset: 0x00008828
+ private void Stind_i8_(VariantBase dummy) // \u0003\u2002\u2000
+ {
+ Stind();
+ }
+
+ // Token: 0x060001DC RID: 476 RVA: 0x0000AAD8 File Offset: 0x00008CD8
+ private void Stelem_i8_(VariantBase dummy) // \u0002\u200B\u2000
+ {
+ var obj = PopVariant().GetValueAbstract();
+ var idx = PopLong();
+ var array = (Array)PopVariant().GetValueAbstract();
+ var elementType = array.GetType().GetElementType();
+ checked
+ {
+ if (elementType == typeof(long))
+ {
+ ((long[])array)[(int)(IntPtr)idx] = (long)VariantFactory.Convert(obj, typeof(long)).GetValueAbstract();
+ return;
+ }
+ if (elementType == typeof(ulong))
+ {
+ ((ulong[])array)[(int)(IntPtr)idx] = (ulong)VariantFactory.Convert(obj, typeof(ulong)).GetValueAbstract();
+ return;
+ }
+ if (elementType.IsEnum)
+ {
+ Stelem(elementType, obj, idx, array);
+ return;
+ }
+ Stelem(typeof(long), obj, idx, array);
+ }
+ }
+
+ // Token: 0x060001DD RID: 477 RVA: 0x0000ABA8 File Offset: 0x00008DA8
+ private void Stelem_i_(VariantBase dummy) // \u000F\u2006\u2000
+ {
+ Stelem(IntPtrType);
+ }
+
+ // Token: 0x060001DE RID: 478 RVA: 0x0000ABB8 File Offset: 0x00008DB8
+ private void Ldelem_i8_(VariantBase dummy) // \u0006\u2000
+ {
+ Ldelem(typeof(long));
+ }
+
+ // Token: 0x060001E0 RID: 480 RVA: 0x0000ABD0 File Offset: 0x00008DD0
+ private void Ldc_i4_(VariantBase val) // \u0006\u2000\u2000
+ {
+ PushVariant(val);
+ }
+
+ // Token: 0x060001E2 RID: 482 RVA: 0x0000AC08 File Offset: 0x00008E08
+ private void Ldarg_1_(VariantBase dummy) // \u0002\u2003\u2001
+ {
+ PushVariant(_variantOutputArgs[1].Clone());
+ }
+
+ // Token: 0x060001E3 RID: 483 RVA: 0x0000AC24 File Offset: 0x00008E24
+ private void Ret_(VariantBase dummy) // \u000E\u2005\u2000
+ {
+ Ret();
+ }
+
+ // Token: 0x060001E8 RID: 488 RVA: 0x0000B10C File Offset: 0x0000930C
+ private void Stelem(Type arrType, object val, long idx, Array array) // \u0002
+ {
+ array.SetValue(VariantFactory.Convert(val, arrType).GetValueAbstract(), idx);
+ }
+
+ // Token: 0x060001E9 RID: 489 RVA: 0x0000B130 File Offset: 0x00009330
+ [DebuggerNonUserCode]
+ private MethodBase FindMethodById(int methodId, UniversalTokenInfo methodToken) // \u0002
+ {
+ MethodBase result = null;
+ lock (AllMetadataById)
+ {
+ //var flag = true;
+ object obj;
+ if (/*flag &&*/ AllMetadataById.TryGetValue(methodId, out obj))
+ {
+ result = (MethodBase)obj;
+ }
+ else if (methodToken.IsVm == 0)
+ {
+ var methodBase = _module.ResolveMethod(methodToken.MetadataToken);
+ //if (flag)
+ {
+ AllMetadataById.Add(methodId, methodBase);
+ }
+ result = methodBase;
+ }
+ else
+ {
+ var mti = (VmMethodTokenInfo)methodToken.VmToken;
+ if (mti.IsGeneric())
+ {
+ result = FindGenericMethod(mti);
+ }
+ else
+ {
+ var clsType = GetTypeById(mti.Class.MetadataToken);
+ var retType = GetTypeById(mti.ReturnType.MetadataToken);
+ var paramArray = new Type[mti.Parameters.Length];
+ for (var i = 0; i < paramArray.Length; i++)
+ {
+ paramArray[i] = GetTypeById(mti.Parameters[i].MetadataToken);
+ }
+ /*if (type.IsGenericType)
+ {
+ flag = false;
+ }*/
+ if (mti.Name == StringDecryptor.GetString(-1550347259) /* .ctor */)
+ {
+ var constructor = clsType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, CallingConventions.Any, paramArray, null);
+ if (constructor == null)
+ {
+ throw new Exception();
+ }
+ if (!clsType.IsGenericType)
+ {
+ AllMetadataById.Add(methodId, constructor);
+ }
+ result = constructor;
+ }
+ else
+ {
+ var bindingAttr = BF(mti.IsStatic());
+ try
+ {
+ result = clsType.GetMethod(mti.Name, bindingAttr, null, CallingConventions.Any, paramArray, null);
+ }
+ catch (AmbiguousMatchException)
+ {
+ var methods = clsType.GetMethods(bindingAttr);
+ foreach (var methodInfo in methods)
+ {
+ if (methodInfo.Name == mti.Name && methodInfo.ReturnType == retType)
+ {
+ var parameters = methodInfo.GetParameters();
+ if (parameters.Length == paramArray.Length)
+ {
+ if (!(bool)paramArray.Where((t, k) => parameters[k].ParameterType != t).Any())
+ {
+ result = methodInfo;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (result == null)
+ {
+ throw new Exception(string.Format(StringDecryptor.GetString(-1550347247) /* Cannot bind method: {0}.{1} */, clsType.Name, mti.Name));
+ }
+ if (!clsType.IsGenericType)
+ {
+ AllMetadataById.Add(methodId, result);
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ // Token: 0x060001EA RID: 490 RVA: 0x0000B3B8 File Offset: 0x000095B8
+ private void Stloc_s_(VariantBase vidx) // \u000E\u2004
+ {
+ var idx = (ByteVariant)vidx;
+ PopToLocal(idx.GetValue());
+ }
+
+ // Token: 0x060001EB RID: 491 RVA: 0x0000B3D8 File Offset: 0x000095D8
+ private void LockIfInterlocked(ref BoolHolder wasLocked, MethodBase mb, bool dummy) // \u0002
+ {
+ if (mb.DeclaringType == typeof(Interlocked) && mb.IsStatic)
+ {
+ var name = mb.Name;
+ if (name == StringDecryptor.GetString(-1550347213) /* Add */ || name == StringDecryptor.GetString(-1550347203) /* CompareExchange */ || name == StringDecryptor.GetString(-1550347053) /* Decrement */ || name == StringDecryptor.GetString(-1550347037) /* Exchange */ || name == StringDecryptor.GetString(-1550347024) /* Increment */ || name == StringDecryptor.GetString(-1550347136) /* Read*/)
+ {
+ Monitor.Enter(InterlockedLock);
+ wasLocked.Val = true;
+ }
+ }
+ }
+
+ // Token: 0x060001EC RID: 492 RVA: 0x0000B4A0 File Offset: 0x000096A0
+ private void Box_(VariantBase vTypeId) // \u0003\u2009\u2000
+ {
+ var type = GetTypeById(((IntVariant)vTypeId).GetValue());
+ var push = VariantFactory.Convert(PopVariant().GetValueAbstract(), type);
+ push.SetVariantType(type);
+ PushVariant(push);
+ }
+
+ // Token: 0x060001F1 RID: 497 RVA: 0x0000B690 File Offset: 0x00009890
+ private void Sizeof_(VariantBase vTypeId) // \u000E\u2001\u2001
+ {
+ var t = GetTypeById(((IntVariant)vTypeId).GetValue());
+ var iv = new IntVariant();
+ iv.SetValue(Marshal.SizeOf(t));
+ PushVariant(iv);
+ }
+
+ // Token: 0x060001F3 RID: 499 RVA: 0x0000B758 File Offset: 0x00009958
+ private void Ldelem_i_(VariantBase dummy) // \u000F\u2000
+ {
+ Ldelem(IntPtrType);
+ }
+
+ // Token: 0x060001F4 RID: 500 RVA: 0x0000B768 File Offset: 0x00009968
+ private void InternalInvoke() // \u0002
+ {
+ try
+ {
+ LoopUntilRet();
+ }
+ catch (Exception ex)
+ {
+ OnException(ex, 0u);
+ LoopUntilRet();
+ }
+ }
+
+ // Token: 0x060001F5 RID: 501 RVA: 0x0000B7A0 File Offset: 0x000099A0
+ private MethodBase GenerateDynamicCall(MethodBase mb, bool mayVirtual) // \u0002
+ {
+ MethodBase result;
+ lock (DynamicMethods)
+ {
+ DynamicMethod dynamicMethod;
+ if (DynamicMethods.TryGetValue(mb, out dynamicMethod))
+ {
+ result = dynamicMethod;
+ }
+ else
+ {
+ var methodInfo = mb as MethodInfo;
+ var returnType = methodInfo?.ReturnType ?? VoidType;
+ var parameters = mb.GetParameters();
+ Type[] array;
+ if (mb.IsStatic)
+ {
+ array = new Type[parameters.Length];
+ for (var i = 0; i < parameters.Length; i++)
+ {
+ array[i] = parameters[i].ParameterType;
+ }
+ }
+ else
+ {
+ array = new Type[parameters.Length + 1];
+ var type = mb.DeclaringType;
+ if (type.IsValueType)
+ {
+ type = type.MakeByRefType();
+ mayVirtual = false;
+ }
+ array[0] = type;
+ for (var j = 0; j < parameters.Length; j++)
+ {
+ array[j + 1] = parameters[j].ParameterType;
+ }
+ }
+ /*if (_alwaysFalse)
+ {
+ dynamicMethod = new DynamicMethod(string.Empty, returnType, array, true);
+ }
+ if (dynamicMethod == null)*/
+ {
+ dynamicMethod = new DynamicMethod(string.Empty, returnType, array, GetTypeById(_methodHeader.ClassId), true);
+ }
+ var iLGenerator = dynamicMethod.GetILGenerator();
+ for (var k = 0; k < array.Length; k++)
+ {
+ iLGenerator.Emit(OpCodes.Ldarg, k);
+ }
+ var constructorInfo = mb as ConstructorInfo;
+ if (constructorInfo != null)
+ {
+ iLGenerator.Emit(mayVirtual ? OpCodes.Callvirt : OpCodes.Call, constructorInfo);
+ }
+ else
+ {
+ iLGenerator.Emit(mayVirtual ? OpCodes.Callvirt : OpCodes.Call, (MethodInfo)mb);
+ }
+ iLGenerator.Emit(OpCodes.Ret);
+ DynamicMethods.Add(mb, dynamicMethod);
+ result = dynamicMethod;
+ }
+ }
+ return result;
+ }
+
+ // Token: 0x060001F7 RID: 503 RVA: 0x0000B9EC File Offset: 0x00009BEC
+ private void Ldelem_i4_(VariantBase dummy) // \u000E\u2007
+ {
+ Ldelem(typeof(int));
+ }
+
+ // Token: 0x060001FD RID: 509 RVA: 0x0000BD88 File Offset: 0x00009F88
+ private void Invoke(int pos, Type[] methodGenericArgs, Type[] classGenericArgs, bool mayVirtual) // \u0002
+ {
+ _srcVirtualizedStreamReader.BaseStream.Seek(pos, SeekOrigin.Begin);
+ DoNothing(_srcVirtualizedStreamReader);
+ var u0006 = ReadMethodHeader(_srcVirtualizedStreamReader);
+ var num = u0006.ArgsTypeToOutput.Length;
+ var array = new object[num];
+ var array2 = new VariantBase[num];
+ if (_currentClass != null & mayVirtual)
+ {
+ var num2 = u0006.IsStatic() ? 0 : 1;
+ var array3 = new Type[num - num2];
+ for (var i = num - 1; i >= num2; i--)
+ {
+ array3[i] = GetTypeById(u0006.ArgsTypeToOutput[i].TypeId);
+ }
+ var method = _currentClass.GetMethod(u0006.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.GetProperty | BindingFlags.SetProperty, null, array3, null);
+ _currentClass = null;
+ if (method != null)
+ {
+ GenerateDynamicCall(method, true);
+ return;
+ }
+ }
+ for (var j = num - 1; j >= 0; j--)
+ {
+ var u000F = PopVariant();
+ array2[j] = u000F;
+ if (u000F.IsAddr())
+ {
+ u000F = FetchByAddr(u000F);
+ }
+ if (u000F.GetVariantType() != null)
+ {
+ u000F = VariantFactory.Convert(null, u000F.GetVariantType()).CopyFrom(u000F);
+ }
+ var u000F2 = VariantFactory.Convert(null, GetTypeById(u0006.ArgsTypeToOutput[j].TypeId)).CopyFrom(u000F);
+ array[j] = u000F2.GetValueAbstract();
+ if (j == 0 & mayVirtual && !u0006.IsStatic() && array[j] == null)
+ {
+ throw new NullReferenceException();
+ }
+ }
+ var executor = new VmExecutor(_instrCodesDb);
+ var callees = new object[]
+ {
+ _module.Assembly
+ };
+ object obj;
+ try
+ {
+ obj = executor.Invoke(_srcVirtualizedStream, pos, array, methodGenericArgs, classGenericArgs, callees);
+ }
+ finally
+ {
+ for (var k = 0; k < array2.Length; k++)
+ {
+ var u000F3 = array2[k];
+ if (u000F3.IsAddr())
+ {
+ var obj2 = array[k];
+ AssignByReference(u000F3, VariantFactory.Convert(obj2, null));
+ }
+ }
+ }
+ var type = executor.GetTypeById(executor._methodHeader.ReturnTypeId);
+ if (type != VoidType)
+ {
+ PushVariant(VariantFactory.Convert(obj, type));
+ }
+ }
+
+ // Token: 0x06000202 RID: 514 RVA: 0x0000C150 File Offset: 0x0000A350
+ public static object CreateValueTypeInstance(Type t) // \u0002
+ {
+ if (t.IsValueType)
+ {
+ return Activator.CreateInstance(t);
+ }
+ return null;
+ }
+
+ // Token: 0x0600020B RID: 523 RVA: 0x0000C51C File Offset: 0x0000A71C
+ private void Ldc_r4_(VariantBase val) // \u0003\u200B\u2000
+ {
+ PushVariant(val);
+ }
+
+ // Token: 0x0600020D RID: 525 RVA: 0x0000C550 File Offset: 0x0000A750
+ private void Stelem(Type t) // \u0003
+ {
+ var obj = PopVariant().GetValueAbstract();
+ var idx = PopLong();
+ var array = (Array)PopVariant().GetValueAbstract();
+ Stelem(t, obj, idx, array);
+ }
+
+ // Token: 0x06000210 RID: 528 RVA: 0x0000C5C4 File Offset: 0x0000A7C4
+ private void Ldvirtftn_(VariantBase vMethodId) // \u0003\u200A
+ {
+ var methodBase = FindMethodById(((IntVariant)vMethodId).GetValue());
+ var declaringType = methodBase.DeclaringType;
+ var type = PopVariant().GetValueAbstract().GetType();
+ var parameters = methodBase.GetParameters();
+ var paramTypes = new Type[parameters.Length];
+ for (var i = 0; i < parameters.Length; i++)
+ {
+ paramTypes[i] = parameters[i].ParameterType;
+ }
+ while (type != null && type != declaringType)
+ {
+ var method = type.GetMethod(methodBase.Name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetProperty | BindingFlags.SetProperty | BindingFlags.ExactBinding, null, CallingConventions.Any, paramTypes, null);
+ if (method != null && method.GetBaseDefinition() == methodBase)
+ {
+ methodBase = method;
+ break;
+ }
+ type = type.BaseType;
+ }
+ var push = new MethodVariant();
+ push.SetValue(methodBase);
+ PushVariant(push);
+ }
+
+ // Token: 0x06000213 RID: 531 RVA: 0x0000C750 File Offset: 0x0000A950
+ private void Ldind_u4_(VariantBase dummy) // \u000E\u2002\u2001
+ {
+ Ldind(typeof(uint));
+ }
+
+ // Token: 0x06000218 RID: 536 RVA: 0x0000C810 File Offset: 0x0000AA10
+ private void Ldind_i2_(VariantBase dummy) // \u0003\u2002\u2001
+ {
+ Ldind(typeof(short));
+ }
+
+ // Token: 0x0600021A RID: 538 RVA: 0x0000C830 File Offset: 0x0000AA30
+ private void Ldind_u2_(VariantBase dummy) // \u000F\u2001\u2001
+ {
+ Ldind(typeof(ushort));
+ }
+
+ // Token: 0x0600021B RID: 539 RVA: 0x0000C844 File Offset: 0x0000AA44
+ private void Break_(VariantBase dummy) // \u0005\u2002
+ {
+ Debugger.Break();
+ }
+
+ // Token: 0x0600021D RID: 541 RVA: 0x0000C878 File Offset: 0x0000AA78
+ private void Ldc_i4_m1_(VariantBase dummy) // \u0002\u2005
+ {
+ var iv = new IntVariant();
+ iv.SetValue(-1);
+ PushVariant(iv);
+ }
+
+ // Token: 0x0600021E RID: 542 RVA: 0x0000C88C File Offset: 0x0000AA8C
+ private void ExecuteNextInstruction() // \u0002\u2000
+ {
+ try
+ {
+ TryExecuteNextInstruction();
+ }
+ catch (Exception ex)
+ {
+ OnException(ex, 0u);
+ }
+ }
+
+ // Token: 0x06000220 RID: 544 RVA: 0x0000F07C File Offset: 0x0000D27C
+ private void OnException(object ex, uint pos) // \u0002
+ {
+ _wasException = ex != null;
+ _exception = ex;
+ if (_wasException)
+ {
+ _ehStack.Clear();
+ }
+ if (!_wasException)
+ {
+ _ehStack.PushBack(new ExcHandlerFrame { Pos = pos });
+ }
+ foreach (var catchBlock in _catchBlocks)
+ {
+ if (PosInRange(_myBufferPos, catchBlock.Start, catchBlock.Len))
+ {
+ switch (catchBlock.Kind)
+ {
+ case 0:
+ if (_wasException)
+ {
+ var type = ex.GetType();
+ var type2 = GetTypeById(catchBlock.ExcTypeId);
+ if (type == type2 || type.IsSubclassOf(type2))
+ {
+ _ehStack.PushBack(new ExcHandlerFrame
+ {
+ Pos = catchBlock.Pos,
+ Exception = ex
+ });
+ _wasException = false;
+ }
+ }
+ break;
+ case 1:
+ if (_wasException)
+ {
+ _ehStack.PushBack(new ExcHandlerFrame { Pos = catchBlock.Pos });
+ }
+ break;
+ case 2:
+ if (_wasException || !PosInRange((long)(ulong)pos, catchBlock.Start, catchBlock.Len))
+ {
+ _ehStack.PushBack(new ExcHandlerFrame { Pos = catchBlock.Pos });
+ }
+ break;
+ case 4:
+ if (_wasException)
+ {
+ _ehStack.PushBack(new ExcHandlerFrame
+ {
+ Pos = catchBlock.PosKind4,
+ Exception = ex
+ });
+ }
+ break;
+ }
+ }
+ }
+ ExecuteExceptionHandler();
+ }
+
+ // Token: 0x06000221 RID: 545 RVA: 0x0000F210 File Offset: 0x0000D410
+ private void Stloc_0_(VariantBase dummy) // \u0008\u2003
+ {
+ PopToLocal(0);
+ }
+
+ // Token: 0x06000222 RID: 546 RVA: 0x0000F21C File Offset: 0x0000D41C
+ private void Ldind_ref_(VariantBase dummy) // \u0003\u2003\u2001
+ {
+ Ldind(SimpleTypeHelper.ObjectType);
+ }
+
+ // Token: 0x06000223 RID: 547 RVA: 0x0000F22C File Offset: 0x0000D42C
+ private void Stind_r4_(VariantBase dummy) // \u0006\u2006
+ {
+ Stind();
+ }
+
+ // Token: 0x06000224 RID: 548 RVA: 0x0000F234 File Offset: 0x0000D434
+ private void Newarr_(VariantBase vTypeId) // \u0002\u2001\u2001
+ {
+ var vLength = PopVariant();
+ var ivLength = vLength as IntVariant;
+ int length;
+ if (ivLength != null)
+ {
+ length = ivLength.GetValue();
+ }
+ else
+ {
+ var ipvLength = vLength as IntPtrVariant;
+ if (ipvLength != null)
+ {
+ length = ipvLength.GetValue().ToInt32();
+ }
+ else
+ {
+ var uipvLength = vLength as UIntPtrVariant;
+ if (uipvLength == null)
+ {
+ throw new Exception();
+ }
+ length = (int)uipvLength.GetValue().ToUInt32();
+ }
+ }
+ var array = Array.CreateInstance(GetTypeById(((IntVariant)vTypeId).GetValue()), length);
+ var push = new ArrayVariant();
+ push.SetValue(array);
+ PushVariant(push);
+ }
+
+ // Token: 0x06000226 RID: 550 RVA: 0x0000F308 File Offset: 0x0000D508
+ private bool RefToMdArrayItem(MethodBase mb, object array, ref object result, object[] oidxs) // \u0003
+ {
+ if (!mb.IsStatic && mb.Name == StringDecryptor.GetString(-1550345964) /* Address */)
+ {
+ var methodInfo = mb as MethodInfo;
+ if (methodInfo != null)
+ {
+ var type = methodInfo.ReturnType;
+ if (type.IsByRef)
+ {
+ type = type.GetElementType();
+ var num = oidxs.Length;
+ if (num >= 1 && oidxs[0] is int)
+ {
+ var idxs = new int[num];
+ for (var i = 0; i < num; i++)
+ {
+ idxs[i] = (int)oidxs[i];
+ }
+ var val = new MdArrayValueVariant();
+ val.SetArray((Array)array);
+ val.SetIndexes(idxs);
+ val.SetHeldType(type);
+ result = val;
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ // Token: 0x0600022C RID: 556 RVA: 0x0000F86C File Offset: 0x0000DA6C
+ private void Stelem_r4_(VariantBase dummy) // \u0005\u200A
+ {
+ Stelem(typeof(float));
+ }
+
+ // Token: 0x0600022E RID: 558 RVA: 0x0000F8AC File Offset: 0x0000DAAC
+ private void Ldarg_2_(VariantBase dummy) // \u0006\u2003
+ {
+ PushVariant(_variantOutputArgs[2].Clone());
+ }
+
+ // Token: 0x06000230 RID: 560 RVA: 0x0000F8DC File Offset: 0x0000DADC
+ private void Not_(VariantBase dummy) // \u0008\u2002\u2001
+ {
+ PushVariant(Not(PopVariant()));
+ }
+
+ // Token: 0x06000232 RID: 562 RVA: 0x0000F914 File Offset: 0x0000DB14
+ private void Ldind_i1_(VariantBase dummy) // \u000F\u2005\u2000
+ {
+ Ldind(typeof(sbyte));
+ }
+
+ // Token: 0x06000233 RID: 563 RVA: 0x0000F928 File Offset: 0x0000DB28
+ private void Stloc_2_(VariantBase dummy) // \u000F\u2009
+ {
+ PopToLocal(2);
+ }
+
+ // Token: 0x06000235 RID: 565 RVA: 0x0000F96C File Offset: 0x0000DB6C
+ private void Stloc_1_(VariantBase dummy) // \u000E\u2009\u2000
+ {
+ PopToLocal(1);
+ }
+
+ // Token: 0x06000236 RID: 566 RVA: 0x0000F978 File Offset: 0x0000DB78
+ private void Pop_(VariantBase dummy) // \u0003
+ {
+ PopVariant();
+ }
+
+ // Token: 0x0600023A RID: 570 RVA: 0x0000F9D4 File Offset: 0x0000DBD4
+ private void Ldc_r8_(VariantBase val) // \u0005\u200B\u2000
+ {
+ PushVariant(val);
+ }
+
+ // Token: 0x0600023F RID: 575 RVA: 0x0000FDF4 File Offset: 0x0000DFF4
+ private void Ldelem_r4_(VariantBase dummy) // \u0008\u200B
+ {
+ Ldelem(typeof(float));
+ }
+
+ // Token: 0x06000240 RID: 576 RVA: 0x0000FE08 File Offset: 0x0000E008
+ private void UnlockInterlockedIfAny(ref BoolHolder wasLocked) // \u0002
+ {
+ if (wasLocked.Val)
+ {
+ Monitor.Exit(InterlockedLock);
+ }
+ }
+
+ // Token: 0x06000241 RID: 577 RVA: 0x0000FE1C File Offset: 0x0000E01C
+ private void Ldarg_0_(VariantBase dummy) // \u0003\u2007
+ {
+ PushVariant(_variantOutputArgs[0].Clone());
+ }
+
+ // Token: 0x06000245 RID: 581 RVA: 0x00010198 File Offset: 0x0000E398
+ private VariantBase Not(VariantBase val) // \u0005
+ {
+ switch (val.GetTypeCode())
+ {
+ case VariantBase.Vtc.Tc19Int:
+ var iv = new IntVariant();
+ iv.SetValue(~((IntVariant)val).GetValue());
+ return iv;
+ case VariantBase.Vtc.Tc24Long:
+ var lv = new LongVariant();
+ lv.SetValue(~((LongVariant)val).GetValue());
+ return lv;
+ case VariantBase.Vtc.Tc5Enum:
+ var underlyingType = Enum.GetUnderlyingType(val.GetValueAbstract().GetType());
+ if (underlyingType == typeof(ulong))
+ {
+ var ret = new UlongVariant();
+ ret.SetValue(~Convert.ToUInt64(val.GetValueAbstract()));
+ return ret;
+ }
+ if (underlyingType == typeof(long))
+ {
+ var ret = new LongVariant();
+ ret.SetValue(~Convert.ToInt64(val.GetValueAbstract()));
+ return ret;
+ }
+ if (underlyingType == typeof(uint))
+ {
+ var ret = new UintVariant();
+ ret.SetValue(~Convert.ToUInt32(val.GetValueAbstract()));
+ return ret;
+ }
+ var result = new IntVariant();
+ result.SetValue(~Convert.ToInt32(val.GetValueAbstract()));
+ return result;
+ case VariantBase.Vtc.Tc21Double:
+ if (IntPtr.Size == 4)
+ {
+ var ret = new DoubleVariant();
+ ret.SetValue(double.NaN);
+ return ret;
+ }
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ if (IntPtr.Size == 4)
+ {
+ var ret = new FloatVariant();
+ ret.SetValue(float.NaN);
+ return ret;
+ }
+ break;
+ case VariantBase.Vtc.Tc18Object:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(IntPtr), new[] { typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(OpCodes.Not);
+ gen.Emit(OpCodes.Ret);
+ var oret = new IntPtrVariant();
+ ((IntPtrVariant)oret).SetValue(((IntPtr)dyn.Invoke(null, new[] { val.GetValueAbstract() })));
+ return oret;
+ }
+ throw new InvalidProgramException();
+ }
+
+ // Token: 0x06000246 RID: 582 RVA: 0x0001025C File Offset: 0x0000E45C
+ private void Ldind_i8_(VariantBase dummy) // \u0005\u2006
+ {
+ Ldind(typeof(long));
+ }
+
+ // Token: 0x06000247 RID: 583 RVA: 0x00010270 File Offset: 0x0000E470
+ private void Clt_(VariantBase dummy) // \u0002\u2004\u2001
+ {
+ var v2 = PopVariant();
+ var v1 = PopVariant();
+ var push = new IntVariant();
+ push.SetValue(UniCompare(v1, v2, ComparisonKind.LT, false) ? 1 : 0);
+ PushVariant(push);
+ }
+
+ // Token: 0x06000249 RID: 585 RVA: 0x00010348 File Offset: 0x0000E548
+ private void Nop_(VariantBase dummy) // \u0005\u2005
+ {
+ }
+
+ // Token: 0x0600024B RID: 587 RVA: 0x00010498 File Offset: 0x0000E698
+ private void TryExecuteNextInstruction() // \u000E
+ {
+ var key = _myBufferReader.ReadInt32();
+ VmInstr instr;
+ if (!_vmInstrDb.TryGetValue(key, out instr))
+ {
+ throw new InvalidOperationException(StringDecryptor.GetString(-1550345644) /* Unsupported instruction. */);
+ }
+ instr.Func(ReadOperand(_myBufferReader, instr.Id.OperandType));
+ _myBufferPos = _myBufferReader.GetBuffer().GetPos();
+ }
+
+ // Token: 0x0600024E RID: 590 RVA: 0x000105B4 File Offset: 0x0000E7B4
+ private void Stelem_i1_(VariantBase dummy) // \u0002\u2003
+ {
+ var obj = PopVariant().GetValueAbstract();
+ var idx = PopLong();
+ var array = (Array)PopVariant().GetValueAbstract();
+ var elementType = array.GetType().GetElementType();
+ checked
+ {
+ if (elementType == typeof(sbyte))
+ {
+ ((sbyte[])array)[(int)(IntPtr)idx] = (sbyte)VariantFactory.Convert(obj, typeof(sbyte)).GetValueAbstract();
+ return;
+ }
+ if (elementType == typeof(byte))
+ {
+ ((byte[])array)[(int)(IntPtr)idx] = (byte)VariantFactory.Convert(obj, typeof(byte)).GetValueAbstract();
+ return;
+ }
+ if (elementType == typeof(bool))
+ {
+ ((bool[])array)[(int)(IntPtr)idx] = (bool)VariantFactory.Convert(obj, typeof(bool)).GetValueAbstract();
+ return;
+ }
+ if (elementType.IsEnum)
+ {
+ Stelem(elementType, obj, idx, array);
+ return;
+ }
+ Stelem(typeof(sbyte), obj, idx, array);
+ }
+ }
+
+ // Token: 0x0600024F RID: 591 RVA: 0x000106B8 File Offset: 0x0000E8B8
+ private void Starg_s_(VariantBase vidx) // \u000E\u2007\u2000
+ {
+ var idx = (ByteVariant)vidx;
+ _variantOutputArgs[idx.GetValue()].CopyFrom(PopVariant());
+ }
+
+ // Token: 0x06000251 RID: 593 RVA: 0x00010748 File Offset: 0x0000E948
+ private void Ldlen_(VariantBase dummy) // \u000E\u200B\u2000
+ {
+ var array = (Array)PopVariant().GetValueAbstract();
+ var len = new IntVariant();
+ len.SetValue(array.Length);
+ PushVariant(len);
+ }
+
+ // Token: 0x06000256 RID: 598 RVA: 0x00010948 File Offset: 0x0000EB48
+ private void Ldelem_i2_(VariantBase dummy) // \u0008\u2000
+ {
+ Ldelem(typeof(short));
+ }
+
+ // Token: 0x06000257 RID: 599 RVA: 0x0001095C File Offset: 0x0000EB5C
+ private void Ldarg_(VariantBase vidx) // \u000E\u2000\u2000
+ {
+ var idx = (UshortVariant)vidx;
+ PushVariant(_variantOutputArgs[idx.GetValue()].Clone());
+ }
+
+ // Token: 0x06000258 RID: 600 RVA: 0x0001098C File Offset: 0x0000EB8C
+ private void Clt_un_(VariantBase dummy) // \u0003\u2000\u2001
+ {
+ var v2 = PopVariant();
+ var v1 = PopVariant();
+ var push = new IntVariant();
+ push.SetValue(UniCompare(v1, v2, ComparisonKind.LT, true) ? 1 : 0);
+ PushVariant(push);
+ }
+
+ // Token: 0x06000259 RID: 601 RVA: 0x000109C8 File Offset: 0x0000EBC8
+ private void Dup_(VariantBase dummy) // \u0002\u2006\u2000
+ {
+ var v = PopVariant();
+ PushVariant(v);
+ PushVariant(v.Clone());
+ }
+
+ // Token: 0x0600025A RID: 602 RVA: 0x000109F4 File Offset: 0x0000EBF4
+ [Conditional("DEBUG")]
+ private void DoNothing(object dummy) // \u0002
+ {
+ }
+
+ // Token: 0x0600025B RID: 603 RVA: 0x000109F8 File Offset: 0x0000EBF8
+ private VariantBase[] ArgsToVariantOutputArgs(object[] args) // u0002
+ {
+ var methodHeaderArgsTypeToOutput = _methodHeader.ArgsTypeToOutput;
+ var num = methodHeaderArgsTypeToOutput.Length;
+ var retArgs = new VariantBase[num];
+ for (var i = 0; i < num; i++)
+ {
+ var obj = args[i];
+ var type = GetTypeById(methodHeaderArgsTypeToOutput[i].TypeId);
+ var type2 = ElementedTypeHelper.TryGoToPointerOrReferenceElementType(type);
+ Type type3;
+ if (type2 == SimpleTypeHelper.ObjectType || SimpleTypeHelper.IsNullableGeneric(type2))
+ {
+ type3 = type;
+ }
+ else
+ {
+ type3 = obj?.GetType() ?? type;
+ }
+ if (obj != null && !type.IsAssignableFrom(type3) && type.IsByRef && !type.GetElementType().IsAssignableFrom(type3))
+ {
+ throw new ArgumentException(string.Format(StringDecryptor.GetString(-1550345390) /* Object of type {0} cannot be converted to type {1}. */, type3, type));
+ }
+ retArgs[i] = VariantFactory.Convert(obj, type3);
+ }
+ if (!_methodHeader.IsStatic() && GetTypeById(_methodHeader.ClassId).IsValueType)
+ {
+ var expr_EB = new VariantBaseHolder();
+ expr_EB.SetValue(retArgs[0]);
+ retArgs[0] = expr_EB;
+ }
+ for (var j = 0; j < num; j++)
+ {
+ if (methodHeaderArgsTypeToOutput[j].IsOutput)
+ {
+ var expr_116 = new VariantBaseHolder();
+ expr_116.SetValue(retArgs[j]);
+ retArgs[j] = expr_116;
+ }
+ }
+ return retArgs;
+ }
+
+ // Token: 0x0600025D RID: 605 RVA: 0x00010B3C File Offset: 0x0000ED3C
+ private void Stind() // \u0003
+ {
+ var v2 = PopVariant();
+ var v1 = PopVariant();
+ AssignByReference(v1, v2);
+ }
+
+ // Token: 0x0600025E RID: 606 RVA: 0x00010B60 File Offset: 0x0000ED60
+ private void Endfinally_(VariantBase dummy) // \u0005\u2000\u2001
+ {
+ ExecuteExceptionHandler();
+ }
+
+ // Token: 0x0600025F RID: 607 RVA: 0x00010B68 File Offset: 0x0000ED68
+ private bool PosInRange(long pos, uint start, uint len) // \u0002
+ {
+ return pos >= (long)(ulong)start && pos <= (long)(ulong)(start + len);
+ }
+
+ // Token: 0x06000260 RID: 608 RVA: 0x00010B7C File Offset: 0x0000ED7C
+ private bool IsCompatible(MethodBase mb) // \u0002
+ {
+ return mb.IsVirtual && GetTypeById(_methodHeader.ClassId).IsSubclassOf(mb.DeclaringType);
+ }
+
+ // Token: 0x06000263 RID: 611 RVA: 0x00010C00 File Offset: 0x0000EE00
+ private void Stelem_(VariantBase vTypeId) // \u0006\u2004\u2000
+ {
+ Stelem(GetTypeById(((IntVariant)vTypeId).GetValue()));
+ }
+
+ // Token: 0x06000265 RID: 613 RVA: 0x00010C40 File Offset: 0x0000EE40
+ private void Ldelem_u1_(VariantBase dummy) // \u0006\u2004
+ {
+ Ldelem(typeof(byte));
+ }
+
+ // Token: 0x06000267 RID: 615 RVA: 0x00010C80 File Offset: 0x0000EE80
+ private void Cgt_(VariantBase dummy) // \u0005\u2001\u2000
+ {
+ var v2 = PopVariant();
+ var v1 = PopVariant();
+ var push = new IntVariant();
+ push.SetValue(UniCompare(v1, v2, ComparisonKind.GT, false) ? 1 : 0);
+ PushVariant(push);
+ }
+
+ private VariantBase And(VariantBase org_v1, VariantBase org_v2)
+ {
+ VariantBase v1, v2;
+ var tc = CommonType(org_v1, org_v2, out v1, out v2, true);
+ VariantBase ret;
+ switch (tc)
+ {
+ case VariantBase.Vtc.Tc9Uint:
+ uint uv1 = ((UintVariant)v1).GetValue(), uv2 = ((UintVariant)v2).GetValue();
+ var uvret = new UintVariant();
+ ret = uvret;
+ uvret.SetValue(uv1 & uv2);
+ break;
+ case VariantBase.Vtc.Tc19Int:
+ int iv1 = ((IntVariant)v1).GetValue(), iv2 = ((IntVariant)v2).GetValue();
+ var ivret = new IntVariant();
+ ret = ivret;
+ ivret.SetValue(iv1 & iv2);
+ break;
+ case VariantBase.Vtc.Tc21Double:
+ {
+ /*double dv1 = ((DoubleVariant)v1).GetValue(), dv2 = ((DoubleVariant)v2).GetValue(); // естественный алгоритм
+ long lv1 = (dv1 < 0) ? (long)dv1 : (long)(ulong)dv1;
+ long lv2 = (dv2 < 0) ? (long)dv2 : (long)(ulong)dv2;
+ var dvret = new DoubleVariant();
+ ret = dvret;
+ var l64 = (ulong) lv1 & (ulong) lv2;
+ if (l64 >> 32 == UInt32.MaxValue) l64 &= UInt32.MaxValue;
+ dvret.SetValue(l64);*/
+ var dvret = new DoubleVariant();
+ ret = dvret;
+ dvret.SetValue((4 == IntPtr.Size) ? Double.NaN : (double)0); // иногда у фреймворка бывает мусор, но чаще эти значения...
+ }
+ break;
+ case VariantBase.Vtc.Tc8Float:
+ {
+ /*float fv1 = ((FloatVariant) v1).GetValue(), fv2 = ((FloatVariant) v2).GetValue(); // естественный алгоритм
+ long lv1 = (fv1 < 0) ? (long)fv1 : (long)(ulong)fv1;
+ long lv2 = (fv2 < 0) ? (long)fv2 : (long)(ulong)fv2;
+ var fvret = new FloatVariant();
+ ret = fvret;
+ var l64 = (ulong)lv1 & (ulong)lv2;
+ if (l64 >> 32 == UInt32.MaxValue) l64 &= UInt32.MaxValue;
+ fvret.SetValue(l64);*/
+ var fvret = new FloatVariant();
+ ret = fvret;
+ fvret.SetValue((4 == IntPtr.Size) ? float.NaN : (float)0.0); // иногда у фреймворка бывает мусор, но чаще эти значения...
+ }
+ break;
+ case VariantBase.Vtc.Tc24Long:
+ {
+ long lv1 = ((LongVariant)v1).GetValue(), lv2 = ((LongVariant)v2).GetValue();
+ var lvret = new LongVariant();
+ ret = lvret;
+ lvret.SetValue(lv1 & lv2);
+ }
+ break;
+ case VariantBase.Vtc.Tc7Ulong:
+ ulong ulv1 = ((UlongVariant)v1).GetValue(), ulv2 = ((UlongVariant)v2).GetValue();
+ var ulvret = new UlongVariant();
+ ret = ulvret;
+ ulvret.SetValue(ulv1 & ulv2);
+ break;
+ default:
+ // это нужно будет заменить на соотв. msil-код
+ var dyn = new DynamicMethod(String.Empty, typeof(IntPtr), new[] { typeof(object), typeof(object) }, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ gen.Emit(OpCodes.Ldarg_1);
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(OpCodes.And);
+ gen.Emit(OpCodes.Ret);
+ ret = new IntPtrVariant();
+ ((IntPtrVariant)ret).SetValue(((IntPtr)dyn.Invoke(null, new[] { org_v1.GetValueAbstract(), org_v2.GetValueAbstract() })));
+ break;
+ }
+ return ret;
+ }
+
+ // Token: 0x0600026E RID: 622 RVA: 0x000110D8 File Offset: 0x0000F2D8
+ private void Ldind(Type t) // \u0005
+ {
+ PushVariant(VariantFactory.Convert(FetchByAddr(PopVariant()).GetValueAbstract(), t));
+ }
+
+ // Token: 0x0600026F RID: 623 RVA: 0x00011104 File Offset: 0x0000F304
+ private void Starg_(VariantBase vidx) // \u000F\u2008\u2000
+ {
+ var idx = (UshortVariant)vidx;
+ _variantOutputArgs[idx.GetValue()].CopyFrom(PopVariant());
+ }
+
+ // Token: 0x06000270 RID: 624 RVA: 0x00011138 File Offset: 0x0000F338
+ private void Ret() // \u0008
+ {
+ _retFound = true;
+ }
+
+ // Token: 0x06000273 RID: 627 RVA: 0x00011480 File Offset: 0x0000F680
+ private void Stind_r8_(VariantBase dummy) // \u0005\u2004\u2000
+ {
+ Stind();
+ }
+
+ // Token: 0x06000275 RID: 629 RVA: 0x00011510 File Offset: 0x0000F710
+ private void Rethrow_(VariantBase dummy) // \u0003\u200A\u2000
+ {
+ if (_exception == null)
+ {
+ throw new InvalidOperationException();
+ }
+ _myBufferPos = _myBufferReader.GetBuffer().GetPos();
+ ThrowStoreCrossDomain(_exception);
+ }
+
+ // Token: 0x06000278 RID: 632 RVA: 0x00011838 File Offset: 0x0000FA38
+ private void Ldelem_u4_(VariantBase dummy) // \u0003\u2003
+ {
+ Ldelem(typeof(uint));
+ }
+
+ // Token: 0x0600027A RID: 634 RVA: 0x00011994 File Offset: 0x0000FB94
+ private void Invoke(VmMethodRefTokenInfo mref) // \u0002
+ {
+ //var arg_18_0 = (U0008U2007)U0003U2008.Get_u0005();
+ var methodBase = FindMethodById(mref.Pos, ReadToken(mref.Pos));
+ //methodBase.GetParameters();
+ var pos = mref.Flags;
+ var mayVirtual = (pos & 1073741824) != 0;
+ pos &= -1073741825;
+ var methodGenericArgs = _methodGenericArgs;
+ var classGenericArgs = _classGenericArgs;
+ try
+ {
+ _methodGenericArgs = methodBase is ConstructorInfo ? Type.EmptyTypes : methodBase.GetGenericArguments();
+ _classGenericArgs = methodBase.DeclaringType.GetGenericArguments();
+ Invoke(pos, _methodGenericArgs, _classGenericArgs, mayVirtual);
+ }
+ finally
+ {
+ _methodGenericArgs = methodGenericArgs;
+ _classGenericArgs = classGenericArgs;
+ }
+ }
+
+ // Token: 0x0600027B RID: 635 RVA: 0x00011A5C File Offset: 0x0000FC5C
+ private void Ldc_i8_(VariantBase val) // \u0006\u2007\u2000
+ {
+ PushVariant(val);
+ }
+
+ // Token: 0x0600027E RID: 638 RVA: 0x00011CB8 File Offset: 0x0000FEB8
+ private void Ldelem_r8_(VariantBase dummy) // \u000E\u2002\u2000
+ {
+ Ldelem(typeof(double));
+ }
+
+ // Token: 0x06000280 RID: 640 RVA: 0x00011DB4 File Offset: 0x0000FFB4
+ private void Stloc_3_(VariantBase dummy) // \u0003\u2004\u2000
+ {
+ PopToLocal(3);
+ }
+
+ // Token: 0x06000281 RID: 641 RVA: 0x00011DC0 File Offset: 0x0000FFC0
+ private void Ckfinite_(VariantBase dummy) // \u000F\u2003
+ {
+ var v = PopVariant();
+ if (v.GetTypeCode() == VariantBase.Vtc.Tc5Enum)
+ {
+ v = VariantBase.SignedVariantFromEnum((EnumVariant)v);
+ }
+ double val = double.NaN;
+ bool con = v.GetValueAbstract() is IConvertible;
+ if (con)
+ {
+ val = Convert.ToDouble(v.GetValueAbstract());
+ if (double.IsNaN(val) || double.IsInfinity(val))
+ {
+ throw new OverflowException(StringDecryptor.GetString(-1550347095) /* The value is not finite real number. */);
+ }
+ }
+ if (IsFloating(v))
+ {
+ PushVariant(v);
+ } else
+ {
+ var push = new DoubleVariant();
+ push.SetValue(val);
+ PushVariant(push);
+ }
+ }
+
+ // Token: 0x06000288 RID: 648 RVA: 0x00012170 File Offset: 0x00010370
+ private void Stind_ref_(VariantBase dummy) // \u0002\u2008
+ {
+ Stind();
+ }
+
+ // Token: 0x06000289 RID: 649 RVA: 0x00012178 File Offset: 0x00010378
+ private void PopToLocal(int idx) // \u0002
+ {
+ var pop = PopVariant();
+ if (pop is ReferenceVariantBase)
+ {
+ _localVariables[idx] = pop;
+ return;
+ }
+ _localVariables[idx].CopyFrom(pop);
+ }
+
+ // Token: 0x0600028B RID: 651 RVA: 0x00012260 File Offset: 0x00010460
+ private void Ldobj_(VariantBase vTypeId) // \u000E\u2008
+ {
+ var type = GetTypeById(((IntVariant)vTypeId).GetValue());
+ Ldind(type);
+ }
+
+ // Token: 0x0600028C RID: 652 RVA: 0x00012288 File Offset: 0x00010488
+ private void Ldloc_1_(VariantBase dummy) // \u0003\u2008\u2000
+ {
+ PushVariant(_localVariables[1].Clone());
+ }
+
+ // Token: 0x0600028E RID: 654 RVA: 0x00012348 File Offset: 0x00010548
+ private void Ldelem_i1_(VariantBase dummy) // \u0005\u2009\u2000
+ {
+ Ldelem(typeof(sbyte));
+ }
+
+ // Token: 0x06000290 RID: 656 RVA: 0x00012370 File Offset: 0x00010570
+ private void JumpToPos(uint val) // \u0002
+ {
+ _storedPos = val;
+ }
+
+ // Token: 0x06000291 RID: 657 RVA: 0x00012380 File Offset: 0x00010580
+ public void VoidInvoke(Stream virtualizedStream, string pos, object[] args) // \u0002
+ {
+ Invoke(virtualizedStream, pos, args);
+ }
+
+ // Token: 0x06000295 RID: 661 RVA: 0x00012420 File Offset: 0x00010620
+ private void _u0002u2002u2001(VariantBase dummy) // \u0002\u2002\u2001
+ {
+ }
+
+ // Token: 0x06000298 RID: 664 RVA: 0x00012590 File Offset: 0x00010790
+ private void LoopUntilRet() // \u0005\u2000
+ {
+ var usedSize = _myBufferReader.GetBuffer().UsedSize();
+ while (!_retFound)
+ {
+ if (_storedPos.HasValue)
+ {
+ _myBufferReader.GetBuffer().SetPos((long)(ulong)_storedPos.Value);
+ _storedPos = null;
+ }
+ ExecuteNextInstruction();
+ if (_myBufferReader.GetBuffer().GetPos() >= usedSize && !_storedPos.HasValue)
+ {
+ break;
+ }
+ }
+ }
+
+ // Token: 0x06000299 RID: 665 RVA: 0x00012614 File Offset: 0x00010814
+ private VmInstrInfo GetInstrById(int id) // \u0002
+ {
+ return _instrCodesDb.MyFieldsEnumerator().FirstOrDefault(current => current.Id == id);
+ }
+
+ // Token: 0x0600029A RID: 666 RVA: 0x00012670 File Offset: 0x00010870
+ private void Ldloc_(VariantBase val) // \u000F\u200A\u2000
+ {
+ PushVariant(_localVariables[((UshortVariant)val).GetValue()].Clone());
+ }
+
+ // Token: 0x0600029E RID: 670 RVA: 0x00012718 File Offset: 0x00010918
+ private bool Isinst(VariantBase obj, Type t) // \u0002
+ {
+ if (obj.GetValueAbstract() == null)
+ {
+ return true;
+ }
+ var type = obj.GetVariantType() ?? obj.GetValueAbstract().GetType();
+ if (type == t || t.IsAssignableFrom(type))
+ {
+ return true;
+ }
+ if (!type.IsValueType && !t.IsValueType && Marshal.IsComObject(obj.GetValueAbstract()))
+ {
+ IntPtr intPtr;
+ try
+ {
+ intPtr = Marshal.GetComInterfaceForObject(obj.GetValueAbstract(), t);
+ }
+ catch (InvalidCastException)
+ {
+ intPtr = IntPtr.Zero;
+ }
+ if (intPtr != IntPtr.Zero)
+ {
+ try
+ {
+ Marshal.Release(intPtr);
+ }
+ catch
+ {
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // Token: 0x0600029F RID: 671 RVA: 0x000127C4 File Offset: 0x000109C4
+ private void Ldind_r8_(VariantBase dummy) // \u000E\u2008\u2000
+ {
+ Ldind(typeof(double));
+ }
+
+ // Token: 0x060002A1 RID: 673 RVA: 0x00012870 File Offset: 0x00010A70
+ private void Stobj_(VariantBase dummy) // \u0005\u2009
+ {
+ Stind();
+ }
+
+ // Token: 0x060002A4 RID: 676 RVA: 0x00012A44 File Offset: 0x00010C44
+ private void Cgt_un_(VariantBase dummy) // \u0006\u2002
+ {
+ var v2 = PopVariant();
+ var v1 = PopVariant();
+ var push = new IntVariant();
+ push.SetValue(UniCompare(v1, v2, ComparisonKind.GT, true) ? 1 : 0);
+ PushVariant(push);
+ }
+
+ // Token: 0x060002A7 RID: 679 RVA: 0x00012CDC File Offset: 0x00010EDC
+ private bool AreCompatible(Type t1, UniversalTokenInfo ut2) // \u0002
+ {
+ var t2 = (VmClassTokenInfo)ut2.VmToken;
+ if (ElementedTypeHelper.TryGoToElementType(t1).IsGenericParameter)
+ {
+ return t2 == null || t2.IsOuterClassGeneric;
+ }
+ return TypeCompatibility.Check(t1, GetTypeById(ut2.MetadataToken));
+ }
+
+ // Token: 0x060002A9 RID: 681 RVA: 0x00012D38 File Offset: 0x00010F38
+ private void Ldloca_(VariantBase vLocIdx) // \u0006\u2005
+ {
+ var push = new LocalsIdxHolderVariant();
+ push.SetValue(((UshortVariant)vLocIdx).GetValue());
+ PushVariant(push);
+ }
+
+ // Token: 0x060002AA RID: 682 RVA: 0x00012D64 File Offset: 0x00010F64
+ private void Ldarg_3_(VariantBase dummy) // \u000E\u2009
+ {
+ PushVariant(_variantOutputArgs[3].Clone());
+ }
+
+ // Token: 0x060002AC RID: 684 RVA: 0x00012DB8 File Offset: 0x00010FB8
+ /*[Conditional("DEBUG")]
+ public static void DoNothing(string dummy) // \u0002
+ {
+ }*/
+
+ // Token: 0x0600021F RID: 543 RVA: 0x0000C8BC File Offset: 0x0000AABC
+ private Dictionary<int, VmInstr> CreateVmInstrDb() // \u0002
+ {
+ return new Dictionary<int, VmInstr>(256)
+ {
+ {
+ _instrCodesDb.Conv_ovf_i4_un_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_i4_un_, Conv_ovf_i4_un_)
+ },
+ {
+ _instrCodesDb.Shr_un_.Id,
+ new VmInstr(_instrCodesDb.Shr_un_, Shr_un_)
+ },
+ {
+ _instrCodesDb.Conv_i_.Id,
+ new VmInstr(_instrCodesDb.Conv_i_, Conv_i_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_i_un_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_i_un_, Conv_ovf_i_un_)
+ },
+ {
+ _instrCodesDb.Stelem_i_.Id,
+ new VmInstr(_instrCodesDb.Stelem_i_, Stelem_i_)
+ },
+ {
+ _instrCodesDb.Starg_s_.Id,
+ new VmInstr(_instrCodesDb.Starg_s_, Starg_s_)
+ },
+ {
+ _instrCodesDb.Sizeof_.Id,
+ new VmInstr(_instrCodesDb.Sizeof_, Sizeof_)
+ },
+ {
+ _instrCodesDb.Ldarg_s_.Id,
+ new VmInstr(_instrCodesDb.Ldarg_s_, Ldarg_s_)
+ },
+ {
+ _instrCodesDb.Stelem_i4_.Id,
+ new VmInstr(_instrCodesDb.Stelem_i4_, Stelem_i4_)
+ },
+ {
+ _instrCodesDb.Calli_.Id,
+ new VmInstr(_instrCodesDb.Calli_, Calli_)
+ },
+ {
+ _instrCodesDb.Ldc_i4_7_.Id,
+ new VmInstr(_instrCodesDb.Ldc_i4_7_, Ldc_i4_7_)
+ },
+ {
+ _instrCodesDb.Newobj_.Id,
+ new VmInstr(_instrCodesDb.Newobj_, Newobj_)
+ },
+ {
+ _instrCodesDb.Ldind_u4_.Id,
+ new VmInstr(_instrCodesDb.Ldind_u4_, Ldind_u4_)
+ },
+ {
+ _instrCodesDb.Cgt_un_.Id,
+ new VmInstr(_instrCodesDb.Cgt_un_, Cgt_un_)
+ },
+ {
+ _instrCodesDb.Conv_u1_.Id,
+ new VmInstr(_instrCodesDb.Conv_u1_, Conv_u1_)
+ },
+ {
+ _instrCodesDb.Ldelem_ref_.Id,
+ new VmInstr(_instrCodesDb.Ldelem_ref_, Ldelem_ref_)
+ },
+ {
+ _instrCodesDb.U0006U2008U2000.Id,
+ new VmInstr(_instrCodesDb.U0006U2008U2000, _u0002u2002u2001)
+ },
+ {
+ _instrCodesDb.Newarr_.Id,
+ new VmInstr(_instrCodesDb.Newarr_, Newarr_)
+ },
+ {
+ _instrCodesDb.Ldarga_s_.Id,
+ new VmInstr(_instrCodesDb.Ldarga_s_, Ldarga_s_)
+ },
+ {
+ _instrCodesDb.Bgt_.Id,
+ new VmInstr(_instrCodesDb.Bgt_, Bgt_)
+ },
+ {
+ _instrCodesDb.Ldflda_.Id,
+ new VmInstr(_instrCodesDb.Ldflda_, Ldflda_)
+ },
+ {
+ _instrCodesDb.Sub_.Id,
+ new VmInstr(_instrCodesDb.Sub_, Sub_)
+ },
+ {
+ _instrCodesDb.Endfilter_.Id,
+ new VmInstr(_instrCodesDb.Endfilter_, Endfilter_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_u_un_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_u_un_, Conv_ovf_u_un_)
+ },
+ {
+ _instrCodesDb.Ldc_i4_1_.Id,
+ new VmInstr(_instrCodesDb.Ldc_i4_1_, Ldc_i4_1_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_i_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_i_, Conv_ovf_i_)
+ },
+ {
+ _instrCodesDb.Add_ovf_.Id,
+ new VmInstr(_instrCodesDb.Add_ovf_, Add_ovf_)
+ },
+ {
+ _instrCodesDb.Ldftn_.Id,
+ new VmInstr(_instrCodesDb.Ldftn_, Ldftn_)
+ },
+ {
+ _instrCodesDb.Stfld_.Id,
+ new VmInstr(_instrCodesDb.Stfld_, Stfld_)
+ },
+ {
+ _instrCodesDb.Ldc_i4_5_.Id,
+ new VmInstr(_instrCodesDb.Ldc_i4_5_, Ldc_i4_5_)
+ },
+ {
+ _instrCodesDb.Xor_.Id,
+ new VmInstr(_instrCodesDb.Xor_, Xor_)
+ },
+ {
+ _instrCodesDb.Conv_u2_.Id,
+ new VmInstr(_instrCodesDb.Conv_u2_, Conv_u2_)
+ },
+ {
+ _instrCodesDb.Div_un_.Id,
+ new VmInstr(_instrCodesDb.Div_un_, Div_un_)
+ },
+ {
+ _instrCodesDb.Stloc_3_.Id,
+ new VmInstr(_instrCodesDb.Stloc_3_, Stloc_3_)
+ },
+ {
+ _instrCodesDb.Ret_.Id,
+ new VmInstr(_instrCodesDb.Ret_, Ret_)
+ },
+ {
+ _instrCodesDb.Ldc_i4_m1_.Id,
+ new VmInstr(_instrCodesDb.Ldc_i4_m1_, Ldc_i4_m1_)
+ },
+ {
+ _instrCodesDb.Ldarg_1_.Id,
+ new VmInstr(_instrCodesDb.Ldarg_1_, Ldarg_1_)
+ },
+ {
+ _instrCodesDb.Div_.Id,
+ new VmInstr(_instrCodesDb.Div_, Div_)
+ },
+ {
+ _instrCodesDb.Ldnull_.Id,
+ new VmInstr(_instrCodesDb.Ldnull_, Ldnull_)
+ },
+ {
+ _instrCodesDb.Break_.Id,
+ new VmInstr(_instrCodesDb.Break_, Break_)
+ },
+ {
+ _instrCodesDb.Cgt_.Id,
+ new VmInstr(_instrCodesDb.Cgt_, Cgt_)
+ },
+ {
+ _instrCodesDb.Arglist_.Id,
+ new VmInstr(_instrCodesDb.Arglist_, Arglist_)
+ },
+ {
+ _instrCodesDb.Ldloc_.Id,
+ new VmInstr(_instrCodesDb.Ldloc_, Ldloc_)
+ },
+ {
+ _instrCodesDb.Conv_u_.Id,
+ new VmInstr(_instrCodesDb.Conv_u_, Conv_u_)
+ },
+ {
+ _instrCodesDb.Ldelem_i_.Id,
+ new VmInstr(_instrCodesDb.Ldelem_i_, Ldelem_i_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_i1_un_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_i1_un_, Conv_ovf_i1_un_)
+ },
+ {
+ _instrCodesDb.Cpblk_.Id,
+ new VmInstr(_instrCodesDb.Cpblk_, Cpblk_)
+ },
+ {
+ _instrCodesDb.Add_.Id,
+ new VmInstr(_instrCodesDb.Add_, Add_)
+ },
+ {
+ _instrCodesDb.Initblk_.Id,
+ new VmInstr(_instrCodesDb.Initblk_, Initblk_)
+ },
+ {
+ _instrCodesDb.Ldind_i_.Id,
+ new VmInstr(_instrCodesDb.Ldind_i_, Ldind_i_)
+ },
+ {
+ _instrCodesDb.Ldelem_u4_.Id,
+ new VmInstr(_instrCodesDb.Ldelem_u4_, Ldelem_u4_)
+ },
+ {
+ _instrCodesDb.Stind_ref_.Id,
+ new VmInstr(_instrCodesDb.Stind_ref_, Stind_ref_)
+ },
+ {
+ _instrCodesDb.Ldelem_i1_.Id,
+ new VmInstr(_instrCodesDb.Ldelem_i1_, Ldelem_i1_)
+ },
+ {
+ _instrCodesDb.Ldloc_3_.Id,
+ new VmInstr(_instrCodesDb.Ldloc_3_, Ldloc_3_)
+ },
+ {
+ _instrCodesDb.Stind_i8_.Id,
+ new VmInstr(_instrCodesDb.Stind_i8_, Stind_i8_)
+ },
+ {
+ _instrCodesDb.Conv_i1_.Id,
+ new VmInstr(_instrCodesDb.Conv_i1_, Conv_i1_)
+ },
+ {
+ _instrCodesDb.Ldelem_.Id,
+ new VmInstr(_instrCodesDb.Ldelem_, Ldelem_)
+ },
+ {
+ _instrCodesDb.Clt_un_.Id,
+ new VmInstr(_instrCodesDb.Clt_un_, Clt_un_)
+ },
+ {
+ _instrCodesDb.Ldelem_i4_.Id,
+ new VmInstr(_instrCodesDb.Ldelem_i4_, Ldelem_i4_)
+ },
+ {
+ _instrCodesDb.Mkrefany_.Id,
+ new VmInstr(_instrCodesDb.Mkrefany_, Mkrefany_)
+ },
+ {
+ _instrCodesDb.Neg_.Id,
+ new VmInstr(_instrCodesDb.Neg_, Neg_)
+ },
+ {
+ _instrCodesDb.Leave_.Id,
+ new VmInstr(_instrCodesDb.Leave_, Leave_)
+ },
+ {
+ _instrCodesDb.Ldc_i4_2_.Id,
+ new VmInstr(_instrCodesDb.Ldc_i4_2_, Ldc_i4_2_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_i2_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_i2_, Conv_ovf_i2_)
+ },
+ {
+ _instrCodesDb.Ldloc_2_.Id,
+ new VmInstr(_instrCodesDb.Ldloc_2_, Ldloc_2_)
+ },
+ {
+ _instrCodesDb.Bgt_un_.Id,
+ new VmInstr(_instrCodesDb.Bgt_un_, Bgt_un_)
+ },
+ {
+ _instrCodesDb.Stsfld_.Id,
+ new VmInstr(_instrCodesDb.Stsfld_, Stsfld_)
+ },
+ /*{
+ _instrCodesDb.Nop_.Id,
+ new VmInstr(_instrCodesDb.Nop_, u000Fu2004)
+ },*/
+ {
+ _instrCodesDb.Shr_.Id,
+ new VmInstr(_instrCodesDb.Shr_, Shr_)
+ },
+ {
+ _instrCodesDb.Ldind_ref_.Id,
+ new VmInstr(_instrCodesDb.Ldind_ref_, Ldind_ref_)
+ },
+ {
+ _instrCodesDb.Ldfld_.Id,
+ new VmInstr(_instrCodesDb.Ldfld_, Ldfld_)
+ },
+ {
+ _instrCodesDb.Ldlen_.Id,
+ new VmInstr(_instrCodesDb.Ldlen_, Ldlen_)
+ },
+ {
+ _instrCodesDb.Stelem_ref_.Id,
+ new VmInstr(_instrCodesDb.Stelem_ref_, Stelem_ref_)
+ },
+ {
+ _instrCodesDb.Ceq_.Id,
+ new VmInstr(_instrCodesDb.Ceq_, Ceq_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_u2_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_u2_, Conv_ovf_u2_)
+ },
+ {
+ _instrCodesDb.Add_ovf_un_.Id,
+ new VmInstr(_instrCodesDb.Add_ovf_un_, Add_ovf_un_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_i8_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_i8_, Conv_ovf_i8_)
+ },
+ {
+ _instrCodesDb.Stind_i2_.Id,
+ new VmInstr(_instrCodesDb.Stind_i2_, Stind_i2_)
+ },
+ {
+ _instrCodesDb.Stelem_i1_.Id,
+ new VmInstr(_instrCodesDb.Stelem_i1_, Stelem_i1_)
+ },
+ {
+ _instrCodesDb.Ldloca_.Id,
+ new VmInstr(_instrCodesDb.Ldloca_, Ldloca_)
+ },
+ {
+ _instrCodesDb.Stind_r4_.Id,
+ new VmInstr(_instrCodesDb.Stind_r4_, Stind_r4_)
+ },
+ {
+ _instrCodesDb.Stloc_s_.Id,
+ new VmInstr(_instrCodesDb.Stloc_s_, Stloc_s_)
+ },
+ {
+ _instrCodesDb.Refanyval_.Id,
+ new VmInstr(_instrCodesDb.Refanyval_, Refanyval_)
+ },
+ {
+ _instrCodesDb.Clt_.Id,
+ new VmInstr(_instrCodesDb.Clt_, Clt_)
+ },
+ {
+ _instrCodesDb.Stelem_r4_.Id,
+ new VmInstr(_instrCodesDb.Stelem_r4_, Stelem_r4_)
+ },
+ {
+ _instrCodesDb.Stelem_r8_.Id,
+ new VmInstr(_instrCodesDb.Stelem_r8_, Stelem_r8_)
+ },
+ {
+ _instrCodesDb.Conv_u4_.Id,
+ new VmInstr(_instrCodesDb.Conv_u4_, Conv_u4_)
+ },
+ {
+ _instrCodesDb.Ldc_i8_.Id,
+ new VmInstr(_instrCodesDb.Ldc_i8_, Ldc_i8_)
+ },
+ {
+ _instrCodesDb.Ldind_r4_.Id,
+ new VmInstr(_instrCodesDb.Ldind_r4_, Ldind_r4_)
+ },
+ {
+ _instrCodesDb.Conv_r_un_.Id,
+ new VmInstr(_instrCodesDb.Conv_r_un_, Conv_r_un_)
+ },
+ {
+ _instrCodesDb.Ldtoken_.Id,
+ new VmInstr(_instrCodesDb.Ldtoken_, Ldtoken_)
+ },
+ {
+ _instrCodesDb.Blt_un_.Id,
+ new VmInstr(_instrCodesDb.Blt_un_, Blt_un_)
+ },
+ {
+ _instrCodesDb.Brtrue_.Id,
+ new VmInstr(_instrCodesDb.Brtrue_, Brtrue_)
+ },
+ {
+ _instrCodesDb.Switch_.Id,
+ new VmInstr(_instrCodesDb.Switch_, Switch_)
+ },
+ {
+ _instrCodesDb.Refanytype_.Id,
+ new VmInstr(_instrCodesDb.Refanytype_, Refanytype_)
+ },
+ {
+ _instrCodesDb.Stobj_.Id,
+ new VmInstr(_instrCodesDb.Stobj_, Stobj_)
+ },
+ {
+ _instrCodesDb.Ble_un_.Id,
+ new VmInstr(_instrCodesDb.Ble_un_, Ble_un_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_i8_un_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_i8_un_, Conv_ovf_i8_un_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_u4_un_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_u4_un_, Conv_ovf_u4_un_)
+ },
+ {
+ _instrCodesDb.Ldind_i8_.Id,
+ new VmInstr(_instrCodesDb.Ldind_i8_, Ldind_i8_)
+ },
+ {
+ _instrCodesDb.U000EU2006U2000.Id,
+ new VmInstr(_instrCodesDb.U000EU2006U2000, Invoke)
+ },
+ {
+ _instrCodesDb.Endfinally_.Id,
+ new VmInstr(_instrCodesDb.Endfinally_, Endfinally_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_u8_un_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_u8_un_, Conv_ovf_u8_un_)
+ },
+ {
+ _instrCodesDb.Ldelem_i2_.Id,
+ new VmInstr(_instrCodesDb.Ldelem_i2_, Ldelem_i2_)
+ },
+ {
+ _instrCodesDb.Ldc_i4_.Id,
+ new VmInstr(_instrCodesDb.Ldc_i4_, Ldc_i4_)
+ },
+ {
+ _instrCodesDb.U000FU2001.Id,
+ new VmInstr(_instrCodesDb.U000FU2001, _u0006u2003u2001)
+ },
+ {
+ _instrCodesDb.Conv_i4_.Id,
+ new VmInstr(_instrCodesDb.Conv_i4_, Conv_i4_)
+ },
+ {
+ _instrCodesDb.Ldind_u1_.Id,
+ new VmInstr(_instrCodesDb.Ldind_u1_, Ldind_u1_)
+ },
+ {
+ _instrCodesDb.Rethrow_.Id,
+ new VmInstr(_instrCodesDb.Rethrow_, Rethrow_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_i1_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_i1_, Conv_ovf_i1_)
+ },
+ {
+ _instrCodesDb.Box_.Id,
+ new VmInstr(_instrCodesDb.Box_, Box_)
+ },
+ {
+ _instrCodesDb.Localloc_.Id,
+ new VmInstr(_instrCodesDb.Localloc_, Localloc_)
+ },
+ {
+ _instrCodesDb.Ldelem_r8_.Id,
+ new VmInstr(_instrCodesDb.Ldelem_r8_, Ldelem_r8_)
+ },
+ {
+ _instrCodesDb.Throw_.Id,
+ new VmInstr(_instrCodesDb.Throw_, Throw_)
+ },
+ {
+ _instrCodesDb.Ldvirtftn_.Id,
+ new VmInstr(_instrCodesDb.Ldvirtftn_, Ldvirtftn_)
+ },
+ {
+ _instrCodesDb.Mul_ovf_un_.Id,
+ new VmInstr(_instrCodesDb.Mul_ovf_un_, Mul_ovf_un_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_i4_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_i4_, Conv_ovf_i4_)
+ },
+ {
+ _instrCodesDb.Ldloc_0_.Id,
+ new VmInstr(_instrCodesDb.Ldloc_0_, Ldloc_0_)
+ },
+ {
+ _instrCodesDb.Starg_.Id,
+ new VmInstr(_instrCodesDb.Starg_, Starg_)
+ },
+ {
+ _instrCodesDb.Stind_i1_.Id,
+ new VmInstr(_instrCodesDb.Stind_i1_, Stind_i1_)
+ },
+ {
+ _instrCodesDb.Ldind_i2_.Id,
+ new VmInstr(_instrCodesDb.Ldind_i2_, Ldind_i2_)
+ },
+ {
+ _instrCodesDb.And_.Id,
+ new VmInstr(_instrCodesDb.And_, And_)
+ },
+ {
+ _instrCodesDb.Ldc_i4_6_.Id,
+ new VmInstr(_instrCodesDb.Ldc_i4_6_, Ldc_i4_6_)
+ },
+ {
+ _instrCodesDb.Nop_.Id,
+ new VmInstr(_instrCodesDb.Nop_, Nop_)
+ },
+ {
+ _instrCodesDb.Ldind_i4_.Id,
+ new VmInstr(_instrCodesDb.Ldind_i4_, Ldind_i4_)
+ },
+ {
+ _instrCodesDb.Dup_.Id,
+ new VmInstr(_instrCodesDb.Dup_, Dup_)
+ },
+ {
+ _instrCodesDb.Mul_.Id,
+ new VmInstr(_instrCodesDb.Mul_, Mul_)
+ },
+ {
+ _instrCodesDb.Stloc_2_.Id,
+ new VmInstr(_instrCodesDb.Stloc_2_, Stloc_2_)
+ },
+ {
+ _instrCodesDb.Or_.Id,
+ new VmInstr(_instrCodesDb.Or_, Or_)
+ },
+ {
+ _instrCodesDb.Conv_u8_.Id,
+ new VmInstr(_instrCodesDb.Conv_u8_, Conv_u8_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_u1_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_u1_, Conv_ovf_u1_)
+ },
+ {
+ _instrCodesDb.Sub_ovf_.Id,
+ new VmInstr(_instrCodesDb.Sub_ovf_, Sub_ovf_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_u1_un_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_u1_un_, Conv_ovf_u1_un_)
+ },
+ {
+ _instrCodesDb.Ldelem_r4_.Id,
+ new VmInstr(_instrCodesDb.Ldelem_r4_, Ldelem_r4_)
+ },
+ {
+ _instrCodesDb.Conv_r8_.Id,
+ new VmInstr(_instrCodesDb.Conv_r8_, Conv_r8_)
+ },
+ {
+ _instrCodesDb.Stloc_0_.Id,
+ new VmInstr(_instrCodesDb.Stloc_0_, Stloc_0_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_u8_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_u8_, Conv_ovf_u8_)
+ },
+ {
+ _instrCodesDb.Brfalse_.Id,
+ new VmInstr(_instrCodesDb.Brfalse_, Brfalse_)
+ },
+ {
+ _instrCodesDb.Ldarg_3_.Id,
+ new VmInstr(_instrCodesDb.Ldarg_3_, Ldarg_3_)
+ },
+ {
+ _instrCodesDb.Ldarg_.Id,
+ new VmInstr(_instrCodesDb.Ldarg_, Ldarg_)
+ },
+ {
+ _instrCodesDb.Ldc_r4_.Id,
+ new VmInstr(_instrCodesDb.Ldc_r4_, Ldc_r4_)
+ },
+ {
+ _instrCodesDb.Initobj_.Id,
+ new VmInstr(_instrCodesDb.Initobj_, Initobj_)
+ },
+ {
+ _instrCodesDb.Stloc_.Id,
+ new VmInstr(_instrCodesDb.Stloc_, Stloc_)
+ },
+ {
+ _instrCodesDb.Stind_i4_.Id,
+ new VmInstr(_instrCodesDb.Stind_i4_, Stind_i4_)
+ },
+ {
+ _instrCodesDb.Callvirt_.Id,
+ new VmInstr(_instrCodesDb.Callvirt_, Callvirt_)
+ },
+ {
+ _instrCodesDb.Stelem_i2_.Id,
+ new VmInstr(_instrCodesDb.Stelem_i2_, Stelem_i2_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_u_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_u_, Conv_ovf_u_)
+ },
+ {
+ _instrCodesDb.Cpobj_.Id,
+ new VmInstr(_instrCodesDb.Cpobj_, Cpobj_)
+ },
+ {
+ _instrCodesDb.Rem_.Id,
+ new VmInstr(_instrCodesDb.Rem_, Rem_)
+ },
+ {
+ _instrCodesDb.Stind_r8_.Id,
+ new VmInstr(_instrCodesDb.Stind_r8_, Stind_r8_)
+ },
+ {
+ _instrCodesDb.Stloc_1_.Id,
+ new VmInstr(_instrCodesDb.Stloc_1_, Stloc_1_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_u4_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_u4_, Conv_ovf_u4_)
+ },
+ {
+ _instrCodesDb.Ldc_i4_0_.Id,
+ new VmInstr(_instrCodesDb.Ldc_i4_0_, Ldc_i4_0_)
+ },
+ {
+ _instrCodesDb.Stind_i_.Id,
+ new VmInstr(_instrCodesDb.Stind_i_, Stind_i_)
+ },
+ {
+ _instrCodesDb.Stelem_i8_.Id,
+ new VmInstr(_instrCodesDb.Stelem_i8_, Stelem_i8_)
+ },
+ {
+ _instrCodesDb.Ldelema_.Id,
+ new VmInstr(_instrCodesDb.Ldelema_, Ldelema_)
+ },
+ {
+ _instrCodesDb.Ldsflda_.Id,
+ new VmInstr(_instrCodesDb.Ldsflda_, Ldsflda_)
+ },
+ {
+ _instrCodesDb.Ldsfld_.Id,
+ new VmInstr(_instrCodesDb.Ldsfld_, Ldsfld_)
+ },
+ {
+ _instrCodesDb.Isinst_.Id,
+ new VmInstr(_instrCodesDb.Isinst_, Isinst_)
+ },
+ {
+ _instrCodesDb.Conv_i2_.Id,
+ new VmInstr(_instrCodesDb.Conv_i2_, Conv_i2_)
+ },
+ {
+ _instrCodesDb.Stelem_.Id,
+ new VmInstr(_instrCodesDb.Stelem_, Stelem_)
+ },
+ {
+ _instrCodesDb.Ldind_r8_.Id,
+ new VmInstr(_instrCodesDb.Ldind_r8_, Ldind_r8_)
+ },
+ {
+ _instrCodesDb.Ldc_r8_.Id,
+ new VmInstr(_instrCodesDb.Ldc_r8_, Ldc_r8_)
+ },
+ {
+ _instrCodesDb.Bge_.Id,
+ new VmInstr(_instrCodesDb.Bge_, Bge_)
+ },
+ {
+ _instrCodesDb.Ldind_i1_.Id,
+ new VmInstr(_instrCodesDb.Ldind_i1_, Ldind_i1_)
+ },
+ {
+ _instrCodesDb.Ldelem_u1_.Id,
+ new VmInstr(_instrCodesDb.Ldelem_u1_, Ldelem_u1_)
+ },
+ {
+ _instrCodesDb.Ldstr_.Id,
+ new VmInstr(_instrCodesDb.Ldstr_, Ldstr_)
+ },
+ {
+ _instrCodesDb.Ldloca_s_.Id,
+ new VmInstr(_instrCodesDb.Ldloca_s_, Ldloca_s_)
+ },
+ {
+ _instrCodesDb.Ldelem_i8_.Id,
+ new VmInstr(_instrCodesDb.Ldelem_i8_, Ldelem_i8_)
+ },
+ {
+ _instrCodesDb.Ldc_i4_8_.Id,
+ new VmInstr(_instrCodesDb.Ldc_i4_8_, Ldc_i4_8_)
+ },
+ {
+ _instrCodesDb.Blt_.Id,
+ new VmInstr(_instrCodesDb.Blt_, Blt_)
+ },
+ {
+ _instrCodesDb.Unbox_.Id,
+ new VmInstr(_instrCodesDb.Unbox_, Unbox_)
+ },
+ {
+ _instrCodesDb.Bge_un_.Id,
+ new VmInstr(_instrCodesDb.Bge_un_, Bge_un_)
+ },
+ {
+ _instrCodesDb.Ldelem_u2_.Id,
+ new VmInstr(_instrCodesDb.Ldelem_u2_, Ldelem_u2_)
+ },
+ {
+ _instrCodesDb.Ldind_u2_.Id,
+ new VmInstr(_instrCodesDb.Ldind_u2_, Ldind_u2_)
+ },
+ {
+ _instrCodesDb.Sub_ovf_un_.Id,
+ new VmInstr(_instrCodesDb.Sub_ovf_un_, Sub_ovf_un_)
+ },
+ {
+ _instrCodesDb.Ldc_i4_4_.Id,
+ new VmInstr(_instrCodesDb.Ldc_i4_4_, Ldc_i4_4_)
+ },
+ {
+ _instrCodesDb.Ldarg_0_.Id,
+ new VmInstr(_instrCodesDb.Ldarg_0_, Ldarg_0_)
+ },
+ {
+ _instrCodesDb.Rem_un_.Id,
+ new VmInstr(_instrCodesDb.Rem_un_, Rem_un_)
+ },
+ {
+ _instrCodesDb.Ldloc_1_.Id,
+ new VmInstr(_instrCodesDb.Ldloc_1_, Ldloc_1_)
+ },
+ {
+ _instrCodesDb.Bne_un_.Id,
+ new VmInstr(_instrCodesDb.Bne_un_, Bne_un_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_i2_un_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_i2_un_, Conv_ovf_i2_un_)
+ },
+ {
+ _instrCodesDb.Ckfinite_.Id,
+ new VmInstr(_instrCodesDb.Ckfinite_, Ckfinite_)
+ },
+ {
+ _instrCodesDb.Ldobj_.Id,
+ new VmInstr(_instrCodesDb.Ldobj_, Ldobj_)
+ },
+ {
+ _instrCodesDb.Pop_.Id,
+ new VmInstr(_instrCodesDb.Pop_, Pop_)
+ },
+ {
+ _instrCodesDb.Constrained_.Id,
+ new VmInstr(_instrCodesDb.Constrained_, Constrained_)
+ },
+ {
+ _instrCodesDb.Ldc_i4_s_.Id,
+ new VmInstr(_instrCodesDb.Ldc_i4_s_, Ldc_i4_s_)
+ },
+ {
+ _instrCodesDb.Ldloc_s_.Id,
+ new VmInstr(_instrCodesDb.Ldloc_s_, Ldloc_s_)
+ },
+ {
+ _instrCodesDb.Ldarg_2_.Id,
+ new VmInstr(_instrCodesDb.Ldarg_2_, Ldarg_2_)
+ },
+ {
+ _instrCodesDb.Ldarga_.Id,
+ new VmInstr(_instrCodesDb.Ldarga_, Ldarga_)
+ },
+ {
+ _instrCodesDb.Conv_i8_.Id,
+ new VmInstr(_instrCodesDb.Conv_i8_, Conv_i8_)
+ },
+ {
+ _instrCodesDb.Br_.Id,
+ new VmInstr(_instrCodesDb.Br_, Br_)
+ },
+ {
+ _instrCodesDb.Ldc_i4_3_.Id,
+ new VmInstr(_instrCodesDb.Ldc_i4_3_, Ldc_i4_3_)
+ },
+ {
+ _instrCodesDb.Mul_ovf_.Id,
+ new VmInstr(_instrCodesDb.Mul_ovf_, Mul_ovf_)
+ },
+ {
+ _instrCodesDb.Shl_.Id,
+ new VmInstr(_instrCodesDb.Shl_, Shl_)
+ },
+ {
+ _instrCodesDb.Castclass_.Id,
+ new VmInstr(_instrCodesDb.Castclass_, Castclass_)
+ },
+ {
+ _instrCodesDb.Jmp_.Id,
+ new VmInstr(_instrCodesDb.Jmp_, Jmp_)
+ },
+ {
+ _instrCodesDb.Beq_.Id,
+ new VmInstr(_instrCodesDb.Beq_, Beq_)
+ },
+ {
+ _instrCodesDb.Conv_r4_.Id,
+ new VmInstr(_instrCodesDb.Conv_r4_, Conv_r4_)
+ },
+ {
+ _instrCodesDb.Ble_.Id,
+ new VmInstr(_instrCodesDb.Ble_, Ble_)
+ },
+ {
+ _instrCodesDb.Conv_ovf_u2_un_.Id,
+ new VmInstr(_instrCodesDb.Conv_ovf_u2_un_, Conv_ovf_u2_un_)
+ },
+ {
+ _instrCodesDb.Call_.Id,
+ new VmInstr(_instrCodesDb.Call_, Call_)
+ },
+ {
+ _instrCodesDb.Not_.Id,
+ new VmInstr(_instrCodesDb.Not_, Not_)
+ }
+ };
+ }
+ }
+
+ // Token: 0x02000042 RID: 66
+ public sealed class LocalVarType // \u0008
+ {
+ // Token: 0x060002E4 RID: 740 RVA: 0x00013F08 File Offset: 0x00012108
+ // Token: 0x060002E5 RID: 741 RVA: 0x00013F10 File Offset: 0x00012110
+ // Token: 0x04000171 RID: 369
+ public int TypeId /* \u0002 */ { get; set; }
+ }
+
+ // Token: 0x0200004D RID: 77
+ public sealed class ArgTypeToOutput // \u000E
+ {
+ // Token: 0x06000321 RID: 801 RVA: 0x00014C74 File Offset: 0x00012E74
+ // Token: 0x06000322 RID: 802 RVA: 0x00014C7C File Offset: 0x00012E7C
+ // Token: 0x0400017C RID: 380
+ public int TypeId /* \u0002 */ { get; set; }
+
+ // Token: 0x06000323 RID: 803 RVA: 0x00014C88 File Offset: 0x00012E88
+ // Token: 0x06000324 RID: 804 RVA: 0x00014C90 File Offset: 0x00012E90
+ // Token: 0x0400017D RID: 381
+ public bool IsOutput /* \u0003 */ { get; set; }
+ }
+
+ // Token: 0x0200005E RID: 94
+ internal sealed class CatchBlock
+ {
+ // Token: 0x0600036B RID: 875 RVA: 0x00015AFC File Offset: 0x00013CFC
+ // Token: 0x0600036C RID: 876 RVA: 0x00015B04 File Offset: 0x00013D04
+ // Token: 0x04000189 RID: 393
+ public byte Kind { get; set; }
+
+ // Token: 0x0600036D RID: 877 RVA: 0x00015B10 File Offset: 0x00013D10
+ // Token: 0x0600036E RID: 878 RVA: 0x00015B18 File Offset: 0x00013D18
+ // Token: 0x0400018A RID: 394
+ public int ExcTypeId { get; set; }
+
+ // Token: 0x0600036F RID: 879 RVA: 0x00015B24 File Offset: 0x00013D24
+ // Token: 0x06000370 RID: 880 RVA: 0x00015B2C File Offset: 0x00013D2C
+ // Token: 0x0400018B RID: 395
+ public uint PosKind4 { get; set; }
+
+ // Token: 0x06000371 RID: 881 RVA: 0x00015B38 File Offset: 0x00013D38
+ // Token: 0x06000372 RID: 882 RVA: 0x00015B40 File Offset: 0x00013D40
+ // Token: 0x0400018C RID: 396
+ public uint Start { get; set; }
+
+ // Token: 0x06000373 RID: 883 RVA: 0x00015B4C File Offset: 0x00013D4C
+ // Token: 0x06000374 RID: 884 RVA: 0x00015B54 File Offset: 0x00013D54
+ // Token: 0x0400018D RID: 397
+ public uint Pos { get; set; } // \u0005
+
+ // Token: 0x06000375 RID: 885 RVA: 0x00015B60 File Offset: 0x00013D60
+ // Token: 0x06000376 RID: 886 RVA: 0x00015B68 File Offset: 0x00013D68
+ // Token: 0x0400018E RID: 398
+ public uint Len { get; set; }
+ }
+
+ // Token: 0x02000049 RID: 73
+ internal abstract class VmTokenInfo // \u0008\u2006
+ {
+ internal enum Kind : byte
+ {
+ Class0, Field1, Method2, String3, MethodRef4
+ }
+
+ // Token: 0x0600030D RID: 781
+ public abstract Kind TokenKind(); // \u0008\u2006\u2008\u2000\u2002\u200A\u0002
+ }
+
+ // Token: 0x02000017 RID: 23
+ internal sealed class UniversalTokenInfo // \u0003\u2008
+ {
+ // Token: 0x06000097 RID: 151 RVA: 0x00003E9C File Offset: 0x0000209C
+ // Token: 0x06000098 RID: 152 RVA: 0x00003EA4 File Offset: 0x000020A4
+ // Token: 0x04000020 RID: 32
+ public byte IsVm { get; set; }
+
+ // Token: 0x06000099 RID: 153 RVA: 0x00003EB0 File Offset: 0x000020B0
+ // Token: 0x0600009A RID: 154 RVA: 0x00003EB8 File Offset: 0x000020B8
+ // Token: 0x04000021 RID: 33
+ public int MetadataToken { get; set; }
+
+ // Token: 0x0600009B RID: 155 RVA: 0x00003EC4 File Offset: 0x000020C4
+ // Token: 0x0600009C RID: 156 RVA: 0x00003ECC File Offset: 0x000020CC
+ // Token: 0x04000022 RID: 34
+ public VmTokenInfo VmToken { get; set; }
+ }
+
+ // Token: 0x02000016 RID: 22
+ internal sealed class VmMethodRefTokenInfo : VmTokenInfo // \u0003\u2007
+ {
+ // Token: 0x06000091 RID: 145 RVA: 0x00003E68 File Offset: 0x00002068
+ // Token: 0x06000092 RID: 146 RVA: 0x00003E70 File Offset: 0x00002070
+ // Token: 0x0400001E RID: 30
+ public int Flags { get; set; }
+
+ // Token: 0x06000093 RID: 147 RVA: 0x00003E7C File Offset: 0x0000207C
+ // Token: 0x06000094 RID: 148 RVA: 0x00003E84 File Offset: 0x00002084
+ // Token: 0x0400001F RID: 31
+ public int Pos { get; set; }
+
+ // Token: 0x06000095 RID: 149 RVA: 0x00003E90 File Offset: 0x00002090
+ public override Kind TokenKind() // \u0008\u2006\u2008\u2000\u2002\u200A\u0002
+ {
+ return Kind.MethodRef4;
+ }
+ }
+
+ // Token: 0x0200004A RID: 74
+ internal sealed class VmMethodTokenInfo : VmTokenInfo // \u0008\u2007
+ {
+ // Token: 0x0600030F RID: 783 RVA: 0x00014BB0 File Offset: 0x00012DB0
+ // Token: 0x06000310 RID: 784 RVA: 0x00014BB8 File Offset: 0x00012DB8
+ // Token: 0x04000176 RID: 374
+ public byte Flags { get; set; }
+
+ // Token: 0x06000311 RID: 785 RVA: 0x00014BC4 File Offset: 0x00012DC4
+ public bool IsStatic() // \u0002
+ {
+ return (Flags & 2) > 0;
+ }
+
+ // Token: 0x06000312 RID: 786 RVA: 0x00014BD4 File Offset: 0x00012DD4
+ public bool IsGeneric() // \u0003
+ {
+ return (Flags & 1) > 0;
+ }
+
+ // Token: 0x06000313 RID: 787 RVA: 0x00014BE4 File Offset: 0x00012DE4
+ // Token: 0x06000314 RID: 788 RVA: 0x00014BEC File Offset: 0x00012DEC
+ // Token: 0x04000177 RID: 375
+ public UniversalTokenInfo Class { get; set; }
+
+ // Token: 0x06000315 RID: 789 RVA: 0x00014BF8 File Offset: 0x00012DF8
+ // Token: 0x06000316 RID: 790 RVA: 0x00014C00 File Offset: 0x00012E00
+ // Token: 0x04000178 RID: 376
+ public string Name { get; set; }
+
+ // Token: 0x06000317 RID: 791 RVA: 0x00014C0C File Offset: 0x00012E0C
+ // Token: 0x06000318 RID: 792 RVA: 0x00014C14 File Offset: 0x00012E14
+ // Token: 0x04000179 RID: 377
+ public UniversalTokenInfo[] Parameters { get; set; }
+
+ // Token: 0x06000319 RID: 793 RVA: 0x00014C20 File Offset: 0x00012E20
+ // Token: 0x0600031A RID: 794 RVA: 0x00014C28 File Offset: 0x00012E28
+ // Token: 0x0400017A RID: 378
+ public UniversalTokenInfo[] GenericArguments { get; set; }
+
+ // Token: 0x0600031B RID: 795 RVA: 0x00014C34 File Offset: 0x00012E34
+ // Token: 0x0600031C RID: 796 RVA: 0x00014C3C File Offset: 0x00012E3C
+ // Token: 0x0400017B RID: 379
+ public UniversalTokenInfo ReturnType { get; set; }
+
+ // Token: 0x0600031D RID: 797 RVA: 0x00014C48 File Offset: 0x00012E48
+ public override Kind TokenKind() // \u0008\u2006\u2008\u2000\u2002\u200A\u0002
+ {
+ return Kind.Method2;
+ }
+ }
+
+ // Token: 0x02000056 RID: 86
+ internal sealed class VmStringTokenInfo : VmTokenInfo // \u000E\u2007
+ {
+ // Token: 0x06000343 RID: 835 RVA: 0x000153CC File Offset: 0x000135CC
+ // Token: 0x06000344 RID: 836 RVA: 0x000153D4 File Offset: 0x000135D4
+ // Token: 0x04000185 RID: 389
+ public string Value { get; set; }
+
+ // Token: 0x06000345 RID: 837 RVA: 0x000153E0 File Offset: 0x000135E0
+ public override Kind TokenKind() // \u0008\u2006\u2008\u2000\u2002\u200A\u0002
+ {
+ return Kind.String3;
+ }
+ }
+
+ // Token: 0x02000060 RID: 96
+ internal sealed class VmFieldTokenInfo : VmTokenInfo // \u000F\u2006
+ {
+ // Token: 0x06000382 RID: 898 RVA: 0x00015C38 File Offset: 0x00013E38
+ // Token: 0x06000383 RID: 899 RVA: 0x00015C40 File Offset: 0x00013E40
+ // Token: 0x04000191 RID: 401
+ public UniversalTokenInfo Class { get; set; }
+
+ // Token: 0x06000384 RID: 900 RVA: 0x00015C4C File Offset: 0x00013E4C
+ // Token: 0x06000385 RID: 901 RVA: 0x00015C54 File Offset: 0x00013E54
+ // Token: 0x04000192 RID: 402
+ public string Name { get; set; }
+
+ // Token: 0x06000386 RID: 902 RVA: 0x00015C60 File Offset: 0x00013E60
+ // Token: 0x06000387 RID: 903 RVA: 0x00015C68 File Offset: 0x00013E68
+ // Token: 0x04000193 RID: 403
+ public bool IsStatic { get; set; }
+
+ // Token: 0x06000388 RID: 904 RVA: 0x00015C74 File Offset: 0x00013E74
+ public override Kind TokenKind() // \u0008\u2006\u2008\u2000\u2002\u200A\u0002
+ {
+ return Kind.Field1;
+ }
+ }
+
+ // Token: 0x02000061 RID: 97
+ internal sealed class VmClassTokenInfo : VmTokenInfo // \u000F\u2007
+ {
+ // Token: 0x04000194 RID: 404
+ // Token: 0x0600038A RID: 906 RVA: 0x00015C90 File Offset: 0x00013E90
+ // Token: 0x0600038B RID: 907 RVA: 0x00015C98 File Offset: 0x00013E98
+ public string ClassName { get; set; }
+
+ // Token: 0x0600038C RID: 908 RVA: 0x00015CA4 File Offset: 0x00013EA4
+ // Token: 0x04000195 RID: 405
+ // Token: 0x0600038D RID: 909 RVA: 0x00015CAC File Offset: 0x00013EAC
+ public bool IsOuterClassGeneric { get; set; }
+
+ // Token: 0x0600038E RID: 910 RVA: 0x00015CB8 File Offset: 0x00013EB8
+ // Token: 0x04000196 RID: 406
+ // Token: 0x0600038F RID: 911 RVA: 0x00015CC0 File Offset: 0x00013EC0
+ public bool IsGeneric { get; set; }
+
+ // Token: 0x06000390 RID: 912 RVA: 0x00015CCC File Offset: 0x00013ECC
+ // Token: 0x04000197 RID: 407
+ // Token: 0x06000391 RID: 913 RVA: 0x00015CD4 File Offset: 0x00013ED4
+ public UniversalTokenInfo[] GenericArguments { get; set; }
+
+ // Token: 0x06000392 RID: 914 RVA: 0x00015CE0 File Offset: 0x00013EE0
+ // Token: 0x04000198 RID: 408
+ // Token: 0x06000393 RID: 915 RVA: 0x00015CE8 File Offset: 0x00013EE8
+ public int OuterClassGenericClassIdx { get; set; } = -1;
+
+ // Token: 0x06000394 RID: 916 RVA: 0x00015CF4 File Offset: 0x00013EF4
+ // Token: 0x04000199 RID: 409
+ // Token: 0x06000395 RID: 917 RVA: 0x00015CFC File Offset: 0x00013EFC
+ public int OuterClassGenericMethodIdx { get; set; } = -1;
+
+ // Token: 0x06000396 RID: 918 RVA: 0x00015D08 File Offset: 0x00013F08
+ public override Kind TokenKind() // \u0008\u2006\u2008\u2000\u2002\u200A\u0002
+ {
+ return Kind.Class0;
+ }
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmInstrCodesDb.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmInstrCodesDb.cs
new file mode 100644
index 0000000..0ca16de
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmInstrCodesDb.cs
@@ -0,0 +1,899 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using System.Reflection;
+using System.Threading;
+
+// ReSharper disable UnusedMember.Global
+
+namespace UnitTestProject.RefVm
+{
+ // Token: 0x0200002E RID: 46
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
+ public class VmInstrCodesDb // \u0006\u2005
+ {
+ // Token: 0x04000068 RID: 104
+ private VmInstrInfo[] _all;
+
+ // Token: 0x0400011D RID: 285
+ private bool _initialized;
+
+ // Token: 0x0600015B RID: 347 RVA: 0x000075B8 File Offset: 0x000057B8
+ public bool IsInitialized() // \u0002
+ {
+ return _initialized;
+ }
+
+ // Token: 0x0600015C RID: 348 RVA: 0x000075C0 File Offset: 0x000057C0
+ public void SetInitialized(bool val) // \u0002
+ {
+ _initialized = val;
+ }
+
+ // Token: 0x0600015A RID: 346 RVA: 0x000075A8 File Offset: 0x000057A8
+ public IEnumerable<VmInstrInfo> MyFieldsEnumerator() // \u0002
+ {
+ return new FieldsEnumerator(-2)
+ {
+ Source = this
+ };
+ }
+
+ // Token: 0x0600015D RID: 349 RVA: 0x000075CC File Offset: 0x000057CC
+ public VmInstrInfo[] ToSortedArray() // \u0002
+ {
+ if (_all == null)
+ {
+ lock (this)
+ {
+ if (_all == null)
+ {
+ var list = new List<VmInstrInfo>(256);
+ list.AddRange(MyFieldsEnumerator());
+ if (SortHelper.MyComparison == null)
+ {
+ SortHelper.MyComparison = SortHelper.MySortHelper.Compare;
+ }
+ list.Sort(SortHelper.MyComparison);
+ _all = list.ToArray();
+ }
+ }
+ }
+ return _all;
+ }
+
+ // Token: 0x0200002F RID: 47
+ [Serializable]
+ private sealed class SortHelper // \u0002
+ {
+ // Token: 0x06000160 RID: 352 RVA: 0x000076A0 File Offset: 0x000058A0
+ internal int Compare(VmInstrInfo v1, VmInstrInfo v2) // \u0002
+ {
+ return v1.Id.CompareTo(v2.Id);
+ }
+
+ // Token: 0x04000129 RID: 297
+ public static readonly SortHelper MySortHelper = new SortHelper(); // \u0002
+
+ // Token: 0x0400012A RID: 298
+ public static Comparison<VmInstrInfo> MyComparison; // \u0003
+ }
+
+ // Token: 0x02000030 RID: 48
+ private sealed class FieldsEnumerator : IEnumerable<VmInstrInfo>, IEnumerator<VmInstrInfo> // \u0003
+ {
+ // Token: 0x06000161 RID: 353 RVA: 0x000076C4 File Offset: 0x000058C4
+ public FieldsEnumerator(int st)
+ {
+ _state = st;
+ _threadId = Thread.CurrentThread.ManagedThreadId;
+ }
+
+ // Token: 0x06000162 RID: 354 RVA: 0x000076E4 File Offset: 0x000058E4
+ void IDisposable.Dispose() // \u0003\u2008\u2000\u2002\u200A\u0002
+ {
+ }
+
+ // Token: 0x06000163 RID: 355 RVA: 0x000076E8 File Offset: 0x000058E8
+ bool IEnumerator.MoveNext()
+ {
+ var num = _state;
+ if (num != 0)
+ {
+ if (num != 1)
+ {
+ return false;
+ }
+ _state = -1;
+ _index++;
+ }
+ else
+ {
+ _state = -1;
+ var fields = typeof(VmInstrCodesDb).GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public);
+ _data = fields;
+ _index = 0;
+ }
+ if (_index >= _data.Length)
+ {
+ _data = null;
+ return false;
+ }
+ var p = (VmInstrInfo)_data[_index].GetValue(Source);
+ _current = p;
+ _state = 1;
+ return true;
+ }
+
+ // Token: 0x06000164 RID: 356 RVA: 0x00007790 File Offset: 0x00005990
+ VmInstrInfo IEnumerator<VmInstrInfo>.Current // \u0003\u2008\u2000\u2002\u200A\u0002
+ => _current;
+
+ // Token: 0x06000165 RID: 357 RVA: 0x00007798 File Offset: 0x00005998
+ [DebuggerHidden]
+ void IEnumerator.Reset() // \u0003\u2008\u2000\u2002\u200A\u0003
+ {
+ throw new NotSupportedException();
+ }
+
+ // Token: 0x06000166 RID: 358 RVA: 0x000077A0 File Offset: 0x000059A0
+ [DebuggerHidden]
+ object IEnumerator.Current // \u0003\u2008\u2000\u2002\u200A\u0002
+ => _current;
+
+ // Token: 0x06000167 RID: 359 RVA: 0x000077A8 File Offset: 0x000059A8
+ [DebuggerHidden]
+ IEnumerator<VmInstrInfo> IEnumerable<VmInstrInfo>.GetEnumerator() // \u0003\u2008\u2000\u2002\u200A\u0002
+ {
+ FieldsEnumerator ret;
+ if (_state == -2 && _threadId == Thread.CurrentThread.ManagedThreadId)
+ {
+ _state = 0;
+ ret = this;
+ }
+ else
+ {
+ ret = new FieldsEnumerator(0) {Source = Source};
+ }
+ return ret;
+ }
+
+ // Token: 0x06000168 RID: 360 RVA: 0x000077F0 File Offset: 0x000059F0
+ [DebuggerHidden]
+ IEnumerator IEnumerable.GetEnumerator() // \u0003\u2008\u2000\u2002\u200A\u0002
+ {
+ return ((IEnumerable<VmInstrInfo>)this).GetEnumerator();
+ }
+
+ // Token: 0x0400012B RID: 299
+ private int _state; // \u0002
+
+ // Token: 0x0400012C RID: 300
+ private VmInstrInfo _current; // \u0003
+
+ // Token: 0x0400012D RID: 301
+ private readonly int _threadId; // \u0005
+
+ // Token: 0x0400012E RID: 302
+ public VmInstrCodesDb Source; // \u0008
+
+ // Token: 0x0400012F RID: 303
+ private FieldInfo[] _data; // \u0006
+
+ // Token: 0x04000130 RID: 304
+ private int _index; // \u000E
+ }
+
+ #region all
+ /*
+no. { typecheck, rangecheck, nullcheck } The specified fault check(s) normally performed as part of the execution of the subsequent instruction can/shall be skipped. Prefix to instruction
+readonly. Specify that the subsequent array address operation performs no type check at runtime, and that it returns a controlled-mutability managed pointer Prefix to instruction
+tail. Subsequent call terminates current method Prefix to instruction
+unaligned. (alignment) Subsequent pointer instruction might be unaligned. Prefix to instruction
+volatile. Subsequent pointer reference is volatile. Prefix to instruction
+ */
+ // Token: 0x04000063 RID: 99
+ public readonly VmInstrInfo U0002U2000 = new VmInstrInfo(690984147, VmOperandType.Ot11Nope); // not implemented
+
+ // Token: 0x04000077 RID: 119
+ public readonly VmInstrInfo U0006U2001U2000 = new VmInstrInfo(733028785, VmOperandType.Ot11Nope); // not implemented
+
+ // Token: 0x0400007A RID: 122
+ public readonly VmInstrInfo U0006U2001 = new VmInstrInfo(701247957, VmOperandType.Ot11Nope); // not implemented
+
+ // Token: 0x04000086 RID: 134
+ public readonly VmInstrInfo U0006U2004 = new VmInstrInfo(-377358754, VmOperandType.Ot11Nope); // not implemented
+
+ // Token: 0x040000B0 RID: 176
+ public readonly VmInstrInfo U0006U2008U2000 = new VmInstrInfo(1026942272, VmOperandType.Ot11Nope); // empty impl
+
+ // Token: 0x040000B2 RID: 178
+ public readonly VmInstrInfo Endfilter_ = new VmInstrInfo(-1041717787, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000C6 RID: 198
+ public readonly VmInstrInfo Mul_ovf_ = new VmInstrInfo(717697778, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000CB RID: 203
+ public readonly VmInstrInfo Endfinally_ = new VmInstrInfo(-860175516, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000E0 RID: 224
+ public readonly VmInstrInfo U0003U2009 = new VmInstrInfo(-1535884281, VmOperandType.Ot11Nope); // not implemented
+
+ // Token: 0x04000080 RID: 128
+ public readonly VmInstrInfo U000EU2006U2000 = new VmInstrInfo(1756761351, VmOperandType.Ot5Int); // ??? invoke some method
+
+ // Token: 0x04000082 RID: 130
+ public readonly VmInstrInfo Jmp_ = new VmInstrInfo(-512817309, VmOperandType.Ot12Int);
+
+ // Token: 0x040000CC RID: 204
+ public readonly VmInstrInfo Initobj_ = new VmInstrInfo(-647649665, VmOperandType.Ot5Int);
+
+ // Token: 0x04000065 RID: 101
+ public readonly VmInstrInfo Calli_ = new VmInstrInfo(1295283437, VmOperandType.Ot5Int);
+
+ // Token: 0x0400006F RID: 111
+ public readonly VmInstrInfo Constrained_ = new VmInstrInfo(1803463719, VmOperandType.Ot5Int);
+
+ // Token: 0x04000098 RID: 152
+ public readonly VmInstrInfo U000FU2001 = new VmInstrInfo(-1952417400, VmOperandType.Ot5Int); // empty impl
+
+ // Token: 0x040000E1 RID: 225
+ public readonly VmInstrInfo Box_ = new VmInstrInfo(1491096114, VmOperandType.Ot5Int);
+
+ // Token: 0x040000E4 RID: 228
+ public readonly VmInstrInfo U0006U200BU2000 = new VmInstrInfo(-1858492701, VmOperandType.Ot11Nope); // not implemented
+
+ // Token: 0x040000ED RID: 237
+ public readonly VmInstrInfo U0002U2002U2001 = new VmInstrInfo(113196648, VmOperandType.Ot11Nope); // not implemented
+
+ // Token: 0x040000EF RID: 239
+ public readonly VmInstrInfo Ldobj_ = new VmInstrInfo(-564585233, VmOperandType.Ot5Int);
+
+ // Token: 0x04000104 RID: 260
+ public readonly VmInstrInfo Rethrow_ = new VmInstrInfo(989001448, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000125 RID: 293
+ public readonly VmInstrInfo U000EU2000U2000 = new VmInstrInfo(814546329, VmOperandType.Ot11Nope); // not implemented
+
+ // Token: 0x040000B8 RID: 184
+ public readonly VmInstrInfo Newobj_ = new VmInstrInfo(783240206, VmOperandType.Ot5Int);
+
+ // Token: 0x040000B9 RID: 185
+ public readonly VmInstrInfo U0006U2000U2000 = new VmInstrInfo(569679686, VmOperandType.Ot11Nope); // not implemented
+
+ // Token: 0x040000BD RID: 189
+ public readonly VmInstrInfo U0002U200B = new VmInstrInfo(578506051, VmOperandType.Ot6SByte); // leave.s not implemented
+
+ // Token: 0x040000BE RID: 190
+ public readonly VmInstrInfo Leave_ = new VmInstrInfo(182069479, VmOperandType.Ot0UInt);
+
+ // Token: 0x040000B3 RID: 179
+ //public readonly VmInstrInfo U0003U2008 = new VmInstrInfo(56035065, VmOperandType.Nope11);
+
+ // Token: 0x04000052 RID: 82
+ public readonly VmInstrInfo Ldnull_ = new VmInstrInfo(1672432034, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000057 RID: 87
+ public readonly VmInstrInfo Pop_ = new VmInstrInfo(-423590017, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400005B RID: 91
+ public readonly VmInstrInfo Ckfinite_ = new VmInstrInfo(-624596400, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400005D RID: 93
+ public readonly VmInstrInfo Stind_i2_ = new VmInstrInfo(81292670, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400006C RID: 108
+ public readonly VmInstrInfo Stind_r8_ = new VmInstrInfo(-239256528, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000074 RID: 116
+ public readonly VmInstrInfo Ldftn_ = new VmInstrInfo(-204727488, VmOperandType.Ot5Int);
+
+ // Token: 0x04000076 RID: 118
+ public readonly VmInstrInfo Ldlen_ = new VmInstrInfo(-1528794514, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000079 RID: 121
+ public readonly VmInstrInfo Isinst_ = new VmInstrInfo(-1879745689, VmOperandType.Ot5Int);
+
+ // Token: 0x04000081 RID: 129
+ public readonly VmInstrInfo Stind_i8_ = new VmInstrInfo(-279385973, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000087 RID: 135
+ public readonly VmInstrInfo Newarr_ = new VmInstrInfo(1211659810, VmOperandType.Ot5Int);
+
+ // Token: 0x04000089 RID: 137
+ public readonly VmInstrInfo Callvirt_ = new VmInstrInfo(497685394, VmOperandType.Ot5Int);
+
+ // Token: 0x0400008A RID: 138
+ public readonly VmInstrInfo Ldc_i8_ = new VmInstrInfo(598097099, VmOperandType.Ot7Long);
+
+ // Token: 0x0400009A RID: 154
+ public readonly VmInstrInfo Castclass_ = new VmInstrInfo(1816382558, VmOperandType.Ot5Int);
+
+ // Token: 0x0400009C RID: 156
+ public readonly VmInstrInfo Stind_i_ = new VmInstrInfo(-774914583, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400009D RID: 157
+ public readonly VmInstrInfo Ldc_i4_s_ = new VmInstrInfo(1440000960, VmOperandType.Ot6SByte);
+
+ // Token: 0x040000A7 RID: 167
+ public readonly VmInstrInfo Not_ = new VmInstrInfo(2044815068, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000A8 RID: 168
+ public readonly VmInstrInfo Ldtoken_ = new VmInstrInfo(757747961, VmOperandType.Ot5Int);
+
+ // Token: 0x040000AD RID: 173
+ public readonly VmInstrInfo Stind_i4_ = new VmInstrInfo(-587303415, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000B6 RID: 182
+ public readonly VmInstrInfo Ldvirtftn_ = new VmInstrInfo(-1088007919, VmOperandType.Ot5Int);
+
+ // Token: 0x040000BA RID: 186
+ public readonly VmInstrInfo Stind_i1_ = new VmInstrInfo(122987244, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000BC RID: 188
+ public readonly VmInstrInfo Cgt_ = new VmInstrInfo(-290816002, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000C4 RID: 196
+ public readonly VmInstrInfo Stobj_ = new VmInstrInfo(-18831398, VmOperandType.Ot5Int);
+
+ // Token: 0x040000C5 RID: 197
+ public readonly VmInstrInfo Clt_un_ = new VmInstrInfo(-377042092, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000DD RID: 221
+ public readonly VmInstrInfo Cgt_un_ = new VmInstrInfo(-244421767, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000D6 RID: 214
+ public readonly VmInstrInfo Stind_ref_ = new VmInstrInfo(-572078212, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000DF RID: 223
+ public readonly VmInstrInfo Ldloca_ = new VmInstrInfo(-1112986259, VmOperandType.Ot1UShort);
+
+ // Token: 0x040000E9 RID: 233
+ public readonly VmInstrInfo Call_ = new VmInstrInfo(-1118186024, VmOperandType.Ot5Int);
+
+ // Token: 0x040000F9 RID: 249
+ public readonly VmInstrInfo Ldc_r8_ = new VmInstrInfo(-557730397, VmOperandType.Ot4Double);
+
+ // Token: 0x040000FD RID: 253
+ public readonly VmInstrInfo Clt_ = new VmInstrInfo(-1789431058, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000107 RID: 263
+ public readonly VmInstrInfo Ldc_i4_ = new VmInstrInfo(-763377227, VmOperandType.Ot12Int);
+
+ // Token: 0x04000112 RID: 274
+ public readonly VmInstrInfo Ldc_r4_ = new VmInstrInfo(-976252990, VmOperandType.Ot10Float);
+
+ // Token: 0x04000116 RID: 278
+ public readonly VmInstrInfo Stind_r4_ = new VmInstrInfo(2036802079, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000119 RID: 281
+ public readonly VmInstrInfo Nop_ = new VmInstrInfo(-724560934, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400011E RID: 286
+ public readonly VmInstrInfo Ldloca_s_ = new VmInstrInfo(1851592203, VmOperandType.Ot8Byte);
+
+ // Token: 0x04000053 RID: 83
+ public readonly VmInstrInfo Sizeof_ = new VmInstrInfo(-1163259743, VmOperandType.Ot5Int);
+
+ // Token: 0x04000054 RID: 84
+ public readonly VmInstrInfo Ldind_r4_ = new VmInstrInfo(1144322863, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000055 RID: 85
+ public readonly VmInstrInfo Ldelem_i1_ = new VmInstrInfo(322204500, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000056 RID: 86
+ public readonly VmInstrInfo Conv_r8_ = new VmInstrInfo(-195608730, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000058 RID: 88
+ public readonly VmInstrInfo Stelem_i1_ = new VmInstrInfo(-1560659480, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000059 RID: 89
+ public readonly VmInstrInfo Ldstr_ = new VmInstrInfo(-883753595, VmOperandType.Ot5Int);
+
+ // Token: 0x0400005A RID: 90
+ public readonly VmInstrInfo Conv_i4_ = new VmInstrInfo(1738936149, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400005C RID: 92
+ public readonly VmInstrInfo Ldarg_2_ = new VmInstrInfo(917707539, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400005E RID: 94
+ public readonly VmInstrInfo Conv_i1_ = new VmInstrInfo(443736782, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400005F RID: 95
+ public readonly VmInstrInfo Div_ = new VmInstrInfo(873071583, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000060 RID: 96
+ public readonly VmInstrInfo Conv_i_ = new VmInstrInfo(863451657, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000061 RID: 97
+ public readonly VmInstrInfo Stelem_ref_ = new VmInstrInfo(1243606418, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000062 RID: 98
+ public readonly VmInstrInfo Shl_ = new VmInstrInfo(1269228253, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000064 RID: 100
+ public readonly VmInstrInfo Conv_u4_ = new VmInstrInfo(-1046006878, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000066 RID: 102
+ public readonly VmInstrInfo Break_ = new VmInstrInfo(-979485219, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000067 RID: 103
+ public readonly VmInstrInfo Ldc_i4_1_ = new VmInstrInfo(-2108713475, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000069 RID: 105
+ public readonly VmInstrInfo Or_ = new VmInstrInfo(1569462844, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400006A RID: 106
+ public readonly VmInstrInfo Ldelem_ = new VmInstrInfo(-1705118555, VmOperandType.Ot5Int);
+
+ // Token: 0x0400006B RID: 107
+ public readonly VmInstrInfo Conv_u1_ = new VmInstrInfo(1055970854, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400006D RID: 109
+ public readonly VmInstrInfo Ldind_i1_ = new VmInstrInfo(33169414, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400006E RID: 110
+ public readonly VmInstrInfo Ldind_i_ = new VmInstrInfo(-1790442498, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000070 RID: 112
+ public readonly VmInstrInfo Ldsfld_ = new VmInstrInfo(-1369658342, VmOperandType.Ot5Int);
+
+ // Token: 0x04000071 RID: 113
+ public readonly VmInstrInfo Ldloc_ = new VmInstrInfo(766115889, VmOperandType.Ot1UShort);
+
+ // Token: 0x04000072 RID: 114
+ public readonly VmInstrInfo Rem_un_ = new VmInstrInfo(-2121309775, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000073 RID: 115
+ public readonly VmInstrInfo Conv_ovf_i8_ = new VmInstrInfo(-287049786, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000075 RID: 117
+ public readonly VmInstrInfo Ldc_i4_0_ = new VmInstrInfo(89715609, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000078 RID: 120
+ public readonly VmInstrInfo Ldloc_3_ = new VmInstrInfo(1790654656, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400007B RID: 123
+ public readonly VmInstrInfo Ldsflda_ = new VmInstrInfo(-2097007575, VmOperandType.Ot5Int);
+
+ // Token: 0x0400007C RID: 124
+ public readonly VmInstrInfo Add_ovf_ = new VmInstrInfo(-545700640, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400007D RID: 125
+ public readonly VmInstrInfo Refanytype_ = new VmInstrInfo(-971088331, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400007E RID: 126
+ public readonly VmInstrInfo Blt_ = new VmInstrInfo(1978323310, VmOperandType.Ot0UInt);
+
+ // Token: 0x0400007F RID: 127
+ public readonly VmInstrInfo Conv_ovf_u8_un_ = new VmInstrInfo(1527584358, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000083 RID: 131
+ public readonly VmInstrInfo Ldelem_i8_ = new VmInstrInfo(1272142104, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000084 RID: 132
+ public readonly VmInstrInfo Ldc_i4_6_ = new VmInstrInfo(871172961, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000085 RID: 133
+ public readonly VmInstrInfo Starg_s_ = new VmInstrInfo(-687376789, VmOperandType.Ot8Byte);
+
+ // Token: 0x04000088 RID: 136
+ public readonly VmInstrInfo Beq_ = new VmInstrInfo(352236975, VmOperandType.Ot0UInt);
+
+ // Token: 0x0400008B RID: 139
+ public readonly VmInstrInfo Ldfld_ = new VmInstrInfo(-688284774, VmOperandType.Ot5Int);
+
+ // Token: 0x0400008C RID: 140
+ public readonly VmInstrInfo Conv_ovf_i2_un_ = new VmInstrInfo(1663762471, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400008D RID: 141
+ public readonly VmInstrInfo Conv_ovf_i_un_ = new VmInstrInfo(2093357171, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400008E RID: 142
+ public readonly VmInstrInfo Ldelem_u4_ = new VmInstrInfo(896332376, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400008F RID: 143
+ public readonly VmInstrInfo Conv_ovf_u4_un_ = new VmInstrInfo(-107488823, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000090 RID: 144
+ public readonly VmInstrInfo Ldarga_ = new VmInstrInfo(2044160323, VmOperandType.Ot1UShort);
+
+ // Token: 0x04000091 RID: 145
+ public readonly VmInstrInfo Div_un_ = new VmInstrInfo(742839562, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000092 RID: 146
+ public readonly VmInstrInfo Ldelem_r4_ = new VmInstrInfo(-1447311583, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000093 RID: 147
+ public readonly VmInstrInfo And_ = new VmInstrInfo(1968373082, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000094 RID: 148
+ public readonly VmInstrInfo Add_ = new VmInstrInfo(-1892228817, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000095 RID: 149
+ public readonly VmInstrInfo Conv_ovf_u2_ = new VmInstrInfo(1775410326, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000096 RID: 150
+ public readonly VmInstrInfo Xor_ = new VmInstrInfo(-273395395, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000097 RID: 151
+ public readonly VmInstrInfo Stloc_1_ = new VmInstrInfo(-1446892238, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000099 RID: 153
+ public readonly VmInstrInfo Conv_ovf_u2_un_ = new VmInstrInfo(-1274139658, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400009B RID: 155
+ public readonly VmInstrInfo Ldc_i4_3_ = new VmInstrInfo(-722334296, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400009E RID: 158
+ public readonly VmInstrInfo Ldelem_u1_ = new VmInstrInfo(580121148, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400009F RID: 159
+ public readonly VmInstrInfo Ldelem_i4_ = new VmInstrInfo(778369289, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000A0 RID: 160
+ public readonly VmInstrInfo Stfld_ = new VmInstrInfo(1721102239, VmOperandType.Ot5Int);
+
+ // Token: 0x040000A1 RID: 161
+ public readonly VmInstrInfo Ldc_i4_m1_ = new VmInstrInfo(-1374936951, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000A2 RID: 162
+ public readonly VmInstrInfo Brfalse_ = new VmInstrInfo(476056811, VmOperandType.Ot0UInt);
+
+ // Token: 0x040000A3 RID: 163
+ public readonly VmInstrInfo Rem_ = new VmInstrInfo(1127773841, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000A4 RID: 164
+ public readonly VmInstrInfo Neg_ = new VmInstrInfo(1824866698, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000A5 RID: 165
+ public readonly VmInstrInfo Initblk_ = new VmInstrInfo(1848160160, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000A6 RID: 166
+ public readonly VmInstrInfo Ldelem_r8_ = new VmInstrInfo(-522987252, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000A9 RID: 169
+ public readonly VmInstrInfo Cpobj_ = new VmInstrInfo(1238115537, VmOperandType.Ot5Int);
+
+ // Token: 0x040000AA RID: 170
+ public readonly VmInstrInfo Ldarga_s_ = new VmInstrInfo(-1193068213, VmOperandType.Ot8Byte);
+
+ // Token: 0x040000AB RID: 171
+ public readonly VmInstrInfo Br_ = new VmInstrInfo(658728581, VmOperandType.Ot0UInt);
+
+ // Token: 0x040000AC RID: 172
+ public readonly VmInstrInfo Conv_u2_ = new VmInstrInfo(-2099750455, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000AE RID: 174
+ public readonly VmInstrInfo Stelem_i_ = new VmInstrInfo(-358560507, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000AF RID: 175
+ public readonly VmInstrInfo Stloc_s_ = new VmInstrInfo(1804315644, VmOperandType.Ot8Byte);
+
+ // Token: 0x040000B1 RID: 177
+ public readonly VmInstrInfo Ble_un_ = new VmInstrInfo(1001656673, VmOperandType.Ot0UInt);
+
+ // Token: 0x040000B4 RID: 180
+ public readonly VmInstrInfo Ldc_i4_2_ = new VmInstrInfo(-2082446517, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000B5 RID: 181
+ public readonly VmInstrInfo Blt_un_ = new VmInstrInfo(-1002275164, VmOperandType.Ot0UInt);
+
+ // Token: 0x040000B7 RID: 183
+ public readonly VmInstrInfo Ldind_ref_ = new VmInstrInfo(-101579585, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000BB RID: 187
+ public readonly VmInstrInfo Ldind_i2_ = new VmInstrInfo(1338544134, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000BF RID: 191
+ public readonly VmInstrInfo Shr_ = new VmInstrInfo(2061114403, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000C0 RID: 192
+ public readonly VmInstrInfo Sub_ovf_ = new VmInstrInfo(-1326124455, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000C1 RID: 193
+ public readonly VmInstrInfo Mul_ = new VmInstrInfo(-368354161, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000C2 RID: 194
+ public readonly VmInstrInfo Conv_r4_ = new VmInstrInfo(461467744, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000C3 RID: 195
+ public readonly VmInstrInfo Ldarg_s_ = new VmInstrInfo(916919316, VmOperandType.Ot8Byte);
+
+ // Token: 0x040000C7 RID: 199
+ public readonly VmInstrInfo Conv_ovf_u8_ = new VmInstrInfo(-1916788012, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000C8 RID: 200
+ public readonly VmInstrInfo Ldind_u2_ = new VmInstrInfo(-1831891367, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000C9 RID: 201
+ public readonly VmInstrInfo Ldind_u4_ = new VmInstrInfo(-1620795876, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000CA RID: 202
+ public readonly VmInstrInfo Conv_ovf_i4_ = new VmInstrInfo(488024265, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000CD RID: 205
+ public readonly VmInstrInfo Ldarg_1_ = new VmInstrInfo(326597331, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000CE RID: 206
+ public readonly VmInstrInfo Conv_ovf_u_ = new VmInstrInfo(115989675, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000CF RID: 207
+ public readonly VmInstrInfo Ldloc_s_ = new VmInstrInfo(1019004451, VmOperandType.Ot8Byte);
+
+ // Token: 0x040000D0 RID: 208
+ public readonly VmInstrInfo Conv_i2_ = new VmInstrInfo(-108178384, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000D1 RID: 209
+ public readonly VmInstrInfo Conv_ovf_i_ = new VmInstrInfo(-2109763431, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000D2 RID: 210
+ public readonly VmInstrInfo Ble_ = new VmInstrInfo(1321262543, VmOperandType.Ot0UInt);
+
+ // Token: 0x040000D3 RID: 211
+ public readonly VmInstrInfo Unbox_ = new VmInstrInfo(-1668682548, VmOperandType.Ot5Int);
+
+ // Token: 0x040000D4 RID: 212
+ public readonly VmInstrInfo Stelem_r4_ = new VmInstrInfo(-1251429380, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000D5 RID: 213
+ public readonly VmInstrInfo Stloc_3_ = new VmInstrInfo(1073782561, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000D7 RID: 215
+ public readonly VmInstrInfo Brtrue_ = new VmInstrInfo(1985375111, VmOperandType.Ot0UInt);
+
+ // Token: 0x040000D8 RID: 216
+ public readonly VmInstrInfo Stelem_ = new VmInstrInfo(-633052479, VmOperandType.Ot5Int);
+
+ // Token: 0x040000D9 RID: 217
+ public readonly VmInstrInfo Stelem_i4_ = new VmInstrInfo(-638226942, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000DA RID: 218
+ public readonly VmInstrInfo Conv_ovf_u1_un_ = new VmInstrInfo(-854623375, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000DB RID: 219
+ public readonly VmInstrInfo Add_ovf_un_ = new VmInstrInfo(-2145629048, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000DC RID: 220
+ public readonly VmInstrInfo Conv_u8_ = new VmInstrInfo(1396092080, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000DE RID: 222
+ public readonly VmInstrInfo Bgt_ = new VmInstrInfo(-939929863, VmOperandType.Ot0UInt);
+
+ // Token: 0x040000E2 RID: 226
+ public readonly VmInstrInfo Bgt_un_ = new VmInstrInfo(-73779400, VmOperandType.Ot0UInt);
+
+ // Token: 0x040000E3 RID: 227
+ public readonly VmInstrInfo Stelem_r8_ = new VmInstrInfo(849078739, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000E5 RID: 229
+ public readonly VmInstrInfo Mkrefany_ = new VmInstrInfo(1810420701, VmOperandType.Ot5Int);
+
+ // Token: 0x040000E6 RID: 230
+ public readonly VmInstrInfo Conv_ovf_u_un_ = new VmInstrInfo(-1209242284, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000E7 RID: 231
+ public readonly VmInstrInfo Conv_ovf_i1_ = new VmInstrInfo(-1678823314, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000E8 RID: 232
+ public readonly VmInstrInfo Conv_ovf_i1_un_ = new VmInstrInfo(-1171707127, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000EA RID: 234
+ public readonly VmInstrInfo Stsfld_ = new VmInstrInfo(-1272257470, VmOperandType.Ot5Int);
+
+ // Token: 0x040000EB RID: 235
+ public readonly VmInstrInfo Starg_ = new VmInstrInfo(-1559324355, VmOperandType.Ot1UShort);
+
+ // Token: 0x040000EC RID: 236
+ public readonly VmInstrInfo Ldflda_ = new VmInstrInfo(685223722, VmOperandType.Ot5Int);
+
+ // Token: 0x040000EE RID: 238
+ public readonly VmInstrInfo Sub_ = new VmInstrInfo(1925911547, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000F0 RID: 240
+ public readonly VmInstrInfo Conv_ovf_i2_ = new VmInstrInfo(2079826493, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000F1 RID: 241
+ public readonly VmInstrInfo Ldarg_0_ = new VmInstrInfo(-1817778622, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000F2 RID: 242
+ public readonly VmInstrInfo Ldelem_i2_ = new VmInstrInfo(-1703864226, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000F3 RID: 243
+ public readonly VmInstrInfo Ceq_ = new VmInstrInfo(-490385948, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000F4 RID: 244
+ public readonly VmInstrInfo Ldelema_ = new VmInstrInfo(-659575843, VmOperandType.Ot5Int);
+
+ // Token: 0x040000F5 RID: 245
+ public readonly VmInstrInfo Localloc_ = new VmInstrInfo(487454996, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000F6 RID: 246
+ public readonly VmInstrInfo Conv_ovf_i4_un_ = new VmInstrInfo(-900057353, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000F7 RID: 247
+ public readonly VmInstrInfo Bge_un_ = new VmInstrInfo(784647969, VmOperandType.Ot0UInt);
+
+ // Token: 0x040000F8 RID: 248
+ public readonly VmInstrInfo Ldelem_ref_ = new VmInstrInfo(880972378, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000FA RID: 250
+ public readonly VmInstrInfo Conv_ovf_i8_un_ = new VmInstrInfo(20637445, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000FB RID: 251
+ public readonly VmInstrInfo Ldind_i8_ = new VmInstrInfo(-607543449, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000FC RID: 252
+ public readonly VmInstrInfo Refanyval_ = new VmInstrInfo(1010177566, VmOperandType.Ot5Int);
+
+ // Token: 0x040000FE RID: 254
+ public readonly VmInstrInfo Dup_ = new VmInstrInfo(85722172, VmOperandType.Ot11Nope);
+
+ // Token: 0x040000FF RID: 255
+ public readonly VmInstrInfo Stloc_0_ = new VmInstrInfo(-1071153572, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000100 RID: 256
+ public readonly VmInstrInfo Ldc_i4_4_ = new VmInstrInfo(-72363801, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000101 RID: 257
+ public readonly VmInstrInfo Ldind_r8_ = new VmInstrInfo(813030660, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000102 RID: 258
+ public readonly VmInstrInfo Ldc_i4_7_ = new VmInstrInfo(-1136876649, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000103 RID: 259
+ public readonly VmInstrInfo Stelem_i8_ = new VmInstrInfo(588832478, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000105 RID: 261
+ public readonly VmInstrInfo Mul_ovf_un_ = new VmInstrInfo(-356198078, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000106 RID: 262
+ public readonly VmInstrInfo Conv_u_ = new VmInstrInfo(1795519976, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000108 RID: 264
+ public readonly VmInstrInfo Ldelem_i_ = new VmInstrInfo(1499071663, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000109 RID: 265
+ public readonly VmInstrInfo Ldarg_ = new VmInstrInfo(-1071239412, VmOperandType.Ot1UShort);
+
+ // Token: 0x0400010A RID: 266
+ public readonly VmInstrInfo Conv_r_un_ = new VmInstrInfo(-23925463, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400010B RID: 267
+ public readonly VmInstrInfo Ldc_i4_8_ = new VmInstrInfo(1119515810, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400010C RID: 268
+ public readonly VmInstrInfo Conv_i8_ = new VmInstrInfo(1980167243, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400010D RID: 269
+ public readonly VmInstrInfo Ldloc_1_ = new VmInstrInfo(704985473, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400010E RID: 270
+ public readonly VmInstrInfo Ldelem_u2_ = new VmInstrInfo(-1142530894, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400010F RID: 271
+ public readonly VmInstrInfo Throw_ = new VmInstrInfo(-958454075, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000110 RID: 272
+ public readonly VmInstrInfo Cpblk_ = new VmInstrInfo(-123910492, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000111 RID: 273
+ public readonly VmInstrInfo Ldind_u1_ = new VmInstrInfo(1476085916, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000113 RID: 275
+ public readonly VmInstrInfo Stloc_2_ = new VmInstrInfo(392938325, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000114 RID: 276
+ public readonly VmInstrInfo Ldarg_3_ = new VmInstrInfo(-1756998893, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000115 RID: 277
+ public readonly VmInstrInfo Stloc_ = new VmInstrInfo(1447397361, VmOperandType.Ot1UShort);
+
+ // Token: 0x04000117 RID: 279
+ public readonly VmInstrInfo Ldc_i4_5_ = new VmInstrInfo(-656328799, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000118 RID: 280
+ public readonly VmInstrInfo Conv_ovf_u1_ = new VmInstrInfo(344575979, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400011A RID: 282
+ public readonly VmInstrInfo Ldind_i4_ = new VmInstrInfo(234126039, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400011B RID: 283
+ public readonly VmInstrInfo Switch_ = new VmInstrInfo(8625656, VmOperandType.Ot9IntArr);
+
+ // Token: 0x0400011C RID: 284
+ public readonly VmInstrInfo Arglist_ = new VmInstrInfo(1783361912, VmOperandType.Ot11Nope);
+
+ // Token: 0x0400011F RID: 287
+ public readonly VmInstrInfo Shr_un_ = new VmInstrInfo(897680915, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000120 RID: 288
+ public readonly VmInstrInfo Ldloc_2_ = new VmInstrInfo(-17993965, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000121 RID: 289
+ public readonly VmInstrInfo Conv_ovf_u4_ = new VmInstrInfo(1596489702, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000122 RID: 290
+ public readonly VmInstrInfo Bge_ = new VmInstrInfo(-1225693454, VmOperandType.Ot0UInt);
+
+ // Token: 0x04000123 RID: 291
+ public readonly VmInstrInfo Ldloc_0_ = new VmInstrInfo(1021709264, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000124 RID: 292
+ public readonly VmInstrInfo Bne_un_ = new VmInstrInfo(68951288, VmOperandType.Ot0UInt);
+
+ // Token: 0x04000126 RID: 294
+ public readonly VmInstrInfo Stelem_i2_ = new VmInstrInfo(1223054294, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000127 RID: 295
+ public readonly VmInstrInfo Sub_ovf_un_ = new VmInstrInfo(-851734976, VmOperandType.Ot11Nope);
+
+ // Token: 0x04000128 RID: 296
+ public readonly VmInstrInfo Ret_ = new VmInstrInfo(1882847521, VmOperandType.Ot11Nope);
+ #endregion
+ }
+
+ public enum VmOperandType
+ {
+ Ot0UInt, Ot1UShort, Ot2Byte, Ot3UShort, Ot4Double, Ot5Int, Ot6SByte, Ot7Long, Ot8Byte, Ot9IntArr, Ot10Float, Ot11Nope, Ot12Int
+ }
+ // Token: 0x0200005F RID: 95
+ public class VmInstrInfo // \u000F\u2005
+ {
+ // Token: 0x06000377 RID: 887 RVA: 0x00015B74 File Offset: 0x00013D74
+ public VmInstrInfo(int id, VmOperandType operandType)
+ {
+ Id = id;
+ OperandType = operandType;
+ }
+
+ // Token: 0x06000378 RID: 888 RVA: 0x00015B8C File Offset: 0x00013D8C
+ // Token: 0x06000379 RID: 889 RVA: 0x00015B94 File Offset: 0x00013D94
+ // Token: 0x0400018F RID: 399
+ public int Id { get; }
+
+ // Token: 0x0600037A RID: 890 RVA: 0x00015BA0 File Offset: 0x00013DA0
+ // Token: 0x04000190 RID: 400
+ public VmOperandType OperandType { get; }
+
+ // Token: 0x0600037B RID: 891 RVA: 0x00015BA8 File Offset: 0x00013DA8
+ public override bool Equals(object o)
+ {
+ var p = o as VmInstrInfo;
+ return (p != null) && EqualTo(p);
+ }
+
+ // Token: 0x0600037C RID: 892 RVA: 0x00015BD0 File Offset: 0x00013DD0
+ private bool EqualTo(VmInstrInfo p)
+ {
+ return p.Id== Id;
+ }
+
+ // Token: 0x0600037D RID: 893 RVA: 0x00015BE0 File Offset: 0x00013DE0
+ public static bool operator ==(VmInstrInfo o1, VmInstrInfo o2)
+ {
+ // ReSharper disable once PossibleNullReferenceException
+ return o1.EqualTo(o2);
+ }
+
+ // Token: 0x0600037E RID: 894 RVA: 0x00015BEC File Offset: 0x00013DEC
+ public static bool operator !=(VmInstrInfo o1, VmInstrInfo o2)
+ {
+ return !(o1 == o2);
+ }
+
+ // Token: 0x0600037F RID: 895 RVA: 0x00015BF8 File Offset: 0x00013DF8
+ public override int GetHashCode()
+ {
+ return Id.GetHashCode();
+ }
+
+ // Token: 0x06000380 RID: 896 RVA: 0x00015C14 File Offset: 0x00013E14
+ public override string ToString()
+ {
+ return Id.ToString();
+ }
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmMethodHeader.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmMethodHeader.cs
new file mode 100644
index 0000000..0d4a0ab
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmMethodHeader.cs
@@ -0,0 +1,42 @@
+namespace UnitTestProject.RefVm
+{
+ // Token: 0x02000028 RID: 40
+ public sealed class VmMethodHeader // \u0006
+ {
+ // Token: 0x06000120 RID: 288 RVA: 0x00005F08 File Offset: 0x00004108
+ // Token: 0x06000121 RID: 289 RVA: 0x00005F10 File Offset: 0x00004110
+ // Token: 0x04000047 RID: 71
+ public LocalVarType[] LocalVarTypes /* \u0003 */ { get; set; }
+
+ // Token: 0x06000122 RID: 290 RVA: 0x00005F1C File Offset: 0x0000411C
+ // Token: 0x06000123 RID: 291 RVA: 0x00005F24 File Offset: 0x00004124
+ // Token: 0x0400004B RID: 75
+ public ArgTypeToOutput[] ArgsTypeToOutput /* \u000E */ { get; set; }
+
+ // Token: 0x06000124 RID: 292 RVA: 0x00005F30 File Offset: 0x00004130
+ // Token: 0x06000125 RID: 293 RVA: 0x00005F38 File Offset: 0x00004138
+ // Token: 0x04000048 RID: 72
+ public string Name /* \u0002 */ { get; set; }
+
+ // Token: 0x06000126 RID: 294 RVA: 0x00005F44 File Offset: 0x00004144
+ // Token: 0x06000127 RID: 295 RVA: 0x00005F4C File Offset: 0x0000414C
+ // Token: 0x04000046 RID: 70
+ public int ClassId /* \u0002 */ { get; set; }
+
+ // Token: 0x06000128 RID: 296 RVA: 0x00005F58 File Offset: 0x00004158
+ // Token: 0x06000129 RID: 297 RVA: 0x00005F60 File Offset: 0x00004160
+ // Token: 0x04000049 RID: 73
+ public int ReturnTypeId /* \u0008 */ { get; set; }
+
+ // Token: 0x0600012A RID: 298 RVA: 0x00005F6C File Offset: 0x0000416C
+ // Token: 0x0600012B RID: 299 RVA: 0x00005F74 File Offset: 0x00004174
+ // Token: 0x0400004A RID: 74
+ public byte Flags /* \u0006 */ { private get; set; }
+
+ // Token: 0x0600012C RID: 300 RVA: 0x00005F80 File Offset: 0x00004180
+ public bool IsStatic() // \u0002
+ {
+ return (Flags & 2) > 0;
+ }
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmPosParser.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmPosParser.cs
new file mode 100644
index 0000000..7b3fb2a
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmPosParser.cs
@@ -0,0 +1,96 @@
+using System;
+using System.IO;
+
+namespace UnitTestProject.RefVm
+{
+ internal static class VmPosParser // \u0006\u2006
+ {
+ // Token: 0x0600016A RID: 362 RVA: 0x00007810 File Offset: 0x00005A10
+ public static byte[] Parse(string pos) // dest
+ {
+ if (pos == null)
+ {
+ throw new Exception();
+ }
+ var memoryStream = new MemoryStream(pos.Length * 4 / 5);
+ byte[] result;
+ using(memoryStream)
+ {
+ var cnt = 0;
+ var val = 0u;
+ foreach (var c in pos)
+ {
+ if (c == 'z' && cnt == 0)
+ {
+ WriteDwPart(memoryStream, val, 0);
+ }
+ else
+ {
+ if (c< '!' || c> 'u')
+ {
+ throw new Exception();
+ }
+ checked
+ {
+ val += (uint)(Arr[cnt] * (ulong)checked(c - '!'));
+ }
+ cnt++;
+ if (cnt == 5)
+ {
+ WriteDwPart(memoryStream, val, 0);
+ cnt = 0;
+ val = 0u;
+ }
+ }
+ }
+ if (cnt == 1)
+ {
+ throw new Exception();
+ }
+ if (cnt > 1)
+ {
+ for (var j = cnt; j < 5; j++)
+ {
+ checked
+ {
+ val += 84u * Arr[j];
+ }
+ }
+ WriteDwPart(memoryStream, val, 5 - cnt);
+ }
+ result = memoryStream.ToArray();
+ }
+ return result;
+ }
+
+ // Token: 0x0600016B RID: 363 RVA: 0x00007900 File Offset: 0x00005B00
+ private static void WriteDwPart(Stream dest, uint val, int ignoreLow) // dest
+ {
+ dest.WriteByte((byte)(val >> 24));
+ if (ignoreLow == 3)
+ {
+ return;
+ }
+ dest.WriteByte((byte)(val >> 16 & 255u));
+ if (ignoreLow == 2)
+ {
+ return;
+ }
+ dest.WriteByte((byte)(val >> 8 & 255u));
+ if (ignoreLow == 1)
+ {
+ return;
+ }
+ dest.WriteByte((byte)(val & 255u));
+ }
+
+ // Token: 0x04000131 RID: 305
+ private static readonly uint[] Arr = {
+ 52200625u,
+ 614125u,
+ 7225u,
+ 85u,
+ 1u
+ };
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmStreamWrapper.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmStreamWrapper.cs
new file mode 100644
index 0000000..8da27f8
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/RefVm/VmStreamWrapper.cs
@@ -0,0 +1,116 @@
+using System;
+using System.IO;
+
+namespace UnitTestProject.RefVm
+{
+ // Token: 0x02000021 RID: 33
+ public sealed class VmStreamWrapper : Stream // \u0005\u2005
+ {
+ // Token: 0x060000CB RID: 203 RVA: 0x00004A20 File Offset: 0x00002C20
+ public VmStreamWrapper(Stream src, int xorKey)
+ {
+ SetStream(src);
+ _xorKey = xorKey;
+ }
+
+ // Token: 0x060000CC RID: 204 RVA: 0x00004A38 File Offset: 0x00002C38
+ public Stream GetStream() // \u0008\u2003\u2003\u2001\u2001\u2000\u2000\u2008\u2000\u2001\u2000\u2008\u200A\u2008\u200B\u2003\u200B
+ {
+ return _srcStream;
+ }
+
+ // Token: 0x060000CD RID: 205 RVA: 0x00004A40 File Offset: 0x00002C40
+ private void SetStream(Stream src) // \u0002
+ {
+ _srcStream = src;
+ }
+
+ // Token: 0x17000001 RID: 1
+ // (get) Token: 0x060000CE RID: 206 RVA: 0x00004A4C File Offset: 0x00002C4C
+ public override bool CanRead => GetStream().CanRead;
+
+ // Token: 0x17000002 RID: 2
+ // (get) Token: 0x060000CF RID: 207 RVA: 0x00004A5C File Offset: 0x00002C5C
+ public override bool CanSeek => GetStream().CanSeek;
+
+ // Token: 0x17000003 RID: 3
+ // (get) Token: 0x060000D0 RID: 208 RVA: 0x00004A6C File Offset: 0x00002C6C
+ public override bool CanWrite => GetStream().CanWrite;
+
+ // Token: 0x060000D1 RID: 209 RVA: 0x00004A7C File Offset: 0x00002C7C
+ public override void Flush()
+ {
+ GetStream().Flush();
+ }
+
+ // Token: 0x17000004 RID: 4
+ // (get) Token: 0x060000D2 RID: 210 RVA: 0x00004A8C File Offset: 0x00002C8C
+ public override long Length => GetStream().Length;
+
+ // Token: 0x17000005 RID: 5
+ // (get) Token: 0x060000D3 RID: 211 RVA: 0x00004A9C File Offset: 0x00002C9C
+ // (set) Token: 0x060000D4 RID: 212 RVA: 0x00004AAC File Offset: 0x00002CAC
+ public override long Position
+ {
+ get
+ {
+ return GetStream().Position;
+ }
+ set
+ {
+ GetStream().Position = value;
+ }
+ }
+
+ // Token: 0x060000D5 RID: 213 RVA: 0x00004ABC File Offset: 0x00002CBC
+ private byte Xor(byte data, long key2) // \u0002
+ {
+ var b = (byte)(_xorKey ^ -559030707 ^ (int)((uint)key2));
+ return (byte)(data ^ b);
+ }
+
+ // Token: 0x060000D6 RID: 214 RVA: 0x00004AE0 File Offset: 0x00002CE0
+ public override void Write(byte[] data, int offset, int size)
+ {
+ var array = new byte[size];
+ Buffer.BlockCopy(data, offset, array, 0, size);
+ var position = Position;
+ for (var i = 0; i < size; i++)
+ {
+ array[i] = Xor(array[i], position + i);
+ }
+ GetStream().Write(array, 0, size);
+ }
+
+ // Token: 0x060000D7 RID: 215 RVA: 0x00004B30 File Offset: 0x00002D30
+ public override int Read(byte[] data, int offset, int size)
+ {
+ var position = Position;
+ var array = new byte[size];
+ var num = GetStream().Read(array, 0, size);
+ for (var i = 0; i < num; i++)
+ {
+ data[i + offset] = Xor(array[i], position + i);
+ }
+ return num;
+ }
+
+ // Token: 0x060000D8 RID: 216 RVA: 0x00004B7C File Offset: 0x00002D7C
+ public override long Seek(long pos, SeekOrigin from)
+ {
+ return GetStream().Seek(pos, from);
+ }
+
+ // Token: 0x060000D9 RID: 217 RVA: 0x00004B8C File Offset: 0x00002D8C
+ public override void SetLength(long val)
+ {
+ GetStream().SetLength(val);
+ }
+
+ // Token: 0x0400002A RID: 42
+ private readonly int _xorKey; // \u0002
+
+ // Token: 0x0400002B RID: 43
+ private Stream _srcStream; // \u0003
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTest1.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTest1.cs
new file mode 100644
index 0000000..ea67e80
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTest1.cs
@@ -0,0 +1,110 @@
+using System;
+using System.Net;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using VMProtect;
+
+namespace UnitTestProject
+{
+ [TestClass]
+ public class UnitTest1
+ {
+ [TestMethod]
+ // ReSharper disable once InconsistentNaming
+ public void TestRC5()
+ {
+ var key = CipherRC5.CreateRandomKey();
+ var rc5 = new CipherRC5(key);
+
+ var dataStr = "Тестовые данные для TestRC5";
+ var dataBytes = Encoding.UTF8.GetBytes(dataStr);
+ Array.Resize(ref dataBytes, (dataBytes.Length + 7)/8*8);
+
+ var encodedBytes = rc5.Encrypt(dataBytes);
+ var dataBytes2 = rc5.Decrypt(encodedBytes);
+
+ CollectionAssert.AreNotEqual(dataBytes, encodedBytes);
+ CollectionAssert.AreEqual(dataBytes, dataBytes2);
+ }
+
+ [TestMethod]
+ public void TestHwid()
+ {
+ var hwid = new HardwareID();
+ Assert.AreNotSame(0, hwid.ToString().Length);
+ var machine = Dns.GetHostName().ToUpperInvariant();
+ var txtHwid = hwid.ToString();
+ if (machine == "ACER-V3")
+ Assert.AreEqual("2D3kAD28P7M7soVoCjyOUA==", txtHwid);
+ else if (machine == "WORK")
+ Assert.AreEqual("AIUkDL3k4HTLFrVrPmOIpw==", txtHwid);
+ else if (machine == "BUILD7N1")
+ Assert.AreEqual("HBG8w5UkOMh714KeZow8vg==", txtHwid);
+ else
+ Assert.Fail("Append branch for machine '{0}' with result '{1}'", machine, txtHwid);
+ }
+
+ [TestMethod]
+ public void TestHwidCompare()
+ {
+ var hwid = new HardwareID();
+ var cur = hwid.GetBytes();
+ var test = new byte[cur.Length];
+
+ Array.Copy(cur, test, cur.Length);
+ // change one id
+ for (var i = 0; i < cur.Length; i += 4)
+ {
+ test[i] = cur[i];
+ switch (test[i] & 3) {
+ case 3:
+ test[i] ^= 4;
+ break;
+ }
+ }
+ Assert.IsTrue(hwid.IsCorrect(test));
+
+
+ // change two ids
+ Array.Copy(cur, test, cur.Length);
+ for (var i = 0; i < cur.Length; i += 4)
+ {
+ switch (test[i] & 3)
+ {
+ case 2:
+ case 3:
+ test[i] ^= 4;
+ break;
+ }
+ }
+ Assert.IsFalse(hwid.IsCorrect(test));
+
+ // change three ids
+ Array.Copy(cur, test, cur.Length);
+ for (var i = 0; i < cur.Length; i += 4)
+ {
+ switch (test[i] & 3)
+ {
+ case 2:
+ case 3:
+ test[i] ^= 4;
+ break;
+ }
+ }
+ Assert.IsFalse(hwid.IsCorrect(test));
+
+ // change cpu`s id
+ Array.Copy(cur, test, cur.Length);
+ for (var i = 0; i < cur.Length; i += 4)
+ {
+ switch (test[i] & 3)
+ {
+ case 0:
+ test[i] ^= 4;
+ break;
+ }
+ }
+ Assert.IsFalse(hwid.IsCorrect(test));
+ }
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTestCombine.cs b/runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTestCombine.cs
new file mode 100644
index 0000000..fb1a6db
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTestCombine.cs
@@ -0,0 +1,1715 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System.Reflection.Emit;
+using System.Runtime.InteropServices;
+using UnitTestProject.RefVm;
+using VMProtect;
+using OpCodes = System.Reflection.Emit.OpCodes;
+
+namespace UnitTestProject
+{
+ [TestClass]
+ public class UnitTestCombine
+ {
+ // шаблон для окружающего кода для некой инструкции
+ public enum CodeTemplate
+ {
+ BranchTwoOpBool, // 2 операнда на стеке, 2 ветки исполнения (одна возвращает true, другая false)
+ SingleOpAny, // 1 операнд на стеке, инструкция, возвращающая разные типы
+ TwoOpBool, // 2 операнда на стеке, инструкция, возвращающая bool
+ TwoOpAny, // 2 операнда на стеке, инструкция, возвращающая разные типы
+ }
+
+ [TestMethod]
+ public void TestMethodRefVm()
+ {
+ InitStrings();
+ TestMethod(new MsilToVmTestCompilerRefVm());
+ }
+
+ [TestMethod]
+ public void TestMethodVmp()
+ {
+ TestMethod(new MsilToVmTestCompilerVmp());
+ }
+
+ [SuppressMessage("ReSharper", "RedundantCast")]
+ public void TestMethod(MsilToVmTestCompiler c)
+ {
+ // типовые и крайние значения следующих типов:
+ // SByte, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64,
+ // float, double,
+ // LongEnum, ULongEnum, Char, SByteEnum, ByteEnum, ShortEnum, UShortEnum, IntEnum, UIntEnum
+ // bool, object, IntPtr, UIntPtr
+ //TODO: decimal
+ #region valsVector
+ // ReSharper disable once RedundantExplicitArrayCreation
+ var valsVector = new object []
+ {
+ (SByte)0, (SByte)1, (SByte)(-1), SByte.MaxValue, SByte.MinValue, (SByte)0x55, // SByte
+ (Byte)0, (Byte)1, Byte.MaxValue, (Byte)0xAA, // Byte
+ (Int16)0, (Int16)1, (Int16)(-1), Int16.MaxValue, Int16.MinValue, (Int16)0x55AA, // Int16
+ (UInt16)0, (UInt16)1, UInt16.MaxValue, (UInt16)0xAA55, // UInt16
+ 0, 1, -1, Int32.MaxValue, Int32.MinValue, 0x55AA55AA, // Int32
+ (UInt32)0, (UInt32)1, UInt32.MaxValue, 0xAA5555AA, // UInt32
+ (Int64)0, (Int64)1, (Int64)(-1), Int64.MaxValue, Int64.MinValue, 0x55AA55AA55AA55AA, // Int64
+ (UInt64)0, (UInt64)1, UInt64.MaxValue, 0xAA5555AAAA5555AA, // UInt64
+ (float)0, (float)1, (float)(-1), float.MaxValue, float.MinValue, float.Epsilon, float.NaN,
+ float.NegativeInfinity, float.PositiveInfinity, (float)(5678.1234),(float)(1234.5678), (float)(-5678.1234), (float)(-1234.5678),
+ (float)(2147483647.0 * 3.0), (float)(-2147483647.0 * 3.0), (float)(9223372336854775807.0 * 3.0), -(float)(9223372336854775807.0 * 3.0), // float
+ (double)0, (double)1, (double)(-1), double.MaxValue, double.MinValue, double.Epsilon, double.NaN,
+ double.NegativeInfinity, double.PositiveInfinity, 5678.1234, 1234.5678, -5678.1234, -1234.5678,
+ (double)(2147483647.0 * 3.0), (double)(-2147483647.0 * 3.0), (double)9223372336854775807.0 * 3.0, -(double)9223372336854775807.0 * 3.0, // double
+ (MsilToVmTestCompiler.LongEnum)0, (MsilToVmTestCompiler.LongEnum)1, (MsilToVmTestCompiler.LongEnum)(-1), (MsilToVmTestCompiler.LongEnum)Int64.MaxValue, (MsilToVmTestCompiler.LongEnum)Int64.MinValue, (MsilToVmTestCompiler.LongEnum)0x55AA55AA55AA55AA, // LongEnum
+ (MsilToVmTestCompiler.ULongEnum)0, (MsilToVmTestCompiler.ULongEnum)1, (MsilToVmTestCompiler.ULongEnum)UInt64.MaxValue, (MsilToVmTestCompiler.ULongEnum)0xAA5555AAAA5555AA, // ULongEnum
+ (Char)0, (Char)1, 'Ю', Char.MaxValue, (Char)0xAA55, // Char
+ (MsilToVmTestCompiler.SByteEnum)0, (MsilToVmTestCompiler.SByteEnum)1, (MsilToVmTestCompiler.SByteEnum)(-1), (MsilToVmTestCompiler.SByteEnum)sbyte.MaxValue, (MsilToVmTestCompiler.SByteEnum)sbyte.MinValue, (MsilToVmTestCompiler.SByteEnum)0x55, // SByteEnum
+ (MsilToVmTestCompiler.ByteEnum)0, (MsilToVmTestCompiler.ByteEnum)1, (MsilToVmTestCompiler.ByteEnum)Byte.MaxValue, (MsilToVmTestCompiler.ByteEnum)0xAA, // ByteEnum
+ (MsilToVmTestCompiler.ShortEnum)0, (MsilToVmTestCompiler.ShortEnum)1, (MsilToVmTestCompiler.ShortEnum)(-1), (MsilToVmTestCompiler.ShortEnum)short.MaxValue, (MsilToVmTestCompiler.ShortEnum)short.MinValue, (MsilToVmTestCompiler.ShortEnum)0x55AA, // ShortEnum
+ (MsilToVmTestCompiler.UShortEnum)0, (MsilToVmTestCompiler.UShortEnum)1, (MsilToVmTestCompiler.UShortEnum)ushort.MaxValue, (MsilToVmTestCompiler.UShortEnum)0xAA55, // UShortEnum
+ (MsilToVmTestCompiler.IntEnum)0, (MsilToVmTestCompiler.IntEnum)1, (MsilToVmTestCompiler.IntEnum)(-1), (MsilToVmTestCompiler.IntEnum)int.MaxValue, (MsilToVmTestCompiler.IntEnum)int.MinValue, (MsilToVmTestCompiler.IntEnum)0x55AA55AA, // IntEnum
+ (MsilToVmTestCompiler.UIntEnum)0, (MsilToVmTestCompiler.UIntEnum)1, (MsilToVmTestCompiler.UIntEnum)uint.MaxValue, (MsilToVmTestCompiler.UIntEnum)0xAA5555AA, // UIntEnum
+ true, false, // bool
+ new object(), //object
+ new IntPtr(0), new UIntPtr(0), // IntPtr, UIntPtr
+ };
+#endregion
+ var errCounters = new int[(int)MsilToVmTestCompiler.InvokeTestCombineError.Cnt];
+ var operations = new List<KeyValuePair<OpCode, CodeTemplate>>
+ {
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Add, CodeTemplate.TwoOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Add_Ovf, CodeTemplate.TwoOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Add_Ovf_Un, CodeTemplate.TwoOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.And, CodeTemplate.TwoOpAny),
+ //Arglist не годится для этого теста
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Beq_S, CodeTemplate.BranchTwoOpBool),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Bge_S, CodeTemplate.BranchTwoOpBool),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Bge_Un_S, CodeTemplate.BranchTwoOpBool),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Bgt_S, CodeTemplate.BranchTwoOpBool),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Bgt_Un_S, CodeTemplate.BranchTwoOpBool),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Ble_S, CodeTemplate.BranchTwoOpBool),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Ble_Un_S, CodeTemplate.BranchTwoOpBool),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Blt_S, CodeTemplate.BranchTwoOpBool),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Blt_Un_S, CodeTemplate.BranchTwoOpBool),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Bne_Un_S, CodeTemplate.BranchTwoOpBool),
+ //TODO Box
+ //Br_S тестируется неявно в этом тесте
+ //Break не годится для этого теста
+ //TODO Brfalse_S
+ //TODO Brtrue_S
+ //Call тестируется в TestNewobj
+ //Calli Callvirt Castclass не годятся для этого теста
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Ceq, CodeTemplate.TwoOpBool),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Cgt, CodeTemplate.TwoOpBool),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Cgt_Un, CodeTemplate.TwoOpBool),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Ckfinite, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Clt, CodeTemplate.TwoOpBool),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Clt_Un, CodeTemplate.TwoOpBool),
+ //Constrained не годится для этого теста
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_I, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_I1, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_I2, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_I4, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_I8, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_I, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_I1, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_I1_Un, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_I2, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_I2_Un, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_I4, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_I4_Un, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_I8, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_I8_Un, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_I_Un, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_U, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_U1, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_U1_Un, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_U2, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_U2_Un, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_U4, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_U4_Un, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_U8, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_U8_Un, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_Ovf_U_Un, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_R4, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_R8, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_R_Un, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_U, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_U1, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_U2, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_U4, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_U8, CodeTemplate.SingleOpAny),
+ //Cpblk Cpobj не годятся для этого теста
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Div, CodeTemplate.TwoOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Div_Un, CodeTemplate.TwoOpAny),
+ //TODO: Dup
+ //Endfilter Endfinally Initblk Initobj Isinst Jmp Ldarg не годятся для этого теста
+ //Ldarg_0 тестируется неявно в этом тесте
+ //Ldarg_1 тестируется неявно в этом тесте
+ //Ldarg_2 Ldarg_3 Ldarg_S Ldarga не годятся для этого теста
+ //Ldarga_S тестируется в TestNewobj
+ //Ldc_I4 не годится для этого теста
+ //Ldc_I4_0 тестируется неявно в этом тесте
+ //Ldc_I4_1 тестируется неявно в этом тесте
+ //Ldc_I4_2 Ldc_I4_3 Ldc_I4_4 Ldc_I4_5 Ldc_I4_6 Ldc_I4_7 Ldc_I4_8 Ldc_I4_M1 Ldc_I4_S Ldc_I8 Ldc_R4 Ldc_R8 не годятся для этого теста
+ //Ldelem* Ldfld Ldflda Ldftn Ldind_* Ldlen Ldloc* Ldnull Ldobj Ldsfld Ldsflda Ldstr Ldtoken Ldvirtftn Leave Leave_S Localloc Mkrefany не годятся для этого теста
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Mul, CodeTemplate.TwoOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Mul_Ovf, CodeTemplate.TwoOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Mul_Ovf_Un, CodeTemplate.TwoOpAny),
+ //TODO new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Neg, CodeTemplate.SingleOp),
+ //Newarr не годится для этого теста
+ //Newobj тестируется в TestNewobj
+ //Nop не годится для этого теста
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Not, CodeTemplate.SingleOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Or, CodeTemplate.TwoOpAny),
+ //Pop Prefix* Readonly Refanytype Refanyval не годятся для этого теста
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Rem, CodeTemplate.TwoOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Rem_Un, CodeTemplate.TwoOpAny),
+ //Ret тестируется неявно в этом тесте
+ //Rethrow не годится для этого теста
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Shl, CodeTemplate.TwoOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Shr, CodeTemplate.TwoOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Shr_Un, CodeTemplate.TwoOpAny),
+ //Sizeof
+ //St* не годятся для этого теста
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Sub, CodeTemplate.TwoOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Sub_Ovf, CodeTemplate.TwoOpAny),
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Sub_Ovf_Un, CodeTemplate.TwoOpAny),
+ //Switch Tailcall Throw Unaligned
+ //TODO Unbox
+ //TODO Unbox_Any
+ //Volatile не годится для этого теста
+ new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Xor, CodeTemplate.TwoOpAny),
+ };
+ foreach (var op in operations)
+ {
+ switch (op.Value)
+ {
+ case CodeTemplate.BranchTwoOpBool:
+ case CodeTemplate.TwoOpBool:
+ case CodeTemplate.TwoOpAny:
+ TestOperationTwoOp(c, op, valsVector, errCounters);
+ break;
+ case CodeTemplate.SingleOpAny:
+ TestOperationSingleOp(c, op, valsVector, errCounters);
+ break;
+ default:
+ Assert.Fail("Unsupported op.Value: {0}", op.Value);
+ break;
+ }
+ }
+ Console.Error.WriteLine("--- {0} results ---", IntPtr.Size == 4 ? "x86" : "x64");
+ var sum = 0;
+ for (var i = 0; i < errCounters.Length; i++)
+ {
+ Console.Error.WriteLine("{0}: {1}", (MsilToVmTestCompiler.InvokeTestCombineError)i, errCounters[i]);
+ sum += errCounters[i];
+ }
+ Console.Error.WriteLine("--- TOTAL: {0} ---", sum);
+ Assert.AreEqual(sum, errCounters[(int)MsilToVmTestCompiler.InvokeTestCombineError.NoError] +
+ errCounters[(int)MsilToVmTestCompiler.InvokeTestCombineError.NoErrorByStdEx]);
+ Console.Error.WriteLine(sum == errCounters[(int) MsilToVmTestCompiler.InvokeTestCombineError.NoError] +
+ errCounters[(int) MsilToVmTestCompiler.InvokeTestCombineError.NoErrorByStdEx]
+ ? "TEST PASSED"
+ : "TEST FAILED");
+ }
+
+ private void TestOperationTwoOp(MsilToVmTestCompiler c, KeyValuePair<OpCode, CodeTemplate> op, object[] valsVector, int[] errCounters)
+ {
+ foreach (var i in valsVector)
+ {
+ foreach (var j in valsVector)
+ {
+ object[] parameters = {i, j};
+ string err, istr = i.ToString(), jstr = j.ToString();
+ if (i is Char)
+ istr = $@"'\{Convert.ToInt32(i)}'";
+ if (j is Char)
+ jstr = $@"'\{Convert.ToInt32(j)}'";
+
+ var res = TestOperation(c, op, parameters, errCounters, out err);
+ if(res > MsilToVmTestCompiler.InvokeTestCombineError.NoErrorByStdEx)
+ Console.Error.WriteLine("{0}.{1}(({4}){2}, ({5}){3}) = {6}", op.Key, op.Value,
+ istr, jstr, i.GetType().FullName, j.GetType().FullName, err);
+ }
+ }
+ }
+
+ private void TestOperationSingleOp(MsilToVmTestCompiler c, KeyValuePair<OpCode, CodeTemplate> op, object[] valsVector, int[] errCounters)
+ {
+ foreach (object i in valsVector)
+ {
+ object[] parameters = { i };
+ string err, istr = i.ToString();
+ if (i is Char)
+ istr = $@"'\{Convert.ToInt32(i)}'";
+ var res = TestOperation(c, op, parameters, errCounters, out err);
+ if (res > MsilToVmTestCompiler.InvokeTestCombineError.NoErrorByStdEx)
+ Console.Error.WriteLine("{0}.{1}(({3}){2}) = {4}", op.Key, op.Value, istr, i.GetType().FullName, err);
+ }
+ }
+
+ [TestMethod]
+ public void TempRefVm()
+ {
+ InitStrings();
+ var errCounters = new int[(int)MsilToVmTestCompiler.InvokeTestCombineError.Cnt];
+ string err;
+ TestOperation(new MsilToVmTestCompilerRefVm(), new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Add_Ovf_Un, CodeTemplate.TwoOpAny),
+ // ReSharper disable once RedundantExplicitArrayCreation
+ new object[] { new object(), (System.SByte)0 }, errCounters, out err);
+ Assert.AreEqual(1, errCounters[0] + errCounters[1]);
+ }
+
+ [TestMethod]
+ public void TempVmp()
+ {
+ var errCounters = new int[(int)MsilToVmTestCompiler.InvokeTestCombineError.Cnt];
+ string err;
+ TestOperation(new MsilToVmTestCompilerVmp(), new KeyValuePair<OpCode, CodeTemplate>(OpCodes.Conv_U4, CodeTemplate.SingleOpAny),
+ // ReSharper disable once RedundantCast
+ new object[] { (Int32)0 }, errCounters, out err);
+ Console.WriteLine(err);
+ Assert.AreEqual(1, errCounters[0] + errCounters[1]);
+ }
+
+ private static void InitStrings()
+ {
+ StringDecryptor.SetString(-1550347095, "The value is not finite real number.");
+ }
+
+ private MsilToVmTestCompiler.InvokeTestCombineError TestOperation(
+ MsilToVmTestCompiler c, KeyValuePair<OpCode, CodeTemplate> op, object[] parameters, int [] errCounters, out string err)
+ {
+ DynamicMethod dyn;
+ err = "";
+ var types = parameters.Select(o => o.GetType()).ToArray();
+ switch (op.Value)
+ {
+ case CodeTemplate.BranchTwoOpBool:
+ dyn = DynBranch2Op(op, types);
+ break;
+ case CodeTemplate.SingleOpAny:
+ dyn = DynSingleOpAny(op, types);
+ break;
+ case CodeTemplate.TwoOpBool:
+ dyn = Dyn2OpBool(op, types);
+ break;
+ case CodeTemplate.TwoOpAny:
+ dyn = Dyn2OpAny(op, types);
+ break;
+ default:
+ Assert.Fail("Unsupported op.Value: {0}", op.Value);
+ // ReSharper disable once HeuristicUnreachableCode
+ return MsilToVmTestCompiler.InvokeTestCombineError.Cnt;
+ }
+ object dynRet, vmRet;
+ var ret = c.InvokeTestCombine(dyn, parameters, out dynRet, out vmRet, out err);
+ // TODO: для регрессии надо как-то научиться закладывать сюда все правильные результаты
+ if (errCounters != null)
+ {
+ if (ret > MsilToVmTestCompiler.InvokeTestCombineError.NoErrorByStdEx &&
+ ExtendedEcma335.Check(op, parameters, vmRet))
+ {
+ ret = MsilToVmTestCompiler.InvokeTestCombineError.NoErrorByStdEx;
+ }
+
+ errCounters[(int)ret]++;
+ }
+ return ret;
+ }
+
+ private DynamicMethod DynSingleOpAny(KeyValuePair<OpCode, CodeTemplate> op, Type[] types)
+ {
+ Type pushedT;
+ switch (op.Key.StackBehaviourPush)
+ {
+ default:
+ Assert.Fail("DynSingleOp unsupported StackBehaviourPush={0}", op.Key.StackBehaviourPush);
+ // ReSharper disable once HeuristicUnreachableCode
+ return null;
+ case StackBehaviour.Pushi:
+ pushedT = typeof(Int32);
+ break;
+ case StackBehaviour.Pushi8:
+ pushedT = typeof(Int64);
+ break;
+ case StackBehaviour.Pushr4:
+ pushedT = typeof(float);
+ break;
+ case StackBehaviour.Pushr8:
+ pushedT = typeof(double);
+ break;
+ case StackBehaviour.Push1:
+ pushedT = CompatibleType(types[0], types[0], false);
+ if (pushedT == typeof(object)) pushedT = typeof(IntPtr);
+ break;
+ }
+ if ((IntPtr.Size == 8) && (op.Key.Equals(OpCodes.Conv_I) || op.Key.Equals(OpCodes.Conv_Ovf_I) || op.Key.Equals(OpCodes.Conv_Ovf_I_Un)))
+ pushedT = typeof(Int64);
+ if (op.Key.Equals(OpCodes.Conv_U) ||op.Key.Equals(OpCodes.Conv_Ovf_U) || op.Key.Equals(OpCodes.Conv_Ovf_U_Un))
+ pushedT = (IntPtr.Size == 8) ? typeof(UInt64) : typeof(UInt32);
+ var dyn = new DynamicMethod(op.Key.Name, pushedT, types, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(op.Key);
+ gen.Emit(OpCodes.Ret);
+
+ return dyn;
+ }
+
+ internal class ClassNewobj
+ {
+ public const long Check = 0xF00D;
+ public long Ptr;
+ public unsafe ClassNewobj(byte *ptr)
+ {
+ Ptr = (long) ptr;
+ }
+ }
+ public static unsafe object StatNewobj(IntPtr ptr)
+ {
+ return new ClassNewobj((byte *)ptr.ToPointer());
+ }
+
+ [TestMethod]
+ [SuppressMessage("ReSharper", "PossibleNullReferenceException")]
+ public void TestNewobj() //https://ursoft.asuscomm.com:8080/browse/VMP-134?focusedCommentId=15312&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15312
+ {
+ InitStrings();
+ MsilToVmTestCompiler c = new MsilToVmTestCompilerVmp();
+ var mi = typeof (UnitTestCombine).GetMethod("StatNewobj");
+ var no = (ClassNewobj)c.Invoke(new object[] {new IntPtr(ClassNewobj.Check)},
+ c.CreateVmStream(mi.ReturnType, mi.GetParameters(),
+ mi.GetMethodBody().LocalVariables.Select(o => o.LocalType).ToArray(), mi.GetMethodBody().GetILAsByteArray()));
+ Assert.AreEqual(ClassNewobj.Check, no.Ptr);
+ }
+
+ private static DynamicMethod DynBranch2Op(KeyValuePair<OpCode, CodeTemplate> op, Type[] types)
+ {
+ var dyn = new DynamicMethod(op.Key.Name, typeof(bool), types, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+ var retTrue = gen.DefineLabel();
+ var endOfMthd = gen.DefineLabel();
+
+ gen.Emit(OpCodes.Ldarg_1);
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(op.Key, retTrue);
+
+ gen.Emit(OpCodes.Ldc_I4_0);
+ gen.Emit(OpCodes.Br_S, endOfMthd);
+
+ gen.MarkLabel(retTrue);
+ gen.Emit(OpCodes.Ldc_I4_1);
+
+ gen.MarkLabel(endOfMthd);
+ gen.Emit(OpCodes.Ret);
+ return dyn;
+ }
+
+ private static DynamicMethod Dyn2OpAny(KeyValuePair<OpCode, CodeTemplate> op, Type[] types)
+ {
+ Type pushedT;
+ switch (op.Key.StackBehaviourPush)
+ {
+ default:
+ Assert.Fail("Dyn2OpAny unsupported StackBehaviourPush={0}", op.Key.StackBehaviourPush);
+ // ReSharper disable once HeuristicUnreachableCode
+ return null;
+ case StackBehaviour.Pushi:
+ pushedT = typeof(Int32);
+ break;
+ case StackBehaviour.Pushi8:
+ pushedT = typeof(Int64);
+ break;
+ case StackBehaviour.Pushr4:
+ pushedT = typeof(float);
+ break;
+ case StackBehaviour.Pushr8:
+ pushedT = typeof(double);
+ break;
+ case StackBehaviour.Push1:
+ pushedT = (op.Key.Value == OpCodes.Shl.Value || op.Key.Value == OpCodes.Shr.Value || op.Key.Value == OpCodes.Shr_Un.Value) ? types[1]: types[0];
+ pushedT = CompatibleType(pushedT, types[1], !op.Key.Name.EndsWith("_Un"));
+ if (pushedT == typeof (object)) pushedT = typeof(IntPtr);
+ break;
+ }
+ return Dyn2Op(op, types, pushedT);
+ }
+
+ public static Type CompatibleType(Type type0, Type type1, bool signed)
+ {
+ if (type0.IsEnum) type0 = type0.GetEnumUnderlyingType();
+ if (type1.IsEnum) type1 = type1.GetEnumUnderlyingType();
+ if (type0 == typeof (bool) && type1 == typeof (bool)) return typeof (sbyte); // true + true = 2
+ if (type0 == typeof (IntPtr)) type0 = IntPtr.Size == 4 ? typeof (Int32) : typeof (Int64);
+ if (type0 == typeof (UIntPtr)) type0 = IntPtr.Size == 4 ? typeof (UInt32) : typeof (UInt64);
+ if (type1 == typeof (IntPtr)) type1 = IntPtr.Size == 4 ? typeof (Int32) : typeof (Int64);
+ if (type1 == typeof (UIntPtr)) type1 = IntPtr.Size == 4 ? typeof (UInt32) : typeof (UInt64);
+ if (type0 == type1) return type0;
+ // возвращаем наиболее широкий из типов
+ return TypeWidth(type0) >= TypeWidth(type1) ? EnsureSign(type0, signed) : EnsureSign(type1, signed);
+ }
+
+ private static Type EnsureSign(Type t, bool signed)
+ {
+ if (t == typeof (Int32)) return signed ? t : typeof (UInt32);
+ if (t == typeof (UInt32)) return signed ? typeof (Int32) : t;
+ if (t == typeof (Int64)) return signed ? t : typeof (UInt64);
+ if (t == typeof (UInt64)) return signed ? typeof (Int64) : t;
+ return t;
+ }
+
+ private static int TypeWidth(Type t)
+ {
+ if (t.IsEnum) t = t.GetEnumUnderlyingType();
+ if (t == typeof (bool)) return 1;
+ if (t == typeof (byte) || t == typeof (sbyte)) return 2;
+ if (t == typeof (short) || t == typeof (ushort) || t == typeof(Char)) return 3;
+ if (t == typeof (int) || t == typeof (uint)) return 4;
+ if (t == typeof (long) || t == typeof (ulong)) return 5;
+ if (t == typeof(float)) return 6;
+ if (t == typeof(double)) return 7;
+ return 8; // object etc
+ }
+
+ private static DynamicMethod Dyn2OpBool(KeyValuePair<OpCode, CodeTemplate> op, Type[] types)
+ {
+ Type pushedT = typeof(bool);
+ return Dyn2Op(op, types, pushedT);
+ }
+
+ private static DynamicMethod Dyn2Op(KeyValuePair<OpCode, CodeTemplate> op, Type[] types, Type ret)
+ {
+ var dyn = new DynamicMethod(op.Key.Name, ret, types, typeof(void), true);
+ var gen = dyn.GetILGenerator();
+
+ gen.Emit(OpCodes.Ldarg_1);
+ gen.Emit(OpCodes.Ldarg_0);
+ gen.Emit(op.Key);
+
+ gen.Emit(OpCodes.Ret);
+ return dyn;
+ }
+ }
+
+ internal class MsilToVmTestCompilerVmp : MsilToVmTestCompiler
+ {
+ #region opcodes
+ internal static readonly Dictionary<short, KeyValuePair<OpCode, VMProtect.OpCodes>> IlToVmInstrInfo = new Dictionary<short, KeyValuePair<OpCode, VMProtect.OpCodes>>()
+ {
+ { OpCodes.Add.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Add, VMProtect.OpCodes.icAdd) },
+ { OpCodes.Add_Ovf.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Add_Ovf, VMProtect.OpCodes.icAdd_ovf) },
+ { OpCodes.Add_Ovf_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Add_Ovf_Un, VMProtect.OpCodes.icAdd_ovf_un) },
+ { OpCodes.And.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.And, VMProtect.OpCodes.icAnd) },
+ //{ OpCodes.Arglist.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Arglist, VMProtect.OpCodes.icArglist) },
+ { OpCodes.Beq_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Beq_S, VMProtect.OpCodes.icBeq) },
+ { OpCodes.Bge_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Bge_S, VMProtect.OpCodes.icBge) },
+ { OpCodes.Bge_Un_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Bge_Un_S, VMProtect.OpCodes.icBge_un) },
+ { OpCodes.Bgt_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Bgt_S, VMProtect.OpCodes.icBgt) },
+ { OpCodes.Bgt_Un_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Bgt_Un_S, VMProtect.OpCodes.icBgt_un) },
+ { OpCodes.Ble_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ble_S, VMProtect.OpCodes.icBle) },
+ { OpCodes.Ble_Un_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ble_Un_S, VMProtect.OpCodes.icBle_un) },
+ { OpCodes.Blt_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Blt_S, VMProtect.OpCodes.icBlt) },
+ { OpCodes.Blt_Un_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Blt_Un_S, VMProtect.OpCodes.icBlt_un) },
+ { OpCodes.Bne_Un_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Bne_Un_S, VMProtect.OpCodes.icBne_un) },
+ //{ OpCodes.Box.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Box, VMProtect.OpCodes.icBox) },
+ { OpCodes.Br_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Br_S, VMProtect.OpCodes.icBr) },
+ //{ OpCodes.Break.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Break, VMProtect.OpCodes.icBreak) },
+ //{ OpCodes.Brfalse_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Brfalse_S, VMProtect.OpCodes.icBrfalse_S) },
+ //{ OpCodes.Brtrue_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Brtrue_S, VMProtect.OpCodes.icBrtrue_S) },
+ { OpCodes.Call.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Call, VMProtect.OpCodes.icCall) },
+ //{ OpCodes.Calli.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Calli, VMProtect.OpCodes.icCalli) },
+ //{ OpCodes.Callvirt.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Callvirt, VMProtect.OpCodes.icCallvirt) },
+ //{ OpCodes.Castclass.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Castclass, VMProtect.OpCodes.icCastclass) },
+ { OpCodes.Ceq.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ceq, VMProtect.OpCodes.icCeq) },
+ { OpCodes.Cgt.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Cgt, VMProtect.OpCodes.icCgt) },
+ { OpCodes.Cgt_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Cgt_Un, VMProtect.OpCodes.icCgt_un) },
+ { OpCodes.Ckfinite.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ckfinite, VMProtect.OpCodes.icCkfinite) },
+ { OpCodes.Clt.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Clt, VMProtect.OpCodes.icClt) },
+ { OpCodes.Clt_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Clt_Un, VMProtect.OpCodes.icClt_un) },
+ //{ OpCodes.Constrained.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Constrained, VMProtect.OpCodes.icConstrained) },
+ { OpCodes.Conv_I.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_I, VMProtect.OpCodes.icConv_i) },
+ { OpCodes.Conv_I1.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_I1, VMProtect.OpCodes.icConv_i1) },
+ { OpCodes.Conv_I2.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_I2, VMProtect.OpCodes.icConv_i2) },
+ { OpCodes.Conv_I4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_I4, VMProtect.OpCodes.icConv_i4) },
+ { OpCodes.Conv_I8.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_I8, VMProtect.OpCodes.icConv_i8) },
+ { OpCodes.Conv_Ovf_I.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_I, VMProtect.OpCodes.icConv_ovf_i) },
+ { OpCodes.Conv_Ovf_I_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_I_Un, VMProtect.OpCodes.icConv_ovf_i_un) },
+ { OpCodes.Conv_Ovf_I1.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_I1, VMProtect.OpCodes.icConv_ovf_i1) },
+ { OpCodes.Conv_Ovf_I1_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_I1_Un, VMProtect.OpCodes.icConv_ovf_i1_un) },
+ { OpCodes.Conv_Ovf_I2.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_I2, VMProtect.OpCodes.icConv_ovf_i2) },
+ { OpCodes.Conv_Ovf_I2_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_I2_Un, VMProtect.OpCodes.icConv_ovf_i2_un) },
+ { OpCodes.Conv_Ovf_I4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_I4, VMProtect.OpCodes.icConv_ovf_i4) },
+ { OpCodes.Conv_Ovf_I4_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_I4_Un, VMProtect.OpCodes.icConv_ovf_i4_un) },
+ { OpCodes.Conv_Ovf_I8.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_I8, VMProtect.OpCodes.icConv_ovf_i8) },
+ { OpCodes.Conv_Ovf_I8_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_I8_Un, VMProtect.OpCodes.icConv_ovf_i8_un) },
+ { OpCodes.Conv_Ovf_U.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_U, VMProtect.OpCodes.icConv_ovf_u) },
+ { OpCodes.Conv_Ovf_U_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_U_Un, VMProtect.OpCodes.icConv_ovf_u_un) },
+ { OpCodes.Conv_Ovf_U1.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_U1, VMProtect.OpCodes.icConv_ovf_u1) },
+ { OpCodes.Conv_Ovf_U1_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_U1_Un, VMProtect.OpCodes.icConv_ovf_u1_un) },
+ { OpCodes.Conv_Ovf_U2.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_U2, VMProtect.OpCodes.icConv_ovf_u2) },
+ { OpCodes.Conv_Ovf_U2_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_U2_Un, VMProtect.OpCodes.icConv_ovf_u2_un) },
+ { OpCodes.Conv_Ovf_U4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_U4, VMProtect.OpCodes.icConv_ovf_u4) },
+ { OpCodes.Conv_Ovf_U4_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_U4_Un, VMProtect.OpCodes.icConv_ovf_u4_un) },
+ { OpCodes.Conv_Ovf_U8.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_U8, VMProtect.OpCodes.icConv_ovf_u8) },
+ { OpCodes.Conv_Ovf_U8_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_Ovf_U8_Un, VMProtect.OpCodes.icConv_ovf_u8_un) },
+ { OpCodes.Conv_R_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_R_Un, VMProtect.OpCodes.icConv_r_un) },
+ { OpCodes.Conv_R4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_R4, VMProtect.OpCodes.icConv_r4) },
+ { OpCodes.Conv_R8.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_R8, VMProtect.OpCodes.icConv_r8) },
+ { OpCodes.Conv_U.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_U, VMProtect.OpCodes.icConv_u) },
+ { OpCodes.Conv_U1.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_U1, VMProtect.OpCodes.icConv_u1) },
+ { OpCodes.Conv_U2.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_U2, VMProtect.OpCodes.icConv_u2) },
+ { OpCodes.Conv_U4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_U4, VMProtect.OpCodes.icConv_u4) },
+ { OpCodes.Conv_U8.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Conv_U8, VMProtect.OpCodes.icConv_u8) },
+ //{ OpCodes.Cpblk.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Cpblk, VMProtect.OpCodes.icCpblk) },
+ //{ OpCodes.Cpobj.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Cpobj, VMProtect.OpCodes.icCpobj) },
+ { OpCodes.Div.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Div, VMProtect.OpCodes.icDiv) },
+ { OpCodes.Div_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Div_Un, VMProtect.OpCodes.icDiv_un) },
+ //{ OpCodes.Dup.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Dup, VMProtect.OpCodes.icDup) },
+ //{ OpCodes.Endfilter.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Endfilter, VMProtect.OpCodes.icEndfilter) },
+ //{ OpCodes.Endfinally.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Endfinally, VMProtect.OpCodes.icEndfinally) },
+ //{ OpCodes.Initblk.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Initblk, VMProtect.OpCodes.icInitblk) },
+ //{ OpCodes.Initobj.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Initobj, VMProtect.OpCodes.icInitobj) },
+ //{ OpCodes.Isinst.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Isinst, VMProtect.OpCodes.icIsinst) },
+ //{ OpCodes.Jmp.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Jmp, VMProtect.OpCodes.icJmp) },
+ //{ OpCodes.Ldarg.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldarg, VMProtect.OpCodes.icLdarg) },
+ { OpCodes.Ldarg_0.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldarg_0, VMProtect.OpCodes.icLdarg_0) },
+ { OpCodes.Ldarg_1.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldarg_1, VMProtect.OpCodes.icLdarg_1) },
+ //{ OpCodes.Ldarg_2.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldarg_2, VMProtect.OpCodes.icLdarg_2) },
+ //{ OpCodes.Ldarg_3.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldarg_3, VMProtect.OpCodes.icLdarg_3) },
+ //{ OpCodes.Ldarg_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldarg_S, VMProtect.OpCodes.icLdarg_S) },
+ //{ OpCodes.Ldarga.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldarga, VMProtect.OpCodes.icLdarga) },
+ { OpCodes.Ldarga_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldarga_S, VMProtect.OpCodes.icLdarga_s) },
+ { OpCodes.Ldc_I4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldc_I4, VMProtect.OpCodes.icLdc_i4) },
+ { OpCodes.Ldc_I4_0.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldc_I4_0, VMProtect.OpCodes.icLdc_i4_0) },
+ { OpCodes.Ldc_I4_1.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldc_I4_1, VMProtect.OpCodes.icLdc_i4_1) },
+ { OpCodes.Ldc_I4_2.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldc_I4_2, VMProtect.OpCodes.icLdc_i4_2) },
+ //{ OpCodes.Ldc_I4_3.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldc_I4_3, VMProtect.OpCodes.icLdc_I4_3) },
+ //{ OpCodes.Ldc_I4_4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldc_I4_4, VMProtect.OpCodes.icLdc_I4_4) },
+ //{ OpCodes.Ldc_I4_5.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldc_I4_5, VMProtect.OpCodes.icLdc_I4_5) },
+ //{ OpCodes.Ldc_I4_6.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldc_I4_6, VMProtect.OpCodes.icLdc_I4_6) },
+ //{ OpCodes.Ldc_I4_7.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldc_I4_7, VMProtect.OpCodes.icLdc_I4_7) },
+ //{ OpCodes.Ldc_I4_8.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldc_I4_8, VMProtect.OpCodes.icLdc_I4_8) },
+ //{ OpCodes.Ldc_I4_M1.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldc_I4_M1, VMProtect.OpCodes.icLdc_I4_M1) },
+ //{ OpCodes.Ldc_I4_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldc_I4_S, VMProtect.OpCodes.icLdc_I4_S) },
+ //{ OpCodes.Ldc_I8.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldc_I8, VMProtect.OpCodes.icLdc_I8) },
+ //{ OpCodes.Ldc_R4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldc_R4, VMProtect.OpCodes.icLdc_R4) },
+ //{ OpCodes.Ldc_R8.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldc_R8, VMProtect.OpCodes.icLdc_R8) },
+ //{ OpCodes.Ldelem.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldelem, VMProtect.OpCodes.icLdelem) },
+ //{ OpCodes.Ldelem_I.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldelem_I, VMProtect.OpCodes.icLdelem_I) },
+ //{ OpCodes.Ldelem_I1.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldelem_I1, VMProtect.OpCodes.icLdelem_I1) },
+ //{ OpCodes.Ldelem_I2.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldelem_I2, VMProtect.OpCodes.icLdelem_I2) },
+ //{ OpCodes.Ldelem_I4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldelem_I4, VMProtect.OpCodes.icLdelem_I4) },
+ //{ OpCodes.Ldelem_I8.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldelem_I8, VMProtect.OpCodes.icLdelem_I8) },
+ //{ OpCodes.Ldelem_R4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldelem_R4, VMProtect.OpCodes.icLdelem_R4) },
+ //{ OpCodes.Ldelem_R8.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldelem_R8, VMProtect.OpCodes.icLdelem_R8) },
+ //{ OpCodes.Ldelem_Ref.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldelem_Ref, VMProtect.OpCodes.icLdelem_Ref) },
+ //{ OpCodes.Ldelem_U1.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldelem_U1, VMProtect.OpCodes.icLdelem_U1) },
+ //{ OpCodes.Ldelem_U2.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldelem_U2, VMProtect.OpCodes.icLdelem_U2) },
+ //{ OpCodes.Ldelem_U4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldelem_U4, VMProtect.OpCodes.icLdelem_U4) },
+ //{ OpCodes.Ldelema.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldelema, VMProtect.OpCodes.icLdelema) },
+ //{ OpCodes.Ldfld.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldfld, VMProtect.OpCodes.icLdfld) },
+ //{ OpCodes.Ldflda.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldflda, VMProtect.OpCodes.icLdflda) },
+ //{ OpCodes.Ldftn.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldftn, VMProtect.OpCodes.icLdftn) },
+ //{ OpCodes.Ldind_I.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldind_I, VMProtect.OpCodes.icLdind_I) },
+ //{ OpCodes.Ldind_I1.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldind_I1, VMProtect.OpCodes.icLdind_I1) },
+ //{ OpCodes.Ldind_I2.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldind_I2, VMProtect.OpCodes.icLdind_I2) },
+ //{ OpCodes.Ldind_I4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldind_I4, VMProtect.OpCodes.icLdind_I4) },
+ //{ OpCodes.Ldind_I8.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldind_I8, VMProtect.OpCodes.icLdind_I8) },
+ //{ OpCodes.Ldind_R4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldind_R4, VMProtect.OpCodes.icLdind_R4) },
+ //{ OpCodes.Ldind_R8.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldind_R8, VMProtect.OpCodes.icLdind_R8) },
+ //{ OpCodes.Ldind_Ref.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldind_Ref, VMProtect.OpCodes.icLdind_Ref) },
+ //{ OpCodes.Ldind_U1.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldind_U1, VMProtect.OpCodes.icLdind_U1) },
+ //{ OpCodes.Ldind_U2.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldind_U2, VMProtect.OpCodes.icLdind_U2) },
+ //{ OpCodes.Ldind_U4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldind_U4, VMProtect.OpCodes.icLdind_U4) },
+ //{ OpCodes.Ldlen.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldlen, VMProtect.OpCodes.icLdlen) },
+ //{ OpCodes.Ldloc.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldloc, VMProtect.OpCodes.icLdloc) },
+ { OpCodes.Ldloc_0.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldloc_0, VMProtect.OpCodes.icLdloc_0) },
+ //{ OpCodes.Ldloc_1.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldloc_1, VMProtect.OpCodes.icLdloc_1) },
+ //{ OpCodes.Ldloc_2.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldloc_2, VMProtect.OpCodes.icLdloc_2) },
+ //{ OpCodes.Ldloc_3.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldloc_3, VMProtect.OpCodes.icLdloc_3) },
+ //{ OpCodes.Ldloc_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldloc_S, VMProtect.OpCodes.icLdloc_S) },
+ //{ OpCodes.Ldloca.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldloca, VMProtect.OpCodes.icLdloca) },
+ //{ OpCodes.Ldloca_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldloca_S, VMProtect.OpCodes.icLdloca_S) },
+ { OpCodes.Ldnull.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldnull, VMProtect.OpCodes.icLdnull) },
+ //{ OpCodes.Ldobj.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldobj, VMProtect.OpCodes.icLdobj) },
+ //{ OpCodes.Ldsfld.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldsfld, VMProtect.OpCodes.icLdsfld) },
+ //{ OpCodes.Ldsflda.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldsflda, VMProtect.OpCodes.icLdsflda) },
+ //{ OpCodes.Ldstr.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldstr, VMProtect.OpCodes.icLdstr) },
+ //{ OpCodes.Ldtoken.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldtoken, VMProtect.OpCodes.icLdtoken) },
+ //{ OpCodes.Ldvirtftn.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ldvirtftn, VMProtect.OpCodes.icLdvirtftn) },
+ //{ OpCodes.Leave.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Leave, VMProtect.OpCodes.icLeave) },
+ //{ OpCodes.Leave_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Leave_S, VMProtect.OpCodes.icLeave_S) },
+ //{ OpCodes.Localloc.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Localloc, VMProtect.OpCodes.icLocalloc) },
+ //{ OpCodes.Mkrefany.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Mkrefany, VMProtect.OpCodes.icMkrefany) },
+ { OpCodes.Mul.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Mul, VMProtect.OpCodes.icMul) },
+ { OpCodes.Mul_Ovf.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Mul_Ovf, VMProtect.OpCodes.icMul_ovf) },
+ { OpCodes.Mul_Ovf_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Mul_Ovf_Un, VMProtect.OpCodes.icMul_ovf_un) },
+ //{ OpCodes.Neg.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Neg, VMProtect.OpCodes.icNeg) },
+ //{ OpCodes.Newarr.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Newarr, VMProtect.OpCodes.icNewarr) },
+ { OpCodes.Newobj.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Newobj, VMProtect.OpCodes.icNewobj) },
+ { OpCodes.Nop.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Nop, VMProtect.OpCodes.icNop) },
+ { OpCodes.Not.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Not, VMProtect.OpCodes.icNot) },
+ { OpCodes.Or.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Or, VMProtect.OpCodes.icOr) },
+ //{ OpCodes.Pop.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Pop, VMProtect.OpCodes.icPop) },
+ //{ OpCodes.Prefix1.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Prefix1, VMProtect.OpCodes.icPrefix1) },
+ //{ OpCodes.Prefix2.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Prefix2, VMProtect.OpCodes.icPrefix2) },
+ //{ OpCodes.Prefix3.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Prefix3, VMProtect.OpCodes.icPrefix3) },
+ //{ OpCodes.Prefix4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Prefix4, VMProtect.OpCodes.icPrefix4) },
+ //{ OpCodes.Prefix5.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Prefix5, VMProtect.OpCodes.icPrefix5) },
+ //{ OpCodes.Prefix6.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Prefix6, VMProtect.OpCodes.icPrefix6) },
+ //{ OpCodes.Prefix7.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Prefix7, VMProtect.OpCodes.icPrefix7) },
+ //{ OpCodes.Prefixref.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Prefixref, VMProtect.OpCodes.icPrefixref) },
+ //{ OpCodes.Readonly.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Readonly, VMProtect.OpCodes.icReadonly) },
+ //{ OpCodes.Refanytype.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Refanytype, VMProtect.OpCodes.icRefanytype) },
+ //{ OpCodes.Refanyval.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Refanyval, VMProtect.OpCodes.icRefanyval) },
+ { OpCodes.Rem.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Rem, VMProtect.OpCodes.icRem) },
+ { OpCodes.Rem_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Rem_Un, VMProtect.OpCodes.icRem_un) },
+ { OpCodes.Ret.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Ret, VMProtect.OpCodes.icRet) },
+ //{ OpCodes.Rethrow.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Rethrow, VMProtect.OpCodes.icRethrow) },
+ { OpCodes.Shl.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Shl, VMProtect.OpCodes.icShl) },
+ { OpCodes.Shr.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Shr, VMProtect.OpCodes.icShr) },
+ { OpCodes.Shr_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Shr_Un, VMProtect.OpCodes.icShr_un) },
+ //{ OpCodes.Sizeof.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Sizeof, VMProtect.OpCodes.icSizeof) },
+ //{ OpCodes.Starg.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Starg, VMProtect.OpCodes.icStarg) },
+ //{ OpCodes.Starg_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Starg_S, VMProtect.OpCodes.icStarg_S) },
+ //{ OpCodes.Stelem.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stelem, VMProtect.OpCodes.icStelem) },
+ //{ OpCodes.Stelem_I.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stelem_I, VMProtect.OpCodes.icStelem_I) },
+ //{ OpCodes.Stelem_I1.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stelem_I1, VMProtect.OpCodes.icStelem_I1) },
+ { OpCodes.Stelem_I2.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stelem_I2, VMProtect.OpCodes.icStelem_i2) },
+ //{ OpCodes.Stelem_I4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stelem_I4, VMProtect.OpCodes.icStelem_I4) },
+ //{ OpCodes.Stelem_I8.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stelem_I8, VMProtect.OpCodes.icStelem_I8) },
+ //{ OpCodes.Stelem_R4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stelem_R4, VMProtect.OpCodes.icStelem_R4) },
+ //{ OpCodes.Stelem_R8.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stelem_R8, VMProtect.OpCodes.icStelem_R8) },
+ //{ OpCodes.Stelem_Ref.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stelem_Ref, VMProtect.OpCodes.icStelem_Ref) },
+ //{ OpCodes.Stfld.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stfld, VMProtect.OpCodes.icStfld) },
+ //{ OpCodes.Stind_I.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stind_I, VMProtect.OpCodes.icStind_I) },
+ //{ OpCodes.Stind_I1.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stind_I1, VMProtect.OpCodes.icStind_I1) },
+ //{ OpCodes.Stind_I2.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stind_I2, VMProtect.OpCodes.icStind_I2) },
+ //{ OpCodes.Stind_I4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stind_I4, VMProtect.OpCodes.icStind_I4) },
+ //{ OpCodes.Stind_I8.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stind_I8, VMProtect.OpCodes.icStind_I8) },
+ //{ OpCodes.Stind_R4.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stind_R4, VMProtect.OpCodes.icStind_R4) },
+ //{ OpCodes.Stind_R8.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stind_R8, VMProtect.OpCodes.icStind_R8) },
+ //{ OpCodes.Stind_Ref.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stind_Ref, VMProtect.OpCodes.icStind_Ref) },
+ //{ OpCodes.Stloc.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stloc, VMProtect.OpCodes.icStloc) },
+ { OpCodes.Stloc_0.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stloc_0, VMProtect.OpCodes.icStloc_0) },
+ //{ OpCodes.Stloc_1.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stloc_1, VMProtect.OpCodes.icStloc_1) },
+ //{ OpCodes.Stloc_2.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stloc_2, VMProtect.OpCodes.icStloc_2) },
+ //{ OpCodes.Stloc_3.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stloc_3, VMProtect.OpCodes.icStloc_3) },
+ //{ OpCodes.Stloc_S.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stloc_S, VMProtect.OpCodes.icStloc_S) },
+ //{ OpCodes.Stobj.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stobj, VMProtect.OpCodes.icStobj) },
+ //{ OpCodes.Stsfld.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Stsfld, VMProtect.OpCodes.icStsfld) },
+ { OpCodes.Sub.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Sub, VMProtect.OpCodes.icSub) },
+ { OpCodes.Sub_Ovf.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Sub_Ovf, VMProtect.OpCodes.icSub_ovf) },
+ { OpCodes.Sub_Ovf_Un.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Sub_Ovf_Un, VMProtect.OpCodes.icSub_ovf_un) },
+ //{ OpCodes.Switch.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Switch, VMProtect.OpCodes.icSwitch) },
+ //{ OpCodes.Tailcall.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Tailcall, VMProtect.OpCodes.icTailcall) },
+ //{ OpCodes.Throw.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Throw, VMProtect.OpCodes.icThrow) },
+ //{ OpCodes.Unaligned.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Unaligned, VMProtect.OpCodes.icUnaligned) },
+ //{ OpCodes.Unbox.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Unbox, VMProtect.OpCodes.icUnbox) },
+ //{ OpCodes.Unbox_Any.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Unbox_Any, VMProtect.OpCodes.icUnbox_Any) },
+ //{ OpCodes.Volatile.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Volatile, VMProtect.OpCodes.icVolatile) },
+ { OpCodes.Xor.Value, new KeyValuePair<OpCode, VMProtect.OpCodes>(OpCodes.Xor, VMProtect.OpCodes.icXor) },
+ };
+ #endregion
+ private static readonly Dictionary<Type, int> TypeTokenInModule = new Dictionary<Type, int>(); //TypeDefs and TypeRefs
+ private static int GetTypeTokenInModule(Type t)
+ {
+ var tryToken = 0x01000001; //first TypeRef
+ var m = typeof (MsilToVmTestCompilerVmp).Module;
+ while (true)
+ {
+ try
+ {
+ Type t1 = m.ResolveType(tryToken);
+ TypeTokenInModule.Add(t1, tryToken++);
+ }
+ catch (Exception)
+ {
+ break; //until last TypeRef
+ }
+
+ }
+ if (TypeTokenInModule.ContainsKey(t))
+ return TypeTokenInModule[t];
+ if (t.Module == m)
+ {
+ TypeTokenInModule.Add(t, t.MetadataToken);
+ return t.MetadataToken;
+ }
+ Assert.Fail("Bad type {0}: not accessible from this module", t);
+ return 0;
+ }
+ public override Stream CreateVmStream(Type rt, ParameterInfo[] pi, Type[] locals, byte[] ilBytes)
+ {
+ var ret = new MemoryStream();
+ var wr = new BinaryWriter(ret);
+ var fwdTypeDefs = new Dictionary<Type, int>();
+ var fwdTypeRefs = new Dictionary<int, Type>();
+ var deferredBrTargets = new Dictionary<long, UInt32>();
+ var srcToDstInstrPositions = new Dictionary<long, UInt32>();
+ const int dummy = 0x55555555;
+ fwdTypeDefs.Add(rt, dummy);
+ var pars = pi;
+ foreach (var parameterInfo in pars)
+ {
+ if (!fwdTypeDefs.ContainsKey(parameterInfo.ParameterType))
+ fwdTypeDefs.Add(parameterInfo.ParameterType, dummy);
+ wr.Write((byte)VMProtect.OpCodes.icInitarg);
+ fwdTypeRefs.Add((int)ret.Position, parameterInfo.ParameterType);
+ wr.Write(dummy); // parTypeId fwd ref
+ }
+ foreach (var lt in locals)
+ {
+ if (!fwdTypeDefs.ContainsKey(lt))
+ fwdTypeDefs.Add(lt, dummy);
+ // FIXME
+ //wr.Write((byte)VMProtect.OpCodes.icInitloc);
+ fwdTypeRefs.Add((int)ret.Position, lt);
+ wr.Write(dummy); // parTypeId fwd ref
+ }
+
+ using (var sr = new BinaryReader(new MemoryStream(ilBytes)))
+ {
+ while (sr.BaseStream.Position < sr.BaseStream.Length)
+ {
+ srcToDstInstrPositions[sr.BaseStream.Position] = (uint)ret.Position;
+ short ilByte = sr.ReadByte();
+ if (ilByte == 0xFE)
+ ilByte = (short)((ilByte << 8) | sr.ReadByte());
+ Assert.IsTrue(IlToVmInstrInfo.ContainsKey(ilByte), "Extend IlToVmInstrInfo with {0:X} or use short jump", ilByte);
+ var vmInstrInfo = IlToVmInstrInfo[ilByte];
+ ulong operand = 0;
+ switch (vmInstrInfo.Key.OperandType)
+ {
+ case OperandType.InlineNone:
+ break;
+ case OperandType.InlineI8:
+ case OperandType.InlineR:
+ operand = sr.ReadUInt64();
+ break;
+ case OperandType.InlineVar:
+ operand = sr.ReadUInt16();
+ break;
+ case OperandType.ShortInlineBrTarget:
+ case OperandType.ShortInlineI:
+ case OperandType.ShortInlineVar:
+ operand = sr.ReadByte();
+ break;
+ default:
+ operand = sr.ReadUInt32();
+ break;
+ }
+ switch ((short)vmInstrInfo.Value)
+ {
+ case (short)VMProtect.OpCodes.icNop:
+ continue;
+ case (short)VMProtect.OpCodes.icStloc_0:
+ wr.Write((byte)VMProtect.OpCodes.icStloc);
+ wr.Write((ushort)0);
+ break;
+ case (short)VMProtect.OpCodes.icStloc_1:
+ wr.Write((byte)VMProtect.OpCodes.icStloc);
+ wr.Write((ushort)1);
+ break;
+ case (short)VMProtect.OpCodes.icStloc_2:
+ wr.Write((byte)VMProtect.OpCodes.icStloc);
+ wr.Write((ushort)2);
+ break;
+ case (short)VMProtect.OpCodes.icStloc_3:
+ wr.Write((byte)VMProtect.OpCodes.icStloc);
+ wr.Write((ushort)3);
+ break;
+ case (short)VMProtect.OpCodes.icLdloc_0:
+ wr.Write((byte)VMProtect.OpCodes.icLdloc);
+ wr.Write((ushort)0);
+ break;
+ case (short)VMProtect.OpCodes.icLdloc_1:
+ wr.Write((byte)VMProtect.OpCodes.icLdloc);
+ wr.Write((ushort)1);
+ break;
+ case (short)VMProtect.OpCodes.icLdloc_2:
+ wr.Write((byte)VMProtect.OpCodes.icLdloc);
+ wr.Write((ushort)2);
+ break;
+ case (short)VMProtect.OpCodes.icLdloc_3:
+ wr.Write((byte)VMProtect.OpCodes.icLdloc);
+ wr.Write((ushort)3);
+ break;
+ case (short)VMProtect.OpCodes.icLdarg_0:
+ wr.Write((byte)VMProtect.OpCodes.icLdarg);
+ wr.Write((ushort)0);
+ break;
+ case (short)VMProtect.OpCodes.icLdarg_1:
+ wr.Write((byte)VMProtect.OpCodes.icLdarg);
+ wr.Write((ushort)1);
+ break;
+ case (short)VMProtect.OpCodes.icLdarg_2:
+ wr.Write((byte)VMProtect.OpCodes.icLdarg);
+ wr.Write((ushort)2);
+ break;
+ case (short)VMProtect.OpCodes.icLdarg_3:
+ wr.Write((byte)VMProtect.OpCodes.icLdarg);
+ wr.Write((ushort)3);
+ break;
+ case (short)VMProtect.OpCodes.icLdarga_s:
+ wr.Write((byte)VMProtect.OpCodes.icLdarga);
+ wr.Write((ushort)operand);
+ break;
+ case (short)VMProtect.OpCodes.icRet:
+ wr.Write((byte)VMProtect.OpCodes.icRet);
+ fwdTypeRefs.Add((int)ret.Position, rt);
+ wr.Write(dummy); // ReturnTypeId fwd ref
+ break;
+ case (short)VMProtect.OpCodes.icLdc_i4_0:
+ wr.Write((byte)VMProtect.OpCodes.icLdc_i4);
+ wr.Write((uint)0);
+ break;
+ case (short)VMProtect.OpCodes.icLdc_i4_1:
+ wr.Write((byte)VMProtect.OpCodes.icLdc_i4);
+ wr.Write((uint)1);
+ break;
+ case (short)VMProtect.OpCodes.icLdc_i4_2:
+ wr.Write((byte)VMProtect.OpCodes.icLdc_i4);
+ wr.Write((uint)2);
+ break;
+ case (short)VMProtect.OpCodes.icLdc_i4_3:
+ wr.Write((byte)VMProtect.OpCodes.icLdc_i4);
+ wr.Write((uint)3);
+ break;
+ case (short)VMProtect.OpCodes.icBr:
+ wr.Write((byte)VMProtect.OpCodes.icLdc_i4);
+ deferredBrTargets[ret.Position] = (uint)sr.BaseStream.Position + (uint)operand;
+ wr.Write(dummy);
+ wr.Write((byte)VMProtect.OpCodes.icBr);
+ break;
+ case (short)VMProtect.OpCodes.icBeq:
+ case (short)VMProtect.OpCodes.icBne_un:
+ case (short)VMProtect.OpCodes.icBlt:
+ case (short)VMProtect.OpCodes.icBlt_un:
+ case (short)VMProtect.OpCodes.icBle:
+ case (short)VMProtect.OpCodes.icBle_un:
+ case (short)VMProtect.OpCodes.icBgt:
+ case (short)VMProtect.OpCodes.icBgt_un:
+ case (short)VMProtect.OpCodes.icBge:
+ case (short)VMProtect.OpCodes.icBge_un:
+ case (short)VMProtect.OpCodes.icBrtrue:
+ case (short)VMProtect.OpCodes.icBrfalse:
+ switch ((short)vmInstrInfo.Value)
+ {
+ // FIXME
+ /*
+ case (short)VMProtect.OpCodes.icBeq:
+ case (short)VMProtect.OpCodes.icBne_un:
+ wr.Write((byte)VMProtect.OpCodes.icCeq);
+ break;
+ case (short)VMProtect.OpCodes.icBge:
+ wr.Write((byte)VMProtect.OpCodes.icCge);
+ break;
+ case (short)VMProtect.OpCodes.icBge_un:
+ wr.Write((byte)VMProtect.OpCodes.icCge_un);
+ break;
+ case (short)VMProtect.OpCodes.icBlt:
+ wr.Write((byte)VMProtect.OpCodes.icClt);
+ break;
+ case (short)VMProtect.OpCodes.icBlt_un:
+ wr.Write((byte)VMProtect.OpCodes.icClt_un);
+ break;
+ case (short)VMProtect.OpCodes.icBle:
+ wr.Write((byte)VMProtect.OpCodes.icCle);
+ break;
+ case (short)VMProtect.OpCodes.icBle_un:
+ wr.Write((byte)VMProtect.OpCodes.icCle_un);
+ break;
+ case (short)VMProtect.OpCodes.icBgt:
+ wr.Write((byte)VMProtect.OpCodes.icCgt);
+ break;
+ case (short)VMProtect.OpCodes.icBgt_un:
+ wr.Write((byte)VMProtect.OpCodes.icCgt_un);
+ break;
+ */
+ }
+ // FIXME
+ //wr.Write((byte)VMProtect.OpCodes.icConv_b);
+ wr.Write((byte)VMProtect.OpCodes.icNeg);
+ switch ((short)vmInstrInfo.Value)
+ {
+ case (short)VMProtect.OpCodes.icBne_un:
+ //case (short)VMProtect.OpCodes.icBle:
+ //case (short)VMProtect.OpCodes.icBle_un:
+ //case (short)VMProtect.OpCodes.icBge:
+ //case (short)VMProtect.OpCodes.icBge_un:
+ case (short)VMProtect.OpCodes.icBrfalse:
+ wr.Write((byte)VMProtect.OpCodes.icNot);
+ break;
+ }
+ wr.Write((byte)VMProtect.OpCodes.icLdc_i4);
+ deferredBrTargets[ret.Position] = (uint)sr.BaseStream.Position + (uint)operand;
+ wr.Write(dummy);
+ wr.Write((byte)VMProtect.OpCodes.icAnd);
+ wr.Write((byte)VMProtect.OpCodes.icDup);
+ // FIXME
+ //wr.Write((byte)VMProtect.OpCodes.icConv_b);
+ wr.Write((byte)VMProtect.OpCodes.icNeg);
+ wr.Write((byte)VMProtect.OpCodes.icNot);
+ wr.Write((byte)VMProtect.OpCodes.icLdc_i4);
+ deferredBrTargets[ret.Position] = (uint)sr.BaseStream.Position;
+ wr.Write(dummy);
+ wr.Write((byte)VMProtect.OpCodes.icAnd);
+ wr.Write((byte)VMProtect.OpCodes.icAdd);
+ wr.Write((byte)VMProtect.OpCodes.icBr);
+ break;
+ default:
+ wr.Write((byte)vmInstrInfo.Value);
+ break;
+ }
+ wr.Flush();
+ }
+ foreach (var t in fwdTypeDefs.Keys.ToArray())
+ {
+ fwdTypeDefs[t] = GetTypeTokenInModule(t);
+ }
+ foreach (var r in fwdTypeRefs)
+ {
+ ret.Position = r.Key;
+ wr.Write(fwdTypeDefs[r.Value]);
+ wr.Flush();
+ }
+ foreach (var r in deferredBrTargets)
+ {
+ ret.Position = r.Key;
+ var srcPos = r.Value;
+ wr.Write(srcToDstInstrPositions[srcPos]);
+ wr.Flush();
+ }
+ ret.Position = 0;
+ return ret;
+ }
+ }
+
+ public override object Invoke(object[] parameters, Stream vmStream)
+ {
+ var contents = new BinaryReader(vmStream).ReadBytes((int) vmStream.Length);
+ var unmanagedPointer = Marshal.AllocHGlobal(contents.Length);
+ Marshal.Copy(contents, 0, unmanagedPointer, contents.Length);
+ var vm = new VirtualMachine();
+ // ReSharper disable once PossibleNullReferenceException
+ typeof(VirtualMachine).GetField("_instance", BindingFlags.Instance | BindingFlags.NonPublic)
+ .SetValue(vm, unmanagedPointer.ToInt64());
+ var vmRet = vm.Invoke(parameters, 0);
+ Marshal.FreeHGlobal(unmanagedPointer);
+ return vmRet;
+ }
+ }
+
+ public class MsilToVmTestCompilerRefVm : MsilToVmTestCompiler
+ {
+ public static readonly VmInstrCodesDb InstrCodesDb = new VmInstrCodesDb();
+ #region opcodes
+ public static readonly Dictionary<short, KeyValuePair<OpCode, VmInstrInfo>> IlToVmInstrInfo = new Dictionary<short, KeyValuePair<OpCode, VmInstrInfo>>()
+ {
+ { OpCodes.Add.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Add, InstrCodesDb.Add_) },
+ { OpCodes.Add_Ovf.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Add_Ovf, InstrCodesDb.Add_ovf_) },
+ { OpCodes.Add_Ovf_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Add_Ovf_Un, InstrCodesDb.Add_ovf_un_) },
+ { OpCodes.And.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.And, InstrCodesDb.And_) },
+ //{ OpCodes.Arglist.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Arglist, InstrCodesDb.Arglist_) },
+ { OpCodes.Beq_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Beq_S, InstrCodesDb.Beq_) },
+ { OpCodes.Bge_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Bge_S, InstrCodesDb.Bge_) },
+ { OpCodes.Bge_Un_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Bge_Un_S, InstrCodesDb.Bge_un_) },
+ { OpCodes.Bgt_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Bgt_S, InstrCodesDb.Bgt_) },
+ { OpCodes.Bgt_Un_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Bgt_Un_S, InstrCodesDb.Bgt_un_) },
+ { OpCodes.Ble_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ble_S, InstrCodesDb.Ble_) },
+ { OpCodes.Ble_Un_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ble_Un_S, InstrCodesDb.Ble_un_) },
+ { OpCodes.Blt_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Blt_S, InstrCodesDb.Blt_) },
+ { OpCodes.Blt_Un_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Blt_Un_S, InstrCodesDb.Blt_un_) },
+ { OpCodes.Bne_Un_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Bne_Un_S, InstrCodesDb.Bne_un_) },
+ //{ OpCodes.Box.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Box, InstrCodesDb.Box_) },
+ { OpCodes.Br_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Br_S, InstrCodesDb.Br_) },
+ //{ OpCodes.Break.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Break, InstrCodesDb.Break_) },
+ //{ OpCodes.Brfalse_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Brfalse_S, InstrCodesDb.Brfalse_S_) },
+ //{ OpCodes.Brtrue_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Brtrue_S, InstrCodesDb.Brtrue_S_) },
+ { OpCodes.Call.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Call, InstrCodesDb.Call_) },
+ //{ OpCodes.Calli.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Calli, InstrCodesDb.Calli_) },
+ //{ OpCodes.Callvirt.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Callvirt, InstrCodesDb.Callvirt_) },
+ //{ OpCodes.Castclass.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Castclass, InstrCodesDb.Castclass_) },
+ { OpCodes.Ceq.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ceq, InstrCodesDb.Ceq_) },
+ { OpCodes.Cgt.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Cgt, InstrCodesDb.Cgt_) },
+ { OpCodes.Cgt_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Cgt_Un, InstrCodesDb.Cgt_un_) },
+ { OpCodes.Ckfinite.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ckfinite, InstrCodesDb.Ckfinite_) },
+ { OpCodes.Clt.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Clt, InstrCodesDb.Clt_) },
+ { OpCodes.Clt_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Clt_Un, InstrCodesDb.Clt_un_) },
+ //{ OpCodes.Constrained.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Constrained, InstrCodesDb.Constrained_) },
+ { OpCodes.Conv_I.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_I, InstrCodesDb.Conv_i_) },
+ { OpCodes.Conv_I1.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_I1, InstrCodesDb.Conv_i1_) },
+ { OpCodes.Conv_I2.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_I2, InstrCodesDb.Conv_i2_) },
+ { OpCodes.Conv_I4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_I4, InstrCodesDb.Conv_i4_) },
+ { OpCodes.Conv_I8.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_I8, InstrCodesDb.Conv_i8_) },
+ { OpCodes.Conv_Ovf_I.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_I, InstrCodesDb.Conv_ovf_i_) },
+ { OpCodes.Conv_Ovf_I_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_I_Un, InstrCodesDb.Conv_ovf_i_un_) },
+ { OpCodes.Conv_Ovf_I1.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_I1, InstrCodesDb.Conv_ovf_i1_) },
+ { OpCodes.Conv_Ovf_I1_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_I1_Un, InstrCodesDb.Conv_ovf_i1_un_) },
+ { OpCodes.Conv_Ovf_I2.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_I2, InstrCodesDb.Conv_ovf_i2_) },
+ { OpCodes.Conv_Ovf_I2_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_I2_Un, InstrCodesDb.Conv_ovf_i2_un_) },
+ { OpCodes.Conv_Ovf_I4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_I4, InstrCodesDb.Conv_ovf_i4_) },
+ { OpCodes.Conv_Ovf_I4_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_I4_Un, InstrCodesDb.Conv_ovf_i4_un_) },
+ { OpCodes.Conv_Ovf_I8.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_I8, InstrCodesDb.Conv_ovf_i8_) },
+ { OpCodes.Conv_Ovf_I8_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_I8_Un, InstrCodesDb.Conv_ovf_i8_un_) },
+ { OpCodes.Conv_Ovf_U.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_U, InstrCodesDb.Conv_ovf_u_) },
+ { OpCodes.Conv_Ovf_U_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_U_Un, InstrCodesDb.Conv_ovf_u_un_) },
+ { OpCodes.Conv_Ovf_U1.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_U1, InstrCodesDb.Conv_ovf_u1_) },
+ { OpCodes.Conv_Ovf_U1_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_U1_Un, InstrCodesDb.Conv_ovf_u1_un_) },
+ { OpCodes.Conv_Ovf_U2.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_U2, InstrCodesDb.Conv_ovf_u2_) },
+ { OpCodes.Conv_Ovf_U2_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_U2_Un, InstrCodesDb.Conv_ovf_u2_un_) },
+ { OpCodes.Conv_Ovf_U4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_U4, InstrCodesDb.Conv_ovf_u4_) },
+ { OpCodes.Conv_Ovf_U4_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_U4_Un, InstrCodesDb.Conv_ovf_u4_un_) },
+ { OpCodes.Conv_Ovf_U8.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_U8, InstrCodesDb.Conv_ovf_u8_) },
+ { OpCodes.Conv_Ovf_U8_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_Ovf_U8_Un, InstrCodesDb.Conv_ovf_u8_un_) },
+ { OpCodes.Conv_R_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_R_Un, InstrCodesDb.Conv_r_un_) },
+ { OpCodes.Conv_R4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_R4, InstrCodesDb.Conv_r4_) },
+ { OpCodes.Conv_R8.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_R8, InstrCodesDb.Conv_r8_) },
+ { OpCodes.Conv_U.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_U, InstrCodesDb.Conv_u_) },
+ { OpCodes.Conv_U1.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_U1, InstrCodesDb.Conv_u1_) },
+ { OpCodes.Conv_U2.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_U2, InstrCodesDb.Conv_u2_) },
+ { OpCodes.Conv_U4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_U4, InstrCodesDb.Conv_u4_) },
+ { OpCodes.Conv_U8.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Conv_U8, InstrCodesDb.Conv_u8_) },
+ //{ OpCodes.Cpblk.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Cpblk, InstrCodesDb.Cpblk_) },
+ //{ OpCodes.Cpobj.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Cpobj, InstrCodesDb.Cpobj_) },
+ { OpCodes.Div.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Div, InstrCodesDb.Div_) },
+ { OpCodes.Div_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Div_Un, InstrCodesDb.Div_un_) },
+ //{ OpCodes.Dup.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Dup, InstrCodesDb.Dup_) },
+ //{ OpCodes.Endfilter.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Endfilter, InstrCodesDb.Endfilter_) },
+ //{ OpCodes.Endfinally.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Endfinally, InstrCodesDb.Endfinally_) },
+ //{ OpCodes.Initblk.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Initblk, InstrCodesDb.Initblk_) },
+ //{ OpCodes.Initobj.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Initobj, InstrCodesDb.Initobj_) },
+ //{ OpCodes.Isinst.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Isinst, InstrCodesDb.Isinst_) },
+ //{ OpCodes.Jmp.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Jmp, InstrCodesDb.Jmp_) },
+ //{ OpCodes.Ldarg.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldarg, InstrCodesDb.Ldarg_) },
+ { OpCodes.Ldarg_0.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldarg_0, InstrCodesDb.Ldarg_0_) },
+ { OpCodes.Ldarg_1.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldarg_1, InstrCodesDb.Ldarg_1_) },
+ //{ OpCodes.Ldarg_2.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldarg_2, InstrCodesDb.Ldarg_2_) },
+ //{ OpCodes.Ldarg_3.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldarg_3, InstrCodesDb.Ldarg_3_) },
+ //{ OpCodes.Ldarg_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldarg_S, InstrCodesDb.Ldarg_S_) },
+ //{ OpCodes.Ldarga.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldarga, InstrCodesDb.Ldarga_) },
+ { OpCodes.Ldarga_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldarga_S, InstrCodesDb.Ldarga_s_) },
+ //{ OpCodes.Ldc_I4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldc_I4, InstrCodesDb.Ldc_i4_) },
+ { OpCodes.Ldc_I4_0.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldc_I4_0, InstrCodesDb.Ldc_i4_0_) },
+ { OpCodes.Ldc_I4_1.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldc_I4_1, InstrCodesDb.Ldc_i4_1_) },
+ //{ OpCodes.Ldc_I4_2.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldc_I4_2, InstrCodesDb.Ldc_i4_2_) },
+ //{ OpCodes.Ldc_I4_3.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldc_I4_3, InstrCodesDb.Ldc_I4_3_) },
+ //{ OpCodes.Ldc_I4_4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldc_I4_4, InstrCodesDb.Ldc_I4_4_) },
+ //{ OpCodes.Ldc_I4_5.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldc_I4_5, InstrCodesDb.Ldc_I4_5_) },
+ //{ OpCodes.Ldc_I4_6.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldc_I4_6, InstrCodesDb.Ldc_I4_6_) },
+ //{ OpCodes.Ldc_I4_7.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldc_I4_7, InstrCodesDb.Ldc_I4_7_) },
+ //{ OpCodes.Ldc_I4_8.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldc_I4_8, InstrCodesDb.Ldc_I4_8_) },
+ //{ OpCodes.Ldc_I4_M1.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldc_I4_M1, InstrCodesDb.Ldc_I4_M1_) },
+ //{ OpCodes.Ldc_I4_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldc_I4_S, InstrCodesDb.Ldc_I4_S_) },
+ //{ OpCodes.Ldc_I8.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldc_I8, InstrCodesDb.Ldc_I8_) },
+ //{ OpCodes.Ldc_R4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldc_R4, InstrCodesDb.Ldc_R4_) },
+ //{ OpCodes.Ldc_R8.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldc_R8, InstrCodesDb.Ldc_R8_) },
+ //{ OpCodes.Ldelem.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldelem, InstrCodesDb.Ldelem_) },
+ //{ OpCodes.Ldelem_I.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldelem_I, InstrCodesDb.Ldelem_I_) },
+ //{ OpCodes.Ldelem_I1.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldelem_I1, InstrCodesDb.Ldelem_I1_) },
+ //{ OpCodes.Ldelem_I2.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldelem_I2, InstrCodesDb.Ldelem_I2_) },
+ //{ OpCodes.Ldelem_I4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldelem_I4, InstrCodesDb.Ldelem_I4_) },
+ //{ OpCodes.Ldelem_I8.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldelem_I8, InstrCodesDb.Ldelem_I8_) },
+ //{ OpCodes.Ldelem_R4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldelem_R4, InstrCodesDb.Ldelem_R4_) },
+ //{ OpCodes.Ldelem_R8.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldelem_R8, InstrCodesDb.Ldelem_R8_) },
+ //{ OpCodes.Ldelem_Ref.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldelem_Ref, InstrCodesDb.Ldelem_Ref_) },
+ //{ OpCodes.Ldelem_U1.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldelem_U1, InstrCodesDb.Ldelem_U1_) },
+ //{ OpCodes.Ldelem_U2.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldelem_U2, InstrCodesDb.Ldelem_U2_) },
+ //{ OpCodes.Ldelem_U4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldelem_U4, InstrCodesDb.Ldelem_U4_) },
+ //{ OpCodes.Ldelema.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldelema, InstrCodesDb.Ldelema_) },
+ //{ OpCodes.Ldfld.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldfld, InstrCodesDb.Ldfld_) },
+ //{ OpCodes.Ldflda.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldflda, InstrCodesDb.Ldflda_) },
+ //{ OpCodes.Ldftn.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldftn, InstrCodesDb.Ldftn_) },
+ //{ OpCodes.Ldind_I.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldind_I, InstrCodesDb.Ldind_I_) },
+ //{ OpCodes.Ldind_I1.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldind_I1, InstrCodesDb.Ldind_I1_) },
+ //{ OpCodes.Ldind_I2.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldind_I2, InstrCodesDb.Ldind_I2_) },
+ //{ OpCodes.Ldind_I4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldind_I4, InstrCodesDb.Ldind_I4_) },
+ //{ OpCodes.Ldind_I8.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldind_I8, InstrCodesDb.Ldind_I8_) },
+ //{ OpCodes.Ldind_R4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldind_R4, InstrCodesDb.Ldind_R4_) },
+ //{ OpCodes.Ldind_R8.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldind_R8, InstrCodesDb.Ldind_R8_) },
+ //{ OpCodes.Ldind_Ref.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldind_Ref, InstrCodesDb.Ldind_Ref_) },
+ //{ OpCodes.Ldind_U1.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldind_U1, InstrCodesDb.Ldind_U1_) },
+ //{ OpCodes.Ldind_U2.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldind_U2, InstrCodesDb.Ldind_U2_) },
+ //{ OpCodes.Ldind_U4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldind_U4, InstrCodesDb.Ldind_U4_) },
+ //{ OpCodes.Ldlen.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldlen, InstrCodesDb.Ldlen_) },
+ //{ OpCodes.Ldloc.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldloc, InstrCodesDb.Ldloc_) },
+ //{ OpCodes.Ldloc_0.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldloc_0, InstrCodesDb.Ldloc_0_) },
+ //{ OpCodes.Ldloc_1.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldloc_1, InstrCodesDb.Ldloc_1_) },
+ //{ OpCodes.Ldloc_2.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldloc_2, InstrCodesDb.Ldloc_2_) },
+ //{ OpCodes.Ldloc_3.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldloc_3, InstrCodesDb.Ldloc_3_) },
+ //{ OpCodes.Ldloc_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldloc_S, InstrCodesDb.Ldloc_S_) },
+ //{ OpCodes.Ldloca.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldloca, InstrCodesDb.Ldloca_) },
+ //{ OpCodes.Ldloca_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldloca_S, InstrCodesDb.Ldloca_S_) },
+ //{ OpCodes.Ldnull.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldnull, InstrCodesDb.Ldnull_) },
+ //{ OpCodes.Ldobj.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldobj, InstrCodesDb.Ldobj_) },
+ //{ OpCodes.Ldsfld.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldsfld, InstrCodesDb.Ldsfld_) },
+ //{ OpCodes.Ldsflda.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldsflda, InstrCodesDb.Ldsflda_) },
+ //{ OpCodes.Ldstr.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldstr, InstrCodesDb.Ldstr_) },
+ //{ OpCodes.Ldtoken.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldtoken, InstrCodesDb.Ldtoken_) },
+ //{ OpCodes.Ldvirtftn.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ldvirtftn, InstrCodesDb.Ldvirtftn_) },
+ //{ OpCodes.Leave.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Leave, InstrCodesDb.Leave_) },
+ //{ OpCodes.Leave_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Leave_S, InstrCodesDb.Leave_S_) },
+ //{ OpCodes.Localloc.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Localloc, InstrCodesDb.Localloc_) },
+ //{ OpCodes.Mkrefany.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Mkrefany, InstrCodesDb.Mkrefany_) },
+ { OpCodes.Mul.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Mul, InstrCodesDb.Mul_) },
+ { OpCodes.Mul_Ovf.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Mul_Ovf, InstrCodesDb.Mul_ovf_) },
+ { OpCodes.Mul_Ovf_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Mul_Ovf_Un, InstrCodesDb.Mul_ovf_un_) },
+ //{ OpCodes.Neg.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Neg, InstrCodesDb.Neg_) },
+ //{ OpCodes.Newarr.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Newarr, InstrCodesDb.Newarr_) },
+ { OpCodes.Newobj.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Newobj, InstrCodesDb.Newobj_) },
+ //{ OpCodes.Nop.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Nop, InstrCodesDb.Nop_) },
+ { OpCodes.Not.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Not, InstrCodesDb.Not_) },
+ { OpCodes.Or.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Or, InstrCodesDb.Or_) },
+ //{ OpCodes.Pop.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Pop, InstrCodesDb.Pop_) },
+ //{ OpCodes.Prefix1.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Prefix1, InstrCodesDb.Prefix1_) },
+ //{ OpCodes.Prefix2.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Prefix2, InstrCodesDb.Prefix2_) },
+ //{ OpCodes.Prefix3.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Prefix3, InstrCodesDb.Prefix3_) },
+ //{ OpCodes.Prefix4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Prefix4, InstrCodesDb.Prefix4_) },
+ //{ OpCodes.Prefix5.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Prefix5, InstrCodesDb.Prefix5_) },
+ //{ OpCodes.Prefix6.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Prefix6, InstrCodesDb.Prefix6_) },
+ //{ OpCodes.Prefix7.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Prefix7, InstrCodesDb.Prefix7_) },
+ //{ OpCodes.Prefixref.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Prefixref, InstrCodesDb.Prefixref_) },
+ //{ OpCodes.Readonly.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Readonly, InstrCodesDb.Readonly_) },
+ //{ OpCodes.Refanytype.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Refanytype, InstrCodesDb.Refanytype_) },
+ //{ OpCodes.Refanyval.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Refanyval, InstrCodesDb.Refanyval_) },
+ { OpCodes.Rem.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Rem, InstrCodesDb.Rem_) },
+ { OpCodes.Rem_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Rem_Un, InstrCodesDb.Rem_un_) },
+ { OpCodes.Ret.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Ret, InstrCodesDb.Ret_) },
+ //{ OpCodes.Rethrow.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Rethrow, InstrCodesDb.Rethrow_) },
+ { OpCodes.Shl.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Shl, InstrCodesDb.Shl_) },
+ { OpCodes.Shr.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Shr, InstrCodesDb.Shr_) },
+ { OpCodes.Shr_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Shr_Un, InstrCodesDb.Shr_un_) },
+ //{ OpCodes.Sizeof.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Sizeof, InstrCodesDb.Sizeof_) },
+ //{ OpCodes.Starg.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Starg, InstrCodesDb.Starg_) },
+ //{ OpCodes.Starg_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Starg_S, InstrCodesDb.Starg_S_) },
+ //{ OpCodes.Stelem.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stelem, InstrCodesDb.Stelem_) },
+ //{ OpCodes.Stelem_I.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stelem_I, InstrCodesDb.Stelem_I_) },
+ //{ OpCodes.Stelem_I1.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stelem_I1, InstrCodesDb.Stelem_I1_) },
+ //{ OpCodes.Stelem_I2.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stelem_I2, InstrCodesDb.Stelem_i2_) },
+ //{ OpCodes.Stelem_I4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stelem_I4, InstrCodesDb.Stelem_I4_) },
+ //{ OpCodes.Stelem_I8.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stelem_I8, InstrCodesDb.Stelem_I8_) },
+ //{ OpCodes.Stelem_R4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stelem_R4, InstrCodesDb.Stelem_R4_) },
+ //{ OpCodes.Stelem_R8.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stelem_R8, InstrCodesDb.Stelem_R8_) },
+ //{ OpCodes.Stelem_Ref.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stelem_Ref, InstrCodesDb.Stelem_Ref_) },
+ //{ OpCodes.Stfld.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stfld, InstrCodesDb.Stfld_) },
+ //{ OpCodes.Stind_I.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stind_I, InstrCodesDb.Stind_I_) },
+ //{ OpCodes.Stind_I1.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stind_I1, InstrCodesDb.Stind_I1_) },
+ //{ OpCodes.Stind_I2.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stind_I2, InstrCodesDb.Stind_I2_) },
+ //{ OpCodes.Stind_I4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stind_I4, InstrCodesDb.Stind_I4_) },
+ //{ OpCodes.Stind_I8.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stind_I8, InstrCodesDb.Stind_I8_) },
+ //{ OpCodes.Stind_R4.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stind_R4, InstrCodesDb.Stind_R4_) },
+ //{ OpCodes.Stind_R8.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stind_R8, InstrCodesDb.Stind_R8_) },
+ //{ OpCodes.Stind_Ref.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stind_Ref, InstrCodesDb.Stind_Ref_) },
+ //{ OpCodes.Stloc.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stloc, InstrCodesDb.Stloc_) },
+ //{ OpCodes.Stloc_0.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stloc_0, InstrCodesDb.Stloc_0_) },
+ //{ OpCodes.Stloc_1.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stloc_1, InstrCodesDb.Stloc_1_) },
+ //{ OpCodes.Stloc_2.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stloc_2, InstrCodesDb.Stloc_2_) },
+ //{ OpCodes.Stloc_3.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stloc_3, InstrCodesDb.Stloc_3_) },
+ //{ OpCodes.Stloc_S.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stloc_S, InstrCodesDb.Stloc_S_) },
+ //{ OpCodes.Stobj.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stobj, InstrCodesDb.Stobj_) },
+ //{ OpCodes.Stsfld.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Stsfld, InstrCodesDb.Stsfld_) },
+ { OpCodes.Sub.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Sub, InstrCodesDb.Sub_) },
+ { OpCodes.Sub_Ovf.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Sub_Ovf, InstrCodesDb.Sub_ovf_) },
+ { OpCodes.Sub_Ovf_Un.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Sub_Ovf_Un, InstrCodesDb.Sub_ovf_un_) },
+ //{ OpCodes.Switch.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Switch, InstrCodesDb.Switch_) },
+ //{ OpCodes.Tailcall.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Tailcall, InstrCodesDb.Tailcall_) },
+ //{ OpCodes.Throw.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Throw, InstrCodesDb.Throw_) },
+ //{ OpCodes.Unaligned.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Unaligned, InstrCodesDb.Unaligned_) },
+ //{ OpCodes.Unbox.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Unbox, InstrCodesDb.Unbox_) },
+ //{ OpCodes.Unbox_Any.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Unbox_Any, InstrCodesDb.Unbox_Any_) },
+ //{ OpCodes.Volatile.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Volatile, InstrCodesDb.Volatile_) },
+ { OpCodes.Xor.Value, new KeyValuePair<OpCode, VmInstrInfo>(OpCodes.Xor, InstrCodesDb.Xor_) },
+ };
+ #endregion
+ public override Stream CreateVmStream(Type rt, ParameterInfo[] pi, Type[] locals, byte [] ilBytes /*GetIlBytes(src)*/)
+ {
+ var ret = new MemoryStream();
+ var wr = new BinaryWriter(ret);
+ var fwdTypeDefs = new Dictionary<Type, int>();
+ var fwdTypeRefs = new Dictionary<int, Type>();
+ var fwdMethodTokenDefs = new Dictionary<UInt32, int>();
+ var fwdMethodTokenRefs = new Dictionary<long, UInt32>();
+ var deferredBrTargets = new Dictionary<long, UInt32>();
+ var srcToDstInstrPositions = new Dictionary<long, UInt32>();
+ wr.Write(0); // ClassId
+ wr.Flush();
+ const int dummy = 0x55555555;
+ fwdTypeDefs.Add(rt, dummy);
+ fwdTypeRefs.Add((int)ret.Position, rt);
+ wr.Write(dummy); // ReturnTypeId fwd ref
+ wr.Write((ushort)0); // LocalVarTypes
+ wr.Write((byte)2); // Flags - static
+ wr.Write((byte)0); // Name
+ var pars = pi;
+ wr.Write((ushort)pars.Length); // ArgsTypeToOutput
+ foreach (var parameterInfo in pars)
+ {
+ if (!fwdTypeDefs.ContainsKey(parameterInfo.ParameterType))
+ fwdTypeDefs.Add(parameterInfo.ParameterType, dummy);
+ fwdTypeRefs.Add((int)ret.Position, parameterInfo.ParameterType);
+ wr.Write(dummy); // parTypeId fwd ref
+ wr.Write(false);
+ }
+ wr.Write((ushort)locals.Length); // LocalVarTypes
+ foreach (var lt in locals)
+ {
+ if (!fwdTypeDefs.ContainsKey(lt))
+ fwdTypeDefs.Add(lt, dummy);
+ fwdTypeRefs.Add((int)ret.Position, lt);
+ wr.Write(dummy); // parTypeId fwd ref
+ }
+
+ var methodLengthPos = ret.Position;
+ wr.Write(dummy); // methodLength
+ using (var sr = new BinaryReader(new MemoryStream(ilBytes)))
+ {
+ while (sr.BaseStream.Position < sr.BaseStream.Length)
+ {
+ srcToDstInstrPositions[sr.BaseStream.Position] = (uint)ret.Position;
+ short ilByte = sr.ReadByte();
+ if (ilByte == 0xFE)
+ ilByte = (short)((ilByte << 8) | sr.ReadByte());
+ Assert.IsTrue(IlToVmInstrInfo.ContainsKey(ilByte), "Extend IlToVmInstrInfo with {0:X} or use short jump", ilByte);
+ var vmInstrInfo = IlToVmInstrInfo[ilByte];
+ var id = vmInstrInfo.Value.Id;
+ wr.Write((ushort)(id >> 16));
+ wr.Write((ushort)(id & 0xFFFF));
+ wr.Flush();
+ ulong operand = 0;
+ switch (vmInstrInfo.Key.OperandType)
+ {
+ case OperandType.InlineNone:
+ break;
+ case OperandType.InlineI8:
+ case OperandType.InlineR:
+ operand = sr.ReadUInt64();
+ break;
+ case OperandType.InlineVar:
+ operand = sr.ReadUInt16();
+ break;
+ case OperandType.ShortInlineBrTarget:
+ case OperandType.ShortInlineI:
+ case OperandType.ShortInlineVar:
+ operand = sr.ReadByte();
+ break;
+ default:
+ operand = sr.ReadUInt32();
+ break;
+ }
+ if (vmInstrInfo.Key.OperandType == OperandType.ShortInlineBrTarget)
+ {
+ deferredBrTargets[wr.BaseStream.Position] = (uint)sr.BaseStream.Position + (uint)operand;
+ }
+ if (vmInstrInfo.Key.Value == OpCodes.Newobj.Value || vmInstrInfo.Key.Value == OpCodes.Call.Value)
+ {
+ var token = (uint)operand;
+ if (!fwdMethodTokenDefs.ContainsKey(token))
+ fwdMethodTokenDefs.Add(token, dummy);
+ fwdMethodTokenRefs[wr.BaseStream.Position] = token;
+ }
+ switch (vmInstrInfo.Value.OperandType)
+ {
+ case VmOperandType.Ot11Nope:
+ break;
+ case VmOperandType.Ot2Byte:
+ case VmOperandType.Ot6SByte:
+ case VmOperandType.Ot8Byte:
+ wr.Write((byte)operand);
+ break;
+ case VmOperandType.Ot1UShort:
+ case VmOperandType.Ot3UShort:
+ wr.Write((ushort)operand);
+ break;
+ case VmOperandType.Ot0UInt:
+ case VmOperandType.Ot12Int:
+ case VmOperandType.Ot5Int:
+ case VmOperandType.Ot10Float:
+ wr.Write((uint)operand);
+ break;
+ case VmOperandType.Ot7Long:
+ case VmOperandType.Ot4Double:
+ wr.Write(operand);
+ break;
+ default:
+ throw new InvalidDataException("OperandType");
+ }
+ }
+ ret.Position = methodLengthPos;
+ wr.Write((int)(ret.Length - methodLengthPos - 4));
+ wr.Flush();
+ ret.Position = ret.Length;
+ foreach (var t in fwdTypeDefs.Keys.ToArray())
+ {
+ fwdTypeDefs[t] = (int)ret.Position;
+ wr.Write(true);
+ wr.Write((byte)0);
+ wr.Write(-1);
+ wr.Write(-1);
+ wr.Write(false);
+ // ReSharper disable once AssignNullToNotNullAttribute
+ wr.Write(t.AssemblyQualifiedName);
+ wr.Write(false);
+ wr.Write((ushort)0);
+ wr.Flush();
+ }
+ foreach (var t in fwdMethodTokenDefs.Keys.ToArray())
+ {
+ fwdMethodTokenDefs[t] = (int)ret.Position;
+ wr.Write((byte)0);
+ wr.Write(t);
+ wr.Flush();
+ }
+ foreach (var r in fwdTypeRefs)
+ {
+ ret.Position = r.Key;
+ wr.Write(fwdTypeDefs[r.Value]);
+ wr.Flush();
+ }
+ foreach (var t in fwdMethodTokenRefs)
+ {
+ ret.Position = t.Key;
+ wr.Write((ushort)(fwdMethodTokenDefs[t.Value]>>16));
+ wr.Write((ushort)fwdMethodTokenDefs[t.Value]);
+ wr.Flush();
+ }
+ foreach (var r in deferredBrTargets)
+ {
+ ret.Position = r.Key;
+ var srcPos = r.Value;
+ wr.Write(srcToDstInstrPositions[srcPos] - (uint)methodLengthPos - 4);
+ wr.Flush();
+ }
+ ret.Position = 0;
+ return ret;
+ }
+ }
+ public override object Invoke(object[] parameters, Stream vmStream)
+ {
+ var vmStreamWrapper = new VmStreamWrapper(vmStream, VmExecutor.VmXorKey());
+ var callees = new object[]
+ {
+ Assembly.GetCallingAssembly()
+ };
+ var vm = new VmExecutor(InstrCodesDb, vmStreamWrapper);
+ vm.Seek(0, vmStreamWrapper, null);
+ var vmRet = vm.Invoke(parameters, null, null, callees);
+ return vmRet;
+ }
+ }
+
+ internal static class ExtendedEcma335
+ {
+ internal static object AsStackedValue(object v, bool signedComparison) // как это значение будет лежать на стеке
+ {
+ Type t = v.GetType();
+ if (IsFloatingType(t))
+ return v;
+ //остальное приводится к Int32 или Int64
+ if (t.IsEnum) t = t.GetEnumUnderlyingType();
+ if (t == typeof (byte)) return signedComparison ? (object) (Int32) (byte) v : (UInt32) (byte)v;
+ if (t == typeof (sbyte)) return signedComparison ? (object) (Int32) (sbyte) v : (UInt32) (sbyte)v;
+ if (t == typeof (short)) return signedComparison ? (object) (Int32) (short) v : (UInt32) (short)v;
+ if (t == typeof (ushort)) return signedComparison ? (object) (Int32) (ushort)v : (UInt32)(ushort) v;
+ if (t == typeof (Char)) return signedComparison ? (object) (Int32) (Char)v : (UInt32) (Char) v;
+ if (t == typeof (Int32)) return signedComparison ? (object) (Int32) v : (UInt32) (Int32)v;
+ if (t == typeof (UInt32)) return signedComparison ? (object) (Int32) (UInt32) v : (UInt32)v;
+ if (t == typeof(Int64)) return signedComparison ? (object) (Int64)v : (UInt64) (Int64)v;
+ if (t == typeof (UInt64)) return signedComparison ? (object) (Int64) (UInt64) v : (UInt64)v;
+ if (t == typeof(bool)) return signedComparison ? (object) ((bool)v ? 1 : 0) : (UInt32) ((bool)v ? 1 : 0);
+ if (t == typeof(IntPtr))
+ {
+ if (IntPtr.Size == 4)
+ return signedComparison ? (object)((IntPtr)v).ToInt32() : (UInt32)((IntPtr)v).ToInt32();
+ return signedComparison ? (object)((IntPtr)v).ToInt64() : (UInt64)((IntPtr)v).ToInt64();
+ }
+ if (t == typeof(UIntPtr))
+ {
+ if (UIntPtr.Size == 4)
+ return signedComparison ? (object)(Int32)((UIntPtr)v).ToUInt32() : ((UIntPtr)v).ToUInt32();
+ return signedComparison ? (object)(Int64)((UIntPtr)v).ToUInt64() : ((UIntPtr)v).ToUInt64();
+ }
+ return v;
+ }
+
+ [SuppressMessage("ReSharper", "RedundantCast")]
+ internal static bool Check(KeyValuePair<OpCode, UnitTestCombine.CodeTemplate> op, object[] parameters, object vmRet)
+ {
+ try
+ {
+ if (parameters.Length == 2 && op.Value == UnitTestCombine.CodeTemplate.TwoOpAny &&
+ (op.Key.Value == OpCodes.Shl.Value || op.Key.Value == OpCodes.Shr.Value ||
+ op.Key.Value == OpCodes.Shr_Un.Value))
+ {
+ var t0 = parameters[0].GetType();
+ var t1 = parameters[1].GetType();
+ if (t0 == typeof (object) || t1 == typeof (object))
+ return true; // TODO понять бы, почему нет совпадения с фреймфорком
+ if (IsFloatingType(t0) || IsFloatingType(t1))
+ return true; // в зависимости от разрядности фреймворк дурит по-разному
+ bool sign = op.Key.Value != OpCodes.Shr_Un.Value;
+ var commonType = UnitTestCombine.CompatibleType(t0, t1, sign);
+ if (commonType == typeof (Int64) || commonType == typeof (UInt64))
+ {
+ if (sign)
+ {
+ var p0 = Convert.ToInt64(AsStackedValue(parameters[0], true));
+ var p1 = Convert.ToInt64(AsStackedValue(parameters[1], true));
+ return Convert.ToInt64(AsStackedValue(vmRet, true)) ==
+ ((op.Key.Value == OpCodes.Shl.Value) ? (p1 << (int)p0) : (p1 >> (int)p0));
+ }
+ else
+ {
+ var p0 = Convert.ToUInt64(AsStackedValue(parameters[0], false));
+ var p1 = Convert.ToUInt64(AsStackedValue(parameters[1], false));
+ return Convert.ToUInt64(AsStackedValue(vmRet, false)) == (p1 >> (int) p0);
+ }
+ }
+ }
+ if (parameters.Length == 2 && op.Value == UnitTestCombine.CodeTemplate.TwoOpAny &&
+ (op.Key.Value == OpCodes.And.Value || op.Key.Value == OpCodes.Or.Value || op.Key.Value == OpCodes.Xor.Value))
+ {
+ var t0 = parameters[0].GetType();
+ var t1 = parameters[1].GetType();
+ if (t0 == typeof (object) || t1 == typeof (object))
+ return true; // TODO понять бы, почему нет совпадения с фреймфорком
+ if (IntPtr.Size == 8)
+ {
+ if (t0 == typeof (double) || t1 == typeof (double))
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return Convert.ToDouble(vmRet) == ((4 == IntPtr.Size) ? Double.NaN : (double) 0);
+ if (t0 == typeof (float) || t1 == typeof (float))
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return Convert.ToSingle(vmRet) == ((4 == IntPtr.Size) ? Single.NaN : (float) 0);
+ }
+ //x64, как более точный в фреймворке, не даёт сюда срабатываний
+ if (IntPtr.Size == 4 && t0 != t1)
+ {
+ var p0 = Convert.ToInt64(AsStackedValue(parameters[0], true));
+ var p1 = Convert.ToInt64(AsStackedValue(parameters[1], true));
+ Int64 check = 0;
+ if (op.Key.Value == OpCodes.And.Value) check = p0 & p1;
+ if (op.Key.Value == OpCodes.Or.Value) check = p0 | p1;
+ if (op.Key.Value == OpCodes.Xor.Value) check = p0 ^ p1;
+ return Convert.ToInt64(AsStackedValue(vmRet, true)) == check;
+ }
+ }
+ bool bAdd = op.Key.Value == OpCodes.Add.Value || op.Key.Value == OpCodes.Add_Ovf.Value ||
+ op.Key.Value == OpCodes.Add_Ovf_Un.Value;
+ bool bSub = op.Key.Value == OpCodes.Sub.Value || op.Key.Value == OpCodes.Sub_Ovf.Value ||
+ op.Key.Value == OpCodes.Sub_Ovf_Un.Value;
+ bool bMul = op.Key.Value == OpCodes.Mul.Value || op.Key.Value == OpCodes.Mul_Ovf.Value ||
+ op.Key.Value == OpCodes.Mul_Ovf_Un.Value;
+ bool bDiv = op.Key.Value == OpCodes.Div.Value || op.Key.Value == OpCodes.Div_Un.Value;
+ bool bRem = op.Key.Value == OpCodes.Rem.Value || op.Key.Value == OpCodes.Rem_Un.Value;
+ if (parameters.Length == 2 && op.Value == UnitTestCombine.CodeTemplate.TwoOpAny && (bAdd || bSub || bMul || bDiv || bRem))
+ {
+ var t0 = parameters[0].GetType();
+ var t1 = parameters[1].GetType();
+ if ((t0 == typeof (object) || t1 == typeof (object)) && (!(vmRet is Exception) || (op.Key.Value == OpCodes.Mul_Ovf.Value) || (op.Key.Value == OpCodes.Mul_Ovf_Un.Value) || (op.Key.Value == OpCodes.Sub_Ovf_Un.Value)))
+ return true; // TODO понять бы, почему нет совпадения с фреймфорком
+ // баг фреймворка в x64 Mul_Ovf_Un для плавающих
+ if (t0 == t1 && !(IntPtr.Size == 8 && op.Key.Value == OpCodes.Mul_Ovf_Un.Value && IsFloatingType(t0) && t0==t1)) return false;
+ bool sign = op.Key.Value != OpCodes.Add_Ovf_Un.Value && op.Key.Value != OpCodes.Sub_Ovf_Un.Value && op.Key.Value != OpCodes.Mul_Ovf_Un.Value && op.Key.Value != OpCodes.Div_Un.Value && op.Key.Value != OpCodes.Rem_Un.Value;
+ var commonType = UnitTestCombine.CompatibleType(t0, t1, sign);
+ if (commonType == typeof (Int64) || commonType == typeof (UInt64))
+ {
+ if (sign)
+ {
+ var p0 = Convert.ToInt64(AsStackedValue(parameters[0], true));
+ var p1 = Convert.ToInt64(AsStackedValue(parameters[1], true));
+ if (vmRet is OverflowException && (op.Key.Value == OpCodes.Add_Ovf.Value || op.Key.Value == OpCodes.Sub_Ovf.Value || op.Key.Value == OpCodes.Mul_Ovf.Value))
+ {
+ decimal res = bAdd ? ((decimal)p0 + (decimal)p1) : bSub ? ((decimal)p1 - (decimal)p0) : ((decimal)p1 * (decimal)p0);
+ if (commonType == typeof(Int64))
+ return res > (decimal)Int64.MaxValue || res < (decimal)Int64.MinValue;
+ if (commonType == typeof(UInt64))
+ return res > (decimal)UInt64.MaxValue || res < 0;
+ }
+ else
+ {
+ if (p0 == 0 && (bDiv || bRem)) return vmRet is DivideByZeroException;
+ try
+ {
+ return (bAdd ? (p0 + p1) : bSub ? (p1 - p0) : bMul ? (p1 * p0) : bDiv ? (p1 / p0) : (p1 % p0)) == Convert.ToInt64(AsStackedValue(vmRet, true));
+ }
+ catch (Exception e)
+ {
+ return e.GetType() == vmRet.GetType();
+ }
+ }
+ } else
+ {
+ var p0 = Convert.ToUInt64(AsStackedValue(parameters[0], false));
+ var p1 = Convert.ToUInt64(AsStackedValue(parameters[1], false));
+ if (vmRet is OverflowException && op.Key.Value == OpCodes.Sub_Ovf_Un.Value && 4 == IntPtr.Size)
+ {
+ decimal res = (decimal)p1 - (decimal)p0;
+ if (commonType == typeof(UInt64))
+ return res > (decimal)UInt64.MaxValue || res < 0;
+ }
+ else
+ {
+ if (p0 == 0 && (bDiv || bRem)) return vmRet is DivideByZeroException;
+ return Convert.ToUInt64(AsStackedValue(vmRet, false)) == (bAdd ? (p0 + p1) : bSub ? (p1 - p0) : bMul ? (p1 * p0) : bDiv ? (p1 / p0) : (p1 % p0));
+ }
+ }
+ } else if (commonType == typeof(float))
+ {
+ var p0 = Convert.ToSingle(AsStackedValue(parameters[0], sign));
+ var p1 = Convert.ToSingle(AsStackedValue(parameters[1], sign));
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ if (p0 == 0 && (bDiv || bRem)) return vmRet is DivideByZeroException;
+ var vm = Convert.ToSingle(AsStackedValue(vmRet, sign));
+ if (float.IsNaN(p0) || float.IsNaN(p1) || float.IsNaN(vm)) return true;
+ // ReSharper disable once RedundantCast
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return vm == (float)(bAdd ? (p0 + p1) : bSub ? (p1 - p0) : bMul ? (p1 * p0) : bDiv ? (p1 / p0) : (p1 % p0));
+ } else if (commonType == typeof(double))
+ {
+ var p0 = Convert.ToDouble(AsStackedValue(parameters[0], sign));
+ var p1 = Convert.ToDouble(AsStackedValue(parameters[1], sign));
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ if (p0 == 0 && (bDiv || bRem)) return vmRet is DivideByZeroException;
+ var vm = Convert.ToDouble(AsStackedValue(vmRet, sign));
+ if (double.IsNaN(p0) || double.IsNaN(p1) || double.IsNaN(vm)) return true;
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return vm == (bAdd ? (p0 + p1) : bSub ? (p1 - p0) : bMul ? (p1 * p0) : bDiv ? (p1 / p0) : (p1 % p0));
+ }
+ }
+ if (parameters.Length == 1 && op.Value == UnitTestCombine.CodeTemplate.SingleOpAny && op.Key.Value == OpCodes.Conv_U.Value)
+ {
+ if (IsFloatingType(parameters[0].GetType()) && !(vmRet is Exception))
+ {
+ // Framework использует мусор, мы возврвщаем 0
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return Convert.ToDouble(vmRet) == 0.0;
+ }
+ }
+ if (parameters.Length == 1 && op.Value == UnitTestCombine.CodeTemplate.SingleOpAny && op.Key.Value == OpCodes.Ckfinite.Value)
+ {
+ if (!IsFloatingType(parameters[0].GetType()) && !(vmRet is Exception))
+ {
+ double d = Double.NaN;
+ if (parameters[0] is IConvertible)
+ {
+ d = Convert.ToDouble(AsStackedValue(parameters[0], true));
+ }
+ return Convert.ToDouble(vmRet).Equals(d);
+ }
+ }
+ if (parameters.Length == 2 && (op.Value == UnitTestCombine.CodeTemplate.BranchTwoOpBool || op.Value == UnitTestCombine.CodeTemplate.TwoOpBool))
+ {
+ var signedComparison = (op.Key.Value == OpCodes.Bgt_S.Value || op.Key.Value == OpCodes.Ble_S.Value ||
+ op.Key.Value == OpCodes.Bge_S.Value || op.Key.Value == OpCodes.Blt_S.Value || op.Key.Value == OpCodes.Beq_S.Value ||
+ op.Key.Value == OpCodes.Cgt.Value || op.Key.Value == OpCodes.Clt.Value || op.Key.Value == OpCodes.Ceq.Value);
+ var unsignedUnorderedComparison = (op.Key.Value == OpCodes.Bgt_Un_S.Value || op.Key.Value == OpCodes.Ble_Un_S.Value ||
+ op.Key.Value == OpCodes.Bge_Un_S.Value || op.Key.Value == OpCodes.Blt_Un_S.Value ||
+ op.Key.Value == OpCodes.Cgt_Un.Value || op.Key.Value == OpCodes.Clt_Un.Value || op.Key.Value == OpCodes.Bne_Un_S.Value);
+ if (signedComparison || unsignedUnorderedComparison)
+ {
+ var isFloat = parameters.Select(o => IsFloatingType(o.GetType())).ToArray();
+ // разрешаем сравнивать такие типы
+ if (isFloat[0] != isFloat[1])
+ {
+ //F and int32/64
+ var vStacked = parameters.Select(o => AsStackedValue(o, true)).ToArray();
+ if (vStacked.Any(o => !(o is IConvertible)))
+ {
+ return (bool)vmRet == (op.Key.Value == OpCodes.Bne_Un_S.Value);
+ }
+ double a = Convert.ToDouble(vStacked[1]), b = Convert.ToDouble(vStacked[0]);
+ return Compare(op, vmRet, a, b, unsignedUnorderedComparison);
+ }
+ else if (isFloat.All(o => o == false))
+ {
+ var vStacked = parameters.Select(o => AsStackedValue(o, signedComparison)).ToArray();
+ if (vStacked.Any(o => !(o is IConvertible)))
+ {
+ return (bool)vmRet == false;
+ }
+ var vStackSize = vStacked.Select(o => Marshal.SizeOf(o.GetType())).ToArray();
+ if (vStackSize[0] != vStackSize[1])
+ {
+ //32 bit and 64 bit ints
+ if (signedComparison)
+ {
+ Int64 a = (vStackSize[1] == 8) ? (Int64)vStacked[1] : (Int32)vStacked[1];
+ Int64 b = (vStackSize[0] == 8) ? (Int64)vStacked[0] : (Int32)vStacked[0];
+ return Compare(op, vmRet, a, b);
+ }
+ else
+ {
+ UInt64 a = (vStackSize[1] == 8) ? (UInt64)vStacked[1] : (UInt32)vStacked[1];
+ UInt64 b = (vStackSize[0] == 8) ? (UInt64)vStacked[0] : (UInt32)vStacked[0];
+ return Compare(op, vmRet, a, b);
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (Exception exc)
+ {
+ Console.Error.WriteLine(exc);
+ }
+
+ return false;
+ }
+
+ private static bool Compare(KeyValuePair<OpCode, UnitTestCombine.CodeTemplate> op, object vmRet, Double a, Double b, bool unordered)
+ {
+ if (unordered && (Double.IsNaN(a) || Double.IsNaN(b)))
+ {
+ return true;
+ }
+ if (op.Key.Value == OpCodes.Bgt_S.Value || op.Key.Value == OpCodes.Bgt_Un_S.Value || op.Key.Value == OpCodes.Cgt.Value || op.Key.Value == OpCodes.Cgt_Un.Value)
+ return ((a > b) == (bool)vmRet);
+ if (op.Key.Value == OpCodes.Ble_S.Value || op.Key.Value == OpCodes.Ble_Un_S.Value)
+ return ((a <= b) == (bool)vmRet);
+ if (op.Key.Value == OpCodes.Bge_S.Value || op.Key.Value == OpCodes.Bge_Un_S.Value)
+ return ((a >= b) == (bool)vmRet);
+ if (op.Key.Value == OpCodes.Blt_S.Value || op.Key.Value == OpCodes.Blt_Un_S.Value || op.Key.Value == OpCodes.Clt.Value || op.Key.Value == OpCodes.Clt_Un.Value)
+ return ((a < b) == (bool)vmRet);
+ if (op.Key.Value == OpCodes.Ceq.Value || op.Key.Value == OpCodes.Beq_S.Value)
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return ((a == b) == (bool)vmRet);
+ if (op.Key.Value == OpCodes.Bne_Un_S.Value)
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ return ((a != b) == (bool)vmRet);
+ Assert.Fail("Bad op for Compare");
+ return false;
+ }
+
+ private static bool Compare<T>(KeyValuePair<OpCode, UnitTestCombine.CodeTemplate> op, object vmRet, T a, T b) where T : IComparable<T>
+ {
+ if (op.Key.Value == OpCodes.Bgt_S.Value || op.Key.Value == OpCodes.Bgt_Un_S.Value || op.Key.Value == OpCodes.Cgt.Value || op.Key.Value == OpCodes.Cgt_Un.Value)
+ return ((a.CompareTo(b) > 0) == (bool)vmRet);
+ if (op.Key.Value == OpCodes.Ble_S.Value || op.Key.Value == OpCodes.Ble_Un_S.Value)
+ return ((a.CompareTo(b) <= 0) == (bool)vmRet);
+ if (op.Key.Value == OpCodes.Bge_S.Value || op.Key.Value == OpCodes.Bge_Un_S.Value)
+ return ((a.CompareTo(b) >= 0) == (bool)vmRet);
+ if (op.Key.Value == OpCodes.Blt_S.Value || op.Key.Value == OpCodes.Blt_Un_S.Value || op.Key.Value == OpCodes.Clt.Value || op.Key.Value == OpCodes.Clt_Un.Value)
+ return ((a.CompareTo(b) < 0) == (bool)vmRet);
+ if (op.Key.Value == OpCodes.Ceq.Value || op.Key.Value == OpCodes.Beq_S.Value)
+ return (a.Equals(b) == (bool)vmRet);
+ if (op.Key.Value == OpCodes.Bne_Un_S.Value)
+ return ((!a.Equals(b)) == (bool)vmRet);
+ Assert.Fail("Bad op for Compare");
+ return false;
+ }
+
+ private static bool IsFloatingType(Type t)
+ {
+ return t == typeof (Single) || t == typeof (Double);
+ }
+ }
+}
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTestProject.csproj b/runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTestProject.csproj
new file mode 100644
index 0000000..c04c1ef
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTestProject.csproj
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{85318BED-28D8-4B31-A7BA-9ED7882D11FC}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>UnitTestProject</RootNamespace>
+ <AssemblyName>UnitTestProject</AssemblyName>
+ <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
+ <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
+ <IsCodedUITest>False</IsCodedUITest>
+ <TestProjectType>UnitTest</TestProjectType>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Web" />
+ <Reference Include="System.Windows.Forms" />
+ </ItemGroup>
+ <Choose>
+ <When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
+ <ItemGroup>
+ <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+ </ItemGroup>
+ </When>
+ <Otherwise>
+ <ItemGroup>
+ <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
+ </ItemGroup>
+ </Otherwise>
+ </Choose>
+ <ItemGroup>
+ <Compile Include="..\..\Crypto.cs">
+ <Link>CipherRC5.cs</Link>
+ </Compile>
+ <Compile Include="..\..\Core.cs">
+ <Link>Core.cs</Link>
+ </Compile>
+ <Compile Include="..\..\CpuId.cs">
+ <Link>CpuId.cs</Link>
+ </Compile>
+ <Compile Include="..\..\Faces.cs">
+ <Link>Faces.cs</Link>
+ </Compile>
+ <Compile Include="..\..\HardwareID.cs">
+ <Link>HardwareID.cs</Link>
+ </Compile>
+ <Compile Include="..\..\LicensingManager.cs">
+ <Link>LicensingManager.cs</Link>
+ </Compile>
+ <Compile Include="..\..\Loader.cs">
+ <Link>Loader.cs</Link>
+ </Compile>
+ <Compile Include="..\..\LzmaDecoder.cs">
+ <Link>LzmaDecoder.cs</Link>
+ </Compile>
+ <Compile Include="..\..\Numerics\BigInteger.cs">
+ <Link>Numerics\BigInteger.cs</Link>
+ </Compile>
+ <Compile Include="..\..\Numerics\BigIntegerBuilder.cs">
+ <Link>Numerics\BigIntegerBuilder.cs</Link>
+ </Compile>
+ <Compile Include="..\..\Numerics\NumericHelpers.cs">
+ <Link>Numerics\NumericHelpers.cs</Link>
+ </Compile>
+ <Compile Include="..\..\StringManager.cs">
+ <Link>StringManager.cs</Link>
+ </Compile>
+ <Compile Include="..\..\VirtualMachine.cs">
+ <Link>VirtualMachine.cs</Link>
+ </Compile>
+ <Compile Include="..\..\Win32.cs">
+ <Link>Win32.cs</Link>
+ </Compile>
+ <Compile Include="LicensingManagerTests.cs" />
+ <Compile Include="LoaderTests.cs" />
+ <Compile Include="MsilToVmTestCompiler.cs" />
+ <Compile Include="RefVm\ElementedTypeHelper.cs" />
+ <Compile Include="RefVm\MyBuffer.cs" />
+ <Compile Include="RefVm\MyBufferReader.cs" />
+ <Compile Include="RefVm\MyCollection.cs" />
+ <Compile Include="RefVm\SdMetadataTokens.cs" />
+ <Compile Include="RefVm\SdTemplateStuff.cs" />
+ <Compile Include="RefVm\SimpleTypeHelper.cs" />
+ <Compile Include="RefVm\StringDecryptor.cs" />
+ <Compile Include="RefVm\TypeCompatibility.cs" />
+ <Compile Include="RefVm\VariantBase.cs" />
+ <Compile Include="RefVm\VariantFactory.cs" />
+ <Compile Include="RefVm\VmExecutor.cs" />
+ <Compile Include="RefVm\VmInstrCodesDb.cs" />
+ <Compile Include="RefVm\VmMethodHeader.cs" />
+ <Compile Include="RefVm\VmPosParser.cs" />
+ <Compile Include="RefVm\VmStreamWrapper.cs" />
+ <Compile Include="UnitTest1.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="UnitTestCombine.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <WCFMetadata Include="Service References\" />
+ </ItemGroup>
+ <Choose>
+ <When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
+ <ItemGroup>
+ <Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <Private>False</Private>
+ </Reference>
+ </ItemGroup>
+ </When>
+ </Choose>
+ <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTestProject.csproj.bak b/runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTestProject.csproj.bak
new file mode 100644
index 0000000..b5bdc24
--- /dev/null
+++ b/runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTestProject.csproj.bak
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{85318BED-28D8-4B31-A7BA-9ED7882D11FC}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>UnitTestProject</RootNamespace>
+ <AssemblyName>UnitTestProject</AssemblyName>
+ <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
+ <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
+ <IsCodedUITest>False</IsCodedUITest>
+ <TestProjectType>UnitTest</TestProjectType>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Windows.Forms" />
+ </ItemGroup>
+ <Choose>
+ <When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
+ <ItemGroup>
+ <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+ </ItemGroup>
+ </When>
+ <Otherwise>
+ <ItemGroup>
+ <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
+ </ItemGroup>
+ </Otherwise>
+ </Choose>
+ <ItemGroup>
+ <Compile Include="..\..\CipherRC5.cs">
+ <Link>CipherRC5.cs</Link>
+ </Compile>
+ <Compile Include="..\..\Core.cs">
+ <Link>Core.cs</Link>
+ </Compile>
+ <Compile Include="..\..\CpuId.cs">
+ <Link>CpuId.cs</Link>
+ </Compile>
+ <Compile Include="..\..\CRC32.cs">
+ <Link>CRC32.cs</Link>
+ </Compile>
+ <Compile Include="..\..\Faces.cs">
+ <Link>Faces.cs</Link>
+ </Compile>
+ <Compile Include="..\..\HardwareID.cs">
+ <Link>HardwareID.cs</Link>
+ </Compile>
+ <Compile Include="..\..\LicensingManager.cs">
+ <Link>LicensingManager.cs</Link>
+ </Compile>
+ <Compile Include="..\..\Numerics\BigInteger.cs">
+ <Link>Numerics\BigInteger.cs</Link>
+ </Compile>
+ <Compile Include="..\..\Numerics\BigIntegerBuilder.cs">
+ <Link>Numerics\BigIntegerBuilder.cs</Link>
+ </Compile>
+ <Compile Include="..\..\Numerics\NumericHelpers.cs">
+ <Link>Numerics\NumericHelpers.cs</Link>
+ </Compile>
+ <Compile Include="..\..\StringManager.cs">
+ <Link>StringManager.cs</Link>
+ </Compile>
+ <Compile Include="..\..\Win32.cs">
+ <Link>Win32.cs</Link>
+ </Compile>
+ <Compile Include="LicensingManagerTests.cs" />
+ <Compile Include="UnitTest1.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <WCFMetadata Include="Service References\" />
+ </ItemGroup>
+ <Choose>
+ <When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
+ <ItemGroup>
+ <Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <Private>False</Private>
+ </Reference>
+ </ItemGroup>
+ </When>
+ </Choose>
+ <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file