mirror of
https://github.com/reactos/wine.git
synced 2024-11-24 20:30:01 +00:00
gdi32: Fix invalid parameter handling in EnumICMProfiles and SetICMProfile.
This commit is contained in:
parent
898a4cfaec
commit
b32ed71ff5
@ -74,11 +74,13 @@ INT CALLBACK enum_profiles_callback( LPWSTR filename, LPARAM lparam )
|
||||
*/
|
||||
INT WINAPI EnumICMProfilesA(HDC hdc, ICMENUMPROCA func, LPARAM lparam)
|
||||
{
|
||||
DC *dc;
|
||||
INT ret = -1;
|
||||
DC *dc = get_dc_ptr(hdc);
|
||||
|
||||
TRACE("%p, %p, 0x%08lx\n", hdc, func, lparam);
|
||||
if (dc)
|
||||
|
||||
if (!func) return -1;
|
||||
if ((dc = get_dc_ptr(hdc)))
|
||||
{
|
||||
if (dc->funcs->pEnumICMProfiles)
|
||||
{
|
||||
@ -99,11 +101,13 @@ INT WINAPI EnumICMProfilesA(HDC hdc, ICMENUMPROCA func, LPARAM lparam)
|
||||
*/
|
||||
INT WINAPI EnumICMProfilesW(HDC hdc, ICMENUMPROCW func, LPARAM lparam)
|
||||
{
|
||||
DC *dc;
|
||||
INT ret = -1;
|
||||
DC *dc = get_dc_ptr(hdc);
|
||||
|
||||
TRACE("%p, %p, 0x%08lx\n", hdc, func, lparam);
|
||||
if (dc)
|
||||
|
||||
if (!func) return -1;
|
||||
if ((dc = get_dc_ptr(hdc)))
|
||||
{
|
||||
if (dc->funcs->pEnumICMProfiles)
|
||||
{
|
||||
@ -200,6 +204,17 @@ BOOL WINAPI GetLogColorSpaceW(HCOLORSPACE colorspace, LPLOGCOLORSPACEW buffer, D
|
||||
BOOL WINAPI SetICMProfileA(HDC hdc, LPSTR filename)
|
||||
{
|
||||
FIXME("%p %s stub\n", hdc, debugstr_a(filename));
|
||||
|
||||
if (!filename)
|
||||
{
|
||||
SetLastError( ERROR_INVALID_PARAMETER );
|
||||
return FALSE;
|
||||
}
|
||||
if (!hdc)
|
||||
{
|
||||
SetLastError( ERROR_INVALID_HANDLE );
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -209,6 +224,17 @@ BOOL WINAPI SetICMProfileA(HDC hdc, LPSTR filename)
|
||||
BOOL WINAPI SetICMProfileW(HDC hdc, LPWSTR filename)
|
||||
{
|
||||
FIXME("%p %s stub\n", hdc, debugstr_w(filename));
|
||||
|
||||
if (!filename)
|
||||
{
|
||||
SetLastError( ERROR_INVALID_PARAMETER );
|
||||
return FALSE;
|
||||
}
|
||||
if (!hdc)
|
||||
{
|
||||
SetLastError( ERROR_INVALID_HANDLE );
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -176,6 +176,127 @@ static void test_SetICMMode( HDC dc )
|
||||
DeleteDC( dc );
|
||||
}
|
||||
|
||||
static CALLBACK INT enum_profiles_callbackA( LPSTR filename, LPARAM lparam )
|
||||
{
|
||||
trace("%s\n", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void test_EnumICMProfilesA( HDC dc )
|
||||
{
|
||||
INT ret;
|
||||
|
||||
ret = EnumICMProfilesA( NULL, NULL, 0 );
|
||||
ok(ret == -1 || broken(ret == 0) /* nt4 */, "expected -1, got %d\n", ret);
|
||||
|
||||
ret = EnumICMProfilesA( dc, NULL, 0 );
|
||||
ok(ret == -1 || broken(ret == 0) /* nt4 */, "expected -1, got %d\n", ret);
|
||||
|
||||
ret = EnumICMProfilesA( dc, enum_profiles_callbackA, 0 );
|
||||
ok(ret == -1 || broken(ret == 0) /* nt4 */, "expected -1, got %d\n", ret);
|
||||
}
|
||||
|
||||
static CALLBACK INT enum_profiles_callbackW( LPWSTR filename, LPARAM lparam )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void test_EnumICMProfilesW( HDC dc )
|
||||
{
|
||||
INT ret;
|
||||
|
||||
ret = EnumICMProfilesW( NULL, NULL, 0 );
|
||||
ok(ret == -1 || broken(ret == 0) /* win9x, nt4 */, "expected -1, got %d\n", ret);
|
||||
|
||||
ret = EnumICMProfilesW( dc, NULL, 0 );
|
||||
ok(ret == -1 || broken(ret == 0) /* win9x, nt4 */, "expected -1, got %d\n", ret);
|
||||
|
||||
ret = EnumICMProfilesW( dc, enum_profiles_callbackW, 0 );
|
||||
ok(ret == -1 || broken(ret == 0) /* win9x, nt4 */, "expected -1, got %d\n", ret);
|
||||
}
|
||||
|
||||
static void test_SetICMProfileA( HDC dc )
|
||||
{
|
||||
BOOL ret;
|
||||
char profile[MAX_PATH];
|
||||
DWORD len, error;
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = SetICMProfileA( NULL, NULL );
|
||||
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
||||
{
|
||||
win_skip("SetICMProfileA is not implemented\n");
|
||||
return;
|
||||
}
|
||||
|
||||
len = sizeof(profile);
|
||||
ret = GetICMProfileA( dc, &len, profile );
|
||||
ok(ret, "GetICMProfileA failed %u\n", GetLastError());
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = SetICMProfileA( NULL, NULL );
|
||||
error = GetLastError();
|
||||
ok(!ret, "SetICMProfileA succeeded\n");
|
||||
ok(error == ERROR_INVALID_PARAMETER || broken(error == 0xdeadbeef) /* win9x */,
|
||||
"expected ERROR_INVALID_PARAMETER, got %u\n", error);
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = SetICMProfileA( NULL, profile );
|
||||
error = GetLastError();
|
||||
ok(!ret, "SetICMProfileA succeeded\n");
|
||||
ok(error == ERROR_INVALID_HANDLE || broken(error == 0xdeadbeef) /* win9x */,
|
||||
"expected ERROR_INVALID_HANDLE, got %u\n", error);
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = SetICMProfileA( dc, NULL );
|
||||
error = GetLastError();
|
||||
ok(!ret, "SetICMProfileA succeeded\n");
|
||||
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
|
||||
|
||||
ret = SetICMProfileA( dc, profile );
|
||||
ok(ret, "SetICMProfileA failed %u\n", GetLastError());
|
||||
}
|
||||
|
||||
static void test_SetICMProfileW( HDC dc )
|
||||
{
|
||||
BOOL ret;
|
||||
WCHAR profile[MAX_PATH];
|
||||
DWORD len, error;
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = SetICMProfileW( NULL, NULL );
|
||||
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
||||
{
|
||||
win_skip("SetICMProfileW is not implemented\n");
|
||||
return;
|
||||
}
|
||||
|
||||
len = sizeof(profile)/sizeof(profile[0]);
|
||||
ret = GetICMProfileW( dc, &len, profile );
|
||||
ok(ret, "GetICMProfileW failed %u\n", GetLastError());
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = SetICMProfileW( NULL, NULL );
|
||||
error = GetLastError();
|
||||
ok(!ret, "SetICMProfileW succeeded\n");
|
||||
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = SetICMProfileW( NULL, profile );
|
||||
error = GetLastError();
|
||||
ok(!ret, "SetICMProfileW succeeded\n");
|
||||
ok(error == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %u\n", error);
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = SetICMProfileW( dc, NULL );
|
||||
error = GetLastError();
|
||||
ok(!ret, "SetICMProfileW succeeded\n");
|
||||
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
|
||||
|
||||
ret = SetICMProfileW( dc, profile );
|
||||
ok(ret, "SetICMProfileW failed %u\n", GetLastError());
|
||||
}
|
||||
|
||||
START_TEST(icm)
|
||||
{
|
||||
HDC dc = GetDC( NULL );
|
||||
@ -183,6 +304,10 @@ START_TEST(icm)
|
||||
test_GetICMProfileA( dc );
|
||||
test_GetICMProfileW( dc );
|
||||
test_SetICMMode( dc );
|
||||
test_EnumICMProfilesA( dc );
|
||||
test_EnumICMProfilesW( dc );
|
||||
test_SetICMProfileA( dc );
|
||||
test_SetICMProfileW( dc );
|
||||
|
||||
ReleaseDC( NULL, dc );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user