summaryrefslogtreecommitdiffstats
path: root/sandbox/win
diff options
context:
space:
mode:
authorrvargas <rvargas@chromium.org>2015-07-27 13:27:16 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-27 20:27:58 +0000
commitba53d6dc1d33f3be64defce3e72cf6c0c5cd855a (patch)
tree71fccfac2064596cdebb035691e71650e8a654a3 /sandbox/win
parent7d23c4f7f5c80f2f70fe1d0fe436d1356eb8f171 (diff)
downloadchromium_src-ba53d6dc1d33f3be64defce3e72cf6c0c5cd855a.zip
chromium_src-ba53d6dc1d33f3be64defce3e72cf6c0c5cd855a.tar.gz
chromium_src-ba53d6dc1d33f3be64defce3e72cf6c0c5cd855a.tar.bz2
Sandbox: Make Wow64 store ScopedHandles instead of raw handles.
BUG=426577 Review URL: https://codereview.chromium.org/1259433002 Cr-Commit-Position: refs/heads/master@{#340547}
Diffstat (limited to 'sandbox/win')
-rw-r--r--sandbox/win/src/Wow64.cc26
-rw-r--r--sandbox/win/src/Wow64.h7
2 files changed, 17 insertions, 16 deletions
diff --git a/sandbox/win/src/Wow64.cc b/sandbox/win/src/Wow64.cc
index 60ee13d..f178386 100644
--- a/sandbox/win/src/Wow64.cc
+++ b/sandbox/win/src/Wow64.cc
@@ -74,11 +74,6 @@ typedef BOOL (WINAPI* IsWow64ProcessFunction)(HANDLE process, BOOL* wow64);
namespace sandbox {
Wow64::~Wow64() {
- if (dll_load_)
- ::CloseHandle(dll_load_);
-
- if (continue_load_)
- ::CloseHandle(continue_load_);
}
// The basic idea is to allocate one page of memory on the child, and initialize
@@ -96,17 +91,20 @@ bool Wow64::WaitForNtdll() {
const size_t page_size = 4096;
// Create some default manual reset un-named events, not signaled.
- dll_load_ = ::CreateEvent(NULL, TRUE, FALSE, NULL);
- continue_load_ = ::CreateEvent(NULL, TRUE, FALSE, NULL);
+ dll_load_.Set(::CreateEvent(NULL, TRUE, FALSE, NULL));
+ continue_load_.Set(::CreateEvent(NULL, TRUE, FALSE, NULL));
HANDLE current_process = ::GetCurrentProcess();
HANDLE remote_load, remote_continue;
DWORD access = EVENT_MODIFY_STATE | SYNCHRONIZE;
- if (!::DuplicateHandle(current_process, dll_load_, child_->Process(),
- &remote_load, access, FALSE, 0))
+ if (!::DuplicateHandle(current_process, dll_load_.Get(), child_->Process(),
+ &remote_load, access, FALSE, 0)) {
return false;
- if (!::DuplicateHandle(current_process, continue_load_, child_->Process(),
- &remote_continue, access, FALSE, 0))
+ }
+ if (!::DuplicateHandle(current_process, continue_load_.Get(),
+ child_->Process(), &remote_continue, access, FALSE,
+ 0)) {
return false;
+ }
void* buffer = ::VirtualAllocEx(child_->Process(), NULL, page_size,
MEM_COMMIT, PAGE_EXECUTE_READWRITE);
@@ -185,11 +183,11 @@ bool Wow64::DllMapped() {
}
for (;;) {
- DWORD reason = ::WaitForSingleObject(dll_load_, INFINITE);
+ DWORD reason = ::WaitForSingleObject(dll_load_.Get(), INFINITE);
if (WAIT_TIMEOUT == reason || WAIT_ABANDONED == reason)
return false;
- if (!::ResetEvent(dll_load_))
+ if (!::ResetEvent(dll_load_.Get()))
return false;
bool found = NtdllPresent();
@@ -198,7 +196,7 @@ bool Wow64::DllMapped() {
return false;
}
- if (!::SetEvent(continue_load_))
+ if (!::SetEvent(continue_load_.Get()))
return false;
if (found)
diff --git a/sandbox/win/src/Wow64.h b/sandbox/win/src/Wow64.h
index e9bbd53..df23c09 100644
--- a/sandbox/win/src/Wow64.h
+++ b/sandbox/win/src/Wow64.h
@@ -8,6 +8,7 @@
#include <windows.h>
#include "base/basictypes.h"
+#include "base/win/scoped_handle.h"
#include "sandbox/win/src/sandbox_types.h"
namespace sandbox {
@@ -40,8 +41,10 @@ class Wow64 {
TargetProcess* child_; // Child process.
HMODULE ntdll_; // ntdll on the parent.
- HANDLE dll_load_; // Event that is signaled on dll load.
- HANDLE continue_load_; // Event to signal to continue execution on the child.
+ // Event that is signaled on dll load.
+ base::win::ScopedHandle dll_load_;
+ // Event to signal to continue execution on the child.
+ base::win::ScopedHandle continue_load_;
DISALLOW_IMPLICIT_CONSTRUCTORS(Wow64);
};