diff --git a/.gitignore b/.gitignore
index dd701dc..a736671 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,7 @@ TestResults
[Dd]ebug/
[Rr]elease/
x64/
+.vs/
*_i.c
*_p.c
*.ilk
diff --git a/AgentInterface/AgentInterface.csproj b/AgentInterface/AgentInterface.csproj
deleted file mode 100644
index 3b092db..0000000
--- a/AgentInterface/AgentInterface.csproj
+++ /dev/null
@@ -1,163 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {5C3B0B17-CBB7-4B4B-B527-1FAB2BB96466}
- Library
- Properties
- AgentInterface
- AgentInterface
- v4.5.2
- 512
-
-
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
- true
-
-
- true
-
-
-
- ..\packages\Cassia.2.0.0.60\lib\2.0\Cassia.dll
- True
-
-
- ..\packages\Newtonsoft.Json.10.0.1-beta1\lib\net45\Newtonsoft.Json.dll
-
-
- ..\packages\OpenHardwareMonitor.0.7.1\lib\net40\OpenHardwareMonitorLib.dll
- True
-
-
-
-
- ..\packages\SharpDX.3.1.1\lib\net45\SharpDX.dll
- True
-
-
- ..\packages\SharpDX.Direct3D11.3.1.1\lib\net45\SharpDX.Direct3D11.dll
- True
-
-
- ..\packages\SharpDX.DXGI.3.1.1\lib\net45\SharpDX.DXGI.dll
- True
-
-
- ..\packages\SharpDX.Mathematics.3.1.1\lib\net45\SharpDX.Mathematics.dll
- True
-
-
-
-
-
-
-
-
- ..\packages\TurboJpegWrapper.1.4.2.6\lib\net35\TurboJpegWrapper.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Designer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ();
-var attribute = config.Attribute("ExcludeAssemblies");
-if (attribute != null)
- foreach (var item in attribute.Value.Split('|').Select(x => x.Trim()).Where(x => x != string.Empty))
- excludedAssemblies.Add(item);
-var element = config.Element("ExcludeAssemblies");
-if (element != null)
- foreach (var item in element.Value.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).Where(x => x != string.Empty))
- excludedAssemblies.Add(item);
-
-var filesToCleanup = Files.Select(f => f.ItemSpec).Where(f => !excludedAssemblies.Contains(Path.GetFileNameWithoutExtension(f), StringComparer.InvariantCultureIgnoreCase));
-
-foreach (var item in filesToCleanup)
- File.Delete(item);
-]]>
-
-
-
-
-
-
-
-
- This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
-
-
-
\ No newline at end of file
diff --git a/AgentInterface/Api/Win32/Display.cs b/AgentInterface/Api/Win32/Display.cs
deleted file mode 100644
index c58d49d..0000000
--- a/AgentInterface/Api/Win32/Display.cs
+++ /dev/null
@@ -1,910 +0,0 @@
-#region
-
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Globalization;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Text.RegularExpressions;
-using System.Windows.Forms;
-using AgentInterface.Api.Models;
-using AgentInterface.Api.ScreenShare;
-
-#endregion
-
-namespace AgentInterface.Api.Win32
-{
- public class Display
- {
-
-
- [Flags]
- public enum ChangeDisplaySettingsFlags : uint
- {
- CDS_NONE = 0,
- CDS_UPDATEREGISTRY = 0x00000001,
- CDS_TEST = 0x00000002,
- CDS_FULLSCREEN = 0x00000004,
- CDS_GLOBAL = 0x00000008,
- CDS_SET_PRIMARY = 0x00000010,
- CDS_VIDEOPARAMETERS = 0x00000020,
- CDS_ENABLE_UNSAFE_MODES = 0x00000100,
- CDS_DISABLE_UNSAFE_MODES = 0x00000200,
- CDS_RESET = 0x40000000,
- CDS_RESET_EX = 0x20000000,
- CDS_NORESET = 0x10000000
- }
-
- [Flags]
- public enum DisplayDeviceStateFlags
- {
- /// The device is part of the desktop.
- AttachedToDesktop = 0x1,
- MultiDriver = 0x2,
-
- /// The device is part of the desktop.
- PrimaryDevice = 0x4,
-
- /// Represents a pseudo device used to mirror application drawing for remoting or other purposes.
- MirroringDriver = 0x8,
-
- /// The device is VGA compatible.
- VgaCompatible = 0x10,
-
- /// The device is removable; it cannot be the primary display.
- Removable = 0x20,
-
- /// The device has more display modes than its output devices support.
- ModesPruned = 0x8000000,
- Remote = 0x4000000,
- Disconnect = 0x2000000
- }
-
- public const int DMDO_DEFAULT = 0;
- public const int DMDO_90 = 1;
- public const int DMDO_180 = 2;
- public const int DMDO_270 = 3;
-
- public const int ErrorSuccess = 0;
-
- public const int ENUM_CURRENT_SETTINGS = -1;
- public const int CDS_UPDATEREGISTRY = 0x01;
- public const int CDS_TEST = 0x02;
-
-
- private const int ENUM_REGISTRY_SETTINGS = -2;
-
- public static int EnumCurrentSettings { get; } = -1;
-
- public static int EnumRegistrySettings { get; } = -2;
-
- private static string MonitorFriendlyName(Luid adapterId, uint targetId)
- {
- var deviceName = new DisplayconfigTargetDeviceName
- {
- header =
- {
- size = (uint) Marshal.SizeOf(typeof(DisplayconfigTargetDeviceName)),
- adapterId = adapterId,
- id = targetId,
- type = DisplayconfigDeviceInfoType.DisplayconfigDeviceInfoGetTargetName
- }
- };
- var error = DisplayConfigGetDeviceInfo(ref deviceName);
- if (error != ErrorSuccess)
- throw new Win32Exception(error);
- return deviceName.monitorFriendlyDeviceName;
- }
-
- private static IEnumerable GetAllMonitorsFriendlyNames()
- {
- uint pathCount, modeCount;
- var error = GetDisplayConfigBufferSizes(QueryDeviceConfigFlags.QdcOnlyActivePaths, out pathCount,
- out modeCount);
- if (error != ErrorSuccess)
- throw new Win32Exception(error);
-
- var displayPaths = new DisplayconfigPathInfo[pathCount];
- var displayModes = new DisplayconfigModeInfo[modeCount];
- error = QueryDisplayConfig(QueryDeviceConfigFlags.QdcOnlyActivePaths,
- ref pathCount, displayPaths, ref modeCount, displayModes, IntPtr.Zero);
- if (error != ErrorSuccess)
- throw new Win32Exception(error);
-
- for (var i = 0; i < modeCount; i++)
- if (displayModes[i].infoType == DisplayconfigModeInfoType.DisplayconfigModeInfoTypeTarget)
- yield return MonitorFriendlyName(displayModes[i].adapterId, displayModes[i].id);
- }
-
- public static List DeviceFriendlyName()
- {
- return GetAllMonitorsFriendlyNames().ToList();
- }
-
- [DllImport("user32.dll")]
- public static extern int ChangeDisplaySettings(
- ref Devmode devMode, int flags);
-
- [DllImport("user32.dll")]
- public static extern DISP_CHANGE ChangeDisplaySettingsEx(string lpszDeviceName, ref Devmode lpDevMode,
- IntPtr hwnd, ChangeDisplaySettingsFlags dwflags, IntPtr lParam);
-
- [DllImport("user32.dll")]
- public static extern DISP_CHANGE ChangeDisplaySettingsEx(string lpszDeviceName, IntPtr lpDevMode, IntPtr hwnd,
- ChangeDisplaySettingsFlags dwflags, IntPtr lParam);
-
- [DllImport("user32.dll")]
- public static extern bool EnumDisplaySettings(
- string deviceName, int modeNum, ref Devmode devMode);
-
- private static List UpdateDisplays()
- {
- var monitors = new List();
- var d = new DisplayDevice();
- d.cb = Marshal.SizeOf(d);
- try
- {
- for (uint id = 0; EnumDisplayDevices(null, id, ref d, 0); id++)
- {
- if (d.StateFlags.HasFlag(DisplayDeviceStateFlags.AttachedToDesktop))
- {
- var device = d.DeviceName;
-
- var vDevMode = new Devmode();
- var i = 0;
- var supportedResolutions = new Dictionary>();
- while (EnumDisplaySettings(device, i, ref vDevMode))
- {
- var width = vDevMode.dmPelsWidth;
- var height = vDevMode.dmPelsHeight;
- var bpp = vDevMode.dmBitsPerPel;
- var orientation = vDevMode.dmDisplayOrientation.ToString();
- var freq = vDevMode.dmDisplayFrequency;
- var resolutionKey = $"{width}x{height}";
- var resolution = new ResolutionInformation
- {
- BitsPerPixel = bpp,
- Frequency = freq,
- Height = height,
- Width = width,
- Orientation = orientation
- };
- if (supportedResolutions.ContainsKey(resolutionKey))
- {
- supportedResolutions[resolutionKey].Add(resolution);
- }
- else
- {
- supportedResolutions.Add(resolutionKey, new List());
- supportedResolutions[resolutionKey].Add(resolution);
- }
- i++;
- }
- var cDevMode = new Devmode();
- EnumDisplaySettings(device, ENUM_CURRENT_SETTINGS, ref cDevMode);
-
- var currentResolution = new ResolutionInformation
- {
- BitsPerPixel = cDevMode.dmBitsPerPel,
- Frequency = cDevMode.dmDisplayFrequency,
- Height = cDevMode.dmPelsHeight,
- Width = cDevMode.dmPelsWidth,
- Orientation = cDevMode.dmDisplayOrientation.ToString(),
- X = cDevMode.dmPositionX,
- Y = cDevMode.dmPositionY
- };
- var monitor = new DisplayInformation
- {
- Primary = d.StateFlags.HasFlag(DisplayDeviceStateFlags.PrimaryDevice),
- Attached = d.StateFlags.HasFlag(DisplayDeviceStateFlags.AttachedToDesktop),
- Removable = d.StateFlags.HasFlag(DisplayDeviceStateFlags.Removable),
- VgaCompatible = d.StateFlags.HasFlag(DisplayDeviceStateFlags.VgaCompatible),
- MirroringDriver = d.StateFlags.HasFlag(DisplayDeviceStateFlags.MirroringDriver),
- MultiDriver = d.StateFlags.HasFlag(DisplayDeviceStateFlags.MultiDriver),
- ModesPruned = d.StateFlags.HasFlag(DisplayDeviceStateFlags.ModesPruned),
- Remote = d.StateFlags.HasFlag(DisplayDeviceStateFlags.Remote),
- Disconnect = d.StateFlags.HasFlag(DisplayDeviceStateFlags.Disconnect),
- FriendlyName = $"{GetAllMonitorsFriendlyNames().ElementAt((int)id)} on {d.DeviceString}",
- SupportedResolutions = supportedResolutions,
- CurrentResolution = currentResolution,
- DeviceName = device
- };
- monitors.Add(monitor);
- d.cb = Marshal.SizeOf(d);
- EnumDisplayDevices(d.DeviceName, 0, ref d, 0);
- }
- d.cb = Marshal.SizeOf(d);
- }
- return monitors;
- }
- catch
- {
-
- }
- string errorMessage = new Win32Exception(Marshal.GetLastWin32Error()).Message;
- Console.WriteLine(errorMessage);
- return monitors;
- }
-
- public static List DisplayInformation()
- {
- return UpdateDisplays();
- }
-
- public static string SetPrimary(string deviceName)
- {
- var id = int.Parse(Regex.Match(deviceName, @"\d+").Value) - 1;
- var originalMode = new Devmode();
- originalMode.dmSize = (short) Marshal.SizeOf(originalMode);
- EnumDisplaySettings(deviceName, ENUM_CURRENT_SETTINGS, ref originalMode);
- var offsetx = originalMode.dmPositionX;
- var offsety = originalMode.dmPositionY;
- originalMode.dmPositionX = 0;
- originalMode.dmPositionY = 0;
-
- ChangeDisplaySettingsEx(deviceName, ref originalMode, (IntPtr) null,
- ChangeDisplaySettingsFlags.CDS_SET_PRIMARY | ChangeDisplaySettingsFlags.CDS_UPDATEREGISTRY |
- ChangeDisplaySettingsFlags.CDS_NORESET, IntPtr.Zero);
- var device = new DisplayDevice();
- device.cb = Marshal.SizeOf(device);
-
- // Update remaining devices
- for (uint otherid = 0; EnumDisplayDevices(null, otherid, ref device, 0); otherid++)
- {
- if (device.StateFlags.HasFlag(DisplayDeviceStateFlags.AttachedToDesktop) && otherid != id)
- {
- device.cb = Marshal.SizeOf(device);
- var otherDeviceMode = new Devmode();
-
- EnumDisplaySettings(device.DeviceName, -1, ref otherDeviceMode);
-
- otherDeviceMode.dmPositionX -= offsetx;
- otherDeviceMode.dmPositionY -= offsety;
-
- ChangeDisplaySettingsEx(
- device.DeviceName,
- ref otherDeviceMode,
- (IntPtr) null,
- ChangeDisplaySettingsFlags.CDS_UPDATEREGISTRY | ChangeDisplaySettingsFlags.CDS_NORESET,
- IntPtr.Zero);
- }
-
- device.cb = Marshal.SizeOf(device);
- }
-
- // Apply settings
- return
- GetMessageForCode(ChangeDisplaySettingsEx(null, IntPtr.Zero, (IntPtr) null,
- ChangeDisplaySettingsFlags.CDS_NONE, (IntPtr) null));
- }
- [DllImport("kernel32.dll")]
- public static extern uint GetLastError();
-
- public static string Rotate(int angle, int width, int height, string deviceName)
- {
- var originalMode = new Devmode();
- originalMode.dmSize = (short) Marshal.SizeOf(originalMode);
- EnumDisplaySettings(deviceName, ENUM_CURRENT_SETTINGS, ref originalMode);
-
- // swap height and width
- var temp = originalMode.dmPelsHeight;
- originalMode.dmPelsHeight = originalMode.dmPelsWidth;
- originalMode.dmPelsWidth = temp;
-
- originalMode.dmPelsWidth = width;
- originalMode.dmPelsHeight = height;
- switch (angle)
- {
- case 0:
- originalMode.dmDisplayOrientation = ScreenOrientation.Angle0;
- break;
- case 90:
- originalMode.dmDisplayOrientation = ScreenOrientation.Angle90;
- break;
- case 180:
- originalMode.dmDisplayOrientation = ScreenOrientation.Angle180;
- break;
- case 270:
- originalMode.dmDisplayOrientation = ScreenOrientation.Angle270;
- break;
- }
- return GetMessageForCode(ChangeDisplaySettingsEx(deviceName, ref originalMode, IntPtr.Zero,
- ChangeDisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero));
- }
-
- public static string ChangeResolution(string deviceName, int width, int height, int bbp, int freq)
- {
- var originalMode = new Devmode();
- originalMode.dmSize = (short) Marshal.SizeOf(originalMode);
- EnumDisplaySettings(deviceName, ENUM_CURRENT_SETTINGS, ref originalMode);
- var newMode = originalMode;
- newMode.dmDeviceName = deviceName;
- newMode.dmPelsWidth = width;
- newMode.dmPelsHeight = height;
- newMode.dmBitsPerPel = bbp;
- newMode.dmDisplayFrequency = freq;
- return GetMessageForCode(ChangeDisplaySettingsEx(deviceName, ref newMode, IntPtr.Zero,
- ChangeDisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero));
- }
-
- private static string GetMessageForCode(DISP_CHANGE code)
- {
- string message;
- switch (code)
- {
- case DISP_CHANGE.Successful:
- message = "Resolution updated.";
- break;
- case DISP_CHANGE.Restart:
- message = "A restart is required for this resolution to take effect.";
- break;
- case DISP_CHANGE.BadMode:
- message = $"resolution is not valid.";
- break;
- case DISP_CHANGE.BadDualView:
- message = "The settings change was unsuccessful because system is DualView capable.";
- break;
- case DISP_CHANGE.BadFlags:
- message = "An invalid set of flags was passed in.";
- break;
- case DISP_CHANGE.BadParam:
- message =
- "An invalid parameter was passed in. This can include an invalid flag or combination of flags.";
- break;
- case DISP_CHANGE.Failed:
- message = "Resolution failed to update.";
- break;
- case DISP_CHANGE.NotUpdated:
- message = "Unable to write settings to the registry.";
- break;
- default:
- message = "Unknown return value from ChangeDisplaySettings API.";
- break;
- }
- return message;
- }
-
- [DllImport("user32.dll")]
- private static extern bool EnumDisplayDevices(string lpDevice, uint iDevNum, ref DisplayDevice lpDisplayDevice,
- uint dwFlags);
-
- public enum DISP_CHANGE
- {
- Successful = 0,
- Restart = 1,
- Failed = -1,
- BadMode = -2,
- NotUpdated = -3,
- BadFlags = -4,
- BadParam = -5,
- BadDualView = -6
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct Devmode
- {
- private const int Cchdevicename = 0x20;
- private const int Cchformname = 0x20;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)] public string dmDeviceName;
- public short dmSpecVersion;
- public short dmDriverVersion;
- public short dmSize;
- public short dmDriverExtra;
- public int dmFields;
- public int dmPositionX;
- public int dmPositionY;
- public ScreenOrientation dmDisplayOrientation;
- public int dmDisplayFixedOutput;
- public short dmColor;
- public short dmDuplex;
- public short dmYResolution;
- public short dmTTOption;
- public short dmCollate;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)] public string dmFormName;
- public short dmLogPixels;
- public int dmBitsPerPel;
- public int dmPelsWidth;
- public int dmPelsHeight;
- public int dmDisplayFlags;
- public int dmDisplayFrequency;
- public int dmICMMethod;
- public int dmICMIntent;
- public int dmMediaType;
- public int dmDitherType;
- public int dmReserved1;
- public int dmReserved2;
- public int dmPanningWidth;
- public int dmPanningHeight;
- }
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
- public struct DisplayDevice
- {
- [MarshalAs(UnmanagedType.U4)] public int cb;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string DeviceName;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string DeviceString;
- [MarshalAs(UnmanagedType.U4)] public DisplayDeviceStateFlags StateFlags;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string DeviceID;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string DeviceKey;
- }
-
- #region enums
-
- public enum QueryDeviceConfigFlags : uint
- {
- QdcAllPaths = 0x00000001,
- QdcOnlyActivePaths = 0x00000002,
- QdcDatabaseCurrent = 0x00000004
- }
-
- public enum DisplayconfigVideoOutputTechnology : uint
- {
- DisplayconfigOutputTechnologyOther = 0xFFFFFFFF,
- DisplayconfigOutputTechnologyHd15 = 0,
- DisplayconfigOutputTechnologySvideo = 1,
- DisplayconfigOutputTechnologyCompositeVideo = 2,
- DisplayconfigOutputTechnologyComponentVideo = 3,
- DisplayconfigOutputTechnologyDvi = 4,
- DisplayconfigOutputTechnologyHdmi = 5,
- DisplayconfigOutputTechnologyLvds = 6,
- DisplayconfigOutputTechnologyDJpn = 8,
- DisplayconfigOutputTechnologySdi = 9,
- DisplayconfigOutputTechnologyDisplayportExternal = 10,
- DisplayconfigOutputTechnologyDisplayportEmbedded = 11,
- DisplayconfigOutputTechnologyUdiExternal = 12,
- DisplayconfigOutputTechnologyUdiEmbedded = 13,
- DisplayconfigOutputTechnologySdtvdongle = 14,
- DisplayconfigOutputTechnologyMiracast = 15,
- DisplayconfigOutputTechnologyInternal = 0x80000000,
- DisplayconfigOutputTechnologyForceUint32 = 0xFFFFFFFF
- }
-
- public enum DisplayconfigScanlineOrdering : uint
- {
- DisplayconfigScanlineOrderingUnspecified = 0,
- DisplayconfigScanlineOrderingProgressive = 1,
- DisplayconfigScanlineOrderingInterlaced = 2,
- DisplayconfigScanlineOrderingInterlacedUpperfieldfirst = DisplayconfigScanlineOrderingInterlaced,
- DisplayconfigScanlineOrderingInterlacedLowerfieldfirst = 3,
- DisplayconfigScanlineOrderingForceUint32 = 0xFFFFFFFF
- }
-
- public enum DisplayconfigRotation : uint
- {
- DisplayconfigRotationIdentity = 1,
- DisplayconfigRotationRotate90 = 2,
- DisplayconfigRotationRotate180 = 3,
- DisplayconfigRotationRotate270 = 4,
- DisplayconfigRotationForceUint32 = 0xFFFFFFFF
- }
-
- public enum DisplayconfigScaling : uint
- {
- DisplayconfigScalingIdentity = 1,
- DisplayconfigScalingCentered = 2,
- DisplayconfigScalingStretched = 3,
- DisplayconfigScalingAspectratiocenteredmax = 4,
- DisplayconfigScalingCustom = 5,
- DisplayconfigScalingPreferred = 128,
- DisplayconfigScalingForceUint32 = 0xFFFFFFFF
- }
- [DllImport("user32")]
- private static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr lpRect, MonitorEnumProc callback, int dwData);
-
- private delegate bool MonitorEnumProc(IntPtr hDesktop, IntPtr hdc, ref Rect pRect, int dwData);
-
- [StructLayout(LayoutKind.Sequential)]
- private struct Rect
- {
- public int left;
- public int top;
- public int right;
- public int bottom;
- }
-
- public enum DisplayconfigPixelformat : uint
- {
- DisplayconfigPixelformat8Bpp = 1,
- DisplayconfigPixelformat16Bpp = 2,
- DisplayconfigPixelformat24Bpp = 3,
- DisplayconfigPixelformat32Bpp = 4,
- DisplayconfigPixelformatNongdi = 5,
- DisplayconfigPixelformatForceUint32 = 0xffffffff
- }
-
- public enum DisplayconfigModeInfoType : uint
- {
- DisplayconfigModeInfoTypeSource = 1,
- DisplayconfigModeInfoTypeTarget = 2,
- DisplayconfigModeInfoTypeForceUint32 = 0xFFFFFFFF
- }
-
- public enum DisplayconfigDeviceInfoType : uint
- {
- DisplayconfigDeviceInfoGetSourceName = 1,
- DisplayconfigDeviceInfoGetTargetName = 2,
- DisplayconfigDeviceInfoGetTargetPreferredMode = 3,
- DisplayconfigDeviceInfoGetAdapterName = 4,
- DisplayconfigDeviceInfoSetTargetPersistence = 5,
- DisplayconfigDeviceInfoGetTargetBaseType = 6,
- DisplayconfigDeviceInfoForceUint32 = 0xFFFFFFFF
- }
-
- #endregion
-
- #region structs
-
- [StructLayout(LayoutKind.Sequential)]
- public struct Luid
- {
- public uint LowPart;
- public int HighPart;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct DisplayconfigPathSourceInfo
- {
- public Luid adapterId;
- public uint id;
- public uint modeInfoIdx;
- public uint statusFlags;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct DisplayconfigPathTargetInfo
- {
- public Luid adapterId;
- public uint id;
- public uint modeInfoIdx;
- private readonly DisplayconfigVideoOutputTechnology outputTechnology;
- private readonly DisplayconfigRotation rotation;
- private readonly DisplayconfigScaling scaling;
- private readonly DisplayconfigRational refreshRate;
- private readonly DisplayconfigScanlineOrdering scanLineOrdering;
- public bool targetAvailable;
- public uint statusFlags;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct DisplayconfigRational
- {
- public uint Numerator;
- public uint Denominator;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct DisplayconfigPathInfo
- {
- public DisplayconfigPathSourceInfo sourceInfo;
- public DisplayconfigPathTargetInfo targetInfo;
- public uint flags;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct Displayconfig2Dregion
- {
- public uint cx;
- public uint cy;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct DisplayconfigVideoSignalInfo
- {
- public ulong pixelRate;
- public DisplayconfigRational hSyncFreq;
- public DisplayconfigRational vSyncFreq;
- public Displayconfig2Dregion activeSize;
- public Displayconfig2Dregion totalSize;
- public uint videoStandard;
- public DisplayconfigScanlineOrdering scanLineOrdering;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct DisplayconfigTargetMode
- {
- public DisplayconfigVideoSignalInfo targetVideoSignalInfo;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct Pointl
- {
- private readonly int x;
- private readonly int y;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct DisplayconfigSourceMode
- {
- public uint width;
- public uint height;
- public DisplayconfigPixelformat pixelFormat;
- public Pointl position;
- }
-
- [StructLayout(LayoutKind.Explicit)]
- public struct DisplayconfigModeInfoUnion
- {
- [FieldOffset(0)] public DisplayconfigTargetMode targetMode;
-
- [FieldOffset(0)] public DisplayconfigSourceMode sourceMode;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct DisplayconfigModeInfo
- {
- public DisplayconfigModeInfoType infoType;
- public uint id;
- public Luid adapterId;
- public DisplayconfigModeInfoUnion modeInfo;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct DisplayconfigTargetDeviceNameFlags
- {
- public uint value;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct DisplayconfigDeviceInfoHeader
- {
- public DisplayconfigDeviceInfoType type;
- public uint size;
- public Luid adapterId;
- public uint id;
- }
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
- public struct DisplayconfigTargetDeviceName
- {
- public DisplayconfigDeviceInfoHeader header;
- public DisplayconfigTargetDeviceNameFlags flags;
- public DisplayconfigVideoOutputTechnology outputTechnology;
- public ushort edidManufactureId;
- public ushort edidProductCodeId;
- public uint connectorInstance;
-
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] public string monitorFriendlyDeviceName;
-
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string monitorDevicePath;
- }
- [StructLayout(LayoutKind.Sequential)]
- public struct RECT
- {
- public int Left, Top, Right, Bottom;
-
- public RECT(int left, int top, int right, int bottom)
- {
- Left = left;
- Top = top;
- Right = right;
- Bottom = bottom;
- }
-
- public RECT(Rectangle r) : this(r.Left, r.Top, r.Right, r.Bottom) { }
-
- public int X
- {
- get { return Left; }
- set { Right -= (Left - value); Left = value; }
- }
-
- public int Y
- {
- get { return Top; }
- set { Bottom -= (Top - value); Top = value; }
- }
-
- public int Height
- {
- get { return Bottom - Top; }
- set { Bottom = value + Top; }
- }
-
- public int Width
- {
- get { return Right - Left; }
- set { Right = value + Left; }
- }
-
-
-
- public Size Size
- {
- get { return new Size(Width, Height); }
- set { Width = value.Width; Height = value.Height; }
- }
-
- public static implicit operator Rectangle(RECT r)
- {
- return new Rectangle(r.Left, r.Top, r.Width, r.Height);
- }
-
- public static implicit operator RECT(Rectangle r)
- {
- return new RECT(r);
- }
-
- public static bool operator ==(RECT r1, RECT r2)
- {
- return r1.Equals(r2);
- }
-
- public static bool operator !=(RECT r1, RECT r2)
- {
- return !r1.Equals(r2);
- }
-
- public bool Equals(RECT r)
- {
- return r.Left == Left && r.Top == Top && r.Right == Right && r.Bottom == Bottom;
- }
-
- public override bool Equals(object obj)
- {
- if (obj is RECT)
- return Equals((RECT)obj);
- else if (obj is Rectangle)
- return Equals(new RECT((Rectangle)obj));
- return false;
- }
-
- public override int GetHashCode()
- {
- return ((Rectangle)this).GetHashCode();
- }
-
- public override string ToString()
- {
- return string.Format(CultureInfo.CurrentCulture, "{{Left={0},Top={1},Right={2},Bottom={3}}}", Left, Top, Right, Bottom);
- }
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct CURSORINFO
- {
- public Int32 cbSize; // Specifies the size, in bytes, of the structure.
- public Int32 flags; // Specifies the cursor state. This parameter can be one of the following values:
- public IntPtr hCursor; // Handle to the cursor.
- public POINT ptScreenPos; // A POINT structure that receives the screen coordinates of the cursor.
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct ICONINFO
- {
- public bool fIcon; // Specifies whether this structure defines an icon or a cursor. A value of TRUE specifies
- public Int32 xHotspot; // Specifies the x-coordinate of a cursor's hot spot. If this structure defines an icon, the hot
- public Int32 yHotspot; // Specifies the y-coordinate of the cursor's hot spot. If this structure defines an icon, the hot
- public IntPtr hbmMask; // (HBITMAP) Specifies the icon bitmask bitmap. If this structure defines a black and white icon,
- public IntPtr hbmColor; // (HBITMAP) Handle to the icon color bitmap. This member can be optional if this
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct POINT
- {
- public Int32 x;
- public Int32 y;
- }
- public const int Width = 0;
- public const int Height = 1;
- public struct ScreenSize
- {
- public int Width;
- public int Height;
- }
- public const Int32 CURSOR_SHOWING = 0x00000001;
-
- [DllImport("user32.dll", EntryPoint = "GetDesktopWindow")]
- public static extern IntPtr GetDesktopWindow();
-
- [DllImport("user32.dll", EntryPoint = "GetDC")]
- public static extern IntPtr GetDesktopContext(IntPtr ptr);
-
- [DllImport("user32.dll", EntryPoint = "GetSystemMetrics")]
- public static extern int GetSystemMetrics(int abc);
-
- [DllImport("user32.dll", EntryPoint = "GetWindowDC")]
- public static extern IntPtr GetWindowDesktopContext(Int32 ptr);
-
- [DllImport("user32.dll", EntryPoint = "ReleaseDC")]
- public static extern IntPtr ReleaseDesktopContext(IntPtr hWnd, IntPtr hDc);
-
- [DllImport("user32.dll", EntryPoint = "GetCursorInfo")]
- public static extern bool GetCursorInfo(out CursorInfo pci);
-
- [DllImport("user32.dll", EntryPoint = "CopyIcon")]
- public static extern IntPtr CopyIcon(IntPtr hIcon);
-
- [DllImport("user32.dll", EntryPoint = "GetIconInfo")]
- public static extern bool GetIconInfo(IntPtr hIcon, out IconInfo piconinfo);
-
- [DllImport("user32.dll", EntryPoint = "DestroyIcon")]
- public static extern bool DestroyIcon(IntPtr hIcon);
- #endregion
- [StructLayout(LayoutKind.Sequential)]
- public struct IconInfo
- {
- public bool IsIcon; // Specifies whether this structure defines an icon or a cursor. A value of TRUE specifies
- public Int32 Xcoord; // Specifies the x-coordinate of a cursor's hot spot. If this structure defines an icon, the hot
- public Int32 Ycoord; // Specifies the y-coordinate of the cursor's hot spot. If this structure defines an icon, the hot
- public IntPtr Bitmask; // (HBITMAP) Specifies the icon bitmask bitmap. If this structure defines a black and white icon,
- public IntPtr Color; // (HBITMAP) Handle to the icon color bitmap. This member can be optional if this
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct Point
- {
- public Int32 X;
- public Int32 Y;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct CursorInfo
- {
- public Int32 Size; // Specifies the size, in bytes, of the structure.
- public Int32 State; // Specifies the cursor state. This parameter can be one of the following values:
- public IntPtr Handle; // Handle to the cursor.
- public Point Coordinates; // A POINT structure that receives the screen coordinates of the cursor.
- }
-
- #region DLL-Imports
-
- [DllImport("user32.dll")]
- public static extern int GetDisplayConfigBufferSizes(
- QueryDeviceConfigFlags flags, out uint numPathArrayElements, out uint numModeInfoArrayElements);
-
- [DllImport("user32.dll")]
- public static extern int QueryDisplayConfig(
- QueryDeviceConfigFlags flags,
- ref uint numPathArrayElements, [Out] DisplayconfigPathInfo[] pathInfoArray,
- ref uint numModeInfoArrayElements, [Out] DisplayconfigModeInfo[] modeInfoArray,
- IntPtr currentTopologyId
- );
-
- [DllImport("user32.dll")]
- public static extern int DisplayConfigGetDeviceInfo(ref DisplayconfigTargetDeviceName deviceName);
-
-
- [DllImport("user32.dll", SetLastError = true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
-
- public static Rectangle GetWindowRectangle()
- {
- RECT scBounds = new RECT();
- GetWindowRect(GetDesktopWindow(), ref scBounds);
- return scBounds;
- }
-
- public const int SRCCOPY = 13369376;
-
- [DllImport("gdi32.dll", EntryPoint = "CreateDC")]
- public static extern IntPtr CreateDesktopContext(IntPtr lpszDriver, string lpszDevice, IntPtr lpszOutput, IntPtr lpInitData);
-
- [DllImport("gdi32.dll", EntryPoint = "DeleteDC")]
- public static extern IntPtr DeleteDesktopContext(IntPtr hDc);
-
- [DllImport("gdi32.dll", EntryPoint = "DeleteObject")]
- public static extern IntPtr DeleteObject(IntPtr hDc);
-
- [DllImport("gdi32.dll", EntryPoint = "BitBlt")]
- public static extern bool BitBlt(IntPtr hdcDest, int xDest,
- int yDest, int wDest,
- int hDest, IntPtr hdcSource,
- int xSrc, int ySrc, int rasterOp);
-
- [DllImport("gdi32.dll", EntryPoint = "CreateCompatibleBitmap")]
- public static extern IntPtr CreateCompatibleBitmap
- (IntPtr hdc, int nWidth, int nHeight);
-
- [DllImport("gdi32.dll", EntryPoint = "CreateCompatibleDC")]
- public static extern IntPtr CreateCompatibleDesktopContext(IntPtr hdc);
-
- [DllImport("gdi32.dll", EntryPoint = "SelectObject")]
- public static extern IntPtr SelectObject(IntPtr hdc, IntPtr bmp);
-
- #endregion
- }
-
-
-}
\ No newline at end of file
diff --git a/AgentInterface/Api/Win32/ProcessStarter.cs b/AgentInterface/Api/Win32/ProcessStarter.cs
deleted file mode 100644
index f264db5..0000000
--- a/AgentInterface/Api/Win32/ProcessStarter.cs
+++ /dev/null
@@ -1,247 +0,0 @@
-#region
-
-using System;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Security.Principal;
-using Cassia;
-
-#endregion
-
-namespace AgentInterface.Api.Win32
-{
- ///
- /// Class that allows running applications with full admin rights. In
- /// addition the application launched will bypass the Vista UAC prompt.
- ///
- public class ProcessStarter
- {
-
-
-
- private static int GetUserSessionId(string username)
- {
- try
- {
- ITerminalServicesManager manager = new TerminalServicesManager();
- using (ITerminalServer server = manager.GetLocalServer())
- {
- server.Open();
- foreach (ITerminalServicesSession session in server.GetSessions())
- {
-
- NTAccount account = session.UserAccount;
- if (account == null) continue;
- var userName = account.Value.Split('\\')[1];
- if (userName.ToLower().Equals(username.ToLower())) return session.SessionId;
- }
- }
- return -1;
- }
- catch (Exception)
- {
-
- return -1;
- }
- }
-
-
- ///
- /// Launches the given application with full admin rights, and in addition bypasses the Vista UAC prompt
- ///
- /// The name of the application to launch
- /// Process information regarding the launched application that gets returned to the caller
- ///
- public static bool StartProcessAndBypassUAC(string applicationName, out PROCESS_INFORMATION procInfo)
- {
- uint winlogonPid = 0;
- IntPtr hUserTokenDup = IntPtr.Zero, hPToken = IntPtr.Zero, hProcess = IntPtr.Zero;
- procInfo = new PROCESS_INFORMATION();
-
-
- // obtain the currently active session id; every logged on user in the system has a unique session id
- var dwSessionId = -1;
-
- dwSessionId = (int) WTSGetActiveConsoleSessionId();
-
- // obtain the process id of the winlogon process that is running within the currently active session
- var processes = Process.GetProcessesByName("winlogon");
- foreach (var p in processes)
- {
- if ((uint) p.SessionId == dwSessionId)
- {
- winlogonPid = (uint) p.Id;
- }
- }
-
- // obtain a handle to the winlogon process
- hProcess = OpenProcess(MAXIMUM_ALLOWED, false, winlogonPid);
-
- // obtain a handle to the access token of the winlogon process
- if (!OpenProcessToken(hProcess, TOKEN_DUPLICATE, ref hPToken))
- {
- CloseHandle(hProcess);
- return false;
- }
-
- // Security attibute structure used in DuplicateTokenEx and CreateProcessAsUser
- // I would prefer to not have to use a security attribute variable and to just
- // simply pass null and inherit (by default) the security attributes
- // of the existing token. However, in C# structures are value types and therefore
- // cannot be assigned the null value.
- var 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,
- (int) SECURITY_IMPERSONATION_LEVEL.SecurityIdentification, (int) TOKEN_TYPE.TokenPrimary,
- ref hUserTokenDup))
- {
- CloseHandle(hProcess);
- 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.
- var si = new STARTUPINFO();
- si.cb = Marshal.SizeOf(si);
- si.lpDesktop = @"winsta0\default";
- // interactive window station parameter; basically this indicates that the process created can display a GUI on the desktop
-
- // flags that specify the priority and creation method of the process
- var dwCreationFlags = NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE;
-
- // create a new process in the current user's logon session
- var result = CreateProcessAsUser(hUserTokenDup, // client's access token
- null, // file to execute
- applicationName, // command line
- ref sa, // pointer to process SECURITY_ATTRIBUTES
- ref sa, // pointer to thread SECURITY_ATTRIBUTES
- false, // handles are not inheritable
- dwCreationFlags, // creation flags
- IntPtr.Zero, // pointer to new environment block
- null, // name of current directory
- ref si, // pointer to STARTUPINFO structure
- out procInfo // receives information about new process
- );
-
- // invalidate the handles
- CloseHandle(hProcess);
- CloseHandle(hPToken);
- CloseHandle(hUserTokenDup);
-
- return result; // return the result
- }
-
- #region Structures
-
- [StructLayout(LayoutKind.Sequential)]
- public struct SECURITY_ATTRIBUTES
- {
- public int Length;
- public IntPtr lpSecurityDescriptor;
- public bool bInheritHandle;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct STARTUPINFO
- {
- public int cb;
- public string lpReserved;
- public string lpDesktop;
- public string lpTitle;
- public uint dwX;
- public uint dwY;
- public uint dwXSize;
- public uint dwYSize;
- public uint dwXCountChars;
- public uint dwYCountChars;
- public uint dwFillAttribute;
- public uint dwFlags;
- public short wShowWindow;
- public short cbReserved2;
- public IntPtr lpReserved2;
- public IntPtr hStdInput;
- public IntPtr hStdOutput;
- public IntPtr hStdError;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct PROCESS_INFORMATION
- {
- public IntPtr hProcess;
- public IntPtr hThread;
- public uint dwProcessId;
- public uint dwThreadId;
- }
-
- #endregion
-
- #region Enumerations
-
- private enum TOKEN_TYPE
- {
- TokenPrimary = 1,
- TokenImpersonation = 2
- }
-
- private enum SECURITY_IMPERSONATION_LEVEL
- {
- 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 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;
-
- #endregion
-
- #region Win32 API Imports
-
- [DllImport("kernel32.dll", SetLastError = true)]
- private static extern bool CloseHandle(IntPtr hSnapshot);
-
- [DllImport("kernel32.dll")]
- private static extern uint WTSGetActiveConsoleSessionId();
-
- [DllImport("advapi32.dll", EntryPoint = "CreateProcessAsUser", SetLastError = true, CharSet = CharSet.Ansi,
- CallingConvention = CallingConvention.StdCall)]
- public static extern bool CreateProcessAsUser(IntPtr hToken, string lpApplicationName, string lpCommandLine,
- ref SECURITY_ATTRIBUTES lpProcessAttributes,
- ref SECURITY_ATTRIBUTES lpThreadAttributes, bool bInheritHandle, int dwCreationFlags, IntPtr lpEnvironment,
- string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation);
-
- [DllImport("kernel32.dll")]
- private static extern bool ProcessIdToSessionId(uint dwProcessId, ref uint pSessionId);
-
- [DllImport("advapi32.dll", EntryPoint = "DuplicateTokenEx")]
- public static extern bool DuplicateTokenEx(IntPtr ExistingTokenHandle, uint dwDesiredAccess,
- ref SECURITY_ATTRIBUTES lpThreadAttributes, int TokenType,
- int ImpersonationLevel, ref IntPtr DuplicateTokenHandle);
-
- [DllImport("kernel32.dll")]
- private static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, uint dwProcessId);
-
- [DllImport("advapi32", SetLastError = true), SuppressUnmanagedCodeSecurity]
- private static extern bool OpenProcessToken(IntPtr ProcessHandle, int DesiredAccess, ref IntPtr TokenHandle);
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/AgentInterface/FodyWeavers.xml b/AgentInterface/FodyWeavers.xml
deleted file mode 100644
index 52e39c5..0000000
--- a/AgentInterface/FodyWeavers.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/AgentInterface/FrameContract.cs b/AgentInterface/FrameContract.cs
deleted file mode 100644
index ac79e4d..0000000
--- a/AgentInterface/FrameContract.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System.ServiceModel;
-using AgentInterface.Api.Models;
-
-namespace AgentInterface
-{
- [ServiceContract(Namespace = "https://ulterius.io/")]
- public interface IFrameContract
- {
-
- [OperationContract]
- FrameInformation GetCleanFrame();
-
- [OperationContract]
- FrameInformation GetFullFrame();
-
- [OperationContract]
- bool KeepAlive();
-
- }
-}
\ No newline at end of file
diff --git a/AgentInterface/InputContract.cs b/AgentInterface/InputContract.cs
deleted file mode 100644
index 69e0401..0000000
--- a/AgentInterface/InputContract.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.ServiceModel;
-using System.Text;
-using System.Threading.Tasks;
-using AgentInterface.Api.Models;
-
-namespace AgentInterface
-{
- [ServiceContract(Namespace = "https://ulterius.io/")]
- public interface IInputContract
- {
-
- [OperationContract(IsOneWay = true)]
- void HandleRightMouseDown();
-
- [OperationContract(IsOneWay = true)]
- void HandleRightMouseUp();
-
- [OperationContract(IsOneWay = true)]
- void MoveMouse(int x, int y);
-
- [OperationContract(IsOneWay = true)]
- void MouseScroll(bool positive);
-
- [OperationContract(IsOneWay = true)]
- void HandleLeftMouseDown();
-
- [OperationContract(IsOneWay = true)]
- void HandleLeftMouseUp();
-
- [OperationContract(IsOneWay = true)]
- void HandleKeyDown(List keyCodes);
-
- [OperationContract(IsOneWay = true)]
- void HandleKeyUp(List keyCodes);
-
- [OperationContract(IsOneWay = true)]
- void HandleRightClick();
-
- [OperationContract]
- float GetGpuTemp(string gpuName);
-
- [OperationContract]
- List GetDisplayInformation();
-
- [OperationContract]
- List GetCpuTemps();
-
- }
-}
diff --git a/AgentInterface/Properties/AssemblyInfo.cs b/AgentInterface/Properties/AssemblyInfo.cs
deleted file mode 100644
index 327ea23..0000000
--- a/AgentInterface/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("AgentInterface")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Octopodal Solutions")]
-[assembly: AssemblyProduct("Ulterius")]
-[assembly: AssemblyCopyright("Copyright © 2016")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("5c3b0b17-cbb7-4b4b-b527-1fab2bb96466")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/AgentInterface/packages.config b/AgentInterface/packages.config
deleted file mode 100644
index 4fbf902..0000000
--- a/AgentInterface/packages.config
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Deps/OpenHardwareMonitorLib.dll b/Deps/OpenHardwareMonitorLib.dll
new file mode 100644
index 0000000..e059e78
Binary files /dev/null and b/Deps/OpenHardwareMonitorLib.dll differ
diff --git a/RemoteTaskServer/Api/Network/Messages/MessageBuilder.cs b/RemoteTaskServer/Api/Network/Messages/MessageBuilder.cs
index e3a8cfe..0aaea75 100644
--- a/RemoteTaskServer/Api/Network/Messages/MessageBuilder.cs
+++ b/RemoteTaskServer/Api/Network/Messages/MessageBuilder.cs
@@ -7,6 +7,7 @@
using UlteriusServer.Utilities.Security;
using UlteriusServer.WebSocketAPI.Authentication;
using vtortola.WebSockets;
+using vtortola.WebSockets.Http;
using static UlteriusServer.Utilities.Security.UlteriusAes;
#endregion
@@ -41,6 +42,7 @@ public void WriteMessage(object data)
if (_client != null && data != null)
{
+ var host = new Uri($"ws://{_client.HttpRequest.Headers[RequestHeader.Host]}", UriKind.Absolute);
JsonSerializerSettings settings = new JsonSerializerSettings {ContractResolver = new MessageResolver()};
var json = JsonConvert.SerializeObject(new
@@ -55,8 +57,11 @@ public void WriteMessage(object data)
{
if (_authClient != null)
{
+
if (_authClient.AesShook)
{
+
+
var keyBytes = Encoding.UTF8.GetBytes(Rsa.SecureStringToString(_authClient.AesKey));
var keyIv = Encoding.UTF8.GetBytes(Rsa.SecureStringToString(_authClient.AesIv));
@@ -71,7 +76,7 @@ public void WriteMessage(object data)
binaryWriter.Write(encryptedData);
}
var message = new Message(_client, memoryStream.ToArray(), Message.MessageType.Binary);
- var targetPort = _client.LocalEndpoint.Port;
+ var targetPort = host.Port;
_authClient?.MessageQueueManagers[targetPort]?.SendQueue.Add(message);
}
return;
@@ -88,7 +93,7 @@ public void WriteMessage(object data)
var jsonMessage = new Message(_client, json, Message.MessageType.Text);
if (_authClient != null)
{
- var targetPort = _client.LocalEndpoint.Port;
+ var targetPort = host.Port;
_authClient?.MessageQueueManagers[targetPort]?.SendQueue.Add(jsonMessage);
}
}
@@ -104,6 +109,7 @@ public void WriteScreenFrame(byte[] data)
if (_client == null || data == null) return;
try
{
+ var host = new Uri($"ws://{_client.HttpRequest.Headers[RequestHeader.Host]}", UriKind.Absolute);
if (_authClient == null) return;
if (!_authClient.AesShook) return;
var keyBytes = Encoding.UTF8.GetBytes(Rsa.SecureStringToString(_authClient.AesKey));
@@ -121,7 +127,7 @@ public void WriteScreenFrame(byte[] data)
binaryWriter.Write(encryptedData);
}
var message = new Message(_client, memoryStream.ToArray(), Message.MessageType.Binary);
- var targetPort = _client.LocalEndpoint.Port;
+ var targetPort = host.Port;
_authClient?.MessageQueueManagers[targetPort]?.SendQueue.Add(message);
}
}
diff --git a/RemoteTaskServer/Api/Network/Models/SystemInformation.cs b/RemoteTaskServer/Api/Network/Models/SystemInformation.cs
index a2b00a1..441966e 100644
--- a/RemoteTaskServer/Api/Network/Models/SystemInformation.cs
+++ b/RemoteTaskServer/Api/Network/Models/SystemInformation.cs
@@ -1,7 +1,7 @@
#region
using System.Collections.Generic;
-using AgentInterface.Api.Models;
+using UlteriusServer.Api.Win32.ScreenShare.Models;
#endregion
diff --git a/RemoteTaskServer/Api/Network/PacketHandlers/AccountPacketHandler.cs b/RemoteTaskServer/Api/Network/PacketHandlers/AccountPacketHandler.cs
index f974117..f7e03f2 100644
--- a/RemoteTaskServer/Api/Network/PacketHandlers/AccountPacketHandler.cs
+++ b/RemoteTaskServer/Api/Network/PacketHandlers/AccountPacketHandler.cs
@@ -6,7 +6,6 @@
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
-using AgentInterface.Settings;
using UlteriusServer.Api.Network.Messages;
using UlteriusServer.Utilities;
using UlteriusServer.WebSocketAPI.Authentication;
diff --git a/RemoteTaskServer/Api/Network/PacketHandlers/DisplayPacketHandler.cs b/RemoteTaskServer/Api/Network/PacketHandlers/DisplayPacketHandler.cs
index bd97a87..1cea03c 100644
--- a/RemoteTaskServer/Api/Network/PacketHandlers/DisplayPacketHandler.cs
+++ b/RemoteTaskServer/Api/Network/PacketHandlers/DisplayPacketHandler.cs
@@ -1,7 +1,7 @@
#region
-using AgentInterface.Api.Win32;
using UlteriusServer.Api.Network.Messages;
+using UlteriusServer.Api.Win32;
using UlteriusServer.WebSocketAPI.Authentication;
using vtortola.WebSockets;
@@ -43,18 +43,18 @@ public override void HandlePacket(Packet packet)
private void SetPrimaryDisplay()
{
- var device = _packet.Args[0].ToString();
+ /* var device = _packet.Args[0].ToString();
var message = Display.SetPrimary(device);
var formThread = new
{
message
};
- _builder.WriteMessage(formThread);
+ _builder.WriteMessage(formThread);*/
}
private void RotateDisplay()
{
- var width = int.Parse(_packet.Args[0].ToString());
+ /*var width = int.Parse(_packet.Args[0].ToString());
var height = int.Parse(_packet.Args[1].ToString());
var angle = int.Parse(_packet.Args[2].ToString());
var device = _packet.Args[3].ToString();
@@ -63,13 +63,13 @@ private void RotateDisplay()
{
message
};
- _builder.WriteMessage(formThread);
+ _builder.WriteMessage(formThread);*/
}
private void ChangeScreenResolution()
{
- var width = int.Parse(_packet.Args[0].ToString());
+ /*var width = int.Parse(_packet.Args[0].ToString());
var height = int.Parse(_packet.Args[1].ToString());
var bbp = int.Parse(_packet.Args[2].ToString());
var freq = int.Parse(_packet.Args[3].ToString());
@@ -79,7 +79,7 @@ private void ChangeScreenResolution()
{
message
};
- _builder.WriteMessage(formThread);
+ _builder.WriteMessage(formThread);*/
}
}
}
\ No newline at end of file
diff --git a/RemoteTaskServer/Api/Network/PacketHandlers/FilePacketHandler.cs b/RemoteTaskServer/Api/Network/PacketHandlers/FilePacketHandler.cs
index 4e742bd..8f83fb7 100644
--- a/RemoteTaskServer/Api/Network/PacketHandlers/FilePacketHandler.cs
+++ b/RemoteTaskServer/Api/Network/PacketHandlers/FilePacketHandler.cs
@@ -6,9 +6,9 @@
using System.IO;
using System.Linq;
using System.Text;
-using AgentInterface.Settings;
using UlteriusServer.Api.Network.Messages;
using UlteriusServer.Api.Services.Network;
+using UlteriusServer.Utilities;
using UlteriusServer.Utilities.Extensions;
using UlteriusServer.Utilities.Files;
using UlteriusServer.Utilities.Security;
diff --git a/RemoteTaskServer/Api/Network/PacketHandlers/GpuPacketHandler.cs b/RemoteTaskServer/Api/Network/PacketHandlers/GpuPacketHandler.cs
index 388d2f0..c4fab49 100644
--- a/RemoteTaskServer/Api/Network/PacketHandlers/GpuPacketHandler.cs
+++ b/RemoteTaskServer/Api/Network/PacketHandlers/GpuPacketHandler.cs
@@ -3,7 +3,6 @@
using System.Linq;
using System.Management;
using System.Runtime.ExceptionServices;
-using AgentInterface.Api.System;
using UlteriusServer.Api.Network.Messages;
using UlteriusServer.Api.Network.Models;
using UlteriusServer.WebSocketAPI.Authentication;
@@ -54,9 +53,7 @@ public void GetGpuInformation()
private float? GetGpuTemp(string gpuName)
{
- return UlteriusApiServer.RunningAsService
- ? UlteriusApiServer.AgentClient.GetGpuTemp(gpuName)
- : SystemData.GetGpuTemp(gpuName);
+ return SystemData.GetGpuTemp(gpuName);
}
diff --git a/RemoteTaskServer/Api/Network/PacketHandlers/ProcessPacketHandler.cs b/RemoteTaskServer/Api/Network/PacketHandlers/ProcessPacketHandler.cs
index 00a868e..a8565ad 100644
--- a/RemoteTaskServer/Api/Network/PacketHandlers/ProcessPacketHandler.cs
+++ b/RemoteTaskServer/Api/Network/PacketHandlers/ProcessPacketHandler.cs
@@ -7,9 +7,9 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
-using AgentInterface.Api.Win32;
using UlteriusServer.Api.Network.Messages;
using UlteriusServer.Api.Network.Models;
+using UlteriusServer.Api.Win32;
using UlteriusServer.Utilities;
using UlteriusServer.WebSocketAPI.Authentication;
using vtortola.WebSockets;
@@ -33,29 +33,10 @@ public void StartProcess()
var processId = -1;
try
{
- if (Environment.UserName.Equals("SYSTEM") && Tools.RunningPlatform() == Tools.Platform.Windows)
- {
- var task = Task.Run(() =>
- {
- try
- {
- ProcessStarter.PROCESS_INFORMATION procInfo;
- ProcessStarter.StartProcessAndBypassUAC(path, out procInfo);
- }
- catch (Exception)
- {
- //continue
- }
- });
- processStarted = task.Wait(TimeSpan.FromSeconds(5));
- }
- else
- {
- var processStartInfo = new ProcessStartInfo(path);
- var process = new Process {StartInfo = processStartInfo};
- processStarted = process.Start();
- processId = process.Id;
- }
+ var processStartInfo = new ProcessStartInfo(path);
+ var process = new Process { StartInfo = processStartInfo };
+ processStarted = process.Start();
+ processId = process.Id;
}
catch (Exception ex)
{
diff --git a/RemoteTaskServer/Api/Network/PacketHandlers/ScreenSharePacketHandler.cs b/RemoteTaskServer/Api/Network/PacketHandlers/ScreenSharePacketHandler.cs
index 0cacf9e..69921a7 100644
--- a/RemoteTaskServer/Api/Network/PacketHandlers/ScreenSharePacketHandler.cs
+++ b/RemoteTaskServer/Api/Network/PacketHandlers/ScreenSharePacketHandler.cs
@@ -10,10 +10,10 @@
using System.Windows.Forms;
using WindowsInput;
using WindowsInput.Native;
-using AgentInterface.Api.ScreenShare;
-using AgentInterface.Api.ScreenShare.DesktopDuplication;
-using AgentInterface.Api.Win32;
using UlteriusServer.Api.Network.Messages;
+using UlteriusServer.Api.Win32;
+using UlteriusServer.Api.Win32.ScreenShare;
+using UlteriusServer.Api.Win32.ScreenShare.DesktopDuplication;
using UlteriusServer.WebSocketAPI.Authentication;
using vtortola.WebSockets;
using static UlteriusServer.Api.UlteriusApiServer;
@@ -125,9 +125,7 @@ public void StartScreenShare()
return;
}
_authClient.ShutDownScreenShare = false;
- var stream = RunningAsService
- ? new Thread(GetScreenAgentFrame) { IsBackground = true }
- : new Thread(GetScreenFrame) { IsBackground = true };
+ var stream = new Thread(GetScreenFrame) { IsBackground = true };
ScreenShareService.Streams[_authClient] = stream;
var data = new
{
@@ -148,41 +146,6 @@ public void StartScreenShare()
}
}
-
- private void GetScreenAgentFrame()
- {
- try
- {
- while (_client != null && _client.IsConnected && _authClient != null &&
- !_authClient.ShutDownScreenShare)
- {
- try
- {
- var image = AgentClient.GetCleanFrame();
- if (image != null)
- {
- if (image.UsingGpu)
- {
- SendGpuFrame(image.FinishedRegions);
- }
- else
- {
- SendPolledFrame(image.ScreenImage, image.Bounds);
- }
- }
- }
- catch (Exception e)
- {
- // Console.WriteLine(e.Message + " " + e.StackTrace);
- }
- }
- Console.WriteLine("Screen Share Died");
- }
- catch (Exception)
- {
- }
- }
-
private void SendGpuFrame(FinishedRegions[] gpuFrame)
{
if (gpuFrame == null)
@@ -208,6 +171,10 @@ private void GetScreenFrame()
while (_client != null && _client.IsConnected && _authClient != null &&
!_authClient.ShutDownScreenShare)
{
+ if (RunningAsService && DesktopWatcher.CurrentDesktop != null)
+ {
+ Desktop.SetCurrent(DesktopWatcher.CurrentDesktop);
+ }
try
{
var image = ScreenData.DesktopCapture();
@@ -243,6 +210,10 @@ private void SendPolledFrame(Bitmap screenImage, Rectangle bounds)
public override void HandlePacket(Packet packet)
{
+ if (RunningAsService && DesktopWatcher.CurrentDesktop != null)
+ {
+ Desktop.SetCurrent(DesktopWatcher.CurrentDesktop);
+ }
_client = packet.Client;
_authClient = packet.AuthClient;
_packet = packet;
@@ -276,14 +247,7 @@ public override void HandlePacket(Packet packet)
HandleKeyUp();
break;
case PacketManager.EndPoints.FullFrame:
- if (RunningAsService)
- {
- HandleAgentFullFrame();
- }
- else
- {
- HandleFullFrame();
- }
+ HandleFullFrame();
break;
case PacketManager.EndPoints.RightClick:
HandleRightClick();
@@ -316,68 +280,12 @@ private void HandleCtrlAltDel()
private void RightUp()
{
- if (!ScreenShareService.Streams.ContainsKey(_authClient)) return;
- if (RunningAsService)
- {
- AgentClient.HandleRightMouseUp();
- }
- else
- {
- new InputSimulator().Mouse.RightButtonUp();
- }
+ new InputSimulator().Mouse.RightButtonUp();
}
private void RightDown()
{
- if (!ScreenShareService.Streams.ContainsKey(_authClient)) return;
- if (RunningAsService)
- {
- AgentClient.HandleRightMouseDown();
- }
- else
- {
- new InputSimulator().Mouse.RightButtonDown();
- }
- }
-
- private void HandleAgentFullFrame()
- {
- try
- {
- var fullFrameData = AgentClient.GetFullFrame();
- if (fullFrameData?.ScreenImage == null) throw new InvalidOperationException("Frame was null");
- var bounds = fullFrameData.Bounds;
- var image = ScreenData.ImageToByteArray(fullFrameData.ScreenImage);
- var frameData = new
- {
- screenBounds = new
- {
- top = bounds.Top,
- bottom = bounds.Bottom,
- left = bounds.Left,
- right = bounds.Right,
- height = bounds.Height,
- width = bounds.Width,
- x = bounds.X,
- y = bounds.Y,
- empty = bounds.IsEmpty,
- location = bounds.Location,
- size = bounds.Size
- },
- frameData = image.Select(b => (int)b).ToArray()
- };
- _builder.WriteMessage(frameData);
- }
- catch (Exception ex)
- {
- var data = new
- {
- frameFailed = true,
- message = ex.Message
- };
- Console.WriteLine(ex.Message + "Fuck");
- _builder.WriteMessage(data);
- }
+ new InputSimulator().Mouse.RightButtonDown();
}
private void HandleFullFrame()
@@ -427,7 +335,6 @@ private void HandleFullFrame()
private void HandleKeyUp()
{
- if (!ScreenShareService.Streams.ContainsKey(_authClient)) return;
var keyCodes = ((IEnumerable)_packet.Args[0]).Cast