mirror of
https://github.com/reactos/reactos.git
synced 2024-07-01 02:10:07 +00:00
fixed NtGdiCreateDC() to use UNICODE_STRINGs
svn path=/trunk/; revision=6996
This commit is contained in:
parent
619a2c32d9
commit
b0848526af
|
@ -86,7 +86,7 @@ typedef struct _DC
|
|||
HSURF Surface;
|
||||
|
||||
DRIVER_FUNCTIONS DriverFunctions;
|
||||
PWSTR DriverName;
|
||||
UNICODE_STRING DriverName;
|
||||
HANDLE DeviceDriver;
|
||||
|
||||
INT wndOrgX; /* Window origin */
|
||||
|
@ -125,9 +125,9 @@ typedef struct
|
|||
GDIOBJ_UnlockObj ((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC)
|
||||
|
||||
HDC FASTCALL RetrieveDisplayHDC(VOID);
|
||||
HDC FASTCALL DC_AllocDC(LPCWSTR Driver);
|
||||
HDC FASTCALL DC_AllocDC(PUNICODE_STRING Driver);
|
||||
VOID FASTCALL DC_InitDC(HDC DCToInit);
|
||||
HDC FASTCALL DC_FindOpenDC(LPCWSTR Driver);
|
||||
HDC FASTCALL DC_FindOpenDC(PUNICODE_STRING Driver);
|
||||
VOID FASTCALL DC_FreeDC(HDC DCToFree);
|
||||
HDC FASTCALL DC_GetNextDC (PDC pDC);
|
||||
VOID FASTCALL DC_SetNextDC (PDC pDC, HDC hNextDC);
|
||||
|
@ -141,9 +141,9 @@ BOOL FASTCALL DC_InvertXform(const XFORM *xformSrc, XFORM *xformDest);
|
|||
|
||||
BOOL STDCALL NtGdiCancelDC(HDC hDC);
|
||||
HDC STDCALL NtGdiCreateCompatableDC(HDC hDC);
|
||||
HDC STDCALL NtGdiCreateDC(LPCWSTR Driver,
|
||||
LPCWSTR Device,
|
||||
LPCWSTR Output,
|
||||
HDC STDCALL NtGdiCreateDC(PUNICODE_STRING Driver,
|
||||
PUNICODE_STRING Device,
|
||||
PUNICODE_STRING Output,
|
||||
CONST PDEVMODEW InitData);
|
||||
HDC STDCALL NtGdiCreateIC(LPCWSTR Driver,
|
||||
LPCWSTR Device,
|
||||
|
|
|
@ -435,12 +435,19 @@ CreateDCW (
|
|||
CONST DEVMODEW * lpInitData
|
||||
)
|
||||
{
|
||||
return NtGdiCreateDC (
|
||||
lpwszDriver,
|
||||
lpwszDevice,
|
||||
lpwszOutput,
|
||||
(PDEVMODEW)lpInitData
|
||||
);
|
||||
UNICODE_STRING Driver, Device, Output;
|
||||
|
||||
if(lpwszDriver)
|
||||
RtlInitUnicodeString(&Driver, lpwszDriver);
|
||||
if(lpwszDevice)
|
||||
RtlInitUnicodeString(&Driver, lpwszDevice);
|
||||
if(lpwszOutput)
|
||||
RtlInitUnicodeString(&Driver, lpwszOutput);
|
||||
|
||||
return NtGdiCreateDC((lpwszDriver ? &Driver : NULL),
|
||||
(lpwszDevice ? &Device : NULL),
|
||||
(lpwszOutput ? &Output : NULL),
|
||||
(PDEVMODEW)lpInitData);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,4 +3,8 @@
|
|||
|
||||
NTSTATUS FASTCALL InitCleanupImpl(VOID);
|
||||
|
||||
NTSTATUS FASTCALL
|
||||
IntSafeCopyUnicodeString(PUNICODE_STRING Dest,
|
||||
PUNICODE_STRING Source);
|
||||
|
||||
#endif /* ndef _SUBSYS_WIN32K_INCLUDE_CLEANUP_H */
|
||||
|
|
|
@ -108,5 +108,11 @@ IntGdiGetDCOrgEx(DC *dc, LPPOINT Point);
|
|||
INT FASTCALL
|
||||
IntGdiGetObject(HANDLE handle, INT count, LPVOID buffer);
|
||||
|
||||
HDC FASTCALL
|
||||
IntGdiCreateDC(PUNICODE_STRING Driver,
|
||||
PUNICODE_STRING Device,
|
||||
PUNICODE_STRING Output,
|
||||
CONST PDEVMODEW InitData);
|
||||
|
||||
#endif /* _WIN32K_INTGDI_H */
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: misc.c,v 1.32 2003/11/30 20:03:47 navaraf Exp $
|
||||
/* $Id: misc.c,v 1.33 2003/12/13 15:49:32 weiden Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -670,3 +670,40 @@ NtUserGetGuiResources(
|
|||
return Ret;
|
||||
}
|
||||
|
||||
NTSTATUS FASTCALL
|
||||
IntSafeCopyUnicodeString(PUNICODE_STRING Dest,
|
||||
PUNICODE_STRING Source)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PWSTR Src;
|
||||
|
||||
Status = MmCopyFromCaller(Dest, Source, sizeof(UNICODE_STRING));
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
if(Dest->MaximumLength > 0)
|
||||
{
|
||||
Src = Dest->Buffer;
|
||||
|
||||
Dest->Buffer = ExAllocatePool(NonPagedPool, Dest->MaximumLength);
|
||||
if(!Dest->Buffer)
|
||||
{
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
Status = MmCopyFromCaller(Dest->Buffer, Src, Dest->MaximumLength);
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
ExFreePool(Dest->Buffer);
|
||||
Dest->Buffer = NULL;
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: windc.c,v 1.44 2003/12/12 18:18:21 weiden Exp $
|
||||
/* $Id: windc.c,v 1.45 2003/12/13 15:49:32 weiden Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -42,6 +42,7 @@
|
|||
#include <include/dce.h>
|
||||
#include <include/vis.h>
|
||||
#include <include/object.h>
|
||||
#include <include/intgdi.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
@ -127,14 +128,17 @@ DceAllocDCE(HWND hWnd, DCE_TYPE Type)
|
|||
{
|
||||
HDCE DceHandle;
|
||||
DCE* Dce;
|
||||
UNICODE_STRING DriverName;
|
||||
|
||||
DceHandle = DCEOBJ_AllocDCE();
|
||||
if(!DceHandle)
|
||||
return NULL;
|
||||
|
||||
RtlInitUnicodeString(&DriverName, L"DISPLAY");
|
||||
|
||||
Dce = DCEOBJ_LockDCE(DceHandle);
|
||||
Dce->Self = DceHandle;
|
||||
Dce->hDC = NtGdiCreateDC(L"DISPLAY", NULL, NULL, NULL);
|
||||
Dce->hDC = IntGdiCreateDC(&DriverName, NULL, NULL, NULL);
|
||||
if (NULL == defaultDCstate)
|
||||
{
|
||||
defaultDCstate = NtGdiGetDCState(Dce->hDC);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: winsta.c,v 1.52 2003/12/13 11:34:53 navaraf Exp $
|
||||
* $Id: winsta.c,v 1.53 2003/12/13 15:49:32 weiden Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -51,6 +51,7 @@
|
|||
#include <include/mouse.h>
|
||||
#include <include/callback.h>
|
||||
#include <include/guicheck.h>
|
||||
#include <include/intgdi.h>
|
||||
/* Needed for DIRECTORY_OBJECT */
|
||||
#include <internal/ob.h>
|
||||
|
||||
|
@ -200,11 +201,13 @@ IntGetWindowStationObject(PWINSTATION_OBJECT Object)
|
|||
BOOL FASTCALL
|
||||
IntInitializeDesktopGraphics(VOID)
|
||||
{
|
||||
UNICODE_STRING DriverName;
|
||||
if (! IntCreatePrimarySurface())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
ScreenDeviceContext = NtGdiCreateDC(L"DISPLAY", NULL, NULL, NULL);
|
||||
RtlInitUnicodeString(&DriverName, L"DISPLAY");
|
||||
ScreenDeviceContext = IntGdiCreateDC(&DriverName, NULL, NULL, NULL);
|
||||
if (NULL == ScreenDeviceContext)
|
||||
{
|
||||
IntDestroyPrimarySurface();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: dc.c,v 1.110 2003/12/13 13:45:18 weiden Exp $
|
||||
/* $Id: dc.c,v 1.111 2003/12/13 15:49:32 weiden Exp $
|
||||
*
|
||||
* DC.C - Device context functions
|
||||
*
|
||||
|
@ -50,6 +50,8 @@
|
|||
#include <include/palette.h>
|
||||
#include <include/guicheck.h>
|
||||
#include <include/desktop.h>
|
||||
#include <include/intgdi.h>
|
||||
#include <include/cleanup.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <win32k/debug1.h>
|
||||
|
@ -136,6 +138,7 @@ NtGdiCreateCompatableDC(HDC hDC)
|
|||
HDC hNewDC, DisplayDC;
|
||||
HRGN hVisRgn;
|
||||
BITMAPOBJ *pb;
|
||||
UNICODE_STRING DriverName;
|
||||
|
||||
DisplayDC = NULL;
|
||||
if (hDC == NULL)
|
||||
|
@ -143,7 +146,8 @@ NtGdiCreateCompatableDC(HDC hDC)
|
|||
hDC = IntGetScreenDC();
|
||||
if (NULL == hDC)
|
||||
{
|
||||
DisplayDC = NtGdiCreateDC(L"DISPLAY", NULL, NULL, NULL);
|
||||
RtlInitUnicodeString(&DriverName, L"DISPLAY");
|
||||
DisplayDC = IntGdiCreateDC(&DriverName, NULL, NULL, NULL);
|
||||
if (NULL == DisplayDC)
|
||||
{
|
||||
return NULL;
|
||||
|
@ -162,7 +166,7 @@ NtGdiCreateCompatableDC(HDC hDC)
|
|||
}
|
||||
return NULL;
|
||||
}
|
||||
hNewDC = DC_AllocDC(OrigDC->DriverName);
|
||||
hNewDC = DC_AllocDC(&OrigDC->DriverName);
|
||||
|
||||
if (NULL == hNewDC)
|
||||
{
|
||||
|
@ -660,10 +664,10 @@ IntDestroyPrimarySurface()
|
|||
ObDereferenceObject(PrimarySurface.VideoFileObject);
|
||||
}
|
||||
|
||||
HDC STDCALL
|
||||
NtGdiCreateDC(LPCWSTR Driver,
|
||||
LPCWSTR Device,
|
||||
LPCWSTR Output,
|
||||
HDC FASTCALL
|
||||
IntGdiCreateDC(PUNICODE_STRING Driver,
|
||||
PUNICODE_STRING Device,
|
||||
PUNICODE_STRING Output,
|
||||
CONST PDEVMODEW InitData)
|
||||
{
|
||||
HDC hNewDC;
|
||||
|
@ -671,8 +675,11 @@ NtGdiCreateDC(LPCWSTR Driver,
|
|||
HDC hDC = NULL;
|
||||
PSURFGDI SurfGDI;
|
||||
HRGN hVisRgn;
|
||||
UNICODE_STRING StdDriver;
|
||||
|
||||
if (NULL == Driver || 0 == _wcsicmp(Driver, L"DISPLAY"))
|
||||
RtlInitUnicodeString(&StdDriver, L"DISPLAY");
|
||||
|
||||
if (NULL == Driver || 0 == RtlCompareUnicodeString(Driver, &StdDriver, TRUE))
|
||||
{
|
||||
if (! IntGraphicsCheck(TRUE))
|
||||
{
|
||||
|
@ -744,6 +751,54 @@ NtGdiCreateDC(LPCWSTR Driver,
|
|||
return hNewDC;
|
||||
}
|
||||
|
||||
HDC STDCALL
|
||||
NtGdiCreateDC(PUNICODE_STRING Driver,
|
||||
PUNICODE_STRING Device,
|
||||
PUNICODE_STRING Output,
|
||||
CONST PDEVMODEW InitData)
|
||||
{
|
||||
UNICODE_STRING SafeDriver, SafeDevice;
|
||||
DEVMODEW SafeInitData;
|
||||
HDC Ret;
|
||||
NTSTATUS Status;
|
||||
|
||||
if(InitData)
|
||||
{
|
||||
Status = MmCopyFromCaller(&SafeInitData, InitData, sizeof(DEVMODEW));
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastNtError(Status);
|
||||
return NULL;
|
||||
}
|
||||
/* FIXME - InitData can have some more bytes! */
|
||||
}
|
||||
|
||||
if(Driver)
|
||||
{
|
||||
Status = IntSafeCopyUnicodeString(&SafeDriver, Driver);
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastNtError(Status);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(Device)
|
||||
{
|
||||
Status = IntSafeCopyUnicodeString(&SafeDevice, Device);
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
RtlFreeUnicodeString(&SafeDriver);
|
||||
SetLastNtError(Status);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Ret = IntGdiCreateDC(&SafeDriver, &SafeDevice, NULL, &SafeInitData);
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
HDC STDCALL
|
||||
NtGdiCreateIC(LPCWSTR Driver,
|
||||
LPCWSTR Device,
|
||||
|
@ -751,7 +806,8 @@ NtGdiCreateIC(LPCWSTR Driver,
|
|||
CONST PDEVMODEW DevMode)
|
||||
{
|
||||
/* FIXME: this should probably do something else... */
|
||||
return NtGdiCreateDC(Driver, Device, Output, DevMode);
|
||||
//return NtGdiCreateDC(Driver, Device, Output, DevMode);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL STDCALL
|
||||
|
@ -1837,14 +1893,29 @@ DC_SET_MODE( NtGdiSetStretchBltMode, w.stretchBltMode, BLACKONWHITE, HALFTONE )
|
|||
// ---------------------------------------------------- Private Interface
|
||||
|
||||
HDC FASTCALL
|
||||
DC_AllocDC(LPCWSTR Driver)
|
||||
DC_AllocDC(PUNICODE_STRING Driver)
|
||||
{
|
||||
PDC NewDC;
|
||||
HDC hDC;
|
||||
PWSTR Buf = NULL;
|
||||
|
||||
if (Driver != NULL)
|
||||
{
|
||||
Buf = ExAllocatePoolWithTag(PagedPool, Driver->MaximumLength, TAG_DC);
|
||||
if(!Buf)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
RtlCopyMemory(Buf, Driver->Buffer, Driver->MaximumLength);
|
||||
}
|
||||
|
||||
hDC = (HDC) GDIOBJ_AllocObj(sizeof(DC), GDI_OBJECT_TYPE_DC, (GDICLEANUPPROC) DC_InternalDeleteDC);
|
||||
if (hDC == NULL)
|
||||
{
|
||||
if(Buf)
|
||||
{
|
||||
ExFreePool(Buf);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1852,8 +1923,8 @@ DC_AllocDC(LPCWSTR Driver)
|
|||
|
||||
if (Driver != NULL)
|
||||
{
|
||||
NewDC->DriverName = ExAllocatePoolWithTag(PagedPool, (wcslen(Driver) + 1) * sizeof(WCHAR), TAG_DC);
|
||||
wcscpy(NewDC->DriverName, Driver);
|
||||
RtlCopyMemory(&NewDC->DriverName, Driver, sizeof(UNICODE_STRING));
|
||||
NewDC->DriverName.Buffer = Buf;
|
||||
}
|
||||
|
||||
NewDC->w.xformWorld2Wnd.eM11 = 1.0f;
|
||||
|
@ -1875,7 +1946,7 @@ DC_AllocDC(LPCWSTR Driver)
|
|||
}
|
||||
|
||||
HDC FASTCALL
|
||||
DC_FindOpenDC(LPCWSTR Driver)
|
||||
DC_FindOpenDC(PUNICODE_STRING Driver)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1909,11 +1980,7 @@ BOOL FASTCALL
|
|||
DC_InternalDeleteDC( PDC DCToDelete )
|
||||
{
|
||||
|
||||
if (NULL != DCToDelete->DriverName)
|
||||
{
|
||||
ExFreePool(DCToDelete->DriverName);
|
||||
}
|
||||
|
||||
RtlFreeUnicodeString(&DCToDelete->DriverName);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue