Skip to content

Commit e705624

Browse files
author
David Major
committedSep 26, 2018
[winasan] Pin the ASan DLL to prevent unloading
Differential Revision: https://reviews.llvm.org/D52505 llvm-svn: 343123
1 parent f0a3fd8 commit e705624

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

‎compiler-rt/lib/asan/asan_win.cc

+8
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@ INTERCEPTOR_WINAPI(void, NtTerminateThread, void *rcx) {
167167
namespace __asan {
168168

169169
void InitializePlatformInterceptors() {
170+
// The interceptors were not designed to be removable, so we have to keep this
171+
// module alive for the life of the process.
172+
HMODULE pinned;
173+
CHECK(GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
174+
GET_MODULE_HANDLE_EX_FLAG_PIN,
175+
(LPCWSTR)&InitializePlatformInterceptors,
176+
&pinned));
177+
170178
ASAN_INTERCEPT_FUNC(CreateThread);
171179
ASAN_INTERCEPT_FUNC(SetUnhandledExceptionFilter);
172180
CHECK(::__interception::OverrideFunction("NtTerminateThread",

0 commit comments

Comments
 (0)