https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c8f69c63de41eb633b31aaad9ed99ea722bd3ce1

commit c8f69c63de41eb633b31aaad9ed99ea722bd3ce1
Author:     Thomas Faber <[email protected]>
AuthorDate: Sun Jan 27 12:08:52 2019 +0100
Commit:     Katayama Hirofumi MZ <[email protected]>
CommitDate: Sun Jan 27 20:08:52 2019 +0900

    [WIN32KNT_APITEST] Test large buffers without relying on stack layout. 
(#1314)
    
    CORE-15657
---
 .../apitests/win32nt/ntgdi/NtGdiSetBitmapBits.c    | 72 ++++------------------
 1 file changed, 12 insertions(+), 60 deletions(-)

diff --git a/modules/rostests/apitests/win32nt/ntgdi/NtGdiSetBitmapBits.c 
b/modules/rostests/apitests/win32nt/ntgdi/NtGdiSetBitmapBits.c
index fa668acf04..88b572041d 100644
--- a/modules/rostests/apitests/win32nt/ntgdi/NtGdiSetBitmapBits.c
+++ b/modules/rostests/apitests/win32nt/ntgdi/NtGdiSetBitmapBits.c
@@ -14,6 +14,7 @@ START_TEST(NtGdiSetBitmapBits)
     HDC hDC;
     BITMAPINFO bmi;
     LPVOID pvBits;
+    LPBYTE LargeBits;
 
     SetLastError(0xDEADFACE);
     ok_long(NtGdiSetBitmapBits(0, 0, 0), 0);
@@ -77,57 +78,32 @@ START_TEST(NtGdiSetBitmapBits)
     ok_long(NtGdiSetBitmapBits(hBitmap, 100, Bits), 12);
     ok_long(GetLastError(), 0xDEADFACE);
 
-    /* Test huge bytes count */
-    SetLastError(0xDEADFACE);
-    ok_long(NtGdiSetBitmapBits(hBitmap, 12345678, Bits), 0);
-    ok_long(GetLastError(), 0xDEADFACE);
+    /* Test large byte counts */
+    LargeBits = VirtualAlloc(NULL, 0x100000 + PAGE_SIZE, MEM_RESERVE, 
PAGE_NOACCESS);
+    VirtualAlloc(LargeBits, 0x100000, MEM_COMMIT, PAGE_READWRITE);
+    CopyMemory(LargeBits, Bits, sizeof(Bits));
 
     SetLastError(0xDEADFACE);
-    ok_long(NtGdiSetBitmapBits(hBitmap, 0x100, Bits), 0xC);
+    ok_long(NtGdiSetBitmapBits(hBitmap, 0x100, LargeBits), 0xC);
     ok_long(GetLastError(), 0xDEADFACE);
 
     SetLastError(0xDEADFACE);
-    ok_long(NtGdiSetBitmapBits(hBitmap, 564, Bits), 0xC);
+    ok_long(NtGdiSetBitmapBits(hBitmap, 0x1000, LargeBits), 0xC);
     ok_long(GetLastError(), 0xDEADFACE);
 
     SetLastError(0xDEADFACE);
-    ok_long(NtGdiSetBitmapBits(hBitmap, 565, Bits), 0);
+    ok_long(NtGdiSetBitmapBits(hBitmap, 0x10000, LargeBits), 0xC);
     ok_long(GetLastError(), 0xDEADFACE);
 
-    {
-        BYTE dummy[256] = { 1 };
-
-        SetLastError(0xDEADFACE);
-        ok_long(NtGdiSetBitmapBits(hBitmap, 564, Bits), 0xC);
-        ok_long(GetLastError(), 0xDEADFACE);
-
-        SetLastError(0xDEADFACE);
-        ok_long(NtGdiSetBitmapBits(hBitmap, 565, Bits), 0);
-        ok_long(GetLastError(), 0xDEADFACE);
-
-        ok_int(dummy[0], 1);
-    }
-
     SetLastError(0xDEADFACE);
-    ok_long(NtGdiSetBitmapBits(hBitmap, 0x7FFF, Bits), 0);
+    ok_long(NtGdiSetBitmapBits(hBitmap, 0x100000, LargeBits), 0xC);
     ok_long(GetLastError(), 0xDEADFACE);
 
     SetLastError(0xDEADFACE);
-    ok_long(NtGdiSetBitmapBits(hBitmap, 0x8000, Bits), 0);
+    ok_long(NtGdiSetBitmapBits(hBitmap, 0x100001, LargeBits), 0x0);
     ok_long(GetLastError(), 0xDEADFACE);
 
-    SetLastError(0xDEADFACE);
-    ok_long(NtGdiSetBitmapBits(hBitmap, 0xFFFF, Bits), 0);
-    ok_long(GetLastError(), 0xDEADFACE);
-
-    SetLastError(0xDEADFACE);
-    ok_long(NtGdiSetBitmapBits(hBitmap, 0x10000, Bits), 0);
-    ok_long(GetLastError(), 0xDEADFACE);
-
-    /* Test negative bytes count */
-    SetLastError(0xDEADFACE);
-    ok_long(NtGdiSetBitmapBits(hBitmap, -5, Bits), 0);
-    ok_long(GetLastError(), 0xDEADFACE);
+    VirtualFree(LargeBits, 0, MEM_RELEASE);
 
     DeleteObject(hBitmap);
 
@@ -143,7 +119,7 @@ START_TEST(NtGdiSetBitmapBits)
     ok_int(Bits[0], 0x55);
 
     FillMemory(Bits, sizeof(Bits), 0x55);
-    
+
     SetLastError(0xDEADFACE);
     ok_long(NtGdiGetBitmapBits(hBitmap, 1, Bits), 1);
     ok_long(GetLastError(), 0xDEADFACE);
@@ -220,14 +196,6 @@ START_TEST(NtGdiSetBitmapBits)
     ok_int(Bits[3], 0x33);
     ok_int(Bits[4], 0x55);
 
-    SetLastError(0xDEADFACE);
-    ok_long(NtGdiSetBitmapBits(hBitmap, 564, Bits), 0x20);
-    ok_long(GetLastError(), 0xDEADFACE);
-
-    SetLastError(0xDEADFACE);
-    ok_long(NtGdiSetBitmapBits(hBitmap, 565, Bits), 0);
-    ok_long(GetLastError(), 0xDEADFACE);
-
     DeleteObject(hBitmap);
 
     /* ------------------------- */
@@ -326,14 +294,6 @@ START_TEST(NtGdiSetBitmapBits)
     ok_int(Bits[3], 0x33);
     ok_int(Bits[4], 0x55);
 
-    SetLastError(0xDEADFACE);
-    ok_long(NtGdiSetBitmapBits(hBitmap, 564, Bits), 0x234);
-    ok_long(GetLastError(), 0xDEADFACE);
-
-    SetLastError(0xDEADFACE);
-    ok_long(NtGdiSetBitmapBits(hBitmap, 565, Bits), 0);
-    ok_long(GetLastError(), 0xDEADFACE);
-
     DeleteObject(hBitmap);
     DeleteDC(hDC);
 
@@ -433,14 +393,6 @@ START_TEST(NtGdiSetBitmapBits)
     ok_int(Bits[3], 0x33);
     ok_int(Bits[4], 0x55);
 
-    SetLastError(0xDEADFACE);
-    ok_long(NtGdiSetBitmapBits(hBitmap, 564, Bits), 0x234);
-    ok_long(GetLastError(), 0xDEADFACE);
-
-    SetLastError(0xDEADFACE);
-    ok_long(NtGdiSetBitmapBits(hBitmap, 565, Bits), 0);
-    ok_long(GetLastError(), 0xDEADFACE);
-
     DeleteObject(hBitmap);
     DeleteDC(hDC);
 }

Reply via email to