From 9cb6d36cfb64fb7952272907ba5fad09ecb17e2d Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Fri, 5 Apr 2019 23:53:10 -0700 Subject: [PATCH] Remove old library files. --- Remotely_Library/Enums/RemoteControlMode.cs | 12 - Remotely_Library/Models/CommandContext.cs | 25 - Remotely_Library/Models/CommandContext.d.ts | 12 - Remotely_Library/Models/ConnectionInfo.cs | 29 - Remotely_Library/Models/CursorInfo.cs | 24 - Remotely_Library/Models/CursorInfo.d.ts | 5 - Remotely_Library/Models/Device.cs | 201 --- Remotely_Library/Models/Device.d.ts | 32 - .../Models/DevicePermissionLink.cs | 14 - .../Models/DevicePermissionLink.d.ts | 53 - Remotely_Library/Models/Drive.cs | 19 - Remotely_Library/Models/EventLog.cs | 28 - .../Models/GenericCommandResult.cs | 16 - Remotely_Library/Models/InviteLink.cs | 17 - Remotely_Library/Models/Organization.cs | 23 - .../Models/PSCoreCommandResult.cs | 19 - Remotely_Library/Models/PSError.cs | 13 - Remotely_Library/Models/PermissionGroup.cs | 19 - Remotely_Library/Models/RemotelyUser.cs | 26 - .../Models/RemotelyUserOptions.cs | 29 - .../Models/RemotelyUserOptions.d.ts | 8 - Remotely_Library/Models/ScreenCastRequest.cs | 12 - Remotely_Library/Models/SharedFile.cs | 18 - Remotely_Library/Models/UserPermissionLink.cs | 14 - Remotely_Library/Remotely_Library.csproj | 81 -- Remotely_Library/Services/OSUtils.cs | 122 -- Remotely_Library/Services/RandomGenerator.cs | 25 - .../ViewModels/OrganizationViewModels.cs | 28 - Remotely_Library/Win32/ADVAPI32.cs | 372 ----- Remotely_Library/Win32/GDI32.cs | 85 -- Remotely_Library/Win32/Kernel32.cs | 24 - Remotely_Library/Win32/SECUR32.cs | 373 ----- Remotely_Library/Win32/User32.cs | 1252 ----------------- Remotely_Library/Win32/WTSAPI32.cs | 43 - Remotely_Library/Win32/Win32Interop.cs | 143 -- Remotely_Server/CurrentVersion.txt | 2 +- Utilities/Publish.ps1 | 14 +- 37 files changed, 9 insertions(+), 3223 deletions(-) delete mode 100644 Remotely_Library/Enums/RemoteControlMode.cs delete mode 100644 Remotely_Library/Models/CommandContext.cs delete mode 100644 Remotely_Library/Models/CommandContext.d.ts delete mode 100644 Remotely_Library/Models/ConnectionInfo.cs delete mode 100644 Remotely_Library/Models/CursorInfo.cs delete mode 100644 Remotely_Library/Models/CursorInfo.d.ts delete mode 100644 Remotely_Library/Models/Device.cs delete mode 100644 Remotely_Library/Models/Device.d.ts delete mode 100644 Remotely_Library/Models/DevicePermissionLink.cs delete mode 100644 Remotely_Library/Models/DevicePermissionLink.d.ts delete mode 100644 Remotely_Library/Models/Drive.cs delete mode 100644 Remotely_Library/Models/EventLog.cs delete mode 100644 Remotely_Library/Models/GenericCommandResult.cs delete mode 100644 Remotely_Library/Models/InviteLink.cs delete mode 100644 Remotely_Library/Models/Organization.cs delete mode 100644 Remotely_Library/Models/PSCoreCommandResult.cs delete mode 100644 Remotely_Library/Models/PSError.cs delete mode 100644 Remotely_Library/Models/PermissionGroup.cs delete mode 100644 Remotely_Library/Models/RemotelyUser.cs delete mode 100644 Remotely_Library/Models/RemotelyUserOptions.cs delete mode 100644 Remotely_Library/Models/RemotelyUserOptions.d.ts delete mode 100644 Remotely_Library/Models/ScreenCastRequest.cs delete mode 100644 Remotely_Library/Models/SharedFile.cs delete mode 100644 Remotely_Library/Models/UserPermissionLink.cs delete mode 100644 Remotely_Library/Remotely_Library.csproj delete mode 100644 Remotely_Library/Services/OSUtils.cs delete mode 100644 Remotely_Library/Services/RandomGenerator.cs delete mode 100644 Remotely_Library/ViewModels/OrganizationViewModels.cs delete mode 100644 Remotely_Library/Win32/ADVAPI32.cs delete mode 100644 Remotely_Library/Win32/GDI32.cs delete mode 100644 Remotely_Library/Win32/Kernel32.cs delete mode 100644 Remotely_Library/Win32/SECUR32.cs delete mode 100644 Remotely_Library/Win32/User32.cs delete mode 100644 Remotely_Library/Win32/WTSAPI32.cs delete mode 100644 Remotely_Library/Win32/Win32Interop.cs diff --git a/Remotely_Library/Enums/RemoteControlMode.cs b/Remotely_Library/Enums/RemoteControlMode.cs deleted file mode 100644 index d49d9a65..00000000 --- a/Remotely_Library/Enums/RemoteControlMode.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Remotely_Library.Enums -{ - public enum RemoteControlMode - { - Unattended, - Normal - } -} diff --git a/Remotely_Library/Models/CommandContext.cs b/Remotely_Library/Models/CommandContext.cs deleted file mode 100644 index fd1865c7..00000000 --- a/Remotely_Library/Models/CommandContext.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Runtime.Serialization; - -namespace Remotely_Library.Models -{ - public class CommandContext - { - [Key] - public string ID { get; set; } = Guid.NewGuid().ToString(); - public string CommandMode { get; set; } - public string CommandText { get; set; } - public string SenderUserID { get; set; } - public string SenderConnectionID { get; set; } - public string[] TargetDeviceIDs { get; set; } - public ICollection PSCoreResults { get; set; } = new List(); - public ICollection CommandResults { get; set; } = new List(); - public DateTime TimeStamp { get; set; } = DateTime.Now; - [IgnoreDataMember] - public virtual Organization Organization { get; set; } - public string OrganizationID { get; set; } - } -} diff --git a/Remotely_Library/Models/CommandContext.d.ts b/Remotely_Library/Models/CommandContext.d.ts deleted file mode 100644 index 12ea1458..00000000 --- a/Remotely_Library/Models/CommandContext.d.ts +++ /dev/null @@ -1,12 +0,0 @@ - interface CommandContext { - ID: string; - CommandMode: string; - CommandText: string; - SenderUserID: string; - SenderConnectionID: string; - TargetDeviceIDs: string[]; - PSCoreResults: any[]; - CommandResults: any[]; - TimeStamp: Date; - OrganizationID: string; - } diff --git a/Remotely_Library/Models/ConnectionInfo.cs b/Remotely_Library/Models/ConnectionInfo.cs deleted file mode 100644 index c04f7d5b..00000000 --- a/Remotely_Library/Models/ConnectionInfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Remotely_Library.Models -{ - public class ConnectionInfo - { - public string DeviceID { get; set; } = Guid.NewGuid().ToString(); - private string host; - public string Host - { - get - { - return host; - } - set - { - host = value.Trim(); - if (host.EndsWith("/")) - { - host = host.Substring(0, host.LastIndexOf("/")); - } - } - } - public string OrganizationID { get; set; } - public string ServerVerificationToken { get; set; } - } -} diff --git a/Remotely_Library/Models/CursorInfo.cs b/Remotely_Library/Models/CursorInfo.cs deleted file mode 100644 index 9737d54b..00000000 --- a/Remotely_Library/Models/CursorInfo.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Remotely_Library.Models -{ - public class CursorInfo - { - - public CursorInfo(byte[] imageBytes, Point hotspot, string cssOverride = null) - { - ImageBytes = imageBytes; - HotSpot = hotspot; - CssOverride = cssOverride; - } - - public byte[] ImageBytes { get; set; } - public Point HotSpot { get; set; } - public string CssOverride { get; set; } - } -} diff --git a/Remotely_Library/Models/CursorInfo.d.ts b/Remotely_Library/Models/CursorInfo.d.ts deleted file mode 100644 index e7037d9b..00000000 --- a/Remotely_Library/Models/CursorInfo.d.ts +++ /dev/null @@ -1,5 +0,0 @@ - interface CursorInfo { - ImageBytes: any[]; - HotSpot: any; - CssOverride: string; - } diff --git a/Remotely_Library/Models/Device.cs b/Remotely_Library/Models/Device.cs deleted file mode 100644 index 63b20f84..00000000 --- a/Remotely_Library/Models/Device.cs +++ /dev/null @@ -1,201 +0,0 @@ -using Remotely_Library.Services; -using Microsoft.Management.Infrastructure; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; - -namespace Remotely_Library.Models -{ - public class Device - { - public string CurrentUser { get; set; } - public List Drives { get; set; } - - public double FreeMemory { get; set; } - - public double FreeStorage { get; set; } - - [Key] - public string ID { get; set; } - - public bool Is64Bit { get; set; } - - public bool IsOnline { get; set; } - - public DateTime LastOnline { get; set; } - - public string DeviceName { get; set; } - - public virtual Organization Organization { get; set; } - public string OrganizationID { get; set; } - public Architecture OSArchitecture { get; set; } - - public string OSDescription { get; set; } - - public virtual ICollection DevicePermissionLinks { get; set; } = new List(); - public string Platform { get; set; } - - public int ProcessorCount { get; set; } - public string ServerVerificationToken { get; set; } - [StringLength(200)] - public string Tags { get; set; } = ""; - - public double TotalMemory { get; set; } - public double TotalStorage { get; set; } - public static Device Create(ConnectionInfo connectionInfo) - { - OSPlatform platform = OSUtils.GetPlatform(); - DriveInfo systemDrive; - - if (!string.IsNullOrWhiteSpace(Environment.SystemDirectory)) - { - systemDrive = DriveInfo.GetDrives() - .Where(x=>x.IsReady) - .FirstOrDefault(x => - x.RootDirectory.FullName.Contains(Path.GetPathRoot(Environment.SystemDirectory ?? Environment.CurrentDirectory)) - ); - } - else - { - systemDrive = DriveInfo.GetDrives().FirstOrDefault(x => - x.IsReady && - x.RootDirectory.FullName == Path.GetPathRoot(Environment.CurrentDirectory)); - } - - var device = new Device() - { - ID = connectionInfo.DeviceID, - DeviceName = Environment.MachineName, - Platform = platform.ToString(), - ProcessorCount = Environment.ProcessorCount, - OSArchitecture = RuntimeInformation.OSArchitecture, - OSDescription = RuntimeInformation.OSDescription, - Is64Bit = Environment.Is64BitOperatingSystem, - Drives = DriveInfo.GetDrives().Where(x => x.IsReady).Select(x => new Drive() - { - DriveFormat = x.DriveFormat, - DriveType = x.DriveType, - Name = x.Name, - RootDirectory = x.RootDirectory.FullName, - FreeSpace = x.TotalSize > 0 ? x.TotalFreeSpace / x.TotalSize : 0, - TotalSize = x.TotalSize > 0 ? Math.Round((double)(x.TotalSize / 1024 / 1024 / 1024), 2) : 0, - VolumeLabel = x.VolumeLabel - }).ToList(), - OrganizationID = connectionInfo.OrganizationID, - CurrentUser = GetCurrentUser() - }; - - if (systemDrive != null && systemDrive.TotalSize > 0 && systemDrive.TotalFreeSpace > 0) - { - device.TotalStorage = Math.Round((double)(systemDrive.TotalSize / 1024 / 1024 / 1024), 2); - var freeStorage = Math.Round((double)(systemDrive.TotalFreeSpace / 1024 / 1024 / 1024), 2); - device.FreeStorage = freeStorage / device.TotalStorage; - } - - Tuple totalMemory = new Tuple(0, 0); - - if (OSUtils.IsWindows) - { - totalMemory = GetWinMemoryInGB(); - } - else if (OSUtils.IsLinux) - { - totalMemory = GetLinxMemoryInGB(); - } - - if (totalMemory.Item2 > 0) - { - device.FreeMemory = totalMemory.Item1 / totalMemory.Item2; - } - else - { - device.FreeMemory = 0; - } - device.TotalMemory = totalMemory.Item2; - - return device; - } - - - private static string GetCurrentUser() - { - try - { - if (OSUtils.IsWindows) - { - var session = CimSession.Create(null); - var computerSystem = session.EnumerateInstances("root\\cimv2", "CIM_ComputerSystem"); - var username = computerSystem.FirstOrDefault().CimInstanceProperties["UserName"].Value ?? ""; - return username as string; - } - else if (OSUtils.IsLinux) - { - var users = OSUtils.StartProcessWithResults("users", ""); - var username = users?.Split()?.FirstOrDefault()?.Trim(); - return $"{Environment.UserDomainName}\\{username}"; - } - throw new Exception("Unsupported operating system."); - } - catch - { - return "Error Retrieving"; - } - } - - private static Tuple GetLinxMemoryInGB() - { - try - { - var results = OSUtils.StartProcessWithResults("cat", "/proc/meminfo"); - var resultsArr = results.Split('n'); - var freeKB = resultsArr - .FirstOrDefault(x => x.StartsWith("FreeMem")) - .Split(" ".ToCharArray(), 2) - .Last() // 9168236 kB - .Trim() - .Split(' ') - .First(); // 9168236 - - var totalKB = resultsArr - .FirstOrDefault(x => x.StartsWith("MemTotal")) - .Split(" ".ToCharArray(), 2) - .Last() // 16637468 kB - .Trim() - .Split(' ') - .First(); // 16637468 - - var freeGB = Math.Round((double.Parse(freeKB) / 1024 / 1024), 2); - var totalGB = Math.Round((double.Parse(totalKB) / 1024 / 1024), 2); - - return new Tuple(freeGB, totalGB); - } - catch - { - return new Tuple(0, 0); - } - } - - private static Tuple GetWinMemoryInGB() - { - try - { - var session = CimSession.Create(null); - var cimOS = session.EnumerateInstances("root\\cimv2", "CIM_OperatingSystem"); - var free = (ulong)(cimOS.FirstOrDefault()?.CimInstanceProperties["FreePhysicalMemory"]?.Value ?? 0); - var freeGB = Math.Round(((double)free / 1024 / 1024), 2); - var total = (ulong)(cimOS.FirstOrDefault()?.CimInstanceProperties["TotalVisibleMemorySize"]?.Value ?? 0); - var totalGB = Math.Round(((double)total / 1024 / 1024), 2); - - return new Tuple(freeGB, totalGB); - } - catch - { - return new Tuple(0, 0); - } - } - } -} \ No newline at end of file diff --git a/Remotely_Library/Models/Device.d.ts b/Remotely_Library/Models/Device.d.ts deleted file mode 100644 index 9d219b24..00000000 --- a/Remotely_Library/Models/Device.d.ts +++ /dev/null @@ -1,32 +0,0 @@ - interface Device { - CurrentUser: string; - Drives: any[]; - FreeMemory: number; - FreeStorage: number; - ID: string; - Is64Bit: boolean; - IsOnline: boolean; - LastOnline: Date; - DeviceName: string; - Organization: { - ID: string; - OrganizationName: string; - RemotelyUsers: any[]; - Devices: .Device[]; - CommandContexts: any[]; - EventLogs: any[]; - PermissionGroups: any[]; - InviteLinks: any[]; - SharedFiles: any[]; - }; - OrganizationID: string; - OSArchitecture: any; - OSDescription: string; - DevicePermissionLinks: any[]; - Platform: string; - ProcessorCount: number; - ServerVerificationToken: string; - Tags: string; - TotalMemory: number; - TotalStorage: number; - } diff --git a/Remotely_Library/Models/DevicePermissionLink.cs b/Remotely_Library/Models/DevicePermissionLink.cs deleted file mode 100644 index c15f4978..00000000 --- a/Remotely_Library/Models/DevicePermissionLink.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Remotely_Library.Models -{ - public class DevicePermissionLink - { - public string DeviceID { get; set; } - public Device Device { get; set; } - public string PermissionGroupID { get; set; } - public PermissionGroup PermissionGroup { get; set; } - } -} diff --git a/Remotely_Library/Models/DevicePermissionLink.d.ts b/Remotely_Library/Models/DevicePermissionLink.d.ts deleted file mode 100644 index 72951bce..00000000 --- a/Remotely_Library/Models/DevicePermissionLink.d.ts +++ /dev/null @@ -1,53 +0,0 @@ - interface DevicePermissionLink { - DeviceID: string; - Device: { - CurrentUser: string; - Drives: any[]; - FreeMemory: number; - FreeStorage: number; - ID: string; - Is64Bit: boolean; - IsOnline: boolean; - LastOnline: Date; - DeviceName: string; - Organization: { - ID: string; - OrganizationName: string; - RemotelyUsers: any[]; - Devices: any[]; - CommandContexts: any[]; - EventLogs: any[]; - PermissionGroups: any[]; - InviteLinks: any[]; - SharedFiles: any[]; - }; - OrganizationID: string; - OSArchitecture: any; - OSDescription: string; - DevicePermissionLinks: any[]; - Platform: string; - ProcessorCount: number; - ServerVerificationToken: string; - Tags: string; - TotalMemory: number; - TotalStorage: number; - }; - PermissionGroupID: string; - PermissionGroup: { - ID: string; - Name: string; - Organization: { - ID: string; - OrganizationName: string; - RemotelyUsers: any[]; - Devices: any[]; - CommandContexts: any[]; - EventLogs: any[]; - PermissionGroups: any[]; - InviteLinks: any[]; - SharedFiles: any[]; - }; - UserPermissionLinks: any[]; - DevicePermissionLinks: any[]; - }; - } diff --git a/Remotely_Library/Models/Drive.cs b/Remotely_Library/Models/Drive.cs deleted file mode 100644 index cc20a9df..00000000 --- a/Remotely_Library/Models/Drive.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.IO; -using System.Text; - -namespace Remotely_Library.Models -{ - public class Drive - { - public DriveType DriveType { get; set; } - public string RootDirectory { get; set; } - public string Name { get; set; } - public string DriveFormat { get; set; } - public double FreeSpace { get; set; } - public double TotalSize { get; set; } - public string VolumeLabel { get; set; } - } -} diff --git a/Remotely_Library/Models/EventLog.cs b/Remotely_Library/Models/EventLog.cs deleted file mode 100644 index 46a8dc6a..00000000 --- a/Remotely_Library/Models/EventLog.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Text; - -namespace Remotely_Library.Models -{ - public class EventLog - { - [Key] - public string ID { get; set; } = Guid.NewGuid().ToString(); - public EventTypes EventType { get; set; } - public string Message { get; set; } - public string Source { get; set; } - public string StackTrace { get; set; } - public string OrganizationID { get; set; } - public DateTime TimeStamp { get; set; } = DateTime.Now; - [JsonIgnore] - public virtual Organization Organization { get; set; } - } - public enum EventTypes - { - Info = 0, - Error = 1, - Debug = 2 - } -} diff --git a/Remotely_Library/Models/GenericCommandResult.cs b/Remotely_Library/Models/GenericCommandResult.cs deleted file mode 100644 index c5199b7d..00000000 --- a/Remotely_Library/Models/GenericCommandResult.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Remotely_Library.Models -{ - public class GenericCommandResult - { - public string DeviceID { get; set; } - public string CommandContextID { get; set; } - public string CommandType { get; set; } - public string StandardOutput { get; set; } - public string ErrorOutput { get; set; } - public DateTime TimeStamp { get; set; } = DateTime.Now; - } -} diff --git a/Remotely_Library/Models/InviteLink.cs b/Remotely_Library/Models/InviteLink.cs deleted file mode 100644 index db4d15df..00000000 --- a/Remotely_Library/Models/InviteLink.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Text; - -namespace Remotely_Library.Models -{ - public class InviteLink - { - [Key] - public string ID { get; set; } = Guid.NewGuid().ToString(); - public string InvitedUser { get; set; } - public bool IsAdmin { get; set; } - public DateTime DateSent { get; set; } - public virtual Organization Organization { get; set; } - } -} diff --git a/Remotely_Library/Models/Organization.cs b/Remotely_Library/Models/Organization.cs deleted file mode 100644 index 859f8b31..00000000 --- a/Remotely_Library/Models/Organization.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Remotely_Library.Models; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace Remotely_Library.Models -{ - public class Organization - { - [Key] - public string ID { get; set; } = Guid.NewGuid().ToString(); - - [StringLength(25)] - public string OrganizationName { get; set; } - public virtual ICollection RemotelyUsers { get; set; } - public virtual ICollection Devices { get; set; } - public virtual ICollection CommandContexts { get; set; } - public virtual ICollection EventLogs { get; set; } - public virtual ICollection PermissionGroups { get; set; } = new List(); - public virtual ICollection InviteLinks { get; set; } - public virtual ICollection SharedFiles { get; set; } - } -} \ No newline at end of file diff --git a/Remotely_Library/Models/PSCoreCommandResult.cs b/Remotely_Library/Models/PSCoreCommandResult.cs deleted file mode 100644 index 976ecb52..00000000 --- a/Remotely_Library/Models/PSCoreCommandResult.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Remotely_Library.Models -{ - public class PSCoreCommandResult - { - public string CommandContextID { get; set; } - public string DeviceID { get; set; } - public List VerboseOutput { get; set; } - public List DebugOutput { get; set; } - public List ErrorOutput { get; set; } - public string HostOutput { get; set; } - public List InformationOutput { get; set; } - public List WarningOutput { get; set; } - public DateTime TimeStamp { get; set; } = DateTime.Now; - } -} diff --git a/Remotely_Library/Models/PSError.cs b/Remotely_Library/Models/PSError.cs deleted file mode 100644 index 9e8aed5d..00000000 --- a/Remotely_Library/Models/PSError.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Remotely_Library.Models -{ - public class PSError - { - public string Exception { get; set; } - public string StackTrace { get; set; } - - } -} diff --git a/Remotely_Library/Models/PermissionGroup.cs b/Remotely_Library/Models/PermissionGroup.cs deleted file mode 100644 index 89e92e5b..00000000 --- a/Remotely_Library/Models/PermissionGroup.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Text; - -namespace Remotely_Library.Models -{ - public class PermissionGroup - { - [Key] - public string ID { get; set; } = Guid.NewGuid().ToString(); - [StringLength(100)] - public string Name { get; set; } - public virtual Organization Organization { get; set; } - public virtual ICollection UserPermissionLinks { get; set; } = new List(); - public virtual ICollection DevicePermissionLinks { get; set; } = new List(); - } -} diff --git a/Remotely_Library/Models/RemotelyUser.cs b/Remotely_Library/Models/RemotelyUser.cs deleted file mode 100644 index e10c4f56..00000000 --- a/Remotely_Library/Models/RemotelyUser.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.AspNetCore.Identity; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Threading.Tasks; - -namespace Remotely_Library.Models -{ - public class RemotelyUser : IdentityUser - { - public RemotelyUser() - { - UserOptions = new RemotelyUserOptions(); - Organization = new Organization(); - } - public RemotelyUserOptions UserOptions { get; set; } - - public virtual Organization Organization { get; set; } - public string OrganizationID { get; set; } - - public virtual ICollection UserPermissionLinks { get; set; } = new List(); - - public bool IsAdministrator { get; set; } = true; - } -} diff --git a/Remotely_Library/Models/RemotelyUserOptions.cs b/Remotely_Library/Models/RemotelyUserOptions.cs deleted file mode 100644 index 0fb0094b..00000000 --- a/Remotely_Library/Models/RemotelyUserOptions.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace Remotely_Library.Models -{ - public class RemotelyUserOptions - { - [Display(Name ="Console Prompt")] - [StringLength(5)] - public string ConsolePrompt { get; set; } = "~>"; - - [Display(Name = "Web Shortcut")] - [StringLength(10)] - public string CommandModeShortcutWeb { get; set; } = "/web"; - [Display(Name = "PS Core Shortcut")] - [StringLength(10)] - public string CommandModeShortcutPSCore { get; set; } = "/pscore"; - [Display(Name = "Windows PS Shortcut")] - [StringLength(10)] - public string CommandModeShortcutWinPS { get; set; } = "/winps"; - [Display(Name = "CMD Shortcut")] - [StringLength(10)] - public string CommandModeShortcutCMD { get; set; } = "/cmd"; - [Display(Name = "Bash Shortcut")] - [StringLength(10)] - public string CommandModeShortcutBash { get; set; } = "/bash"; - } -} diff --git a/Remotely_Library/Models/RemotelyUserOptions.d.ts b/Remotely_Library/Models/RemotelyUserOptions.d.ts deleted file mode 100644 index 10487419..00000000 --- a/Remotely_Library/Models/RemotelyUserOptions.d.ts +++ /dev/null @@ -1,8 +0,0 @@ - interface RemotelyUserOptions { - ConsolePrompt: string; - CommandModeShortcutWeb: string; - CommandModeShortcutPSCore: string; - CommandModeShortcutWinPS: string; - CommandModeShortcutCMD: string; - CommandModeShortcutBash: string; - } diff --git a/Remotely_Library/Models/ScreenCastRequest.cs b/Remotely_Library/Models/ScreenCastRequest.cs deleted file mode 100644 index 4c13b270..00000000 --- a/Remotely_Library/Models/ScreenCastRequest.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Remotely_Library.Models -{ - public class ScreenCastRequest - { - public string ViewerID { get; set; } - public string RequesterName { get; set; } - } -} diff --git a/Remotely_Library/Models/SharedFile.cs b/Remotely_Library/Models/SharedFile.cs deleted file mode 100644 index 557dd65e..00000000 --- a/Remotely_Library/Models/SharedFile.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Text; - -namespace Remotely_Library.Models -{ - public class SharedFile - { - [Key] - public string ID { get; set; } = Guid.NewGuid().ToString(); - public string FileName { get; set; } - public string ContentType { get; set; } - public byte[] FileContents { get; set; } - public DateTime Timestamp { get; set; } = DateTime.Now; - public virtual Organization Organization { get; set; } - } -} diff --git a/Remotely_Library/Models/UserPermissionLink.cs b/Remotely_Library/Models/UserPermissionLink.cs deleted file mode 100644 index babae314..00000000 --- a/Remotely_Library/Models/UserPermissionLink.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Remotely_Library.Models -{ - public class UserPermissionLink - { - public string RemotelyUserID { get; set; } - public RemotelyUser RemotelyUser { get; set; } - public string PermissionGroupID { get; set; } - public PermissionGroup PermissionGroup { get; set; } - } -} diff --git a/Remotely_Library/Remotely_Library.csproj b/Remotely_Library/Remotely_Library.csproj deleted file mode 100644 index 56a58aa4..00000000 --- a/Remotely_Library/Remotely_Library.csproj +++ /dev/null @@ -1,81 +0,0 @@ - - - - netstandard2.0 - AnyCPU;x86;x64 - - - - - Device.cs - True - True - - - PSCoreCommandResult.cs - True - True - - - - - - - - - - - - CommandContext.d.ts - DtsGenerator - - - DtsGenerator - CursorInfo.d.ts - - - DtsGenerator - DevicePermissionLink.d.ts - - - RemotelyUserOptions.d.ts - DtsGenerator - - - GenericCommandResult.cs.d.ts - DtsGenerator - - - Device.d.ts - DtsGenerator - - - PSCoreCommandResult.cs.d.ts - DtsGenerator - - - - - - True - True - CommandContext.cs - - - True - True - CursorInfo.cs - - - True - True - DevicePermissionLink.cs - - - True - True - RemotelyUserOptions.cs - - - - diff --git a/Remotely_Library/Services/OSUtils.cs b/Remotely_Library/Services/OSUtils.cs deleted file mode 100644 index c669ef0e..00000000 --- a/Remotely_Library/Services/OSUtils.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace Remotely_Library.Services -{ - public static class OSUtils - { - public static bool IsLinux - { - get - { - return RuntimeInformation.IsOSPlatform(OSPlatform.Linux); - } - } - - public static bool IsWindows - { - get - { - return RuntimeInformation.IsOSPlatform(OSPlatform.Windows); - } - } - public static string ClientExecutableFileName - { - get - { - string fileExt = ""; - if (IsWindows) - { - fileExt = "Remotely_Agent.exe"; - } - else if (IsLinux) - { - fileExt = "Remotely_Agent"; - } - return fileExt; - } - } - public static string ScreenCastExecutableFileName - { - get - { - if (IsWindows) - { - return "Remotely_ScreenCast.exe"; - } - else if (IsLinux) - { - return "Remotely_ScreenCast.Linux"; - } - else - { - throw new Exception("Unsupported operating system."); - } - } - } - - public static string CoreZipFileName - { - get - { - if (IsWindows) - { - if (Environment.Is64BitOperatingSystem) - { - return "Remotely-Win10-x64.zip"; - } - else - { - return "Remotely-Win10-x86.zip"; - } - - } - else if (OSUtils.IsLinux) - { - return "Remotely-Linux.zip"; - } - else - { - throw new Exception("Unsupported operating system."); - } - } - } - public static OSPlatform GetPlatform() - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return OSPlatform.Windows; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - return OSPlatform.Linux; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - return OSPlatform.OSX; - } - else - { - return OSPlatform.Create("Unknown"); - } - } - - public static string StartProcessWithResults(string command, string arguments) - { - var psi = new ProcessStartInfo(command, arguments); - psi.WindowStyle = ProcessWindowStyle.Hidden; - psi.Verb = "RunAs"; - psi.UseShellExecute = false; - psi.RedirectStandardOutput = true; - - var proc = new Process(); - proc.StartInfo = psi; - - proc.Start(); - proc.WaitForExit(); - - return proc.StandardOutput.ReadToEnd(); - } - } -} diff --git a/Remotely_Library/Services/RandomGenerator.cs b/Remotely_Library/Services/RandomGenerator.cs deleted file mode 100644 index 7f091b18..00000000 --- a/Remotely_Library/Services/RandomGenerator.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Security.Cryptography; -using System.Text; -using System.Linq; - -namespace Remotely_Library.Services -{ - public class RandomGenerator - { - private const string allowableCharacters = "abcdefghijklmnopqrstuvwxyz0123456789"; - - public string GenerateString(int length) - { - var bytes = new byte[length]; - - using (var random = RandomNumberGenerator.Create()) - { - random.GetBytes(bytes); - } - - return new string(bytes.Select(x => allowableCharacters[x % allowableCharacters.Length]).ToArray()); - } - } -} diff --git a/Remotely_Library/ViewModels/OrganizationViewModels.cs b/Remotely_Library/ViewModels/OrganizationViewModels.cs deleted file mode 100644 index 2add6068..00000000 --- a/Remotely_Library/ViewModels/OrganizationViewModels.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Text; - -namespace Remotely_Library.ViewModels -{ - public class Permission - { - public string ID { get; set; } - [StringLength(100)] - public string Name { get; set; } - } - public class OrganizationUser - { - public string ID { get; set; } - public string UserName { get; set; } - public bool IsAdmin { get; set; } - public List Permissions { get; set; } - } - public class Invite - { - public string ID { get; set; } - public bool IsAdmin { get; set; } - public DateTime DateSent { get; set; } - public string InvitedUser { get; set; } - } -} diff --git a/Remotely_Library/Win32/ADVAPI32.cs b/Remotely_Library/Win32/ADVAPI32.cs deleted file mode 100644 index c7da5679..00000000 --- a/Remotely_Library/Win32/ADVAPI32.cs +++ /dev/null @@ -1,372 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Security; - -namespace Remotely_Library.Win32 -{ - public static class ADVAPI32 - { - #region Structs - public struct TOKEN_PRIVILEGES - { - public struct LUID - { - public UInt32 LowPart; - public Int32 HighPart; - } - [StructLayout(LayoutKind.Sequential, Pack = 4)] - public struct LUID_AND_ATTRIBUTES - { - public LUID Luid; - public UInt32 Attributes; - } - public int PrivilegeCount; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = ANYSIZE_ARRAY)] - public LUID_AND_ATTRIBUTES[] Privileges; - } - public class USEROBJECTFLAGS - { - public int fInherit = 0; - public int fReserved = 0; - public int dwFlags = 0; - } - [StructLayout(LayoutKind.Sequential)] - public struct SECURITY_ATTRIBUTES - { - public int Length; - public IntPtr lpSecurityDescriptor; - public bool bInheritHandle; - } - [StructLayout(LayoutKind.Sequential)] - public struct PROCESS_INFORMATION - { - public IntPtr hProcess; - public IntPtr hThread; - public int dwProcessId; - public int dwThreadId; - } - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct STARTUPINFO - { - public Int32 cb; - public string lpReserved; - public string lpDesktop; - public string lpTitle; - public Int32 dwX; - public Int32 dwY; - public Int32 dwXSize; - public Int32 dwYSize; - public Int32 dwXCountChars; - public Int32 dwYCountChars; - public Int32 dwFillAttribute; - public Int32 dwFlags; - public Int16 wShowWindow; - public Int16 cbReserved2; - public IntPtr lpReserved2; - public IntPtr hStdInput; - public IntPtr hStdOutput; - public IntPtr hStdError; - } - #endregion - - #region Enums - public enum TOKEN_INFORMATION_CLASS - { - /// -     /// The buffer receives a TOKEN_USER structure that contains the user account of the token. -     /// - TokenUser = 1, - - /// -     /// The buffer receives a TOKEN_GROUPS structure that contains the group accounts associated with the token. -     /// - TokenGroups, - - /// -     /// The buffer receives a TOKEN_PRIVILEGES structure that contains the privileges of the token. -     /// - TokenPrivileges, - - /// -     /// The buffer receives a TOKEN_OWNER structure that contains the default owner security identifier (SID) for newly created objects. -     /// - TokenOwner, - - /// -     /// The buffer receives a TOKEN_PRIMARY_GROUP structure that contains the default primary group SID for newly created objects. -     /// - TokenPrimaryGroup, - - /// -     /// The buffer receives a TOKEN_DEFAULT_DACL structure that contains the default DACL for newly created objects. -     /// - TokenDefaultDacl, - - /// -     /// The buffer receives a TOKEN_SOURCE structure that contains the source of the token. TOKEN_QUERY_SOURCE access is needed to retrieve this information. -     /// - TokenSource, - - /// -     /// The buffer receives a TOKEN_TYPE value that indicates whether the token is a primary or impersonation token. -     /// - TokenType, - - /// -     /// The buffer receives a SECURITY_IMPERSONATION_LEVEL value that indicates the impersonation level of the token. If the access token is not an impersonation token, the function fails. -     /// - TokenImpersonationLevel, - - /// -     /// The buffer receives a TOKEN_STATISTICS structure that contains various token statistics. -     /// - TokenStatistics, - - /// -     /// The buffer receives a TOKEN_GROUPS structure that contains the list of restricting SIDs in a restricted token. -     /// - TokenRestrictedSids, - - /// -     /// The buffer receives a DWORD value that indicates the Terminal Services session identifier that is associated with the token. -     /// - TokenSessionId, - - /// -     /// The buffer receives a TOKEN_GROUPS_AND_PRIVILEGES structure that contains the user SID, the group accounts, the restricted SIDs, and the authentication ID associated with the token. -     /// - TokenGroupsAndPrivileges, - - /// -     /// Reserved. -     /// - TokenSessionReference, - - /// -     /// The buffer receives a DWORD value that is nonzero if the token includes the SANDBOX_INERT flag. -     /// - TokenSandBoxInert, - - /// -     /// Reserved. -     /// - TokenAuditPolicy, - - /// -     /// The buffer receives a TOKEN_ORIGIN value. -     /// - TokenOrigin, - - /// -     /// The buffer receives a TOKEN_ELEVATION_TYPE value that specifies the elevation level of the token. -     /// - TokenElevationType, - - /// -     /// The buffer receives a TOKEN_LINKED_TOKEN structure that contains a handle to another token that is linked to this token. -     /// - TokenLinkedToken, - - /// -     /// The buffer receives a TOKEN_ELEVATION structure that specifies whether the token is elevated. -     /// - TokenElevation, - - /// -     /// The buffer receives a DWORD value that is nonzero if the token has ever been filtered. -     /// - TokenHasRestrictions, - - /// -     /// The buffer receives a TOKEN_ACCESS_INFORMATION structure that specifies security information contained in the token. -     /// - TokenAccessInformation, - - /// -     /// The buffer receives a DWORD value that is nonzero if virtualization is allowed for the token. -     /// - TokenVirtualizationAllowed, - - /// -     /// The buffer receives a DWORD value that is nonzero if virtualization is enabled for the token. -     /// - TokenVirtualizationEnabled, - - /// -     /// The buffer receives a TOKEN_MANDATORY_LABEL structure that specifies the token's integrity level. -     /// - TokenIntegrityLevel, - - /// -     /// The buffer receives a DWORD value that is nonzero if the token has the UIAccess flag set. -     /// - TokenUIAccess, - - /// -     /// The buffer receives a TOKEN_MANDATORY_POLICY structure that specifies the token's mandatory integrity policy. -     /// - TokenMandatoryPolicy, - - /// -     /// The buffer receives the token's logon security identifier (SID). -     /// - TokenLogonSid, - - /// -     /// The maximum value for this enumeration -     /// - MaxTokenInfoClass - } - public enum LOGON_TYPE - { - LOGON32_LOGON_INTERACTIVE = 2, - LOGON32_LOGON_NETWORK, - LOGON32_LOGON_BATCH, - LOGON32_LOGON_SERVICE, - LOGON32_LOGON_UNLOCK = 7, - LOGON32_LOGON_NETWORK_CLEARTEXT, - LOGON32_LOGON_NEW_CREDENTIALS - } - public enum LOGON_PROVIDER - { - LOGON32_PROVIDER_DEFAULT, - LOGON32_PROVIDER_WINNT35, - LOGON32_PROVIDER_WINNT40, - LOGON32_PROVIDER_WINNT50 - } - [Flags] - public enum CreateProcessFlags - { - CREATE_BREAKAWAY_FROM_JOB = 0x01000000, - CREATE_DEFAULT_ERROR_MODE = 0x04000000, - CREATE_NEW_CONSOLE = 0x00000010, - CREATE_NEW_PROCESS_GROUP = 0x00000200, - CREATE_NO_WINDOW = 0x08000000, - CREATE_PROTECTED_PROCESS = 0x00040000, - CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000, - CREATE_SEPARATE_WOW_VDM = 0x00000800, - CREATE_SHARED_WOW_VDM = 0x00001000, - CREATE_SUSPENDED = 0x00000004, - CREATE_UNICODE_ENVIRONMENT = 0x00000400, - DEBUG_ONLY_THIS_PROCESS = 0x00000002, - DEBUG_PROCESS = 0x00000001, - DETACHED_PROCESS = 0x00000008, - EXTENDED_STARTUPINFO_PRESENT = 0x00080000, - INHERIT_PARENT_AFFINITY = 0x00010000 - } - public enum TOKEN_TYPE : int - { - TokenPrimary = 1, - TokenImpersonation = 2 - } - - public enum SECURITY_IMPERSONATION_LEVEL : int - { - SecurityAnonymous = 0, - SecurityIdentification = 1, - SecurityImpersonation = 2, - SecurityDelegation = 3, - } - - #endregion - - #region Constants - public const int TOKEN_DUPLICATE = 0x0002; - public const uint MAXIMUM_ALLOWED = 0x2000000; - public const int CREATE_NEW_CONSOLE = 0x00000010; - public const int CREATE_NO_WINDOW = 0x08000000; - public const int DETACHED_PROCESS = 0x00000008; - public const int TOKEN_ALL_ACCESS = 0x000f01ff; - public const int PROCESS_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF; - public const int STANDARD_RIGHTS_REQUIRED = 0x000F0000; - public const int SYNCHRONIZE = 0x00100000; - - public const int IDLE_PRIORITY_CLASS = 0x40; - public const int NORMAL_PRIORITY_CLASS = 0x20; - public const int HIGH_PRIORITY_CLASS = 0x80; - public const int REALTIME_PRIORITY_CLASS = 0x100; - public const UInt32 SE_PRIVILEGE_ENABLED_BY_DEFAULT = 0x00000001; - public const UInt32 SE_PRIVILEGE_ENABLED = 0x00000002; - public const UInt32 SE_PRIVILEGE_REMOVED = 0x00000004; - public const UInt32 SE_PRIVILEGE_USED_FOR_ACCESS = 0x80000000; - public const Int32 ANYSIZE_ARRAY = 1; - - public const int UOI_FLAGS = 1; - public const int UOI_NAME = 2; - public const int UOI_TYPE = 3; - public const int UOI_USER_SID = 4; - public const int UOI_HEAPSIZE = 5; - public const int UOI_IO = 6; - #endregion - - #region DLL Imports - [DllImport("advapi32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool AdjustTokenPrivileges(IntPtr tokenHandle, - [MarshalAs(UnmanagedType.Bool)]bool disableAllPrivileges, - ref TOKEN_PRIVILEGES newState, - UInt32 bufferLengthInBytes, - ref TOKEN_PRIVILEGES previousState, - out UInt32 returnLengthInBytes); - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Auto)] - public static extern bool CreateProcessAsUser( - IntPtr hToken, - string lpApplicationName, - string lpCommandLine, - ref SECURITY_ATTRIBUTES lpProcessAttributes, - ref SECURITY_ATTRIBUTES lpThreadAttributes, - bool bInheritHandles, - uint dwCreationFlags, - IntPtr lpEnvironment, - string lpCurrentDirectory, - ref STARTUPINFO lpStartupInfo, - out PROCESS_INFORMATION lpProcessInformation); - - [DllImport("advapi32.dll", SetLastError = true)] - public static extern bool AllocateLocallyUniqueId(out IntPtr pLuid); - - [DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = false)] - public static extern SECUR32.WinErrors LsaNtStatusToWinError(SECUR32.WinStatusCodes status); - - [DllImport("advapi32.dll", SetLastError = true)] - public static extern bool GetTokenInformation( - IntPtr TokenHandle, - SECUR32.TOKEN_INFORMATION_CLASS TokenInformationClass, - IntPtr TokenInformation, - uint TokenInformationLength, - out uint ReturnLength); - - [DllImport("advapi32.dll", SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool LogonUser( - [MarshalAs(UnmanagedType.LPStr)] string pszUserName, - [MarshalAs(UnmanagedType.LPStr)] string pszDomain, - [MarshalAs(UnmanagedType.LPStr)] string pszPassword, - int dwLogonType, - int dwLogonProvider, - out IntPtr phToken); - - [DllImport("advapi32", SetLastError = true), SuppressUnmanagedCodeSecurityAttribute] - public static extern bool OpenProcessToken(IntPtr ProcessHandle, int DesiredAccess, ref IntPtr TokenHandle); - [DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)] - public extern static bool DuplicateTokenEx( - IntPtr hExistingToken, - uint dwDesiredAccess, - ref SECURITY_ATTRIBUTES lpTokenAttributes, - SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, - TOKEN_TYPE TokenType, - out IntPtr phNewToken); - - [DllImport("advapi32.dll", SetLastError = false)] - public static extern uint LsaNtStatusToWinError(uint status); - - [DllImport("user32.dll", SetLastError = true)] - public static extern bool GetUserObjectInformationW(IntPtr hObj, int nIndex, - [Out] byte[] pvInfo, uint nLength, out uint lpnLengthNeeded); - #endregion - - - } -} diff --git a/Remotely_Library/Win32/GDI32.cs b/Remotely_Library/Win32/GDI32.cs deleted file mode 100644 index 2dea3bd8..00000000 --- a/Remotely_Library/Win32/GDI32.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; - -namespace Remotely_Library.Win32 -{ - public static class GDI32 - { - #region Enums - /// - /// Specifies a raster-operation code. These codes define how the color data for the - /// source rectangle is to be combined with the color data for the destination - /// rectangle to achieve the final color. - /// - public enum TernaryRasterOperations : uint - { - /// dest = source - SRCCOPY = 0x00CC0020, - /// dest = source OR dest - SRCPAINT = 0x00EE0086, - /// dest = source AND dest - SRCAND = 0x008800C6, - /// dest = source XOR dest - SRCINVERT = 0x00660046, - /// dest = source AND (NOT dest) - SRCERASE = 0x00440328, - /// dest = (NOT source) - NOTSRCCOPY = 0x00330008, - /// dest = (NOT src) AND (NOT dest) - NOTSRCERASE = 0x001100A6, - /// dest = (source AND pattern) - MERGECOPY = 0x00C000CA, - /// dest = (NOT source) OR dest - MERGEPAINT = 0x00BB0226, - /// dest = pattern - PATCOPY = 0x00F00021, - /// dest = DPSnoo - PATPAINT = 0x00FB0A09, - /// dest = pattern XOR dest - PATINVERT = 0x005A0049, - /// dest = (NOT dest) - DSTINVERT = 0x00550009, - /// dest = BLACK - BLACKNESS = 0x00000042, - /// dest = WHITE - WHITENESS = 0x00FF0062, - /// - /// Capture window as seen on screen. This includes layered windows - /// such as WPF windows with AllowsTransparency="true" - /// - CAPTUREBLT = 0x40000000 - } - #endregion - - #region DLL Imports - - [DllImport("gdi32.dll", EntryPoint = "BitBlt", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool BitBlt([In] IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight, [In] IntPtr hdcSrc, int nXSrc, int nYSrc, TernaryRasterOperations dwRop); - - [DllImport("gdi32.dll")] - public static extern IntPtr CreateDC(string lpszDriver, string lpszDevice, string lpszOutput, IntPtr lpInitData); - - [DllImport("GDI32.dll")] - public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight);[DllImport("GDI32.dll")] - public static extern IntPtr CreateCompatibleDC(IntPtr hdc); - - [DllImport("GDI32.dll")] - public static extern bool DeleteDC(IntPtr hdc); - - [DllImport("GDI32.dll")] - public static extern bool DeleteObject(IntPtr hObject); - - [DllImport("GDI32.dll")] - public static extern IntPtr GetDeviceCaps(IntPtr hdc, int nIndex); - - [DllImport("GDI32.dll")] - public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj); - - #endregion - } -} diff --git a/Remotely_Library/Win32/Kernel32.cs b/Remotely_Library/Win32/Kernel32.cs deleted file mode 100644 index 1e3114a7..00000000 --- a/Remotely_Library/Win32/Kernel32.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Remotely_Library.Win32 -{ - public static class Kernel32 - { - #region DLL Imports - - [DllImport("kernel32.dll", SetLastError = true)] - public static extern bool CloseHandle(IntPtr hSnapshot); - - [DllImport("kernel32.dll")] - public static extern uint WTSGetActiveConsoleSessionId(); - - [DllImport("kernel32.dll")] - public static extern bool ProcessIdToSessionId(uint dwProcessId, ref uint pSessionId); - - [DllImport("kernel32.dll")] - public static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, uint dwProcessId); - - #endregion - } -} diff --git a/Remotely_Library/Win32/SECUR32.cs b/Remotely_Library/Win32/SECUR32.cs deleted file mode 100644 index 24dd82bd..00000000 --- a/Remotely_Library/Win32/SECUR32.cs +++ /dev/null @@ -1,373 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using System.Runtime.Versioning; -using Microsoft.Win32.SafeHandles; -using System.Runtime.ConstrainedExecution; -using Remotely_Library.Win32; - -public static class SECUR32 -{ - public enum WinStatusCodes : uint - { - STATUS_SUCCESS = 0 - } - - public enum WinErrors : uint - { - NO_ERROR = 0, - } - public enum WinLogonType - { - LOGON32_LOGON_INTERACTIVE = 2, - LOGON32_LOGON_NETWORK = 3, - LOGON32_LOGON_BATCH = 4, - LOGON32_LOGON_SERVICE = 5, - LOGON32_LOGON_UNLOCK = 7, - LOGON32_LOGON_NETWORK_CLEARTEXT = 8, - LOGON32_LOGON_NEW_CREDENTIALS = 9 - } - - // SECURITY_LOGON_TYPE - public enum SecurityLogonType - { - Interactive = 2, // Interactively logged on (locally or remotely) - Network, // Accessing system via network - Batch, // Started via a batch queue - Service, // Service started by service controller - Proxy, // Proxy logon - Unlock, // Unlock workstation - NetworkCleartext, // Network logon with cleartext credentials - NewCredentials, // Clone caller, new default credentials - RemoteInteractive, // Remote, yet interactive. Terminal server - CachedInteractive, // Try cached credentials without hitting the net. - CachedRemoteInteractive, // Same as RemoteInteractive, this is used internally for auditing purpose - CachedUnlock // Cached Unlock workstation - } - - [StructLayout(LayoutKind.Sequential)] - public struct LSA_UNICODE_STRING - { - public UInt16 Length; - public UInt16 MaximumLength; - public IntPtr Buffer; - } - - [StructLayout(LayoutKind.Sequential)] - public struct TOKEN_SOURCE - { - public TOKEN_SOURCE(string name) - { - SourceName = new byte[8]; - System.Text.Encoding.GetEncoding(1252).GetBytes(name, 0, name.Length, SourceName, 0); - if (!ADVAPI32.AllocateLocallyUniqueId(out SourceIdentifier)) - throw new System.ComponentModel.Win32Exception(); - } - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] SourceName; - public IntPtr SourceIdentifier; - } - [StructLayout(LayoutKind.Sequential)] - public struct KERB_INTERACTIVE_LOGON - { - public KERB_LOGON_SUBMIT_TYPE MessageType; - public string LogonDomainName; - public string UserName; - public string Password; - } - public enum KERB_LOGON_SUBMIT_TYPE - { - KerbInteractiveLogon = 2, - KerbSmartCardLogon = 6, - KerbWorkstationUnlockLogon = 7, - KerbSmartCardUnlockLogon = 8, - KerbProxyLogon = 9, - KerbTicketLogon = 10, - KerbTicketUnlockLogon = 11, - KerbS4ULogon = 12, - KerbCertificateLogon = 13, - KerbCertificateS4ULogon = 14, - KerbCertificateUnlockLogon = 15 - } - public enum TOKEN_INFORMATION_CLASS - { - /// -     /// The buffer receives a TOKEN_USER structure that contains the user account of the token. -     /// - TokenUser = 1, - - /// -     /// The buffer receives a TOKEN_GROUPS structure that contains the group accounts associated with the token. -     /// - TokenGroups, - - /// -     /// The buffer receives a TOKEN_PRIVILEGES structure that contains the privileges of the token. -     /// - TokenPrivileges, - - /// -     /// The buffer receives a TOKEN_OWNER structure that contains the default owner security identifier (SID) for newly created objects. -     /// - TokenOwner, - - /// -     /// The buffer receives a TOKEN_PRIMARY_GROUP structure that contains the default primary group SID for newly created objects. -     /// - TokenPrimaryGroup, - - /// -     /// The buffer receives a TOKEN_DEFAULT_DACL structure that contains the default DACL for newly created objects. -     /// - TokenDefaultDacl, - - /// -     /// The buffer receives a TOKEN_SOURCE structure that contains the source of the token. TOKEN_QUERY_SOURCE access is needed to retrieve this information. -     /// - TokenSource, - - /// -     /// The buffer receives a TOKEN_TYPE value that indicates whether the token is a primary or impersonation token. -     /// - TokenType, - - /// -     /// The buffer receives a SECURITY_IMPERSONATION_LEVEL value that indicates the impersonation level of the token. If the access token is not an impersonation token, the function fails. -     /// - TokenImpersonationLevel, - - /// -     /// The buffer receives a TOKEN_STATISTICS structure that contains various token statistics. -     /// - TokenStatistics, - - /// -     /// The buffer receives a TOKEN_GROUPS structure that contains the list of restricting SIDs in a restricted token. -     /// - TokenRestrictedSids, - - /// -     /// The buffer receives a DWORD value that indicates the Terminal Services session identifier that is associated with the token. -     /// - TokenSessionId, - - /// -     /// The buffer receives a TOKEN_GROUPS_AND_PRIVILEGES structure that contains the user SID, the group accounts, the restricted SIDs, and the authentication ID associated with the token. -     /// - TokenGroupsAndPrivileges, - - /// -     /// Reserved. -     /// - TokenSessionReference, - - /// -     /// The buffer receives a DWORD value that is nonzero if the token includes the SANDBOX_INERT flag. -     /// - TokenSandBoxInert, - - /// -     /// Reserved. -     /// - TokenAuditPolicy, - - /// -     /// The buffer receives a TOKEN_ORIGIN value. -     /// - TokenOrigin, - - /// -     /// The buffer receives a TOKEN_ELEVATION_TYPE value that specifies the elevation level of the token. -     /// - TokenElevationType, - - /// -     /// The buffer receives a TOKEN_LINKED_TOKEN structure that contains a handle to another token that is linked to this token. -     /// - TokenLinkedToken, - - /// -     /// The buffer receives a TOKEN_ELEVATION structure that specifies whether the token is elevated. -     /// - TokenElevation, - - /// -     /// The buffer receives a DWORD value that is nonzero if the token has ever been filtered. -     /// - TokenHasRestrictions, - - /// -     /// The buffer receives a TOKEN_ACCESS_INFORMATION structure that specifies security information contained in the token. -     /// - TokenAccessInformation, - - /// -     /// The buffer receives a DWORD value that is nonzero if virtualization is allowed for the token. -     /// - TokenVirtualizationAllowed, - - /// -     /// The buffer receives a DWORD value that is nonzero if virtualization is enabled for the token. -     /// - TokenVirtualizationEnabled, - - /// -     /// The buffer receives a TOKEN_MANDATORY_LABEL structure that specifies the token's integrity level. -     /// - TokenIntegrityLevel, - - /// -     /// The buffer receives a DWORD value that is nonzero if the token has the UIAccess flag set. -     /// - TokenUIAccess, - - /// -     /// The buffer receives a TOKEN_MANDATORY_POLICY structure that specifies the token's mandatory integrity policy. -     /// - TokenMandatoryPolicy, - - /// -     /// The buffer receives the token's logon security identifier (SID). -     /// - TokenLogonSid, - - /// -     /// The maximum value for this enumeration -     /// - MaxTokenInfoClass - } - [StructLayout(LayoutKind.Sequential)] - public struct QUOTA_LIMITS - { - UInt32 PagedPoolLimit; - UInt32 NonPagedPoolLimit; - UInt32 MinimumWorkingSetSize; - UInt32 MaximumWorkingSetSize; - UInt32 PagefileLimit; - Int64 TimeLimit; - } - - [StructLayout(LayoutKind.Sequential)] - public struct LSA_STRING - { - public UInt16 Length; - public UInt16 MaximumLength; - public /*PCHAR*/ IntPtr Buffer; - } - - - [DllImport("secur32.dll", SetLastError = true)] - public static extern WinStatusCodes LsaLogonUser( - [In] IntPtr LsaHandle, - [In] ref LSA_STRING OriginName, - [In] SecurityLogonType LogonType, - [In] UInt32 AuthenticationPackage, - [In] IntPtr AuthenticationInformation, - [In] UInt32 AuthenticationInformationLength, - [In] /*PTOKEN_GROUPS*/ IntPtr LocalGroups, - [In] ref TOKEN_SOURCE SourceContext, - [Out] /*PVOID*/ out IntPtr ProfileBuffer, - [Out] out UInt32 ProfileBufferLength, - [Out] out Int64 LogonId, - [Out] out IntPtr Token, - [Out] out QUOTA_LIMITS Quotas, - [Out] out WinStatusCodes SubStatus - ); - - [DllImport("secur32.dll", SetLastError = true)] - public static extern WinStatusCodes LsaRegisterLogonProcess( - IntPtr LogonProcessName, - out IntPtr LsaHandle, - out ulong SecurityMode - ); - - [DllImport("secur32.dll", SetLastError = false)] - public static extern WinStatusCodes LsaLookupAuthenticationPackage([In] IntPtr LsaHandle, [In] ref LSA_STRING PackageName, [Out] out UInt32 AuthenticationPackage); - - [DllImport("secur32.dll", CharSet = CharSet.Auto, SetLastError = true)] - [ResourceExposure(ResourceScope.None)] - internal static extern int LsaConnectUntrusted( - [In, Out] ref SafeLsaLogonProcessHandle LsaHandle); - - [DllImport("secur32.dll", SetLastError = false)] - public static extern WinStatusCodes LsaConnectUntrusted([Out] out IntPtr LsaHandle); - - [System.Security.SecurityCritical] // auto-generated - internal sealed class SafeLsaLogonProcessHandle : SafeHandleZeroOrMinusOneIsInvalid - { - private SafeLsaLogonProcessHandle() : base(true) { } - - // 0 is an Invalid Handle - internal SafeLsaLogonProcessHandle(IntPtr handle) : base(true) - { - SetHandle(handle); - } - - internal static SafeLsaLogonProcessHandle InvalidHandle - { - get { return new SafeLsaLogonProcessHandle(IntPtr.Zero); } - } - - [System.Security.SecurityCritical] - override protected bool ReleaseHandle() - { - // LsaDeregisterLogonProcess returns an NTSTATUS - return LsaDeregisterLogonProcess(handle) >= 0; - } - } - - [DllImport("secur32.dll", SetLastError = true)] - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] - [ResourceExposure(ResourceScope.None)] - internal static extern int LsaDeregisterLogonProcess(IntPtr handle); - - - public static void CreateNewSession() - { - var kli = new SECUR32.KERB_INTERACTIVE_LOGON() - { - MessageType = SECUR32.KERB_LOGON_SUBMIT_TYPE.KerbInteractiveLogon, - UserName = "", - Password = "" - }; - IntPtr pluid; - IntPtr lsaHan; - uint authPackID; - IntPtr kerbLogInfo; - SECUR32.LSA_STRING logonProc = new SECUR32.LSA_STRING() - { - Buffer = Marshal.StringToHGlobalAuto("InstaLogon"), - Length = (ushort)Marshal.SizeOf(Marshal.StringToHGlobalAuto("InstaLogon")), - MaximumLength = (ushort)Marshal.SizeOf(Marshal.StringToHGlobalAuto("InstaLogon")) - }; - SECUR32.LSA_STRING originName = new SECUR32.LSA_STRING() - { - Buffer = Marshal.StringToHGlobalAuto("InstaLogon"), - Length = (ushort)Marshal.SizeOf(Marshal.StringToHGlobalAuto("InstaLogon")), - MaximumLength = (ushort)Marshal.SizeOf(Marshal.StringToHGlobalAuto("InstaLogon")) - }; - SECUR32.LSA_STRING authPackage = new SECUR32.LSA_STRING() - { - Buffer = Marshal.StringToHGlobalAuto("MICROSOFT_KERBEROS_NAME_A"), - Length = (ushort)Marshal.SizeOf(Marshal.StringToHGlobalAuto("MICROSOFT_KERBEROS_NAME_A")), - MaximumLength = (ushort)Marshal.SizeOf(Marshal.StringToHGlobalAuto("MICROSOFT_KERBEROS_NAME_A")) - }; - IntPtr hLogonProc = Marshal.AllocHGlobal(Marshal.SizeOf(logonProc)); - Marshal.StructureToPtr(logonProc, hLogonProc, false); - ADVAPI32.AllocateLocallyUniqueId(out pluid); - LsaConnectUntrusted(out lsaHan); - //SECUR32.LsaRegisterLogonProcess(hLogonProc, out lsaHan, out secMode); - SECUR32.LsaLookupAuthenticationPackage(lsaHan, ref authPackage, out authPackID); - - kerbLogInfo = Marshal.AllocHGlobal(Marshal.SizeOf(kli)); - Marshal.StructureToPtr(kli, kerbLogInfo, false); - - var ts = new SECUR32.TOKEN_SOURCE("Insta"); - IntPtr profBuf; - uint profBufLen; - long logonID; - IntPtr logonToken; - SECUR32.QUOTA_LIMITS quotas; - SECUR32.WinStatusCodes subStatus; - SECUR32.LsaLogonUser(lsaHan, ref originName, SECUR32.SecurityLogonType.Interactive, authPackID, kerbLogInfo, (uint)Marshal.SizeOf(kerbLogInfo), IntPtr.Zero, ref ts, out profBuf, out profBufLen, out logonID, out logonToken, out quotas, out subStatus); - } -} \ No newline at end of file diff --git a/Remotely_Library/Win32/User32.cs b/Remotely_Library/Win32/User32.cs deleted file mode 100644 index b0a6baf1..00000000 --- a/Remotely_Library/Win32/User32.cs +++ /dev/null @@ -1,1252 +0,0 @@ -using Microsoft.Win32.SafeHandles; -using System; -using System.Linq; -using System.Runtime.ConstrainedExecution; -using System.Runtime.InteropServices; -using System.Text; - -namespace Remotely_Library.Win32 -{ - public static class User32 - { - #region Constants - public const Int32 CURSOR_SHOWING = 0x00000001; - public const uint MOUSEEVENTF_ABSOLUTE = 0x8000; - public const int MOUSEEVENTF_LEFTDOWN = 0x02; - public const int MOUSEEVENTF_LEFTUP = 0x04; - public const int MOUSEEVENTF_RIGHTDOWN = 0x08; - public const int MOUSEEVENTF_RIGHTUP = 0x10; - public const int MOUSEEVENTF_MOVE = 0x0001; - public const uint KEYEVENTF_EXTENDEDKEY = 0x0001; - public const uint KEYEVENTF_KEYUP = 0x0002; - - public const int SPIF_SENDWININICHANGE = 0x02; - public const int SPI_SETDESKWALLPAPER = 20; - public const int SPIF_UPDATEINIFILE = 1; - public const int SPIF_SENDCHANGE = 2; - - public static readonly int SPI_GETDESKWALLPAPER = 0x73; - public static readonly int MAX_PATH = 260; - #endregion - - #region Enums - [Flags] - public enum MouseEventFlags : uint - { - LEFTDOWN = 0x00000002, - LEFTUP = 0x00000004, - MIDDLEDOWN = 0x00000020, - MIDDLEUP = 0x00000040, - MOVE = 0x00000001, - ABSOLUTE = 0x00008000, - RIGHTDOWN = 0x00000008, - RIGHTUP = 0x00000010, - WHEEL = 0x00000800, - XDOWN = 0x00000080, - XUP = 0x00000100 - } - [Flags] - public enum MOUSEEVENTF : uint - { - ABSOLUTE = 0x8000, - HWHEEL = 0x01000, - MOVE = 0x0001, - MOVE_NOCOALESCE = 0x2000, - LEFTDOWN = 0x0002, - LEFTUP = 0x0004, - RIGHTDOWN = 0x0008, - RIGHTUP = 0x0010, - MIDDLEDOWN = 0x0020, - MIDDLEUP = 0x0040, - VIRTUALDESK = 0x4000, - WHEEL = 0x0800, - XDOWN = 0x0080, - XUP = 0x0100 - } - public enum MonitorState - { - MonitorStateOn = -1, - MonitorStateOff = 2, - MonitorStateStandBy = 1 - } - [Flags] - public enum KEYEVENTF : uint - { - EXTENDEDKEY = 0x0001, - KEYUP = 0x0002, - SCANCODE = 0x0008, - UNICODE = 0x0004 - } - - public enum VirtualKey : short - { - /// -         ///Left mouse button -         /// - LBUTTON = 0x01, - /// -         ///Right mouse button -         /// - RBUTTON = 0x02, - /// -         ///Control-break processing -         /// - CANCEL = 0x03, - /// -         ///Middle mouse button (three-button mouse) -         /// - MBUTTON = 0x04, - /// -         ///Windows 2000/XP: X1 mouse button -         /// - XBUTTON1 = 0x05, - /// -         ///Windows 2000/XP: X2 mouse button -         /// - XBUTTON2 = 0x06, - /// -         ///BACKSPACE key -         /// - BACK = 0x08, - /// -         ///TAB key -         /// - TAB = 0x09, - /// -         ///CLEAR key -         /// - CLEAR = 0x0C, - /// -         ///ENTER key -         /// - RETURN = 0x0D, - /// -         ///SHIFT key -         /// - SHIFT = 0x10, - /// -         ///CTRL key -         /// - CONTROL = 0x11, - /// -         ///ALT key -         /// - MENU = 0x12, - /// -         ///PAUSE key -         /// - PAUSE = 0x13, - /// -         ///CAPS LOCK key -         /// - CAPITAL = 0x14, - /// -         ///Input Method Editor (IME) Kana mode -         /// - KANA = 0x15, - /// -         ///IME Hangul mode -         /// - HANGUL = 0x15, - /// -         ///IME Junja mode -         /// - JUNJA = 0x17, - /// -         ///IME final mode -         /// - FINAL = 0x18, - /// -         ///IME Hanja mode -         /// - HANJA = 0x19, - /// -         ///IME Kanji mode -         /// - KANJI = 0x19, - /// -         ///ESC key -         /// - ESCAPE = 0x1B, - /// -         ///IME convert -         /// - CONVERT = 0x1C, - /// -         ///IME nonconvert -         /// - NONCONVERT = 0x1D, - /// -         ///IME accept -         /// - ACCEPT = 0x1E, - /// -         ///IME mode change request -         /// - MODECHANGE = 0x1F, - /// -         ///SPACEBAR -         /// - SPACE = 0x20, - /// -         ///PAGE UP key -         /// - PRIOR = 0x21, - /// -         ///PAGE DOWN key -         /// - NEXT = 0x22, - /// -         ///END key -         /// - END = 0x23, - /// -         ///HOME key -         /// - HOME = 0x24, - /// -         ///LEFT ARROW key -         /// - LEFT = 0x25, - /// -         ///UP ARROW key -         /// - UP = 0x26, - /// -         ///RIGHT ARROW key -         /// - RIGHT = 0x27, - /// -         ///DOWN ARROW key -         /// - DOWN = 0x28, - /// -         ///SELECT key -         /// - SELECT = 0x29, - /// -         ///PRINT key -         /// - PRINT = 0x2A, - /// -         ///EXECUTE key -         /// - EXECUTE = 0x2B, - /// -         ///PRINT SCREEN key -         /// - SNAPSHOT = 0x2C, - /// -         ///INS key -         /// - INSERT = 0x2D, - /// -         ///DEL key -         /// - DELETE = 0x2E, - /// -         ///HELP key -         /// - HELP = 0x2F, - /// -         ///0 key -         /// - KEY_0 = 0x30, - /// -         ///1 key -         /// - KEY_1 = 0x31, - /// -         ///2 key -         /// - KEY_2 = 0x32, - /// -         ///3 key -         /// - KEY_3 = 0x33, - /// -         ///4 key -         /// - KEY_4 = 0x34, - /// -         ///5 key -         /// - KEY_5 = 0x35, - /// -         ///6 key -         /// - KEY_6 = 0x36, - /// -         ///7 key -         /// - KEY_7 = 0x37, - /// -         ///8 key -         /// - KEY_8 = 0x38, - /// -         ///9 key -         /// - KEY_9 = 0x39, - /// -         ///A key -         /// - KEY_A = 0x41, - /// -         ///B key -         /// - KEY_B = 0x42, - /// -         ///C key -         /// - KEY_C = 0x43, - /// -         ///D key -         /// - KEY_D = 0x44, - /// -         ///E key -         /// - KEY_E = 0x45, - /// -         ///F key -         /// - KEY_F = 0x46, - /// -         ///G key -         /// - KEY_G = 0x47, - /// -         ///H key -         /// - KEY_H = 0x48, - /// -         ///I key -         /// - KEY_I = 0x49, - /// -         ///J key -         /// - KEY_J = 0x4A, - /// -         ///K key -         /// - KEY_K = 0x4B, - /// -         ///L key -         /// - KEY_L = 0x4C, - /// -         ///M key -         /// - KEY_M = 0x4D, - /// -         ///N key -         /// - KEY_N = 0x4E, - /// -         ///O key -         /// - KEY_O = 0x4F, - /// -         ///P key -         /// - KEY_P = 0x50, - /// -         ///Q key -         /// - KEY_Q = 0x51, - /// -         ///R key -         /// - KEY_R = 0x52, - /// -         ///S key -         /// - KEY_S = 0x53, - /// -         ///T key -         /// - KEY_T = 0x54, - /// -         ///U key -         /// - KEY_U = 0x55, - /// -         ///V key -         /// - KEY_V = 0x56, - /// -         ///W key -         /// - KEY_W = 0x57, - /// -         ///X key -         /// - KEY_X = 0x58, - /// -         ///Y key -         /// - KEY_Y = 0x59, - /// -         ///Z key -         /// - KEY_Z = 0x5A, - /// -         ///Left Windows key (Microsoft Natural keyboard) -         /// - LWIN = 0x5B, - /// -         ///Right Windows key (Natural keyboard) -         /// - RWIN = 0x5C, - /// -         ///Applications key (Natural keyboard) -         /// - APPS = 0x5D, - /// -         ///Computer Sleep key -         /// - SLEEP = 0x5F, - /// -         ///Numeric keypad 0 key -         /// - NUMPAD0 = 0x60, - /// -         ///Numeric keypad 1 key -         /// - NUMPAD1 = 0x61, - /// -         ///Numeric keypad 2 key -         /// - NUMPAD2 = 0x62, - /// -         ///Numeric keypad 3 key -         /// - NUMPAD3 = 0x63, - /// -         ///Numeric keypad 4 key -         /// - NUMPAD4 = 0x64, - /// -         ///Numeric keypad 5 key -         /// - NUMPAD5 = 0x65, - /// -         ///Numeric keypad 6 key -         /// - NUMPAD6 = 0x66, - /// -         ///Numeric keypad 7 key -         /// - NUMPAD7 = 0x67, - /// -         ///Numeric keypad 8 key -         /// - NUMPAD8 = 0x68, - /// -         ///Numeric keypad 9 key -         /// - NUMPAD9 = 0x69, - /// -         ///Multiply key -         /// - MULTIPLY = 0x6A, - /// -         ///Add key -         /// - ADD = 0x6B, - /// -         ///Separator key -         /// - SEPARATOR = 0x6C, - /// -         ///Subtract key -         /// - SUBTRACT = 0x6D, - /// -         ///Decimal key -         /// - DECIMAL = 0x6E, - /// -         ///Divide key -         /// - DIVIDE = 0x6F, - /// -         ///F1 key -         /// - F1 = 0x70, - /// -         ///F2 key -         /// - F2 = 0x71, - /// -         ///F3 key -         /// - F3 = 0x72, - /// -         ///F4 key -         /// - F4 = 0x73, - /// -         ///F5 key -         /// - F5 = 0x74, - /// -         ///F6 key -         /// - F6 = 0x75, - /// -         ///F7 key -         /// - F7 = 0x76, - /// -         ///F8 key -         /// - F8 = 0x77, - /// -         ///F9 key -         /// - F9 = 0x78, - /// -         ///F10 key -         /// - F10 = 0x79, - /// -         ///F11 key -         /// - F11 = 0x7A, - /// -         ///F12 key -         /// - F12 = 0x7B, - /// -         ///F13 key -         /// - F13 = 0x7C, - /// -         ///F14 key -         /// - F14 = 0x7D, - /// -         ///F15 key -         /// - F15 = 0x7E, - /// -         ///F16 key -         /// - F16 = 0x7F, - /// -         ///F17 key   -         /// - F17 = 0x80, - /// -         ///F18 key   -         /// - F18 = 0x81, - /// -         ///F19 key   -         /// - F19 = 0x82, - /// -         ///F20 key   -         /// - F20 = 0x83, - /// -         ///F21 key   -         /// - F21 = 0x84, - /// -         ///F22 key, (PPC only) Key used to lock device. -         /// - F22 = 0x85, - /// -         ///F23 key   -         /// - F23 = 0x86, - /// -         ///F24 key   -         /// - F24 = 0x87, - /// -         ///NUM LOCK key -         /// - NUMLOCK = 0x90, - /// -         ///SCROLL LOCK key -         /// - SCROLL = 0x91, - /// -         ///Left SHIFT key -         /// - LSHIFT = 0xA0, - /// -         ///Right SHIFT key -         /// - RSHIFT = 0xA1, - /// -         ///Left CONTROL key -         /// - LCONTROL = 0xA2, - /// -         ///Right CONTROL key -         /// - RCONTROL = 0xA3, - /// -         ///Left MENU key -         /// - LMENU = 0xA4, - /// -         ///Right MENU key -         /// - RMENU = 0xA5, - /// -         ///Windows 2000/XP: Browser Back key -         /// - BROWSER_BACK = 0xA6, - /// -         ///Windows 2000/XP: Browser Forward key -         /// - BROWSER_FORWARD = 0xA7, - /// -         ///Windows 2000/XP: Browser Refresh key -         /// - BROWSER_REFRESH = 0xA8, - /// -         ///Windows 2000/XP: Browser Stop key -         /// - BROWSER_STOP = 0xA9, - /// -         ///Windows 2000/XP: Browser Search key -         /// - BROWSER_SEARCH = 0xAA, - /// -         ///Windows 2000/XP: Browser Favorites key -         /// - BROWSER_FAVORITES = 0xAB, - /// -         ///Windows 2000/XP: Browser Start and Home key -         /// - BROWSER_HOME = 0xAC, - /// -         ///Windows 2000/XP: Volume Mute key -         /// - VOLUME_MUTE = 0xAD, - /// -         ///Windows 2000/XP: Volume Down key -         /// - VOLUME_DOWN = 0xAE, - /// -         ///Windows 2000/XP: Volume Up key -         /// - VOLUME_UP = 0xAF, - /// -         ///Windows 2000/XP: Next Track key -         /// - MEDIA_NEXT_TRACK = 0xB0, - /// -         ///Windows 2000/XP: Previous Track key -         /// - MEDIA_PREV_TRACK = 0xB1, - /// -         ///Windows 2000/XP: Stop Media key -         /// - MEDIA_STOP = 0xB2, - /// -         ///Windows 2000/XP: Play/Pause Media key -         /// - MEDIA_PLAY_PAUSE = 0xB3, - /// -         ///Windows 2000/XP: Start Mail key -         /// - LAUNCH_MAIL = 0xB4, - /// -         ///Windows 2000/XP: Select Media key -         /// - LAUNCH_MEDIA_SELECT = 0xB5, - /// -         ///Windows 2000/XP: Start Application 1 key -         /// - LAUNCH_APP1 = 0xB6, - /// -         ///Windows 2000/XP: Start Application 2 key -         /// - LAUNCH_APP2 = 0xB7, - /// -         ///Used for miscellaneous characters; it can vary by keyboard. -         /// - OEM_1 = 0xBA, - /// -         ///Windows 2000/XP: For any country/region, the '+' key -         /// - OEM_PLUS = 0xBB, - /// -         ///Windows 2000/XP: For any country/region, the ',' key -         /// - OEM_COMMA = 0xBC, - /// -         ///Windows 2000/XP: For any country/region, the '-' key -         /// - OEM_MINUS = 0xBD, - /// -         ///Windows 2000/XP: For any country/region, the '.' key -         /// - OEM_PERIOD = 0xBE, - /// -         ///Used for miscellaneous characters; it can vary by keyboard. -         /// - OEM_2 = 0xBF, - /// -         ///Used for miscellaneous characters; it can vary by keyboard. -         /// - OEM_3 = 0xC0, - /// -         ///Used for miscellaneous characters; it can vary by keyboard. -         /// - OEM_4 = 0xDB, - /// -         ///Used for miscellaneous characters; it can vary by keyboard. -         /// - OEM_5 = 0xDC, - /// -         ///Used for miscellaneous characters; it can vary by keyboard. -         /// - OEM_6 = 0xDD, - /// -         ///Used for miscellaneous characters; it can vary by keyboard. -         /// - OEM_7 = 0xDE, - /// -         ///Used for miscellaneous characters; it can vary by keyboard. -         /// - OEM_8 = 0xDF, - /// -         ///Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard -         /// - OEM_102 = 0xE2, - /// -         ///Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key -         /// - PROCESSKEY = 0xE5, - /// -         ///Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. -         ///The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, -         ///see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP -         /// - PACKET = 0xE7, - /// -         ///Attn key -         /// - ATTN = 0xF6, - /// -         ///CrSel key -         /// - CRSEL = 0xF7, - /// -         ///ExSel key -         /// - EXSEL = 0xF8, - /// -         ///Erase EOF key -         /// - EREOF = 0xF9, - /// -         ///Play key -         /// - PLAY = 0xFA, - /// -         ///Zoom key -         /// - ZOOM = 0xFB, - /// -         ///Reserved -         /// - NONAME = 0xFC, - /// -         ///PA1 key -         /// - PA1 = 0xFD, - /// -         ///Clear key -         /// - OEM_CLEAR = 0xFE - } - public enum ScanCodeShort : short - { - LBUTTON = 0, - RBUTTON = 0, - CANCEL = 70, - MBUTTON = 0, - XBUTTON1 = 0, - XBUTTON2 = 0, - BACK = 14, - TAB = 15, - CLEAR = 76, - RETURN = 28, - SHIFT = 42, - CONTROL = 29, - MENU = 56, - PAUSE = 0, - CAPITAL = 58, - KANA = 0, - HANGUL = 0, - JUNJA = 0, - FINAL = 0, - HANJA = 0, - KANJI = 0, - ESCAPE = 1, - CONVERT = 0, - NONCONVERT = 0, - ACCEPT = 0, - MODECHANGE = 0, - SPACE = 57, - PRIOR = 73, - NEXT = 81, - END = 79, - HOME = 71, - LEFT = 75, - UP = 72, - RIGHT = 77, - DOWN = 80, - SELECT = 0, - PRINT = 0, - EXECUTE = 0, - SNAPSHOT = 84, - INSERT = 82, - DELETE = 83, - HELP = 99, - KEY_0 = 11, - KEY_1 = 2, - KEY_2 = 3, - KEY_3 = 4, - KEY_4 = 5, - KEY_5 = 6, - KEY_6 = 7, - KEY_7 = 8, - KEY_8 = 9, - KEY_9 = 10, - KEY_A = 30, - KEY_B = 48, - KEY_C = 46, - KEY_D = 32, - KEY_E = 18, - KEY_F = 33, - KEY_G = 34, - KEY_H = 35, - KEY_I = 23, - KEY_J = 36, - KEY_K = 37, - KEY_L = 38, - KEY_M = 50, - KEY_N = 49, - KEY_O = 24, - KEY_P = 25, - KEY_Q = 16, - KEY_R = 19, - KEY_S = 31, - KEY_T = 20, - KEY_U = 22, - KEY_V = 47, - KEY_W = 17, - KEY_X = 45, - KEY_Y = 21, - KEY_Z = 44, - LWIN = 91, - RWIN = 92, - APPS = 93, - SLEEP = 95, - NUMPAD0 = 82, - NUMPAD1 = 79, - NUMPAD2 = 80, - NUMPAD3 = 81, - NUMPAD4 = 75, - NUMPAD5 = 76, - NUMPAD6 = 77, - NUMPAD7 = 71, - NUMPAD8 = 72, - NUMPAD9 = 73, - MULTIPLY = 55, - ADD = 78, - SEPARATOR = 0, - SUBTRACT = 74, - DECIMAL = 83, - DIVIDE = 53, - F1 = 59, - F2 = 60, - F3 = 61, - F4 = 62, - F5 = 63, - F6 = 64, - F7 = 65, - F8 = 66, - F9 = 67, - F10 = 68, - F11 = 87, - F12 = 88, - F13 = 100, - F14 = 101, - F15 = 102, - F16 = 103, - F17 = 104, - F18 = 105, - F19 = 106, - F20 = 107, - F21 = 108, - F22 = 109, - F23 = 110, - F24 = 118, - NUMLOCK = 69, - SCROLL = 70, - LSHIFT = 42, - RSHIFT = 54, - LCONTROL = 29, - RCONTROL = 29, - LMENU = 56, - RMENU = 56, - BROWSER_BACK = 106, - BROWSER_FORWARD = 105, - BROWSER_REFRESH = 103, - BROWSER_STOP = 104, - BROWSER_SEARCH = 101, - BROWSER_FAVORITES = 102, - BROWSER_HOME = 50, - VOLUME_MUTE = 32, - VOLUME_DOWN = 46, - VOLUME_UP = 48, - MEDIA_NEXT_TRACK = 25, - MEDIA_PREV_TRACK = 16, - MEDIA_STOP = 36, - MEDIA_PLAY_PAUSE = 34, - LAUNCH_MAIL = 108, - LAUNCH_MEDIA_SELECT = 109, - LAUNCH_APP1 = 107, - LAUNCH_APP2 = 33, - OEM_1 = 39, - OEM_PLUS = 13, - OEM_COMMA = 51, - OEM_MINUS = 12, - OEM_PERIOD = 52, - OEM_2 = 53, - OEM_3 = 41, - OEM_4 = 26, - OEM_5 = 43, - OEM_6 = 27, - OEM_7 = 40, - OEM_8 = 0, - OEM_102 = 86, - PROCESSKEY = 0, - PACKET = 0, - ATTN = 0, - CRSEL = 0, - EXSEL = 0, - EREOF = 93, - PLAY = 0, - ZOOM = 98, - NONAME = 0, - PA1 = 0, - OEM_CLEAR = 0, - } - [Flags] - public enum ACCESS_MASK : uint - { - DELETE = 0x00010000, - READ_CONTROL = 0x00020000, - WRITE_DAC = 0x00040000, - WRITE_OWNER = 0x00080000, - SYNCHRONIZE = 0x00100000, - - STANDARD_RIGHTS_REQUIRED = 0x000F0000, - - STANDARD_RIGHTS_READ = 0x00020000, - STANDARD_RIGHTS_WRITE = 0x00020000, - STANDARD_RIGHTS_EXECUTE = 0x00020000, - - STANDARD_RIGHTS_ALL = 0x001F0000, - - SPECIFIC_RIGHTS_ALL = 0x0000FFFF, - - ACCESS_SYSTEM_SECURITY = 0x01000000, - - MAXIMUM_ALLOWED = 0x02000000, - - GENERIC_READ = 0x80000000, - GENERIC_WRITE = 0x40000000, - GENERIC_EXECUTE = 0x20000000, - GENERIC_ALL = 0x10000000, - - DESKTOP_READOBJECTS = 0x00000001, - DESKTOP_CREATEWINDOW = 0x00000002, - DESKTOP_CREATEMENU = 0x00000004, - DESKTOP_HOOKCONTROL = 0x00000008, - DESKTOP_JOURNALRECORD = 0x00000010, - DESKTOP_JOURNALPLAYBACK = 0x00000020, - DESKTOP_ENUMERATE = 0x00000040, - DESKTOP_WRITEOBJECTS = 0x00000080, - DESKTOP_SWITCHDESKTOP = 0x00000100, - - WINSTA_ENUMDESKTOPS = 0x00000001, - WINSTA_READATTRIBUTES = 0x00000002, - WINSTA_ACCESSCLIPBOARD = 0x00000004, - WINSTA_CREATEDESKTOP = 0x00000008, - WINSTA_WRITEATTRIBUTES = 0x00000010, - WINSTA_ACCESSGLOBALATOMS = 0x00000020, - WINSTA_EXITWINDOWS = 0x00000040, - WINSTA_ENUMERATE = 0x00000100, - WINSTA_READSCREEN = 0x00000200, - - WINSTA_ALL_ACCESS = 0x0000037F - } - public enum InputType : uint - { - MOUSE = 0, - KEYBOARD = 1, - HARDWARE = 2 - } - #endregion - - #region Structs - [StructLayout(LayoutKind.Sequential)] - public struct ICONINFO - { - public bool fIcon; - public Int32 xHotspot; - public Int32 yHotspot; - public IntPtr hbmMask; - public IntPtr hbmColor; - } - - [StructLayout(LayoutKind.Sequential)] - public struct POINT - { - public Int32 x; - public Int32 y; - } - - [StructLayout(LayoutKind.Sequential)] - public struct CursorInfo - { - public Int32 cbSize; - public Int32 flags; - public IntPtr hCursor; - public POINT ptScreenPos; - } - [StructLayout(LayoutKind.Sequential)] - public struct INPUT - { - public InputType type; - public InputUnion U; - public static int Size - { - get { return Marshal.SizeOf(typeof(INPUT)); } - } - } - - [StructLayout(LayoutKind.Explicit)] - public struct InputUnion - { - [FieldOffset(0)] - public MOUSEINPUT mi; - [FieldOffset(0)] - public KEYBDINPUT ki; - [FieldOffset(0)] - public HARDWAREINPUT hi; - } - [StructLayout(LayoutKind.Sequential)] - public struct MOUSEINPUT - { - public int dx; - public int dy; - public int mouseData; - public MOUSEEVENTF dwFlags; - public uint time; - public UIntPtr dwExtraInfo; - } - [StructLayout(LayoutKind.Sequential)] - public struct KEYBDINPUT - { - public VirtualKey wVk; - public ScanCodeShort wScan; - public KEYEVENTF dwFlags; - public int time; - public UIntPtr dwExtraInfo; - } - [StructLayout(LayoutKind.Sequential)] - public struct HARDWAREINPUT - { - public int uMsg; - public short wParamL; - public short wParamH; - } - #endregion - - #region DLL Imports - [DllImport("user32.dll")] - public static extern bool GetCursorInfo(out CursorInfo pci); - [DllImport("user32.dll", SetLastError = false)] - public static extern IntPtr GetDesktopWindow(); - - [DllImport("user32.dll")] - public static extern IntPtr GetCursor(); - - [DllImport("user32.dll")] - public static extern IntPtr CopyIcon(IntPtr hIcon); - - [DllImport("user32.dll")] - public static extern bool DrawIcon(IntPtr hdc, int x, int y, IntPtr hIcon); - - [DllImport("user32.dll")] - public static extern bool GetIconInfo(IntPtr hIcon, out ICONINFO piconinfo); - - [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] - public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, UIntPtr dwExtraInfo); - - [DllImport("user32.dll")] - public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo); - - [DllImport("user32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool GetCursorPos(out System.Drawing.Point lpPoint); - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool SetCursorPos(int x, int y); - - [DllImport("user32.dll")] - public static extern IntPtr SetCursor(IntPtr hcursor); - - [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] - static extern IntPtr LoadImage(IntPtr hinst, string lpszName, uint uType, - int cxDesired, int cyDesired, uint fuLoad); - - [DllImport("user32.dll")] - public static extern IntPtr CreateCursor(IntPtr hInst, int xHotSpot, int yHotSpot, - int nWidth, int nHeight, byte[] pvANDPlane, byte[] pvXORPlane); - - [DllImport("user32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool PrintWindow(IntPtr hwnd, IntPtr hDC, uint nFlags); - - [DllImport("user32.dll", SetLastError = true)] - public static extern bool SwitchDesktop(IntPtr hDesktop); - - public delegate bool EnumDesktopsDelegate(string desktop, IntPtr lParam); - - [DllImport("user32.dll")] - public static extern bool EnumDesktopsA(IntPtr hwinsta, EnumDesktopsDelegate lpEnumFunc, IntPtr lParam); - - [DllImport("user32.dll", SetLastError = true)] - public static extern IntPtr OpenInputDesktop(uint dwFlags, bool fInherit, ACCESS_MASK dwDesiredAccess); - - public delegate bool EnumWindowStationsDelegate(string windowsStation, IntPtr lParam); - - [DllImport("user32.dll")] - public static extern bool EnumWindowStations(EnumWindowStationsDelegate lpEnumFunc, IntPtr lParam); - - [DllImport("user32.dll")] - public static extern IntPtr GetShellWindow(); - - public sealed class SafeWindowStationHandle : SafeHandleZeroOrMinusOneIsInvalid - { - public SafeWindowStationHandle() - : base(true) - { - } - - protected override bool ReleaseHandle() - { - return CloseWindowStation(handle); - - } - } - - [return: MarshalAs(UnmanagedType.Bool)] - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] - [DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool CloseWindowStation(IntPtr hWinsta); - - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] - [DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)] - public static extern SafeWindowStationHandle OpenWindowStation([MarshalAs(UnmanagedType.LPTStr)] string lpszWinSta, [MarshalAs(UnmanagedType.Bool)] bool fInherit, ACCESS_MASK dwDesiredAccess); - - [DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)] - public static extern IntPtr OpenWindowStationW([MarshalAs(UnmanagedType.LPTStr)] string lpszWinSta, [MarshalAs(UnmanagedType.Bool)] bool fInherit, ACCESS_MASK dwDesiredAccess); - - [DllImport("user32.dll", SetLastError = true)] - public static extern bool SetProcessWindowStation(IntPtr hWinSta); - - [DllImport("user32.dll")] - public static extern IntPtr GetWindowDC(IntPtr hWnd); - - public delegate bool EnumWindowsProc(IntPtr hwnd, IntPtr lParam); - - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool EnumChildWindows(IntPtr hwndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam); - - [DllImport("User32.dll")] - public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC); - - [DllImport("User32.dll")] - public static extern IntPtr GetProcessWindowStation(); - - [DllImport("user32.dll", SetLastError = true)] - public static extern bool SetThreadDesktop(IntPtr hDesktop); - - [DllImport("user32.dll")] - public static extern IntPtr OpenDesktop(string lpszDesktop, uint dwFlags, bool fInherit, ACCESS_MASK dwDesiredAccess); - [DllImport("user32.dll", SetLastError = true)] - public static extern bool CloseDesktop(IntPtr hDesktop); - - public delegate bool EnumDesktopWindowsDelegate(IntPtr hWnd, int lParam); - - [DllImport("user32.dll")] - public static extern bool EnumDesktopWindows(IntPtr hDesktop, EnumDesktopWindowsDelegate lpfn, IntPtr lParam); - - [DllImport("user32.dll")] - public static extern IntPtr GetDC(IntPtr hWnd); - - [DllImport("user32.dll", SetLastError = true)] - public static extern IntPtr SetActiveWindow(IntPtr hWnd); - - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool SetForegroundWindow(IntPtr hWnd); - - [DllImport("user32.dll")] - public static extern uint SendInput(uint nInputs, [MarshalAs(UnmanagedType.LPArray), In] INPUT[] pInputs, int cbSize); - [DllImport("user32.dll", SetLastError = false)] - public static extern UIntPtr GetMessageExtraInfo(); - [DllImport("sas.dll")] - public static extern void SendSAS(bool AsUser); - [DllImport("user32.dll")] - public static extern bool OpenClipboard(IntPtr hWnd); - [DllImport("user32.dll")] - public static extern bool EmptyClipboard(); - [DllImport("user32.dll")] - public static extern bool CloseClipboard(); - [DllImport("user32.dll")] - public static extern IntPtr SetClipboardData(int Format, IntPtr hMem); - - [DllImport("user32.dll", EntryPoint = "ShowWindow", SetLastError = true)] - public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); - /* - * SystemParametersInfo( - * SPI_SETDESKWALLPAPER, 0, "filename.bmp", - * SPIF_UPDATEINIFILE | SPIF_SENDCHANGE); - */ - - [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] - public static extern int SystemParametersInfo( - int uAction, int uParam, string lpvParam, int fuWinIni); - - [DllImport("user32.dll", SetLastError = true)] - public static extern bool LockWorkStation(); - - [DllImport("user32.dll")] - public static extern short VkKeyScan(char ch); - - [DllImport("user32.dll")] - public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam); - - #endregion - } -} diff --git a/Remotely_Library/Win32/WTSAPI32.cs b/Remotely_Library/Win32/WTSAPI32.cs deleted file mode 100644 index e10bbe7c..00000000 --- a/Remotely_Library/Win32/WTSAPI32.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Remotely_Library.Win32 -{ - public static class WTSAPI32 - { - [StructLayout(LayoutKind.Sequential)] - public struct WTS_SESSION_INFO - { - public Int32 SessionID; - [MarshalAs(UnmanagedType.LPStr)] - public String pWinStationName; - public WTS_CONNECTSTATE_CLASS State; - } - public enum WTS_CONNECTSTATE_CLASS - { - WTSActive, - WTSConnected, - WTSConnectQuery, - WTSShadow, - WTSDisconnected, - WTSIdle, - WTSListen, - WTSReset, - WTSDown, - WTSInit - } - public static IntPtr WTS_CURRENT_SERVER_HANDLE = IntPtr.Zero; - - [DllImport("wtsapi32.dll", SetLastError = true)] - static extern IntPtr WTSOpenServer(string pServerName); - - [DllImport("wtsapi32.dll", SetLastError = true)] - public static extern int WTSEnumerateSessions( - System.IntPtr hServer, - int Reserved, - int Version, - ref System.IntPtr ppSessionInfo, - ref int pCount); - - } -} diff --git a/Remotely_Library/Win32/Win32Interop.cs b/Remotely_Library/Win32/Win32Interop.cs deleted file mode 100644 index f44ce40e..00000000 --- a/Remotely_Library/Win32/Win32Interop.cs +++ /dev/null @@ -1,143 +0,0 @@ -using Remotely_Library.Win32; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using static Remotely_Library.Win32.ADVAPI32; -using static Remotely_Library.Win32.User32; - -namespace Remotely_Library.Win32 -{ - public class Win32Interop - { - public static bool OpenInteractiveProcess(string applicationName, string desktopName, bool hiddenWindow, out PROCESS_INFORMATION procInfo) - { - uint winlogonPid = 0; - IntPtr hUserTokenDup = IntPtr.Zero, hPToken = IntPtr.Zero, hProcess = IntPtr.Zero; - procInfo = new PROCESS_INFORMATION(); - - // Obtain session ID for active session. - uint dwSessionId = Kernel32.WTSGetActiveConsoleSessionId(); - - // Check for RDP session. If active, use that session ID instead. - var rdpSessionID = GetRDPSession(); - if (rdpSessionID > 0) - { - dwSessionId = rdpSessionID; - } - - // Obtain the process ID of the winlogon process that is running within the currently active session. - Process[] processes = Process.GetProcessesByName("winlogon"); - foreach (Process p in processes) - { - if ((uint)p.SessionId == dwSessionId) - { - winlogonPid = (uint)p.Id; - } - } - - // Obtain a handle to the winlogon process. - hProcess = Kernel32.OpenProcess(MAXIMUM_ALLOWED, false, winlogonPid); - - // Obtain a handle to the access token of the winlogon process. - if (!OpenProcessToken(hProcess, TOKEN_DUPLICATE, ref hPToken)) - { - Kernel32.CloseHandle(hProcess); - return false; - } - - // Security attibute structure used in DuplicateTokenEx and CreateProcessAsUser. - SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES(); - sa.Length = Marshal.SizeOf(sa); - - // Copy the access token of the winlogon process; the newly created token will be a primary token. - if (!DuplicateTokenEx(hPToken, MAXIMUM_ALLOWED, ref sa, SECURITY_IMPERSONATION_LEVEL.SecurityIdentification, TOKEN_TYPE.TokenPrimary, out hUserTokenDup)) - { - Kernel32.CloseHandle(hProcess); - Kernel32.CloseHandle(hPToken); - return false; - } - - // By default, CreateProcessAsUser creates a process on a non-interactive window station, meaning - // the window station has a desktop that is invisible and the process is incapable of receiving - // user input. To remedy this we set the lpDesktop parameter to indicate we want to enable user - // interaction with the new process. - STARTUPINFO si = new STARTUPINFO(); - si.cb = Marshal.SizeOf(si); - si.lpDesktop = @"winsta0\" + desktopName; - - // Flags that specify the priority and creation method of the process. - uint dwCreationFlags; - if (hiddenWindow) - { - dwCreationFlags = NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW | DETACHED_PROCESS; - } - else - { - dwCreationFlags = NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE; - } - - // Create a new process in the current user's logon session. - bool result = CreateProcessAsUser(hUserTokenDup, null, applicationName, ref sa, ref sa, false, dwCreationFlags, IntPtr.Zero, null, ref si, out procInfo); - - // Invalidate the handles. - Kernel32.CloseHandle(hProcess); - Kernel32.CloseHandle(hPToken); - Kernel32.CloseHandle(hUserTokenDup); - - return result; - } - - public static uint GetRDPSession() - { - IntPtr ppSessionInfo = IntPtr.Zero; - Int32 count = 0; - Int32 retval = WTSAPI32.WTSEnumerateSessions(WTSAPI32.WTS_CURRENT_SERVER_HANDLE, 0, 1, ref ppSessionInfo, ref count); - Int32 dataSize = Marshal.SizeOf(typeof(WTSAPI32.WTS_SESSION_INFO)); - var sessList = new List(); - Int64 current = (Int64)ppSessionInfo; - - if (retval != 0) - { - for (int i = 0; i < count; i++) - { - WTSAPI32.WTS_SESSION_INFO sessInf = (WTSAPI32.WTS_SESSION_INFO)Marshal.PtrToStructure((System.IntPtr)current, typeof(WTSAPI32.WTS_SESSION_INFO)); - current += dataSize; - sessList.Add(sessInf); - } - } - uint retVal = 0; - var rdpSession = sessList.Find(ses => ses.pWinStationName.ToLower().Contains("rdp") && ses.State == 0); - if (sessList.Exists(ses => ses.pWinStationName.ToLower().Contains("rdp") && ses.State == 0)) - { - retVal = (uint)rdpSession.SessionID; - } - return retVal; - } - public static IntPtr OpenInputDesktop() - { - return User32.OpenInputDesktop(0, false, ACCESS_MASK.GENERIC_ALL); - } - public static string GetCurrentDesktop() - { - var inputDesktop = OpenInputDesktop(); - byte[] deskBytes = new byte[256]; - uint lenNeeded; - var success = GetUserObjectInformationW(inputDesktop, UOI_NAME, deskBytes, 256, out lenNeeded); - if (!success) - { - CloseDesktop(inputDesktop); - return "Default"; - } - var desktopName = Encoding.Unicode.GetString(deskBytes.Take((int)lenNeeded).ToArray()).Replace("\0", ""); - CloseDesktop(inputDesktop); - return desktopName; - } - public static void SetMonitorState(MonitorState state) - { - User32.SendMessage(0xFFFF, 0x112, 0xF170, (int)state); - } - } -} diff --git a/Remotely_Server/CurrentVersion.txt b/Remotely_Server/CurrentVersion.txt index 49254084..18457a44 100644 --- a/Remotely_Server/CurrentVersion.txt +++ b/Remotely_Server/CurrentVersion.txt @@ -1 +1 @@ -2019.04.04.0721 +2019.04.05.2344 diff --git a/Utilities/Publish.ps1 b/Utilities/Publish.ps1 index 50453123..cd7a937d 100644 --- a/Utilities/Publish.ps1 +++ b/Utilities/Publish.ps1 @@ -52,7 +52,9 @@ else { } } -Set-Location -Path (Get-Item -Path $PSScriptRoot).Parent.FullName +$Root = (Get-Item -Path $PSScriptRoot).Parent.FullName + +Set-Location -Path $Root if ($ArgList.Contains("c")) { # Add Current Version file to root content folder for client update checks. @@ -79,15 +81,15 @@ if ($ArgList.Contains("c")) { Pop-Location + New-Item -Path ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x64\publish\ScreenCast\" -ItemType Directory -Force + New-Item -Path ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x86\publish\ScreenCast\" -ItemType Directory -Force + New-Item -Path ".\Remotely_Agent\bin\Release\netcoreapp2.2\linux-x64\publish\ScreenCast\" -ItemType Directory -Force + # Publish Linux ScreenCaster - dotnet publish /p:Version=$CurrentVersion /p:FileVersion=$CurrentVersion --runtime linux-x64 --configuration Release --output ".\Remotely_Agent\bin\Release\netcoreapp2.2\linux-x64\publish\ScreenCast\" ".\Remotely_ScreenCast.Linux\" + dotnet publish /p:Version=$CurrentVersion /p:FileVersion=$CurrentVersion --runtime linux-x64 --configuration Release --output "$Root\Remotely_Agent\bin\Release\netcoreapp2.2\linux-x64\publish\ScreenCast\" "$Root\Remotely_ScreenCast.Linux\" - New-Item -Path ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x64\publish\ScreenCast\" -ItemType Directory -Force - New-Item -Path ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x86\publish\ScreenCast\" -ItemType Directory -Force - #New-Item -Path ".\Remotely_Agent\bin\Release\netcoreapp2.2\linux-x64\publish\ScreenCast\" -ItemType Directory -Force - # Copy .NET Framework ScreenCaster to Agent output folder. if ((Test-Path -Path ".\Remotely_ScreenCast.Win\bin\Release\Remotely_ScreenCast.exe") -eq $true) { Copy-Item -Path ".\Remotely_ScreenCast.Win\bin\Release\Remotely_ScreenCast.exe" -Destination ".\Remotely_Agent\bin\Release\netcoreapp2.2\win10-x64\publish\ScreenCast\Remotely_ScreenCast.exe" -Force