Skip to content

Commit

Permalink
[winasan] Pin the ASan DLL to prevent unloading
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D52505

llvm-svn: 343123
  • Loading branch information
David Major committed Sep 26, 2018
1 parent f0a3fd8 commit e705624
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions compiler-rt/lib/asan/asan_win.cc
Expand Up @@ -167,6 +167,14 @@ INTERCEPTOR_WINAPI(void, NtTerminateThread, void *rcx) {
namespace __asan {

void InitializePlatformInterceptors() {
// The interceptors were not designed to be removable, so we have to keep this
// module alive for the life of the process.
HMODULE pinned;
CHECK(GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_PIN,
(LPCWSTR)&InitializePlatformInterceptors,
&pinned));

ASAN_INTERCEPT_FUNC(CreateThread);
ASAN_INTERCEPT_FUNC(SetUnhandledExceptionFilter);
CHECK(::__interception::OverrideFunction("NtTerminateThread",
Expand Down

0 comments on commit e705624

Please sign in to comment.