Module: wine Branch: master Commit: f95f4660602aad2e6564af3e3a933a68a36b4e82 URL: http://source.winehq.org/git/wine.git/?a=commit;h=f95f4660602aad2e6564af3e3a...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Thu Jun 28 13:11:14 2012 +0200
ddraw: Prevent ddraw from being unloaded.
---
dlls/ddraw/main.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c index db79184..61e8ec9 100644 --- a/dlls/ddraw/main.c +++ b/dlls/ddraw/main.c @@ -812,6 +812,7 @@ DllMain(HINSTANCE hInstDLL, TRACE("(%p,%x,%p)\n", hInstDLL, Reason, lpv); if (Reason == DLL_PROCESS_ATTACH) { + static HMODULE ddraw_self; char buffer[MAX_PATH+10]; DWORD size = sizeof(buffer); HKEY hkey = 0; @@ -911,6 +912,16 @@ DllMain(HINSTANCE hInstDLL, RegCloseKey( hkey ); }
+ /* Prevent the ddraw module from being unloaded. When switching to + * exclusive mode, we replace the window proc of the ddraw window. If + * an application would unload ddraw from the WM_DESTROY handler for + * that window, it would return to unmapped memory and die. Apparently + * this is supposed to work on Windows. We should probably use + * GET_MODULE_HANDLE_EX_FLAG_PIN for this, but that's not currently + * implemented. */ + if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (const WCHAR *)&ddraw_self, &ddraw_self)) + ERR("Failed to get own module handle.\n"); + instance = hInstDLL; DisableThreadLibraryCalls(hInstDLL); }