From a709c01ca88ead74fe02a08c91b90d1250b83e1f Mon Sep 17 00:00:00 2001 From: Magnus Olsen Date: Sat, 2 Dec 2006 13:37:55 +0000 Subject: [PATCH] fixed partly linking with other directdraw interface, but we still overwrite some member and crash it, when we doing a link. svn path=/trunk/; revision=25016 --- reactos/dll/directx/ddraw/startup.c | 31 ++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/reactos/dll/directx/ddraw/startup.c b/reactos/dll/directx/ddraw/startup.c index d0a6a7a0183..4435c0561fa 100644 --- a/reactos/dll/directx/ddraw/startup.c +++ b/reactos/dll/directx/ddraw/startup.c @@ -879,20 +879,37 @@ Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface, REFIID id, BOOL ex) -{ - LPDDRAWI_DIRECTDRAW_INT This; - +{ + LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)*pIface; + DX_WINDBG_trace(); if (!IsEqualGUID(&IID_IDirectDraw7, id)) { return DDERR_INVALIDDIRECTDRAWGUID; } - - This = DxHeapMemAlloc(sizeof(DDRAWI_DIRECTDRAW_INT)); - if (This == NULL) + + + if (This == NULL) { - return DDERR_OUTOFMEMORY; + /* We do not have any DirectDraw interface alloc */ + This = DxHeapMemAlloc(sizeof(DDRAWI_DIRECTDRAW_INT)); + if (This == NULL) + { + return DDERR_OUTOFMEMORY; + } + } + else + { + /* We got the DirectDraw interface alloc and we need create the link */ + LPDDRAWI_DIRECTDRAW_INT newThis; + newThis = DxHeapMemAlloc(sizeof(DDRAWI_DIRECTDRAW_INT)); + if (newThis == NULL) + { + return DDERR_OUTOFMEMORY; + } + newThis->lpLink = This; + This = newThis; } This->lpLcl = DxHeapMemAlloc(sizeof(DDRAWI_DIRECTDRAW_INT));