| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <windows.h> | 6 #include <windows.h> |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 dll = dll.Append(L"chrome_elf.dll"); | 54 dll = dll.Append(L"chrome_elf.dll"); |
| 55 GetImports(dll, &elf_imports); | 55 GetImports(dll, &elf_imports); |
| 56 | 56 |
| 57 // Check that ELF has imports. | 57 // Check that ELF has imports. |
| 58 ASSERT_LT(0u, elf_imports.size()) << "Ensure the chrome_elf_unittests " | 58 ASSERT_LT(0u, elf_imports.size()) << "Ensure the chrome_elf_unittests " |
| 59 "target was built, instead of chrome_elf_unittests.exe"; | 59 "target was built, instead of chrome_elf_unittests.exe"; |
| 60 | 60 |
| 61 std::vector<std::string>::iterator it(elf_imports.begin()); | 61 std::vector<std::string>::iterator it(elf_imports.begin()); |
| 62 | 62 |
| 63 static const char* const kValidFilePatterns[] = { | 63 static const char* const kValidFilePatterns[] = { |
| 64 "KERNEL32.dll", | 64 "KERNEL32.dll", |
| 65 "MSVC*", | 65 "MSVC*", |
| 66 #if defined(ADDRESS_SANITIZER) | 66 #if defined(SYZYASAN) |
| 67 "syzyasan_rtl.dll", | 67 "syzyasan_rtl.dll", |
| 68 #endif | 68 #endif |
| 69 "ADVAPI32.dll"}; | 69 "ADVAPI32.dll" |
| 70 }; |
| 70 | 71 |
| 71 // Make sure all of ELF's imports are in the valid imports list. | 72 // Make sure all of ELF's imports are in the valid imports list. |
| 72 for (; it != elf_imports.end(); it++) { | 73 for (; it != elf_imports.end(); it++) { |
| 73 bool match = false; | 74 bool match = false; |
| 74 for (int i = 0; i < arraysize(kValidFilePatterns); ++i) { | 75 for (int i = 0; i < arraysize(kValidFilePatterns); ++i) { |
| 75 if (MatchPattern(*it, kValidFilePatterns[i])) | 76 if (MatchPattern(*it, kValidFilePatterns[i])) |
| 76 match = true; | 77 match = true; |
| 77 } | 78 } |
| 78 ASSERT_TRUE(match) << "Illegal import in chrome_elf.dll."; | 79 ASSERT_TRUE(match) << "Illegal import in chrome_elf.dll."; |
| 79 } | 80 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 91 ASSERT_LT(0u, exe_imports.size()) << "Ensure the chrome_elf_unittests " | 92 ASSERT_LT(0u, exe_imports.size()) << "Ensure the chrome_elf_unittests " |
| 92 "target was built, instead of chrome_elf_unittests.exe"; | 93 "target was built, instead of chrome_elf_unittests.exe"; |
| 93 | 94 |
| 94 // Chrome.exe's first import must be ELF. | 95 // Chrome.exe's first import must be ELF. |
| 95 EXPECT_EQ("chrome_elf.dll", exe_imports[0]) << | 96 EXPECT_EQ("chrome_elf.dll", exe_imports[0]) << |
| 96 "Illegal import order in chrome.exe (ensure the chrome_elf_unittest " | 97 "Illegal import order in chrome.exe (ensure the chrome_elf_unittest " |
| 97 "target was built, instead of just chrome_elf_unittests.exe)"; | 98 "target was built, instead of just chrome_elf_unittests.exe)"; |
| 98 } | 99 } |
| 99 | 100 |
| 100 } // namespace | 101 } // namespace |
| OLD | NEW |