Merge branch 'main' into AllyTDP
@@ -88,6 +88,7 @@ namespace GHelper.AnimeMatrix
|
|||||||
{
|
{
|
||||||
deviceSlash.Init();
|
deviceSlash.Init();
|
||||||
deviceSlash.SetOptions(false, 0, 0);
|
deviceSlash.SetOptions(false, 0, 0);
|
||||||
|
deviceSlash.SetSleepActive(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -98,12 +99,11 @@ namespace GHelper.AnimeMatrix
|
|||||||
}
|
}
|
||||||
|
|
||||||
deviceSlash.Init();
|
deviceSlash.Init();
|
||||||
|
|
||||||
switch ((SlashMode)running)
|
switch ((SlashMode)running)
|
||||||
{
|
{
|
||||||
case SlashMode.Static:
|
case SlashMode.Static:
|
||||||
deviceSlash.SetStatic();
|
deviceSlash.SetStatic(brightness);
|
||||||
deviceSlash.Save();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
deviceSlash.SetMode((SlashMode)running);
|
deviceSlash.SetMode((SlashMode)running);
|
||||||
@@ -111,6 +111,8 @@ namespace GHelper.AnimeMatrix
|
|||||||
deviceSlash.Save();
|
deviceSlash.Save();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deviceSlash.SetSleepActive(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -118,7 +120,11 @@ namespace GHelper.AnimeMatrix
|
|||||||
public void SetLidMode(bool force = false)
|
public void SetLidMode(bool force = false)
|
||||||
{
|
{
|
||||||
bool matrixLid = AppConfig.Is("matrix_lid");
|
bool matrixLid = AppConfig.Is("matrix_lid");
|
||||||
if (deviceSlash is not null) deviceSlash.SetLidMode(matrixLid);
|
|
||||||
|
if (deviceSlash is not null)
|
||||||
|
{
|
||||||
|
deviceSlash.SetLidMode(matrixLid);
|
||||||
|
}
|
||||||
|
|
||||||
if (matrixLid || force)
|
if (matrixLid || force)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -117,10 +117,15 @@ namespace GHelper.AnimeMatrix
|
|||||||
Set(Packet<SlashPacket>(0xD3, 0x04, 0x00, 0x0C, 0x01, modeByte, 0x02, 0x19, 0x03, 0x13, 0x04, 0x11, 0x05, 0x12, 0x06, 0x13), "SlashMode");
|
Set(Packet<SlashPacket>(0xD3, 0x04, 0x00, 0x0C, 0x01, modeByte, 0x02, 0x19, 0x03, 0x13, 0x04, 0x11, 0x05, 0x12, 0x06, 0x13), "SlashMode");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetStatic()
|
public void SetStatic(int brightness = 0)
|
||||||
{
|
{
|
||||||
Set(Packet<SlashPacket>(0xD3, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), "StaticWhite");
|
byte brightnessByte = (byte)(brightness * 85.333);
|
||||||
Set(Packet<SlashPacket>(0xD3, 0x00, 0x00, 0x01, 0xAC), "Static");
|
|
||||||
|
Set(Packet<SlashPacket>(0xD2, 0x02, 0x01, 0x08, 0xAC), "Static");
|
||||||
|
Set(Packet<SlashPacket>(0xD3, 0x03, 0x01, 0x08, 0xAC, 0xFF, 0xFF, 0x01, 0x05, 0xFF, 0xFF), "StaticSettings");
|
||||||
|
Set(Packet<SlashPacket>(0xD4, 0x00, 0x00, 0x01, 0xAC), "StaticSave");
|
||||||
|
|
||||||
|
Set(Packet<SlashPacket>(0xD3, 0x00, 0x00, 0x07, brightnessByte, brightnessByte, brightnessByte, brightnessByte, brightnessByte, brightnessByte, brightnessByte), "Static White");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetOptions(bool status, int brightness = 0, int interval = 0)
|
public void SetOptions(bool status, int brightness = 0, int interval = 0)
|
||||||
@@ -132,12 +137,18 @@ namespace GHelper.AnimeMatrix
|
|||||||
|
|
||||||
public void SetBatterySaver(bool status)
|
public void SetBatterySaver(bool status)
|
||||||
{
|
{
|
||||||
Set(Packet<SlashPacket>(0xD8, 0x01, 0x00, 0x01, status ? (byte)0x80 : (byte)0x00), "SlashBatterySaver");
|
Set(Packet<SlashPacket>(0xD8, 0x01, 0x00, 0x01, status ? (byte)0x80 : (byte)0x00), $"SlashBatterySaver {status}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetLidMode(bool status)
|
public void SetLidMode(bool status)
|
||||||
{
|
{
|
||||||
Set(Packet<SlashPacket>(0xD8, 0x00, 0x00, 0x02, 0xA5, status ? (byte)0x80 : (byte)0x00));
|
Set(Packet<SlashPacket>(0xD8, 0x00, 0x00, 0x02, 0xA5, status ? (byte)0x80 : (byte)0x00), $"DisableLidClose {status}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetSleepActive(bool status)
|
||||||
|
{
|
||||||
|
Set(Packet<SlashPacket>(0xD2, 0x02, 0x01, 0x08, 0xA1), "SleepInit");
|
||||||
|
Set(Packet<SlashPacket>(0xD3, 0x03, 0x01, 0x08, 0xA1, 0x00, 0xFF, status ? (byte)0x01 : (byte)0x00, 0x02, 0xFF, 0xFF), $"Sleep {status}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Set(Packet packet, string? log = null)
|
public void Set(Packet packet, string? log = null)
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ public static class AppConfig
|
|||||||
|
|
||||||
public static bool IsOLED()
|
public static bool IsOLED()
|
||||||
{
|
{
|
||||||
return ContainsModel("OLED") || IsSlash() || ContainsModel("M7600") || ContainsModel("UX64") || ContainsModel("UX34") || ContainsModel("UX53") || ContainsModel("K360") || ContainsModel("X150") || ContainsModel("M350") || ContainsModel("K650") || ContainsModel("UM53") || ContainsModel("K660") || ContainsModel("UX84") || ContainsModel("M650") || ContainsModel("K340") || ContainsModel("K350") || ContainsModel("M140");
|
return ContainsModel("OLED") || IsSlash() || ContainsModel("M7600") || ContainsModel("UX64") || ContainsModel("UX34") || ContainsModel("UX53") || ContainsModel("K360") || ContainsModel("X150") || ContainsModel("M350") || ContainsModel("K650") || ContainsModel("UM53") || ContainsModel("K660") || ContainsModel("UX84") || ContainsModel("M650") || ContainsModel("K340") || ContainsModel("K350") || ContainsModel("M140") || ContainsModel("UM340");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsNoOverdrive()
|
public static bool IsNoOverdrive()
|
||||||
|
|||||||
@@ -866,14 +866,23 @@ namespace GHelper
|
|||||||
|
|
||||||
private void VisualizeCurrentDPIProfile()
|
private void VisualizeCurrentDPIProfile()
|
||||||
{
|
{
|
||||||
if (mouse.DpiProfile > mouse.DpiSettings.Count())
|
if (mouse.DpiProfile > mouse.DpiSettings.Length)
|
||||||
{
|
{
|
||||||
Logger.WriteLine($"Wrong mouse DPI: {mouse.DpiProfile}");
|
Logger.WriteLine($"Wrong mouse DPI: {mouse.DpiProfile}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AsusMouseDPI dpi = mouse.DpiSettings[mouse.DpiProfile - 1];
|
AsusMouseDPI dpi;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
dpi = mouse.DpiSettings[mouse.DpiProfile - 1];
|
||||||
|
} catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.WriteLine($"Wrong mouse DPI: {mouse.DpiProfile} {mouse.DpiSettings.Length} {ex.Message}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (dpi is null)
|
if (dpi is null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -66,6 +66,11 @@ namespace GHelper.Display
|
|||||||
return Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\ASUS\\ASUS System Control Interface\\ASUSOptimization\\Splendid";
|
return Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\ASUS\\ASUS System Control Interface\\ASUSOptimization\\Splendid";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SplendidGamut GetDefaultGamut()
|
||||||
|
{
|
||||||
|
return AppConfig.IsVivoZenbook() ? SplendidGamut.VivoNative : SplendidGamut.Native;
|
||||||
|
}
|
||||||
|
|
||||||
public static Dictionary<SplendidGamut, string> GetGamutModes()
|
public static Dictionary<SplendidGamut, string> GetGamutModes()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -104,6 +109,11 @@ namespace GHelper.Display
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SplendidCommand GetDefaultVisualMode()
|
||||||
|
{
|
||||||
|
return AppConfig.IsVivoZenbook() ? SplendidCommand.VivoNormal : SplendidCommand.Default;
|
||||||
|
}
|
||||||
|
|
||||||
public static Dictionary<SplendidCommand, string> GetVisualModes()
|
public static Dictionary<SplendidCommand, string> GetVisualModes()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ namespace GHelper.Fan
|
|||||||
if (AppConfig.ContainsModel("FA507R")) return new int[3] { 63, 57, DEFAULT_FAN_MAX };
|
if (AppConfig.ContainsModel("FA507R")) return new int[3] { 63, 57, DEFAULT_FAN_MAX };
|
||||||
if (AppConfig.ContainsModel("FA507X")) return new int[3] { 63, 68, DEFAULT_FAN_MAX };
|
if (AppConfig.ContainsModel("FA507X")) return new int[3] { 63, 68, DEFAULT_FAN_MAX };
|
||||||
|
|
||||||
|
if (AppConfig.ContainsModel("FX607J")) return new int[3] { 74, 72, DEFAULT_FAN_MAX };
|
||||||
|
|
||||||
if (AppConfig.ContainsModel("GX650")) return new int[3] { 62, 62, DEFAULT_FAN_MAX };
|
if (AppConfig.ContainsModel("GX650")) return new int[3] { 62, 62, DEFAULT_FAN_MAX };
|
||||||
|
|
||||||
if (AppConfig.ContainsModel("G732")) return new int[3] { 61, 60, DEFAULT_FAN_MAX };
|
if (AppConfig.ContainsModel("G732")) return new int[3] { 61, 60, DEFAULT_FAN_MAX };
|
||||||
|
|||||||
13
app/Fans.cs
@@ -162,13 +162,14 @@ namespace GHelper
|
|||||||
trackGPUTemp.Scroll += trackGPUPower_Scroll;
|
trackGPUTemp.Scroll += trackGPUPower_Scroll;
|
||||||
trackGPUPower.Scroll += trackGPUPower_Scroll;
|
trackGPUPower.Scroll += trackGPUPower_Scroll;
|
||||||
|
|
||||||
trackGPUCore.MouseUp += TrackGPU_MouseUp;
|
trackGPUCore.MouseUp += TrackGPUClocks_MouseUp;
|
||||||
trackGPUMemory.MouseUp += TrackGPU_MouseUp;
|
trackGPUMemory.MouseUp += TrackGPUClocks_MouseUp;
|
||||||
|
trackGPUClockLimit.MouseUp += TrackGPUClocks_MouseUp;
|
||||||
|
|
||||||
trackGPUBoost.MouseUp += TrackGPU_MouseUp;
|
trackGPUBoost.MouseUp += TrackGPU_MouseUp;
|
||||||
trackGPUTemp.MouseUp += TrackGPU_MouseUp;
|
trackGPUTemp.MouseUp += TrackGPU_MouseUp;
|
||||||
trackGPUPower.MouseUp += TrackGPU_MouseUp;
|
trackGPUPower.MouseUp += TrackGPU_MouseUp;
|
||||||
|
|
||||||
trackGPUClockLimit.MouseUp += TrackGPU_MouseUp;
|
|
||||||
|
|
||||||
//labelInfo.MaximumSize = new Size(280, 0);
|
//labelInfo.MaximumSize = new Size(280, 0);
|
||||||
labelFansResult.Visible = false;
|
labelFansResult.Visible = false;
|
||||||
@@ -526,13 +527,17 @@ namespace GHelper
|
|||||||
private void TrackGPU_MouseUp(object? sender, MouseEventArgs e)
|
private void TrackGPU_MouseUp(object? sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
modeControl.SetGPUPower();
|
modeControl.SetGPUPower();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TrackGPUClocks_MouseUp(object? sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
modeControl.SetGPUClocks(true);
|
modeControl.SetGPUClocks(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitGPUPower()
|
private void InitGPUPower()
|
||||||
{
|
{
|
||||||
gpuPowerBase = Program.acpi.DeviceGet(AsusACPI.GPU_BASE);
|
gpuPowerBase = Program.acpi.DeviceGet(AsusACPI.GPU_BASE);
|
||||||
Logger.WriteLine($"ReadGPUPowerBase: {gpuPowerBase}");
|
if (gpuPowerBase >= 0) Logger.WriteLine($"ReadGPUPowerBase: {gpuPowerBase}");
|
||||||
|
|
||||||
panelGPUPower.Visible = isGPUPower;
|
panelGPUPower.Visible = isGPUPower;
|
||||||
if (!isGPUPower) return;
|
if (!isGPUPower) return;
|
||||||
|
|||||||
376
app/Helpers/RestrictedProcessHelper.cs
Normal file
@@ -0,0 +1,376 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
public static class RestrictedProcessHelper
|
||||||
|
{
|
||||||
|
/// Runs a process as a non-elevated version of the current user.
|
||||||
|
public static Process? RunAsRestrictedUser(string fileName, string? args = null)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(fileName))
|
||||||
|
throw new ArgumentException("Value cannot be null or whitespace.", nameof(fileName));
|
||||||
|
|
||||||
|
if (!GetRestrictedSessionUserToken(out var hRestrictedToken))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var si = new STARTUPINFO();
|
||||||
|
si.cb = Marshal.SizeOf(si);
|
||||||
|
si.dwFlags = 0x1;
|
||||||
|
si.wShowWindow = 0x00; // Set the window to be hidden
|
||||||
|
|
||||||
|
var pi = new PROCESS_INFORMATION();
|
||||||
|
var cmd = new StringBuilder();
|
||||||
|
cmd.Append('"').Append(fileName).Append('"');
|
||||||
|
if (!string.IsNullOrWhiteSpace(args))
|
||||||
|
{
|
||||||
|
cmd.Append(' ').Append(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.WriteLine($"Launching {cmd}");
|
||||||
|
|
||||||
|
if (!CreateProcessAsUser(
|
||||||
|
hRestrictedToken,
|
||||||
|
null,
|
||||||
|
cmd,
|
||||||
|
IntPtr.Zero,
|
||||||
|
IntPtr.Zero,
|
||||||
|
true, // inherit handle
|
||||||
|
0,
|
||||||
|
IntPtr.Zero,
|
||||||
|
Path.GetDirectoryName(fileName),
|
||||||
|
ref si,
|
||||||
|
out pi))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Process.GetProcessById(pi.dwProcessId);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseHandle(hRestrictedToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool GetRestrictedSessionUserToken(out IntPtr token)
|
||||||
|
{
|
||||||
|
token = IntPtr.Zero;
|
||||||
|
if (!SaferCreateLevel(SaferScope.User, SaferLevel.NormalUser, SaferOpenFlags.Open, out var hLevel, IntPtr.Zero))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
IntPtr hRestrictedToken = IntPtr.Zero;
|
||||||
|
TOKEN_MANDATORY_LABEL tml = default;
|
||||||
|
tml.Label.Sid = IntPtr.Zero;
|
||||||
|
IntPtr tmlPtr = IntPtr.Zero;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!SaferComputeTokenFromLevel(hLevel, IntPtr.Zero, out hRestrictedToken, 0, IntPtr.Zero))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the token to medium integrity.
|
||||||
|
tml.Label.Attributes = SE_GROUP_INTEGRITY;
|
||||||
|
tml.Label.Sid = IntPtr.Zero;
|
||||||
|
if (!ConvertStringSidToSid("S-1-16-8192", out tml.Label.Sid))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmlPtr = Marshal.AllocHGlobal(Marshal.SizeOf(tml));
|
||||||
|
Marshal.StructureToPtr(tml, tmlPtr, false);
|
||||||
|
if (!SetTokenInformation(hRestrictedToken,
|
||||||
|
TOKEN_INFORMATION_CLASS.TokenIntegrityLevel,
|
||||||
|
tmlPtr, (uint)Marshal.SizeOf(tml)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
token = hRestrictedToken;
|
||||||
|
hRestrictedToken = IntPtr.Zero; // make sure finally() doesn't close the handle
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
SaferCloseLevel(hLevel);
|
||||||
|
SafeCloseHandle(hRestrictedToken);
|
||||||
|
if (tml.Label.Sid != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
LocalFree(tml.Label.Sid);
|
||||||
|
}
|
||||||
|
if (tmlPtr != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
Marshal.FreeHGlobal(tmlPtr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct PROCESS_INFORMATION
|
||||||
|
{
|
||||||
|
public IntPtr hProcess;
|
||||||
|
public IntPtr hThread;
|
||||||
|
public int dwProcessId;
|
||||||
|
public int dwThreadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||||
|
private 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct SID_AND_ATTRIBUTES
|
||||||
|
{
|
||||||
|
public IntPtr Sid;
|
||||||
|
public uint Attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct TOKEN_MANDATORY_LABEL
|
||||||
|
{
|
||||||
|
public SID_AND_ATTRIBUTES Label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SaferLevel : uint
|
||||||
|
{
|
||||||
|
Disallowed = 0,
|
||||||
|
Untrusted = 0x1000,
|
||||||
|
Constrained = 0x10000,
|
||||||
|
NormalUser = 0x20000,
|
||||||
|
FullyTrusted = 0x40000
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SaferScope : uint
|
||||||
|
{
|
||||||
|
Machine = 1,
|
||||||
|
User = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum SaferOpenFlags : uint
|
||||||
|
{
|
||||||
|
Open = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("advapi32", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
|
||||||
|
private static extern bool SaferCreateLevel(SaferScope scope, SaferLevel level, SaferOpenFlags openFlags, out IntPtr pLevelHandle, IntPtr lpReserved);
|
||||||
|
|
||||||
|
[DllImport("advapi32", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
|
||||||
|
private static extern bool SaferComputeTokenFromLevel(IntPtr LevelHandle, IntPtr InAccessToken, out IntPtr OutAccessToken, int dwFlags, IntPtr lpReserved);
|
||||||
|
|
||||||
|
[DllImport("advapi32", SetLastError = true)]
|
||||||
|
private static extern bool SaferCloseLevel(IntPtr hLevelHandle);
|
||||||
|
|
||||||
|
[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||||
|
private static extern bool ConvertStringSidToSid(string StringSid, out IntPtr ptrSid);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
private static extern bool CloseHandle(IntPtr hObject);
|
||||||
|
|
||||||
|
private static bool SafeCloseHandle(IntPtr hObject)
|
||||||
|
{
|
||||||
|
return (hObject == IntPtr.Zero) ? true : CloseHandle(hObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
|
static extern IntPtr LocalFree(IntPtr hMem);
|
||||||
|
|
||||||
|
enum TOKEN_INFORMATION_CLASS
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_USER structure that contains the user account of the token.
|
||||||
|
/// </summary>
|
||||||
|
TokenUser = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_GROUPS structure that contains the group accounts associated with the token.
|
||||||
|
/// </summary>
|
||||||
|
TokenGroups,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_PRIVILEGES structure that contains the privileges of the token.
|
||||||
|
/// </summary>
|
||||||
|
TokenPrivileges,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_OWNER structure that contains the default owner security identifier (SID) for newly created objects.
|
||||||
|
/// </summary>
|
||||||
|
TokenOwner,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_PRIMARY_GROUP structure that contains the default primary group SID for newly created objects.
|
||||||
|
/// </summary>
|
||||||
|
TokenPrimaryGroup,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_DEFAULT_DACL structure that contains the default DACL for newly created objects.
|
||||||
|
/// </summary>
|
||||||
|
TokenDefaultDacl,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_SOURCE structure that contains the source of the token. TOKEN_QUERY_SOURCE access is needed to retrieve this information.
|
||||||
|
/// </summary>
|
||||||
|
TokenSource,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_TYPE value that indicates whether the token is a primary or impersonation token.
|
||||||
|
/// </summary>
|
||||||
|
TokenType,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
TokenImpersonationLevel,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_STATISTICS structure that contains various token statistics.
|
||||||
|
/// </summary>
|
||||||
|
TokenStatistics,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_GROUPS structure that contains the list of restricting SIDs in a restricted token.
|
||||||
|
/// </summary>
|
||||||
|
TokenRestrictedSids,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a DWORD value that indicates the Terminal Services session identifier that is associated with the token.
|
||||||
|
/// </summary>
|
||||||
|
TokenSessionId,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
TokenGroupsAndPrivileges,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reserved.
|
||||||
|
/// </summary>
|
||||||
|
TokenSessionReference,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a DWORD value that is nonzero if the token includes the SANDBOX_INERT flag.
|
||||||
|
/// </summary>
|
||||||
|
TokenSandBoxInert,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reserved.
|
||||||
|
/// </summary>
|
||||||
|
TokenAuditPolicy,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_ORIGIN value.
|
||||||
|
/// </summary>
|
||||||
|
TokenOrigin,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_ELEVATION_TYPE value that specifies the elevation level of the token.
|
||||||
|
/// </summary>
|
||||||
|
TokenElevationType,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_LINKED_TOKEN structure that contains a handle to another token that is linked to this token.
|
||||||
|
/// </summary>
|
||||||
|
TokenLinkedToken,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_ELEVATION structure that specifies whether the token is elevated.
|
||||||
|
/// </summary>
|
||||||
|
TokenElevation,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a DWORD value that is nonzero if the token has ever been filtered.
|
||||||
|
/// </summary>
|
||||||
|
TokenHasRestrictions,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_ACCESS_INFORMATION structure that specifies security information contained in the token.
|
||||||
|
/// </summary>
|
||||||
|
TokenAccessInformation,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a DWORD value that is nonzero if virtualization is allowed for the token.
|
||||||
|
/// </summary>
|
||||||
|
TokenVirtualizationAllowed,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a DWORD value that is nonzero if virtualization is enabled for the token.
|
||||||
|
/// </summary>
|
||||||
|
TokenVirtualizationEnabled,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_MANDATORY_LABEL structure that specifies the token's integrity level.
|
||||||
|
/// </summary>
|
||||||
|
TokenIntegrityLevel,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a DWORD value that is nonzero if the token has the UIAccess flag set.
|
||||||
|
/// </summary>
|
||||||
|
TokenUIAccess,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives a TOKEN_MANDATORY_POLICY structure that specifies the token's mandatory integrity policy.
|
||||||
|
/// </summary>
|
||||||
|
TokenMandatoryPolicy,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer receives the token's logon security identifier (SID).
|
||||||
|
/// </summary>
|
||||||
|
TokenLogonSid,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum value for this enumeration
|
||||||
|
/// </summary>
|
||||||
|
MaxTokenInfoClass
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("advapi32.dll", SetLastError = true)]
|
||||||
|
static extern Boolean SetTokenInformation(
|
||||||
|
IntPtr TokenHandle,
|
||||||
|
TOKEN_INFORMATION_CLASS TokenInformationClass,
|
||||||
|
IntPtr TokenInformation,
|
||||||
|
UInt32 TokenInformationLength);
|
||||||
|
|
||||||
|
const uint SE_GROUP_INTEGRITY = 0x00000020;
|
||||||
|
|
||||||
|
[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||||
|
static extern bool CreateProcessAsUser(
|
||||||
|
IntPtr hToken,
|
||||||
|
string? lpApplicationName,
|
||||||
|
StringBuilder? lpCommandLine,
|
||||||
|
IntPtr lpProcessAttributes,
|
||||||
|
IntPtr lpThreadAttributes,
|
||||||
|
bool bInheritHandles,
|
||||||
|
uint dwCreationFlags,
|
||||||
|
IntPtr lpEnvironment,
|
||||||
|
string? lpCurrentDirectory,
|
||||||
|
ref STARTUPINFO lpStartupInfo,
|
||||||
|
out PROCESS_INFORMATION lpProcessInformation);
|
||||||
|
}
|
||||||
@@ -941,33 +941,17 @@ namespace GHelper.Input
|
|||||||
|
|
||||||
static void LaunchProcess(string command = "")
|
static void LaunchProcess(string command = "")
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(command)) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
RestrictedProcessHelper.RunAsRestrictedUser(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "cmd.exe"), "/C " + command);
|
||||||
//string executable = command.Split(' ')[0];
|
|
||||||
//string arguments = command.Substring(executable.Length).Trim();
|
|
||||||
ProcessStartInfo startInfo = new ProcessStartInfo("cmd", "/C " + command);
|
|
||||||
|
|
||||||
startInfo.RedirectStandardOutput = true;
|
|
||||||
startInfo.RedirectStandardError = true;
|
|
||||||
startInfo.UseShellExecute = false;
|
|
||||||
startInfo.CreateNoWindow = true;
|
|
||||||
|
|
||||||
startInfo.WorkingDirectory = Environment.CurrentDirectory;
|
|
||||||
//startInfo.Arguments = arguments;
|
|
||||||
Process proc = Process.Start(startInfo);
|
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.WriteLine("Failed to run " + command);
|
Logger.WriteLine($"Failed to run: {command} {ex.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void WatcherEventArrived(object sender, EventArrivedEventArgs e)
|
static void WatcherEventArrived(object sender, EventArrivedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.NewEvent is null) return;
|
if (e.NewEvent is null) return;
|
||||||
|
|||||||
@@ -139,12 +139,6 @@
|
|||||||
<data name="icons8-bicycle-48 (1)" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icons8-bicycle-48 (1)" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\icons8-bicycle-48 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\icons8-bicycle-48 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="standard" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\standard.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="eco" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\eco.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="icons8_mute_unmute_96" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icons8_mute_unmute_96" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\icons8-mute-unmute-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\icons8-mute-unmute-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -226,9 +220,6 @@
|
|||||||
<data name="icons8-hibernate-32" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icons8-hibernate-32" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\icons8-hibernate-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\icons8-hibernate-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ultimate" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\ultimate.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="icons8-keyboard-32" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icons8-keyboard-32" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\icons8-keyboard-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\icons8-keyboard-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -349,10 +340,19 @@
|
|||||||
<data name="dark_standard" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="dark_standard" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\dark-standard.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\dark-standard.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="eco" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\eco.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
<data name="light_eco" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="light_eco" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\light-eco.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\light-eco.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="light_standard" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="light_standard" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\light-standard.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\light-standard.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="standard" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\standard.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="ultimate" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\ultimate.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -507,7 +507,7 @@ Trotzdem fortfahren?</value>
|
|||||||
<value>Beleuchtung</value>
|
<value>Beleuchtung</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="LockScreen" xml:space="preserve">
|
<data name="LockScreen" xml:space="preserve">
|
||||||
<value>Lock Screen</value>
|
<value>Bildschirm sperren</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Logo" xml:space="preserve">
|
<data name="Logo" xml:space="preserve">
|
||||||
<value>Logo</value>
|
<value>Logo</value>
|
||||||
|
|||||||
@@ -247,7 +247,7 @@
|
|||||||
<value>Pil tasarrufu için 60Hz kullanılır, şarja takıldığında eski haline gelir</value>
|
<value>Pil tasarrufu için 60Hz kullanılır, şarja takıldığında eski haline gelir</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Awake" xml:space="preserve">
|
<data name="Awake" xml:space="preserve">
|
||||||
<value>Uyanırken</value>
|
<value>Uyanış</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="BacklightLow" xml:space="preserve">
|
<data name="BacklightLow" xml:space="preserve">
|
||||||
<value>Düşük</value>
|
<value>Düşük</value>
|
||||||
@@ -298,10 +298,10 @@
|
|||||||
<value>BIOS ve Sürücü Güncellemeleri</value>
|
<value>BIOS ve Sürücü Güncellemeleri</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Boot" xml:space="preserve">
|
<data name="Boot" xml:space="preserve">
|
||||||
<value>Açılışta</value>
|
<value>Açılış</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="BootSound" xml:space="preserve">
|
<data name="BootSound" xml:space="preserve">
|
||||||
<value>Önyükleme Sesi</value>
|
<value>Açılış sesi</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Brightness" xml:space="preserve">
|
<data name="Brightness" xml:space="preserve">
|
||||||
<value>Parlaklık</value>
|
<value>Parlaklık</value>
|
||||||
@@ -729,7 +729,7 @@ Yine de devam etmek istiyor musunuz?</value>
|
|||||||
<value>Aura'yı Kullan</value>
|
<value>Aura'yı Kullan</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ToggleClamshellMode" xml:space="preserve">
|
<data name="ToggleClamshellMode" xml:space="preserve">
|
||||||
<value>Otomatik Clamshell Modunu Aç</value>
|
<value>Kapaklı modu otmatik değiştir</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ToggleFnLock" xml:space="preserve">
|
<data name="ToggleFnLock" xml:space="preserve">
|
||||||
<value>Fn-Lock'u Aç</value>
|
<value>Fn-Lock'u Aç</value>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 7.7 KiB |
@@ -343,7 +343,7 @@ namespace GHelper
|
|||||||
panelGamma.Visible = true;
|
panelGamma.Visible = true;
|
||||||
tableVisual.Visible = true;
|
tableVisual.Visible = true;
|
||||||
|
|
||||||
var visualValue = (SplendidCommand)AppConfig.Get("visual", (int)SplendidCommand.Default);
|
var visualValue = (SplendidCommand)AppConfig.Get("visual", (int)VisualControl.GetDefaultVisualMode());
|
||||||
var colorTempValue = AppConfig.Get("color_temp", VisualControl.DefaultColorTemp);
|
var colorTempValue = AppConfig.Get("color_temp", VisualControl.DefaultColorTemp);
|
||||||
|
|
||||||
comboVisual.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboVisual.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
@@ -372,7 +372,7 @@ namespace GHelper
|
|||||||
comboGamut.DataSource = new BindingSource(gamuts, null);
|
comboGamut.DataSource = new BindingSource(gamuts, null);
|
||||||
comboGamut.DisplayMember = "Value";
|
comboGamut.DisplayMember = "Value";
|
||||||
comboGamut.ValueMember = "Key";
|
comboGamut.ValueMember = "Key";
|
||||||
comboGamut.SelectedValue = (SplendidGamut)AppConfig.Get("gamut", (int)SplendidGamut.Native);
|
comboGamut.SelectedValue = (SplendidGamut)AppConfig.Get("gamut", (int)VisualControl.GetDefaultGamut());
|
||||||
|
|
||||||
comboGamut.SelectedValueChanged += ComboGamut_SelectedValueChanged;
|
comboGamut.SelectedValueChanged += ComboGamut_SelectedValueChanged;
|
||||||
comboGamut.Visible = true;
|
comboGamut.Visible = true;
|
||||||
|
|||||||