aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/w32-util.c')
-rw-r--r--src/w32-util.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/src/w32-util.c b/src/w32-util.c
index 79541898..8a04c8c1 100644
--- a/src/w32-util.c
+++ b/src/w32-util.c
@@ -99,8 +99,6 @@ static char *default_gpgconf_name;
gpgme_set_global_flag and accessed by _gpgme_get_inst_dir. */
static char *override_inst_dir;
-#ifdef HAVE_ALLOW_SET_FOREGROUND_WINDOW
-
#define RTLD_LAZY 0
static GPG_ERR_INLINE void *
@@ -135,7 +133,6 @@ dlclose (void * hd)
}
return -1;
}
-#endif /* HAVE_ALLOW_SET_FOREGROUND_WINDOW */
/* Return a malloced string encoded in UTF-8 from the wide char input
@@ -241,6 +238,45 @@ _gpgme_allow_set_foreground_window (pid_t pid)
}
+/* Wrapper around CancelSynchronousIo which is only available since
+ * Vista. */
+void
+_gpgme_w32_cancel_synchronous_io (HANDLE thread)
+{
+ static int initialized;
+ static BOOL (WINAPI * func)(DWORD);
+ void *handle;
+
+ if (!initialized)
+ {
+ /* Available since Vista; thus we dynload it. */
+ initialized = 1;
+ handle = dlopen ("kerner32.dll", RTLD_LAZY);
+ if (handle)
+ {
+ func = dlsym (handle, "CancelSynchronousIo");
+ if (!func)
+ {
+ dlclose (handle);
+ handle = NULL;
+ }
+ }
+ }
+
+ if (func)
+ {
+ int rc = func (thread);
+ TRACE2 (DEBUG_ENGINE, "gpgme:CancelSynchronousIo", 0,
+ "called for thread %p; result=%d", thread, rc);
+ }
+ else
+ {
+ TRACE0 (DEBUG_ENGINE, "gpgme:CancelSynchronousIo", 0,
+ "function not available");
+ }
+}
+
+
/* Return a string from the W32 Registry or NULL in case of error.
Caller must release the return value. A NULL for root is an alias
for HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE in turn. */