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

Side by Side Diff: base/win/win_util.cc

Issue 11565026: Crash ppapi processes on Windows when calling exit(), _exit(), abort() and ExitProcess() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years 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 | « base/win/win_util.h ('k') | content/ppapi_plugin/ppapi_thread.cc » ('j') | 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 "base/win/win_util.h" 5 #include "base/win/win_util.h"
6 6
7 #include <aclapi.h> 7 #include <aclapi.h>
8 #include <shobjidl.h> // Must be before propkey. 8 #include <shobjidl.h> // Must be before propkey.
9 #include <initguid.h> 9 #include <initguid.h>
10 #include <propkey.h> 10 #include <propkey.h>
11 #include <propvarutil.h> 11 #include <propvarutil.h>
12 #include <sddl.h> 12 #include <sddl.h>
13 #include <shlobj.h> 13 #include <shlobj.h>
14 #include <signal.h>
15 #include <stdlib.h>
14 16
15 #include "base/logging.h" 17 #include "base/logging.h"
16 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
17 #include "base/win/registry.h" 19 #include "base/win/registry.h"
18 #include "base/string_util.h" 20 #include "base/string_util.h"
19 #include "base/stringprintf.h" 21 #include "base/stringprintf.h"
20 #include "base/threading/thread_restrictions.h" 22 #include "base/threading/thread_restrictions.h"
21 #include "base/win/scoped_handle.h" 23 #include "base/win/scoped_handle.h"
22 #include "base/win/windows_version.h" 24 #include "base/win/windows_version.h"
23 25
24 namespace { 26 namespace {
25 27
26 // Sets the value of |property_key| to |property_value| in |property_store|. 28 // Sets the value of |property_key| to |property_value| in |property_store|.
27 // Clears the PropVariant contained in |property_value|. 29 // Clears the PropVariant contained in |property_value|.
28 bool SetPropVariantValueForPropertyStore( 30 bool SetPropVariantValueForPropertyStore(
29 IPropertyStore* property_store, 31 IPropertyStore* property_store,
30 const PROPERTYKEY& property_key, 32 const PROPERTYKEY& property_key,
31 PROPVARIANT* property_value) { 33 PROPVARIANT* property_value) {
32 DCHECK(property_store); 34 DCHECK(property_store);
33 35
34 HRESULT result = property_store->SetValue(property_key, *property_value); 36 HRESULT result = property_store->SetValue(property_key, *property_value);
35 if (result == S_OK) 37 if (result == S_OK)
36 result = property_store->Commit(); 38 result = property_store->Commit();
37 39
38 PropVariantClear(property_value); 40 PropVariantClear(property_value);
39 return SUCCEEDED(result); 41 return SUCCEEDED(result);
40 } 42 }
41 43
44 void __cdecl ForceCrashOnSigAbort(int) {
45 *((int*)0) = 0x1337;
46 }
47
42 } // namespace 48 } // namespace
43 49
44 namespace base { 50 namespace base {
45 namespace win { 51 namespace win {
46 52
47 static bool g_crash_on_process_detach = false; 53 static bool g_crash_on_process_detach = false;
48 54
49 #define NONCLIENTMETRICS_SIZE_PRE_VISTA \ 55 #define NONCLIENTMETRICS_SIZE_PRE_VISTA \
50 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont) 56 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont)
51 57
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 185 }
180 186
181 void SetShouldCrashOnProcessDetach(bool crash) { 187 void SetShouldCrashOnProcessDetach(bool crash) {
182 g_crash_on_process_detach = crash; 188 g_crash_on_process_detach = crash;
183 } 189 }
184 190
185 bool ShouldCrashOnProcessDetach() { 191 bool ShouldCrashOnProcessDetach() {
186 return g_crash_on_process_detach; 192 return g_crash_on_process_detach;
187 } 193 }
188 194
195 void SetAbortBehaviorForCrashReporting() {
196 // Prevent CRT's abort code from prompting a dialog or trying to "report" it.
197 // Disabling the _CALL_REPORTFAULT behavior is important since otherwise it
198 // has the sideffect of clearing our exception filter, which means we
199 // don't get any crash.
200 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
201
202 // Set a SIGABRT handler for good measure. We will crash even if the default
203 // is left in place, however this allows us to crash earlier. And it also
204 // lets us crash in response to code which might directly call raise(SIGABRT)
205 signal(SIGABRT, ForceCrashOnSigAbort);
206 }
207
189 bool IsMachineATablet() { 208 bool IsMachineATablet() {
190 if (base::win::GetVersion() < base::win::VERSION_WIN7) 209 if (base::win::GetVersion() < base::win::VERSION_WIN7)
191 return false; 210 return false;
192 const int kMultiTouch = NID_INTEGRATED_TOUCH | NID_MULTI_INPUT | NID_READY; 211 const int kMultiTouch = NID_INTEGRATED_TOUCH | NID_MULTI_INPUT | NID_READY;
193 const int kMaxTabletScreenWidth = 1366; 212 const int kMaxTabletScreenWidth = 1366;
194 const int kMaxTabletScreenHeight = 768; 213 const int kMaxTabletScreenHeight = 768;
195 int sm = GetSystemMetrics(SM_DIGITIZER); 214 int sm = GetSystemMetrics(SM_DIGITIZER);
196 if ((sm & kMultiTouch) == kMultiTouch) { 215 if ((sm & kMultiTouch) == kMultiTouch) {
197 int cx = GetSystemMetrics(SM_CXSCREEN); 216 int cx = GetSystemMetrics(SM_CXSCREEN);
198 int cy = GetSystemMetrics(SM_CYSCREEN); 217 int cy = GetSystemMetrics(SM_CYSCREEN);
(...skipping 22 matching lines...) Expand all
221 240
222 #ifndef COPY_FILE_COPY_SYMLINK 241 #ifndef COPY_FILE_COPY_SYMLINK
223 #error You must install the Windows 2008 or Vista Software Development Kit and \ 242 #error You must install the Windows 2008 or Vista Software Development Kit and \
224 set it as your default include path to build this library. You can grab it by \ 243 set it as your default include path to build this library. You can grab it by \
225 searching for "download windows sdk 2008" in your favorite web search engine. \ 244 searching for "download windows sdk 2008" in your favorite web search engine. \
226 Also make sure you register the SDK with Visual Studio, by selecting \ 245 Also make sure you register the SDK with Visual Studio, by selecting \
227 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \ 246 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \
228 menu (see Start - All Programs - Microsoft Windows SDK - \ 247 menu (see Start - All Programs - Microsoft Windows SDK - \
229 Visual Studio Registration). 248 Visual Studio Registration).
230 #endif 249 #endif
OLDNEW
« no previous file with comments | « base/win/win_util.h ('k') | content/ppapi_plugin/ppapi_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698