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 <windows.h> | 5 #include <windows.h> |
6 #include <DelayIMP.h> | 6 #include <DelayIMP.h> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/scoped_native_library.h" | 10 #include "base/scoped_native_library.h" |
11 #include "chrome/app/delay_load_hook_win.h" | 11 #include "chrome/app/delay_load_hook_win.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 class ChromeDelayLoadHookTest : public testing::Test { | 16 class ChromeDelayLoadHookTest : public testing::Test { |
17 public: | 17 public: |
18 ChromeDelayLoadHookTest() : proc_ptr_(NULL) { | 18 ChromeDelayLoadHookTest() : proc_ptr_(NULL) { |
19 } | 19 } |
20 | 20 |
21 virtual void SetUp() override { | 21 void SetUp() override { |
22 SetupInfo("kernel32.dll"); | 22 SetupInfo("kernel32.dll"); |
23 } | 23 } |
24 | 24 |
25 void SetupInfo(const char* dll_name) { | 25 void SetupInfo(const char* dll_name) { |
26 info_.cb = sizeof(info_); | 26 info_.cb = sizeof(info_); |
27 info_.pidd = NULL; | 27 info_.pidd = NULL; |
28 info_.ppfn = &proc_ptr_; | 28 info_.ppfn = &proc_ptr_; |
29 info_.szDll = dll_name; | 29 info_.szDll = dll_name; |
30 info_.dlp.fImportByName = TRUE; | 30 info_.dlp.fImportByName = TRUE; |
31 info_.dlp.szProcName = "CreateFileA"; | 31 info_.dlp.szProcName = "CreateFileA"; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 TEST_F(ChromeDelayLoadHookTest, IgnoresUnhandledNotifications) { | 76 TEST_F(ChromeDelayLoadHookTest, IgnoresUnhandledNotifications) { |
77 SetupInfo("kernel32-delay.dll"); | 77 SetupInfo("kernel32-delay.dll"); |
78 | 78 |
79 // The hook should ignore all notifications but the preload notifications. | 79 // The hook should ignore all notifications but the preload notifications. |
80 EXPECT_TRUE(ChromeDelayLoadHook(dliNoteStartProcessing, &info_) == NULL); | 80 EXPECT_TRUE(ChromeDelayLoadHook(dliNoteStartProcessing, &info_) == NULL); |
81 EXPECT_TRUE(ChromeDelayLoadHook(dliNotePreGetProcAddress, &info_) == NULL); | 81 EXPECT_TRUE(ChromeDelayLoadHook(dliNotePreGetProcAddress, &info_) == NULL); |
82 EXPECT_TRUE(ChromeDelayLoadHook(dliNoteEndProcessing, &info_) == NULL); | 82 EXPECT_TRUE(ChromeDelayLoadHook(dliNoteEndProcessing, &info_) == NULL); |
83 EXPECT_TRUE(ChromeDelayLoadHook(dliFailLoadLib, &info_) == NULL); | 83 EXPECT_TRUE(ChromeDelayLoadHook(dliFailLoadLib, &info_) == NULL); |
84 EXPECT_TRUE(ChromeDelayLoadHook(dliFailGetProc, &info_) == NULL); | 84 EXPECT_TRUE(ChromeDelayLoadHook(dliFailGetProc, &info_) == NULL); |
85 } | 85 } |
OLD | NEW |