summaryrefslogtreecommitdiff
path: root/lib/interception
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-04-16 16:02:53 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-04-16 16:02:53 +0000
commitab0bf875a5f328a6710f4e48258979ae1bc8da1c (patch)
tree66903cf9f73151825893dcc216b04c0930317a10 /lib/interception
parentabacad30a54c59ad437ccf54ec5236a8dd7f3ba9 (diff)
Notes
Diffstat (limited to 'lib/interception')
-rw-r--r--lib/interception/interception_win.cc2
-rw-r--r--lib/interception/tests/interception_win_test.cc7
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/interception/interception_win.cc b/lib/interception/interception_win.cc
index 91abecf6de5f0..e4f3d358f40c0 100644
--- a/lib/interception/interception_win.cc
+++ b/lib/interception/interception_win.cc
@@ -878,6 +878,8 @@ uptr InternalGetProcAddress(void *module, const char *func_name) {
IMAGE_DATA_DIRECTORY *export_directory =
&headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT];
+ if (export_directory->Size == 0)
+ return 0;
RVAPtr<IMAGE_EXPORT_DIRECTORY> exports(module,
export_directory->VirtualAddress);
RVAPtr<DWORD> functions(module, exports->AddressOfFunctions);
diff --git a/lib/interception/tests/interception_win_test.cc b/lib/interception/tests/interception_win_test.cc
index 684ee03035590..a705768d6d5d2 100644
--- a/lib/interception/tests/interception_win_test.cc
+++ b/lib/interception/tests/interception_win_test.cc
@@ -613,6 +613,13 @@ TEST(Interception, PatchableFunctionPadding) {
EXPECT_FALSE(TestFunctionPatching(kUnpatchableCode6, override, prefix));
}
+TEST(Interception, EmptyExportTable) {
+ // We try to get a pointer to a function from an executable that doesn't
+ // export any symbol (empty export table).
+ uptr FunPtr = InternalGetProcAddress((void *)GetModuleHandleA(0), "example");
+ EXPECT_EQ(0U, FunPtr);
+}
+
} // namespace __interception
#endif // SANITIZER_WINDOWS