mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 12:04:51 +00:00
Fix DD_Cleanup that will make Contry Strike not crashing when it does not found right reslution, thx drfred that found the bug + source cleanup and small bugfix for ntddraw
svn path=/trunk/; revision=18387
This commit is contained in:
parent
690727fe99
commit
5e45c5916f
2 changed files with 85 additions and 136 deletions
|
@ -9,6 +9,7 @@
|
||||||
#define GDI_OBJECT_TYPE_DD_MOTIONCOMP 0x00650000
|
#define GDI_OBJECT_TYPE_DD_MOTIONCOMP 0x00650000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
DD_SURFACE_LOCAL Local;
|
DD_SURFACE_LOCAL Local;
|
||||||
|
@ -26,7 +27,6 @@ typedef struct
|
||||||
// Drv callbacks
|
// Drv callbacks
|
||||||
PGD_GETDIRECTDRAWINFO DrvGetDirectDrawInfo;
|
PGD_GETDIRECTDRAWINFO DrvGetDirectDrawInfo;
|
||||||
PGD_DISABLEDIRECTDRAW DrvDisableDirectDraw;
|
PGD_DISABLEDIRECTDRAW DrvDisableDirectDraw;
|
||||||
PDD_GETDRIVERINFO DdGetDriverInfo;
|
|
||||||
|
|
||||||
// DD callbacks
|
// DD callbacks
|
||||||
DD_CALLBACKS DD;
|
DD_CALLBACKS DD;
|
||||||
|
@ -37,13 +37,28 @@ typedef struct
|
||||||
// Palette callbacks
|
// Palette callbacks
|
||||||
DD_PALETTECALLBACKS Pal;
|
DD_PALETTECALLBACKS Pal;
|
||||||
|
|
||||||
|
// HAL
|
||||||
|
DD_HALINFO Hal;
|
||||||
|
|
||||||
// Color Control Callback
|
// Color Control Callback
|
||||||
PDD_COLORCB_COLORCONTROL DdControlColor;
|
DD_COLORCONTROLCALLBACKS Color;
|
||||||
// Miscellaneous Callback
|
|
||||||
PDD_GETAVAILDRIVERMEMORY DdGetAvailDriverMemory;
|
// D3DHAL_CALLBACKS
|
||||||
|
//D3DHAL_CALLBACKS D3dHal;
|
||||||
|
//D3DHAL_CALLBACKS3 D3dHal3;
|
||||||
|
//D3DHAL_D3DEXTENDEDCAPS D3dHal3Ext;
|
||||||
|
|
||||||
|
// Heap Callback
|
||||||
|
//DD_GETHEAPALIGNMENTDATA HeapData;
|
||||||
|
|
||||||
// Kernel Callback
|
// Kernel Callback
|
||||||
PDD_KERNELCB_SYNCSURFACE DdSyncSurfaceData;
|
//DD_KERNELCALLBACKS Kernel;
|
||||||
PDD_KERNELCB_SYNCVIDEOPORT DdSyncVideoPortData;
|
//DDKERNELCAPS KernelCaps;
|
||||||
|
|
||||||
|
// Miscellaneous Callback
|
||||||
|
DD_MISCELLANEOUSCALLBACKS Misc;
|
||||||
|
|
||||||
|
|
||||||
// NT-based Callback
|
// NT-based Callback
|
||||||
PDD_FLIPTOGDISURFACE DdFlipToGDISurface;
|
PDD_FLIPTOGDISURFACE DdFlipToGDISurface;
|
||||||
PDD_FREEDRIVERMEMORY DdFreeDriverMemory;
|
PDD_FREEDRIVERMEMORY DdFreeDriverMemory;
|
||||||
|
@ -79,15 +94,6 @@ typedef struct
|
||||||
//LPDD_NOTIFYCALLBACK NotifyCallback
|
//LPDD_NOTIFYCALLBACK NotifyCallback
|
||||||
|
|
||||||
|
|
||||||
// D3D Device context callbacks
|
|
||||||
PD3DNTHAL_CONTEXTCREATECB D3dContextCreate;
|
|
||||||
PD3DNTHAL_CONTEXTDESTROYCB D3dContextDestroy;
|
|
||||||
// D3D Buffer callbacks
|
|
||||||
PDD_CANCREATESURFACE DdCanCreateD3DBuffer;
|
|
||||||
PDD_CREATESURFACE DdCreateD3DBuffer;
|
|
||||||
PDD_SURFCB_DESTROYSURFACE DdDestroyD3DBuffer;
|
|
||||||
PDD_SURFCB_LOCK DdLockD3DBuffer;
|
|
||||||
PDD_SURFCB_UNLOCK DdUnlockD3DBuffer;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,13 @@
|
||||||
BOOL INTERNAL_CALL
|
BOOL INTERNAL_CALL
|
||||||
DD_Cleanup(PVOID ObjectBody)
|
DD_Cleanup(PVOID ObjectBody)
|
||||||
{
|
{
|
||||||
PDD_DIRECTDRAW pDD = (PDD_DIRECTDRAW)ObjectBody;
|
PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(ObjectBody, GDI_OBJECT_TYPE_DIRECTDRAW);
|
||||||
pDD->DrvDisableDirectDraw(pDD->Global.dhpdev);
|
if (!pDirectDraw)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
pDirectDraw->DrvDisableDirectDraw(pDirectDraw->Global.dhpdev);
|
||||||
|
|
||||||
|
GDIOBJ_UnlockObjByPtr(pDirectDraw);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,12 +38,13 @@ HANDLE STDCALL NtGdiDdCreateDirectDrawObject(
|
||||||
DD_SURFACECALLBACKS surface_callbacks;
|
DD_SURFACECALLBACKS surface_callbacks;
|
||||||
DD_PALETTECALLBACKS palette_callbacks;
|
DD_PALETTECALLBACKS palette_callbacks;
|
||||||
|
|
||||||
RtlZeroMemory(&callbacks, sizeof(callbacks));
|
RtlZeroMemory(&callbacks, sizeof(DD_CALLBACKS));
|
||||||
callbacks.dwSize = sizeof(callbacks);
|
callbacks.dwSize = sizeof(DD_CALLBACKS);
|
||||||
RtlZeroMemory(&surface_callbacks, sizeof(surface_callbacks));
|
RtlZeroMemory(&surface_callbacks, sizeof(DD_SURFACECALLBACKS));
|
||||||
surface_callbacks.dwSize = sizeof(surface_callbacks);
|
surface_callbacks.dwSize = sizeof(DD_SURFACECALLBACKS);
|
||||||
RtlZeroMemory(&palette_callbacks, sizeof(palette_callbacks));
|
RtlZeroMemory(&palette_callbacks, sizeof(DD_PALETTECALLBACKS));
|
||||||
palette_callbacks.dwSize = sizeof(palette_callbacks);
|
palette_callbacks.dwSize = sizeof(DD_PALETTECALLBACKS);
|
||||||
|
|
||||||
|
|
||||||
DC *pDC = DC_LockDc(hdc);
|
DC *pDC = DC_LockDc(hdc);
|
||||||
if (!pDC)
|
if (!pDC)
|
||||||
|
@ -85,65 +91,13 @@ HANDLE STDCALL NtGdiDdCreateDirectDrawObject(
|
||||||
pDirectDraw->DrvDisableDirectDraw = pDC->DriverFunctions.DisableDirectDraw;
|
pDirectDraw->DrvDisableDirectDraw = pDC->DriverFunctions.DisableDirectDraw;
|
||||||
|
|
||||||
/* DD_CALLBACKS setup */
|
/* DD_CALLBACKS setup */
|
||||||
pDirectDraw->DD.dwFlags = callbacks.dwFlags;
|
RtlMoveMemory(&pDirectDraw->DD, &callbacks, sizeof(DD_CALLBACKS));
|
||||||
|
|
||||||
/* DestroyDriver Unsuse in win2k or higher */
|
/* DD_SURFACECALLBACKS setup*/
|
||||||
if (callbacks.dwFlags & DDHAL_CB32_DESTROYDRIVER)
|
RtlMoveMemory(&pDirectDraw->Surf, &surface_callbacks, sizeof(DD_SURFACECALLBACKS));
|
||||||
pDirectDraw->DD.DestroyDriver = callbacks.DestroyDriver;
|
|
||||||
if (callbacks.dwFlags & DDHAL_CB32_CREATESURFACE)
|
|
||||||
pDirectDraw->DD.CreateSurface = callbacks.CreateSurface;
|
|
||||||
if (callbacks.dwFlags & DDHAL_CB32_SETCOLORKEY)
|
|
||||||
pDirectDraw->DD.SetColorKey = callbacks.SetColorKey;
|
|
||||||
if (callbacks.dwFlags & DDHAL_CB32_SETMODE)
|
|
||||||
pDirectDraw->DD.SetMode = callbacks.SetMode;
|
|
||||||
if (callbacks.dwFlags & DDHAL_CB32_WAITFORVERTICALBLANK)
|
|
||||||
pDirectDraw->DD.WaitForVerticalBlank = callbacks.WaitForVerticalBlank;
|
|
||||||
if (callbacks.dwFlags & DDHAL_CB32_CANCREATESURFACE)
|
|
||||||
pDirectDraw->DD.CanCreateSurface = callbacks.CanCreateSurface;
|
|
||||||
if (callbacks.dwFlags & DDHAL_CB32_CREATEPALETTE)
|
|
||||||
pDirectDraw->DD.CreatePalette = callbacks.CreatePalette;
|
|
||||||
if (callbacks.dwFlags & DDHAL_CB32_GETSCANLINE)
|
|
||||||
pDirectDraw->DD.GetScanLine = callbacks.GetScanLine;
|
|
||||||
if (callbacks.dwFlags & DDHAL_CB32_MAPMEMORY)
|
|
||||||
pDirectDraw->DD.MapMemory = callbacks.MapMemory;
|
|
||||||
|
|
||||||
/* Surface Callbacks */
|
/* DD_PALETTECALLBACKS setup*/
|
||||||
pDirectDraw->Surf.dwFlags = surface_callbacks.dwFlags;
|
RtlMoveMemory(&pDirectDraw->Pal, &surface_callbacks, sizeof(DD_PALETTECALLBACKS));
|
||||||
|
|
||||||
if (surface_callbacks.dwFlags & DDHAL_SURFCB32_DESTROYSURFACE)
|
|
||||||
pDirectDraw->Surf.DestroySurface = surface_callbacks.DestroySurface;
|
|
||||||
if (surface_callbacks.dwFlags & DDHAL_SURFCB32_FLIP)
|
|
||||||
pDirectDraw->Surf.Flip = surface_callbacks.Flip;
|
|
||||||
if (surface_callbacks.dwFlags & DDHAL_SURFCB32_SETCLIPLIST)
|
|
||||||
pDirectDraw->Surf.SetClipList = surface_callbacks.SetClipList;
|
|
||||||
if (surface_callbacks.dwFlags & DDHAL_SURFCB32_LOCK)
|
|
||||||
pDirectDraw->Surf.Lock = surface_callbacks.Lock;
|
|
||||||
if (surface_callbacks.dwFlags & DDHAL_SURFCB32_UNLOCK)
|
|
||||||
pDirectDraw->Surf.Unlock = surface_callbacks.Unlock;
|
|
||||||
if (surface_callbacks.dwFlags & DDHAL_SURFCB32_BLT)
|
|
||||||
pDirectDraw->Surf.Blt = surface_callbacks.Blt;
|
|
||||||
/* DD Callbacks SetColorKey is same as Surface callback SetColorKey */
|
|
||||||
if (surface_callbacks.dwFlags & DDHAL_SURFCB32_SETCOLORKEY)
|
|
||||||
pDirectDraw->Surf.SetColorKey = surface_callbacks.SetColorKey;
|
|
||||||
if (surface_callbacks.dwFlags & DDHAL_SURFCB32_ADDATTACHEDSURFACE)
|
|
||||||
pDirectDraw->Surf.AddAttachedSurface = surface_callbacks.AddAttachedSurface;
|
|
||||||
if (surface_callbacks.dwFlags & DDHAL_SURFCB32_GETBLTSTATUS)
|
|
||||||
pDirectDraw->Surf.GetBltStatus = surface_callbacks.GetBltStatus;
|
|
||||||
if (surface_callbacks.dwFlags & DDHAL_SURFCB32_GETFLIPSTATUS)
|
|
||||||
pDirectDraw->Surf.GetFlipStatus = surface_callbacks.GetFlipStatus;
|
|
||||||
if (surface_callbacks.dwFlags & DDHAL_SURFCB32_UPDATEOVERLAY)
|
|
||||||
pDirectDraw->Surf.UpdateOverlay = surface_callbacks.UpdateOverlay;
|
|
||||||
if (surface_callbacks.dwFlags & DDHAL_SURFCB32_SETOVERLAYPOSITION)
|
|
||||||
pDirectDraw->Surf.SetOverlayPosition = surface_callbacks.SetOverlayPosition;
|
|
||||||
if (surface_callbacks.dwFlags & DDHAL_SURFCB32_SETPALETTE)
|
|
||||||
pDirectDraw->Surf.SetPalette = surface_callbacks.SetPalette;
|
|
||||||
|
|
||||||
/* Palette Callbacks */
|
|
||||||
pDirectDraw->Pal.dwFlags = palette_callbacks.dwFlags;
|
|
||||||
if (palette_callbacks.dwFlags & DDHAL_PALCB32_DESTROYPALETTE)
|
|
||||||
pDirectDraw->Pal.DestroyPalette = palette_callbacks.DestroyPalette;
|
|
||||||
if (palette_callbacks.dwFlags & DDHAL_PALCB32_SETENTRIES)
|
|
||||||
pDirectDraw->Pal.SetEntries = palette_callbacks.SetEntries;
|
|
||||||
|
|
||||||
GDIOBJ_UnlockObjByPtr(pDirectDraw);
|
GDIOBJ_UnlockObjByPtr(pDirectDraw);
|
||||||
DC_UnlockDc(pDC);
|
DC_UnlockDc(pDC);
|
||||||
|
@ -190,28 +144,25 @@ BOOL STDCALL NtGdiDdQueryDirectDrawObject(
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pHalInfo)
|
||||||
|
{
|
||||||
|
RtlMoveMemory(&pDirectDraw->Hal, pHalInfo, sizeof(DD_HALINFO));
|
||||||
|
|
||||||
if (pHalInfo->lpD3DHALCallbacks)
|
if (pHalInfo->lpD3DHALCallbacks)
|
||||||
{
|
{
|
||||||
RtlMoveMemory(puD3dCallbacks, pHalInfo->lpD3DHALCallbacks, sizeof(D3DNTHAL_CALLBACKS));
|
RtlMoveMemory(puD3dCallbacks, pHalInfo->lpD3DHALCallbacks, sizeof(D3DNTHAL_CALLBACKS));
|
||||||
pDirectDraw->D3dContextCreate = puD3dCallbacks->ContextCreate;
|
|
||||||
pDirectDraw->D3dContextDestroy = puD3dCallbacks->ContextDestroy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pHalInfo->lpD3DGlobalDriverData)
|
if (pHalInfo->lpD3DGlobalDriverData)
|
||||||
{
|
{
|
||||||
RtlMoveMemory(puD3dDriverData, pHalInfo->lpD3DGlobalDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA));
|
RtlMoveMemory(puD3dDriverData, pHalInfo->lpD3DGlobalDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pHalInfo->lpD3DBufCallbacks)
|
if (pHalInfo->lpD3DBufCallbacks)
|
||||||
{
|
{
|
||||||
RtlMoveMemory(puD3dBufferCallbacks, pHalInfo->lpD3DBufCallbacks, sizeof(DD_D3DBUFCALLBACKS));
|
RtlMoveMemory(puD3dBufferCallbacks, pHalInfo->lpD3DBufCallbacks, sizeof(DD_D3DBUFCALLBACKS));
|
||||||
pDirectDraw->DdCanCreateD3DBuffer = puD3dBufferCallbacks->CanCreateD3DBuffer;
|
|
||||||
pDirectDraw->DdCreateD3DBuffer = puD3dBufferCallbacks->CreateD3DBuffer;
|
|
||||||
pDirectDraw->DdDestroyD3DBuffer = puD3dBufferCallbacks->DestroyD3DBuffer;
|
|
||||||
pDirectDraw->DdLockD3DBuffer = puD3dBufferCallbacks->LockD3DBuffer;
|
|
||||||
pDirectDraw->DdUnlockD3DBuffer = puD3dBufferCallbacks->UnlockD3DBuffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
GDIOBJ_UnlockObjByPtr(pDirectDraw);
|
GDIOBJ_UnlockObjByPtr(pDirectDraw);
|
||||||
|
|
||||||
|
@ -219,6 +170,27 @@ BOOL STDCALL NtGdiDdQueryDirectDrawObject(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DWORD STDCALL NtGdiDdGetDriverInfo(
|
||||||
|
HANDLE hDirectDrawLocal,
|
||||||
|
PDD_GETDRIVERINFODATA puGetDriverInfoData)
|
||||||
|
|
||||||
|
{
|
||||||
|
DWORD ddRVal;
|
||||||
|
|
||||||
|
PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
|
||||||
|
if (pDirectDraw == NULL)
|
||||||
|
return DDHAL_DRIVER_NOTHANDLED;
|
||||||
|
|
||||||
|
if (!(pDirectDraw->Hal.dwFlags & DDHALINFO_GETDRIVERINFOSET))
|
||||||
|
ddRVal = DDHAL_DRIVER_NOTHANDLED;
|
||||||
|
else
|
||||||
|
ddRVal = pDirectDraw->Hal.GetDriverInfo(puGetDriverInfoData);
|
||||||
|
|
||||||
|
GDIOBJ_UnlockObjByPtr(pDirectDraw);
|
||||||
|
|
||||||
|
return ddRVal;
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* DD CALLBACKS */
|
/* DD CALLBACKS */
|
||||||
/* FIXME NtGdiDdCreateSurface we do not call to ddCreateSurface */
|
/* FIXME NtGdiDdCreateSurface we do not call to ddCreateSurface */
|
||||||
|
@ -653,45 +625,16 @@ BOOL STDCALL NtGdiDdAttachSurface(
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DWORD STDCALL NtGdiDdGetDriverInfo(
|
|
||||||
HANDLE hDirectDrawLocal,
|
|
||||||
PDD_GETDRIVERINFODATA puGetDriverInfoData)
|
|
||||||
|
|
||||||
{
|
|
||||||
DWORD ddRVal;
|
|
||||||
|
|
||||||
PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
|
|
||||||
|
|
||||||
ddRVal = pDirectDraw->DdGetDriverInfo(puGetDriverInfoData);
|
|
||||||
|
|
||||||
GDIOBJ_UnlockObjByPtr(pDirectDraw);
|
|
||||||
|
|
||||||
return ddRVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DWORD STDCALL NtGdiDdGetAvailDriverMemory(
|
DWORD STDCALL NtGdiDdGetAvailDriverMemory(
|
||||||
HANDLE hDirectDrawLocal,
|
HANDLE hDirectDrawLocal,
|
||||||
PDD_GETAVAILDRIVERMEMORYDATA puGetAvailDriverMemoryData
|
PDD_GETAVAILDRIVERMEMORYDATA puGetAvailDriverMemoryData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD ddRVal;
|
DWORD ddRVal = DDHAL_DRIVER_NOTHANDLED;
|
||||||
|
|
||||||
PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
|
PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
|
||||||
|
|
||||||
ddRVal = pDirectDraw->DdGetAvailDriverMemory(puGetAvailDriverMemoryData);
|
// ddRVal = pDirectDraw->DdGetAvailDriverMemory(puGetAvailDriverMemoryData);
|
||||||
|
|
||||||
GDIOBJ_UnlockObjByPtr(pDirectDraw);
|
GDIOBJ_UnlockObjByPtr(pDirectDraw);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue