Author: gedmurphy
Date: Tue Sep 25 17:27:09 2007
New Revision: 29200
URL:
http://svn.reactos.org/svn/reactos?rev=29200&view=rev
Log:
- Add usermode checks to GetDIBits
- passes 21 out of 27 tests
- Add GdiSetLastError to the lib instead of forwarding it straight to kernel32
Modified:
trunk/reactos/dll/win32/gdi32/gdi32.def
trunk/reactos/dll/win32/gdi32/include/gdi32p.h
trunk/reactos/dll/win32/gdi32/misc/misc.c
trunk/reactos/dll/win32/gdi32/objects/bitmap.c
Modified: trunk/reactos/dll/win32/gdi32/gdi32.def
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/gdi32.def?…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/gdi32.def (original)
+++ trunk/reactos/dll/win32/gdi32/gdi32.def Tue Sep 25 17:27:09 2007
@@ -328,7 +328,7 @@
GdiResetDCEMF@8
GdiSetAttrs@4
GdiSetBatchLimit@4
-GdiSetLastError@4=SetLastError@4
+GdiSetLastError@4
GdiSetPixelFormat@8=NtGdiSetPixelFormat@8
GdiSetServerAttr@8
GdiStartDocEMF@8
Modified: trunk/reactos/dll/win32/gdi32/include/gdi32p.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/include/gd…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/include/gdi32p.h (original)
+++ trunk/reactos/dll/win32/gdi32/include/gdi32p.h Tue Sep 25 17:27:09 2007
@@ -192,5 +192,9 @@
STDCALL
GdiAddFontResourceW(LPCWSTR lpszFilename,FLONG fl,DESIGNVECTOR *pdv);
+VOID
+STDCALL
+GdiSetLastError( DWORD dwErrCode );
+
/* EOF */
Modified: trunk/reactos/dll/win32/gdi32/misc/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/misc/misc.…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/misc/misc.c (original)
+++ trunk/reactos/dll/win32/gdi32/misc/misc.c Tue Sep 25 17:27:09 2007
@@ -178,3 +178,13 @@
{
return NtGdiExtEscape(hDC, NULL, 0, nEscape, cbInput, (LPSTR)lpszInData, cbOutput,
lpszOutData);
}
+
+/*
+ * @implemented
+ */
+VOID
+STDCALL
+GdiSetLastError(DWORD dwErrCode)
+{
+ SetLastError(dwErrCode);
+}
Modified: trunk/reactos/dll/win32/gdi32/objects/bitmap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/bi…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/objects/bitmap.c (original)
+++ trunk/reactos/dll/win32/gdi32/objects/bitmap.c Tue Sep 25 17:27:09 2007
@@ -1,4 +1,7 @@
#include "precomp.h"
+
+//#define NDEBUG
+//#include <debug.h>
/*
* Return the full scan size for a bitmap.
@@ -151,8 +154,6 @@
-
-
INT
STDCALL
GetDIBits(
@@ -162,16 +163,34 @@
UINT cScanLines,
LPVOID lpvBits,
LPBITMAPINFO lpbmi,
- UINT uUsage
- )
+ UINT uUsage)
{
- return NtGdiGetDIBitsInternal(hDC,
- hbmp,
- uStartScan,
- cScanLines,
- lpvBits,
- lpbmi,
- uUsage,
- DIB_BitmapMaxBitsSize( lpbmi, cScanLines ),
- 0);
+ INT ret = 0;
+
+ if (hDC == NULL || !GdiIsHandleValid((HGDIOBJ)hDC))
+ {
+ GdiSetLastError(ERROR_INVALID_PARAMETER);
+ }
+ else if (lpbmi == NULL)
+ {
+ // XP doesn't run this check and results in a
+ // crash in DIB_BitmapMaxBitsSize, we'll be more forgiving
+ GdiSetLastError(ERROR_INVALID_PARAMETER);
+ }
+ else
+ {
+ UINT cjBmpScanSize = DIB_BitmapMaxBitsSize(lpbmi, cScanLines);
+
+ ret = NtGdiGetDIBitsInternal(hDC,
+ hbmp,
+ uStartScan,
+ cScanLines,
+ lpvBits,
+ lpbmi,
+ uUsage,
+ cjBmpScanSize,
+ 0);
+ }
+
+ return ret;
}