| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Utilities shared by both Broker RPC client and server. | 5 // Utilities shared by both Broker RPC client and server. |
| 6 | 6 |
| 7 #include "ceee/ie/broker/broker_rpc_utils.h" | 7 #include "ceee/ie/broker/broker_rpc_utils.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "base/win_util.h" | 11 #include "base/win_util.h" |
| 12 #include "broker_rpc_lib.h" // NOLINT |
| 12 #include "ceee/common/process_utils_win.h" | 13 #include "ceee/common/process_utils_win.h" |
| 13 | 14 |
| 15 |
| 14 // Local interprocess communication only. | 16 // Local interprocess communication only. |
| 15 const wchar_t kRpcProtocol[] = L"ncalrpc"; | 17 const wchar_t kRpcProtocol[] = L"ncalrpc"; |
| 16 | 18 |
| 17 std::wstring GetRpcEndPointAddress() { | 19 std::wstring GetRpcEndpointAddress() { |
| 18 std::wstring end_point; | 20 std::wstring endpoint; |
| 19 bool running_as_admin = false; | 21 bool running_as_admin = false; |
| 20 // CEEE running as regular user and CEEE running as elevated user will start | 22 // CEEE running as regular user and CEEE running as elevated user will start |
| 21 // different broker processes. So make end points names different to connect | 23 // different broker processes. So make end points names different to connect |
| 22 // to appropriate one. | 24 // to appropriate one. |
| 23 process_utils_win::IsCurrentProcessUacElevated(&running_as_admin); | 25 process_utils_win::IsCurrentProcessUacElevated(&running_as_admin); |
| 24 if (running_as_admin) | 26 if (running_as_admin) |
| 25 end_point += L"ADMIN-"; | 27 endpoint += L"ADMIN-"; |
| 26 std::wstring sid; | 28 std::wstring sid; |
| 27 win_util::GetUserSidString(&sid); | 29 win_util::GetUserSidString(&sid); |
| 28 end_point += sid; | 30 endpoint += sid; |
| 29 end_point += L"-B4630D08-4621-41A1-A8D0-F1E98DA460D6"; | 31 endpoint += L"-B4630D08-4621-41A1-A8D0-F1E98DA460D6"; |
| 30 // XP does not accept endpoints longer than 52. | 32 // XP does not accept endpoints longer than 52. |
| 31 end_point.resize(std::min(52u, end_point.size())); | 33 endpoint.resize(std::min<size_t>(kMaxEndpointSize, endpoint.size())); |
| 32 return end_point; | 34 return endpoint; |
| 33 } | 35 } |
| 34 | 36 |
| 35 void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len) { | 37 void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len) { |
| 36 return malloc(len); | 38 return malloc(len); |
| 37 } | 39 } |
| 38 | 40 |
| 39 void __RPC_USER midl_user_free(void __RPC_FAR * ptr) { | 41 void __RPC_USER midl_user_free(void __RPC_FAR * ptr) { |
| 40 free(ptr); | 42 free(ptr); |
| 41 } | 43 } |
| OLD | NEW |