// Decompiled with JetBrains decompiler
// Type: A.L
// Assembly: RansomGuard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 37652FF6-4FF5-4E76-944D-E6CA5073036F
// Assembly location: RansomGuard.dll inside C:\Users\WDAGUtilityAccount\Desktop\RansomGuard.exe)

using \u003CPrivateImplementationDetails\u003E\u007B29195D03\u002D3E0A\u002D468D\u002DA5D2\u002D1BA9D027086D\u007D;
using Microsoft.Win32.SafeHandles;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

#nullable enable
namespace A;

internal static class L
{
  internal static bool A([In] int obj0)
  {
    try
    {
      using (Process processById = Process.GetProcessById(obj0))
      {
        SafeProcessHandle safeHandle = processById.SafeHandle;
        bool flag = false;
        try
        {
          ((SafeHandle) safeHandle).DangerousAddRef(ref flag);
          return G.a(((SafeHandle) safeHandle).DangerousGetHandle()) == 0U;
        }
        finally
        {
          if (flag)
            ((SafeHandle) safeHandle).DangerousRelease();
        }
      }
    }
    catch
    {
      return false;
    }
  }

  internal static bool a([In] int obj0)
  {
    try
    {
      using (Process processById = Process.GetProcessById(obj0))
      {
        SafeProcessHandle safeHandle = processById.SafeHandle;
        bool flag = false;
        try
        {
          ((SafeHandle) safeHandle).DangerousAddRef(ref flag);
          return G.B(((SafeHandle) safeHandle).DangerousGetHandle()) == 0U;
        }
        finally
        {
          if (flag)
            ((SafeHandle) safeHandle).DangerousRelease();
        }
      }
    }
    catch
    {
      return false;
    }
  }

  internal static bool B([In] int obj0)
  {
    try
    {
      Dictionary<int, List<int>> dictionary = L.A();
      HashSet<int> intSet = new HashSet<int>();
      bool flag = true;
      L.A(obj0, dictionary, intSet, ref flag);
      return flag;
    }
    catch
    {
      return false;
    }
  }

  internal static bool A([In] string obj0, [In] string obj1)
  {
    try
    {
      if (!File.Exists(obj0))
        return false;
      Directory.CreateDirectory(obj1);
      string str1 = obj1;
      DefaultInterpolatedStringHandler interpolatedStringHandler = new DefaultInterpolatedStringHandler(1, 2);
      interpolatedStringHandler.AppendFormatted<DateTime>(DateTime.Now, F5D1BF18\u002D5FBA\u002D43C1\u002DA4E0\u002D6D909C027158.eL());
      interpolatedStringHandler.AppendLiteral(F5D1BF18\u002D5FBA\u002D43C1\u002DA4E0\u002D6D909C027158.r());
      interpolatedStringHandler.AppendFormatted(Path.GetFileName(obj0));
      string stringAndClear1 = interpolatedStringHandler.ToStringAndClear();
      string str2 = Path.Combine(str1, stringAndClear1);
      File.Copy(obj0, str2, true);
      L.A(str2);
      string str3 = str2 + F5D1BF18\u002D5FBA\u002D43C1\u002DA4E0\u002D6D909C027158.Br();
      interpolatedStringHandler = new DefaultInterpolatedStringHandler(75, 2);
      interpolatedStringHandler.AppendLiteral(F5D1BF18\u002D5FBA\u002D43C1\u002DA4E0\u002D6D909C027158.el());
      interpolatedStringHandler.AppendFormatted(obj0);
      interpolatedStringHandler.AppendLiteral(F5D1BF18\u002D5FBA\u002D43C1\u002DA4E0\u002D6D909C027158.c());
      interpolatedStringHandler.AppendLiteral(F5D1BF18\u002D5FBA\u002D43C1\u002DA4E0\u002D6D909C027158.eM());
      interpolatedStringHandler.AppendFormatted<DateTime>(DateTime.Now);
      interpolatedStringHandler.AppendLiteral(F5D1BF18\u002D5FBA\u002D43C1\u002DA4E0\u002D6D909C027158.c());
      interpolatedStringHandler.AppendLiteral(F5D1BF18\u002D5FBA\u002D43C1\u002DA4E0\u002D6D909C027158.em());
      string stringAndClear2 = interpolatedStringHandler.ToStringAndClear();
      File.WriteAllText(str3, stringAndClear2);
      return true;
    }
    catch
    {
      return false;
    }
  }

  private static void A([In] string obj0)
  {
    try
    {
      File.WriteAllText(obj0 + F5D1BF18\u002D5FBA\u002D43C1\u002DA4E0\u002D6D909C027158.eN(), F5D1BF18\u002D5FBA\u002D43C1\u002DA4E0\u002D6D909C027158.en());
    }
    catch
    {
    }
  }

  private static Dictionary<int, List<int>> A()
  {
    Dictionary<int, List<int>> dictionary = new Dictionary<int, List<int>>();
    IntPtr num = IntPtr.Zero;
    try
    {
      num = G.A(2U, 0U);
      if (num == IntPtr.Zero || num == G.bA)
        return dictionary;
      G.a a = new G.a()
      {
        EO = (uint) Marshal.SizeOf<G.a>()
      };
      if (!G.A(num, ref a))
        return dictionary;
      do
      {
        int ep = (int) a.EP;
        int er = (int) a.ER;
        List<int> intList;
        if (!dictionary.TryGetValue(er, ref intList))
        {
          intList = new List<int>();
          dictionary[er] = intList;
        }
        intList.Add(ep);
      }
      while (G.a(num, ref a));
    }
    catch
    {
    }
    finally
    {
      if (num != IntPtr.Zero && num != G.bA)
        G.A(num);
    }
    return dictionary;
  }

  private static void A(
    [In] int obj0,
    [In] Dictionary<int, List<int>> obj1,
    [In] HashSet<int> obj2,
    [In] ref bool obj3)
  {
    if (!obj2.Add(obj0))
      return;
    List<int> intList;
    if (obj1.TryGetValue(obj0, ref intList))
    {
      foreach (int num in intList)
        L.A(num, obj1, obj2, ref obj3);
    }
    if (obj0 == Environment.ProcessId || L.b(obj0))
      return;
    obj3 = false;
  }

  private static bool b([In] int obj0)
  {
    IntPtr num = IntPtr.Zero;
    try
    {
      num = G.A(G.ProcessAccessFlags.Terminate, false, obj0);
      return num != IntPtr.Zero && G.A(num, 1U);
    }
    catch
    {
      return false;
    }
    finally
    {
      if (num != IntPtr.Zero && num != G.bA)
        G.A(num);
    }
  }
}
