Author: jimtabor
Date: Sun May 11 23:59:20 2008
New Revision: 33460
URL:
http://svn.reactos.org/svn/reactos?rev=33460&view=rev
Log:
Fixed wine all of gdi32 dc tests and only 2 of gdiobj tests left todo.
Modified:
trunk/reactos/dll/win32/gdi32/misc/stubs.c
trunk/reactos/dll/win32/gdi32/objects/dc.c
Modified: trunk/reactos/dll/win32/gdi32/misc/stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/misc/stubs…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/misc/stubs.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/gdi32/misc/stubs.c [iso-8859-1] Sun May 11 23:59:20 2008
@@ -1657,74 +1657,46 @@
*/
DEVMODEW *
STDCALL
-GdiConvertToDevmodeW(DEVMODEA *dm)
-{
- LPDEVMODEW dmw;
-
- dmw = HEAP_alloc(sizeof(DEVMODEW));
- #define COPYS(f,len) MultiByteToWideChar ( CP_THREAD_ACP, 0, (LPSTR)dm->f, len,
dmw->f, len )
- #define COPYN(f) dmw->f = dm->f
- COPYS(dmDeviceName, CCHDEVICENAME );
- COPYN(dmSpecVersion);
- COPYN(dmDriverVersion);
- switch ( dm->dmSize )
+GdiConvertToDevmodeW(DEVMODEA *dmA)
+{
+ DEVMODEW *dmW;
+ WORD dmW_size, dmA_size;
+
+ dmA_size = dmA->dmSize;
+
+ /* this is the minimal dmSize that XP accepts */
+ if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
+ return NULL;
+
+ if (dmA_size > sizeof(DEVMODEA))
+ dmA_size = sizeof(DEVMODEA);
+
+ dmW_size = dmA_size + CCHDEVICENAME;
+ if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
+ dmW_size += CCHFORMNAME;
+
+ dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
+ if (!dmW) return NULL;
+
+ MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, CCHDEVICENAME,
+ dmW->dmDeviceName, CCHDEVICENAME);
+ /* copy slightly more, to avoid long computations */
+ memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size -
CCHDEVICENAME);
+
+ if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
{
- case SIZEOF_DEVMODEA_300:
- dmw->dmSize = SIZEOF_DEVMODEW_300;
- break;
- case SIZEOF_DEVMODEA_400:
- dmw->dmSize = SIZEOF_DEVMODEW_400;
- break;
- case SIZEOF_DEVMODEA_500:
- default: /* FIXME what to do??? */
- dmw->dmSize = SIZEOF_DEVMODEW_500;
- break;
+ MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, CCHFORMNAME,
+ dmW->dmFormName, CCHFORMNAME);
+ if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
+ memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size -
FIELD_OFFSET(DEVMODEA, dmLogPixels));
}
- COPYN(dmDriverExtra);
- COPYN(dmFields);
- COPYN(dmPosition.x);
- COPYN(dmPosition.y);
- COPYN(dmScale);
- COPYN(dmCopies);
- COPYN(dmDefaultSource);
- COPYN(dmPrintQuality);
- COPYN(dmColor);
- COPYN(dmDuplex);
- COPYN(dmYResolution);
- COPYN(dmTTOption);
- COPYN(dmCollate);
- COPYS(dmFormName,CCHFORMNAME);
- COPYN(dmLogPixels);
- COPYN(dmBitsPerPel);
- COPYN(dmPelsWidth);
- COPYN(dmPelsHeight);
- COPYN(dmDisplayFlags); // aka dmNup
- COPYN(dmDisplayFrequency);
-
- if ( dm->dmSize <= SIZEOF_DEVMODEA_300 )
- {
- return dmw; // we're done with 0x300 fields
- }
-
- COPYN(dmICMMethod);
- COPYN(dmICMIntent);
- COPYN(dmMediaType);
- COPYN(dmDitherType);
- COPYN(dmReserved1);
- COPYN(dmReserved2);
-
- if ( dm->dmSize <= SIZEOF_DEVMODEA_400 )
- {
- return dmw; // we're done with 0x400 fields
- }
-
- COPYN(dmPanningWidth);
- COPYN(dmPanningHeight);
-
- return dmw;
-
- #undef COPYN
- #undef COPYS
+
+ if (dmA->dmDriverExtra)
+ memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size,
dmA->dmDriverExtra);
+
+ dmW->dmSize = dmW_size;
+
+ return dmW;
}
/*
Modified: trunk/reactos/dll/win32/gdi32/objects/dc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/dc…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/objects/dc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/gdi32/objects/dc.c [iso-8859-1] Sun May 11 23:59:20 2008
@@ -386,6 +386,8 @@
{
HGDIOBJ hGO = NULL;
PDC_ATTR Dc_Attr;
+
+ if (!hDC) return hGO;
if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr))
return NULL;