Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/gdi32/tests/bitmap.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c index 0293d881fd9..a244414660b 100644 --- a/dlls/gdi32/tests/bitmap.c +++ b/dlls/gdi32/tests/bitmap.c @@ -5686,10 +5686,12 @@ static void test_D3DKMTCreateDCFromMemory( void ) { D3DKMT_DESTROYDCFROMMEMORY destroy_desc; D3DKMT_CREATEDCFROMMEMORY create_desc; + MEMORY_BASIC_INFORMATION memory_info; unsigned int width_bytes; unsigned int i, x, y, z; DWORD expected, colour; BYTE data[12][48]; + void *alloc_data; NTSTATUS status; HGDIOBJ *bitmap; DIBSECTION dib; @@ -5939,6 +5941,39 @@ static void test_D3DKMTCreateDCFromMemory( void ) DeleteObject( SelectObject( bmp_dc, bmp ) ); DeleteDC( bmp_dc ); } + + alloc_data = VirtualAlloc( NULL, 4096, MEM_COMMIT, PAGE_READWRITE ); + ok(!!alloc_data, "Failed to allocate memory, error %u.\n", GetLastError()); + + create_desc.pMemory = alloc_data; + create_desc.Format = D3DDDIFMT_A8R8G8B8; + create_desc.Width = 16; + create_desc.Height = 16; + create_desc.Pitch = 16 * 4; + create_desc.hDeviceDc = CreateCompatibleDC( NULL ); + create_desc.pColorTable = NULL; + + status = pD3DKMTCreateDCFromMemory( &create_desc ); + ok(!status, "Got unexpected status %#x.\n", status); + + size = VirtualQuery( alloc_data, &memory_info, sizeof(memory_info) ); + ok(size == sizeof(memory_info), "Got unexpected size %u.\n", size); + ok(memory_info.State == MEM_COMMIT, "Got state %#x.\n", memory_info.State); + ok(memory_info.Protect == PAGE_READWRITE, "Got protection %#x.\n", memory_info.Protect); + + destroy_desc.hDc = create_desc.hDc; + destroy_desc.hBitmap = create_desc.hBitmap; + + status = pD3DKMTDestroyDCFromMemory( &destroy_desc ); + ok(!status, "Got unexpected status %#x.\n", status); + + size = VirtualQuery( alloc_data, &memory_info, sizeof(memory_info) ); + ok(size == sizeof(memory_info), "Got unexpected size %u.\n", size); + todo_wine ok(memory_info.State == MEM_COMMIT, "Got state %#x.\n", memory_info.State); + todo_wine ok(memory_info.Protect == PAGE_READWRITE, "Got protection %#x.\n", memory_info.Protect); + + ret = VirtualFree( alloc_data, 0, MEM_RELEASE ); + todo_wine ok(ret, "Failed to free memory, error %u.\n", GetLastError()); }
START_TEST(bitmap)
This fixes a test crash in ddraw:ddraw1 introduced by 7d2a7b94aad8a776a2ee3031a18bb3b53d5925cd.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/gdi32/tests/bitmap.c | 6 +++--- dlls/win32u/dib.c | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c index a244414660b..93793ad7108 100644 --- a/dlls/gdi32/tests/bitmap.c +++ b/dlls/gdi32/tests/bitmap.c @@ -5969,11 +5969,11 @@ static void test_D3DKMTCreateDCFromMemory( void )
size = VirtualQuery( alloc_data, &memory_info, sizeof(memory_info) ); ok(size == sizeof(memory_info), "Got unexpected size %u.\n", size); - todo_wine ok(memory_info.State == MEM_COMMIT, "Got state %#x.\n", memory_info.State); - todo_wine ok(memory_info.Protect == PAGE_READWRITE, "Got protection %#x.\n", memory_info.Protect); + ok(memory_info.State == MEM_COMMIT, "Got state %#x.\n", memory_info.State); + ok(memory_info.Protect == PAGE_READWRITE, "Got protection %#x.\n", memory_info.Protect);
ret = VirtualFree( alloc_data, 0, MEM_RELEASE ); - todo_wine ok(ret, "Failed to free memory, error %u.\n", GetLastError()); + ok(ret, "Failed to free memory, error %u.\n", GetLastError()); }
START_TEST(bitmap) diff --git a/dlls/win32u/dib.c b/dlls/win32u/dib.c index b27b341d470..ee82d1a8ed8 100644 --- a/dlls/win32u/dib.c +++ b/dlls/win32u/dib.c @@ -1574,6 +1574,24 @@ error: }
+static BOOL memory_dib_DeleteObject( HGDIOBJ handle ) +{ + BITMAPOBJ *bmp; + + if (!(bmp = free_gdi_handle( handle ))) return FALSE; + + free( bmp->color_table ); + free( bmp ); + return TRUE; +} + + +static const struct gdi_obj_funcs memory_dib_funcs = +{ + .pGetObjectW = DIB_GetObject, + .pDeleteObject = memory_dib_DeleteObject, +}; + /*********************************************************************** * NtGdiDdDDICreateDCFromMemory (win32u.@) */ @@ -1673,7 +1691,7 @@ NTSTATUS WINAPI NtGdiDdDDICreateDCFromMemory( D3DKMT_CREATEDCFROMMEMORY *desc ) } }
- if (!(bitmap = alloc_gdi_handle( &bmp->obj, NTGDI_OBJ_BITMAP, &dib_funcs ))) goto error; + if (!(bitmap = alloc_gdi_handle( &bmp->obj, NTGDI_OBJ_BITMAP, &memory_dib_funcs ))) goto error;
desc->hDc = dc; desc->hBitmap = bitmap;