emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GnuTLS for W32


From: Juanma Barranquero
Subject: Re: GnuTLS for W32
Date: Wed, 4 Jan 2012 16:15:56 +0100

On Wed, Jan 4, 2012 at 15:14, Óscar Fuentes <address@hidden> wrote:

> On the topic of how hard is to load a dll from an arbitrary location,
> that is what I found on the Emacs sources:

And BTW, I prefer the patched version from bug#10424, which records
the full pathname too, and which I'll commit after 24.1 (at least this
change, the one in misc.el could be circumvented with better
customizability of tabulated-list-mode).

> /* The argument LIBRARIES is an alist that associates a symbol
>   LIBRARY_ID, identifying an external DLL library known to Emacs, to
>   a list of filenames under which the library is usually found.  In
>   most cases, the argument passed as LIBRARIES is the variable
>   `dynamic-library-alist', which is initialized to a list of common
>   library names.  If the function loads the library successfully, it
>   returns the handle of the DLL, and records the filename in the
>   property :loaded-from of LIBRARY_ID; it returns NULL if the library
>   could not be found, or when it was already loaded (because the
>   handle is not recorded anywhere, and so is lost after use).  It
>   would be trivial to save the handle too in :loaded-from, but
>   currently there's no use case for it.  */
> HMODULE
> w32_delayed_load (Lisp_Object libraries, Lisp_Object library_id)
> {
>  HMODULE library_dll = NULL;
>
>  CHECK_SYMBOL (library_id);
>
>  if (CONSP (libraries) && NILP (Fassq (library_id, Vlibrary_cache)))
>    {
>      Lisp_Object found = Qnil;
>      Lisp_Object dlls = Fassq (library_id, libraries);
>
>      if (CONSP (dlls))
>        for (dlls = XCDR (dlls); CONSP (dlls); dlls = XCDR (dlls))
>          {
>            CHECK_STRING_CAR (dlls);
>            if ((library_dll = LoadLibrary (SDATA (XCAR (dlls)))))
>              {
-                found = XCAR (dlls);
+                char name[MAX_PATH];
+                DWORD len;
+
+                len = GetModuleFileNameA (library_dll, name, sizeof (name));
+                found = Fcons (XCAR (dlls),
+                               (len > 0)
+                               /* Possibly truncated */
+                               ? make_specified_string (name, -1, len, 1)
+                               : Qnil);
>                break;
>              }
>          }
>
>      Fput (library_id, QCloaded_from, found);
>    }
>
>  return library_dll;
> }

    Juanma



reply via email to

[Prev in Thread] Current Thread [Next in Thread]