summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/sandbox_policy.cc3
-rwxr-xr-xchrome/common/section_util_win.cc29
-rwxr-xr-xchrome/common/section_util_win.h23
3 files changed, 53 insertions, 2 deletions
diff --git a/chrome/common/sandbox_policy.cc b/chrome/common/sandbox_policy.cc
index 501b19f..632d873 100644
--- a/chrome/common/sandbox_policy.cc
+++ b/chrome/common/sandbox_policy.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -6,7 +6,6 @@
#include <string>
-#include "app/win/win_util.h"
#include "base/command_line.h"
#include "base/debug/debugger.h"
#include "base/debug/trace_event.h"
diff --git a/chrome/common/section_util_win.cc b/chrome/common/section_util_win.cc
new file mode 100755
index 0000000..449151c
--- /dev/null
+++ b/chrome/common/section_util_win.cc
@@ -0,0 +1,29 @@
+// Copyright (c) 2011 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 "chrome/common/section_util_win.h"
+
+namespace chrome {
+
+HANDLE GetSectionFromProcess(HANDLE section, HANDLE process, bool read_only) {
+ HANDLE valid_section = NULL;
+ DWORD access = STANDARD_RIGHTS_REQUIRED | FILE_MAP_READ;
+ if (!read_only)
+ access |= FILE_MAP_WRITE;
+ DuplicateHandle(process, section, GetCurrentProcess(), &valid_section, access,
+ FALSE, 0);
+ return valid_section;
+}
+
+HANDLE GetSectionForProcess(HANDLE section, HANDLE process, bool read_only) {
+ HANDLE valid_section = NULL;
+ DWORD access = STANDARD_RIGHTS_REQUIRED | FILE_MAP_READ;
+ if (!read_only)
+ access |= FILE_MAP_WRITE;
+ DuplicateHandle(GetCurrentProcess(), section, process, &valid_section, access,
+ FALSE, 0);
+ return valid_section;
+}
+
+} // namespace chrome
diff --git a/chrome/common/section_util_win.h b/chrome/common/section_util_win.h
new file mode 100755
index 0000000..a3c849e
--- /dev/null
+++ b/chrome/common/section_util_win.h
@@ -0,0 +1,23 @@
+// Copyright (c) 2011 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.
+
+#ifndef CHROME_COMMON_SECTION_UTIL_WIN_H_
+#define CHROME_COMMON_SECTION_UTIL_WIN_H_
+#pragma once
+
+#include <windows.h>
+
+namespace chrome {
+
+// Duplicates a section handle from another process to the current process.
+// Returns the new valid handle if the function succeed. NULL otherwise.
+HANDLE GetSectionFromProcess(HANDLE section, HANDLE process, bool read_only);
+
+// Duplicates a section handle from the current process for use in another
+// process. Returns the new valid handle or NULL on failure.
+HANDLE GetSectionForProcess(HANDLE section, HANDLE process, bool read_only);
+
+} // namespace chrome
+
+#endif // CHROME_COMMON_SECTION_UTIL_WIN_H_