| 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> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // Get the security attributes from the current window station; we will | 39 // Get the security attributes from the current window station; we will |
| 40 // use this as the base security attributes for the new window station. | 40 // use this as the base security attributes for the new window station. |
| 41 HWINSTA current_winsta = ::GetProcessWindowStation(); | 41 HWINSTA current_winsta = ::GetProcessWindowStation(); |
| 42 if (!current_winsta) | 42 if (!current_winsta) |
| 43 return SBOX_ERROR_CANNOT_GET_WINSTATION; | 43 return SBOX_ERROR_CANNOT_GET_WINSTATION; |
| 44 | 44 |
| 45 SECURITY_ATTRIBUTES attributes = {0}; | 45 SECURITY_ATTRIBUTES attributes = {0}; |
| 46 if (!GetSecurityAttributes(current_winsta, &attributes)) | 46 if (!GetSecurityAttributes(current_winsta, &attributes)) |
| 47 return SBOX_ERROR_CANNOT_QUERY_WINSTATION_SECURITY; | 47 return SBOX_ERROR_CANNOT_QUERY_WINSTATION_SECURITY; |
| 48 | 48 |
| 49 // Create the window station using NULL for the name to ask the os to | 49 // Create the window station using nullptr for the name to ask the os to |
| 50 // generate it. | 50 // generate it. |
| 51 *winsta = ::CreateWindowStationW( | 51 *winsta = ::CreateWindowStationW( |
| 52 NULL, 0, GENERIC_READ | WINSTA_CREATEDESKTOP, &attributes); | 52 nullptr, 0, GENERIC_READ | WINSTA_CREATEDESKTOP, &attributes); |
| 53 if (*winsta == nullptr && ::GetLastError() == ERROR_ACCESS_DENIED) { |
| 54 *winsta = ::CreateWindowStationW( |
| 55 nullptr, 0, WINSTA_READATTRIBUTES | WINSTA_CREATEDESKTOP, &attributes); |
| 56 } |
| 53 LocalFree(attributes.lpSecurityDescriptor); | 57 LocalFree(attributes.lpSecurityDescriptor); |
| 54 | 58 |
| 55 if (*winsta) | 59 if (*winsta) |
| 56 return SBOX_ALL_OK; | 60 return SBOX_ALL_OK; |
| 57 | 61 |
| 58 return SBOX_ERROR_CANNOT_CREATE_WINSTATION; | 62 return SBOX_ERROR_CANNOT_CREATE_WINSTATION; |
| 59 } | 63 } |
| 60 | 64 |
| 61 ResultCode CreateAltDesktop(HWINSTA winsta, HDESK* desktop) { | 65 ResultCode CreateAltDesktop(HWINSTA winsta, HDESK* desktop) { |
| 62 base::string16 desktop_name = L"sbox_alternate_desktop_"; | 66 base::string16 desktop_name = L"sbox_alternate_desktop_"; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 if (winsta) { | 163 if (winsta) { |
| 160 name = GetWindowObjectName(winsta); | 164 name = GetWindowObjectName(winsta); |
| 161 name += L'\\'; | 165 name += L'\\'; |
| 162 } | 166 } |
| 163 | 167 |
| 164 name += GetWindowObjectName(desktop); | 168 name += GetWindowObjectName(desktop); |
| 165 return name; | 169 return name; |
| 166 } | 170 } |
| 167 | 171 |
| 168 } // namespace sandbox | 172 } // namespace sandbox |
| OLD | NEW |