• thakis's avatar
    win: Remove GetModuleFromAddress, deduplicate __ImageBase code. · d62f5447
    thakis authored
    8 different places were using __ImageBase to get the current module,
    create a CURRENT_MODULE() macro that all these places can use.
    
    All but one use of base::GetModuleFromAddress() were used to get
    the module of the current file; change all these to use
    CURRENT_MODULE() instead.
    
    The (somewhat lame) motivation is that GetModuleFromAddress() took
    a void* but was always called with function pointers, and converting
    function pointers to void* has undefined behavior. POSIX (dlsym())
    requires that conversions between void* and function pointers work
    in practice, but on posix an explicit reinterpret_cast is required, and it
    seems nice to have compilers behave identically between platforms
    here (i.e. we should turn on clang/win's -Wmicrosoft-cast).
    
    In the one place where GetModuleFromAddress() didn't refer to the
    current TU's module, add an explicit reinterpret_cast.
    
    BUG=550065
    TBR=asvitkine,wez
    
    Review URL: https://codereview.chromium.org/1852143002
    
    Cr-Commit-Position: refs/heads/master@{#384841}
    d62f5447
file_version_info.h 2.79 KB