From 5466bca986569a2169e7354df425c09e29faeed6 Mon Sep 17 00:00:00 2001 From: sebmarchand Date: Wed, 19 Oct 2016 09:16:01 -0700 Subject: [PATCH] Enable the IAT patcher unittests in x64. Review-Url: https://chromiumcodereview.appspot.com/2427043003 --- syzygy/agent/asan/asan.gyp | 11 ++++++---- syzygy/agent/asan/iat_patcher_unittest.cc | 4 ++++ syzygy/pe/export_dll_x64.def | 23 +++++++++++++++++++++ syzygy/pe/pe.gyp | 25 +++++++++++++++++++++++ syzygy/pe/test_dll_x64.def | 4 ++++ 5 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 syzygy/pe/export_dll_x64.def diff --git a/syzygy/agent/asan/asan.gyp b/syzygy/agent/asan/asan.gyp index 0d3cdf3a..85acfc0f 100644 --- a/syzygy/agent/asan/asan.gyp +++ b/syzygy/agent/asan/asan.gyp @@ -217,6 +217,9 @@ 'LargeAddressAware': 1, }, }, + 'dependencies': [ + '<(src)/syzygy/pe/pe.gyp:test_dll', + ], }, { 'sources!': [ # Static shadow doesn't work for large address spaces. @@ -225,13 +228,13 @@ 'memory_interceptors_patcher_unittest.cc', # Relies on full set of probes. 'memory_interceptors_unittest.cc', - # PE lib for win64 is sort of stub, so there's nothing - # to test there. - 'iat_patcher_unittest.cc', # Uses 32bit assembler. 'heap_managers/block_heap_manager_unittest.cc', ], - 'sources': ['dummy_shadow.cc'] + 'sources': ['dummy_shadow.cc'], + 'dependencies': [ + '<(src)/syzygy/pe/pe.gyp:test_dll_x64', + ], }], ], 'dependencies': [ diff --git a/syzygy/agent/asan/iat_patcher_unittest.cc b/syzygy/agent/asan/iat_patcher_unittest.cc index 6b6b989c..294c7261 100644 --- a/syzygy/agent/asan/iat_patcher_unittest.cc +++ b/syzygy/agent/asan/iat_patcher_unittest.cc @@ -38,7 +38,11 @@ class LenientIATPatcherTest : public testing::Test { void SetUp() override { base::FilePath path = +#ifndef _WIN64 testing::GetExeRelativePath(L"test_dll.dll"); +#else + testing::GetExeRelativePath(L"test_dll_x64.dll"); +#endif test_dll_ = ::LoadLibrary(path.value().c_str()); ASSERT_NE(nullptr, test_dll_); } diff --git a/syzygy/pe/export_dll_x64.def b/syzygy/pe/export_dll_x64.def new file mode 100644 index 00000000..eeebd424 --- /dev/null +++ b/syzygy/pe/export_dll_x64.def @@ -0,0 +1,23 @@ +; Copyright 2016 Google Inc. All Rights Reserved. +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. +; +; Export declarations for the export DLL 64-bit build. +LIBRARY export_dll_x64.dll + +EXPORTS + ; Export some functions to make sure the DLL has an exports section. + kExportedData + function1 + function2 @7 NONAME + function3 diff --git a/syzygy/pe/pe.gyp b/syzygy/pe/pe.gyp index 201b2fa1..2b2fb3f9 100644 --- a/syzygy/pe/pe.gyp +++ b/syzygy/pe/pe.gyp @@ -378,6 +378,7 @@ 'test_dll_x64.rc', ], 'dependencies': [ + 'export_dll_x64', '<(src)/syzygy/version/version.gyp:syzygy_version', ], 'msvs_settings': { @@ -504,6 +505,30 @@ }, }, }, + { + 'target_name': 'export_dll_x64', + 'type': 'shared_library', + 'sources': [ + 'export_dll.cc', + 'export_dll_x64.def', + ], + 'msvs_settings': { + }, + 'configurations': { + 'Common_Base': { + 'msvs_settings': { + 'VCLinkerTool': { + 'VCLinkerTool': { + # Force MSVS to produce the same output name as Ninja. + 'ImportLibrary': '$(OutDir)lib\$(TargetFileName).lib' + }, + }, + }, + 'msvs_target_platform': 'x64', + 'msvs_configuration_platform': 'x64', + }, + }, + }, { 'target_name': 'decompose_image_to_text', 'type': 'executable', diff --git a/syzygy/pe/test_dll_x64.def b/syzygy/pe/test_dll_x64.def index 06ac8358..b34ca986 100644 --- a/syzygy/pe/test_dll_x64.def +++ b/syzygy/pe/test_dll_x64.def @@ -19,3 +19,7 @@ EXPORTS ; Export some functions to make sure the DLL has an exports section. DllMain @7 PRIVATE Hello + function1 @17 PRIVATE + ; Export by ordinal only. + function2 @1 NONAME PRIVATE + function3 @9 PRIVATE