user32: Don't allow SetClipboardData if the clipboard is not open.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
79d2e0a9be
commit
42c221db6c
|
@ -345,9 +345,15 @@ HANDLE WINAPI SetClipboardData(UINT wFormat, HANDLE hData)
|
|||
return 0;
|
||||
}
|
||||
|
||||
flags = get_clipboard_flags();
|
||||
if (!(flags & CB_OPEN_ANY))
|
||||
{
|
||||
SetLastError( ERROR_CLIPBOARD_NOT_OPEN );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If it's not owned, data can only be set if the format isn't
|
||||
available and its rendering is not delayed */
|
||||
flags = get_clipboard_flags();
|
||||
if (!(flags & CB_OWNER) && !hData)
|
||||
{
|
||||
WARN("Clipboard not owned by calling task. Operation failed.\n");
|
||||
|
|
|
@ -72,12 +72,12 @@ static DWORD WINAPI set_clipboard_data_thread(LPVOID arg)
|
|||
else
|
||||
{
|
||||
SetClipboardData( CF_WAVE, 0 );
|
||||
todo_wine ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "%u: wrong error %u\n",
|
||||
ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "%u: wrong error %u\n",
|
||||
thread_from_line, GetLastError());
|
||||
ok( !IsClipboardFormatAvailable( CF_WAVE ), "%u: SetClipboardData succeeded\n", thread_from_line );
|
||||
ret = SetClipboardData( CF_WAVE, GlobalAlloc( GMEM_DDESHARE | GMEM_ZEROINIT, 100 ));
|
||||
todo_wine ok( !ret, "%u: SetClipboardData succeeded\n", thread_from_line );
|
||||
todo_wine ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "%u: wrong error %u\n",
|
||||
ok( !ret, "%u: SetClipboardData succeeded\n", thread_from_line );
|
||||
ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "%u: wrong error %u\n",
|
||||
thread_from_line, GetLastError());
|
||||
}
|
||||
return 0;
|
||||
|
@ -99,12 +99,12 @@ static void set_clipboard_data_process( int arg )
|
|||
else
|
||||
{
|
||||
SetClipboardData( CF_WAVE, 0 );
|
||||
todo_wine ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "process %u: wrong error %u\n",
|
||||
ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "process %u: wrong error %u\n",
|
||||
arg, GetLastError());
|
||||
todo_wine ok( !IsClipboardFormatAvailable( CF_WAVE ), "process %u: SetClipboardData succeeded\n", arg );
|
||||
ok( !IsClipboardFormatAvailable( CF_WAVE ), "process %u: SetClipboardData succeeded\n", arg );
|
||||
ret = SetClipboardData( CF_WAVE, GlobalAlloc( GMEM_DDESHARE | GMEM_ZEROINIT, 100 ));
|
||||
ok( !ret, "process %u: SetClipboardData succeeded\n", arg );
|
||||
todo_wine ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "process %u: wrong error %u\n",
|
||||
ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "process %u: wrong error %u\n",
|
||||
arg, GetLastError());
|
||||
}
|
||||
}
|
||||
|
@ -256,10 +256,10 @@ static void test_ClipboardOwner(void)
|
|||
ok( ret, "CloseClipboard error %d\n", GetLastError());
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
todo_wine ok( !SetClipboardData( CF_WAVE, GlobalAlloc( GMEM_DDESHARE | GMEM_ZEROINIT, 100 )),
|
||||
ok( !SetClipboardData( CF_WAVE, GlobalAlloc( GMEM_DDESHARE | GMEM_ZEROINIT, 100 )),
|
||||
"SetClipboardData succeeded\n" );
|
||||
todo_wine ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "wrong error %u\n", GetLastError() );
|
||||
todo_wine ok( !IsClipboardFormatAvailable( CF_WAVE ), "SetClipboardData succeeded\n" );
|
||||
ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "wrong error %u\n", GetLastError() );
|
||||
ok( !IsClipboardFormatAvailable( CF_WAVE ), "SetClipboardData succeeded\n" );
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4508,6 +4508,7 @@ struct set_clipboard_info_reply
|
|||
|
||||
#define SET_CB_SEQNO 0x008
|
||||
#define SET_CB_RELOWNER 0x010
|
||||
#define CB_OPEN_ANY 0x020
|
||||
#define CB_OPEN 0x040
|
||||
#define CB_OWNER 0x080
|
||||
#define CB_PROCESS 0x100
|
||||
|
@ -6317,6 +6318,6 @@ union generic_reply
|
|||
struct terminate_job_reply terminate_job_reply;
|
||||
};
|
||||
|
||||
#define SERVER_PROTOCOL_VERSION 512
|
||||
#define SERVER_PROTOCOL_VERSION 513
|
||||
|
||||
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
|
||||
|
|
|
@ -223,6 +223,7 @@ DECL_HANDLER(set_clipboard_info)
|
|||
|
||||
reply->seqno = get_seqno( clipboard );
|
||||
|
||||
if (clipboard->open_thread) reply->flags |= CB_OPEN_ANY;
|
||||
if (clipboard->open_thread == current) reply->flags |= CB_OPEN;
|
||||
if (clipboard->owner_thread == current) reply->flags |= CB_OWNER;
|
||||
if (clipboard->owner_thread && clipboard->owner_thread->process == current->process)
|
||||
|
|
|
@ -3189,6 +3189,7 @@ enum caret_state
|
|||
|
||||
#define SET_CB_SEQNO 0x008
|
||||
#define SET_CB_RELOWNER 0x010
|
||||
#define CB_OPEN_ANY 0x020
|
||||
#define CB_OPEN 0x040
|
||||
#define CB_OWNER 0x080
|
||||
#define CB_PROCESS 0x100
|
||||
|
|
Loading…
Reference in New Issue