OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/common/sandbox_win.h" | 5 #include "content/common/sandbox_win.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 if (!module) { | 186 if (!module) { |
187 // The module could have been loaded with a 8.3 short name. We check | 187 // The module could have been loaded with a 8.3 short name. We check |
188 // the three most common cases: 'thelongname.dll' becomes | 188 // the three most common cases: 'thelongname.dll' becomes |
189 // 'thelon~1.dll', 'thelon~2.dll' and 'thelon~3.dll'. | 189 // 'thelon~1.dll', 'thelon~2.dll' and 'thelon~3.dll'. |
190 std::wstring name(module_name); | 190 std::wstring name(module_name); |
191 size_t period = name.rfind(L'.'); | 191 size_t period = name.rfind(L'.'); |
192 DCHECK_NE(std::string::npos, period); | 192 DCHECK_NE(std::string::npos, period); |
193 DCHECK_LE(3U, (name.size() - period)); | 193 DCHECK_LE(3U, (name.size() - period)); |
194 if (period <= 8) | 194 if (period <= 8) |
195 return; | 195 return; |
196 for (int ix = 0; ix < 3; ++ix) { | 196 for (wchar_t ix = '1'; ix <= '3'; ++ix) { |
197 const wchar_t suffix[] = {'~', ('1' + ix), 0}; | 197 const wchar_t suffix[] = {'~', ix, 0}; |
198 std::wstring alt_name = name.substr(0, 6) + suffix; | 198 std::wstring alt_name = name.substr(0, 6) + suffix; |
199 alt_name += name.substr(period, name.size()); | 199 alt_name += name.substr(period, name.size()); |
200 if (check_in_browser) { | 200 if (check_in_browser) { |
201 module = ::GetModuleHandleW(alt_name.c_str()); | 201 module = ::GetModuleHandleW(alt_name.c_str()); |
202 if (!module) | 202 if (!module) |
203 return; | 203 return; |
204 // We found it, but because it only has 6 significant letters, we | 204 // We found it, but because it only has 6 significant letters, we |
205 // want to make sure it is the right one. | 205 // want to make sure it is the right one. |
206 if (!IsExpandedModuleName(module, module_name)) | 206 if (!IsExpandedModuleName(module, module_name)) |
207 return; | 207 return; |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 } | 759 } |
760 | 760 |
761 return false; | 761 return false; |
762 } | 762 } |
763 | 763 |
764 bool BrokerAddTargetPeer(HANDLE peer_process) { | 764 bool BrokerAddTargetPeer(HANDLE peer_process) { |
765 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; | 765 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; |
766 } | 766 } |
767 | 767 |
768 } // namespace content | 768 } // namespace content |
OLD | NEW |