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

Unified Diff: sandbox/src/win_utils.cc

Issue 199052: Simplify ResolveNTFunctionPtr (temporary)... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/src/win_utils.cc
===================================================================
--- sandbox/src/win_utils.cc (revision 25655)
+++ sandbox/src/win_utils.cc (working copy)
@@ -197,42 +197,12 @@
}; // namespace sandbox
-// The information is cached in a map. The map has to be global, so it's memory
-// is leaked, and it's ok.
+// TODO(cpu): Revert this change to use a map to speed up the function once
+// this has been deployed in the dev channel for a week. See bug 11789.
void ResolveNTFunctionPtr(const char* name, void* ptr) {
- static std::map<std::string, FARPROC>* function_map = NULL;
- if (!function_map)
- function_map = new std::map<std::string, FARPROC>;
-
static HMODULE ntdll = ::GetModuleHandle(sandbox::kNtdllName);
Nicolas Sylvain 2009/09/09 03:31:00 This is going to fail the same way it was failing
FARPROC* function_ptr = reinterpret_cast<FARPROC*>(ptr);
- *function_ptr = (*function_map)[name];
- if (*function_ptr)
- return;
-
*function_ptr = ::GetProcAddress(ntdll, name);
- (*function_map)[name] = *function_ptr;
- DCHECK(*function_ptr) << "Failed to resolve NTDLL function";
-
- if (!*function_ptr) {
- // If we return NULL, we are going to crash. Unfortunately, this happens.
- // See bug 11789.
- // Maybe our module handle is not valid anymore?
- HMODULE ntdll2 = ::GetModuleHandle(sandbox::kNtdllName);
- *function_ptr = ::GetProcAddress(ntdll2, name);
- (*function_map)[name] = *function_ptr;
-
- // TODO(nsylvain): Remove this check after we are done troubleshooting.
- CHECK(ntdll2) << "Fatal error: NTLL module is NULL";
- CHECK(*function_ptr) << "Fatal error: Failed to resolve NTDLL function";
-
- // If we are here, it means that getting the new module handle worked. This
- // is not really expected. We want to receive some reports from users, so
- // we will crash anyway.
- // TODO(nsylvain): Remove this check after we are done troubleshooting.
- CHECK(ntdll) << "Fatal Error: NTDLL module was NULL.";
- CHECK(ntdll == ntdll2) << "Fatal Error: NTDLL module has been moved.";
- CHECK(false) << "Fatal Error: GetProcAddress Inconsistency";
- }
+ CHECK(*function_ptr) << "Failed to resolve NTDLL function";
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698