2003-09-19 02:06:45 +02:00
|
|
|
/*
|
|
|
|
* NT basis DLL
|
|
|
|
*
|
|
|
|
* This file contains the Nt* API functions of NTDLL.DLL.
|
|
|
|
* In the original ntdll.dll they all seem to just call int 0x2e (down to the NTOSKRNL)
|
|
|
|
*
|
|
|
|
* Copyright 1996-1998 Marcus Meissner
|
|
|
|
*
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
2015-07-17 06:46:47 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2003-09-19 02:06:45 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
2015-07-17 06:46:47 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
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"
|
|
|
|
#include "wine/server.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
|
|
|
|
|
2009-09-12 01:27:42 +02:00
|
|
|
static ULONG execute_flags = MEM_EXECUTE_OPTION_DISABLE;
|
2009-08-18 01:20:52 +02:00
|
|
|
|
2003-09-19 02:06:45 +02:00
|
|
|
/*
|
|
|
|
* Process object
|
|
|
|
*/
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtTerminateProcess [NTDLL.@]
|
|
|
|
*
|
|
|
|
* Native applications must kill themselves when done
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code )
|
|
|
|
{
|
|
|
|
NTSTATUS ret;
|
|
|
|
BOOL self;
|
|
|
|
SERVER_START_REQ( terminate_process )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( handle );
|
2003-09-19 02:06:45 +02:00
|
|
|
req->exit_code = exit_code;
|
|
|
|
ret = wine_server_call( req );
|
|
|
|
self = !ret && reply->self;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2015-07-17 06:46:47 +02:00
|
|
|
if (self && handle) _exit( exit_code );
|
2003-09-19 02:06:45 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-08-02 13:38:51 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* RtlGetCurrentPeb [NTDLL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
PEB * WINAPI RtlGetCurrentPeb(void)
|
|
|
|
{
|
|
|
|
return NtCurrentTeb()->Peb;
|
|
|
|
}
|
|
|
|
|
2007-06-06 20:33:13 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* __wine_make_process_system (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Mark the current process as a system process.
|
|
|
|
* Returns the event that is signaled when all non-system processes have exited.
|
|
|
|
*/
|
2008-12-16 16:37:46 +01:00
|
|
|
HANDLE CDECL __wine_make_process_system(void)
|
2007-06-06 20:33:13 +02:00
|
|
|
{
|
|
|
|
HANDLE ret = 0;
|
|
|
|
SERVER_START_REQ( make_process_system )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
if (!wine_server_call( req )) ret = wine_server_ptr_handle( reply->event );
|
2007-06-06 20:33:13 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-05-14 22:20:03 +02:00
|
|
|
static UINT process_error_mode;
|
2007-06-06 20:33:13 +02:00
|
|
|
|
2005-07-05 16:05:58 +02:00
|
|
|
#define UNIMPLEMENTED_INFO_CLASS(c) \
|
|
|
|
case c: \
|
|
|
|
FIXME("(process=%p) Unimplemented information class: " #c "\n", ProcessHandle); \
|
|
|
|
ret = STATUS_INVALID_INFO_CLASS; \
|
|
|
|
break
|
|
|
|
|
2015-01-21 13:24:14 +01:00
|
|
|
ULONG_PTR get_system_affinity_mask(void)
|
|
|
|
{
|
|
|
|
ULONG num_cpus = NtCurrentTeb()->Peb->NumberOfProcessors;
|
|
|
|
if (num_cpus >= sizeof(ULONG_PTR) * 8) return ~(ULONG_PTR)0;
|
|
|
|
return ((ULONG_PTR)1 << num_cpus) - 1;
|
|
|
|
}
|
|
|
|
|
2003-09-19 02:06:45 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* NtQueryInformationProcess [NTDLL.@]
|
|
|
|
* ZwQueryInformationProcess [NTDLL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtQueryInformationProcess(
|
|
|
|
IN HANDLE ProcessHandle,
|
|
|
|
IN PROCESSINFOCLASS ProcessInformationClass,
|
|
|
|
OUT PVOID ProcessInformation,
|
|
|
|
IN ULONG ProcessInformationLength,
|
|
|
|
OUT PULONG ReturnLength)
|
|
|
|
{
|
|
|
|
NTSTATUS ret = STATUS_SUCCESS;
|
|
|
|
ULONG len = 0;
|
|
|
|
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%p,0x%08x,%p,0x%08x,%p)\n",
|
2005-06-14 14:25:02 +02:00
|
|
|
ProcessHandle,ProcessInformationClass,
|
|
|
|
ProcessInformation,ProcessInformationLength,
|
|
|
|
ReturnLength);
|
|
|
|
|
2003-09-19 02:06:45 +02:00
|
|
|
switch (ProcessInformationClass)
|
|
|
|
{
|
2005-07-05 16:05:58 +02:00
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessQuotaLimits);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessBasePriority);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessRaisePriority);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessExceptionPort);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessAccessToken);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessLdtInformation);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessLdtSize);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessIoPortHandlers);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessPooledUsageAndLimits);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessWorkingSetWatch);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessUserModeIOPL);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessEnableAlignmentFaultFixup);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessPriorityClass);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessWx86Information);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessPriorityBoost);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessDeviceMap);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessSessionInformation);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessForegroundInformation);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessLUIDDeviceMapsEnabled);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessBreakOnTermination);
|
|
|
|
UNIMPLEMENTED_INFO_CLASS(ProcessHandleTracing);
|
|
|
|
|
2004-06-14 19:02:00 +02:00
|
|
|
case ProcessBasicInformation:
|
|
|
|
{
|
2005-06-21 22:22:01 +02:00
|
|
|
PROCESS_BASIC_INFORMATION pbi;
|
2015-01-21 13:24:14 +01:00
|
|
|
const ULONG_PTR affinity_mask = get_system_affinity_mask();
|
2005-06-21 22:22:01 +02:00
|
|
|
|
|
|
|
if (ProcessInformationLength >= sizeof(PROCESS_BASIC_INFORMATION))
|
2004-06-14 19:02:00 +02:00
|
|
|
{
|
2005-06-21 22:22:01 +02:00
|
|
|
if (!ProcessInformation)
|
|
|
|
ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else if (!ProcessHandle)
|
|
|
|
ret = STATUS_INVALID_HANDLE;
|
|
|
|
else
|
2004-06-14 19:02:00 +02:00
|
|
|
{
|
2005-06-21 22:22:01 +02:00
|
|
|
SERVER_START_REQ(get_process_info)
|
2005-06-14 14:25:02 +02:00
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( ProcessHandle );
|
2005-06-21 22:22:01 +02:00
|
|
|
if ((ret = wine_server_call( req )) == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
pbi.ExitStatus = reply->exit_code;
|
2008-12-30 23:02:33 +01:00
|
|
|
pbi.PebBaseAddress = wine_server_get_ptr( reply->peb );
|
2008-01-16 21:02:04 +01:00
|
|
|
pbi.AffinityMask = reply->affinity & affinity_mask;
|
2005-06-21 22:22:01 +02:00
|
|
|
pbi.BasePriority = reply->priority;
|
|
|
|
pbi.UniqueProcessId = reply->pid;
|
|
|
|
pbi.InheritedFromUniqueProcessId = reply->ppid;
|
|
|
|
}
|
2005-06-14 14:25:02 +02:00
|
|
|
}
|
2005-06-21 22:22:01 +02:00
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
memcpy(ProcessInformation, &pbi, sizeof(PROCESS_BASIC_INFORMATION));
|
|
|
|
|
|
|
|
len = sizeof(PROCESS_BASIC_INFORMATION);
|
2004-06-14 19:02:00 +02:00
|
|
|
}
|
2005-06-21 22:22:01 +02:00
|
|
|
|
|
|
|
if (ProcessInformationLength > sizeof(PROCESS_BASIC_INFORMATION))
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
2004-06-14 19:02:00 +02:00
|
|
|
}
|
2009-08-27 19:46:28 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
len = sizeof(PROCESS_BASIC_INFORMATION);
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
}
|
2004-06-14 19:02:00 +02:00
|
|
|
}
|
|
|
|
break;
|
2003-09-19 02:06:45 +02:00
|
|
|
case ProcessIoCounters:
|
|
|
|
{
|
2005-06-20 13:42:02 +02:00
|
|
|
IO_COUNTERS pii;
|
|
|
|
|
|
|
|
if (ProcessInformationLength >= sizeof(IO_COUNTERS))
|
|
|
|
{
|
|
|
|
if (!ProcessInformation)
|
|
|
|
ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else if (!ProcessHandle)
|
|
|
|
ret = STATUS_INVALID_HANDLE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FIXME : real data */
|
|
|
|
memset(&pii, 0 , sizeof(IO_COUNTERS));
|
|
|
|
|
|
|
|
memcpy(ProcessInformation, &pii, sizeof(IO_COUNTERS));
|
|
|
|
|
|
|
|
len = sizeof(IO_COUNTERS);
|
|
|
|
}
|
2005-06-21 22:22:01 +02:00
|
|
|
|
|
|
|
if (ProcessInformationLength > sizeof(IO_COUNTERS))
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
2005-06-20 13:42:02 +02:00
|
|
|
}
|
2009-08-27 19:46:28 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
len = sizeof(IO_COUNTERS);
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
}
|
2005-06-20 13:42:02 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ProcessVmCounters:
|
|
|
|
{
|
|
|
|
VM_COUNTERS pvmi;
|
|
|
|
|
2009-01-03 14:54:11 +01:00
|
|
|
/* older Windows versions don't have the PrivatePageCount field */
|
|
|
|
if (ProcessInformationLength >= FIELD_OFFSET(VM_COUNTERS,PrivatePageCount))
|
2005-06-20 13:42:02 +02:00
|
|
|
{
|
|
|
|
if (!ProcessInformation)
|
|
|
|
ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else if (!ProcessHandle)
|
|
|
|
ret = STATUS_INVALID_HANDLE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FIXME : real data */
|
|
|
|
memset(&pvmi, 0 , sizeof(VM_COUNTERS));
|
|
|
|
|
2009-01-03 14:54:11 +01:00
|
|
|
len = ProcessInformationLength;
|
|
|
|
if (len != FIELD_OFFSET(VM_COUNTERS,PrivatePageCount)) len = sizeof(VM_COUNTERS);
|
2005-06-20 13:42:02 +02:00
|
|
|
|
2009-01-03 14:54:11 +01:00
|
|
|
memcpy(ProcessInformation, &pvmi, min(ProcessInformationLength,sizeof(VM_COUNTERS)));
|
2005-06-20 13:42:02 +02:00
|
|
|
}
|
2005-06-21 22:22:01 +02:00
|
|
|
|
2009-01-03 14:54:11 +01:00
|
|
|
if (ProcessInformationLength != FIELD_OFFSET(VM_COUNTERS,PrivatePageCount) &&
|
|
|
|
ProcessInformationLength != sizeof(VM_COUNTERS))
|
2005-06-21 22:22:01 +02:00
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
2005-06-20 13:42:02 +02:00
|
|
|
}
|
2009-08-27 19:46:28 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
len = sizeof(pvmi);
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
}
|
2005-06-20 13:42:02 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ProcessTimes:
|
|
|
|
{
|
2005-06-21 22:22:01 +02:00
|
|
|
KERNEL_USER_TIMES pti;
|
|
|
|
|
|
|
|
if (ProcessInformationLength >= sizeof(KERNEL_USER_TIMES))
|
2005-06-20 13:42:02 +02:00
|
|
|
{
|
2005-06-21 22:22:01 +02:00
|
|
|
if (!ProcessInformation)
|
|
|
|
ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else if (!ProcessHandle)
|
|
|
|
ret = STATUS_INVALID_HANDLE;
|
|
|
|
else
|
|
|
|
{
|
2006-07-20 23:30:04 +02:00
|
|
|
/* FIXME : User- and KernelTime have to be implemented */
|
2005-06-21 22:22:01 +02:00
|
|
|
memset(&pti, 0, sizeof(KERNEL_USER_TIMES));
|
2005-06-20 13:42:02 +02:00
|
|
|
|
2006-07-20 23:30:04 +02:00
|
|
|
SERVER_START_REQ(get_process_info)
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( ProcessHandle );
|
2006-07-20 23:30:04 +02:00
|
|
|
if ((ret = wine_server_call( req )) == STATUS_SUCCESS)
|
|
|
|
{
|
2007-04-17 20:08:59 +02:00
|
|
|
pti.CreateTime.QuadPart = reply->start_time;
|
|
|
|
pti.ExitTime.QuadPart = reply->end_time;
|
2006-07-20 23:30:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
2005-06-21 22:22:01 +02:00
|
|
|
memcpy(ProcessInformation, &pti, sizeof(KERNEL_USER_TIMES));
|
|
|
|
len = sizeof(KERNEL_USER_TIMES);
|
|
|
|
}
|
2005-06-20 13:42:02 +02:00
|
|
|
|
2005-06-21 22:22:01 +02:00
|
|
|
if (ProcessInformationLength > sizeof(KERNEL_USER_TIMES))
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
2005-06-20 13:42:02 +02:00
|
|
|
}
|
2009-08-27 19:46:28 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
len = sizeof(KERNEL_USER_TIMES);
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
}
|
2003-09-19 02:06:45 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ProcessDebugPort:
|
2010-03-14 21:53:26 +01:00
|
|
|
len = sizeof(DWORD_PTR);
|
2009-08-27 19:46:28 +02:00
|
|
|
if (ProcessInformationLength == len)
|
2010-03-14 21:53:27 +01:00
|
|
|
{
|
|
|
|
if (!ProcessInformation)
|
|
|
|
ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else if (!ProcessHandle)
|
|
|
|
ret = STATUS_INVALID_HANDLE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SERVER_START_REQ(get_process_info)
|
|
|
|
{
|
|
|
|
req->handle = wine_server_obj_handle( ProcessHandle );
|
|
|
|
if ((ret = wine_server_call( req )) == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
*(DWORD_PTR *)ProcessInformation = reply->debugger_present ? ~(DWORD_PTR)0 : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
|
|
|
}
|
2009-08-27 19:46:28 +02:00
|
|
|
else
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
2009-09-29 18:48:42 +02:00
|
|
|
break;
|
2011-03-28 05:20:20 +02:00
|
|
|
case ProcessDebugFlags:
|
|
|
|
len = sizeof(DWORD);
|
|
|
|
if (ProcessInformationLength == len)
|
|
|
|
{
|
|
|
|
if (!ProcessInformation)
|
|
|
|
ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else if (!ProcessHandle)
|
|
|
|
ret = STATUS_INVALID_HANDLE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SERVER_START_REQ(get_process_info)
|
|
|
|
{
|
|
|
|
req->handle = wine_server_obj_handle( ProcessHandle );
|
|
|
|
if ((ret = wine_server_call( req )) == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
*(DWORD *)ProcessInformation = !reply->debugger_present;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
break;
|
2010-05-14 22:20:03 +02:00
|
|
|
case ProcessDefaultHardErrorMode:
|
|
|
|
len = sizeof(process_error_mode);
|
|
|
|
if (ProcessInformationLength == len)
|
|
|
|
memcpy(ProcessInformation, &process_error_mode, len);
|
|
|
|
else
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
break;
|
2009-09-29 18:48:42 +02:00
|
|
|
case ProcessDebugObjectHandle:
|
|
|
|
/* "These are not the debuggers you are looking for." *
|
|
|
|
* set it to 0 aka "no debugger" to satisfy copy protections */
|
|
|
|
len = sizeof(HANDLE);
|
|
|
|
if (ProcessInformationLength == len)
|
2009-10-06 11:34:21 +02:00
|
|
|
{
|
|
|
|
if (!ProcessInformation)
|
|
|
|
ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else if (!ProcessHandle)
|
|
|
|
ret = STATUS_INVALID_HANDLE;
|
|
|
|
else
|
2010-07-27 13:15:35 +02:00
|
|
|
{
|
2009-10-06 11:34:21 +02:00
|
|
|
memset(ProcessInformation, 0, ProcessInformationLength);
|
2010-07-27 13:15:35 +02:00
|
|
|
ret = STATUS_PORT_NOT_SET;
|
|
|
|
}
|
2009-10-06 11:34:21 +02:00
|
|
|
}
|
2009-09-29 18:48:42 +02:00
|
|
|
else
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
2003-09-19 02:06:45 +02:00
|
|
|
break;
|
2005-06-20 13:42:02 +02:00
|
|
|
case ProcessHandleCount:
|
|
|
|
if (ProcessInformationLength >= 4)
|
|
|
|
{
|
|
|
|
if (!ProcessInformation)
|
|
|
|
ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else if (!ProcessHandle)
|
|
|
|
ret = STATUS_INVALID_HANDLE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memset(ProcessInformation, 0, 4);
|
|
|
|
len = 4;
|
|
|
|
}
|
2005-06-21 22:22:01 +02:00
|
|
|
|
|
|
|
if (ProcessInformationLength > 4)
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
2009-08-27 19:46:28 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
len = 4;
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
}
|
|
|
|
break;
|
2011-04-14 19:57:34 +02:00
|
|
|
|
|
|
|
case ProcessAffinityMask:
|
|
|
|
len = sizeof(ULONG_PTR);
|
|
|
|
if (ProcessInformationLength == len)
|
|
|
|
{
|
2015-01-21 13:24:14 +01:00
|
|
|
const ULONG_PTR system_mask = get_system_affinity_mask();
|
2011-04-14 19:57:34 +02:00
|
|
|
|
|
|
|
SERVER_START_REQ(get_process_info)
|
|
|
|
{
|
|
|
|
req->handle = wine_server_obj_handle( ProcessHandle );
|
|
|
|
if (!(ret = wine_server_call( req )))
|
|
|
|
*(ULONG_PTR *)ProcessInformation = reply->affinity & system_mask;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
|
|
|
else ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
break;
|
|
|
|
|
2003-09-19 02:06:45 +02:00
|
|
|
case ProcessWow64Information:
|
2015-01-15 09:52:26 +01:00
|
|
|
len = sizeof(ULONG_PTR);
|
|
|
|
if (ProcessInformationLength != len) ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
else if (!ProcessInformation) ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else if(!ProcessHandle) ret = STATUS_INVALID_HANDLE;
|
|
|
|
else
|
2003-09-19 02:06:45 +02:00
|
|
|
{
|
2015-01-15 09:52:26 +01:00
|
|
|
ULONG_PTR val = 0;
|
2009-07-07 11:38:19 +02:00
|
|
|
|
|
|
|
if (ProcessHandle == GetCurrentProcess()) val = is_wow64;
|
2015-05-07 23:37:44 +02:00
|
|
|
else if (server_cpus & ((1 << CPU_x86_64) | (1 << CPU_ARM64)))
|
2009-07-07 11:38:19 +02:00
|
|
|
{
|
|
|
|
SERVER_START_REQ( get_process_info )
|
|
|
|
{
|
|
|
|
req->handle = wine_server_obj_handle( ProcessHandle );
|
2015-05-07 23:37:44 +02:00
|
|
|
if (!(ret = wine_server_call( req )))
|
|
|
|
val = (reply->cpu != CPU_x86_64 && reply->cpu != CPU_ARM64);
|
2009-07-07 11:38:19 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
2015-01-15 09:52:26 +01:00
|
|
|
*(ULONG_PTR *)ProcessInformation = val;
|
2003-09-19 02:06:45 +02:00
|
|
|
}
|
|
|
|
break;
|
2007-11-20 10:30:50 +01:00
|
|
|
case ProcessImageFileName:
|
2009-03-29 23:36:33 +02:00
|
|
|
/* FIXME: this will return a DOS path. Windows returns an NT path. Changing this would require also changing kernel32.QueryFullProcessImageName.
|
|
|
|
* The latter may be harder because of the lack of RtlNtPathNameToDosPathName. */
|
2007-11-20 10:30:50 +01:00
|
|
|
SERVER_START_REQ(get_dll_info)
|
|
|
|
{
|
|
|
|
UNICODE_STRING *image_file_name_str = ProcessInformation;
|
|
|
|
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( ProcessHandle );
|
2008-12-29 16:47:51 +01:00
|
|
|
req->base_address = 0; /* main module */
|
2007-11-20 10:30:50 +01:00
|
|
|
wine_server_set_reply( req, image_file_name_str ? image_file_name_str + 1 : NULL,
|
|
|
|
ProcessInformationLength > sizeof(UNICODE_STRING) ? ProcessInformationLength - sizeof(UNICODE_STRING) : 0 );
|
|
|
|
ret = wine_server_call( req );
|
|
|
|
if (ret == STATUS_BUFFER_TOO_SMALL) ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
|
|
|
|
len = sizeof(UNICODE_STRING) + reply->filename_len;
|
|
|
|
if (ret == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
image_file_name_str->MaximumLength = image_file_name_str->Length = reply->filename_len;
|
|
|
|
image_file_name_str->Buffer = (PWSTR)(image_file_name_str + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
break;
|
2009-08-18 01:20:52 +02:00
|
|
|
case ProcessExecuteFlags:
|
2009-08-27 19:46:28 +02:00
|
|
|
len = sizeof(ULONG);
|
|
|
|
if (ProcessInformationLength == len)
|
2009-08-18 01:20:52 +02:00
|
|
|
*(ULONG *)ProcessInformation = execute_flags;
|
2009-08-27 19:46:28 +02:00
|
|
|
else
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
2009-08-18 01:20:52 +02:00
|
|
|
break;
|
2003-09-19 02:06:45 +02:00
|
|
|
default:
|
2006-10-16 13:49:06 +02:00
|
|
|
FIXME("(%p,info_class=%d,%p,0x%08x,%p) Unknown information class\n",
|
2003-09-19 02:06:45 +02:00
|
|
|
ProcessHandle,ProcessInformationClass,
|
|
|
|
ProcessInformation,ProcessInformationLength,
|
|
|
|
ReturnLength);
|
2005-06-14 14:25:02 +02:00
|
|
|
ret = STATUS_INVALID_INFO_CLASS;
|
2003-09-19 02:06:45 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ReturnLength) *ReturnLength = len;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtSetInformationProcess [NTDLL.@]
|
|
|
|
* ZwSetInformationProcess [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtSetInformationProcess(
|
|
|
|
IN HANDLE ProcessHandle,
|
|
|
|
IN PROCESSINFOCLASS ProcessInformationClass,
|
|
|
|
IN PVOID ProcessInformation,
|
|
|
|
IN ULONG ProcessInformationLength)
|
|
|
|
{
|
2005-09-06 12:25:11 +02:00
|
|
|
NTSTATUS ret = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
switch (ProcessInformationClass)
|
|
|
|
{
|
2010-04-22 18:33:28 +02:00
|
|
|
case ProcessDefaultHardErrorMode:
|
|
|
|
if (ProcessInformationLength != sizeof(UINT)) return STATUS_INVALID_PARAMETER;
|
|
|
|
process_error_mode = *(UINT *)ProcessInformation;
|
|
|
|
break;
|
2005-09-27 12:52:10 +02:00
|
|
|
case ProcessAffinityMask:
|
2015-01-21 13:24:14 +01:00
|
|
|
{
|
|
|
|
const ULONG_PTR system_mask = get_system_affinity_mask();
|
|
|
|
|
2005-09-27 12:52:10 +02:00
|
|
|
if (ProcessInformationLength != sizeof(DWORD_PTR)) return STATUS_INVALID_PARAMETER;
|
2015-01-21 13:24:14 +01:00
|
|
|
if (*(PDWORD_PTR)ProcessInformation & ~system_mask)
|
2008-01-16 21:02:04 +01:00
|
|
|
return STATUS_INVALID_PARAMETER;
|
2009-09-28 17:24:02 +02:00
|
|
|
if (!*(PDWORD_PTR)ProcessInformation)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
2005-09-27 12:52:10 +02:00
|
|
|
SERVER_START_REQ( set_process_info )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( ProcessHandle );
|
2005-09-27 12:52:10 +02:00
|
|
|
req->affinity = *(PDWORD_PTR)ProcessInformation;
|
|
|
|
req->mask = SET_PROCESS_INFO_AFFINITY;
|
|
|
|
ret = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
break;
|
2015-01-21 13:24:14 +01:00
|
|
|
}
|
2005-09-06 12:25:11 +02:00
|
|
|
case ProcessPriorityClass:
|
|
|
|
if (ProcessInformationLength != sizeof(PROCESS_PRIORITY_CLASS))
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PROCESS_PRIORITY_CLASS* ppc = ProcessInformation;
|
|
|
|
|
|
|
|
SERVER_START_REQ( set_process_info )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( ProcessHandle );
|
2005-09-06 12:25:11 +02:00
|
|
|
/* FIXME Foreground isn't used */
|
|
|
|
req->priority = ppc->PriorityClass;
|
|
|
|
req->mask = SET_PROCESS_INFO_PRIORITY;
|
|
|
|
ret = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
|
|
|
break;
|
2008-09-04 10:37:23 +02:00
|
|
|
|
|
|
|
case ProcessExecuteFlags:
|
|
|
|
if (ProcessInformationLength != sizeof(ULONG))
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
2009-08-18 01:20:54 +02:00
|
|
|
else if (execute_flags & MEM_EXECUTE_OPTION_PERMANENT)
|
|
|
|
return STATUS_ACCESS_DENIED;
|
2008-09-04 10:37:23 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
BOOL enable;
|
|
|
|
switch (*(ULONG *)ProcessInformation & (MEM_EXECUTE_OPTION_ENABLE|MEM_EXECUTE_OPTION_DISABLE))
|
|
|
|
{
|
|
|
|
case MEM_EXECUTE_OPTION_ENABLE:
|
2009-07-26 19:58:46 +02:00
|
|
|
enable = TRUE;
|
2008-09-04 10:37:23 +02:00
|
|
|
break;
|
|
|
|
case MEM_EXECUTE_OPTION_DISABLE:
|
2009-07-26 19:58:46 +02:00
|
|
|
enable = FALSE;
|
2008-09-04 10:37:23 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
}
|
2009-08-18 01:20:52 +02:00
|
|
|
execute_flags = *(ULONG *)ProcessInformation;
|
2008-09-04 10:37:23 +02:00
|
|
|
VIRTUAL_SetForceExec( enable );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-09-06 12:25:11 +02:00
|
|
|
default:
|
2006-10-16 13:49:06 +02:00
|
|
|
FIXME("(%p,0x%08x,%p,0x%08x) stub\n",
|
2005-09-06 12:25:11 +02:00
|
|
|
ProcessHandle,ProcessInformationClass,ProcessInformation,
|
|
|
|
ProcessInformationLength);
|
|
|
|
ret = STATUS_NOT_IMPLEMENTED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
2003-09-19 02:06:45 +02:00
|
|
|
}
|
2004-08-04 20:15:04 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtFlushInstructionCache [NTDLL.@]
|
|
|
|
* ZwFlushInstructionCache [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtFlushInstructionCache(
|
|
|
|
IN HANDLE ProcessHandle,
|
|
|
|
IN LPCVOID BaseAddress,
|
2005-07-15 12:01:30 +02:00
|
|
|
IN SIZE_T Size)
|
2004-08-04 20:15:04 +02:00
|
|
|
{
|
2013-12-13 00:34:10 +01:00
|
|
|
static int once;
|
|
|
|
if (!once++)
|
|
|
|
{
|
2013-12-16 20:28:36 +01:00
|
|
|
#if defined(__x86_64__) || defined(__i386__)
|
|
|
|
TRACE("%p %p %ld - no-op on x86 and x86_64\n", ProcessHandle, BaseAddress, Size );
|
2004-08-04 20:15:04 +02:00
|
|
|
#else
|
2013-12-13 00:34:10 +01:00
|
|
|
FIXME("%p %p %ld\n", ProcessHandle, BaseAddress, Size );
|
2004-08-04 20:15:04 +02:00
|
|
|
#endif
|
2013-12-13 00:34:10 +01:00
|
|
|
}
|
2004-08-04 20:15:04 +02:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2005-06-27 13:12:11 +02:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* NtOpenProcess [NTDLL.@]
|
|
|
|
* ZwOpenProcess [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtOpenProcess(PHANDLE handle, ACCESS_MASK access,
|
|
|
|
const OBJECT_ATTRIBUTES* attr, const CLIENT_ID* cid)
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
SERVER_START_REQ( open_process )
|
|
|
|
{
|
2007-05-23 09:36:29 +02:00
|
|
|
req->pid = HandleToULong(cid->UniqueProcess);
|
2005-12-09 12:13:11 +01:00
|
|
|
req->access = access;
|
|
|
|
req->attributes = attr ? attr->Attributes : 0;
|
2005-06-27 13:12:11 +02:00
|
|
|
status = wine_server_call( req );
|
2008-12-08 16:05:17 +01:00
|
|
|
if (!status) *handle = wine_server_ptr_handle( reply->handle );
|
2005-06-27 13:12:11 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return status;
|
|
|
|
}
|