[WIN32KNT_APITEST] Improve NtGdiSetBitmapBits 6 (#1320)
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Tue, 29 Jan 2019 13:48:14 +0000 (22:48 +0900)
committerGitHub <noreply@github.com>
Tue, 29 Jan 2019 13:48:14 +0000 (22:48 +0900)
Add some PAGE_READONLY tests. Add two bit pattern tests. CORE-15657 and CORE-15695

modules/rostests/apitests/win32nt/ntgdi/NtGdiSetBitmapBits.c

index 21d1f1f..8b6fa26 100644 (file)
@@ -78,7 +78,7 @@ START_TEST(NtGdiSetBitmapBits)
     ok_long(NtGdiSetBitmapBits(hBitmap, 100, Bits), 12);
     ok_long(GetLastError(), 0xDEADFACE);
 
-    /* Test large byte counts */
+    /* Test large byte counts (with PAGE_NOACCESS) */
     LargeBits = VirtualAlloc(NULL, 0x100000 + PAGE_SIZE, MEM_RESERVE, PAGE_NOACCESS);
     VirtualAlloc(LargeBits, 0x100000, MEM_COMMIT, PAGE_READWRITE);
     CopyMemory(LargeBits, Bits, sizeof(Bits));
@@ -88,7 +88,26 @@ START_TEST(NtGdiSetBitmapBits)
     ok_long(GetLastError(), 0xDEADFACE);
 
     SetLastError(0xDEADFACE);
-    ok_long(NtGdiSetBitmapBits(hBitmap, 0x1000, LargeBits), 0xC);
+    ok_long(NtGdiSetBitmapBits(hBitmap, 0x10000, LargeBits), 0xC);
+    ok_long(GetLastError(), 0xDEADFACE);
+
+    SetLastError(0xDEADFACE);
+    ok_long(NtGdiSetBitmapBits(hBitmap, 0x100000, LargeBits), 0xC);
+    ok_long(GetLastError(), 0xDEADFACE);
+
+    SetLastError(0xDEADFACE);
+    ok_long(NtGdiSetBitmapBits(hBitmap, 0x100001, LargeBits), 0x0);
+    ok_long(GetLastError(), 0xDEADFACE);
+
+    VirtualFree(LargeBits, 0, MEM_RELEASE);
+
+    /* Test large byte counts (with PAGE_READONLY) */
+    LargeBits = VirtualAlloc(NULL, 0x100000 + PAGE_SIZE, MEM_RESERVE, PAGE_READONLY);
+    VirtualAlloc(LargeBits, 0x100000, MEM_COMMIT, PAGE_READWRITE);
+    CopyMemory(LargeBits, Bits, sizeof(Bits));
+
+    SetLastError(0xDEADFACE);
+    ok_long(NtGdiSetBitmapBits(hBitmap, 0x100, LargeBits), 0xC);
     ok_long(GetLastError(), 0xDEADFACE);
 
     SetLastError(0xDEADFACE);
@@ -295,6 +314,7 @@ START_TEST(NtGdiSetBitmapBits)
     ok_int(Bits[4], 0x55);
 
     ok_long(*(LPDWORD)pvBits, 0);
+    ok_long(((LPDWORD)pvBits)[1], 0);
 
     DeleteObject(hBitmap);
     DeleteDC(hDC);
@@ -396,6 +416,7 @@ START_TEST(NtGdiSetBitmapBits)
     ok_int(Bits[4], 0x55);
 
     ok_long(*(LPDWORD)pvBits, 0x33AAAAAA);
+    ok_long(((LPDWORD)pvBits)[1], 0x33333333);
 
     DeleteObject(hBitmap);
     DeleteDC(hDC);