Index: base/win/pe_image_unittest.cc |
diff --git a/base/win/pe_image_unittest.cc b/base/win/pe_image_unittest.cc |
index e20af22530551a958da9f98c2d253c792c5fed59..3c2a266770085419f915b949f2288715db429915 100644 |
--- a/base/win/pe_image_unittest.cc |
+++ b/base/win/pe_image_unittest.cc |
@@ -102,20 +102,20 @@ TEST(PEImageTest, EnumeratesPE) { |
const int sections = 6; |
const int imports_dlls = 2; |
const int delay_dlls = 2; |
- const int exports = 2; |
- const int imports = 69; |
+ const int exports = 3; |
+ const int imports = 70; |
const int delay_imports = 2; |
- const int relocs = 632; |
+ const int relocs = 976; |
#else |
pe_image_test_path = |
pe_image_test_path.Append(FILE_PATH_LITERAL("pe_image_test_32.dll")); |
const int sections = 5; |
const int imports_dlls = 2; |
const int delay_dlls = 2; |
- const int exports = 2; |
+ const int exports = 3; |
const int imports = 66; |
const int delay_imports = 2; |
- const int relocs = 1586; |
+ const int relocs = 2114; |
#endif |
HMODULE module = LoadLibrary(pe_image_test_path.value().c_str()); |
@@ -174,6 +174,37 @@ TEST(PEImageTest, RetrievesExports) { |
FreeLibrary(module); |
} |
+// Tests that we can locate a forwarded export. |
+TEST(PEImageTest, ForwardedExport) { |
+ base::FilePath pe_image_test_path; |
+ ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &pe_image_test_path)); |
+ pe_image_test_path = pe_image_test_path.Append(FILE_PATH_LITERAL("pe_image")); |
+ |
+#if defined(ARCH_CPU_64_BITS) |
+ pe_image_test_path = |
+ pe_image_test_path.Append(FILE_PATH_LITERAL("pe_image_test_64.dll")); |
+#else |
+ pe_image_test_path = |
+ pe_image_test_path.Append(FILE_PATH_LITERAL("pe_image_test_32.dll")); |
+#endif |
+ |
+ HMODULE module = LoadLibrary(pe_image_test_path.value().c_str()); |
+ ASSERT_TRUE(NULL != module); |
+ |
+ PEImage pe(module); |
+ |
+ FARPROC addr = pe.GetProcAddress("FwdExport"); |
+ EXPECT_EQ(FARPROC(-1), addr); |
Nico
2015/12/24 14:11:11
same question
Will Harris
2015/12/24 19:22:03
Acknowledged.
|
+ |
+ PDWORD export_entry = pe.GetExportEntry("FwdExport"); |
+ EXPECT_NE(nullptr, export_entry); |
+ PVOID fwd_addr = pe.RVAToAddr(*export_entry); |
+ const char expected_fwd[] = "KERNEL32.CreateFileA"; |
+ EXPECT_STREQ(expected_fwd, reinterpret_cast<char*>(fwd_addr)); |
+ |
+ FreeLibrary(module); |
Nico
2015/12/24 14:11:11
(i'm a bit surprised we don't have a ScopedFoo for
Will Harris
2015/12/24 19:22:03
yes, we do, it's base::ScopedNativeLibrary so I sw
|
+} |
+ |
// Test that we can get debug id out of a module. |
TEST(PEImageTest, GetDebugId) { |
HMODULE module = LoadLibrary(L"advapi32.dll"); |