Skip to content

Commit ccc5a8d

Browse files
committed
* Code Doc
* Minor parameter name changes
1 parent d7c696a commit ccc5a8d

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

MemPlus/Classes/MemPlus.cs

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ internal enum SystemInformationClass
5454
}
5555

5656
/// <summary>
57-
/// Class containing methods to 'optimize' or clear memory usage in Windows
57+
/// Sealed class containing methods to 'optimize' or clear memory usage in Windows
5858
/// </summary>
59-
internal class MemPlus
59+
internal sealed class MemPlus
6060
{
61+
#region Variables
6162
/// <summary>
6263
/// Constant int used for TokenPrivileges Atrr variable
6364
/// </summary>
@@ -70,19 +71,49 @@ internal class MemPlus
7071
/// Profile single process
7172
/// </summary>
7273
private const string SeProfileSingleProcessName = "SeProfileSingleProcessPrivilege";
74+
/// <summary>
75+
/// Memory purge standby list
76+
/// </summary>
7377
private const int MemoryPurgeStandbyList = 4;
78+
#endregion
7479

80+
#region Imports
81+
/// <summary>
82+
/// Retrieves the locally unique identifier (LUID) used on a specified system to locally represent the specified privilege name.
83+
/// </summary>
84+
/// /// <param name="lpSystemName">A pointer to a null-terminated string that specifies the name of the system on which the privilege name is retrieved. If a null string is specified, the function attempts to find the privilege name on the local system</param>
85+
/// <param name="lpName">A pointer to a null-terminated string that specifies the name of the privilege, as defined in the Winnt.h header file. For example, this parameter could specify the constant, SE_SECURITY_NAME, or its corresponding string, "SeSecurityPrivilege"</param>
86+
/// <param name="pluid">A pointer to a variable that receives the LUID by which the privilege is known on the system specified by the lpSystemName parameter.</param>
87+
/// <returns>If the function succeeds, the function returns nonzero. Otherwise, return value will be zero</returns>
7588
[DllImport("advapi32.dll", SetLastError = true)]
76-
private static extern bool LookupPrivilegeValue(string host, string name, ref long pluid);
77-
89+
private static extern bool LookupPrivilegeValue(string lpSystemName, string lpName, ref long pluid);
90+
/// <summary>
91+
/// Enables or disables privileges in the specified access token. Enabling or disabling privileges in an access token requires TOKEN_ADJUST_PRIVILEGES access
92+
/// </summary>
93+
/// <param name="tokenHandle">A handle to the access token that contains the privileges to be modified. The handle must have TOKEN_ADJUST_PRIVILEGES access to the token. If the PreviousState parameter is not NULL, the handle must also have TOKEN_QUERY access</param>
94+
/// <param name="disableAllPrivileges">Specifies whether the function disables all of the token's privileges. If this value is TRUE, the function disables all privileges and ignores the NewState parameter. If it is FALSE, the function modifies privileges based on the information pointed to by the NewState parameter</param>
95+
/// <param name="newState">A pointer to a TOKEN_PRIVILEGES structure that specifies an array of privileges and their attributes. If the DisableAllPrivileges parameter is FALSE, the AdjustTokenPrivileges function enables, disables, or removes these privileges for the token</param>
96+
/// <param name="bufferLength">Specifies the size, in bytes, of the buffer pointed to by the PreviousState parameter. This parameter can be zero if the PreviousState parameter is NULL</param>
97+
/// <param name="previousState">A pointer to a buffer that the function fills with a TOKEN_PRIVILEGES structure that contains the previous state of any privileges that the function modifies. That is, if a privilege has been modified by this function, the privilege and its previous state are contained in the TOKEN_PRIVILEGES structure referenced by PreviousState. If the PrivilegeCount member of TOKEN_PRIVILEGES is zero, then no privileges have been changed by this function. This parameter can be NULL</param>
98+
/// <param name="returnLength">A pointer to a variable that receives the required size, in bytes, of the buffer pointed to by the PreviousState parameter. This parameter can be NULL if PreviousState is NULL</param>
99+
/// <returns>If the function succeeds, the return value is nonzero</returns>
78100
[DllImport("advapi32.dll", SetLastError = true)]
79-
private static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall, ref TokenPrivileges newst, int len, IntPtr prev, IntPtr relen);
80-
101+
private static extern bool AdjustTokenPrivileges(IntPtr tokenHandle, bool disableAllPrivileges, ref TokenPrivileges newState, int bufferLength, IntPtr previousState, IntPtr returnLength);
102+
/// <summary>Change Windows System parameters</summary>
103+
/// <param name="infoClass"></param>
104+
/// <param name="info"></param>
105+
/// <param name="length">Allocated bytes for the Info block</param>
106+
/// <returns>Opposite of boolean. Zero means success, non-zero means fail and use GetLastError</returns>
81107
[DllImport("ntdll.dll")]
82108
private static extern uint NtSetSystemInformation(int infoClass, IntPtr info, int length);
83-
109+
/// <summary>
110+
/// Removes as many pages as possible from the working set of the specified process
111+
/// </summary>
112+
/// <param name="hwProc">A handle to the process. The handle must have the PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION access right and the PROCESS_SET_QUOTA access right</param>
113+
/// <returns>If the function succeeds, the return value is nonzero</returns>
84114
[DllImport("psapi.dll")]
85115
private static extern int EmptyWorkingSet(IntPtr hwProc);
116+
#endregion
86117

87118
/// <summary>
88119
/// Clear the working sets of all processes that are available to the application

0 commit comments

Comments
 (0)