summaryrefslogtreecommitdiffstats
path: root/sandbox/src
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/src')
-rw-r--r--sandbox/src/file_policy_test.cc22
-rw-r--r--sandbox/src/filesystem_policy.cc6
-rw-r--r--sandbox/src/process_policy_test.cc14
-rw-r--r--sandbox/src/registry_dispatcher.cc8
-rw-r--r--sandbox/src/restricted_token_utils.cc15
-rw-r--r--sandbox/src/sync_policy_test.cc23
-rw-r--r--sandbox/src/unload_dll_test.cc11
-rw-r--r--sandbox/src/win_utils_unittest.cc9
8 files changed, 52 insertions, 56 deletions
diff --git a/sandbox/src/file_policy_test.cc b/sandbox/src/file_policy_test.cc
index df1e903..2abf6e2 100644
--- a/sandbox/src/file_policy_test.cc
+++ b/sandbox/src/file_policy_test.cc
@@ -1,14 +1,13 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
#include <algorithm>
#include <cctype>
#include <windows.h>
#include <winioctl.h>
-#include "base/win/scoped_handle.h"
+#include "base/scoped_handle_win.h"
#include "sandbox/src/nt_internals.h"
#include "sandbox/src/sandbox.h"
#include "sandbox/src/sandbox_factory.h"
@@ -36,20 +35,19 @@ SBOX_TESTS_COMMAND int File_Create(int argc, wchar_t **argv) {
bool read = (_wcsicmp(argv[0], L"Read") == 0);
if (read) {
- base::win::ScopedHandle file1(CreateFile(
- argv[1], GENERIC_READ, kSharing, NULL, OPEN_EXISTING, 0, NULL));
- base::win::ScopedHandle file2(CreateFile(
- argv[1], FILE_EXECUTE, kSharing, NULL, OPEN_EXISTING, 0, NULL));
+ ScopedHandle file1(CreateFile(argv[1], GENERIC_READ, kSharing, NULL,
+ OPEN_EXISTING, 0, NULL));
+ ScopedHandle file2(CreateFile(argv[1], FILE_EXECUTE, kSharing, NULL,
+ OPEN_EXISTING, 0, NULL));
if (file1.Get() && file2.Get())
return SBOX_TEST_SUCCEEDED;
return SBOX_TEST_DENIED;
} else {
- base::win::ScopedHandle file1(CreateFile(
- argv[1], GENERIC_ALL, kSharing, NULL, OPEN_EXISTING, 0, NULL));
- base::win::ScopedHandle file2(CreateFile(
- argv[1], GENERIC_READ | FILE_WRITE_DATA, kSharing, NULL, OPEN_EXISTING,
- 0, NULL));
+ ScopedHandle file1(CreateFile(argv[1], GENERIC_ALL, kSharing, NULL,
+ OPEN_EXISTING, 0, NULL));
+ ScopedHandle file2(CreateFile(argv[1], GENERIC_READ | FILE_WRITE_DATA,
+ kSharing, NULL, OPEN_EXISTING, 0, NULL));
if (file1.Get() && file2.Get())
return SBOX_TEST_SUCCEEDED;
diff --git a/sandbox/src/filesystem_policy.cc b/sandbox/src/filesystem_policy.cc
index 385f4ae..2a15555 100644
--- a/sandbox/src/filesystem_policy.cc
+++ b/sandbox/src/filesystem_policy.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,7 +7,7 @@
#include "sandbox/src/filesystem_policy.h"
#include "base/logging.h"
-#include "base/win/scoped_handle.h"
+#include "base/scoped_handle_win.h"
#include "sandbox/src/ipc_tags.h"
#include "sandbox/src/policy_engine_opcodes.h"
#include "sandbox/src/policy_params.h"
@@ -363,7 +363,7 @@ bool FileSystemPolicy::SetInformationFileAction(
return true;
}
- base::win::ScopedHandle handle(local_handle);
+ ScopedHandle handle(local_handle);
FILE_INFORMATION_CLASS file_info_class =
static_cast<FILE_INFORMATION_CLASS>(info_class);
diff --git a/sandbox/src/process_policy_test.cc b/sandbox/src/process_policy_test.cc
index 8681671..0fbf204 100644
--- a/sandbox/src/process_policy_test.cc
+++ b/sandbox/src/process_policy_test.cc
@@ -1,17 +1,17 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <memory>
#include <string>
+#include <memory>
-#include "base/win/scoped_handle.h"
+#include "base/scoped_handle_win.h"
+#include "testing/gtest/include/gtest/gtest.h"
#include "sandbox/src/sandbox.h"
#include "sandbox/src/sandbox_policy.h"
#include "sandbox/src/sandbox_factory.h"
#include "sandbox/src/sandbox_utils.h"
#include "sandbox/tests/common/controller.h"
-#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -178,14 +178,14 @@ SBOX_TESTS_COMMAND int Process_GetChildProcessToken(int argc, wchar_t **argv) {
return SBOX_TEST_FAILED;
}
- base::win::ScopedHandle process(pi.hProcess);
- base::win::ScopedHandle thread(pi.hThread);
+ ScopedHandle process(pi.hProcess);
+ ScopedHandle thread(pi.hThread);
HANDLE token = NULL;
BOOL result = ::OpenProcessToken(process.Get(), TOKEN_IMPERSONATE, &token);
DWORD error = ::GetLastError();
- base::win::ScopedHandle token_handle(token);
+ ScopedHandle token_handle(token);
if (!::TerminateProcess(process.Get(), 0))
return SBOX_TEST_FAILED;
diff --git a/sandbox/src/registry_dispatcher.cc b/sandbox/src/registry_dispatcher.cc
index f86c76a..5f53770 100644
--- a/sandbox/src/registry_dispatcher.cc
+++ b/sandbox/src/registry_dispatcher.cc
@@ -1,10 +1,10 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sandbox/src/registry_dispatcher.h"
-#include "base/win/scoped_handle.h"
+#include "base/scoped_handle_win.h"
#include "base/win/windows_version.h"
#include "sandbox/src/crosscall_client.h"
#include "sandbox/src/interception.h"
@@ -74,7 +74,7 @@ bool RegistryDispatcher::SetupService(InterceptionManager* manager,
bool RegistryDispatcher::NtCreateKey(
IPCInfo* ipc, std::wstring* name, DWORD attributes, HANDLE root,
DWORD desired_access, DWORD title_index, DWORD create_options) {
- base::win::ScopedHandle root_handle;
+ ScopedHandle root_handle;
std::wstring real_path = *name;
// If there is a root directory, we need to duplicate the handle to make
@@ -120,7 +120,7 @@ bool RegistryDispatcher::NtCreateKey(
bool RegistryDispatcher::NtOpenKey(IPCInfo* ipc, std::wstring* name,
DWORD attributes, HANDLE root,
DWORD desired_access) {
- base::win::ScopedHandle root_handle;
+ ScopedHandle root_handle;
std::wstring real_path = *name;
// If there is a root directory, we need to duplicate the handle to make
diff --git a/sandbox/src/restricted_token_utils.cc b/sandbox/src/restricted_token_utils.cc
index b036e51..8842865 100644
--- a/sandbox/src/restricted_token_utils.cc
+++ b/sandbox/src/restricted_token_utils.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,7 +9,7 @@
#include "sandbox/src/restricted_token_utils.h"
#include "base/logging.h"
-#include "base/win/scoped_handle.h"
+#include "base/scoped_handle_win.h"
#include "base/win/windows_version.h"
#include "sandbox/src/job.h"
#include "sandbox/src/restricted_token.h"
@@ -166,7 +166,7 @@ DWORD StartRestrictedProcessInJob(wchar_t *command_line,
if (ERROR_SUCCESS != err_code) {
return err_code;
}
- base::win::ScopedHandle primary_token(primary_token_handle);
+ ScopedHandle primary_token(primary_token_handle);
// Create the impersonation token (restricted) to be able to start the
// process.
@@ -178,7 +178,7 @@ DWORD StartRestrictedProcessInJob(wchar_t *command_line,
if (ERROR_SUCCESS != err_code) {
return err_code;
}
- base::win::ScopedHandle impersonation_token(impersonation_token_handle);
+ ScopedHandle impersonation_token(impersonation_token_handle);
// Start the process
STARTUPINFO startup_info = {0};
@@ -198,8 +198,8 @@ DWORD StartRestrictedProcessInJob(wchar_t *command_line,
return ::GetLastError();
}
- base::win::ScopedHandle thread_handle(process_info.hThread);
- base::win::ScopedHandle process_handle(process_info.hProcess);
+ ScopedHandle thread_handle(process_info.hThread);
+ ScopedHandle process_handle(process_info.hProcess);
// Change the token of the main thread of the new process for the
// impersonation token with more rights.
@@ -335,9 +335,10 @@ DWORD SetProcessIntegrityLevel(IntegrityLevel integrity_level) {
&token_handle))
return ::GetLastError();
- base::win::ScopedHandle token(token_handle);
+ ScopedHandle token(token_handle);
return SetTokenIntegrityLevel(token.Get(), integrity_level);
}
+
} // namespace sandbox
diff --git a/sandbox/src/sync_policy_test.cc b/sandbox/src/sync_policy_test.cc
index 3c87243..835a578 100644
--- a/sandbox/src/sync_policy_test.cc
+++ b/sandbox/src/sync_policy_test.cc
@@ -1,14 +1,14 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/win/scoped_handle.h"
+#include "base/scoped_handle_win.h"
+#include "testing/gtest/include/gtest/gtest.h"
#include "sandbox/src/sandbox.h"
#include "sandbox/src/sandbox_policy.h"
#include "sandbox/src/sandbox_factory.h"
#include "sandbox/src/nt_internals.h"
#include "sandbox/tests/common/controller.h"
-#include "testing/gtest/include/gtest/gtest.h"
namespace sandbox {
@@ -20,8 +20,7 @@ SBOX_TESTS_COMMAND int Event_Open(int argc, wchar_t **argv) {
if (L'f' == argv[0][0])
desired_access = EVENT_ALL_ACCESS;
- base::win::ScopedHandle event_open(::OpenEvent(
- desired_access, FALSE, argv[1]));
+ ScopedHandle event_open(::OpenEvent(desired_access, FALSE, argv[1]));
DWORD error_open = ::GetLastError();
if (event_open.Get())
@@ -49,10 +48,10 @@ SBOX_TESTS_COMMAND int Event_CreateOpen(int argc, wchar_t **argv) {
if (L't' == argv[1][0])
initial_state = TRUE;
- base::win::ScopedHandle event_create(::CreateEvent(
- NULL, manual_reset, initial_state, event_name));
+ ScopedHandle event_create(::CreateEvent(NULL, manual_reset, initial_state,
+ event_name));
DWORD error_create = ::GetLastError();
- base::win::ScopedHandle event_open;
+ ScopedHandle event_open;
if (event_name)
event_open.Set(::OpenEvent(EVENT_ALL_ACCESS, FALSE, event_name));
@@ -125,10 +124,10 @@ TEST(SyncPolicyTest, TestEventReadOnly) {
TargetPolicy::EVENTS_ALLOW_READONLY,
L"test6"));
- base::win::ScopedHandle handle1(::CreateEvent(NULL, FALSE, FALSE, L"test1"));
- base::win::ScopedHandle handle2(::CreateEvent(NULL, FALSE, FALSE, L"test2"));
- base::win::ScopedHandle handle3(::CreateEvent(NULL, FALSE, FALSE, L"test3"));
- base::win::ScopedHandle handle4(::CreateEvent(NULL, FALSE, FALSE, L"test4"));
+ ScopedHandle handle1(::CreateEvent(NULL, FALSE, FALSE, L"test1"));
+ ScopedHandle handle2(::CreateEvent(NULL, FALSE, FALSE, L"test2"));
+ ScopedHandle handle3(::CreateEvent(NULL, FALSE, FALSE, L"test3"));
+ ScopedHandle handle4(::CreateEvent(NULL, FALSE, FALSE, L"test4"));
EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"Event_CreateOpen f f"));
EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"Event_CreateOpen t f"));
diff --git a/sandbox/src/unload_dll_test.cc b/sandbox/src/unload_dll_test.cc
index a50f1aa..063f43f 100644
--- a/sandbox/src/unload_dll_test.cc
+++ b/sandbox/src/unload_dll_test.cc
@@ -1,13 +1,13 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/win/scoped_handle.h"
+#include "base/scoped_handle_win.h"
+#include "testing/gtest/include/gtest/gtest.h"
#include "sandbox/src/sandbox.h"
#include "sandbox/src/sandbox_factory.h"
#include "sandbox/src/target_services.h"
#include "sandbox/tests/common/controller.h"
-#include "testing/gtest/include/gtest/gtest.h"
namespace sandbox {
@@ -36,7 +36,7 @@ SBOX_TESTS_COMMAND int SimpleOpenEvent(int argc, wchar_t **argv) {
if (argc != 1)
return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
- base::win::ScopedHandle event_open(::OpenEvent(SYNCHRONIZE, FALSE, argv[0]));
+ ScopedHandle event_open(::OpenEvent(SYNCHRONIZE, FALSE, argv[0]));
return event_open.Get() ? SBOX_TEST_SUCCEEDED : SBOX_TEST_FAILED;
}
@@ -73,8 +73,7 @@ TEST(UnloadDllTest, FLAKY_UnloadAviCapDllWithPatching) {
sandbox::TargetPolicy* policy = runner.GetPolicy();
policy->AddDllToUnload(L"avicap32.dll");
- base::win::ScopedHandle handle1(::CreateEvent(
- NULL, FALSE, FALSE, L"tst0001"));
+ ScopedHandle handle1(::CreateEvent(NULL, FALSE, FALSE, L"tst0001"));
// Add a couple of rules that ensures that the interception agent add EAT
// patching on the client which makes sure that the unload dll record does
diff --git a/sandbox/src/win_utils_unittest.cc b/sandbox/src/win_utils_unittest.cc
index 0f445ef..99ce7e2 100644
--- a/sandbox/src/win_utils_unittest.cc
+++ b/sandbox/src/win_utils_unittest.cc
@@ -1,10 +1,10 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <windows.h>
-#include "base/win/scoped_handle.h"
+#include "base/scoped_handle_win.h"
#include "sandbox/src/win_utils.h"
#include "sandbox/tests/common/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -67,9 +67,8 @@ TEST(WinUtils, SameObject) {
std::wstring folder(my_folder);
std::wstring file_name = folder + L"\\foo.txt";
const ULONG kSharing = FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE;
- base::win::ScopedHandle file(CreateFile(
- file_name.c_str(), GENERIC_WRITE, kSharing, NULL, CREATE_ALWAYS,
- FILE_FLAG_DELETE_ON_CLOSE, NULL));
+ ScopedHandle file(CreateFile(file_name.c_str(), GENERIC_WRITE, kSharing, NULL,
+ CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL));
EXPECT_TRUE(file.IsValid());
std::wstring file_name_nt1 = std::wstring(L"\\??\\") + file_name;