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

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

Issue 12295040: Stop delay loading user32.dll from chrome.dll on x86/Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Build config sketch, mostly works for x86 and x64. Move the hook back to base." Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/win/delay_load_hook.h"
6
7 #if defined(_WIN32_WINNT_WIN8) && _MSC_VER < 1700
8 // The Windows 8 SDK defines FACILITY_VISUALCPP in winerror.h, and in
9 // delayimp.h previous to VS2012.
10 #undef FACILITY_VISUALCPP
11 #endif
12 #include <DelayIMP.h>
13
14 #include "base/logging.h"
15 #include "base/string_util.h"
16 #include "base/stringprintf.h"
17
18 // So long as these symbols are supplied to the final binary through an
19 // object file (as opposed to indirectly thruogh a library), these pointers
20 // will override the CRT's symbols and direct the notifications to our hook.
21 PfnDliHook __pfnDliNotifyHook2 = base::win::DelayLoadHook;
22 PfnDliHook __pfnDliFailureHook2 = base::win::DelayLoadHook;
23
24
25 namespace base {
26 namespace win {
27
28 namespace {
29
30 FARPROC OnPreLoadLibrary(DelayLoadInfo* info) {
31 // If the DLL name ends with "-delay.dll", this call is about one of our
32 // custom import libraries. In this case we need to snip the suffix off,
33 // and bind to the real DLL.
34 std::string dll_name(info->szDll);
35 const char kDelaySuffix[] = "-delay.dll";
cpu_(ooo_6.6-7.5) 2013/03/04 02:18:53 any way to see if we get 8dot3 ~1 madness here? A
Sigurður Ásgeirsson 2013/03/25 20:43:29 You'll get whatever you put into the binary here,
36 if (EndsWith(dll_name, kDelaySuffix, false)) {
37 // Trim the "-delay.dll" suffix from the string.
38 dll_name.resize(dll_name.length() - (sizeof(kDelaySuffix) - 1));
39 dll_name.append(".dll");
40
41 HMODULE dll = ::LoadLibraryA(dll_name.c_str());
42
43 return reinterpret_cast<FARPROC>(dll);
44 }
45
46 return NULL;
47 }
48
49 } // namespace
50
51 FARPROC WINAPI DelayLoadHook(unsigned reason, DelayLoadInfo* info) {
52 switch (reason) {
53 case dliNoteStartProcessing:
54 // Nothing to do here.
55 break;
56
57 case dliNotePreLoadLibrary:
58 return OnPreLoadLibrary(info);
59 break;
60
61 case dliNotePreGetProcAddress:
62 case dliFailLoadLib:
63 case dliFailGetProc:
64 case dliNoteEndProcessing:
65 // Nothing to do here.
cpu_(ooo_6.6-7.5) 2013/03/04 02:18:53 How about this here? // By returning NULL the del
Sigurður Ásgeirsson 2013/03/25 20:43:29 Done.
66 break;
67
68 default:
69 NOTREACHED() << "Impossible delay load notification.";
70 break;
71 }
72
73 return NULL;
74 }
75
76 } // namespace win
77 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698