Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: sandbox/tests/common/controller.cc

Issue 6610029: Create a "GetWOW64Status()" utility function and make the rest of the codebas... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2010 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/tests/common/controller.h" 5 #include "sandbox/tests/common/controller.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/win/windows_version.h"
9 #include "sandbox/src/sandbox_factory.h" 10 #include "sandbox/src/sandbox_factory.h"
10 #include "sandbox/src/sandbox_utils.h" 11 #include "sandbox/src/sandbox_utils.h"
11 #include "sandbox/src/wow64.h"
12 12
13 namespace { 13 namespace {
14 14
15 static const int kDefaultTimeout = 3000; 15 static const int kDefaultTimeout = 3000;
16 16
17 // Constructs a full path to a file inside the system32 folder. 17 // Constructs a full path to a file inside the system32 folder.
18 std::wstring MakePathToSys32(const wchar_t* name, bool is_obj_man_path) { 18 std::wstring MakePathToSys32(const wchar_t* name, bool is_obj_man_path) {
19 wchar_t windows_path[MAX_PATH] = {0}; 19 wchar_t windows_path[MAX_PATH] = {0};
20 if (0 == ::GetSystemWindowsDirectoryW(windows_path, MAX_PATH)) 20 if (0 == ::GetSystemWindowsDirectoryW(windows_path, MAX_PATH))
21 return std::wstring(); 21 return std::wstring();
(...skipping 26 matching lines...) Expand all
48 full_path += L"\\SysWOW64\\"; 48 full_path += L"\\SysWOW64\\";
49 full_path += name; 49 full_path += name;
50 return full_path; 50 return full_path;
51 } 51 }
52 52
53 } // namespace 53 } // namespace
54 54
55 namespace sandbox { 55 namespace sandbox {
56 56
57 std::wstring MakePathToSys(const wchar_t* name, bool is_obj_man_path) { 57 std::wstring MakePathToSys(const wchar_t* name, bool is_obj_man_path) {
58 Wow64 current_proc(NULL, NULL); 58 if (base::win::GetWOW64Status() == base::win::WOW64_ENABLED)
59 if (current_proc.IsWow64())
60 return MakePathToSysWow64(name, is_obj_man_path); 59 return MakePathToSysWow64(name, is_obj_man_path);
61 else 60 return MakePathToSys32(name, is_obj_man_path);
62 return MakePathToSys32(name, is_obj_man_path);
63 } 61 }
64 62
65 BrokerServices* GetBroker() { 63 BrokerServices* GetBroker() {
66 static BrokerServices* broker = SandboxFactory::GetBrokerServices(); 64 static BrokerServices* broker = SandboxFactory::GetBrokerServices();
67 static bool is_initialized = false; 65 static bool is_initialized = false;
68 66
69 if (!broker) { 67 if (!broker) {
70 return NULL; 68 return NULL;
71 } 69 }
72 70
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 if (!is_init_) 131 if (!is_init_)
134 return false; 132 return false;
135 133
136 std::wstring win32_path = MakePathToSys32(pattern, false); 134 std::wstring win32_path = MakePathToSys32(pattern, false);
137 if (win32_path.empty()) 135 if (win32_path.empty())
138 return false; 136 return false;
139 137
140 if (!AddRule(TargetPolicy::SUBSYS_FILES, semantics, win32_path.c_str())) 138 if (!AddRule(TargetPolicy::SUBSYS_FILES, semantics, win32_path.c_str()))
141 return false; 139 return false;
142 140
143 Wow64 current_proc(NULL, NULL); 141 if (base::win::GetWOW64Status() != base::win::WOW64_ENABLED)
144 if (!current_proc.IsWow64())
145 return true; 142 return true;
146 143
147 win32_path = MakePathToSysWow64(pattern, false); 144 win32_path = MakePathToSysWow64(pattern, false);
148 if (win32_path.empty()) 145 if (win32_path.empty())
149 return false; 146 return false;
150 147
151 return AddRule(TargetPolicy::SUBSYS_FILES, semantics, win32_path.c_str()); 148 return AddRule(TargetPolicy::SUBSYS_FILES, semantics, win32_path.c_str());
152 } 149 }
153 150
154 bool TestRunner::AddFsRule(TargetPolicy::Semantics semantics, 151 bool TestRunner::AddFsRule(TargetPolicy::Semantics semantics,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 if (BEFORE_REVERT == state) 280 if (BEFORE_REVERT == state)
284 return command(argc - 4, argv + 4); 281 return command(argc - 4, argv + 4);
285 else if (EVERY_STATE == state) 282 else if (EVERY_STATE == state)
286 command(argc - 4, argv + 4); 283 command(argc - 4, argv + 4);
287 284
288 target->LowerToken(); 285 target->LowerToken();
289 return command(argc - 4, argv + 4); 286 return command(argc - 4, argv + 4);
290 } 287 }
291 288
292 } // namespace sandbox 289 } // namespace sandbox
OLDNEW
« base/win/windows_version.cc ('K') | « sandbox/src/service_resolver_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698