[PATCH 4/4] ntdll: Print a warning when LdrGetProcedureAddress fails

Zebediah Figura z.figura12 at gmail.com
Mon Jun 8 00:05:49 CDT 2020


On 6/7/20 11:41 PM, Alex Henrie wrote:
> Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
> ---
> This will help tremendously with debugging null pointer segfaults.

Seconded wholeheartedly. I've kept a similar patch in my local tree for 
quite a while.

Even worse, applications will detect that a function is missing but 
silently fail...

> ---
>   dlls/ntdll/loader.c | 11 +++++++++++
>   1 file changed, 11 insertions(+)
> 
> diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
> index d1b71efc07..2c37135105 100644
> --- a/dlls/ntdll/loader.c
> +++ b/dlls/ntdll/loader.c
> @@ -1865,6 +1865,17 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name,
>       }
>   
>       RtlLeaveCriticalSection( &loader_section );
> +
> +    if (__WINE_GET_DEBUGGING_WARN( __wine_dbch___default ) && module && (name || ord) && !*address)

Why not just WARN_ON(module)?

Couldn't we just check for STATUS_PROCEDURE_NOT_FOUND? (I also wouldn't 
think it's worth checking that the parameters are valid.)

> +    {
> +        WCHAR path_buffer[MAX_PATH];
> +        UNICODE_STRING module_path = { 0, sizeof(path_buffer), path_buffer };
> +        path_buffer[0] = 0;
> +        LdrGetDllFullName( module, &module_path );
> +        WARN( "function %s (ordinal %d) not found in module %s\n",
> +              wine_dbgstr_a(name ? name->Buffer : NULL), ord, wine_dbgstr_w(path_buffer) );

As long as we're calling get_modref() in this function anyway, if we're 
concerned about printing the module name, I think it makes sense to just 
access the WINE_MODREF directly. That way you wouldn't have to possibly 
truncate the buffer (not that it probably matters).

> +    }
> +
>       return ret;
>   }
>   
> 




More information about the wine-devel mailing list