📄 ddraw.c
字号:
SetLastNtError(Status);
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return Ret;
}
}
else
{
DPRINT1("GDIOBJ_UnlockObjByPtr\n");
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return Ret;
}
/*
* Get puD3dCallbacks
*/
if (puD3dCallbacks != NULL)
{
DPRINT1("copy pDirectDraw->Hal.lpD3DHALCallbacks to puD3dCallbacks\n");
if (pDirectDraw->Hal.lpD3DHALCallbacks != NULL)
{
_SEH_TRY
{
ProbeForWrite(puD3dCallbacks, sizeof(D3DNTHAL_CALLBACKS), 1);
RtlCopyMemory( puD3dCallbacks, pDirectDraw->Hal.lpD3DHALCallbacks,
sizeof( D3DNTHAL_CALLBACKS ) );
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
if(!NT_SUCCESS(Status))
{
DPRINT1("GDIOBJ_UnlockObjByPtr and SetLastNtError\n");
SetLastNtError(Status);
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return Ret;
}
}
}
else
{
DPRINT1("GDIOBJ_UnlockObjByPtr\n");
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return Ret;
}
/*
* Get lpD3DGlobalDriverData
*/
if (puD3dDriverData != NULL)
{
DPRINT1("copy pDirectDraw->Hal.lpD3DGlobalDriverData to puD3dDriverData\n");
if (pDirectDraw->Hal.lpD3DGlobalDriverData != NULL)
{
_SEH_TRY
{
LPD3DNTHAL_GLOBALDRIVERDATA MyD3d;
DPRINT1("Found DirectDraw GlobalDriverData for 3D Hal\n");
MyD3d = (LPD3DNTHAL_GLOBALDRIVERDATA) pDirectDraw->Hal.lpD3DGlobalDriverData;
/* Get puD3dDriverData */
ProbeForWrite(puD3dDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA), 1);
RtlCopyMemory( puD3dDriverData, pDirectDraw->Hal.lpD3DGlobalDriverData,
sizeof(D3DNTHAL_GLOBALDRIVERDATA));
/* Get puD3dTextureFormats */
if (puD3dTextureFormats != NULL)
{
ProbeForWrite(puD3dTextureFormats, sizeof(DDSURFACEDESC) * MyD3d->dwNumTextureFormats, 1);
if (( MyD3d->lpTextureFormats != NULL) && ( MyD3d->dwNumTextureFormats != 0))
{
RtlCopyMemory( puD3dTextureFormats, MyD3d->lpTextureFormats, sizeof(DDSURFACEDESC) * MyD3d->dwNumTextureFormats);
}
ProbeForWrite(puD3dDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA), 1);
}
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
if(!NT_SUCCESS(Status))
{
DPRINT1("GDIOBJ_UnlockObjByPtr and SetLastNtError\n");
SetLastNtError(Status);
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return Ret;
}
}
}
else
{
DPRINT1("GDIOBJ_UnlockObjByPtr\n");
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return Ret;
}
/*
* Get puD3dBufferCallbacks
*/
if (puD3dBufferCallbacks != NULL)
{
DPRINT1("copy pDirectDraw->Hal.lpD3DGlobalDriverData to puD3dBufferCallbacks\n");
if (pDirectDraw->Hal.lpD3DBufCallbacks != NULL)
{
DPRINT1("Found DirectDraw CallBack for 3D Hal Bufffer \n");
_SEH_TRY
{
ProbeForWrite(puD3dBufferCallbacks, sizeof(DD_D3DBUFCALLBACKS), 1);
RtlCopyMemory( puD3dBufferCallbacks, pDirectDraw->Hal.lpD3DBufCallbacks,
sizeof(DD_D3DBUFCALLBACKS));
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
if(!NT_SUCCESS(Status))
{
DPRINT1("GDIOBJ_UnlockObjByPtr and SetLastNtError\n");
SetLastNtError(Status);
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return Ret;
}
}
}
else
{
DPRINT1("GDIOBJ_UnlockObjByPtr\n");
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return Ret;
}
DPRINT1("next\n");
_SEH_TRY
{
ProbeForWrite(puNumHeaps, sizeof(DWORD), 1);
*puNumHeaps = pDirectDraw->dwNumHeaps;
if ((pDirectDraw->pvmList != NULL) && (puvmList != NULL))
{
ProbeForWrite(puvmList, sizeof(VIDEOMEMORY) * pDirectDraw->dwNumHeaps, 1);
RtlCopyMemory( puvmList, pDirectDraw->pvmList, sizeof(VIDEOMEMORY) * pDirectDraw->dwNumHeaps);
}
ProbeForWrite(puNumFourCC, sizeof(DWORD), 1);
*puNumFourCC = pDirectDraw->dwNumFourCC;
if ((pDirectDraw->pdwFourCC != NULL) && (puFourCC != NULL))
{
ProbeForWrite(puFourCC, sizeof(DWORD) * pDirectDraw->dwNumFourCC, 1);
RtlCopyMemory( puFourCC, pDirectDraw->pdwFourCC, sizeof(DWORD) * pDirectDraw->dwNumFourCC);
}
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
}
else
{
Ret = TRUE;
}
return Ret;
}
BOOL STDCALL NtGdiDdReenableDirectDrawObject(
HANDLE hDirectDrawLocal,
BOOL *pubNewMode
)
{
BOOL Ret=FALSE;
NTSTATUS Status = FALSE;
PDD_DIRECTDRAW pDirectDraw;
if (hDirectDrawLocal == NULL)
{
return Ret;
}
pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDrawLocal,
GDI_OBJECT_TYPE_DIRECTDRAW);
if (!pDirectDraw)
{
return Ret;
}
/*
* FIXME detect mode change thic code maybe are not correct
* if we call on intEnableDriver it will cause some memory leak
* we need free the alloc memory before we call on it
*/
Ret = intEnableDriver(pDirectDraw);
_SEH_TRY
{
ProbeForWrite(pubNewMode, sizeof(BOOL), 1);
*pubNewMode = Ret;
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return Ret;
}
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return Ret;
}
DWORD STDCALL NtGdiDdGetDriverInfo(
HANDLE hDirectDrawLocal,
PDD_GETDRIVERINFODATA puGetDriverInfoData)
{
DWORD ddRVal = 0;
PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDrawLocal,
GDI_OBJECT_TYPE_DIRECTDRAW);
DPRINT1("NtGdiDdGetDriverInfo\n");
if (pDirectDraw == NULL)
{
return DDHAL_DRIVER_NOTHANDLED;
}
/* it exsist two version of NtGdiDdGetDriverInfo we need check for both flags */
if (!(pDirectDraw->Hal.dwFlags & DDHALINFO_GETDRIVERINFOSET))
ddRVal++;
if (!(pDirectDraw->Hal.dwFlags & DDHALINFO_GETDRIVERINFO2))
ddRVal++;
/* Now we are doing the call to drv DrvGetDriverInfo */
if (ddRVal == 2)
{
DPRINT1("NtGdiDdGetDriverInfo DDHAL_DRIVER_NOTHANDLED");
ddRVal = DDHAL_DRIVER_NOTHANDLED;
}
else
{
ddRVal = pDirectDraw->Hal.GetDriverInfo(puGetDriverInfoData);
}
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
DWORD STDCALL NtGdiDdUnlock(
HANDLE hSurface,
PDD_UNLOCKDATA puUnlockData
)
{
DWORD ddRVal;
PDD_DIRECTDRAW_GLOBAL lgpl;
PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdUnlock\n");
#endif
if (pDirectDraw == NULL)
return DDHAL_DRIVER_NOTHANDLED;
/* backup the orignal PDev and info */
lgpl = puUnlockData->lpDD;
/* use our cache version instead */
puUnlockData->lpDD = &pDirectDraw->Global;
/* make the call */
if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_UNLOCK))
ddRVal = DDHAL_DRIVER_NOTHANDLED;
else
ddRVal = pDirectDraw->Surf.Unlock(puUnlockData);
/* But back the orignal PDev */
puUnlockData->lpDD = lgpl;
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
DWORD STDCALL NtGdiDdBlt(
HANDLE hSurfaceDest,
HANDLE hSurfaceSrc,
PDD_BLTDATA puBltData
)
{
DWORD ddRVal;
PDD_DIRECTDRAW_GLOBAL lgpl;
PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hSurfaceDest, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdBlt\n");
#endif
if (pDirectDraw == NULL)
return DDHAL_DRIVER_NOTHANDLED;
/* backup the orignal PDev and info */
lgpl = puBltData->lpDD;
/* use our cache version instead */
puBltData->lpDD = &pDirectDraw->Global;
/* make the call */
if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_BLT))
ddRVal = DDHAL_DRIVER_NOTHANDLED;
else
ddRVal = pDirectDraw->Surf.Blt(puBltData);
/* But back the orignal PDev */
puBltData->lpDD = lgpl;
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
DWORD STDCALL NtGdiDdSetColorKey(
HANDLE hSurface,
PDD_SETCOLORKEYDATA puSetColorKeyData
)
{
DWORD ddRVal;
PDD_DIRECTDRAW_GLOBAL lgpl;
PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdSetColorKey\n");
#endif
if (pDirectDraw == NULL)
return DDHAL_DRIVER_NOTHANDLED;
/* backup the orignal PDev and info */
lgpl = puSetColorKeyData->lpDD;
/* use our cache version instead */
puSetColorKeyData->lpDD = &pDirectDraw->Global;
/* make the call */
if (!(pDirectDraw->Surf.dwFlags & DDHAL_SURFCB32_SETCOLORKEY))
ddRVal = DDHAL_DRIVER_NOTHANDLED;
else
ddRVal = pDirectDraw->Surf.SetColorKey(puSetColorKeyData);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -