Module: wine
Branch: master
Commit: f95f4660602aad2e6564af3e3a933a68a36b4e82
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f95f4660602aad2e6564af3e3…
Author: Henri Verbeet <hverbeet(a)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);
}
Module: wine
Branch: master
Commit: 91f02018c59cb0254556d513f4881dd2354b3ffe
URL: http://source.winehq.org/git/wine.git/?a=commit;h=91f02018c59cb0254556d513f…
Author: Henri Verbeet <hverbeet(a)codeweavers.com>
Date: Thu Jun 28 13:11:10 2012 +0200
wined3d: Avoid a useless call to wined3d_get_adapter_mode_count() in wined3d_enum_adapter_modes().
---
dlls/wined3d/directx.c | 19 ++++++++-----------
1 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 1cce96b..88e6a91 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -2945,12 +2945,8 @@ HRESULT CDECL wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT ada
TRACE("wined3d %p, adapter_idx %u, format %s, mode_idx %u, mode %p.\n",
wined3d, adapter_idx, debug_d3dformat(format_id), mode_idx, mode);
- /* Validate the parameters as much as possible */
- if (!mode || adapter_idx >= wined3d->adapter_count
- || mode_idx >= wined3d_get_adapter_mode_count(wined3d, adapter_idx, format_id))
- {
+ if (!mode || adapter_idx >= wined3d->adapter_count)
return WINED3DERR_INVALIDCALL;
- }
/* TODO: Store modes per adapter and read it from the adapter structure */
if (!adapter_idx)
@@ -2968,8 +2964,14 @@ HRESULT CDECL wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT ada
/* If we are filtering to a specific format (D3D9), then need to skip
all unrelated modes, but if mode is irrelevant (D3D8), then we can
just count through the ones with valid bit depths */
- while (i <= mode_idx && EnumDisplaySettingsExW(NULL, j++, &DevModeW, 0))
+ while (i <= mode_idx)
{
+ if (!EnumDisplaySettingsExW(NULL, j++, &DevModeW, 0))
+ {
+ WARN("Invalid mode_idx %u.\n", mode_idx);
+ return WINED3DERR_INVALIDCALL;
+ }
+
if (format_id == WINED3DFMT_UNKNOWN)
{
/* This is for D3D8, do not enumerate P8 here */
@@ -2981,11 +2983,6 @@ HRESULT CDECL wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT ada
}
}
- if (!i)
- {
- TRACE("No modes found for format %s (%#x).\n", debug_d3dformat(format_id), format_id);
- return WINED3DERR_INVALIDCALL;
- }
ModeIdx = j - 1;
/* Now get the display mode via the calculated index */