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

Unified Diff: chrome_frame/crash_reporting/nt_loader_unittest.cc

Issue 872004: Heuristically avoid reporting crashes during DLL loading.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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
« no previous file with comments | « chrome_frame/crash_reporting/nt_loader.h ('k') | chrome_frame/crash_reporting/vectored_handler-impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_frame/crash_reporting/nt_loader_unittest.cc
===================================================================
--- chrome_frame/crash_reporting/nt_loader_unittest.cc (revision 41289)
+++ chrome_frame/crash_reporting/nt_loader_unittest.cc (working copy)
@@ -7,6 +7,7 @@
#include <winnt.h>
#include <base/at_exit.h>
#include <base/scoped_handle.h>
+#include <base/string_util.h>
#include <base/sys_info.h>
#include <base/thread.h>
#include "chrome_frame/crash_reporting/crash_dll.h"
@@ -116,8 +117,6 @@
}
TEST(NtLoader, GetLoaderEntry) {
- ScopedEnterCriticalSection lock(GetLoaderLock());
-
// Get all modules in the current process.
ScopedHandle snap(::CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,
::GetCurrentProcessId()));
@@ -128,14 +127,43 @@
MODULEENTRY32 module = { sizeof(module) };
ASSERT_TRUE(::Module32First(snap.Get(), &module));
do {
+ ScopedEnterCriticalSection lock(GetLoaderLock());
+
nt_loader::LDR_DATA_TABLE_ENTRY* entry =
nt_loader::GetLoaderEntry(module.hModule);
ASSERT_TRUE(entry != NULL);
- ASSERT_EQ(module.hModule, reinterpret_cast<HMODULE>(entry->DllBase));
- ASSERT_STREQ(module.szModule,
+ EXPECT_EQ(module.hModule, reinterpret_cast<HMODULE>(entry->DllBase));
+ EXPECT_STREQ(module.szModule,
FromUnicodeString(entry->BaseDllName).c_str());
- ASSERT_STREQ(module.szExePath,
+ EXPECT_STREQ(module.szExePath,
FromUnicodeString(entry->FullDllName).c_str());
+
+ ULONG flags = entry->Flags;
+
+ // All entries should have this flag set.
+ ASSERT_TRUE(flags & LDRP_ENTRY_PROCESSED);
+
+ if (0 == (flags & LDRP_IMAGE_DLL)) {
robertshield 2010/03/11 22:10:56 nit: if you feel like it, and are bored, and are v
Sigurður Ásgeirsson 2010/03/11 22:13:52 Adding a TODO.
+ // Dlls have the LDRP_IMAGE_DLL flag set, any module that doesn't
+ // have that flag has to be the main executable.
+ EXPECT_TRUE(module.hModule == ::GetModuleHandle(NULL));
+ } else {
+ // Since we're not currently loading any modules, all loaded
+ // modules should either have the LDRP_PROCESS_ATTACH_CALLED,
+ // or a NULL entrypoint.
+ if (entry->EntryPoint == NULL) {
+ EXPECT_FALSE(flags & LDRP_PROCESS_ATTACH_CALLED);
+ } else {
+ // Shimeng.dll is an exception to the above, it's loaded
+ // in a special way, see e.g. http://www.alex-ionescu.com/?p=41
+ // for details.
+ bool is_shimeng = LowerCaseEqualsASCII(
+ FromUnicodeString(entry->BaseDllName), "shimeng.dll");
+
+ EXPECT_TRUE(is_shimeng || (flags & LDRP_PROCESS_ATTACH_CALLED));
+ }
+ }
+
} while(::Module32Next(snap.Get(), &module));
}
@@ -199,8 +227,6 @@
NtLoaderTest* NtLoaderTest::current_ = NULL;
DWORD NtLoaderTest::main_thread_ = ::GetCurrentThreadId();
-const wchar_t kCrashDllName[] = L"crash_dll.dll";
-
} // namespace
static int exceptions_handled = 0;
« no previous file with comments | « chrome_frame/crash_reporting/nt_loader.h ('k') | chrome_frame/crash_reporting/vectored_handler-impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698