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

Unified Diff: chrome_frame/dll_redirector.cc

Issue 7866043: Prevent redirector from returning the current module in cases where it fails to look up the first... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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/dll_redirector.h ('k') | chrome_frame/test/dll_redirector_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_frame/dll_redirector.cc
===================================================================
--- chrome_frame/dll_redirector.cc (revision 100136)
+++ chrome_frame/dll_redirector.cc (working copy)
@@ -42,7 +42,10 @@
if (first_module_handle_) {
if (first_module_handle_ != reinterpret_cast<HMODULE>(&__ImageBase)) {
FreeLibrary(first_module_handle_);
+ } else {
+ NOTREACHED() << "Error, DllRedirector attempting to free self.";
}
+
first_module_handle_ = NULL;
}
UnregisterAsFirstCFModule();
@@ -142,7 +145,6 @@
// back to loading our current version. We return true to indicate that the
// caller should not attempt to delegate to an already loaded version.
dll_version_.swap(our_version);
- first_module_handle_ = reinterpret_cast<HMODULE>(&__ImageBase);
return true;
}
@@ -182,9 +184,6 @@
dll_version_->GetString().c_str(),
std::min(kSharedMemorySize,
dll_version_->GetString().length() + 1));
-
- // Mark ourself as the first module in.
- first_module_handle_ = reinterpret_cast<HMODULE>(&__ImageBase);
} else {
char buffer[kSharedMemorySize] = {0};
memcpy(buffer, shared_memory_->memory(), kSharedMemorySize - 1);
@@ -195,7 +194,6 @@
// memory or we did parse a version and it is the same as our own,
// then pretend we're first in to avoid trying to load any other DLLs.
dll_version_.reset(our_version.release());
- first_module_handle_ = reinterpret_cast<HMODULE>(&__ImageBase);
created_beacon = true;
}
}
@@ -228,15 +226,14 @@
LPFNGETCLASSOBJECT DllRedirector::GetDllGetClassObjectPtr() {
HMODULE first_module_handle = GetFirstModule();
- LPFNGETCLASSOBJECT proc_ptr = reinterpret_cast<LPFNGETCLASSOBJECT>(
- GetProcAddress(first_module_handle, "DllGetClassObject"));
- if (!proc_ptr) {
- DPLOG(ERROR) << "DllRedirector: Could not get address of DllGetClassObject "
- "from first loaded module.";
- // Oh boink, the first module we loaded was somehow bogus, make ourselves
- // the first module again.
- first_module_handle = reinterpret_cast<HMODULE>(&__ImageBase);
+ LPFNGETCLASSOBJECT proc_ptr = NULL;
+ if (first_module_handle) {
+ proc_ptr = reinterpret_cast<LPFNGETCLASSOBJECT>(
+ GetProcAddress(first_module_handle, "DllGetClassObject"));
+ DPLOG_IF(ERROR, !proc_ptr) << "DllRedirector: Could not get address of "
+ "DllGetClassObject from first loaded module.";
}
+
return proc_ptr;
}
@@ -261,11 +258,13 @@
if (first_module_handle_ == NULL) {
first_module_handle_ = LoadVersionedModule(dll_version_.get());
- if (!first_module_handle_) {
- first_module_handle_ = reinterpret_cast<HMODULE>(&__ImageBase);
- }
}
+ if (first_module_handle_ == reinterpret_cast<HMODULE>(&__ImageBase)) {
+ NOTREACHED() << "Should not be loading own version.";
+ first_module_handle_ = NULL;
+ }
+
return first_module_handle_;
}
« no previous file with comments | « chrome_frame/dll_redirector.h ('k') | chrome_frame/test/dll_redirector_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698