mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-26 11:04:21 +01:00
Force Normal IO and Page Priority
More useful when run as Task but it seems to help normal runs as well. Related to issue #487.
This commit is contained in:
parent
54b6b2754a
commit
a7192d2fbf
67
DS4Windows/DS4Control/Util.cs
Normal file
67
DS4Windows/DS4Control/Util.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
|
||||
namespace DS4Windows
|
||||
{
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
class Util
|
||||
{
|
||||
public enum PROCESS_INFORMATION_CLASS : int
|
||||
{
|
||||
ProcessBasicInformation = 0,
|
||||
ProcessQuotaLimits,
|
||||
ProcessIoCounters,
|
||||
ProcessVmCounters,
|
||||
ProcessTimes,
|
||||
ProcessBasePriority,
|
||||
ProcessRaisePriority,
|
||||
ProcessDebugPort,
|
||||
ProcessExceptionPort,
|
||||
ProcessAccessToken,
|
||||
ProcessLdtInformation,
|
||||
ProcessLdtSize,
|
||||
ProcessDefaultHardErrorMode,
|
||||
ProcessIoPortHandlers,
|
||||
ProcessPooledUsageAndLimits,
|
||||
ProcessWorkingSetWatch,
|
||||
ProcessUserModeIOPL,
|
||||
ProcessEnableAlignmentFaultFixup,
|
||||
ProcessPriorityClass,
|
||||
ProcessWx86Information,
|
||||
ProcessHandleCount,
|
||||
ProcessAffinityMask,
|
||||
ProcessPriorityBoost,
|
||||
ProcessDeviceMap,
|
||||
ProcessSessionInformation,
|
||||
ProcessForegroundInformation,
|
||||
ProcessWow64Information,
|
||||
ProcessImageFileName,
|
||||
ProcessLUIDDeviceMapsEnabled,
|
||||
ProcessBreakOnTermination,
|
||||
ProcessDebugObjectHandle,
|
||||
ProcessDebugFlags,
|
||||
ProcessHandleTracing,
|
||||
ProcessIoPriority,
|
||||
ProcessExecuteFlags,
|
||||
ProcessResourceManagement,
|
||||
ProcessCookie,
|
||||
ProcessImageInformation,
|
||||
ProcessCycleTime,
|
||||
ProcessPagePriority,
|
||||
ProcessInstrumentationCallback,
|
||||
ProcessThreadStackAllocation,
|
||||
ProcessWorkingSetWatchEx,
|
||||
ProcessImageFileNameWin32,
|
||||
ProcessImageFileMapping,
|
||||
ProcessAffinityUpdateMode,
|
||||
ProcessMemoryAllocationMode,
|
||||
MaxProcessInfoClass
|
||||
}
|
||||
|
||||
[DllImport("ntdll.dll", SetLastError = true)]
|
||||
public static extern int NtSetInformationProcess(IntPtr processHandle,
|
||||
PROCESS_INFORMATION_CLASS processInformationClass, ref IntPtr processInformation, uint processInformationLength);
|
||||
}
|
||||
}
|
@ -141,6 +141,7 @@
|
||||
<Compile Include="DS4Control\ScpDevice.cs" />
|
||||
<Compile Include="DS4Control\ScpUtil.cs" />
|
||||
<Compile Include="DS4Control\UdpServer.cs" />
|
||||
<Compile Include="DS4Control\Util.cs" />
|
||||
<Compile Include="DS4Control\X360Device.cs" />
|
||||
<Compile Include="DS4Forms\LanguagePackComboBox.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
|
@ -75,6 +75,16 @@ namespace DS4Windows
|
||||
}
|
||||
catch { } // Ignore problems raising the priority.
|
||||
|
||||
// Force Normal IO Priority
|
||||
IntPtr ioPrio = new IntPtr(2);
|
||||
Util.NtSetInformationProcess(Process.GetCurrentProcess().Handle,
|
||||
Util.PROCESS_INFORMATION_CLASS.ProcessIoPriority, ref ioPrio, 4);
|
||||
|
||||
// Force Normal Page Priority
|
||||
IntPtr pagePrio = new IntPtr(5);
|
||||
Util.NtSetInformationProcess(Process.GetCurrentProcess().Handle,
|
||||
Util.PROCESS_INFORMATION_CLASS.ProcessPagePriority, ref pagePrio, 4);
|
||||
|
||||
try
|
||||
{
|
||||
// another instance is already running if OpenExsting succeeds.
|
||||
|
Loading…
Reference in New Issue
Block a user