2005-01-01 01:51:05 +00:00
|
|
|
/* $Id$
|
1999-08-29 06:59:11 +00:00
|
|
|
*
|
1998-12-04 18:28:13 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
|
|
|
* FILE: lib/kernel32/proc/proc.c
|
|
|
|
* PURPOSE: Process functions
|
|
|
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
* Created 01/11/98
|
1996-01-23 01:02:17 +00:00
|
|
|
*/
|
1999-01-16 21:03:00 +00:00
|
|
|
|
|
|
|
/* INCLUDES ****************************************************************/
|
|
|
|
|
2003-01-15 21:24:36 +00:00
|
|
|
#include <k32.h>
|
2002-09-08 10:23:54 +00:00
|
|
|
|
1999-01-16 21:03:00 +00:00
|
|
|
#define NDEBUG
|
2007-09-02 19:42:22 +00:00
|
|
|
#include <debug.h>
|
1999-01-16 02:11:45 +00:00
|
|
|
|
2000-01-26 10:07:30 +00:00
|
|
|
|
1999-05-29 00:15:17 +00:00
|
|
|
/* GLOBALS *******************************************************************/
|
1999-01-01 22:03:17 +00:00
|
|
|
|
1998-12-04 18:28:13 +00:00
|
|
|
WaitForInputIdleType lpfnGlobalRegisterWaitForInputIdle;
|
1996-01-23 01:02:17 +00:00
|
|
|
|
2003-08-05 15:41:03 +00:00
|
|
|
LPSTARTUPINFOA lpLocalStartupInfo = NULL;
|
2000-02-19 19:37:13 +00:00
|
|
|
|
2001-03-13 16:25:55 +00:00
|
|
|
VOID STDCALL
|
2003-01-22 02:24:36 +00:00
|
|
|
RegisterWaitForInputIdle(WaitForInputIdleType lpfnRegisterWaitForInputIdle);
|
1996-01-23 01:02:17 +00:00
|
|
|
|
2003-01-22 02:24:36 +00:00
|
|
|
/* FUNCTIONS ****************************************************************/
|
1999-04-14 00:52:19 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2003-03-06 15:05:29 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
GetProcessAffinityMask (HANDLE hProcess,
|
|
|
|
LPDWORD lpProcessAffinityMask,
|
|
|
|
LPDWORD lpSystemAffinityMask)
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2003-03-06 15:05:29 +00:00
|
|
|
PROCESS_BASIC_INFORMATION ProcessInfo;
|
2005-01-07 13:34:47 +00:00
|
|
|
SYSTEM_BASIC_INFORMATION SystemInfo;
|
2003-03-06 15:05:29 +00:00
|
|
|
NTSTATUS Status;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2005-01-07 13:34:47 +00:00
|
|
|
Status = NtQuerySystemInformation(SystemBasicInformation,
|
|
|
|
&SystemInfo,
|
|
|
|
sizeof(SystemInfo),
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastErrorByStatus (Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-03-06 15:05:29 +00:00
|
|
|
|
|
|
|
Status = NtQueryInformationProcess (hProcess,
|
|
|
|
ProcessBasicInformation,
|
|
|
|
(PVOID)&ProcessInfo,
|
|
|
|
sizeof(PROCESS_BASIC_INFORMATION),
|
2004-10-19 10:27:11 +00:00
|
|
|
NULL);
|
2003-03-06 15:05:29 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
2002-10-20 16:40:12 +00:00
|
|
|
{
|
2004-09-19 14:36:47 +00:00
|
|
|
SetLastErrorByStatus (Status);
|
2003-03-06 15:05:29 +00:00
|
|
|
return FALSE;
|
2002-10-20 16:40:12 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 15:05:29 +00:00
|
|
|
*lpProcessAffinityMask = (DWORD)ProcessInfo.AffinityMask;
|
2005-06-20 04:07:49 +00:00
|
|
|
*lpSystemAffinityMask = (DWORD)SystemInfo.ActiveProcessorsAffinityMask;
|
2002-10-20 16:40:12 +00:00
|
|
|
|
2003-03-06 15:05:29 +00:00
|
|
|
return TRUE;
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2003-01-22 02:24:36 +00:00
|
|
|
BOOL STDCALL
|
2003-03-06 15:05:29 +00:00
|
|
|
SetProcessAffinityMask (HANDLE hProcess,
|
|
|
|
DWORD dwProcessAffinityMask)
|
2003-01-22 02:24:36 +00:00
|
|
|
{
|
2003-03-06 15:05:29 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
Status = NtSetInformationProcess (hProcess,
|
|
|
|
ProcessAffinityMask,
|
|
|
|
(PVOID)&dwProcessAffinityMask,
|
|
|
|
sizeof(DWORD));
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2004-09-19 14:36:47 +00:00
|
|
|
SetLastErrorByStatus (Status);
|
2003-03-06 15:05:29 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2003-01-22 02:24:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2004-01-23 17:18:16 +00:00
|
|
|
BOOL STDCALL
|
2003-03-06 15:05:29 +00:00
|
|
|
GetProcessShutdownParameters (LPDWORD lpdwLevel,
|
|
|
|
LPDWORD lpdwFlags)
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
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 CsrRequest;
|
|
|
|
ULONG Request;
|
2002-10-20 16:40:12 +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
|
|
|
Request = GET_SHUTDOWN_PARAMETERS;
|
2002-10-20 16:40:12 +00:00
|
|
|
Status = CsrClientCallServer(&CsrRequest,
|
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,
|
|
|
|
MAKE_CSR_API(Request, CSR_NATIVE),
|
|
|
|
sizeof(CSR_API_MESSAGE));
|
|
|
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrRequest.Status))
|
2002-10-20 16:40:12 +00:00
|
|
|
{
|
2004-09-19 14:36:47 +00:00
|
|
|
SetLastErrorByStatus (Status);
|
2002-10-20 16:40:12 +00:00
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
*lpdwLevel = CsrRequest.Data.GetShutdownParametersRequest.Level;
|
|
|
|
*lpdwFlags = CsrRequest.Data.GetShutdownParametersRequest.Flags;
|
2002-10-20 16:40:12 +00:00
|
|
|
|
|
|
|
return(TRUE);
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2004-01-23 17:18:16 +00:00
|
|
|
BOOL STDCALL
|
2003-03-06 15:05:29 +00:00
|
|
|
SetProcessShutdownParameters (DWORD dwLevel,
|
|
|
|
DWORD dwFlags)
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
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 CsrRequest;
|
|
|
|
ULONG Request;
|
2002-10-20 16:40:12 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
CsrRequest.Data.SetShutdownParametersRequest.Level = dwLevel;
|
|
|
|
CsrRequest.Data.SetShutdownParametersRequest.Flags = dwFlags;
|
|
|
|
|
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
|
|
|
Request = SET_SHUTDOWN_PARAMETERS;
|
2002-10-20 16:40:12 +00:00
|
|
|
Status = CsrClientCallServer(&CsrRequest,
|
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,
|
|
|
|
MAKE_CSR_API(Request, CSR_NATIVE),
|
|
|
|
sizeof(CSR_API_MESSAGE));
|
|
|
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrRequest.Status))
|
2002-10-20 16:40:12 +00:00
|
|
|
{
|
2004-09-19 14:36:47 +00:00
|
|
|
SetLastErrorByStatus (Status);
|
2002-10-20 16:40:12 +00:00
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(TRUE);
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
2002-10-20 16:40:12 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2004-01-23 17:18:16 +00:00
|
|
|
BOOL STDCALL
|
2003-03-06 15:05:29 +00:00
|
|
|
GetProcessWorkingSetSize (HANDLE hProcess,
|
2004-09-19 14:36:47 +00:00
|
|
|
PSIZE_T lpMinimumWorkingSetSize,
|
|
|
|
PSIZE_T lpMaximumWorkingSetSize)
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2003-01-22 02:24:36 +00:00
|
|
|
QUOTA_LIMITS QuotaLimits;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
Status = NtQueryInformationProcess(hProcess,
|
|
|
|
ProcessQuotaLimits,
|
|
|
|
&QuotaLimits,
|
|
|
|
sizeof(QUOTA_LIMITS),
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastErrorByStatus(Status);
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
2004-09-19 14:36:47 +00:00
|
|
|
*lpMinimumWorkingSetSize = QuotaLimits.MinimumWorkingSetSize;
|
|
|
|
*lpMaximumWorkingSetSize = QuotaLimits.MaximumWorkingSetSize;
|
2003-01-22 02:24:36 +00:00
|
|
|
|
|
|
|
return(TRUE);
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
2004-09-19 14:36:47 +00:00
|
|
|
* @implemented
|
2003-07-10 18:50:51 +00:00
|
|
|
*/
|
2004-01-23 17:18:16 +00:00
|
|
|
BOOL STDCALL
|
2002-10-20 16:40:12 +00:00
|
|
|
SetProcessWorkingSetSize(HANDLE hProcess,
|
2004-09-19 14:36:47 +00:00
|
|
|
SIZE_T dwMinimumWorkingSetSize,
|
|
|
|
SIZE_T dwMaximumWorkingSetSize)
|
2001-03-31 01:17:30 +00:00
|
|
|
{
|
2004-09-19 14:36:47 +00:00
|
|
|
QUOTA_LIMITS QuotaLimits;
|
|
|
|
NTSTATUS Status;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2004-09-19 14:36:47 +00:00
|
|
|
QuotaLimits.MinimumWorkingSetSize = dwMinimumWorkingSetSize;
|
|
|
|
QuotaLimits.MaximumWorkingSetSize = dwMaximumWorkingSetSize;
|
|
|
|
|
|
|
|
Status = NtSetInformationProcess(hProcess,
|
|
|
|
ProcessQuotaLimits,
|
|
|
|
&QuotaLimits,
|
|
|
|
sizeof(QUOTA_LIMITS));
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastErrorByStatus(Status);
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(TRUE);
|
2001-03-31 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2004-01-23 17:18:16 +00:00
|
|
|
BOOL STDCALL
|
2002-10-20 16:40:12 +00:00
|
|
|
GetProcessTimes(HANDLE hProcess,
|
|
|
|
LPFILETIME lpCreationTime,
|
|
|
|
LPFILETIME lpExitTime,
|
|
|
|
LPFILETIME lpKernelTime,
|
|
|
|
LPFILETIME lpUserTime)
|
1999-04-14 00:52:19 +00:00
|
|
|
{
|
2002-10-20 16:40:12 +00:00
|
|
|
KERNEL_USER_TIMES Kut;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
Status = NtQueryInformationProcess(hProcess,
|
|
|
|
ProcessTimes,
|
|
|
|
&Kut,
|
|
|
|
sizeof(Kut),
|
|
|
|
NULL);
|
2001-03-13 16:25:55 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2002-10-20 16:40:12 +00:00
|
|
|
SetLastErrorByStatus(Status);
|
|
|
|
return(FALSE);
|
2001-03-13 16:25:55 +00:00
|
|
|
}
|
2002-10-20 16:40:12 +00:00
|
|
|
|
2003-01-22 02:24:36 +00:00
|
|
|
lpCreationTime->dwLowDateTime = Kut.CreateTime.u.LowPart;
|
2001-03-13 16:25:55 +00:00
|
|
|
lpCreationTime->dwHighDateTime = Kut.CreateTime.u.HighPart;
|
2002-10-20 16:40:12 +00:00
|
|
|
|
2001-03-13 16:25:55 +00:00
|
|
|
lpExitTime->dwLowDateTime = Kut.ExitTime.u.LowPart;
|
|
|
|
lpExitTime->dwHighDateTime = Kut.ExitTime.u.HighPart;
|
2002-10-20 16:40:12 +00:00
|
|
|
|
2001-03-13 16:25:55 +00:00
|
|
|
lpKernelTime->dwLowDateTime = Kut.KernelTime.u.LowPart;
|
|
|
|
lpKernelTime->dwHighDateTime = Kut.KernelTime.u.HighPart;
|
2002-10-20 16:40:12 +00:00
|
|
|
|
2001-03-13 16:25:55 +00:00
|
|
|
lpUserTime->dwLowDateTime = Kut.UserTime.u.LowPart;
|
|
|
|
lpUserTime->dwHighDateTime = Kut.UserTime.u.HighPart;
|
2002-10-20 16:40:12 +00:00
|
|
|
|
|
|
|
return(TRUE);
|
1999-04-14 00:52:19 +00:00
|
|
|
}
|
|
|
|
|
1999-08-29 06:59:11 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-10-20 16:40:12 +00:00
|
|
|
HANDLE STDCALL
|
|
|
|
GetCurrentProcess(VOID)
|
1996-01-23 01:02:17 +00:00
|
|
|
{
|
2002-10-20 16:40:12 +00:00
|
|
|
return((HANDLE)NtCurrentProcess());
|
1998-12-04 18:28:13 +00:00
|
|
|
}
|
|
|
|
|
1999-08-29 06:59:11 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-10-20 16:40:12 +00:00
|
|
|
HANDLE STDCALL
|
|
|
|
GetCurrentThread(VOID)
|
1998-12-04 18:28:13 +00:00
|
|
|
{
|
2002-10-20 16:40:12 +00:00
|
|
|
return((HANDLE)NtCurrentThread());
|
1998-12-04 18:28:13 +00:00
|
|
|
}
|
|
|
|
|
1999-08-29 06:59:11 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-10-20 16:40:12 +00:00
|
|
|
DWORD STDCALL
|
|
|
|
GetCurrentProcessId(VOID)
|
1999-10-13 22:35:55 +00:00
|
|
|
{
|
2008-08-25 16:38:02 +00:00
|
|
|
return((DWORD)GetTeb()->ClientId.UniqueProcess);
|
1996-01-23 01:02:17 +00:00
|
|
|
}
|
|
|
|
|
1999-08-29 06:59:11 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2004-01-23 17:18:16 +00:00
|
|
|
BOOL STDCALL
|
2002-10-20 16:40:12 +00:00
|
|
|
GetExitCodeProcess(HANDLE hProcess,
|
|
|
|
LPDWORD lpExitCode)
|
1999-01-16 02:11:45 +00:00
|
|
|
{
|
2002-10-20 16:40:12 +00:00
|
|
|
PROCESS_BASIC_INFORMATION ProcessBasic;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
Status = NtQueryInformationProcess(hProcess,
|
|
|
|
ProcessBasicInformation,
|
|
|
|
&ProcessBasic,
|
|
|
|
sizeof(PROCESS_BASIC_INFORMATION),
|
2004-10-19 10:27:11 +00:00
|
|
|
NULL);
|
2002-10-20 16:40:12 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastErrorByStatus(Status);
|
|
|
|
return(FALSE);
|
1999-01-16 21:03:00 +00:00
|
|
|
}
|
2002-10-20 16:40:12 +00:00
|
|
|
|
2005-02-14 16:49:36 +00:00
|
|
|
*lpExitCode = (DWORD)ProcessBasic.ExitStatus;
|
2002-10-20 16:40:12 +00:00
|
|
|
|
|
|
|
return(TRUE);
|
1996-01-23 01:02:17 +00:00
|
|
|
}
|
|
|
|
|
1999-08-29 06:59:11 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2004-11-02 21:51:25 +00:00
|
|
|
DWORD
|
|
|
|
STDCALL
|
|
|
|
GetProcessId(HANDLE Process)
|
1996-01-23 01:02:17 +00:00
|
|
|
{
|
2003-01-22 02:24:36 +00:00
|
|
|
PROCESS_BASIC_INFORMATION ProcessBasic;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
2004-11-02 21:51:25 +00:00
|
|
|
Status = NtQueryInformationProcess(Process,
|
2003-01-22 02:24:36 +00:00
|
|
|
ProcessBasicInformation,
|
|
|
|
&ProcessBasic,
|
|
|
|
sizeof(PROCESS_BASIC_INFORMATION),
|
2004-10-19 10:27:11 +00:00
|
|
|
NULL);
|
2003-01-22 02:24:36 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
2004-03-14 11:11:17 +00:00
|
|
|
{
|
2004-11-02 21:51:25 +00:00
|
|
|
SetLastErrorByStatus(Status);
|
2004-03-14 11:11:17 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2004-11-02 21:51:25 +00:00
|
|
|
|
2005-01-26 00:03:05 +00:00
|
|
|
return (DWORD)ProcessBasic.UniqueProcessId;
|
2004-03-14 11:11:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-10-20 16:40:12 +00:00
|
|
|
HANDLE STDCALL
|
|
|
|
OpenProcess(DWORD dwDesiredAccess,
|
2004-01-23 17:18:16 +00:00
|
|
|
BOOL bInheritHandle,
|
2002-10-20 16:40:12 +00:00
|
|
|
DWORD dwProcessId)
|
1998-12-04 18:28:13 +00:00
|
|
|
{
|
1999-01-16 21:03:00 +00:00
|
|
|
NTSTATUS errCode;
|
|
|
|
HANDLE ProcessHandle;
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
2004-10-02 21:14:08 +00:00
|
|
|
CLIENT_ID ClientId;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
1999-01-16 21:03:00 +00:00
|
|
|
ClientId.UniqueProcess = (HANDLE)dwProcessId;
|
2005-04-18 05:12:36 +00:00
|
|
|
ClientId.UniqueThread = 0;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2005-04-18 05:12:36 +00:00
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
NULL,
|
|
|
|
(bInheritHandle ? OBJ_INHERIT : 0),
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2000-02-19 19:37:13 +00:00
|
|
|
errCode = NtOpenProcess(&ProcessHandle,
|
|
|
|
dwDesiredAccess,
|
|
|
|
&ObjectAttributes,
|
1999-01-16 21:03:00 +00:00
|
|
|
&ClientId);
|
2000-02-19 19:37:13 +00:00
|
|
|
if (!NT_SUCCESS(errCode))
|
1999-01-16 21:03:00 +00:00
|
|
|
{
|
2000-04-25 23:22:57 +00:00
|
|
|
SetLastErrorByStatus (errCode);
|
1999-01-16 21:03:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return ProcessHandle;
|
1998-12-04 18:28:13 +00:00
|
|
|
}
|
|
|
|
|
1999-08-29 06:59:11 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-10-20 16:40:12 +00:00
|
|
|
UINT STDCALL
|
|
|
|
WinExec(LPCSTR lpCmdLine,
|
|
|
|
UINT uCmdShow)
|
1996-01-23 01:02:17 +00:00
|
|
|
{
|
1999-10-13 22:35:55 +00:00
|
|
|
STARTUPINFOA StartupInfo;
|
|
|
|
PROCESS_INFORMATION ProcessInformation;
|
1999-01-16 21:03:00 +00:00
|
|
|
DWORD dosErr;
|
2000-02-19 19:37:13 +00:00
|
|
|
|
2004-05-29 15:10:28 +00:00
|
|
|
RtlZeroMemory(&StartupInfo, sizeof(StartupInfo));
|
1999-10-13 22:35:55 +00:00
|
|
|
StartupInfo.cb = sizeof(STARTUPINFOA);
|
2007-01-26 07:22:19 +00:00
|
|
|
StartupInfo.wShowWindow = (WORD)uCmdShow;
|
1999-01-16 21:03:00 +00:00
|
|
|
StartupInfo.dwFlags = 0;
|
1999-10-13 22:35:55 +00:00
|
|
|
|
2004-07-02 12:18:04 +00:00
|
|
|
if (! CreateProcessA(NULL,
|
|
|
|
(PVOID)lpCmdLine,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&StartupInfo,
|
|
|
|
&ProcessInformation))
|
1999-01-16 21:03:00 +00:00
|
|
|
{
|
|
|
|
dosErr = GetLastError();
|
2004-07-02 12:18:04 +00:00
|
|
|
return dosErr < 32 ? dosErr : ERROR_BAD_FORMAT;
|
1999-01-16 21:03:00 +00:00
|
|
|
}
|
2000-04-25 23:22:57 +00:00
|
|
|
if (NULL != lpfnGlobalRegisterWaitForInputIdle)
|
2004-07-02 12:18:04 +00:00
|
|
|
{
|
|
|
|
lpfnGlobalRegisterWaitForInputIdle (
|
|
|
|
ProcessInformation.hProcess,
|
|
|
|
10000
|
2000-04-25 23:22:57 +00:00
|
|
|
);
|
2004-07-02 12:18:04 +00:00
|
|
|
}
|
|
|
|
NtClose(ProcessInformation.hProcess);
|
|
|
|
NtClose(ProcessInformation.hThread);
|
|
|
|
|
|
|
|
return 33; /* Something bigger than 31 means success. */
|
1996-01-23 01:02:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-10-20 16:40:12 +00:00
|
|
|
VOID STDCALL
|
1999-08-29 06:59:11 +00:00
|
|
|
RegisterWaitForInputIdle (
|
|
|
|
WaitForInputIdleType lpfnRegisterWaitForInputIdle
|
|
|
|
)
|
1998-12-04 18:28:13 +00:00
|
|
|
{
|
2000-03-16 01:14:58 +00:00
|
|
|
lpfnGlobalRegisterWaitForInputIdle = lpfnRegisterWaitForInputIdle;
|
1999-08-29 06:59:11 +00:00
|
|
|
return;
|
1998-12-04 18:28:13 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2000-12-28 20:38:28 +00:00
|
|
|
VOID STDCALL
|
|
|
|
GetStartupInfoW(LPSTARTUPINFOW lpStartupInfo)
|
1996-01-23 01:02:17 +00:00
|
|
|
{
|
2002-10-20 16:40:12 +00:00
|
|
|
PRTL_USER_PROCESS_PARAMETERS Params;
|
1999-10-13 22:35:55 +00:00
|
|
|
|
2002-10-20 16:40:12 +00:00
|
|
|
if (lpStartupInfo == NULL)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return;
|
|
|
|
}
|
1999-10-13 22:35:55 +00:00
|
|
|
|
2002-10-20 16:40:12 +00:00
|
|
|
Params = NtCurrentPeb()->ProcessParameters;
|
|
|
|
|
|
|
|
lpStartupInfo->cb = sizeof(STARTUPINFOW);
|
|
|
|
lpStartupInfo->lpDesktop = Params->DesktopInfo.Buffer;
|
|
|
|
lpStartupInfo->lpTitle = Params->WindowTitle.Buffer;
|
2005-07-12 01:56:14 +00:00
|
|
|
lpStartupInfo->dwX = Params->StartingX;
|
|
|
|
lpStartupInfo->dwY = Params->StartingY;
|
|
|
|
lpStartupInfo->dwXSize = Params->CountX;
|
|
|
|
lpStartupInfo->dwYSize = Params->CountY;
|
|
|
|
lpStartupInfo->dwXCountChars = Params->CountCharsX;
|
|
|
|
lpStartupInfo->dwYCountChars = Params->CountCharsY;
|
|
|
|
lpStartupInfo->dwFillAttribute = Params->FillAttribute;
|
|
|
|
lpStartupInfo->dwFlags = Params->WindowFlags;
|
2007-01-26 07:22:19 +00:00
|
|
|
lpStartupInfo->wShowWindow = (WORD)Params->ShowWindowFlags;
|
2005-07-12 01:56:14 +00:00
|
|
|
lpStartupInfo->cbReserved2 = Params->RuntimeData.Length;
|
|
|
|
lpStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeData.Buffer;
|
|
|
|
|
|
|
|
lpStartupInfo->hStdInput = Params->StandardInput;
|
|
|
|
lpStartupInfo->hStdOutput = Params->StandardOutput;
|
|
|
|
lpStartupInfo->hStdError = Params->StandardError;
|
1996-01-23 01:02:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2000-12-28 20:38:28 +00:00
|
|
|
VOID STDCALL
|
|
|
|
GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo)
|
1998-12-04 18:28:13 +00:00
|
|
|
{
|
2002-10-20 16:40:12 +00:00
|
|
|
PRTL_USER_PROCESS_PARAMETERS Params;
|
|
|
|
ANSI_STRING AnsiString;
|
1999-10-13 22:35:55 +00:00
|
|
|
|
2002-10-20 16:40:12 +00:00
|
|
|
if (lpStartupInfo == NULL)
|
|
|
|
{
|
1999-04-10 12:08:24 +00:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
1998-12-04 18:28:13 +00:00
|
|
|
return;
|
2002-10-20 16:40:12 +00:00
|
|
|
}
|
1999-10-13 22:35:55 +00:00
|
|
|
|
2002-10-20 16:40:12 +00:00
|
|
|
Params = NtCurrentPeb ()->ProcessParameters;
|
1999-10-13 22:35:55 +00:00
|
|
|
|
2002-10-20 16:40:12 +00:00
|
|
|
RtlAcquirePebLock ();
|
2000-02-19 19:37:13 +00:00
|
|
|
|
2005-12-11 21:12:22 +00:00
|
|
|
/* FIXME - not thread-safe */
|
2002-10-20 16:40:12 +00:00
|
|
|
if (lpLocalStartupInfo == NULL)
|
|
|
|
{
|
2000-02-19 19:37:13 +00:00
|
|
|
/* create new local startup info (ansi) */
|
|
|
|
lpLocalStartupInfo = RtlAllocateHeap (RtlGetProcessHeap (),
|
|
|
|
0,
|
|
|
|
sizeof(STARTUPINFOA));
|
2005-12-11 21:12:22 +00:00
|
|
|
if (lpLocalStartupInfo == NULL)
|
|
|
|
{
|
|
|
|
RtlReleasePebLock ();
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return;
|
|
|
|
}
|
2000-02-19 19:37:13 +00:00
|
|
|
|
|
|
|
lpLocalStartupInfo->cb = sizeof(STARTUPINFOA);
|
|
|
|
|
|
|
|
/* copy window title string */
|
|
|
|
RtlUnicodeStringToAnsiString (&AnsiString,
|
|
|
|
&Params->WindowTitle,
|
|
|
|
TRUE);
|
|
|
|
lpLocalStartupInfo->lpTitle = AnsiString.Buffer;
|
|
|
|
|
|
|
|
/* copy desktop info string */
|
|
|
|
RtlUnicodeStringToAnsiString (&AnsiString,
|
|
|
|
&Params->DesktopInfo,
|
|
|
|
TRUE);
|
|
|
|
lpLocalStartupInfo->lpDesktop = AnsiString.Buffer;
|
|
|
|
|
|
|
|
/* copy shell info string */
|
|
|
|
RtlUnicodeStringToAnsiString (&AnsiString,
|
|
|
|
&Params->ShellInfo,
|
|
|
|
TRUE);
|
|
|
|
lpLocalStartupInfo->lpReserved = AnsiString.Buffer;
|
|
|
|
|
2005-07-12 01:56:14 +00:00
|
|
|
lpLocalStartupInfo->dwX = Params->StartingX;
|
|
|
|
lpLocalStartupInfo->dwY = Params->StartingY;
|
|
|
|
lpLocalStartupInfo->dwXSize = Params->CountX;
|
|
|
|
lpLocalStartupInfo->dwYSize = Params->CountY;
|
|
|
|
lpLocalStartupInfo->dwXCountChars = Params->CountCharsX;
|
|
|
|
lpLocalStartupInfo->dwYCountChars = Params->CountCharsY;
|
|
|
|
lpLocalStartupInfo->dwFillAttribute = Params->FillAttribute;
|
|
|
|
lpLocalStartupInfo->dwFlags = Params->WindowFlags;
|
2007-01-26 07:22:19 +00:00
|
|
|
lpLocalStartupInfo->wShowWindow = (WORD)Params->ShowWindowFlags;
|
2005-07-12 01:56:14 +00:00
|
|
|
lpLocalStartupInfo->cbReserved2 = Params->RuntimeData.Length;
|
|
|
|
lpLocalStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeData.Buffer;
|
|
|
|
|
|
|
|
lpLocalStartupInfo->hStdInput = Params->StandardInput;
|
|
|
|
lpLocalStartupInfo->hStdOutput = Params->StandardOutput;
|
|
|
|
lpLocalStartupInfo->hStdError = Params->StandardError;
|
1999-04-10 12:08:24 +00:00
|
|
|
}
|
2000-02-19 19:37:13 +00:00
|
|
|
|
|
|
|
RtlReleasePebLock ();
|
|
|
|
|
|
|
|
/* copy local startup info data to external startup info */
|
|
|
|
memcpy (lpStartupInfo,
|
|
|
|
lpLocalStartupInfo,
|
|
|
|
sizeof(STARTUPINFOA));
|
1998-12-04 18:28:13 +00:00
|
|
|
}
|
|
|
|
|
1999-08-29 06:59:11 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-08-26 11:24:29 +00:00
|
|
|
BOOL STDCALL
|
|
|
|
FlushInstructionCache (HANDLE hProcess,
|
|
|
|
LPCVOID lpBaseAddress,
|
|
|
|
DWORD dwSize)
|
1996-01-23 01:02:17 +00:00
|
|
|
{
|
2002-10-20 16:40:12 +00:00
|
|
|
NTSTATUS Status;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2002-10-20 16:40:12 +00:00
|
|
|
Status = NtFlushInstructionCache(hProcess,
|
|
|
|
(PVOID)lpBaseAddress,
|
|
|
|
dwSize);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2002-08-26 11:24:29 +00:00
|
|
|
{
|
2002-10-20 16:40:12 +00:00
|
|
|
SetLastErrorByStatus(Status);
|
2002-08-26 11:24:29 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
1998-12-04 18:28:13 +00:00
|
|
|
}
|
|
|
|
|
1999-08-29 06:59:11 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-08-26 11:24:29 +00:00
|
|
|
VOID STDCALL
|
2002-10-20 16:40:12 +00:00
|
|
|
ExitProcess(UINT uExitCode)
|
1999-05-11 15:28:11 +00:00
|
|
|
{
|
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 CsrRequest;
|
|
|
|
ULONG Request;
|
2002-08-26 11:24:29 +00:00
|
|
|
NTSTATUS Status;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2007-08-27 05:00:03 +00:00
|
|
|
/* kill sibling threads ... we want to be alone at this point */
|
|
|
|
NtTerminateProcess (NULL, 0);
|
|
|
|
|
2002-08-26 11:24:29 +00:00
|
|
|
/* unload all dll's */
|
|
|
|
LdrShutdownProcess ();
|
|
|
|
|
|
|
|
/* notify csrss of process termination */
|
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
|
|
|
Request = TERMINATE_PROCESS;
|
2005-05-09 01:46:57 +00:00
|
|
|
Status = CsrClientCallServer(&CsrRequest,
|
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,
|
|
|
|
MAKE_CSR_API(Request, CSR_NATIVE),
|
|
|
|
sizeof(CSR_API_MESSAGE));
|
|
|
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrRequest.Status))
|
2002-08-26 11:24:29 +00:00
|
|
|
{
|
2004-09-13 19:10:45 +00:00
|
|
|
DPRINT("Failed to tell csrss about terminating process\n");
|
2002-08-26 11:24:29 +00:00
|
|
|
}
|
2005-05-09 01:46:57 +00:00
|
|
|
|
|
|
|
|
2002-08-26 11:24:29 +00:00
|
|
|
NtTerminateProcess (NtCurrentProcess (),
|
|
|
|
uExitCode);
|
My biggest commit so far (everything compiles and apparently runs fine):
- replaced DWORD with ULONG in a couple of places
- replaced some ULONGs with LONGs in the KD GDB stub
- replaced INITIAL_TEB with USER_STACK, as per Nebbet's book, to support both fixed size and expandable stacks
- added InterlockedExchangePointer
- added the ASM_BREAKPOINT macro as the architecture-dependent assembler code to raise a breakpoint exception
- corrected definitions of INT, LONG, DWORD, UINT, ULONG and ULONG32
- corrected IoSetCancelRoutine to use InterlockedExchangePointer
- corrected definition of NtCurrentTeb and NtCurrentPeb
- corrected DbgBreakPoint and DbgUserBreakPoint not to set up a stack frame (temporary fix with inline assembler - why doesn't GCC understand __declspec(naked)?)
- corrected various calls to Interlocked* functions to cast OUT operands to LONG *
- corrected various printf format strings
- corrected DbgUiIssueRemoteBreakin to use the smallest possible stack (this is what started everything)
- removed a DPRINT that accessed pageable memory at non-PASSIVE_LEVEL IRQL
- beautified CreateProcessA (another temporary fix - all the new functions will be isolated in the upcoming stand-alone RTL)
- prefixed LdrInitializeThunk with a nop that can be overwritten with a breakpoint for debugging purposes (temporary debugging aid until we have user-mode debugger support). Will add support for this to the breakin utility soon
- thread creation code rewritten from scratch (some glitches documented inline, but works fine)
- thread creation code now duplicated just twice, as opposed to five times (temporary fix - three new, non standard functions have been exported from NTDLL.DLL, will fix later)
svn path=/trunk/; revision=4595
2003-04-26 23:13:33 +00:00
|
|
|
|
|
|
|
/* should never get here */
|
2004-11-05 12:28:19 +00:00
|
|
|
ASSERT(0);
|
My biggest commit so far (everything compiles and apparently runs fine):
- replaced DWORD with ULONG in a couple of places
- replaced some ULONGs with LONGs in the KD GDB stub
- replaced INITIAL_TEB with USER_STACK, as per Nebbet's book, to support both fixed size and expandable stacks
- added InterlockedExchangePointer
- added the ASM_BREAKPOINT macro as the architecture-dependent assembler code to raise a breakpoint exception
- corrected definitions of INT, LONG, DWORD, UINT, ULONG and ULONG32
- corrected IoSetCancelRoutine to use InterlockedExchangePointer
- corrected definition of NtCurrentTeb and NtCurrentPeb
- corrected DbgBreakPoint and DbgUserBreakPoint not to set up a stack frame (temporary fix with inline assembler - why doesn't GCC understand __declspec(naked)?)
- corrected various calls to Interlocked* functions to cast OUT operands to LONG *
- corrected various printf format strings
- corrected DbgUiIssueRemoteBreakin to use the smallest possible stack (this is what started everything)
- removed a DPRINT that accessed pageable memory at non-PASSIVE_LEVEL IRQL
- beautified CreateProcessA (another temporary fix - all the new functions will be isolated in the upcoming stand-alone RTL)
- prefixed LdrInitializeThunk with a nop that can be overwritten with a breakpoint for debugging purposes (temporary debugging aid until we have user-mode debugger support). Will add support for this to the breakin utility soon
- thread creation code rewritten from scratch (some glitches documented inline, but works fine)
- thread creation code now duplicated just twice, as opposed to five times (temporary fix - three new, non standard functions have been exported from NTDLL.DLL, will fix later)
svn path=/trunk/; revision=4595
2003-04-26 23:13:33 +00:00
|
|
|
while(1);
|
1999-05-11 15:28:11 +00:00
|
|
|
}
|
|
|
|
|
1999-08-29 06:59:11 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2004-01-23 17:18:16 +00:00
|
|
|
BOOL STDCALL
|
2002-08-26 11:24:29 +00:00
|
|
|
TerminateProcess (HANDLE hProcess,
|
|
|
|
UINT uExitCode)
|
1999-05-11 15:28:11 +00:00
|
|
|
{
|
2002-10-20 16:40:12 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
Status = NtTerminateProcess (hProcess, uExitCode);
|
2002-08-26 11:24:29 +00:00
|
|
|
if (NT_SUCCESS(Status))
|
2001-08-15 20:35:39 +00:00
|
|
|
{
|
2002-08-26 11:24:29 +00:00
|
|
|
return TRUE;
|
2001-08-15 20:35:39 +00:00
|
|
|
}
|
2002-08-26 11:24:29 +00:00
|
|
|
SetLastErrorByStatus (Status);
|
|
|
|
return FALSE;
|
1996-01-23 01:02:17 +00:00
|
|
|
}
|
1998-10-05 04:01:30 +00:00
|
|
|
|
2000-03-16 01:14:58 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2002-08-26 11:24:29 +00:00
|
|
|
VOID STDCALL
|
|
|
|
FatalAppExitA (UINT uAction,
|
|
|
|
LPCSTR lpMessageText)
|
1998-12-04 18:28:13 +00:00
|
|
|
{
|
2002-08-26 11:24:29 +00:00
|
|
|
UNICODE_STRING MessageTextU;
|
|
|
|
ANSI_STRING MessageText;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2002-08-26 11:24:29 +00:00
|
|
|
RtlInitAnsiString (&MessageText, (LPSTR) lpMessageText);
|
2000-03-16 01:14:58 +00:00
|
|
|
|
2002-08-26 11:24:29 +00:00
|
|
|
RtlAnsiStringToUnicodeString (&MessageTextU,
|
|
|
|
&MessageText,
|
|
|
|
TRUE);
|
2000-03-16 01:14:58 +00:00
|
|
|
|
2002-08-26 11:24:29 +00:00
|
|
|
FatalAppExitW (uAction, MessageTextU.Buffer);
|
1999-10-13 22:35:55 +00:00
|
|
|
|
2002-08-26 11:24:29 +00:00
|
|
|
RtlFreeUnicodeString (&MessageTextU);
|
1998-12-04 18:28:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2002-08-26 11:24:29 +00:00
|
|
|
VOID STDCALL
|
2002-10-20 16:40:12 +00:00
|
|
|
FatalAppExitW(UINT uAction,
|
|
|
|
LPCWSTR lpMessageText)
|
1998-12-04 18:28:13 +00:00
|
|
|
{
|
2002-08-26 11:24:29 +00:00
|
|
|
return;
|
1998-12-04 18:28:13 +00:00
|
|
|
}
|
1999-08-29 06:59:11 +00:00
|
|
|
|
2000-04-25 23:22:57 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-08-26 11:24:29 +00:00
|
|
|
VOID STDCALL
|
|
|
|
FatalExit (int ExitCode)
|
2000-09-05 13:53:27 +00:00
|
|
|
{
|
2002-08-26 11:24:29 +00:00
|
|
|
ExitProcess(ExitCode);
|
2000-09-05 13:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-08-26 11:24:29 +00:00
|
|
|
DWORD STDCALL
|
2004-09-19 14:36:47 +00:00
|
|
|
GetPriorityClass (HANDLE hProcess)
|
2000-04-25 23:22:57 +00:00
|
|
|
{
|
2004-09-19 14:36:47 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
PROCESS_PRIORITY_CLASS PriorityClass;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2004-09-19 14:36:47 +00:00
|
|
|
Status = NtQueryInformationProcess(hProcess,
|
|
|
|
ProcessPriorityClass,
|
|
|
|
&PriorityClass,
|
|
|
|
sizeof(PROCESS_PRIORITY_CLASS),
|
|
|
|
NULL);
|
|
|
|
if(NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
switch(PriorityClass.PriorityClass)
|
2002-08-26 11:24:29 +00:00
|
|
|
{
|
2004-09-19 14:36:47 +00:00
|
|
|
case PROCESS_PRIORITY_CLASS_IDLE:
|
|
|
|
return IDLE_PRIORITY_CLASS;
|
|
|
|
|
|
|
|
case PROCESS_PRIORITY_CLASS_BELOW_NORMAL:
|
|
|
|
return BELOW_NORMAL_PRIORITY_CLASS;
|
|
|
|
|
|
|
|
case PROCESS_PRIORITY_CLASS_NORMAL:
|
|
|
|
return NORMAL_PRIORITY_CLASS;
|
|
|
|
|
|
|
|
case PROCESS_PRIORITY_CLASS_ABOVE_NORMAL:
|
|
|
|
return ABOVE_NORMAL_PRIORITY_CLASS;
|
|
|
|
|
|
|
|
case PROCESS_PRIORITY_CLASS_HIGH:
|
|
|
|
return HIGH_PRIORITY_CLASS;
|
|
|
|
|
|
|
|
case PROCESS_PRIORITY_CLASS_REALTIME:
|
|
|
|
return REALTIME_PRIORITY_CLASS;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return NORMAL_PRIORITY_CLASS;
|
2002-08-26 11:24:29 +00:00
|
|
|
}
|
2004-09-19 14:36:47 +00:00
|
|
|
}
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2004-09-19 14:36:47 +00:00
|
|
|
SetLastErrorByStatus(Status);
|
|
|
|
return FALSE;
|
2000-04-25 23:22:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2004-01-23 17:18:16 +00:00
|
|
|
BOOL STDCALL
|
2004-09-19 14:36:47 +00:00
|
|
|
SetPriorityClass (HANDLE hProcess,
|
2002-08-26 11:24:29 +00:00
|
|
|
DWORD dwPriorityClass)
|
2000-04-25 23:22:57 +00:00
|
|
|
{
|
2004-09-19 14:36:47 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
PROCESS_PRIORITY_CLASS PriorityClass;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2004-09-19 14:36:47 +00:00
|
|
|
switch(dwPriorityClass)
|
|
|
|
{
|
|
|
|
case IDLE_PRIORITY_CLASS:
|
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_IDLE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BELOW_NORMAL_PRIORITY_CLASS:
|
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_BELOW_NORMAL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NORMAL_PRIORITY_CLASS:
|
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL;
|
2002-08-26 11:24:29 +00:00
|
|
|
break;
|
2004-09-19 14:36:47 +00:00
|
|
|
|
|
|
|
case ABOVE_NORMAL_PRIORITY_CLASS:
|
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_ABOVE_NORMAL;
|
2002-08-26 11:24:29 +00:00
|
|
|
break;
|
2004-09-19 14:36:47 +00:00
|
|
|
|
|
|
|
case HIGH_PRIORITY_CLASS:
|
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_HIGH;
|
2002-08-26 11:24:29 +00:00
|
|
|
break;
|
2004-09-19 14:36:47 +00:00
|
|
|
|
|
|
|
case REALTIME_PRIORITY_CLASS:
|
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_REALTIME;
|
2002-08-26 11:24:29 +00:00
|
|
|
break;
|
2004-09-19 14:36:47 +00:00
|
|
|
|
2002-08-26 11:24:29 +00:00
|
|
|
default:
|
2004-09-19 14:36:47 +00:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2004-09-19 14:36:47 +00:00
|
|
|
PriorityClass.Foreground = FALSE;
|
|
|
|
|
|
|
|
Status = NtSetInformationProcess(hProcess,
|
|
|
|
ProcessPriorityClass,
|
|
|
|
&PriorityClass,
|
|
|
|
sizeof(PROCESS_PRIORITY_CLASS));
|
|
|
|
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastErrorByStatus(Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2004-09-19 14:36:47 +00:00
|
|
|
return TRUE;
|
2000-04-25 23:22:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2002-08-26 11:24:29 +00:00
|
|
|
DWORD STDCALL
|
2003-03-06 15:05:29 +00:00
|
|
|
GetProcessVersion (DWORD ProcessId)
|
2001-02-10 22:01:50 +00:00
|
|
|
{
|
2002-08-26 11:24:29 +00:00
|
|
|
DWORD Version = 0;
|
|
|
|
PIMAGE_NT_HEADERS NtHeader = NULL;
|
|
|
|
PVOID BaseAddress = NULL;
|
2001-02-10 22:01:50 +00:00
|
|
|
|
2002-08-26 11:24:29 +00:00
|
|
|
/* Caller's */
|
2003-03-06 15:05:29 +00:00
|
|
|
if (0 == ProcessId || GetCurrentProcessId() == ProcessId)
|
2002-08-26 11:24:29 +00:00
|
|
|
{
|
|
|
|
BaseAddress = (PVOID) NtCurrentPeb()->ImageBaseAddress;
|
|
|
|
NtHeader = RtlImageNtHeader (BaseAddress);
|
|
|
|
if (NULL != NtHeader)
|
2001-02-10 22:01:50 +00:00
|
|
|
{
|
2002-08-26 11:24:29 +00:00
|
|
|
Version =
|
2005-05-09 01:46:57 +00:00
|
|
|
(NtHeader->OptionalHeader.MajorOperatingSystemVersion << 16) |
|
2002-08-26 11:24:29 +00:00
|
|
|
(NtHeader->OptionalHeader.MinorOperatingSystemVersion);
|
2001-02-10 22:01:50 +00:00
|
|
|
}
|
2002-08-26 11:24:29 +00:00
|
|
|
}
|
|
|
|
else /* other process */
|
|
|
|
{
|
|
|
|
/* FIXME: open the other process */
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
return (Version);
|
2001-02-10 22:01:50 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 18:16:40 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
GetProcessIoCounters(
|
|
|
|
HANDLE hProcess,
|
|
|
|
PIO_COUNTERS lpIoCounters)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
Status = NtQueryInformationProcess(hProcess,
|
|
|
|
ProcessIoCounters,
|
|
|
|
lpIoCounters,
|
|
|
|
sizeof(IO_COUNTERS),
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastErrorByStatus(Status);
|
|
|
|
return(FALSE);
|
|
|
|
}
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2004-03-14 18:16:40 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-08-29 14:46:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
GetProcessPriorityBoost(HANDLE hProcess,
|
|
|
|
PBOOL pDisablePriorityBoost)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
2005-01-21 21:34:49 +00:00
|
|
|
ULONG PriorityBoost;
|
2004-08-29 14:46:02 +00:00
|
|
|
|
|
|
|
Status = NtQueryInformationProcess(hProcess,
|
|
|
|
ProcessPriorityBoost,
|
|
|
|
&PriorityBoost,
|
2005-01-21 21:34:49 +00:00
|
|
|
sizeof(ULONG),
|
2004-08-29 14:46:02 +00:00
|
|
|
NULL);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
*pDisablePriorityBoost = PriorityBoost;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetLastErrorByStatus(Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
SetProcessPriorityBoost(HANDLE hProcess,
|
|
|
|
BOOL bDisablePriorityBoost)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
2005-01-21 21:34:49 +00:00
|
|
|
ULONG PriorityBoost = (bDisablePriorityBoost ? TRUE : FALSE); /* prevent setting values other than 1 and 0 */
|
2004-08-29 14:46:02 +00:00
|
|
|
|
|
|
|
Status = NtSetInformationProcess(hProcess,
|
|
|
|
ProcessPriorityBoost,
|
|
|
|
&PriorityBoost,
|
2005-01-21 21:34:49 +00:00
|
|
|
sizeof(ULONG));
|
2004-08-29 14:46:02 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastErrorByStatus(Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-09-21 21:53:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
STDCALL
|
|
|
|
GetProcessHandleCount(HANDLE hProcess,
|
|
|
|
PDWORD pdwHandleCount)
|
|
|
|
{
|
2004-10-19 10:27:11 +00:00
|
|
|
ULONG phc;
|
2004-09-21 21:53:45 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
Status = NtQueryInformationProcess(hProcess,
|
|
|
|
ProcessHandleCount,
|
|
|
|
&phc,
|
|
|
|
sizeof(ULONG),
|
2004-10-19 10:27:11 +00:00
|
|
|
NULL);
|
2004-09-21 21:53:45 +00:00
|
|
|
if(NT_SUCCESS(Status))
|
|
|
|
{
|
2004-09-23 19:01:38 +00:00
|
|
|
*pdwHandleCount = phc;
|
2004-09-21 21:53:45 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetLastErrorByStatus(Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-08-29 06:59:11 +00:00
|
|
|
/* EOF */
|