/**
- * Signals a specific event in a running service instance.
+ * Signals a specific event in a running service instance. Since this function
+ * doesn't know whether the service is running through the SCM, it first tries
+ * to open a local event, and if that fails, tries a global event.
*
* @param[in] svcname Name of the service to be signaled.
* @param[in] evtFmt Format string for the event name. It should expect
ASSERT(svcname != NULL);
- evt = Str_Aswprintf(NULL, evtFmt, svcname);
+ evt = Str_Aswprintf(NULL, evtFmt, L"Local", svcname);
+ if (evt == NULL) {
+ g_printerr("Out of memory!\n");
+ goto exit;
+ }
+
+ h = OpenEvent(EVENT_MODIFY_STATE, FALSE, evt);
+ if (h != NULL) {
+ goto dispatch;
+ }
+
+ vm_free(evt);
+ evt = Str_Aswprintf(NULL, evtFmt, L"Global", svcname);
if (evt == NULL) {
g_printerr("Out of memory!\n");
goto exit;
goto error;
}
+dispatch:
if (!SetEvent(h)) {
goto error;
}
/* Used by the Windows implementation to communicate with other processes. */
#if defined(G_PLATFORM_WIN32)
-# define QUIT_EVENT_NAME_FMT L"Global\\VMwareToolsQuitEvent_%s"
-# define DUMP_STATE_EVENT_NAME_FMT L"Global\\VMwareToolsDumpStateEvent_%s"
+# define QUIT_EVENT_NAME_FMT L"%S\\VMwareToolsQuitEvent_%s"
+# define DUMP_STATE_EVENT_NAME_FMT L"%S\\VMwareToolsDumpStateEvent_%s"
#endif
/* On Mac OS, G_MODULE_SUFFIX seems to be defined to "so"... */