diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-11 22:20:31 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-11 22:20:31 +0000 |
commit | 0483cf1851e39d333d5fdab34506e1ef1006fc8a (patch) | |
tree | 2408fa7306b79dfd241b6a8deca616c21197ef2c /sandbox/src/win_utils.cc | |
parent | 83f30e9abf82b6e1defa5c6fcc3ed2bc6b2aa067 (diff) | |
download | chromium_src-0483cf1851e39d333d5fdab34506e1ef1006fc8a.zip chromium_src-0483cf1851e39d333d5fdab34506e1ef1006fc8a.tar.gz chromium_src-0483cf1851e39d333d5fdab34506e1ef1006fc8a.tar.bz2 |
Sandbox: Some cleanup after the previous changes.
No real code change.
BUG=27218
TEST=current tests.
Review URL: http://codereview.chromium.org/597050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38837 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox/src/win_utils.cc')
-rw-r--r-- | sandbox/src/win_utils.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sandbox/src/win_utils.cc b/sandbox/src/win_utils.cc index bf4936b..8be9ce4 100644 --- a/sandbox/src/win_utils.cc +++ b/sandbox/src/win_utils.cc @@ -265,6 +265,26 @@ bool GetPathFromHandle(HANDLE handle, std::wstring* path) { return true; } +bool WriteProtectedChildMemory(HANDLE child_process, void* address, + const void* buffer, size_t length) { + // First, remove the protections. + DWORD old_protection; + if (!::VirtualProtectEx(child_process, address, length, + PAGE_WRITECOPY, &old_protection)) + return false; + + SIZE_T written; + bool ok = ::WriteProcessMemory(child_process, address, buffer, length, + &written) && (length == written); + + // Always attempt to restore the original protection. + if (!::VirtualProtectEx(child_process, address, length, + old_protection, &old_protection)) + return false; + + return ok; +} + }; // namespace sandbox // TODO(cpu): This is not the final code we want here but we are yet |