| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/app/delay_load_hook_win.h" | 5 #include "chrome/app/delay_load_hook_win.h" |
| 6 | 6 |
| 7 #include <DelayIMP.h> | 7 #include <DelayIMP.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 | 12 |
| 13 // So long as these symbols are supplied to the final binary through an | 13 // So long as these symbols are supplied to the final binary through an |
| 14 // object file (as opposed to indirectly through a library), these pointers | 14 // object file (as opposed to indirectly through a library), these pointers |
| 15 // will override the CRT's symbols and direct the notifications to our hook. | 15 // will override the CRT's symbols and direct the notifications to our hook. |
| 16 // Alternatively referencing the ChromeDelayLoadHook function somehow will | 16 // Alternatively referencing the ChromeDelayLoadHook function somehow will |
| 17 // cause this declaration of these variables to take preference to the delay | 17 // cause this declaration of these variables to take preference to the delay |
| 18 // load runtime's defaults (in delayimp.lib). | 18 // load runtime's defaults (in delayimp.lib). |
| 19 PfnDliHook __pfnDliNotifyHook2 = ChromeDelayLoadHook; | 19 const PfnDliHook __pfnDliNotifyHook2 = ChromeDelayLoadHook; |
| 20 PfnDliHook __pfnDliFailureHook2 = ChromeDelayLoadHook; | 20 const PfnDliHook __pfnDliFailureHook2 = ChromeDelayLoadHook; |
| 21 | 21 |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 FARPROC OnPreLoadLibrary(DelayLoadInfo* info) { | 25 FARPROC OnPreLoadLibrary(DelayLoadInfo* info) { |
| 26 // If the DLL name ends with "-delay.dll", this call is about one of our | 26 // If the DLL name ends with "-delay.dll", this call is about one of our |
| 27 // custom import libraries. In this case we need to snip the suffix off, | 27 // custom import libraries. In this case we need to snip the suffix off, |
| 28 // and bind to the real DLL. | 28 // and bind to the real DLL. |
| 29 std::string dll_name(info->szDll); | 29 std::string dll_name(info->szDll); |
| 30 const char kDelaySuffix[] = "-delay.dll"; | 30 const char kDelaySuffix[] = "-delay.dll"; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 default: | 73 default: |
| 74 NOTREACHED() << "Impossible delay load notification."; | 74 NOTREACHED() << "Impossible delay load notification."; |
| 75 break; | 75 break; |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Returning NULL causes the delay load machinery to perform default | 78 // Returning NULL causes the delay load machinery to perform default |
| 79 // processing for this notification. | 79 // processing for this notification. |
| 80 return NULL; | 80 return NULL; |
| 81 } | 81 } |
| OLD | NEW |