summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-11-05 17:42:58 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-11-05 17:43:07 +0300
commit0c20eac9b081cd9c1c81dfbc3e48e069f859edc1 (patch)
treef3754f8ea5fb40312ae3da88764520e4a33d913f /plugins
parent52921a9e13484319df2d4f1153521f3f5e12b932 (diff)
AssocMsg: fix for launching it via rundll32
Diffstat (limited to 'plugins')
-rw-r--r--plugins/AssocMgr/assocmgr.vcxproj6
-rw-r--r--plugins/AssocMgr/src/assocmgr.def4
-rw-r--r--plugins/AssocMgr/src/dde.cpp50
-rw-r--r--plugins/AssocMgr/src/main.cpp21
-rw-r--r--plugins/AssocMgr/src/stdafx.h3
-rw-r--r--plugins/AssocMgr/src/version.h14
6 files changed, 62 insertions, 36 deletions
diff --git a/plugins/AssocMgr/assocmgr.vcxproj b/plugins/AssocMgr/assocmgr.vcxproj
index ec8afbf2d1..553603b7f8 100644
--- a/plugins/AssocMgr/assocmgr.vcxproj
+++ b/plugins/AssocMgr/assocmgr.vcxproj
@@ -25,4 +25,10 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(ProjectDir)..\..\build\vc.common\plugin.props" />
</ImportGroup>
+ <ItemDefinitionGroup>
+ <Link>
+ <DelayLoadDLLs>api-ms-win-crt-convert-l1-1-0.dll;api-ms-win-crt-runtime-l1-1-0.dll;api-ms-win-crt-string-l1-1-0.dll;mir_app.mir;mir_core.mir;VCRUNTIME140.dll</DelayLoadDLLs>
+ <ModuleDefinitionFile>src/assocmgr.def</ModuleDefinitionFile>
+ </Link>
+ </ItemDefinitionGroup>
</Project> \ No newline at end of file
diff --git a/plugins/AssocMgr/src/assocmgr.def b/plugins/AssocMgr/src/assocmgr.def
new file mode 100644
index 0000000000..7a3f973545
--- /dev/null
+++ b/plugins/AssocMgr/src/assocmgr.def
@@ -0,0 +1,4 @@
+LIBRARY AssocMgr.dll
+
+EXPORTS
+WaitForDDE @1 \ No newline at end of file
diff --git a/plugins/AssocMgr/src/dde.cpp b/plugins/AssocMgr/src/dde.cpp
index f6c52a67df..13da3b00eb 100644
--- a/plugins/AssocMgr/src/dde.cpp
+++ b/plugins/AssocMgr/src/dde.cpp
@@ -182,39 +182,31 @@ static HANDLE StartupMainProcess(wchar_t *pszDatabasePath)
return pi.hProcess;
}
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- // entry point for RunDll32, this is also WaitForDDEW
- __declspec(dllexport) void CALLBACK WaitForDDE(HWND, HINSTANCE, wchar_t *pszCmdLine, int)
- {
- HANDLE pHandles[2];
- DWORD dwTick;
-
- /* wait for dde window to be available (avoiding race condition) */
- pHandles[0] = CreateEvent(NULL, TRUE, FALSE, WNDCLASS_DDEMSGWINDOW);
- if (pHandles[0] != NULL) {
- pHandles[1] = StartupMainProcess(pszCmdLine); /* obeys nCmdShow using GetStartupInfo() */
- if (pHandles[1] != NULL) {
- dwTick = GetTickCount();
- /* either process terminated or dde window created */
- if (WaitForMultipleObjects(_countof(pHandles), pHandles, FALSE, DDEMESSAGETIMEOUT) == WAIT_OBJECT_0) {
- dwTick = GetTickCount() - dwTick;
- if (dwTick < DDEMESSAGETIMEOUT)
- WaitForInputIdle(pHandles[1], DDEMESSAGETIMEOUT - dwTick);
- }
- CloseHandle(pHandles[1]);
+// entry point for RunDll32, this is also WaitForDDEW
+EXTERN_C __declspec(dllexport) void CALLBACK WaitForDDE(HWND, HINSTANCE, wchar_t *pszCmdLine, int)
+{
+ HANDLE pHandles[2];
+ DWORD dwTick;
+
+ /* wait for dde window to be available (avoiding race condition) */
+ pHandles[0] = CreateEvent(NULL, TRUE, FALSE, WNDCLASS_DDEMSGWINDOW);
+ if (pHandles[0] != NULL) {
+ pHandles[1] = StartupMainProcess(pszCmdLine); /* obeys nCmdShow using GetStartupInfo() */
+ if (pHandles[1] != NULL) {
+ dwTick = GetTickCount();
+ /* either process terminated or dde window created */
+ if (WaitForMultipleObjects(_countof(pHandles), pHandles, FALSE, DDEMESSAGETIMEOUT) == WAIT_OBJECT_0) {
+ dwTick = GetTickCount() - dwTick;
+ if (dwTick < DDEMESSAGETIMEOUT)
+ WaitForInputIdle(pHandles[1], DDEMESSAGETIMEOUT - dwTick);
}
- CloseHandle(pHandles[0]);
+ CloseHandle(pHandles[1]);
}
- /* shell called WaitForInputIdle() on us to detect when dde is ready,
- * we are ready now: exit helper process */
+ CloseHandle(pHandles[0]);
}
-
-#ifdef __cplusplus
+ /* shell called WaitForInputIdle() on us to detect when dde is ready,
+ * we are ready now: exit helper process */
}
-#endif
/************************* Misc ***********************************/
diff --git a/plugins/AssocMgr/src/main.cpp b/plugins/AssocMgr/src/main.cpp
index ddc2075d52..10bd63eaf9 100644
--- a/plugins/AssocMgr/src/main.cpp
+++ b/plugins/AssocMgr/src/main.cpp
@@ -21,6 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
+#pragma comment(lib, "delayimp.lib")
+
HINSTANCE hInst;
static HANDLE hHookModulesLoaded;
int hLangpack;
@@ -39,6 +41,25 @@ PLUGININFOEX pluginInfo = {
{0x52685cd7, 0xec7, 0x44c1, {0xa1, 0xa6, 0x38, 0x16, 0x12, 0x41, 0x82, 0x2}}
};
+/////////////////////////////////////////////////////////////////////////////////////////
+// if we run here, we're running from the command prompt
+
+static bool bPathSet = false;
+
+FARPROC WINAPI myDliHook(unsigned dliNotify, PDelayLoadInfo)
+{
+ if (dliNotify == dliNotePreLoadLibrary && !bPathSet) {
+ bPathSet = true;
+ SetCurrentDirectoryW(L"Libs");
+ LoadLibraryW(L"ucrtbase.dll");
+ }
+ return NULL;
+}
+
+PfnDliHook __pfnDliNotifyHook2 = &myDliHook;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
{
hInst = hinstDLL;
diff --git a/plugins/AssocMgr/src/stdafx.h b/plugins/AssocMgr/src/stdafx.h
index 89cf724b45..6c93da6e33 100644
--- a/plugins/AssocMgr/src/stdafx.h
+++ b/plugins/AssocMgr/src/stdafx.h
@@ -24,6 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <malloc.h>
#include <Uxtheme.h>
+#define DELAYIMP_INSECURE_WRITABLE_HOOKS
+#include <delayimp.h>
+
#include <newpluginapi.h>
#include <m_database.h>
#include <m_langpack.h>
diff --git a/plugins/AssocMgr/src/version.h b/plugins/AssocMgr/src/version.h
index b6d649a810..df73ec2cb1 100644
--- a/plugins/AssocMgr/src/version.h
+++ b/plugins/AssocMgr/src/version.h
@@ -19,17 +19,17 @@ along with this program (AssocMgr-License.txt); if not, write to the Free Softwa
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 1
-#define __RELEASE_NUM 1
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 2
+#define __RELEASE_NUM 1
#define __BUILD_NUM 0
#include <stdver.h>
#define __PLUGIN_NAME "File association manager"
#define __FILENAME "AssocMgr.dll"
-#define __DESCRIPTION "Handles file type associations and URLs like aim, gg, mirpu, tlen, wpmsg, xmpp, ymsgr."
-#define __AUTHOR "H. Herkenrath"
+#define __DESCRIPTION "Handles file type associations and URLs like aim, gg, mirpu, tlen, wpmsg, xmpp, ymsgr."
+#define __AUTHOR "H. Herkenrath"
#define __AUTHOREMAIL "hrathh@users.sourceforge.net"
-#define __AUTHORWEB "https://miranda-ng.org/p/AssocMgr/"
-#define __COPYRIGHT "© 2005-2007 H. Herkenrath"
+#define __AUTHORWEB "https://miranda-ng.org/p/AssocMgr/"
+#define __COPYRIGHT "© 2005-2007 H. Herkenrath"