mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 913953 - Part y: Remove unused AddAccessToKernelObject function; r=ehsan
This commit is contained in:
parent
98911170b0
commit
12e5df4340
@ -93,76 +93,6 @@ void GetServicePackLevel(int* major, int* minor) {
|
||||
*minor = service_pack_minor;
|
||||
}
|
||||
|
||||
bool AddAccessToKernelObject(HANDLE handle, WELL_KNOWN_SID_TYPE known_sid,
|
||||
ACCESS_MASK access) {
|
||||
PSECURITY_DESCRIPTOR descriptor = NULL;
|
||||
PACL old_dacl = NULL;
|
||||
PACL new_dacl = NULL;
|
||||
|
||||
if (ERROR_SUCCESS != GetSecurityInfo(handle, SE_KERNEL_OBJECT,
|
||||
DACL_SECURITY_INFORMATION, NULL, NULL, &old_dacl, NULL,
|
||||
&descriptor))
|
||||
return false;
|
||||
|
||||
BYTE sid[SECURITY_MAX_SID_SIZE] = {0};
|
||||
DWORD size_sid = SECURITY_MAX_SID_SIZE;
|
||||
|
||||
if (known_sid == WinSelfSid) {
|
||||
// We hijack WinSelfSid when we want to add the current user instead of
|
||||
// a known sid.
|
||||
HANDLE token = NULL;
|
||||
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &token)) {
|
||||
LocalFree(descriptor);
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD size = sizeof(TOKEN_USER) + size_sid;
|
||||
TOKEN_USER* token_user = reinterpret_cast<TOKEN_USER*>(new BYTE[size]);
|
||||
scoped_ptr<TOKEN_USER> token_user_ptr(token_user);
|
||||
BOOL ret = GetTokenInformation(token, TokenUser, token_user, size, &size);
|
||||
|
||||
CloseHandle(token);
|
||||
|
||||
if (!ret) {
|
||||
LocalFree(descriptor);
|
||||
return false;
|
||||
}
|
||||
memcpy(sid, token_user->User.Sid, size_sid);
|
||||
} else {
|
||||
if (!CreateWellKnownSid(known_sid , NULL, sid, &size_sid)) {
|
||||
LocalFree(descriptor);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
EXPLICIT_ACCESS new_access = {0};
|
||||
new_access.grfAccessMode = GRANT_ACCESS;
|
||||
new_access.grfAccessPermissions = access;
|
||||
new_access.grfInheritance = NO_INHERITANCE;
|
||||
|
||||
new_access.Trustee.pMultipleTrustee = NULL;
|
||||
new_access.Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
|
||||
new_access.Trustee.TrusteeForm = TRUSTEE_IS_SID;
|
||||
new_access.Trustee.ptstrName = reinterpret_cast<LPWSTR>(&sid);
|
||||
|
||||
if (ERROR_SUCCESS != SetEntriesInAcl(1, &new_access, old_dacl, &new_dacl)) {
|
||||
LocalFree(descriptor);
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD result = SetSecurityInfo(handle, SE_KERNEL_OBJECT,
|
||||
DACL_SECURITY_INFORMATION, NULL, NULL,
|
||||
new_dacl, NULL);
|
||||
|
||||
LocalFree(new_dacl);
|
||||
LocalFree(descriptor);
|
||||
|
||||
if (ERROR_SUCCESS != result)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IsShiftPressed() {
|
||||
return (::GetKeyState(VK_SHIFT) & 0x80) == 0x80;
|
||||
}
|
||||
|
@ -35,13 +35,6 @@ WinVersion GetWinVersion();
|
||||
// Returns the major and minor version of the service pack installed.
|
||||
void GetServicePackLevel(int* major, int* minor);
|
||||
|
||||
// Adds an ACE in the DACL of the object referenced by handle. The ACE is
|
||||
// granting |access| to the user |known_sid|.
|
||||
// If |known_sid| is WinSelfSid, the sid of the current user will be added to
|
||||
// the DACL.
|
||||
bool AddAccessToKernelObject(HANDLE handle, WELL_KNOWN_SID_TYPE known_sid,
|
||||
ACCESS_MASK access);
|
||||
|
||||
// Returns true if the shift key is currently pressed.
|
||||
bool IsShiftPressed();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user