2003-11-19 12:33:32 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2005-01-06 13:58:04 +00:00
|
|
|
/* $Id$
|
2003-11-19 12:33:32 +00:00
|
|
|
*
|
|
|
|
* 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 ******************************************************************/
|
|
|
|
|
2005-06-19 18:06:53 +00:00
|
|
|
#include <user32.h>
|
2006-06-26 13:16:43 +00:00
|
|
|
|
|
|
|
#include <wine/debug.h>
|
2003-11-19 12:33:32 +00:00
|
|
|
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
DWORD
|
|
|
|
STDCALL
|
|
|
|
GetGuiResources(
|
|
|
|
HANDLE hProcess,
|
|
|
|
DWORD uiFlags)
|
|
|
|
{
|
|
|
|
return NtUserGetGuiResources(hProcess, uiFlags);
|
|
|
|
}
|
|
|
|
|
2003-12-03 21:50:50 +00:00
|
|
|
|
|
|
|
/*
|
2004-05-28 21:33:41 +00:00
|
|
|
* Private calls for CSRSS
|
2003-12-03 21:50:50 +00:00
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
STDCALL
|
2003-12-07 23:02:57 +00:00
|
|
|
PrivateCsrssManualGuiCheck(LONG Check)
|
2003-12-03 21:50:50 +00:00
|
|
|
{
|
2003-12-07 23:02:57 +00:00
|
|
|
NtUserManualGuiCheck(Check);
|
2003-12-03 21:50:50 +00:00
|
|
|
}
|
2004-05-01 16:43:15 +00:00
|
|
|
|
2004-05-28 21:33:41 +00:00
|
|
|
VOID
|
|
|
|
STDCALL
|
2004-07-08 14:36:18 +00:00
|
|
|
PrivateCsrssInitialized(VOID)
|
2004-05-28 21:33:41 +00:00
|
|
|
{
|
|
|
|
NtUserCallNoParam(NOPARAM_ROUTINE_CSRSS_INITIALIZED);
|
|
|
|
}
|
|
|
|
|
2004-07-08 14:36:18 +00:00
|
|
|
|
2004-05-01 16:43:15 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
2004-07-08 14:36:18 +00:00
|
|
|
RegisterLogonProcess(DWORD dwProcessId, BOOL bRegister)
|
2004-05-01 16:43:15 +00:00
|
|
|
{
|
2004-07-08 14:36:18 +00:00
|
|
|
return NtUserCallTwoParam(dwProcessId,
|
|
|
|
(DWORD)bRegister,
|
|
|
|
TWOPARAM_ROUTINE_REGISTERLOGONPROC);
|
2004-05-01 16:43:15 +00:00
|
|
|
}
|
2004-07-12 20:09:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
SetLogonNotifyWindow (HWND Wnd, HWINSTA WinSta)
|
|
|
|
{
|
|
|
|
/* Maybe we should call NtUserSetLogonNotifyWindow and let that one inform CSRSS??? */
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
CSR_API_MESSAGE Request;
|
|
|
|
ULONG CsrRequest;
|
2004-07-12 20:09:35 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
CsrRequest = MAKE_CSR_API(SET_LOGON_NOTIFY_WINDOW, CSR_GUI);
|
2004-07-12 20:09:35 +00:00
|
|
|
Request.Data.SetLogonNotifyWindowRequest.LogonNotifyWindow = Wnd;
|
|
|
|
|
|
|
|
Status = CsrClientCallServer(&Request,
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
NULL,
|
|
|
|
CsrRequest,
|
|
|
|
sizeof(CSR_API_MESSAGE));
|
|
|
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
|
2004-07-12 20:09:35 +00:00
|
|
|
{
|
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
2004-11-20 15:55:45 +00:00
|
|
|
|
|
|
|
/*
|
2004-12-06 02:23:05 +00:00
|
|
|
* @implemented
|
2004-11-20 15:55:45 +00:00
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
2004-12-06 02:23:05 +00:00
|
|
|
UpdatePerUserSystemParameters(
|
|
|
|
DWORD dwReserved,
|
|
|
|
BOOL bEnable)
|
2004-11-20 15:55:45 +00:00
|
|
|
{
|
2004-12-06 08:41:38 +00:00
|
|
|
return NtUserUpdatePerUserSystemParameters(dwReserved, bEnable);
|
2004-11-20 15:55:45 +00:00
|
|
|
}
|
2006-04-05 08:05:55 +00:00
|
|
|
|
|
|
|
PW32THREADINFO
|
|
|
|
GetW32ThreadInfo(VOID)
|
|
|
|
{
|
|
|
|
PW32THREADINFO ti;
|
|
|
|
|
|
|
|
ti = (PW32THREADINFO)NtCurrentTeb()->Win32ThreadInfo;
|
|
|
|
if (ti == NULL)
|
|
|
|
{
|
|
|
|
/* create the W32THREADINFO structure */
|
|
|
|
NtUserGetThreadState(THREADSTATE_GETTHREADINFO);
|
|
|
|
ti = (PW32THREADINFO)NtCurrentTeb()->Win32ThreadInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ti;
|
|
|
|
}
|
|
|
|
|
|
|
|
PW32PROCESSINFO
|
|
|
|
GetW32ProcessInfo(VOID)
|
|
|
|
{
|
|
|
|
PW32THREADINFO ti;
|
|
|
|
PW32PROCESSINFO pi = NULL;
|
|
|
|
|
|
|
|
ti = GetW32ThreadInfo();
|
|
|
|
if (ti != NULL)
|
|
|
|
{
|
|
|
|
pi = ti->pi;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pi;
|
|
|
|
}
|
2006-07-09 00:16:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GetUserObjectSecurity
|
|
|
|
*
|
|
|
|
* Retrieves security information for user object specified
|
|
|
|
* with handle 'hObject'. Descriptor returned in self-relative
|
|
|
|
* format.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 1) hObject - handle to an object to retrieve information for
|
|
|
|
* 2) pSecurityInfo - type of information to retrieve
|
|
|
|
* 3) pSecurityDescriptor - buffer which receives descriptor
|
|
|
|
* 4) dwLength - size, in bytes, of buffer 'pSecurityDescriptor'
|
|
|
|
* 5) pdwLengthNeeded - reseives actual size of descriptor
|
|
|
|
*
|
|
|
|
* Return Vaules:
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure, call GetLastError() for more information
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
GetUserObjectSecurity(
|
|
|
|
IN HANDLE hObject,
|
|
|
|
IN PSECURITY_INFORMATION pSecurityInfo,
|
|
|
|
OUT PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|
|
|
IN DWORD dwLength,
|
|
|
|
OUT PDWORD pdwLengthNeeded
|
|
|
|
)
|
|
|
|
{
|
|
|
|
DWORD dwWin32Error;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
|
|
|
|
Status = NtQuerySecurityObject(
|
|
|
|
hObject, // Object Handle
|
|
|
|
*pSecurityInfo, // Security Information
|
|
|
|
pSecurityDescriptor,// Security Descriptor
|
|
|
|
dwLength, // Buffer Length
|
|
|
|
pdwLengthNeeded // Actual Length
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( ! NT_SUCCESS( Status ) ) {
|
|
|
|
dwWin32Error = RtlNtStatusToDosError( Status );
|
|
|
|
NtCurrentTeb()->LastErrorValue = dwWin32Error;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SetUserObjectSecurity
|
|
|
|
*
|
|
|
|
* Sets new security descriptor to user object specified by
|
|
|
|
* handle 'hObject'. Descriptor must be in self-relative format.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 1) hObject - handle to an object to set information for
|
|
|
|
* 2) pSecurityInfo - type of information to apply
|
|
|
|
* 3) pSecurityDescriptor - buffer which descriptor to set
|
|
|
|
*
|
|
|
|
* Return Vaules:
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure, call GetLastError() for more information
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
SetUserObjectSecurity(
|
|
|
|
IN HANDLE hObject,
|
|
|
|
IN PSECURITY_INFORMATION pSecurityInfo,
|
|
|
|
IN PSECURITY_DESCRIPTOR pSecurityDescriptor
|
|
|
|
)
|
|
|
|
{
|
|
|
|
DWORD dwWin32Error;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
|
|
|
|
Status = NtSetSecurityObject(
|
|
|
|
hObject, // Object Handle
|
|
|
|
*pSecurityInfo, // Security Information
|
|
|
|
pSecurityDescriptor // Security Descriptor
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( ! NT_SUCCESS( Status ) ) {
|
|
|
|
dwWin32Error = RtlNtStatusToDosError( Status );
|
|
|
|
NtCurrentTeb()->LastErrorValue = dwWin32Error;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
EndTask(
|
|
|
|
HWND hWnd,
|
|
|
|
BOOL fShutDown,
|
|
|
|
BOOL fForce)
|
|
|
|
{
|
|
|
|
SendMessageW(hWnd, WM_CLOSE, 0, 0);
|
|
|
|
|
|
|
|
if (IsWindow(hWnd))
|
|
|
|
{
|
|
|
|
if (fForce)
|
|
|
|
return DestroyWindow(hWnd);
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2007-09-20 14:26:43 +00:00
|
|
|
|
2007-09-24 02:42:17 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
IsGUIThread(
|
|
|
|
BOOL bConvert)
|
|
|
|
{
|
|
|
|
PW32THREADINFO ti = (PW32THREADINFO)NtCurrentTeb()->Win32ThreadInfo;
|
|
|
|
if (ti == NULL)
|
|
|
|
{
|
|
|
|
if(bConvert)
|
|
|
|
{
|
2007-09-24 02:58:22 +00:00
|
|
|
NtUserGetThreadState(THREADSTATE_GETTHREADINFO);
|
|
|
|
if ((PW32THREADINFO)NtCurrentTeb()->Win32ThreadInfo) return TRUE;
|
2007-09-24 02:42:17 +00:00
|
|
|
else
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-09-20 14:26:43 +00:00
|
|
|
PUSER_HANDLE_ENTRY
|
|
|
|
FASTCALL
|
|
|
|
GetUser32Handle(HANDLE handle)
|
|
|
|
{
|
|
|
|
PUSER_HANDLE_TABLE ht = gHandleTable;
|
|
|
|
USHORT generation;
|
|
|
|
|
|
|
|
DPRINT1("Main Handle Table %x\n", ht);
|
|
|
|
|
|
|
|
INT Index = (((UINT)handle & 0xffff) - FIRST_USER_HANDLE) >> 1;
|
|
|
|
|
|
|
|
if (Index < 0 || Index >= ht->nb_handles) return NULL;
|
|
|
|
|
|
|
|
if (!ht->handles[Index].type) return NULL;
|
|
|
|
|
|
|
|
generation = (UINT)handle >> 16;
|
|
|
|
|
|
|
|
if (generation == ht->handles[Index].generation || !generation || generation == 0xffff)
|
|
|
|
return &ht->handles[Index];
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Validate Handle and return the pointer to the object.
|
|
|
|
//
|
|
|
|
PVOID
|
|
|
|
FASTCALL
|
|
|
|
ValidateHandle(HANDLE handle, UINT uType)
|
|
|
|
{
|
|
|
|
PW32CLIENTINFO ClientInfo = GetWin32ClientInfo();
|
|
|
|
|
|
|
|
if (uType == VALIDATE_TYPE_WIN)
|
|
|
|
{
|
|
|
|
if (handle == ClientInfo->hWND) return ClientInfo->pvWND;
|
|
|
|
}
|
|
|
|
|
|
|
|
PUSER_HANDLE_ENTRY pEntry = GetUser32Handle(handle);
|
|
|
|
|
|
|
|
// Must have an entry and must be the same type!
|
|
|
|
if ( (!pEntry) || (pEntry->type != uType) )
|
|
|
|
{
|
|
|
|
switch ( uType )
|
|
|
|
{ // Test (with wine too) confirms these results!
|
|
|
|
case VALIDATE_TYPE_WIN:
|
|
|
|
SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|
|
|
break;
|
|
|
|
case VALIDATE_TYPE_MENU:
|
|
|
|
SetLastError(ERROR_INVALID_MENU_HANDLE);
|
|
|
|
break;
|
|
|
|
case VALIDATE_TYPE_CURSOR:
|
|
|
|
SetLastError(ERROR_INVALID_CURSOR_HANDLE);
|
|
|
|
break;
|
|
|
|
case VALIDATE_TYPE_MWPOS:
|
|
|
|
SetLastError(ERROR_INVALID_DWP_HANDLE);
|
|
|
|
break;
|
|
|
|
case VALIDATE_TYPE_HOOK:
|
|
|
|
SetLastError(ERROR_INVALID_HOOK_HANDLE);
|
|
|
|
break;
|
|
|
|
case VALIDATE_TYPE_ACCEL:
|
|
|
|
SetLastError(ERROR_INVALID_ACCEL_HANDLE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(NtUserValidateHandleSecure(handle, FALSE))) return NULL;
|
|
|
|
|
|
|
|
return pEntry->ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|