mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
NamedPipe for Division WIP
This commit is contained in:
parent
a31a33a6c9
commit
3c4b750b1e
@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Security.Principal;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
|
using Artemis.Utilities;
|
||||||
using WpfExceptionViewer;
|
using WpfExceptionViewer;
|
||||||
|
|
||||||
namespace Artemis
|
namespace Artemis
|
||||||
@ -15,42 +13,14 @@ namespace Artemis
|
|||||||
{
|
{
|
||||||
public App()
|
public App()
|
||||||
{
|
{
|
||||||
if (!IsRunAsAdministrator())
|
if (!GeneralHelpers.IsRunAsAdministrator())
|
||||||
{
|
GeneralHelpers.RunAsAdministrator();
|
||||||
var processInfo = new ProcessStartInfo(Assembly.GetExecutingAssembly().CodeBase);
|
|
||||||
|
|
||||||
// The following properties run the new process as administrator
|
|
||||||
processInfo.UseShellExecute = true;
|
|
||||||
processInfo.Verb = "runas";
|
|
||||||
|
|
||||||
// Start the new process
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Process.Start(processInfo);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
// The user did not allow the application to run as administrator
|
|
||||||
MessageBox.Show("Sorry, this application must be run as Administrator.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shut down the current process
|
|
||||||
Environment.Exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DoHandle { get; set; }
|
public bool DoHandle { get; set; }
|
||||||
|
|
||||||
private bool IsRunAsAdministrator()
|
|
||||||
{
|
|
||||||
var wi = WindowsIdentity.GetCurrent();
|
|
||||||
var wp = new WindowsPrincipal(wi);
|
|
||||||
|
|
||||||
return wp.IsInRole(WindowsBuiltInRole.Administrator);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Application_Startup(object sender, StartupEventArgs e)
|
private void Application_Startup(object sender, StartupEventArgs e)
|
||||||
{
|
{
|
||||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
|
|||||||
@ -163,6 +163,10 @@
|
|||||||
<Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="NamedPipeWrapper, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\NamedPipeWrapper.1.4.0\lib\net40\NamedPipeWrapper.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="NAudio, Version=1.7.3.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="NAudio, Version=1.7.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\NAudio.1.7.3\lib\net35\NAudio.dll</HintPath>
|
<HintPath>..\packages\NAudio.1.7.3\lib\net35\NAudio.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
@ -271,12 +275,15 @@
|
|||||||
<DependentUpon>AmbientLightningEffectView.xaml</DependentUpon>
|
<DependentUpon>AmbientLightningEffectView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Modules\Effects\AmbientLightning\AmbientLightningEffectViewModel.cs" />
|
<Compile Include="Modules\Effects\AmbientLightning\AmbientLightningEffectViewModel.cs" />
|
||||||
|
<Compile Include="Modules\Effects\AmbientLightning\ScreenCapture.cs" />
|
||||||
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualization.Designer.cs">
|
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualization.Designer.cs">
|
||||||
<DependentUpon>AudioVisualization.settings</DependentUpon>
|
<DependentUpon>AudioVisualization.settings</DependentUpon>
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerModel.cs" />
|
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerModel.cs" />
|
||||||
|
<Compile Include="Modules\Effects\AudioVisualizer\Utilities\FftEventArgs.cs" />
|
||||||
|
<Compile Include="Modules\Effects\AudioVisualizer\Utilities\SampleAggregator.cs" />
|
||||||
<Compile Include="Modules\Effects\Debug\DebugEffectModel.cs" />
|
<Compile Include="Modules\Effects\Debug\DebugEffectModel.cs" />
|
||||||
<Compile Include="Modules\Effects\TypeHole\TypeHoleModel.cs" />
|
<Compile Include="Modules\Effects\TypeHole\TypeHoleModel.cs" />
|
||||||
<Compile Include="Modules\Effects\TypeWave\TypeWave.Designer.cs">
|
<Compile Include="Modules\Effects\TypeWave\TypeWave.Designer.cs">
|
||||||
@ -346,21 +353,20 @@
|
|||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
<DependentUpon>Offsets.settings</DependentUpon>
|
<DependentUpon>Offsets.settings</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Utilities\Audio\FftEventArgs.cs" />
|
|
||||||
<Compile Include="Utilities\Audio\SampleAggregator.cs" />
|
|
||||||
<Compile Include="Utilities\ColorHelpers.cs" />
|
<Compile Include="Utilities\ColorHelpers.cs" />
|
||||||
<Compile Include="Utilities\GameState\GameDataReceivedEventArgs.cs" />
|
<Compile Include="Utilities\GameState\GameDataReceivedEventArgs.cs" />
|
||||||
<Compile Include="Utilities\GameState\GameStateWebServer.cs" />
|
<Compile Include="Utilities\GameState\GameStateWebServer.cs" />
|
||||||
|
<Compile Include="Utilities\GeneralHelpers.cs" />
|
||||||
<Compile Include="Utilities\ImageUtilities.cs" />
|
<Compile Include="Utilities\ImageUtilities.cs" />
|
||||||
<Compile Include="Utilities\Keyboard\KeyboardHook.cs" />
|
<Compile Include="Utilities\Keyboard\KeyboardHook.cs" />
|
||||||
<Compile Include="Utilities\LogitechDll\DllManager.cs" />
|
<Compile Include="Utilities\LogitechDll\DllManager.cs" />
|
||||||
|
<Compile Include="Utilities\LogitechDll\LogitechNamedPipe.cs" />
|
||||||
<Compile Include="Utilities\Memory\GamePointer.cs" />
|
<Compile Include="Utilities\Memory\GamePointer.cs" />
|
||||||
<Compile Include="Utilities\Memory\Memory.cs" />
|
<Compile Include="Utilities\Memory\Memory.cs" />
|
||||||
<Compile Include="Utilities\Memory\MemoryHelpers.cs" />
|
<Compile Include="Utilities\Memory\MemoryHelpers.cs" />
|
||||||
<Compile Include="Utilities\Memory\Win32.cs" />
|
<Compile Include="Utilities\Memory\Win32.cs" />
|
||||||
<Compile Include="Utilities\Keyboard\Key.cs" />
|
<Compile Include="Utilities\Keyboard\Key.cs" />
|
||||||
<Compile Include="Utilities\Keyboard\KeyboardRectangle.cs" />
|
<Compile Include="Utilities\Keyboard\KeyboardRectangle.cs" />
|
||||||
<Compile Include="Utilities\ScreenCapture.cs" />
|
|
||||||
<Compile Include="Utilities\ShellLink.cs" />
|
<Compile Include="Utilities\ShellLink.cs" />
|
||||||
<Compile Include="Utilities\Updater.cs" />
|
<Compile Include="Utilities\Updater.cs" />
|
||||||
<Compile Include="ViewModels\Abstract\EffectViewModel.cs" />
|
<Compile Include="ViewModels\Abstract\EffectViewModel.cs" />
|
||||||
|
|||||||
@ -1,14 +1,13 @@
|
|||||||
using System;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Artemis.Utilities;
|
||||||
using Artemis.Utilities.LogitechDll;
|
using Artemis.Utilities.LogitechDll;
|
||||||
using Artemis.ViewModels;
|
using Artemis.ViewModels;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using Caliburn.Micro.Autofac;
|
using Caliburn.Micro.Autofac;
|
||||||
using Microsoft.Win32;
|
|
||||||
using Application = System.Windows.Application;
|
using Application = System.Windows.Application;
|
||||||
using MessageBox = System.Windows.Forms.MessageBox;
|
using MessageBox = System.Windows.Forms.MessageBox;
|
||||||
|
|
||||||
@ -18,8 +17,10 @@ namespace Artemis
|
|||||||
{
|
{
|
||||||
public ArtemisBootstrapper()
|
public ArtemisBootstrapper()
|
||||||
{
|
{
|
||||||
//CheckDuplicateInstances();
|
CheckDuplicateInstances();
|
||||||
DllManager.RestoreDll();
|
if (DllManager.RestoreDll())
|
||||||
|
GeneralHelpers.RunAsAdministrator();
|
||||||
|
|
||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ using MapFlags = SharpDX.DXGI.MapFlags;
|
|||||||
using Resource = SharpDX.DXGI.Resource;
|
using Resource = SharpDX.DXGI.Resource;
|
||||||
using ResultCode = SharpDX.DXGI.ResultCode;
|
using ResultCode = SharpDX.DXGI.ResultCode;
|
||||||
|
|
||||||
namespace Artemis.Utilities
|
namespace Artemis.Modules.Effects.AmbientLightning
|
||||||
{
|
{
|
||||||
internal class ScreenCapture : IDisposable
|
internal class ScreenCapture : IDisposable
|
||||||
{
|
{
|
||||||
@ -5,8 +5,8 @@ using System.Drawing.Drawing2D;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
|
using Artemis.Modules.Effects.AudioVisualizer.Utilities;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using Artemis.Utilities.Audio;
|
|
||||||
using Artemis.Utilities.Keyboard;
|
using Artemis.Utilities.Keyboard;
|
||||||
using NAudio.CoreAudioApi;
|
using NAudio.CoreAudioApi;
|
||||||
using NAudio.Wave;
|
using NAudio.Wave;
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using NAudio.Dsp;
|
using NAudio.Dsp;
|
||||||
|
|
||||||
namespace Artemis.Utilities.Audio
|
namespace Artemis.Modules.Effects.AudioVisualizer.Utilities
|
||||||
{
|
{
|
||||||
public class FftEventArgs : EventArgs
|
public class FftEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using NAudio.Dsp;
|
using NAudio.Dsp;
|
||||||
|
|
||||||
namespace Artemis.Utilities.Audio
|
namespace Artemis.Modules.Effects.AudioVisualizer.Utilities
|
||||||
{ // The Complex and FFT are here!
|
{ // The Complex and FFT are here!
|
||||||
|
|
||||||
public class SampleAggregator
|
public class SampleAggregator
|
||||||
48
Artemis/Artemis/Utilities/GeneralHelpers.cs
Normal file
48
Artemis/Artemis/Utilities/GeneralHelpers.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Security.Principal;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace Artemis.Utilities
|
||||||
|
{
|
||||||
|
public static class GeneralHelpers
|
||||||
|
{
|
||||||
|
public static void RunAsAdministrator()
|
||||||
|
{
|
||||||
|
var processInfo = new ProcessStartInfo(Assembly.GetExecutingAssembly().CodeBase)
|
||||||
|
{
|
||||||
|
UseShellExecute = true,
|
||||||
|
Verb = "runas"
|
||||||
|
};
|
||||||
|
|
||||||
|
// The following properties run the new process as administrator
|
||||||
|
|
||||||
|
// Start the new process
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Process.Start(processInfo);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// The user did not allow the application to run as administrator
|
||||||
|
MessageBox.Show("Sorry, this application must be run as Administrator.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shut down the current process
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsRunAsAdministrator()
|
||||||
|
{
|
||||||
|
var wi = WindowsIdentity.GetCurrent();
|
||||||
|
var wp = new WindowsPrincipal(wi);
|
||||||
|
|
||||||
|
return wp.IsInRole(WindowsBuiltInRole.Administrator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -6,16 +6,20 @@ namespace Artemis.Utilities.LogitechDll
|
|||||||
{
|
{
|
||||||
internal static class DllManager
|
internal static class DllManager
|
||||||
{
|
{
|
||||||
public static void RestoreDll()
|
private const string LogitechPath = @"C:\Program Files\Logitech Gaming Software\SDK\LED\x64\";
|
||||||
|
|
||||||
|
public static bool RestoreDll()
|
||||||
{
|
{
|
||||||
if (!BackupAvailable())
|
if (!File.Exists(LogitechPath + @"\LogitechLed.dll.bak"))
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
// Get rid of our own DLL
|
// Get rid of our own DLL
|
||||||
File.Delete(@"C:\Program Files\Logitech Gaming Software\SDK\LED\x64\LogitechLed.dll");
|
File.Delete(LogitechPath + @"\LogitechLed.dll");
|
||||||
// Restore the backup
|
// Restore the backup
|
||||||
File.Move(@"C:\Program Files\Logitech Gaming Software\SDK\LED\x64\LogitechLed.dll.bak",
|
File.Move(LogitechPath + @"\LogitechLed.dll.bak",
|
||||||
@"C:\Program Files\Logitech Gaming Software\SDK\LED\x64\LogitechLed.dll");
|
LogitechPath + @"\LogitechLed.dll");
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void PlaceDll()
|
public static void PlaceDll()
|
||||||
@ -24,19 +28,19 @@ namespace Artemis.Utilities.LogitechDll
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Create directory structure, just in case
|
// Create directory structure, just in case
|
||||||
Directory.CreateDirectory(@"C:\Program Files\Logitech Gaming Software\SDK\LED\x64");
|
Directory.CreateDirectory(LogitechPath + @"");
|
||||||
|
|
||||||
// Remove old backups if they are there
|
// Remove old backups if they are there
|
||||||
if (BackupAvailable())
|
if (File.Exists(LogitechPath + @"\LogitechLed.dll.bak"))
|
||||||
File.Delete(@"C:\Program Files\Logitech Gaming Software\SDK\LED\x64\LogitechLed.dll.bak");
|
File.Delete(LogitechPath + @"\LogitechLed.dll.bak");
|
||||||
|
|
||||||
// Backup the existing DLL
|
// Backup the existing DLL
|
||||||
if (File.Exists(@"C:\Program Files\Logitech Gaming Software\SDK\LED\x64\LogitechLed.dll"))
|
if (File.Exists(LogitechPath + @"\LogitechLed.dll"))
|
||||||
File.Move(@"C:\Program Files\Logitech Gaming Software\SDK\LED\x64\LogitechLed.dll",
|
File.Move(LogitechPath + @"\LogitechLed.dll",
|
||||||
@"C:\Program Files\Logitech Gaming Software\SDK\LED\x64\LogitechLed.dll.bak");
|
LogitechPath + @"\LogitechLed.dll.bak");
|
||||||
|
|
||||||
// Copy our own DLL in place
|
// Copy our own DLL in place
|
||||||
File.WriteAllBytes(@"C:\Program Files\Logitech Gaming Software\SDK\LED\x64\LogitechLED.dll",
|
File.WriteAllBytes(LogitechPath + @"\LogitechLED.dll",
|
||||||
Resources.LogitechLED);
|
Resources.LogitechLED);
|
||||||
|
|
||||||
// If the user doesn't have a Logitech device, the CLSID will be missing
|
// If the user doesn't have a Logitech device, the CLSID will be missing
|
||||||
@ -47,17 +51,12 @@ namespace Artemis.Utilities.LogitechDll
|
|||||||
|
|
||||||
public static bool DllPlaced()
|
public static bool DllPlaced()
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(@"C:\Program Files\Logitech Gaming Software\SDK\LED\x64"))
|
if (!Directory.Exists(LogitechPath + @""))
|
||||||
return false;
|
return false;
|
||||||
if (!RegistryKeyPlaced())
|
if (!RegistryKeyPlaced())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return File.Exists(@"C:\Program Files\Logitech Gaming Software\SDK\LED\x64\LogitechLed.dll");
|
return File.Exists(LogitechPath + @"\LogitechLed.dll");
|
||||||
}
|
|
||||||
|
|
||||||
private static bool BackupAvailable()
|
|
||||||
{
|
|
||||||
return File.Exists(@"C:\Program Files\Logitech Gaming Software\SDK\LED\x64\LogitechLed.dll.bak");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool RegistryKeyPlaced()
|
private static bool RegistryKeyPlaced()
|
||||||
@ -73,7 +72,7 @@ namespace Artemis.Utilities.LogitechDll
|
|||||||
var key = Registry
|
var key = Registry
|
||||||
.LocalMachine.OpenSubKey(
|
.LocalMachine.OpenSubKey(
|
||||||
@"SOFTWARE\Classes\CLSID\{a6519e67-7632-4375-afdf-caa889744403}\ServerBinary", true);
|
@"SOFTWARE\Classes\CLSID\{a6519e67-7632-4375-afdf-caa889744403}\ServerBinary", true);
|
||||||
key?.SetValue(null, @"C:\Program Files\Logitech Gaming Software\SDK\LED\x64\LogitechLed.dll");
|
key?.SetValue(null, LogitechPath + @"\LogitechLed.dll");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
23
Artemis/Artemis/Utilities/LogitechDll/LogitechNamedPipe.cs
Normal file
23
Artemis/Artemis/Utilities/LogitechDll/LogitechNamedPipe.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using NamedPipeWrapper;
|
||||||
|
|
||||||
|
namespace Artemis.Utilities.LogitechDll
|
||||||
|
{
|
||||||
|
public class LogitechNamedPipe
|
||||||
|
{
|
||||||
|
public LogitechNamedPipe()
|
||||||
|
{
|
||||||
|
LogitechPipe = new NamedPipeServer<string>("ArtemisLogitech");
|
||||||
|
|
||||||
|
LogitechPipe.ClientMessage += LogitechPipeOnClientMessage;
|
||||||
|
LogitechPipe.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamedPipeServer<string> LogitechPipe { get; set; }
|
||||||
|
|
||||||
|
private void LogitechPipeOnClientMessage(NamedPipeConnection<string, string> connection, string message)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -12,6 +12,7 @@
|
|||||||
<package id="log4net" version="2.0.5" targetFramework="net452" />
|
<package id="log4net" version="2.0.5" targetFramework="net452" />
|
||||||
<package id="MahApps.Metro" version="1.2.4.0" targetFramework="net452" />
|
<package id="MahApps.Metro" version="1.2.4.0" targetFramework="net452" />
|
||||||
<package id="MahApps.Metro.Resources" version="0.4.0.0" targetFramework="net452" />
|
<package id="MahApps.Metro.Resources" version="0.4.0.0" targetFramework="net452" />
|
||||||
|
<package id="NamedPipeWrapper" version="1.4.0" targetFramework="net452" />
|
||||||
<package id="NAudio" version="1.7.3" targetFramework="net452" />
|
<package id="NAudio" version="1.7.3" targetFramework="net452" />
|
||||||
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net452" />
|
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net452" />
|
||||||
<package id="SharpDX" version="3.0.1" targetFramework="net452" />
|
<package id="SharpDX" version="3.0.1" targetFramework="net452" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user