// Decompiled with JetBrains decompiler
// Type: A.H
// 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 RansomGuard;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Cryptography;

#nullable enable
namespace A;

public sealed class H
{
  private readonly ConcurrentDictionary<int, F> bp = new ConcurrentDictionary<int, F>();

  [CompilerGenerated]
  [SpecialName]
  public static H? A() => H.bP;

  [CompilerGenerated]
  [SpecialName]
  public static void A([In] H? obj0) => H.bP = obj0;

  private F A([In] int obj0)
  {
    F f1;
    if (this.bp.TryGetValue(obj0, ref f1))
      return f1;
    F f2 = new F();
    f2.A(obj0);
    f2.A(DateTime.UtcNow);
    f2.B(true);
    F f3 = f2;
    this.bp[obj0] = f3;
    return f3;
  }

  public static F? a([In] int obj0)
  {
    if (H.A() == null)
      return (F) null;
    F f1 = H.A().A(obj0);
    if (!string.IsNullOrWhiteSpace(f1.B()))
      return f1;
    try
    {
      using (Process processById = Process.GetProcessById(obj0))
      {
        f1.B(!processById.HasExited);
        try
        {
          f1.a(processById.MainModule?.FileName);
        }
        catch
        {
          F f2 = f1;
          if (f2.B() == null)
          {
            string processName;
            f2.a(processName = processById.ProcessName);
          }
        }
        f1.A(Path.GetFileName(f1.B() ?? processById.ProcessName));
      }
    }
    catch
    {
      f1.B(false);
    }
    return f1;
  }

  public static bool A([In] int obj0, out F? _param1)
  {
    _param1 = H.a(obj0);
    return _param1 != null;
  }

  public (string? Path, string? Name) A([In] int obj0, [In] string? obj1, [In] string? obj2, int? _param4 = null)
  {
    F f1 = this.A(obj0);
    if (!string.IsNullOrWhiteSpace(obj1))
    {
      f1.a(obj1);
      f1.A(Path.GetFileName(obj1));
      f1.a(_param4 ?? f1.b());
      f1.B(true);
      return (f1.B(), f1.a());
    }
    F f2 = H.a(obj0);
    if (f2 != null)
      return (f2.B(), f2.a());
    F f3;
    if (!this.bp.TryGetValue(f1.b(), ref f3) || string.IsNullOrWhiteSpace(f3.B()))
      return ((string) null, obj2);
    f1.a(f3.B());
    f1.A(f3.a());
    return (f1.B(), f1.a());
  }

  public static string A([In] F obj0)
  {
    if (!string.IsNullOrWhiteSpace(obj0.C()))
      return obj0.C();
    if (!string.IsNullOrWhiteSpace(obj0.B()))
    {
      if (File.Exists(obj0.B()))
      {
        try
        {
          using (SHA256 shA256 = SHA256.Create())
          {
            using (FileStream inputStream = File.OpenRead(obj0.B()))
            {
              byte[] hash = shA256.ComputeHash((Stream) inputStream);
              obj0.B(BitConverter.ToString(hash).Replace(F5D1BF18\u002D5FBA\u002D43C1\u002DA4E0\u002D6D909C027158.DP(), F5D1BF18\u002D5FBA\u002D43C1\u002DA4E0\u002D6D909C027158.Dp()).ToLowerInvariant());
            }
          }
        }
        catch
        {
          obj0.B(F5D1BF18\u002D5FBA\u002D43C1\u002DA4E0\u002D6D909C027158.Do());
        }
        return obj0.C();
      }
    }
    obj0.B(F5D1BF18\u002D5FBA\u002D43C1\u002DA4E0\u002D6D909C027158.Do());
    return obj0.C();
  }

  public static void a([In] F? obj0)
  {
    if (obj0 == null || obj0.c() != SignerStatus.Unavailable && !string.IsNullOrWhiteSpace(obj0.D()))
      return;
    if (string.IsNullOrWhiteSpace(obj0.B()))
    {
      obj0.A(SignerStatus.Unavailable);
      F f = obj0;
      if (f.E() == null)
        f.c(F5D1BF18\u002D5FBA\u002D43C1\u002DA4E0\u002D6D909C027158.cx());
      obj0.a(false);
      obj0.A(false);
    }
    else
    {
      (SignerStatus Status, string Signer, string Issuer, DateTime? ValidFrom, DateTime? ValidTo, string TrustReason) tuple = c.a(obj0.B());
      obj0.A(tuple.Status);
      obj0.b(tuple.Signer);
      obj0.c(tuple.TrustReason);
      obj0.A(tuple.TrustReason != null && tuple.TrustReason.IndexOf(F5D1BF18\u002D5FBA\u002D43C1\u002DA4E0\u002D6D909C027158.DQ(), (StringComparison) 5) >= 0);
      obj0.a(tuple.Status == SignerStatus.Trusted);
    }
  }

  public void B([In] int obj0)
  {
    F f;
    this.bp.TryRemove(obj0, ref f);
  }

  public void A()
  {
    DateTime dateTime = DateTime.UtcNow.AddMinutes(-10.0);
    foreach (KeyValuePair<int, F> keyValuePair in this.bp)
    {
      if (!keyValuePair.Value.H() && DateTime.op_LessThan(keyValuePair.Value.G(), dateTime))
      {
        F f;
        this.bp.TryRemove(keyValuePair.Key, ref f);
      }
    }
  }

  public static string? b([In] int obj0) => H.a(obj0)?.B();
}
