-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
13,768 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||
</startup> | ||
</configuration> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{EA18C290-F170-42F9-B5C3-72228337744E}</ProjectGuid> | ||
<OutputType>WinExe</OutputType> | ||
<RootNamespace>Cleaner_PRO</RootNamespace> | ||
<AssemblyName>Cleaner PRO</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<ApplicationIcon>bin.ico</ApplicationIcon> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="BekraRamclear, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Bekra.RamClear.1.0.0.2\lib\BekraRamclear.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Bunifu_UI_v1.5.3"> | ||
<HintPath>.\Bunifu_UI_v1.5.3.dll</HintPath> | ||
</Reference> | ||
<Reference Include="CircularProgressBar, Version=2.8.0.16, Culture=neutral, PublicKeyToken=310fd07b25df79b3, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\CircularProgressBar.2.8.0.16\lib\net40\CircularProgressBar.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.VisualBasic" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Management" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Deployment" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Windows.Forms" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="WinFormAnimation, Version=1.6.0.4, Culture=neutral, PublicKeyToken=310fd07b25df79b3, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\WinFormAnimation.1.6.0.4\lib\net40\WinFormAnimation.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="ComputerHelper.cs" /> | ||
<Compile Include="Enums.cs" /> | ||
<Compile Include="Form1.cs"> | ||
<SubType>Form</SubType> | ||
</Compile> | ||
<Compile Include="Form1.Designer.cs"> | ||
<DependentUpon>Form1.cs</DependentUpon> | ||
</Compile> | ||
<Compile Include="loading.cs"> | ||
<SubType>Form</SubType> | ||
</Compile> | ||
<Compile Include="loading.Designer.cs"> | ||
<DependentUpon>loading.cs</DependentUpon> | ||
</Compile> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<EmbeddedResource Include="Form1.resx"> | ||
<DependentUpon>Form1.cs</DependentUpon> | ||
</EmbeddedResource> | ||
<EmbeddedResource Include="loading.resx"> | ||
<DependentUpon>loading.cs</DependentUpon> | ||
</EmbeddedResource> | ||
<EmbeddedResource Include="Properties\Resources.resx"> | ||
<Generator>ResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
<SubType>Designer</SubType> | ||
</EmbeddedResource> | ||
<Compile Include="Properties\Resources.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
<DesignTime>True</DesignTime> | ||
</Compile> | ||
<None Include="packages.config" /> | ||
<None Include="Properties\Settings.settings"> | ||
<Generator>SettingsSingleFileGenerator</Generator> | ||
<LastGenOutput>Settings.Designer.cs</LastGenOutput> | ||
</None> | ||
<Compile Include="Properties\Settings.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Settings.settings</DependentUpon> | ||
<DesignTimeSharedInput>True</DesignTimeSharedInput> | ||
</Compile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="bin.ico" /> | ||
<None Include="Resources\reject.png" /> | ||
<None Include="Resources\minimize-sign.png" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,218 @@ | ||
using System; | ||
using System.Security.Principal; | ||
using Microsoft.VisualBasic.Devices; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Cleaner_PRO | ||
{ | ||
/// <summary> | ||
/// Computer Helper | ||
/// </summary> | ||
/// | ||
internal static class NativeMethods | ||
{ | ||
[DllImport("advapi32.dll", SetLastError = true)] | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
internal static extern bool AdjustTokenPrivileges(IntPtr tokenHandle, [MarshalAs(UnmanagedType.Bool)] bool disableAllPrivileges, ref Structs.Windows.TokenPrivileges newState, int bufferLength, IntPtr previousState, IntPtr returnLength); | ||
|
||
[DllImport("psapi.dll", SetLastError = true)] | ||
internal static extern int EmptyWorkingSet(IntPtr hProcess); | ||
|
||
[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)] | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
internal static extern bool LookupPrivilegeValue(string lpSystemName, string lpName, ref long lpLuid); | ||
|
||
[DllImport("ntdll.dll", SetLastError = true)] | ||
internal static extern UInt32 NtSetSystemInformation(int infoClass, IntPtr info, int length); | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
internal static extern bool SetSystemFileCacheSize(IntPtr minimumFileCacheSize, IntPtr maximumFileCacheSize, int flags); | ||
} | ||
internal static class Structs | ||
{ | ||
internal static class Windows | ||
{ | ||
/// <summary> | ||
/// Memory Combine Information Ex | ||
/// </summary> | ||
[StructLayout(LayoutKind.Sequential, Pack = 1)] | ||
internal struct MemoryCombineInformationEx | ||
{ | ||
private readonly IntPtr Handle; | ||
private readonly IntPtr PagesCombined; | ||
private readonly IntPtr Flags; | ||
} | ||
|
||
/// <summary> | ||
/// System Cache Information structure for x86 working set | ||
/// </summary> | ||
[StructLayout(LayoutKind.Sequential, Pack = 1)] | ||
internal struct SystemCacheInformation32 | ||
{ | ||
private readonly uint CurrentSize; | ||
private readonly uint PeakSize; | ||
private readonly uint PageFaultCount; | ||
internal uint MinimumWorkingSet; | ||
internal uint MaximumWorkingSet; | ||
private readonly uint Unused1; | ||
private readonly uint Unused2; | ||
private readonly uint Unused3; | ||
private readonly uint Unused4; | ||
} | ||
|
||
/// <summary> | ||
/// System Cache Information structure for x64 working set | ||
/// </summary> | ||
[StructLayout(LayoutKind.Sequential, Pack = 1)] | ||
internal struct SystemCacheInformation64 | ||
{ | ||
private readonly long CurrentSize; | ||
private readonly long PeakSize; | ||
private readonly long PageFaultCount; | ||
internal long MinimumWorkingSet; | ||
internal long MaximumWorkingSet; | ||
private readonly long Unused1; | ||
private readonly long Unused2; | ||
private readonly long Unused3; | ||
private readonly long Unused4; | ||
} | ||
|
||
/// <summary> | ||
/// Token Privileges structure, used for adjusting token privileges | ||
/// </summary> | ||
[StructLayout(LayoutKind.Sequential, Pack = 1)] | ||
internal struct TokenPrivileges | ||
{ | ||
internal int Count; | ||
internal long Luid; | ||
internal int Attr; | ||
} | ||
} | ||
} | ||
internal static class Constants | ||
{ | ||
internal static class Windows | ||
{ | ||
internal const string DebugPrivilege = "SeDebugPrivilege"; | ||
internal const string IncreaseQuotaName = "SeIncreaseQuotaPrivilege"; | ||
internal const int MemoryFlushModifiedList = 3; | ||
internal const int MemoryPurgeLowPriorityStandbyList = 5; | ||
internal const int MemoryPurgeStandbyList = 4; | ||
internal const int PrivilegeEnabled = 2; | ||
internal const string ProfileSingleProcessName = "SeProfileSingleProcessPrivilege"; | ||
internal const int SystemCombinePhysicalMemoryInformation = 130; | ||
internal const int SystemFileCacheInformation = 21; | ||
internal const int SystemMemoryListInformation = 80; | ||
} | ||
} | ||
internal static class ComputerHelper | ||
{ | ||
#region Fields | ||
|
||
private static readonly ComputerInfo _computer = new ComputerInfo(); | ||
|
||
#endregion | ||
|
||
#region Properties | ||
|
||
/// <summary> | ||
/// Determines whether the current operating system is a 64-bit operating system | ||
/// </summary> | ||
/// <value> | ||
/// <c>true</c> if it 64-bit; otherwise, <c>false</c>. | ||
/// </value> | ||
internal static bool Is64Bit | ||
{ | ||
get | ||
{ | ||
return Environment.Is64BitOperatingSystem; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets a value indicating whether this instance is windows 10 or above. | ||
/// </summary> | ||
/// <value> | ||
/// <c>true</c> if this instance is windows 10 or above; otherwise, <c>false</c>. | ||
/// </value> | ||
internal static bool IsWindows8OrAbove | ||
{ | ||
get | ||
{ | ||
return Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 6.2; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets a value indicating whether this instance is windows vista or above. | ||
/// </summary> | ||
/// <value> | ||
/// <c>true</c> if this instance is windows vista or above; otherwise, <c>false</c>. | ||
/// </value> | ||
internal static bool IsWindowsVistaOrAbove | ||
{ | ||
get | ||
{ | ||
return Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 6; | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
#region Methods | ||
|
||
/// <summary> | ||
/// Gets the memory available. | ||
/// </summary> | ||
/// <returns></returns> | ||
internal static long GetMemoryAvailable() | ||
{ | ||
return Convert.ToInt64(_computer.AvailablePhysicalMemory); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the size of the memory. | ||
/// </summary> | ||
/// <returns></returns> | ||
internal static long GetMemorySize() | ||
{ | ||
return Convert.ToInt64(_computer.TotalPhysicalMemory); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the memory usage. | ||
/// </summary> | ||
/// <returns></returns> | ||
internal static long GetMemoryUsage() | ||
{ | ||
return Convert.ToInt64(100 - ((GetMemoryAvailable() / (double)GetMemorySize()) * 100)); | ||
} | ||
|
||
/// <summary> | ||
/// Sets the increase privilege. | ||
/// </summary> | ||
/// <param name="privilegeName">Name of the privilege.</param> | ||
/// <returns></returns> | ||
internal static bool SetIncreasePrivilege(string privilegeName) | ||
{ | ||
using (WindowsIdentity current = WindowsIdentity.GetCurrent(TokenAccessLevels.Query | TokenAccessLevels.AdjustPrivileges)) | ||
{ | ||
Structs.Windows.TokenPrivileges newState; | ||
newState.Count = 1; | ||
newState.Luid = 0L; | ||
newState.Attr = Constants.Windows.PrivilegeEnabled; | ||
|
||
if (NativeMethods.LookupPrivilegeValue(null, privilegeName, ref newState.Luid)) | ||
{ | ||
int result = NativeMethods.AdjustTokenPrivileges(current.Token, false, ref newState, 0, IntPtr.Zero, IntPtr.Zero) ? 1 : 0; | ||
return result != 0; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
#endregion | ||
} | ||
} |
Oops, something went wrong.