Skip to content

Commit

Permalink
Change to __ImageBase linker directive to fight possible Windows 7 ra…
Browse files Browse the repository at this point in the history
…ce condition.
  • Loading branch information
win32ss committed Mar 8, 2024
1 parent ebdfdf3 commit 25cef38
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
#if BUILDFLAG(IS_WIN)
#include <Windows.h>
extern "C" {
VOID __stdcall TLSInit_DllMain_ThreadAttach(HMODULE DllBase);
VOID __stdcall TLSInit_DllMain_ThreadAttach(IMAGE_DOS_HEADER* DllBase);
}
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
#define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
#endif

namespace {
Expand Down Expand Up @@ -120,7 +122,7 @@ PA_ALWAYS_INLINE void* ShimMalloc(size_t size, void* context) {

PA_ALWAYS_INLINE void* ShimCalloc(size_t n, size_t size, void* context) {
#if BUILDFLAG(IS_WIN)
TLSInit_DllMain_ThreadAttach(::GetModuleHandleA("chrome.dll"));
TLSInit_DllMain_ThreadAttach(&__ImageBase);
#endif
const allocator_shim::AllocatorDispatch* const chain_head =
allocator_shim::internal::GetChainHead();
Expand Down
7 changes: 4 additions & 3 deletions base/sampling_heap_profiler/poisson_allocation_sampler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
#if BUILDFLAG(IS_WIN)
#include <windows.h>
extern "C" {
VOID __stdcall TLSInit_DllMain_ThreadAttach(HMODULE DllBase);
VOID __stdcall TLSInit_DllMain_ThreadAttach(IMAGE_DOS_HEADER* DllBase);
}

EXTERN_C IMAGE_DOS_HEADER __ImageBase;
#define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
#endif

namespace base {
Expand Down Expand Up @@ -251,7 +252,7 @@ void PoissonAllocationSampler::DoRecordAllocation(
const char* context) {

#if BUILDFLAG(IS_WIN)
TLSInit_DllMain_ThreadAttach(::GetModuleHandleA("chrome.dll"));
TLSInit_DllMain_ThreadAttach(&__ImageBase);
#endif
ThreadLocalData* const thread_local_data = GetThreadLocalData();

Expand Down

0 comments on commit 25cef38

Please sign in to comment.