Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2205)

Unified Diff: base/process_win.cc

Issue 7640008: Call NtTerminateProcess directly in Process::Terminate (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_win.cc
===================================================================
--- base/process_win.cc (revision 96401)
+++ base/process_win.cc (working copy)
@@ -14,15 +14,38 @@
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 {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698