]> saetta.ns0.it Git - zakaudit/libzakaudit/commitdiff
Better relocation under win32.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Tue, 5 May 2015 08:38:43 +0000 (10:38 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Tue, 5 May 2015 08:38:43 +0000 (10:38 +0200)
src/audit.c
tests/test1.c

index b18bf49d2ce80ef4205fe40655f600e1303854de..c4f2faeb525942e81f68b796a2ad0fb07912fc03 100644 (file)
 
 #include <string.h>
 
+#include <glib.h>
+
+#ifdef G_OS_WIN32
+       #include <windows.h>
+#endif
+
 #include <libgda/sql-parser/gda-sql-parser.h>
 
 #include "libzakaudit.h"
@@ -133,6 +139,30 @@ struct _ZakAuditPrivate
 /* PRIVATE */
 G_DEFINE_TYPE (ZakAudit, zak_audit, G_TYPE_OBJECT)
 
+#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
+
 static void
 zak_audit_class_init (ZakAuditClass *klass)
 {
@@ -170,7 +200,7 @@ static ZakAudit
        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
index 207092b9e578467cb226f472df680bdee0380465..0a89dd93ba473cb94af06e359b20a9936eb42e78 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * test1.c
  *
- * Copyright (C) 2005-2014 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2015 Andrea Zagli <azagli@libero.it>
  *
  *  This file is part of libaudit.
  *