2003-09-19 02:06:45 +02:00
|
|
|
/*
|
2018-10-24 12:27:23 +02:00
|
|
|
* NT process handling
|
2003-09-19 02:06:45 +02:00
|
|
|
*
|
|
|
|
* Copyright 1996-1998 Marcus Meissner
|
2018-10-24 12:27:23 +02:00
|
|
|
* Copyright 2018 Alexandre Julliard
|
2003-09-19 02:06:45 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-09-19 02:06:45 +02:00
|
|
|
*/
|
|
|
|
|
2018-10-24 12:27:23 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
2003-09-19 02:06:45 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
2018-10-24 12:27:23 +02:00
|
|
|
#include <sys/types.h>
|
2003-09-19 02:06:45 +02:00
|
|
|
|
2005-11-28 17:32:54 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#include "wine/debug.h"
|
2003-09-19 02:06:45 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winternl.h"
|
|
|
|
#include "ntdll_misc.h"
|
2019-09-30 15:08:00 +02:00
|
|
|
#include "wine/exception.h"
|
2003-09-19 02:06:45 +02:00
|
|
|
|
2018-10-24 12:27:23 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(process);
|
2003-09-19 02:06:45 +02:00
|
|
|
|
|
|
|
|
2005-08-02 13:38:51 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* RtlGetCurrentPeb [NTDLL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
PEB * WINAPI RtlGetCurrentPeb(void)
|
|
|
|
{
|
|
|
|
return NtCurrentTeb()->Peb;
|
|
|
|
}
|
|
|
|
|
2019-11-11 21:04:27 +01:00
|
|
|
|
2020-06-10 09:37:01 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* RtlCreateUserProcess (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlCreateUserProcess( UNICODE_STRING *path, ULONG attributes,
|
|
|
|
RTL_USER_PROCESS_PARAMETERS *params,
|
|
|
|
SECURITY_DESCRIPTOR *process_descr,
|
|
|
|
SECURITY_DESCRIPTOR *thread_descr,
|
|
|
|
HANDLE parent, BOOLEAN inherit, HANDLE debug, HANDLE exception,
|
|
|
|
RTL_USER_PROCESS_INFORMATION *info )
|
|
|
|
{
|
|
|
|
OBJECT_ATTRIBUTES process_attr, thread_attr;
|
|
|
|
PS_CREATE_INFO create_info;
|
|
|
|
ULONG_PTR buffer[offsetof( PS_ATTRIBUTE_LIST, Attributes[5] ) / sizeof(ULONG_PTR)];
|
|
|
|
PS_ATTRIBUTE_LIST *attr = (PS_ATTRIBUTE_LIST *)buffer;
|
|
|
|
UINT pos = 0;
|
|
|
|
|
|
|
|
RtlNormalizeProcessParams( params );
|
|
|
|
|
|
|
|
attr->Attributes[pos].Attribute = PS_ATTRIBUTE_IMAGE_NAME;
|
|
|
|
attr->Attributes[pos].Size = path->Length;
|
|
|
|
attr->Attributes[pos].ValuePtr = path->Buffer;
|
|
|
|
attr->Attributes[pos].ReturnLength = NULL;
|
|
|
|
pos++;
|
|
|
|
attr->Attributes[pos].Attribute = PS_ATTRIBUTE_CLIENT_ID;
|
|
|
|
attr->Attributes[pos].Size = sizeof(info->ClientId);
|
|
|
|
attr->Attributes[pos].ValuePtr = &info->ClientId;
|
|
|
|
attr->Attributes[pos].ReturnLength = NULL;
|
|
|
|
pos++;
|
|
|
|
attr->Attributes[pos].Attribute = PS_ATTRIBUTE_IMAGE_INFO;
|
|
|
|
attr->Attributes[pos].Size = sizeof(info->ImageInformation);
|
|
|
|
attr->Attributes[pos].ValuePtr = &info->ImageInformation;
|
|
|
|
attr->Attributes[pos].ReturnLength = NULL;
|
|
|
|
pos++;
|
|
|
|
if (parent)
|
|
|
|
{
|
|
|
|
attr->Attributes[pos].Attribute = PS_ATTRIBUTE_PARENT_PROCESS;
|
|
|
|
attr->Attributes[pos].Size = sizeof(parent);
|
|
|
|
attr->Attributes[pos].ValuePtr = parent;
|
|
|
|
attr->Attributes[pos].ReturnLength = NULL;
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
if (debug)
|
|
|
|
{
|
|
|
|
attr->Attributes[pos].Attribute = PS_ATTRIBUTE_DEBUG_PORT;
|
|
|
|
attr->Attributes[pos].Size = sizeof(debug);
|
|
|
|
attr->Attributes[pos].ValuePtr = debug;
|
|
|
|
attr->Attributes[pos].ReturnLength = NULL;
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
attr->TotalLength = offsetof( PS_ATTRIBUTE_LIST, Attributes[pos] );
|
|
|
|
|
|
|
|
InitializeObjectAttributes( &process_attr, NULL, 0, NULL, process_descr );
|
|
|
|
InitializeObjectAttributes( &thread_attr, NULL, 0, NULL, thread_descr );
|
|
|
|
|
|
|
|
return NtCreateUserProcess( &info->Process, &info->Thread, PROCESS_ALL_ACCESS, THREAD_ALL_ACCESS,
|
|
|
|
&process_attr, &thread_attr,
|
|
|
|
inherit ? PROCESS_CREATE_FLAGS_INHERIT_HANDLES : 0,
|
|
|
|
THREAD_CREATE_FLAGS_CREATE_SUSPENDED, params,
|
|
|
|
&create_info, attr );
|
|
|
|
}
|
|
|
|
|
2019-07-05 13:21:14 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* DbgUiRemoteBreakin (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void WINAPI DbgUiRemoteBreakin( void *arg )
|
|
|
|
{
|
|
|
|
TRACE( "\n" );
|
2019-09-30 15:08:00 +02:00
|
|
|
if (NtCurrentTeb()->Peb->BeingDebugged)
|
|
|
|
{
|
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
DbgBreakPoint();
|
|
|
|
}
|
|
|
|
__EXCEPT_ALL
|
|
|
|
{
|
|
|
|
/* do nothing */
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
}
|
2019-07-05 13:21:14 +02:00
|
|
|
RtlExitUserThread( STATUS_SUCCESS );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DbgUiIssueRemoteBreakin (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI DbgUiIssueRemoteBreakin( HANDLE process )
|
|
|
|
{
|
2020-06-05 16:54:17 +02:00
|
|
|
return unix_funcs->DbgUiIssueRemoteBreakin( process );
|
2019-07-05 13:21:14 +02:00
|
|
|
}
|