mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-24 11:36:20 +00:00
Code cleanup.
This commit is contained in:
parent
c107547c6c
commit
2650545916
1 changed files with 11 additions and 18 deletions
|
@ -51,34 +51,27 @@ Return value: TRUE indicates success, FALSE failure.
|
||||||
* AWE Example: https://msdn.microsoft.com/en-us/library/windows/desktop/aa366531(v=vs.85).aspx
|
* AWE Example: https://msdn.microsoft.com/en-us/library/windows/desktop/aa366531(v=vs.85).aspx
|
||||||
* Creating a File Mapping Using Large Pages: https://msdn.microsoft.com/en-us/library/aa366543(VS.85).aspx
|
* Creating a File Mapping Using Large Pages: https://msdn.microsoft.com/en-us/library/aa366543(VS.85).aspx
|
||||||
*/
|
*/
|
||||||
static BOOL SetLockPagesPrivilege(HANDLE hProcess, BOOL bEnable) {
|
static BOOL SetLockPagesPrivilege() {
|
||||||
struct {
|
HANDLE token;
|
||||||
DWORD Count;
|
|
||||||
LUID_AND_ATTRIBUTES Privilege[1];
|
|
||||||
} Info;
|
|
||||||
|
|
||||||
HANDLE Token;
|
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token) != TRUE) {
|
||||||
|
|
||||||
if (OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES, &Token) != TRUE) {
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info.Count = 1;
|
TOKEN_PRIVILEGES tp;
|
||||||
Info.Privilege[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
|
tp.PrivilegeCount = 1;
|
||||||
|
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||||
|
|
||||||
if (LookupPrivilegeValue(NULL, SE_LOCK_MEMORY_NAME, &(Info.Privilege[0].Luid)) != TRUE) {
|
if (LookupPrivilegeValue(NULL, SE_LOCK_MEMORY_NAME, &(tp.Privileges[0].Luid)) != TRUE) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AdjustTokenPrivileges(Token, FALSE, (PTOKEN_PRIVILEGES) &Info, 0, NULL, NULL) != TRUE) {
|
BOOL rc = AdjustTokenPrivileges(token, FALSE, (PTOKEN_PRIVILEGES) &tp, 0, NULL, NULL);
|
||||||
|
if (rc != TRUE || GetLastError() != ERROR_SUCCESS) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetLastError() != ERROR_SUCCESS) {
|
CloseHandle(token);
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(Token);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +81,7 @@ const char * persistent_memory_allocate() {
|
||||||
const int ratio = opt_double_hash ? 2 : 1;
|
const int ratio = opt_double_hash ? 2 : 1;
|
||||||
const int size = MEMORY * (opt_n_threads * ratio + 1);
|
const int size = MEMORY * (opt_n_threads * ratio + 1);
|
||||||
|
|
||||||
if (SetLockPagesPrivilege(GetCurrentProcess(), TRUE)) {
|
if (SetLockPagesPrivilege()) {
|
||||||
persistent_memory_flags |= MEMORY_HUGEPAGES_AVAILABLE;
|
persistent_memory_flags |= MEMORY_HUGEPAGES_AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue