4 // RUN: %clang_cl_asan %LD %Od -DDLL %s %Fe%t.dll
5 // RUN: %clang_cl %Od -DEXE %s %Fe%te.exe
6 // RUN: %env_asan_opts=windows_hook_rtl_allocators=true not %run %te.exe %t.dll 2>&1 | FileCheck %s
7 // REQUIRES: asan-dynamic-runtime
8 // REQUIRES: asan-32-bits
16 int main(int argc
, char **argv
) {
17 void *region_without_hooks
= HeapAlloc(GetProcessHeap(), 0, 10);
18 HMODULE lib
= LoadLibraryA(argv
[1]);
19 assert(lib
!= INVALID_HANDLE_VALUE
);
21 void *region_w_hooks
= HeapAlloc(GetProcessHeap(), 0, 10);
22 assert(region_w_hooks
!= nullptr);
23 assert(0 != FreeLibrary(lib
));
25 fprintf(stderr
, "WITHOUT:0x%08x\n", (unsigned int)region_without_hooks
);
26 fprintf(stderr
, "WITH:0x%08x\n", (unsigned int)region_w_hooks
);
28 assert(0 != HeapFree(GetProcessHeap(), 0, region_without_hooks
));
29 assert(0 != HeapFree(GetProcessHeap(), 0, region_w_hooks
));
31 HeapFree(GetProcessHeap(), 0, region_w_hooks
); //will dump
34 // This global is registered at startup.
36 BOOL WINAPI
DllMain(HMODULE
, DWORD reason
, LPVOID
) {
37 fprintf(stderr
, "in DLL(reason=%d)\n", (int)reason
);
42 // CHECK: in DLL(reason=1)
43 // CHECK: in DLL(reason=0)
44 // CHECK: WITHOUT:[[WITHOUT:0x[0-9a-fA-F]+]]
45 // CHECK: WITH:[[WITH:0x[0-9a-fA-F]+]]
46 // CHECK: AddressSanitizer: attempting double-free on [[WITH]] in thread T0: