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

Side by Side Diff: sandbox/win/src/handle_closer_agent.cc

Issue 11035012: Enable handle tracing in Canary, Dev, and all debug builds of Chrome (Windows only). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Avoid single-thread race between _try and exception handling code. Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/app/breakpad_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sandbox/win/src/handle_closer_agent.h" 5 #include "sandbox/win/src/handle_closer_agent.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "sandbox/win/src/nt_internals.h" 8 #include "sandbox/win/src/nt_internals.h"
9 #include "sandbox/win/src/win_utils.h" 9 #include "sandbox/win/src/win_utils.h"
10 10
11 namespace { 11 namespace {
12 12
13 int QueryObjectTypeInformationFilter(EXCEPTION_POINTERS* exception_pointers,
14 NTSTATUS* exception_code) {
15 *exception_code = exception_pointers->ExceptionRecord->ExceptionCode;
16 return EXCEPTION_EXECUTE_HANDLER;
rvargas (doing something else) 2012/10/03 03:01:16 I'm a little concerned here about the actual handl
17 }
18
13 // Returns type infomation for an NT object. This routine is expected to be 19 // Returns type infomation for an NT object. This routine is expected to be
14 // called for invalid handles so it catches STATUS_INVALID_HANDLE exceptions 20 // called for invalid handles so it catches STATUS_INVALID_HANDLE exceptions
15 // that can be generated when handle tracing is enabled. 21 // that can be generated when handle tracing is enabled.
16 NTSTATUS QueryObjectTypeInformation(HANDLE handle, 22 NTSTATUS QueryObjectTypeInformation(HANDLE handle,
17 void* buffer, 23 void* buffer,
18 ULONG* size) { 24 ULONG* size) {
19 static NtQueryObject QueryObject = NULL; 25 static NtQueryObject QueryObject = NULL;
20 if (!QueryObject) 26 if (!QueryObject)
21 ResolveNTFunctionPtr("NtQueryObject", &QueryObject); 27 ResolveNTFunctionPtr("NtQueryObject", &QueryObject);
22 28
23 NTSTATUS status = STATUS_UNSUCCESSFUL; 29 NTSTATUS exception_code = STATUS_UNSUCCESSFUL;
rvargas (doing something else) 2012/10/03 03:01:16 I would prefer setting exeption_code, but I don't
24 __try { 30 __try {
25 status = QueryObject(handle, ObjectTypeInformation, buffer, *size, size); 31 return QueryObject(handle, ObjectTypeInformation, buffer, *size, size);
26 } __except(GetExceptionCode() == STATUS_INVALID_HANDLE ? 32 } __except(QueryObjectTypeInformationFilter(GetExceptionInformation(),
27 EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { 33 &exception_code)) {
cpu_(ooo_6.6-7.5) 2012/10/02 19:21:37 can't you call GetExceptionCode() from the body of
alexeypa (please no reviews) 2012/10/02 19:23:22 GetExceptionCode() can only be called from the fil
28 status = STATUS_INVALID_HANDLE; 34 return exception_code;
29 } 35 }
30 return status;
31 } 36 }
32 37
33 } // namespace 38 } // namespace
34 39
35 namespace sandbox { 40 namespace sandbox {
36 41
37 // Memory buffer mapped from the parent, with the list of handles. 42 // Memory buffer mapped from the parent, with the list of handles.
38 SANDBOX_INTERCEPT HandleCloserInfo* g_handles_to_close = NULL; 43 SANDBOX_INTERCEPT HandleCloserInfo* g_handles_to_close = NULL;
39 44
40 bool HandleCloserAgent::NeedsHandlesClosed() { 45 bool HandleCloserAgent::NeedsHandlesClosed() {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 return false; 141 return false;
137 if (!::CloseHandle(handle)) 142 if (!::CloseHandle(handle))
138 return false; 143 return false;
139 } 144 }
140 } 145 }
141 146
142 return true; 147 return true;
143 } 148 }
144 149
145 } // namespace sandbox 150 } // namespace sandbox
OLDNEW
« no previous file with comments | « chrome/app/breakpad_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698