// Decompiled with JetBrains decompiler
// Type: Borland.Delphi.System.Unit
// Assembly: Project1, Version=1.0.1859.4414, Culture=neutral, PublicKeyToken=null
// MVID: 387A0727-86C4-4744-A694-CF2F2E0F060B
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\Trojan.MSIL.WMC.10-fd5e584bd80ce552c9df6b54aeb5b165ab53ae3852db7b074873a0872cf5dc56.exe

using System;
using System.Collections;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;

namespace Borland.Delphi.System
{
  public class Unit
  {
    public static Encoding AnsiEncoding;
    public static readonly ushort[][] MonthDays = new ushort[2][]
    {
      new ushort[12]
      {
        (ushort) 31,
        (ushort) 28,
        (ushort) 31,
        (ushort) 30,
        (ushort) 31,
        (ushort) 30,
        (ushort) 31,
        (ushort) 31,
        (ushort) 30,
        (ushort) 31,
        (ushort) 30,
        (ushort) 31
      },
      new ushort[12]
      {
        (ushort) 31,
        (ushort) 29,
        (ushort) 31,
        (ushort) 30,
        (ushort) 31,
        (ushort) 30,
        (ushort) 31,
        (ushort) 31,
        (ushort) 30,
        (ushort) 31,
        (ushort) 30,
        (ushort) 31
      }
    };
    public static int RandSeed = 0;
    public static object \u0040GlobalFinalizerObject;
    [ThreadStatic]
    public static object \u0040ExceptObject;
    public static TVCLFreeNotify VCLFreeNotify;
    public static TVCLGetClassName VCLGetClassName;
    public static bool TraditionalClassNames = false;
    public static IProxySystemSupport ProxySystemSupport = (IProxySystemSupport) null;
    internal static Thread LMainThread;
    internal static int LastRandSeed = -1;
    internal static Hashtable MetaTypeMap;
    internal static Hashtable MethodMaps;
    internal static _FinalizeHandler OnProcessExit;

    static Unit() => Unit.Borland\u002EDelphi\u002ESystem();

    internal static void InitMetaTypeMap()
    {
      if (Unit.MetaTypeMap != null)
        return;
      Unit.MetaTypeMap = new Hashtable();
    }

    public static \u0040TClass \u0040GetMetaFromHandle(RuntimeTypeHandle ATypeHandle)
    {
      Unit.InitMetaTypeMap();
      if (!(Unit.MetaTypeMap[(object) ATypeHandle] is \u0040TClass metaFromHandle))
      {
        Type typeFromHandle = Type.GetTypeFromHandle(ATypeHandle);
        Type type1 = typeFromHandle;
        if (!type1.IsSubclassOf(typeof (\u0040TClass)))
          type1 = type1.GetNestedType("@Meta" + type1.Name, BindingFlags.Public | BindingFlags.NonPublic);
        if ((object) type1 != null)
        {
          // ISSUE: explicit non-virtual call
          metaFromHandle = __nonvirtual (type1.GetField("@Instance")).GetValue((object) null) as \u0040TClass;
        }
        else
        {
          Type baseType = typeFromHandle.BaseType;
          if ((object) baseType != null)
          {
            Type type2 = (Unit.\u0040GetMetaFromHandle(baseType.TypeHandle) as object).GetType();
            if (type2.IsSubclassOf(typeof (\u0040TClass)))
            {
              // ISSUE: explicit non-virtual call
              ConstructorInfo constructor = __nonvirtual (type2.GetConstructor(Type.EmptyTypes));
              if ((object) constructor != null)
              {
                metaFromHandle = constructor.Invoke((object[]) null) as \u0040TClass;
                metaFromHandle.SetInstanceType(ATypeHandle);
              }
            }
          }
          if (metaFromHandle == null)
            metaFromHandle = new \u0040TClass(ATypeHandle);
        }
        Unit.MetaTypeMap.Add((object) ATypeHandle, (object) metaFromHandle);
      }
      return metaFromHandle;
    }

    public static \u0040TClass \u0040GetMetaFromObject(object Obj) => Obj != null ? (!(Obj is \u0040TClass) ? Unit.\u0040GetMetaFromHandle(Type.GetTypeHandle(Obj)) : Obj as \u0040TClass) : (\u0040TClass) null;

    internal static int GetMessageID(object Obj) => (int) __nonvirtual (Obj.GetType().GetFields())[0].GetValue(Obj);

    public static int \u0040WStrLen([In] string Dest)
    {
      int num = 0;
      if (Dest != null)
        num = Dest != null ? Dest.Length : 0;
      return num;
    }

    public static int \u0040WStrCmp([In] string L, [In] string R)
    {
      int num1 = Unit.\u0040WStrLen(L);
      int num2 = Unit.\u0040WStrLen(R);
      int num3;
      int num4;
      for (num3 = 1; num3 <= num1 && num3 <= num2; ++num3)
      {
        char ch1 = L[num3 - 1];
        char ch2 = R[num3 - 1];
        if ((int) ch1 != (int) ch2)
        {
          num4 = (uint) ch1 >= (uint) ch2 ? 1 : -1;
          goto label_6;
        }
      }
      num4 = num3 > num1 ? (num3 > num2 ? 0 : -1) : 1;
label_6:
      return num4;
    }

    public static void Borland\u002EDelphi\u002ESystem()
    {
      Unit.\u0040GlobalFinalizerObject = (object) new TFinalObject();
      Unit.AnsiEncoding = Encoding.Default;
      Unit.LMainThread = Thread.CurrentThread;
    }
  }
}
