From e10344279bbca7787973cccb9fe68697978c0212 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Fri, 10 Apr 2015 13:07:54 +0200 Subject: [PATCH] Better relocation. --- .gitignore | 3 ++- src/aute_smbldap.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a41bfdd..7315df9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ INSTALL Makefile aclocal.m4 autom4te.cache/ +compile config.guess config.log config.status @@ -28,4 +29,4 @@ stamp-h1 tests/test tools/aute-db-mkpwd *.tar.gz -*.exe \ No newline at end of file +*.exe diff --git a/src/aute_smbldap.c b/src/aute_smbldap.c index 526ac26..7e9b634 100644 --- a/src/aute_smbldap.c +++ b/src/aute_smbldap.c @@ -20,6 +20,10 @@ #include "config.h" #endif +#ifdef G_OS_WIN32 +#include +#endif + #include #include #include @@ -82,6 +86,31 @@ enum }; /* PRIVATE */ +#ifdef G_OS_WIN32 +static HMODULE backend_dll = NULL; + +BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved); + +BOOL WINAPI +DllMain (HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpReserved) +{ + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + backend_dll = (HMODULE) hinstDLL; + break; + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} +#endif + + #ifdef HAVE_LIBCONFI static gboolean get_connection_parameters_from_confi (Confi *confi, gchar **user_field) @@ -887,7 +916,7 @@ gchar gchar *moddir; gchar *p; - moddir = g_win32_get_package_installation_directory_of_module (NULL); + moddir = g_win32_get_package_installation_directory_of_module (backend_dll); p = g_strrstr (moddir, g_strdup_printf ("%c", G_DIR_SEPARATOR)); if (p != NULL -- 2.49.0