git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 1/1] Win32: simplify loading of DLL functions

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Sep 25, 2017, 16:52 UTC
Message-ID
<20170925165211.GN27425@aiede.mtv.corp.google.com>
In-Reply-To
<177d34742e603aabb57046a0d5f9a5c6e40696ca.1506355545.git.johannes.schindelin@gmx.de>
Johannes Schindelin wrote:
Show 27 quoted lines
> Dynamic loading of DLL functions is duplicated in several places in Git
> for Windows' source code.
>
> This patch adds a pair of macros to simplify the process: the
> DECLARE_PROC_ADDR(<dll>, <return-type>, <function-name>,
> ...<function-parameter-types>...) macro to be used at the beginning of a
> code block, and the INIT_PROC_ADDR(<function-name>) macro to call before
> using the declared function. The return value of the INIT_PROC_ADDR()
> call has to be checked; If it is NULL, the function was not found in the
> specified DLL.
>
> Example:
>
>         DECLARE_PROC_ADDR(kernel32.dll, BOOL, CreateHardLinkW,
>                           LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
>
>         if (!INIT_PROC_ADDR(CreateHardLinkW))
>                 return error("Could not find CreateHardLinkW() function";
>
> 	if (!CreateHardLinkW(source, target, NULL))
> 		return error("could not create hardlink from %S to %S",
> 			     source, target);
> 	return 0;
>
> Signed-off-by: Karsten Blees <blees@dcon.de>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Yep, this is indeed
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
>  compat/win32/lazyload.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 57 insertions(+)
>  create mode 100644 compat/win32/lazyload.h

Thanks, Jonathan

Previous: Johannes Schindelin
Message 9 of 9 in “Win32: simplify loading of DLL functions”
  1. Win32: simplify loading of DLL functionsJohannes Schindelin, Sep 19, 2017
  2. Jonathan NiederSep 19, 2017
  3. Junio C HamanoSep 20, 2017
  4. Johannes SchindelinSep 20, 2017
  5. Jonathan NiederSep 20, 2017
  6. Junio C HamanoSep 21, 2017
  7. 0/1 Simplify loading of DLL functions on WindowsJohannes Schindelin, Sep 25, 2017
  8. 1/1 Win32: simplify loading of DLL functionsJohannes Schindelin, Sep 25, 2017
  9. Jonathan NiederSep 25, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.