/****************************************************************************** * SetConsoleScreenBufferSize [KERNEL32.@] Changes size of console * * PARAMS * hConsoleOutput [I] Handle to console screen buffer * dwSize [I] New size in character rows and cols * * RETURNS * Success: TRUE * Failure: FALSE */ BOOL WINAPI SetConsoleScreenBufferSize(HANDLE hConsoleOutput, COORD dwSize) { BOOL ret; SERVER_START_REQ(set_console_output_info) { req->handle = hConsoleOutput; req->width = dwSize.X; req->height = dwSize.Y; req->mask = SET_CONSOLE_OUTPUT_INFO_SIZE; ret = !wine_server_call_err( req ); } SERVER_END_REQ; return ret; }
/****************************************************************************** * SetConsoleCursorInfo [KERNEL32.@] Sets size and visibility of cursor * * PARAMS * hcon [I] Handle to console screen buffer * cinfo [I] Address of cursor information * RETURNS * Success: TRUE * Failure: FALSE */ BOOL WINAPI SetConsoleCursorInfo(HANDLE hCon, LPCONSOLE_CURSOR_INFO cinfo) { BOOL ret; SERVER_START_REQ(set_console_output_info) { req->handle = hCon; req->cursor_size = cinfo->dwSize; req->cursor_visible = cinfo->bVisible; req->mask = SET_CONSOLE_OUTPUT_INFO_CURSOR_GEOM; ret = !wine_server_call_err( req ); } SERVER_END_REQ; return ret; }
/*********************************************************************** * UnhookWindowsHookEx (USER32.@) */ BOOL WINAPI UnhookWindowsHookEx( HHOOK hhook ) { BOOL ret; SERVER_START_REQ( remove_hook ) { req->handle = wine_server_user_handle( hhook ); req->id = 0; ret = !wine_server_call_err( req ); if (ret) get_user_thread_info()->active_hooks = reply->active_hooks; } SERVER_END_REQ; if (!ret && GetLastError() == ERROR_INVALID_HANDLE) SetLastError( ERROR_INVALID_HOOK_HANDLE ); return ret; }
/************************************************************************** * GetClipboardViewer (USER32.@) */ HWND WINAPI GetClipboardViewer(void) { HWND hWndViewer = 0; SERVER_START_REQ( set_clipboard_info ) { req->flags = 0; if (!wine_server_call_err( req )) hWndViewer = reply->old_viewer; } SERVER_END_REQ; TRACE(" hWndViewer=%p\n", hWndViewer); return hWndViewer; }
/************************************************************************** * GetOpenClipboardWindow (USER32.@) */ HWND WINAPI GetOpenClipboardWindow(void) { HWND hWndOpen = 0; SERVER_START_REQ( set_clipboard_info ) { req->flags = 0; if (!wine_server_call_err( req )) hWndOpen = reply->old_clipboard; } SERVER_END_REQ; TRACE(" hWndClipWindow(%p)\n", hWndOpen); return hWndOpen; }
/*********************************************************************** * DebugBreakProcess (KERNEL32.@) * * Raises an exception so that a debugger (if attached) * can take some action. Same as DebugBreak, but applies to any process. * * PARAMS * hProc [I] Process to break into. * * RETURNS * * True if successful. */ BOOL WINAPI DebugBreakProcess(HANDLE hProc) { BOOL ret, self; TRACE("(%p)\n", hProc); SERVER_START_REQ( debug_break ) { req->handle = wine_server_obj_handle( hProc ); ret = !wine_server_call_err( req ); self = ret && reply->self; } SERVER_END_REQ; if (self) DbgBreakPoint(); return ret; }
/************************************************************************** * CLIPBOARD_SetClipboardOwner * * Set the global wineserver clipboard owner. The current process will * be the owner and <hWnd> will get the render notifications. */ static BOOL CLIPBOARD_SetClipboardOwner(HWND hWnd) { BOOL bRet; TRACE(" hWnd(%p)\n", hWnd); SERVER_START_REQ( set_clipboard_info ) { req->flags = SET_CB_OWNER; req->owner = wine_server_user_handle( hWnd ); bRet = !wine_server_call_err( req ); } SERVER_END_REQ; return bRet; }
/****************************************************************************** * SetConsoleActiveScreenBuffer [KERNEL32.@] Sets buffer to current console * * RETURNS * Success: TRUE * Failure: FALSE */ BOOL WINAPI SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput) { BOOL ret; TRACE("(%x)\n", hConsoleOutput); SERVER_START_REQ( set_console_input_info ) { req->handle = 0; req->mask = SET_CONSOLE_INPUT_INFO_ACTIVE_SB; req->active_sb = hConsoleOutput; ret = !wine_server_call_err( req ); } SERVER_END_REQ; return ret; }
/********************************************************************** * ContinueDebugEvent (KERNEL32.@) * * Enables a thread that previously produced a debug event to continue. * * PARAMS * pid [I] The id of the process to continue. * tid [I] The id of the thread to continue. * status [I] The rule to apply to unhandled exeptions. * * RETURNS * * True if the debugger is listed as the processes owner and the process * and thread are valid. */ BOOL WINAPI ContinueDebugEvent( DWORD pid, DWORD tid, DWORD status) { BOOL ret; SERVER_START_REQ( continue_debug_event ) { req->pid = pid; req->tid = tid; req->status = status; ret = !wine_server_call_err( req ); } SERVER_END_REQ; return ret; }
/************************************************************************** * CLIPBOARD_CloseClipboard */ static BOOL CLIPBOARD_CloseClipboard(void) { BOOL bRet; TRACE(" Changed=%d\n", bCBHasChanged); SERVER_START_REQ( set_clipboard_info ) { req->flags = SET_CB_CLOSE; if (bCBHasChanged) req->flags |= SET_CB_SEQNO; bRet = !wine_server_call_err( req ); } SERVER_END_REQ; return bRet; }
/************************************************************************** * SetClipboardViewer (USER32.@) */ HWND WINAPI SetClipboardViewer( HWND hWnd ) { HWND hwndPrev = 0; SERVER_START_REQ( set_clipboard_info ) { req->flags = SET_CB_VIEWER; req->viewer = wine_server_user_handle( hWnd ); if (!wine_server_call_err( req )) hwndPrev = wine_server_ptr_handle( reply->old_viewer ); } SERVER_END_REQ; TRACE("(%p): returning %p\n", hWnd, hwndPrev); return hwndPrev; }
/********************************************************************** * GetKeyboardState (USER32.@) */ BOOL WINAPI DECLSPEC_HOTPATCH GetKeyboardState( LPBYTE state ) { BOOL ret; TRACE("(%p)\n", state); memset( state, 0, 256 ); SERVER_START_REQ( get_key_state ) { req->tid = GetCurrentThreadId(); req->key = -1; wine_server_set_reply( req, state, 256 ); ret = !wine_server_call_err( req ); } SERVER_END_REQ; return ret; }
/****************************************************************************** * GetConsoleCursorInfo [KERNEL32.@] Gets size and visibility of console * * PARAMS * hcon [I] Handle to console screen buffer * cinfo [O] Address of cursor information * * RETURNS * Success: TRUE * Failure: FALSE */ BOOL WINAPI GetConsoleCursorInfo(HANDLE hcon, LPCONSOLE_CURSOR_INFO cinfo) { BOOL ret; SERVER_START_REQ(get_console_output_info) { req->handle = hcon; ret = !wine_server_call_err( req ); if (ret && cinfo) { cinfo->dwSize = reply->cursor_size; cinfo->bVisible = reply->cursor_visible; } } SERVER_END_REQ; return ret; }
/****************************************************************************** * read_console_input * * Helper function for ReadConsole, ReadConsoleInput and PeekConsoleInput */ static BOOL read_console_input(HANDLE handle, LPINPUT_RECORD buffer, DWORD count, LPDWORD pRead, BOOL flush) { BOOL ret; unsigned read = 0; SERVER_START_REQ( read_console_input ) { req->handle = handle; req->flush = flush; wine_server_set_reply( req, buffer, count * sizeof(INPUT_RECORD) ); if ((ret = !wine_server_call_err( req ))) read = reply->read; } SERVER_END_REQ; if (pRead) *pRead = read; return ret; }
/*********************************************************************** * wait_input_idle * * user32.WaitForInputIdle releases the win16 lock, so here is a replacement. */ static DWORD wait_input_idle( HANDLE process, DWORD timeout ) { DWORD ret; HANDLE handles[2]; LOG(LOG_FILE, 0, 0, "\n"); handles[0] = process; SERVER_START_REQ( get_process_idle_event ) { req->handle = process; if (!(ret = wine_server_call_err( req ))) handles[1] = reply->event; } SERVER_END_REQ; if (ret) return WAIT_FAILED; /* error */ if (!handles[1]) return 0; /* no event to wait on */ return WaitForMultipleObjects( 2, handles, FALSE, timeout ); }
/****************************************************************************** * SetThreadDesktop (USER32.@) */ BOOL WINAPI SetThreadDesktop( HDESK handle ) { BOOL ret; SERVER_START_REQ( set_thread_desktop ) { req->handle = wine_server_obj_handle( handle ); ret = !wine_server_call_err( req ); } SERVER_END_REQ; if (ret) /* reset the desktop windows */ { struct user_thread_info *thread_info = get_user_thread_info(); thread_info->top_window = 0; thread_info->msg_window = 0; } return ret; }
/****************************************************************************** * SetConsoleMode [KERNEL32.@] Sets input mode of console's input buffer * * PARAMS * hcon [I] Handle to console input or screen buffer * mode [I] Input or output mode to set * * RETURNS * Success: TRUE * Failure: FALSE */ BOOL WINAPI SetConsoleMode(HANDLE hcon, DWORD mode) { BOOL ret; TRACE("(%x,%lx)\n", hcon, mode); SERVER_START_REQ(set_console_mode) { req->handle = hcon; req->mode = mode; ret = !wine_server_call_err( req ); } SERVER_END_REQ; /* FIXME: when resetting a console input to editline mode, I think we should * empty the S_EditString buffer */ return ret; }
/*********************************************************************** * UnhookWindowsHook (USER32.@) */ BOOL WINAPI UnhookWindowsHook( INT id, HOOKPROC proc ) { BOOL ret; TRACE( "%s %p\n", hook_names[id-WH_MINHOOK], proc ); SERVER_START_REQ( remove_hook ) { req->handle = 0; req->id = id; req->proc = wine_server_client_ptr( proc ); ret = !wine_server_call_err( req ); if (ret) get_user_thread_info()->active_hooks = reply->active_hooks; } SERVER_END_REQ; if (!ret && GetLastError() == ERROR_INVALID_HANDLE) SetLastError( ERROR_INVALID_HOOK_HANDLE ); return ret; }
/****************************************************************************** * OpenWindowStationW (USER32.@) */ HWINSTA WINAPI OpenWindowStationW( LPCWSTR name, BOOL inherit, ACCESS_MASK access ) { HANDLE ret = 0; DWORD len = name ? strlenW(name) : 0; if (len >= MAX_PATH) { SetLastError( ERROR_FILENAME_EXCED_RANGE ); return 0; } SERVER_START_REQ( open_winstation ) { req->access = access; req->attributes = OBJ_CASE_INSENSITIVE | (inherit ? OBJ_INHERIT : 0); wine_server_add_data( req, name, len * sizeof(WCHAR) ); if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->handle ); } SERVER_END_REQ; return ret; }
/********************************************************************** * SetCapture (USER32.@) */ HWND WINAPI SetCapture( HWND hwnd ) { HWND previous = 0; SERVER_START_REQ( set_capture_window ) { req->handle = hwnd; req->flags = 0; if (!wine_server_call_err( req )) { previous = reply->previous; hwnd = reply->full_handle; } } SERVER_END_REQ; if (previous && previous != hwnd) SendMessageW( previous, WM_CAPTURECHANGED, 0, (LPARAM)hwnd ); return previous; }
/********************************************************************** * ReleaseCapture (USER32.@) */ BOOL WINAPI ReleaseCapture(void) { BOOL ret; HWND previous = 0; SERVER_START_REQ( set_capture_window ) { req->handle = 0; req->flags = 0; if ((ret = !wine_server_call_err( req ))) previous = reply->previous; } SERVER_END_REQ; if (previous) SendMessageW( previous, WM_CAPTURECHANGED, 0, 0 ); /* Somebody may have missed some mouse movements */ mouse_event( MOUSEEVENTF_MOVE, 0, 0, 0, 0 ); return ret; }
/****************************************************************************** * OpenInputDesktop (USER32.@) */ HDESK WINAPI OpenInputDesktop( DWORD flags, BOOL inherit, ACCESS_MASK access ) { HANDLE ret = 0; TRACE( "(%x,%i,%x)\n", flags, inherit, access ); if (flags) FIXME( "partial stub flags %08x\n", flags ); SERVER_START_REQ( open_input_desktop ) { req->flags = flags; req->access = access; req->attributes = inherit ? OBJ_INHERIT : 0; if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->handle ); } SERVER_END_REQ; return ret; }
/***************************************************************** * SetCaretPos (USER32.@) */ BOOL WINAPI SetCaretPos( INT x, INT y ) { BOOL ret; HWND hwnd = 0; RECT r; int old_state = 0; int hidden = 0; SERVER_START_REQ( set_caret_info ) { req->flags = SET_CARET_POS|SET_CARET_STATE; req->handle = 0; req->x = x; req->y = y; req->hide = 0; req->state = 1; if ((ret = !wine_server_call_err( req ))) { hwnd = wine_server_ptr_handle( reply->full_handle ); r.left = reply->old_rect.left; r.top = reply->old_rect.top; r.right = reply->old_rect.right; r.bottom = reply->old_rect.bottom; old_state = reply->old_state; hidden = reply->old_hide; } } SERVER_END_REQ; if (ret && !hidden && (x != r.left || y != r.top)) { if (old_state) CARET_DisplayCaret( hwnd, &r ); r.right += x - r.left; r.bottom += y - r.top; r.left = x; r.top = y; CARET_DisplayCaret( hwnd, &r ); USER_Driver->pUpdateCandidatePos( hwnd, &r ); SetSystemTimer( hwnd, TIMERID, Caret.timeout, CARET_Callback ); } return ret; }
/****************************************************************** * GetLastInputInfo (USER32.@) */ BOOL WINAPI GetLastInputInfo(PLASTINPUTINFO plii) { BOOL ret; TRACE("%p\n", plii); if (plii->cbSize != sizeof (*plii) ) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } SERVER_START_REQ( get_last_input_time ) { ret = !wine_server_call_err( req ); if (ret) plii->dwTime = reply->time; } SERVER_END_REQ; return ret; }
/***************************************************************** * GetCaretPos (USER32.@) */ BOOL WINAPI GetCaretPos( LPPOINT pt ) { BOOL ret; SERVER_START_REQ( set_caret_info ) { req->flags = 0; /* don't set anything */ req->handle = 0; req->x = 0; req->y = 0; req->hide = 0; req->state = 0; if ((ret = !wine_server_call_err( req ))) { pt->x = reply->old_rect.left; pt->y = reply->old_rect.top; } } SERVER_END_REQ; return ret; }
/****************************************************************************** * SetUserObjectInformationW (USER32.@) */ BOOL WINAPI SetUserObjectInformationW( HANDLE handle, INT index, LPVOID info, DWORD len ) { BOOL ret; const USEROBJECTFLAGS *obj_flags = info; if (index != UOI_FLAGS || !info || len < sizeof(*obj_flags)) { SetLastError( ERROR_INVALID_PARAMETER ); return FALSE; } /* FIXME: inherit flag */ SERVER_START_REQ( set_user_object_info ) { req->handle = wine_server_obj_handle( handle ); req->flags = SET_USER_OBJECT_FLAGS; req->obj_flags = obj_flags->dwFlags; ret = !wine_server_call_err( req ); } SERVER_END_REQ; return ret; }
/****************************************************************** * write_char * * WriteConsoleOutput helper: hides server call semantics */ static int write_char(HANDLE hCon, LPCWSTR lpBuffer, int nc, COORD* pos) { int written = -1; if (!nc) return 0; SERVER_START_REQ( write_console_output ) { req->handle = hCon; req->x = pos->X; req->y = pos->Y; req->mode = CHAR_INFO_MODE_TEXTSTDATTR; req->wrap = FALSE; wine_server_add_data( req, lpBuffer, nc * sizeof(WCHAR) ); if (!wine_server_call_err( req )) written = reply->written; } SERVER_END_REQ; if (written > 0) pos->X += written; return written; }
/************************************************************************** * CLIPBOARD_ReleaseOwner */ BOOL CLIPBOARD_ReleaseOwner(void) { BOOL bRet = FALSE; SERVER_START_REQ( set_clipboard_info ) { req->flags = SET_CB_RELOWNER | SET_CB_SEQNO; if (wine_server_call_err( req )) { ERR("Failed to set clipboard.\n"); } else { bRet = TRUE; } } SERVER_END_REQ; return bRet; }
/************************************************************************** * CLIPBOARD_GetClipboardInfo */ static BOOL CLIPBOARD_GetClipboardInfo(LPCLIPBOARDINFO cbInfo) { BOOL bRet; SERVER_START_REQ( set_clipboard_info ) { req->flags = 0; if (((bRet = !wine_server_call_err( req )))) { cbInfo->hWndOpen = wine_server_ptr_handle( reply->old_clipboard ); cbInfo->hWndOwner = wine_server_ptr_handle( reply->old_owner ); cbInfo->hWndViewer = wine_server_ptr_handle( reply->old_viewer ); cbInfo->seqno = reply->seqno; cbInfo->flags = reply->flags; } } SERVER_END_REQ; return bRet; }
/****************************************************************************** * GenerateConsoleCtrlEvent [KERNEL32.@] Simulate a CTRL-C or CTRL-BREAK * * PARAMS * dwCtrlEvent [I] Type of event * dwProcessGroupID [I] Process group ID to send event to * * RETURNS * Success: True * Failure: False (and *should* [but doesn't] set LastError) */ BOOL WINAPI GenerateConsoleCtrlEvent(DWORD dwCtrlEvent, DWORD dwProcessGroupID) { BOOL ret; TRACE("(%ld, %ld)\n", dwCtrlEvent, dwProcessGroupID); if (dwCtrlEvent != CTRL_C_EVENT && dwCtrlEvent != CTRL_BREAK_EVENT) { ERR("Invalid event %ld for PGID %ld\n", dwCtrlEvent, dwProcessGroupID); return FALSE; } SERVER_START_REQ( send_console_signal ) { req->signal = dwCtrlEvent; req->group_id = (process_id_t)dwProcessGroupID; ret = !wine_server_call_err( req ); } SERVER_END_REQ; return ret; }