- Call GetThreadConsoleDesktop of CONSRV if needed, in GetThreadDesktop (in case the process is a console app).
- Introduce two last-error helpers UserSetLast(NT)Error which work the same as the (Base)SetLast(NT)Error of kernel32, needed for CSR status errors etc...

[WINSRV]
- Improve the stub of SrvGetThreadConsoleDesktop (it needs to success, and atm. it always zeroes-out the returned console desktop handle).

svn path=/trunk/; revision=65513
This commit is contained in:
Hermès Bélusca-Maïto 2014-11-28 20:34:16 +00:00
parent 0abf72fdee
commit d3b2696104
5 changed files with 62 additions and 25 deletions

View file

@ -36,18 +36,24 @@ typedef enum _USERSRV_API_NUMBER
} USERSRV_API_NUMBER, *PUSERSRV_API_NUMBER;
typedef struct
typedef struct _USER_EXIT_REACTOS
{
UINT Flags;
DWORD Reserved;
} USER_EXIT_REACTOS, *PUSER_EXIT_REACTOS;
typedef struct
typedef struct _USER_GET_THREAD_CONSOLE_DESKTOP
{
ULONG_PTR ThreadId;
HANDLE ConsoleDesktop;
} USER_GET_THREAD_CONSOLE_DESKTOP, *PUSER_GET_THREAD_CONSOLE_DESKTOP;
typedef struct _USER_REGISTER_SERVICES_PROCESS
{
ULONG_PTR ProcessId;
} USER_REGISTER_SERVICES_PROCESS, *PUSER_REGISTER_SERVICES_PROCESS;
typedef struct
typedef struct _USER_REGISTER_LOGON_PROCESS
{
ULONG_PTR ProcessId;
BOOL Register;
@ -65,6 +71,7 @@ typedef struct _USER_API_MESSAGE
union
{
USER_EXIT_REACTOS ExitReactosRequest;
USER_GET_THREAD_CONSOLE_DESKTOP GetThreadConsoleDesktopRequest;
USER_REGISTER_SERVICES_PROCESS RegisterServicesProcessRequest;
USER_REGISTER_LOGON_PROCESS RegisterLogonProcessRequest;
} Data;

View file

@ -68,6 +68,8 @@ BOOL FASTCALL MessageInit(VOID);
VOID FASTCALL MessageCleanup(VOID);
/* definitions for misc.c */
VOID WINAPI UserSetLastError(IN DWORD dwErrCode);
VOID WINAPI UserSetLastNTError(IN NTSTATUS Status);
PCALLPROCDATA FASTCALL ValidateCallProc(HANDLE hCallProc);
PWND FASTCALL ValidateHwnd(HWND hwnd);
PWND FASTCALL ValidateHwndOrDesk(HWND hwnd);

View file

@ -548,7 +548,23 @@ WINAPI
GetThreadDesktop(
DWORD dwThreadId)
{
return NtUserGetThreadDesktop(dwThreadId, 0);
USER_API_MESSAGE ApiMessage;
PUSER_GET_THREAD_CONSOLE_DESKTOP GetThreadConsoleDesktopRequest = &ApiMessage.Data.GetThreadConsoleDesktopRequest;
GetThreadConsoleDesktopRequest->ThreadId = dwThreadId;
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
NULL,
CSR_CREATE_API_NUMBER(USERSRV_SERVERDLL_INDEX, UserpGetThreadConsoleDesktop),
sizeof(*GetThreadConsoleDesktopRequest));
if (!NT_SUCCESS(ApiMessage.Status))
{
UserSetLastNTError(ApiMessage.Status);
return NULL;
}
return NtUserGetThreadDesktop(dwThreadId,
(DWORD)GetThreadConsoleDesktopRequest->ConsoleDesktop);
}

View file

@ -1,28 +1,9 @@
/*
* ReactOS kernel
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll
* FILE: lib/user32/misc/misc.c
* PURPOSE: Misc
* PROGRAMMER: Thomas Weidenmueller (w3seek@users.sourceforge.net)
* UPDATE HISTORY:
* 19-11-2003 Created
*/
/* INCLUDES ******************************************************************/
@ -35,6 +16,30 @@ WINE_DEFAULT_DEBUG_CHANNEL(user32);
/* FUNCTIONS *****************************************************************/
VOID
WINAPI
UserSetLastError(IN DWORD dwErrCode)
{
/*
* Equivalent of SetLastError in kernel32, but without breaking
* into the debugger nor checking whether the last old error is
* the same as the one we are going to set.
*/
NtCurrentTeb()->LastErrorValue = dwErrCode;
}
VOID
WINAPI
UserSetLastNTError(IN NTSTATUS Status)
{
/*
* Equivalent of BaseSetLastNTError in kernel32, but using
* UserSetLastError: convert from NT to Win32, then set.
*/
UserSetLastError(RtlNtStatusToDosError(Status));
}
/*
* @implemented
*/

View file

@ -121,8 +121,15 @@ CSR_API(SrvActivateDebugger)
CSR_API(SrvGetThreadConsoleDesktop)
{
PUSER_GET_THREAD_CONSOLE_DESKTOP GetThreadConsoleDesktopRequest = &((PUSER_API_MESSAGE)ApiMessage)->Data.GetThreadConsoleDesktopRequest;
DPRINT1("%s not yet implemented\n", __FUNCTION__);
return STATUS_NOT_IMPLEMENTED;
/* Return nothing for the moment... */
GetThreadConsoleDesktopRequest->ConsoleDesktop = NULL;
/* Always succeeds */
return STATUS_SUCCESS;
}
CSR_API(SrvDeviceEvent)