Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 28 additions & 25 deletions pecoff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ backtrace_initialize (struct backtrace_state *state,
#ifdef HAVE_WINDOWS_H
HMODULE nt_dll_handle;

module_handle = (uintptr_t) GetModuleHandle (NULL);
module_handle = (uintptr_t) GetModuleHandle (state->filename);
#endif

ret = coff_add (state, descriptor, error_callback, data,
Expand Down Expand Up @@ -1061,31 +1061,34 @@ backtrace_initialize (struct backtrace_state *state,
#endif

#ifdef HAVE_WINDOWS_H
nt_dll_handle = GetModuleHandleW (L"ntdll.dll");
if (nt_dll_handle)
if ((uintptr_t) GetModuleHandle (NULL) == module_handle)
{
LDR_REGISTER_FUNCTION register_func;
const char register_name[] = "LdrRegisterDllNotification";
register_func = (void*) GetProcAddress (nt_dll_handle,
register_name);

if (register_func)
{
PVOID cookie;
struct dll_notification_context *context
= backtrace_alloc (state,
sizeof (struct dll_notification_context),
error_callback, data);

if (context)
{
context->state = state;
context->data = data;
context->error_callback = error_callback;

register_func (0, &dll_notification, context, &cookie);
}
}
nt_dll_handle = GetModuleHandleW (L"ntdll.dll");
if (nt_dll_handle)
{
LDR_REGISTER_FUNCTION register_func;
const char register_name[] = "LdrRegisterDllNotification";
register_func = (void*) GetProcAddress (nt_dll_handle,
register_name);

if (register_func)
{
PVOID cookie;
struct dll_notification_context *context
= backtrace_alloc (state,
sizeof (struct dll_notification_context),
error_callback, data);

if (context)
{
context->state = state;
context->data = data;
context->error_callback = error_callback;

register_func (0, &dll_notification, context, &cookie);
}
}
}
}
#endif /* defined(HAVE_WINDOWS_H) */

Expand Down