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

Unified Diff: base/win/dllmain.cc

Issue 9803002: [windows] Make calls to exit(), _exit(), abort(), and ExitProcess() from the renderer process resul… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
Index: base/win/dllmain.cc
diff --git a/base/win/dllmain.cc b/base/win/dllmain.cc
index fad951905ddb3b01301ee6ba9eec12becf8da13d..f18cf711c6635fe2a169833861394f306a683d73 100644
--- a/base/win/dllmain.cc
+++ b/base/win/dllmain.cc
@@ -26,7 +26,7 @@
#include <windows.h>
-#include "base/logging.h"
+#include "base/compiler_specific.h"
// Indicate if another service is scanning the callbacks. When this becomes
// set to true, then DllMain() will stop supporting the callback service. This
@@ -34,6 +34,9 @@
// shows that some other service is handling callbacks.
static bool linker_notifications_are_active = false;
+// Indicates if we should crash in response to DLL_PROCESS_DETACH.
+static bool crash_on_process_detach = false;
+
// This will be our mostly no-op callback that we'll list. We won't
// deliberately call it, and if it is called, that means we don't need to do any
// of the callbacks anymore. We expect such a call to arrive via a
@@ -83,10 +86,16 @@ PIMAGE_TLS_CALLBACK p_thread_callback_dllmain_typical_entry = on_callback;
#endif // _WIN64
} // extern "C"
+NOINLINE static void CrashOnProcessDetach() {
+ *((int*)0) = 0x356;
+}
// Make DllMain call the listed callbacks. This way any third parties that are
// linked in will also be called.
BOOL WINAPI DllMain(PVOID h, DWORD reason, PVOID reserved) {
+ if (DLL_PROCESS_DETACH == reason && crash_on_process_detach)
+ CrashOnProcessDetach();
+
if (DLL_THREAD_DETACH != reason && DLL_PROCESS_DETACH != reason)
return true; // We won't service THREAD_ATTACH calls.
@@ -113,3 +122,13 @@ static void NTAPI on_callback(PVOID h, DWORD reason, PVOID reserved) {
// and allow us to do the callbacks on XP, where we are currently devoid of
// callbacks (due to an explicit LoadLibrary call).
}
+
+namespace base {
+namespace win {
+
+void DLLMain_SetCrashOnProcessDetach(bool crash) {
rvargas (doing something else) 2012/03/21 03:13:45 This is problematic because this file is not part
eroman 2012/03/21 04:14:31 Good point. How about if I add exported methods t
rvargas (doing something else) 2012/03/21 17:46:12 Sounds good.
+ crash_on_process_detach = crash;
+}
+
+} // namespace win
+} // namespace base

Powered by Google App Engine
This is Rietveld 408576698