summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-15 19:22:44 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-15 19:22:44 +0000
commitb987e90e17a644bc6157252efbdfe8b16a3b72b3 (patch)
tree12b3fe185ee7db532656d9b4c74eece79dea4bba /base
parent23233a6c635781f87f33e2404c38085aee2df354 (diff)
downloadchromium_src-b987e90e17a644bc6157252efbdfe8b16a3b72b3.zip
chromium_src-b987e90e17a644bc6157252efbdfe8b16a3b72b3.tar.gz
chromium_src-b987e90e17a644bc6157252efbdfe8b16a3b72b3.tar.bz2
Call ntdll.dll!NtTerminateProcess directly, without going through the
import table for kernel31.dll!TerminateProcess to determine if TerminateProcess is being hooked. This is an attempt to diagnose the bug referenced below. BUG=81449 Review URL: http://codereview.chromium.org/7640008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96807 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/process_win.cc29
1 files changed, 26 insertions, 3 deletions
diff --git a/base/process_win.cc b/base/process_win.cc
index 0a38805..593bdd3 100644
--- a/base/process_win.cc
+++ b/base/process_win.cc
@@ -14,15 +14,38 @@ void Process::Close() {
if (!process_)
return;
// Don't call CloseHandle on a pseudo-handle.
- if (process_ != ::GetCurrentProcess())
- ::CloseHandle(process_);
+ if (process_ != ::GetCurrentProcess()) {
+ // TODO(apatrick): Call NtCloseHandle directly, without going through the
+ // import table to determine if CloseHandle is being hooked.
+ // http://crbug.com/81449.
+ HMODULE module = GetModuleHandle(L"ntdll.dll");
+ typedef UINT (WINAPI *CloseHandlePtr)(HANDLE handle);
+ CloseHandlePtr close_handle = reinterpret_cast<CloseHandlePtr>(
+ GetProcAddress(module, "NtClose"));
+ close_handle(process_);
+
+ // It used to look like this:
+ // ::CloseHandle(process_);
+ }
+
process_ = NULL;
}
void Process::Terminate(int result_code) {
if (!process_)
return;
- ::TerminateProcess(process_, result_code);
+
+ // TODO(apatrick): Call NtTerminateProcess directly, without going through the
+ // import table to determine if TerminateProcess is being hooked.
+ // http://crbug.com/81449.
+ HMODULE module = GetModuleHandle(L"ntdll.dll");
+ typedef UINT (WINAPI *TerminateProcessPtr)(HANDLE handle, UINT code);
+ TerminateProcessPtr terminate_process = reinterpret_cast<TerminateProcessPtr>(
+ GetProcAddress(module, "NtTerminateProcess"));
+ terminate_process(process_, result_code);
+
+ // It used to look like this:
+ // ::TerminateProcess(process_, result_code);
}
bool Process::IsProcessBackgrounded() const {