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 "ceee/common/process_utils_win.h" | 12 #include "ceee/common/process_utils_win.h" |
13 | 13 |
14 // Local interprocess communication only. | 14 // Local interprocess communication only. |
15 const wchar_t kRpcProtocol[] = L"ncalrpc"; | 15 const wchar_t kRpcProtocol[] = L"ncalrpc"; |
16 | 16 |
17 std::wstring GetRpcEndPointAddress() { | 17 std::wstring GetRpcEndpointAddress() { |
18 std::wstring end_point; | 18 std::wstring endpoint; |
19 bool running_as_admin = false; | 19 bool running_as_admin = false; |
20 // CEEE running as regular user and CEEE running as elevated user will start | 20 // 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 | 21 // different broker processes. So make end points names different to connect |
22 // to appropriate one. | 22 // to appropriate one. |
23 process_utils_win::IsCurrentProcessUacElevated(&running_as_admin); | 23 process_utils_win::IsCurrentProcessUacElevated(&running_as_admin); |
24 if (running_as_admin) | 24 if (running_as_admin) |
25 end_point += L"ADMIN-"; | 25 endpoint += L"ADMIN-"; |
26 std::wstring sid; | 26 std::wstring sid; |
27 win_util::GetUserSidString(&sid); | 27 win_util::GetUserSidString(&sid); |
28 end_point += sid; | 28 endpoint += sid; |
29 end_point += L"-B4630D08-4621-41A1-A8D0-F1E98DA460D6"; | 29 endpoint += L"-B4630D08-4621-41A1-A8D0-F1E98DA460D6"; |
30 // XP does not accept endpoints longer than 52. | 30 // XP does not accept endpoints longer than 52. |
31 end_point.resize(std::min(52u, end_point.size())); | 31 endpoint.resize(std::min<size_t>(52, endpoint.size())); |
Sigurður Ásgeirsson
2010/12/01 14:23:54
back to 52U?
Vitaly Buka corp
2010/12/01 19:06:04
it does not matter with <size_t>
However if you li
| |
32 return end_point; | 32 return endpoint; |
33 } | 33 } |
34 | 34 |
35 void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len) { | 35 void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len) { |
36 return malloc(len); | 36 return malloc(len); |
37 } | 37 } |
38 | 38 |
39 void __RPC_USER midl_user_free(void __RPC_FAR * ptr) { | 39 void __RPC_USER midl_user_free(void __RPC_FAR * ptr) { |
40 free(ptr); | 40 free(ptr); |
41 } | 41 } |
OLD | NEW |