summaryrefslogtreecommitdiffstats
path: root/base/process_win.cc
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-19 01:36:21 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-19 01:36:21 +0000
commitc4ed802942d46ce11a6d8728bb7b02110e6076a8 (patch)
tree2437201c6d79cefe4e1dc8d4526d51d40034d5e9 /base/process_win.cc
parent8e3e6fd0003787bbf4041b2904581b36cefd5a8e (diff)
downloadchromium_src-c4ed802942d46ce11a6d8728bb7b02110e6076a8.zip
chromium_src-c4ed802942d46ce11a6d8728bb7b02110e6076a8.tar.gz
chromium_src-c4ed802942d46ce11a6d8728bb7b02110e6076a8.tar.bz2
Cleanup code used to diagnose and fix bug 81449.
I think it is unlikely that CloseHandle was the function that was being hooked because it is called from so many other places without problems. I am assuming that TerminateProcess was being hooked. If the symptoms of 81449 return when this is landed, this patch can be reverted. BUG=81449 Review URL: http://codereview.chromium.org/7624052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97407 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_win.cc')
-rw-r--r--base/process_win.cc25
1 files changed, 6 insertions, 19 deletions
diff --git a/base/process_win.cc b/base/process_win.cc
index 593bdd3..8b4c2b0 100644
--- a/base/process_win.cc
+++ b/base/process_win.cc
@@ -13,20 +13,10 @@ namespace base {
void Process::Close() {
if (!process_)
return;
+
// Don't call CloseHandle on a pseudo-handle.
- 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_);
- }
+ if (process_ != ::GetCurrentProcess())
+ ::CloseHandle(process_);
process_ = NULL;
}
@@ -35,17 +25,14 @@ void Process::Terminate(int result_code) {
if (!process_)
return;
- // TODO(apatrick): Call NtTerminateProcess directly, without going through the
- // import table to determine if TerminateProcess is being hooked.
- // http://crbug.com/81449.
+ // Call NtTerminateProcess directly, without going through the import table,
+ // which might have been hooked with a buggy replacement by third party
+ // software. 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 {