Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. DWORD AdjustPrivilege(TCHAR *szPrivilege)
  2. {
  3. HANDLE hToken;
  4. TOKEN_PRIVILEGES tkp;
  5. DWORD dwErr = 0;
  6.  
  7. // Get a token for this process.
  8.  
  9. if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
  10. return GetLastError();
  11.  
  12. // Get the LUID for the privilege.
  13.  
  14. if (!LookupPrivilegeValue(NULL, szPrivilege, &tkp.Privileges[0].Luid))
  15. {
  16. dwErr = GetLastError();
  17. CloseHandle(hToken);
  18. return dwErr;
  19. }
  20.  
  21. tkp.PrivilegeCount = 1; // one privilege to set
  22. tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
  23.  
  24. // Set privilege for this process.
  25.  
  26. AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES) NULL, 0);
  27. dwErr = GetLastError();
  28. CloseHandle(hToken);
  29. return dwErr;
  30. }
  31.  
  32. ...
  33.  
  34. AdjustPrivilege(SE_INCREASE_QUOTA_NAME);
  35.  
  36. SIZE_T lMinSize = 0, lMaxSize = 0;
  37. DWORD dwFlags = 0;
  38. if (GetSystemFileCacheSize(&lMinSize, &lMaxSize, &dwFlags))
  39. {
  40. lMaxSize = 300;
  41. lMaxSize *= 1024 * 1024;
  42. SetSystemFileCacheSize(lMinSize, lMaxSize, FILE_CACHE_MAX_HARD_ENABLE);
  43. dwErr = GetLastError();
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement