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 "chrome/nacl/nacl_main_platform_delegate.h" | 5 #include "chrome/nacl/nacl_main_platform_delegate.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/native_library.h" | 10 #include "base/native_library.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 void NaClMainPlatformDelegate::PlatformInitialize() { | 22 void NaClMainPlatformDelegate::PlatformInitialize() { |
23 // Be mindful of what resources you acquire here. They can be used by | 23 // Be mindful of what resources you acquire here. They can be used by |
24 // malicious code if the renderer gets compromised. | 24 // malicious code if the renderer gets compromised. |
25 } | 25 } |
26 | 26 |
27 void NaClMainPlatformDelegate::PlatformUninitialize() { | 27 void NaClMainPlatformDelegate::PlatformUninitialize() { |
28 } | 28 } |
29 | 29 |
30 void NaClMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { | 30 void NaClMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { |
31 const CommandLine& command_line = parameters_.command_line_; | 31 const CommandLine& command_line = parameters_.command_line; |
32 | 32 |
33 DVLOG(1) << "Started NaClLdr with " << command_line.GetCommandLineString(); | 33 DVLOG(1) << "Started NaClLdr with " << command_line.GetCommandLineString(); |
34 | 34 |
35 sandbox::TargetServices* target_services = | 35 sandbox::TargetServices* target_services = |
36 parameters_.sandbox_info_.TargetServices(); | 36 parameters_.sandbox_info->target_services; |
37 | 37 |
38 if (target_services && !no_sandbox) { | 38 if (target_services && !no_sandbox) { |
39 FilePath test_dll_name = | 39 FilePath test_dll_name = |
40 command_line.GetSwitchValuePath(switches::kTestNaClSandbox); | 40 command_line.GetSwitchValuePath(switches::kTestNaClSandbox); |
41 if (!test_dll_name.empty()) { | 41 if (!test_dll_name.empty()) { |
42 // At this point, hack on the suffix according to with bitness | 42 // At this point, hack on the suffix according to with bitness |
43 // of your windows process. | 43 // of your windows process. |
44 #if defined(_WIN64) | 44 #if defined(_WIN64) |
45 DVLOG(1) << "Using 64-bit test dll\n"; | 45 DVLOG(1) << "Using 64-bit test dll\n"; |
46 test_dll_name = test_dll_name.InsertBeforeExtension(L"64"); | 46 test_dll_name = test_dll_name.InsertBeforeExtension(L"64"); |
47 test_dll_name = test_dll_name.ReplaceExtension(L"dll"); | 47 test_dll_name = test_dll_name.ReplaceExtension(L"dll"); |
48 #else | 48 #else |
49 DVLOG(1) << "Using 32-bit test dll\n"; | 49 DVLOG(1) << "Using 32-bit test dll\n"; |
50 test_dll_name = test_dll_name.ReplaceExtension(L"dll"); | 50 test_dll_name = test_dll_name.ReplaceExtension(L"dll"); |
51 #endif | 51 #endif |
52 DVLOG(1) << "Loading test lib " << test_dll_name.value() << "\n"; | 52 DVLOG(1) << "Loading test lib " << test_dll_name.value() << "\n"; |
53 sandbox_test_module_ = base::LoadNativeLibrary(test_dll_name, NULL); | 53 sandbox_test_module_ = base::LoadNativeLibrary(test_dll_name, NULL); |
54 CHECK(sandbox_test_module_); | 54 CHECK(sandbox_test_module_); |
55 VLOG(1) << "Testing NaCl sandbox\n"; | 55 VLOG(1) << "Testing NaCl sandbox\n"; |
56 } | 56 } |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 void NaClMainPlatformDelegate::EnableSandbox() { | 60 void NaClMainPlatformDelegate::EnableSandbox() { |
61 sandbox::TargetServices* target_services = | 61 sandbox::TargetServices* target_services = |
62 parameters_.sandbox_info_.TargetServices(); | 62 parameters_.sandbox_info->target_services; |
63 | 63 |
64 CHECK(target_services) << "NaCl-Win EnableSandbox: No Target Services!"; | 64 CHECK(target_services) << "NaCl-Win EnableSandbox: No Target Services!"; |
65 // Cause advapi32 to load before the sandbox is turned on. | 65 // Cause advapi32 to load before the sandbox is turned on. |
66 unsigned int dummy_rand; | 66 unsigned int dummy_rand; |
67 rand_s(&dummy_rand); | 67 rand_s(&dummy_rand); |
68 // Warm up language subsystems before the sandbox is turned on. | 68 // Warm up language subsystems before the sandbox is turned on. |
69 ::GetUserDefaultLangID(); | 69 ::GetUserDefaultLangID(); |
70 ::GetUserDefaultLCID(); | 70 ::GetUserDefaultLCID(); |
71 // Turn the sandbox on. | 71 // Turn the sandbox on. |
72 target_services->LowerToken(); | 72 target_services->LowerToken(); |
(...skipping 12 matching lines...) Expand all Loading... |
85 result = (*run_security_tests)(); | 85 result = (*run_security_tests)(); |
86 } else { | 86 } else { |
87 VLOG(1) << "Failed to get NaCl sandbox test function"; | 87 VLOG(1) << "Failed to get NaCl sandbox test function"; |
88 result = false; | 88 result = false; |
89 } | 89 } |
90 base::UnloadNativeLibrary(sandbox_test_module_); | 90 base::UnloadNativeLibrary(sandbox_test_module_); |
91 sandbox_test_module_ = NULL; | 91 sandbox_test_module_ = NULL; |
92 } | 92 } |
93 return result; | 93 return result; |
94 } | 94 } |
OLD | NEW |