| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sandbox/win/src/window.h" | 5 #include "sandbox/win/src/window.h" |
| 6 | 6 |
| 7 #include <aclapi.h> | 7 #include <aclapi.h> |
| 8 | 8 |
| 9 #include <memory> |
| 10 |
| 9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "sandbox/win/src/acl.h" | 12 #include "sandbox/win/src/acl.h" |
| 12 #include "sandbox/win/src/sid.h" | 13 #include "sandbox/win/src/sid.h" |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 // Gets the security attributes of a window object referenced by |handle|. The | 17 // Gets the security attributes of a window object referenced by |handle|. The |
| 17 // lpSecurityDescriptor member of the SECURITY_ATTRIBUTES parameter returned | 18 // lpSecurityDescriptor member of the SECURITY_ATTRIBUTES parameter returned |
| 18 // must be freed using LocalFree by the caller. | 19 // must be freed using LocalFree by the caller. |
| 19 bool GetSecurityAttributes(HANDLE handle, SECURITY_ATTRIBUTES* attributes) { | 20 bool GetSecurityAttributes(HANDLE handle, SECURITY_ATTRIBUTES* attributes) { |
| 20 attributes->bInheritHandle = FALSE; | 21 attributes->bInheritHandle = FALSE; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // Get the size of the name. | 124 // Get the size of the name. |
| 124 DWORD size = 0; | 125 DWORD size = 0; |
| 125 ::GetUserObjectInformation(handle, UOI_NAME, NULL, 0, &size); | 126 ::GetUserObjectInformation(handle, UOI_NAME, NULL, 0, &size); |
| 126 | 127 |
| 127 if (!size) { | 128 if (!size) { |
| 128 NOTREACHED(); | 129 NOTREACHED(); |
| 129 return base::string16(); | 130 return base::string16(); |
| 130 } | 131 } |
| 131 | 132 |
| 132 // Create the buffer that will hold the name. | 133 // Create the buffer that will hold the name. |
| 133 scoped_ptr<wchar_t[]> name_buffer(new wchar_t[size]); | 134 std::unique_ptr<wchar_t[]> name_buffer(new wchar_t[size]); |
| 134 | 135 |
| 135 // Query the name of the object. | 136 // Query the name of the object. |
| 136 if (!::GetUserObjectInformation(handle, UOI_NAME, name_buffer.get(), size, | 137 if (!::GetUserObjectInformation(handle, UOI_NAME, name_buffer.get(), size, |
| 137 &size)) { | 138 &size)) { |
| 138 NOTREACHED(); | 139 NOTREACHED(); |
| 139 return base::string16(); | 140 return base::string16(); |
| 140 } | 141 } |
| 141 | 142 |
| 142 return base::string16(name_buffer.get()); | 143 return base::string16(name_buffer.get()); |
| 143 } | 144 } |
| 144 | 145 |
| 145 base::string16 GetFullDesktopName(HWINSTA winsta, HDESK desktop) { | 146 base::string16 GetFullDesktopName(HWINSTA winsta, HDESK desktop) { |
| 146 if (!desktop) { | 147 if (!desktop) { |
| 147 NOTREACHED(); | 148 NOTREACHED(); |
| 148 return base::string16(); | 149 return base::string16(); |
| 149 } | 150 } |
| 150 | 151 |
| 151 base::string16 name; | 152 base::string16 name; |
| 152 if (winsta) { | 153 if (winsta) { |
| 153 name = GetWindowObjectName(winsta); | 154 name = GetWindowObjectName(winsta); |
| 154 name += L'\\'; | 155 name += L'\\'; |
| 155 } | 156 } |
| 156 | 157 |
| 157 name += GetWindowObjectName(desktop); | 158 name += GetWindowObjectName(desktop); |
| 158 return name; | 159 return name; |
| 159 } | 160 } |
| 160 | 161 |
| 161 } // namespace sandbox | 162 } // namespace sandbox |
| OLD | NEW |