summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/win/MainWin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/win/MainWin.cpp')
-rw-r--r--Source/WebKit2/win/MainWin.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/Source/WebKit2/win/MainWin.cpp b/Source/WebKit2/win/MainWin.cpp
index 7aea3f2..c12d048 100644
--- a/Source/WebKit2/win/MainWin.cpp
+++ b/Source/WebKit2/win/MainWin.cpp
@@ -23,6 +23,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <shlwapi.h>
#include <windows.h>
#if defined _M_IX86
@@ -37,9 +38,30 @@
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='" PROCESSORARCHITECTURE "' publicKeyToken='6595b64144ccf1df' language='*'\"")
-extern "C" __declspec(dllimport) int WebKitMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrCmdLine, int nCmdShow);
-
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrCmdLine, int nCmdShow)
{
- return WebKitMain(hInstance, hPrevInstance, lpstrCmdLine, nCmdShow);
+#ifndef DEBUG_ALL
+ LPCWSTR webKitDLLName = L"WebKit.dll";
+#else
+ LPCTSTR webKitDLLName = L"WebKit_debug.dll";
+#endif
+
+ WCHAR webKitPath[MAX_PATH];
+ ::GetModuleFileNameW(0, webKitPath, ARRAYSIZE(webKitPath));
+ ::PathRemoveFileSpecW(webKitPath);
+
+ // Look for DLLs in the same directory as WebKit2WebProcess.exe. This is not in the search
+ // path already, since we launch WebKit2WebProcess.exe via CreateProcess with lpCurrentDirectory
+ // set to 0. We want both the WebKit client app DLL path and the WebKit directory DLL path in
+ // the DLL search order, and we want the current directory set to the WebKit client app path.
+ ::SetDllDirectoryW(webKitPath);
+
+ ::PathAppendW(webKitPath, webKitDLLName);
+ HMODULE module = ::LoadLibraryW(webKitPath);
+ typedef int (__cdecl* WebKitMainProcPtr)(HINSTANCE, HINSTANCE, LPTSTR, int);
+ WebKitMainProcPtr mainProc = reinterpret_cast<WebKitMainProcPtr>(GetProcAddress(module, "WebKitMain"));
+ if (!mainProc)
+ return 0;
+
+ return mainProc(hInstance, hPrevInstance, lpstrCmdLine, nCmdShow);
}