diff --git a/ipc/chromium/src/base/win_util.cc b/ipc/chromium/src/base/win_util.cc index 5adde21f65e0..abde2fa97247 100644 --- a/ipc/chromium/src/base/win_util.cc +++ b/ipc/chromium/src/base/win_util.cc @@ -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(new BYTE[size]); - scoped_ptr 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(&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; } diff --git a/ipc/chromium/src/base/win_util.h b/ipc/chromium/src/base/win_util.h index a771bd249406..2dc2c0ee2ff0 100644 --- a/ipc/chromium/src/base/win_util.h +++ b/ipc/chromium/src/base/win_util.h @@ -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();