2003-06-27 06:08:04 +02:00
|
|
|
/*
|
|
|
|
* Win32 processes
|
|
|
|
*
|
|
|
|
* Copyright 1996, 1998 Alexandre Julliard
|
|
|
|
*
|
|
|
|
* 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-06-27 06:08:04 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2003-09-17 07:31:32 +02:00
|
|
|
#include <assert.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <signal.h>
|
2009-12-30 23:36:56 +01:00
|
|
|
#include <stdarg.h>
|
2003-09-17 07:31:32 +02:00
|
|
|
#include <stdio.h>
|
2004-03-10 00:51:02 +01:00
|
|
|
#include <time.h>
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
2006-07-19 14:00:10 +02:00
|
|
|
#ifdef HAVE_SYS_IOCTL_H
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#endif
|
2004-03-10 00:51:02 +01:00
|
|
|
#include <sys/types.h>
|
2011-12-01 01:20:24 +01:00
|
|
|
#ifdef HAVE_SYS_WAIT_H
|
|
|
|
# include <sys/wait.h>
|
|
|
|
#endif
|
2011-09-06 12:11:46 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2003-09-17 07:31:32 +02:00
|
|
|
|
2005-11-28 17:32:54 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2005-06-06 22:13:08 +02:00
|
|
|
#include "winternl.h"
|
2019-07-01 17:44:38 +02:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "wincon.h"
|
2003-09-17 07:31:32 +02:00
|
|
|
#include "kernel_private.h"
|
2011-05-12 14:19:40 +02:00
|
|
|
#include "psapi.h"
|
2017-12-04 13:13:05 +01:00
|
|
|
#include "wine/exception.h"
|
2009-12-28 22:19:31 +01:00
|
|
|
#include "wine/library.h"
|
2003-06-27 06:08:04 +02:00
|
|
|
#include "wine/server.h"
|
2003-10-04 06:09:41 +02:00
|
|
|
#include "wine/unicode.h"
|
2019-05-14 12:30:46 +02:00
|
|
|
#include "wine/asm.h"
|
2003-06-27 06:08:04 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2003-09-17 07:31:32 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(process);
|
2006-07-31 21:25:29 +02:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(relay);
|
2003-09-17 07:31:32 +02:00
|
|
|
|
2003-11-17 21:16:38 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
LPSTR lpEnvAddress;
|
|
|
|
LPSTR lpCmdLine;
|
|
|
|
LPSTR lpCmdShow;
|
|
|
|
DWORD dwReserved;
|
|
|
|
} LOADPARMS32;
|
|
|
|
|
2004-02-12 01:00:55 +01:00
|
|
|
HMODULE kernel32_handle = 0;
|
2013-01-08 22:02:21 +01:00
|
|
|
SYSTEM_BASIC_INFORMATION system_info = { 0 };
|
2003-09-17 07:31:32 +02:00
|
|
|
|
2018-02-19 19:45:58 +01:00
|
|
|
const WCHAR DIR_Windows[] = {'C',':','\\','w','i','n','d','o','w','s',0};
|
|
|
|
const WCHAR DIR_System[] = {'C',':','\\','w','i','n','d','o','w','s',
|
|
|
|
'\\','s','y','s','t','e','m','3','2',0};
|
2004-05-14 23:43:18 +02:00
|
|
|
|
2003-09-17 07:31:32 +02:00
|
|
|
/* Process flags */
|
|
|
|
#define PDB32_DEBUGGED 0x0001 /* Process is being debugged */
|
|
|
|
#define PDB32_WIN16_PROC 0x0008 /* Win16 process */
|
|
|
|
#define PDB32_DOS_PROC 0x0010 /* Dos process */
|
|
|
|
#define PDB32_CONSOLE_PROC 0x0020 /* Console process */
|
|
|
|
#define PDB32_FILE_APIS_OEM 0x0040 /* File APIs are OEM */
|
|
|
|
#define PDB32_WIN32S_PROC 0x8000 /* Win32s process */
|
|
|
|
|
|
|
|
|
2010-05-28 11:20:28 +02:00
|
|
|
#ifdef __i386__
|
|
|
|
extern DWORD call_process_entry( PEB *peb, LPTHREAD_START_ROUTINE entry );
|
|
|
|
__ASM_GLOBAL_FUNC( call_process_entry,
|
|
|
|
"pushl %ebp\n\t"
|
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
|
|
|
|
__ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
|
|
|
|
"movl %esp,%ebp\n\t"
|
|
|
|
__ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
|
2018-07-08 21:19:56 +02:00
|
|
|
"pushl 4(%ebp)\n\t" /* deliberately mis-align the stack by 8, Doom 3 needs this */
|
|
|
|
"pushl 4(%ebp)\n\t" /* Driller expects readable address at this offset */
|
|
|
|
"pushl 4(%ebp)\n\t"
|
2010-05-28 11:20:28 +02:00
|
|
|
"pushl 8(%ebp)\n\t"
|
|
|
|
"call *12(%ebp)\n\t"
|
|
|
|
"leave\n\t"
|
|
|
|
__ASM_CFI(".cfi_def_cfa %esp,4\n\t")
|
|
|
|
__ASM_CFI(".cfi_same_value %ebp\n\t")
|
|
|
|
"ret" )
|
2017-12-04 13:13:05 +01:00
|
|
|
|
2019-12-10 11:08:40 +01:00
|
|
|
__ASM_GLOBAL_FUNC( __wine_start_process,
|
2017-12-04 13:13:05 +01:00
|
|
|
"pushl %ebp\n\t"
|
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
|
|
|
|
__ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
|
|
|
|
"movl %esp,%ebp\n\t"
|
|
|
|
__ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
|
|
|
|
"pushl %ebx\n\t" /* arg */
|
|
|
|
"pushl %eax\n\t" /* entry */
|
|
|
|
"call " __ASM_NAME("start_process") )
|
2010-05-28 11:20:28 +02:00
|
|
|
#else
|
|
|
|
static inline DWORD call_process_entry( PEB *peb, LPTHREAD_START_ROUTINE entry )
|
|
|
|
{
|
|
|
|
return entry( peb );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-09-17 07:31:32 +02:00
|
|
|
/***********************************************************************
|
2019-12-10 11:08:40 +01:00
|
|
|
* __wine_start_process
|
2003-09-17 07:31:32 +02:00
|
|
|
*
|
|
|
|
* Startup routine of a new process. Runs on the new process stack.
|
|
|
|
*/
|
2019-12-10 11:08:40 +01:00
|
|
|
#ifdef __i386__
|
|
|
|
void CDECL start_process( LPTHREAD_START_ROUTINE entry, PEB *peb )
|
|
|
|
#else
|
|
|
|
void CDECL __wine_start_process( LPTHREAD_START_ROUTINE entry, PEB *peb )
|
|
|
|
#endif
|
2003-09-17 07:31:32 +02:00
|
|
|
{
|
2017-02-10 17:21:32 +01:00
|
|
|
BOOL being_debugged;
|
2009-02-26 13:19:43 +01:00
|
|
|
|
2017-02-09 20:11:52 +01:00
|
|
|
if (!entry)
|
2003-09-17 07:31:32 +02:00
|
|
|
{
|
2009-08-29 11:07:17 +02:00
|
|
|
ERR( "%s doesn't have an entry point, it cannot be executed\n",
|
|
|
|
debugstr_w(peb->ProcessParameters->ImagePathName.Buffer) );
|
|
|
|
ExitThread( 1 );
|
2003-09-17 07:31:32 +02:00
|
|
|
}
|
2009-08-29 11:07:17 +02:00
|
|
|
|
2017-11-25 11:47:36 +01:00
|
|
|
TRACE_(relay)( "\1Starting process %s (entryproc=%p)\n",
|
|
|
|
debugstr_w(peb->ProcessParameters->ImagePathName.Buffer), entry );
|
2009-08-29 11:07:17 +02:00
|
|
|
|
2017-12-04 13:13:05 +01:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
if (!CheckRemoteDebuggerPresent( GetCurrentProcess(), &being_debugged ))
|
|
|
|
being_debugged = FALSE;
|
2017-02-10 17:21:32 +01:00
|
|
|
|
2017-12-04 13:13:05 +01:00
|
|
|
SetLastError( 0 ); /* clear error code */
|
|
|
|
if (being_debugged) DbgBreakPoint();
|
|
|
|
ExitThread( call_process_entry( peb, entry ));
|
|
|
|
}
|
|
|
|
__EXCEPT(UnhandledExceptionFilter)
|
|
|
|
{
|
2019-07-04 13:37:45 +02:00
|
|
|
TerminateProcess( GetCurrentProcess(), GetExceptionCode() );
|
2017-12-04 13:13:05 +01:00
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
abort(); /* should not be reached */
|
2003-09-17 07:31:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* wait_input_idle
|
|
|
|
*
|
|
|
|
* Wrapper to call WaitForInputIdle USER function
|
|
|
|
*/
|
|
|
|
typedef DWORD (WINAPI *WaitForInputIdle_ptr)( HANDLE hProcess, DWORD dwTimeOut );
|
|
|
|
|
|
|
|
static DWORD wait_input_idle( HANDLE process, DWORD timeout )
|
|
|
|
{
|
|
|
|
HMODULE mod = GetModuleHandleA( "user32.dll" );
|
|
|
|
if (mod)
|
|
|
|
{
|
|
|
|
WaitForInputIdle_ptr ptr = (WaitForInputIdle_ptr)GetProcAddress( mod, "WaitForInputIdle" );
|
|
|
|
if (ptr) return ptr( process, timeout );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WinExec (KERNEL32.@)
|
|
|
|
*/
|
2015-11-12 16:05:01 +01:00
|
|
|
UINT WINAPI DECLSPEC_HOTPATCH WinExec( LPCSTR lpCmdLine, UINT nCmdShow )
|
2003-09-17 07:31:32 +02:00
|
|
|
{
|
|
|
|
PROCESS_INFORMATION info;
|
|
|
|
STARTUPINFOA startup;
|
|
|
|
char *cmdline;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
memset( &startup, 0, sizeof(startup) );
|
|
|
|
startup.cb = sizeof(startup);
|
|
|
|
startup.dwFlags = STARTF_USESHOWWINDOW;
|
|
|
|
startup.wShowWindow = nCmdShow;
|
|
|
|
|
2006-12-04 19:55:35 +01:00
|
|
|
/* cmdline needs to be writable for CreateProcess */
|
2003-09-17 07:31:32 +02:00
|
|
|
if (!(cmdline = HeapAlloc( GetProcessHeap(), 0, strlen(lpCmdLine)+1 ))) return 0;
|
|
|
|
strcpy( cmdline, lpCmdLine );
|
|
|
|
|
|
|
|
if (CreateProcessA( NULL, cmdline, NULL, NULL, FALSE,
|
|
|
|
0, NULL, NULL, &startup, &info ))
|
|
|
|
{
|
|
|
|
/* Give 30 seconds to the app to come up */
|
2003-10-16 21:31:11 +02:00
|
|
|
if (wait_input_idle( info.hProcess, 30000 ) == WAIT_FAILED)
|
2006-10-12 22:56:29 +02:00
|
|
|
WARN("WaitForInputIdle failed: Error %d\n", GetLastError() );
|
2003-09-17 07:31:32 +02:00
|
|
|
ret = 33;
|
|
|
|
/* Close off the handles */
|
|
|
|
CloseHandle( info.hThread );
|
|
|
|
CloseHandle( info.hProcess );
|
|
|
|
}
|
|
|
|
else if ((ret = GetLastError()) >= 32)
|
|
|
|
{
|
|
|
|
FIXME("Strange error set by CreateProcess: %d\n", ret );
|
|
|
|
ret = 11;
|
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, cmdline );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* LoadModule (KERNEL32.@)
|
|
|
|
*/
|
2010-10-11 12:16:51 +02:00
|
|
|
DWORD WINAPI LoadModule( LPCSTR name, LPVOID paramBlock )
|
2003-09-17 07:31:32 +02:00
|
|
|
{
|
2003-11-17 21:16:38 +01:00
|
|
|
LOADPARMS32 *params = paramBlock;
|
2003-09-17 07:31:32 +02:00
|
|
|
PROCESS_INFORMATION info;
|
|
|
|
STARTUPINFOA startup;
|
2010-10-11 12:16:51 +02:00
|
|
|
DWORD ret;
|
2003-09-17 07:31:32 +02:00
|
|
|
LPSTR cmdline, p;
|
|
|
|
char filename[MAX_PATH];
|
|
|
|
BYTE len;
|
|
|
|
|
2010-10-11 12:16:51 +02:00
|
|
|
if (!name) return ERROR_FILE_NOT_FOUND;
|
2003-09-17 07:31:32 +02:00
|
|
|
|
|
|
|
if (!SearchPathA( NULL, name, ".exe", sizeof(filename), filename, NULL ) &&
|
|
|
|
!SearchPathA( NULL, name, NULL, sizeof(filename), filename, NULL ))
|
2010-10-11 12:16:51 +02:00
|
|
|
return GetLastError();
|
2003-09-17 07:31:32 +02:00
|
|
|
|
|
|
|
len = (BYTE)params->lpCmdLine[0];
|
|
|
|
if (!(cmdline = HeapAlloc( GetProcessHeap(), 0, strlen(filename) + len + 2 )))
|
2010-10-11 12:16:51 +02:00
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
2003-09-17 07:31:32 +02:00
|
|
|
|
|
|
|
strcpy( cmdline, filename );
|
|
|
|
p = cmdline + strlen(cmdline);
|
|
|
|
*p++ = ' ';
|
|
|
|
memcpy( p, params->lpCmdLine + 1, len );
|
|
|
|
p[len] = 0;
|
|
|
|
|
|
|
|
memset( &startup, 0, sizeof(startup) );
|
|
|
|
startup.cb = sizeof(startup);
|
|
|
|
if (params->lpCmdShow)
|
|
|
|
{
|
|
|
|
startup.dwFlags = STARTF_USESHOWWINDOW;
|
2003-11-17 21:16:38 +01:00
|
|
|
startup.wShowWindow = ((WORD *)params->lpCmdShow)[1];
|
2003-09-17 07:31:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (CreateProcessA( filename, cmdline, NULL, NULL, FALSE, 0,
|
|
|
|
params->lpEnvAddress, NULL, &startup, &info ))
|
|
|
|
{
|
|
|
|
/* Give 30 seconds to the app to come up */
|
2003-10-16 21:31:11 +02:00
|
|
|
if (wait_input_idle( info.hProcess, 30000 ) == WAIT_FAILED)
|
2006-10-12 22:56:29 +02:00
|
|
|
WARN("WaitForInputIdle failed: Error %d\n", GetLastError() );
|
2010-10-11 12:16:51 +02:00
|
|
|
ret = 33;
|
2003-09-17 07:31:32 +02:00
|
|
|
/* Close off the handles */
|
|
|
|
CloseHandle( info.hThread );
|
|
|
|
CloseHandle( info.hProcess );
|
|
|
|
}
|
2010-10-11 12:16:51 +02:00
|
|
|
else if ((ret = GetLastError()) >= 32)
|
2003-09-17 07:31:32 +02:00
|
|
|
{
|
2010-10-11 12:16:51 +02:00
|
|
|
FIXME("Strange error set by CreateProcess: %u\n", ret );
|
|
|
|
ret = 11;
|
2003-09-17 07:31:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, cmdline );
|
2010-10-11 12:16:51 +02:00
|
|
|
return ret;
|
2003-09-17 07:31:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-08 05:57:02 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ExitProcess (KERNEL32.@)
|
2006-03-31 13:33:04 +02:00
|
|
|
*
|
|
|
|
* Exits the current process.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* status [I] Status code to exit with.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
2003-10-08 05:57:02 +02:00
|
|
|
*/
|
2008-10-07 18:16:19 +02:00
|
|
|
#ifdef __i386__
|
2009-06-14 15:34:09 +02:00
|
|
|
__ASM_STDCALL_FUNC( ExitProcess, 4, /* Shrinker depend on this particular ExitProcess implementation */
|
2008-10-07 18:16:19 +02:00
|
|
|
"pushl %ebp\n\t"
|
|
|
|
".byte 0x8B, 0xEC\n\t" /* movl %esp, %ebp */
|
|
|
|
".byte 0x6A, 0x00\n\t" /* pushl $0 */
|
|
|
|
".byte 0x68, 0x00, 0x00, 0x00, 0x00\n\t" /* pushl $0 - 4 bytes immediate */
|
|
|
|
"pushl 8(%ebp)\n\t"
|
2019-05-16 18:13:45 +02:00
|
|
|
"call " __ASM_STDCALL("RtlExitUserProcess",4) "\n\t"
|
2008-10-07 18:16:19 +02:00
|
|
|
"leave\n\t"
|
|
|
|
"ret $4" )
|
|
|
|
#else
|
|
|
|
|
2003-10-08 05:57:02 +02:00
|
|
|
void WINAPI ExitProcess( DWORD status )
|
|
|
|
{
|
2013-07-19 12:15:15 +02:00
|
|
|
RtlExitUserProcess( status );
|
2003-10-08 05:57:02 +02:00
|
|
|
}
|
|
|
|
|
2008-10-07 18:16:19 +02:00
|
|
|
#endif
|
2003-10-08 05:57:02 +02:00
|
|
|
|
2003-09-17 07:31:32 +02:00
|
|
|
/***********************************************************************
|
2005-12-21 20:44:49 +01:00
|
|
|
* GetExitCodeProcess [KERNEL32.@]
|
2003-09-17 07:31:32 +02:00
|
|
|
*
|
2005-12-21 20:44:49 +01:00
|
|
|
* Gets termination status of specified process.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hProcess [in] Handle to the process.
|
|
|
|
* lpExitCode [out] Address to receive termination status.
|
2003-09-17 07:31:32 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
2005-12-21 20:44:49 +01:00
|
|
|
BOOL WINAPI GetExitCodeProcess( HANDLE hProcess, LPDWORD lpExitCode )
|
2003-09-17 07:31:32 +02:00
|
|
|
{
|
2004-06-14 19:02:00 +02:00
|
|
|
PROCESS_BASIC_INFORMATION pbi;
|
|
|
|
|
2019-10-01 09:36:16 +02:00
|
|
|
if (!set_ntstatus( NtQueryInformationProcess( hProcess, ProcessBasicInformation, &pbi, sizeof(pbi), NULL )))
|
|
|
|
return FALSE;
|
|
|
|
if (lpExitCode) *lpExitCode = pbi.ExitStatus;
|
|
|
|
return TRUE;
|
2003-09-17 07:31:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-08 22:30:38 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* FatalExit (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
void WINAPI FatalExit( int code )
|
|
|
|
{
|
|
|
|
WARN( "FatalExit\n" );
|
|
|
|
ExitProcess( code );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-27 06:08:04 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetProcessFlags (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetProcessFlags( DWORD processid )
|
|
|
|
{
|
|
|
|
IMAGE_NT_HEADERS *nt;
|
|
|
|
DWORD flags = 0;
|
|
|
|
|
|
|
|
if (processid && processid != GetCurrentProcessId()) return 0;
|
|
|
|
|
|
|
|
if ((nt = RtlImageNtHeader( NtCurrentTeb()->Peb->ImageBaseAddress )))
|
|
|
|
{
|
|
|
|
if (nt->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI)
|
|
|
|
flags |= PDB32_CONSOLE_PROC;
|
|
|
|
}
|
|
|
|
if (!AreFileApisANSI()) flags |= PDB32_FILE_APIS_OEM;
|
|
|
|
if (IsDebuggerPresent()) flags |= PDB32_DEBUGGED;
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-08 06:24:49 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ConvertToGlobalHandle (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
|
|
|
|
{
|
|
|
|
HANDLE ret = INVALID_HANDLE_VALUE;
|
|
|
|
DuplicateHandle( GetCurrentProcess(), hSrc, GetCurrentProcess(), &ret, 0, FALSE,
|
|
|
|
DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetHandleContext (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetHandleContext(HANDLE hnd,DWORD context)
|
|
|
|
{
|
2006-10-12 22:56:29 +02:00
|
|
|
FIXME("(%p,%d), stub. In case this got called by WSOCK32/WS2_32: "
|
2003-10-08 06:24:49 +02:00
|
|
|
"the external WINSOCK DLLs won't work with WINE, don't use them.\n",hnd,context);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetHandleContext (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetHandleContext(HANDLE hnd)
|
|
|
|
{
|
|
|
|
FIXME("(%p), stub. In case this got called by WSOCK32/WS2_32: "
|
|
|
|
"the external WINSOCK DLLs won't work with WINE, don't use them.\n",hnd);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CreateSocketHandle (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateSocketHandle(void)
|
|
|
|
{
|
|
|
|
FIXME("(), stub. In case this got called by WSOCK32/WS2_32: "
|
|
|
|
"the external WINSOCK DLLs won't work with WINE, don't use them.\n");
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-27 06:08:04 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetProcessAffinityMask (KERNEL32.@)
|
|
|
|
*/
|
2004-10-20 01:55:15 +02:00
|
|
|
BOOL WINAPI SetProcessAffinityMask( HANDLE hProcess, DWORD_PTR affmask )
|
2003-06-27 06:08:04 +02:00
|
|
|
{
|
2019-10-01 09:36:16 +02:00
|
|
|
return set_ntstatus( NtSetInformationProcess( hProcess, ProcessAffinityMask,
|
|
|
|
&affmask, sizeof(DWORD_PTR) ));
|
2003-06-27 06:08:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetProcessAffinityMask (KERNEL32.@)
|
|
|
|
*/
|
2011-04-14 19:57:34 +02:00
|
|
|
BOOL WINAPI GetProcessAffinityMask( HANDLE hProcess, PDWORD_PTR process_mask, PDWORD_PTR system_mask )
|
2003-06-27 06:08:04 +02:00
|
|
|
{
|
2011-04-14 19:57:34 +02:00
|
|
|
if (process_mask)
|
2003-06-27 06:08:04 +02:00
|
|
|
{
|
2019-10-01 09:36:16 +02:00
|
|
|
if (!set_ntstatus( NtQueryInformationProcess( hProcess, ProcessAffinityMask,
|
|
|
|
process_mask, sizeof(*process_mask), NULL )))
|
|
|
|
return FALSE;
|
2003-06-27 06:08:04 +02:00
|
|
|
}
|
2019-10-01 09:36:16 +02:00
|
|
|
if (system_mask)
|
2015-01-21 13:23:36 +01:00
|
|
|
{
|
|
|
|
SYSTEM_BASIC_INFORMATION info;
|
|
|
|
|
2019-10-01 09:36:16 +02:00
|
|
|
if (!set_ntstatus( NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )))
|
|
|
|
return FALSE;
|
|
|
|
*system_mask = info.ActiveProcessorsAffinityMask;
|
2015-01-21 13:23:36 +01:00
|
|
|
}
|
2019-10-01 09:36:16 +02:00
|
|
|
return TRUE;
|
2003-06-27 06:08:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetProcessVersion (KERNEL32.@)
|
|
|
|
*/
|
2008-10-15 16:44:54 +02:00
|
|
|
DWORD WINAPI GetProcessVersion( DWORD pid )
|
2003-06-27 06:08:04 +02:00
|
|
|
{
|
2008-10-15 16:44:54 +02:00
|
|
|
HANDLE process;
|
|
|
|
NTSTATUS status;
|
|
|
|
PROCESS_BASIC_INFORMATION pbi;
|
|
|
|
SIZE_T count;
|
|
|
|
PEB peb;
|
|
|
|
IMAGE_DOS_HEADER dos;
|
|
|
|
IMAGE_NT_HEADERS nt;
|
|
|
|
DWORD ver = 0;
|
2003-06-27 06:08:04 +02:00
|
|
|
|
2008-10-15 16:44:54 +02:00
|
|
|
if (!pid || pid == GetCurrentProcessId())
|
2003-06-27 06:08:04 +02:00
|
|
|
{
|
2011-10-21 08:19:17 +02:00
|
|
|
IMAGE_NT_HEADERS *pnt;
|
2008-10-15 16:44:54 +02:00
|
|
|
|
2011-10-21 08:19:17 +02:00
|
|
|
if ((pnt = RtlImageNtHeader( NtCurrentTeb()->Peb->ImageBaseAddress )))
|
|
|
|
return ((pnt->OptionalHeader.MajorSubsystemVersion << 16) |
|
|
|
|
pnt->OptionalHeader.MinorSubsystemVersion);
|
2003-06-27 06:08:04 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2008-10-15 16:44:54 +02:00
|
|
|
|
|
|
|
process = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, FALSE, pid);
|
|
|
|
if (!process) return 0;
|
|
|
|
|
|
|
|
status = NtQueryInformationProcess(process, ProcessBasicInformation, &pbi, sizeof(pbi), NULL);
|
|
|
|
if (status) goto err;
|
|
|
|
|
|
|
|
status = NtReadVirtualMemory(process, pbi.PebBaseAddress, &peb, sizeof(peb), &count);
|
|
|
|
if (status || count != sizeof(peb)) goto err;
|
|
|
|
|
|
|
|
memset(&dos, 0, sizeof(dos));
|
|
|
|
status = NtReadVirtualMemory(process, peb.ImageBaseAddress, &dos, sizeof(dos), &count);
|
|
|
|
if (status || count != sizeof(dos)) goto err;
|
|
|
|
if (dos.e_magic != IMAGE_DOS_SIGNATURE) goto err;
|
|
|
|
|
|
|
|
memset(&nt, 0, sizeof(nt));
|
|
|
|
status = NtReadVirtualMemory(process, (char *)peb.ImageBaseAddress + dos.e_lfanew, &nt, sizeof(nt), &count);
|
|
|
|
if (status || count != sizeof(nt)) goto err;
|
|
|
|
if (nt.Signature != IMAGE_NT_SIGNATURE) goto err;
|
|
|
|
|
|
|
|
ver = MAKELONG(nt.OptionalHeader.MinorSubsystemVersion, nt.OptionalHeader.MajorSubsystemVersion);
|
|
|
|
|
|
|
|
err:
|
|
|
|
CloseHandle(process);
|
|
|
|
|
|
|
|
if (status != STATUS_SUCCESS)
|
|
|
|
SetLastError(RtlNtStatusToDosError(status));
|
|
|
|
|
|
|
|
return ver;
|
2003-06-27 06:08:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-16 16:59:21 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SetProcessWorkingSetSize [KERNEL32.@]
|
|
|
|
* Sets the min/max working set sizes for a specified process.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* process [I] Handle to the process of interest
|
|
|
|
* minset [I] Specifies minimum working set size
|
|
|
|
* maxset [I] Specifies maximum working set size
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetProcessWorkingSetSize(HANDLE process, SIZE_T minset, SIZE_T maxset)
|
|
|
|
{
|
|
|
|
return SetProcessWorkingSetSizeEx(process, minset, maxset, 0);
|
|
|
|
}
|
|
|
|
|
2011-04-19 14:21:08 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* K32EmptyWorkingSet (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI K32EmptyWorkingSet(HANDLE hProcess)
|
|
|
|
{
|
|
|
|
return SetProcessWorkingSetSize(hProcess, (SIZE_T)-1, (SIZE_T)-1);
|
|
|
|
}
|
|
|
|
|
2017-09-13 07:10:49 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetProcessWorkingSetSize (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetProcessWorkingSetSize(HANDLE process, SIZE_T *minset, SIZE_T *maxset)
|
|
|
|
{
|
|
|
|
return GetProcessWorkingSetSizeEx(process, minset, maxset, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-19 02:06:45 +02:00
|
|
|
/******************************************************************
|
|
|
|
* GetProcessIoCounters (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetProcessIoCounters(HANDLE hProcess, PIO_COUNTERS ioc)
|
|
|
|
{
|
2019-10-01 09:36:16 +02:00
|
|
|
return set_ntstatus( NtQueryInformationProcess(hProcess, ProcessIoCounters, ioc, sizeof(*ioc), NULL ));
|
2007-11-01 07:46:54 +01:00
|
|
|
}
|
|
|
|
|
2009-06-10 20:39:42 +02:00
|
|
|
/******************************************************************
|
|
|
|
* QueryFullProcessImageNameA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI QueryFullProcessImageNameA(HANDLE hProcess, DWORD dwFlags, LPSTR lpExeName, PDWORD pdwSize)
|
|
|
|
{
|
|
|
|
BOOL retval;
|
|
|
|
DWORD pdwSizeW = *pdwSize;
|
|
|
|
LPWSTR lpExeNameW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *pdwSize * sizeof(WCHAR));
|
|
|
|
|
|
|
|
retval = QueryFullProcessImageNameW(hProcess, dwFlags, lpExeNameW, &pdwSizeW);
|
|
|
|
|
|
|
|
if(retval)
|
|
|
|
retval = (0 != WideCharToMultiByte(CP_ACP, 0, lpExeNameW, -1,
|
|
|
|
lpExeName, *pdwSize, NULL, NULL));
|
|
|
|
if(retval)
|
|
|
|
*pdwSize = strlen(lpExeName);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpExeNameW);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2009-03-29 23:36:33 +02:00
|
|
|
/******************************************************************
|
|
|
|
* QueryFullProcessImageNameW (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI QueryFullProcessImageNameW(HANDLE hProcess, DWORD dwFlags, LPWSTR lpExeName, PDWORD pdwSize)
|
|
|
|
{
|
|
|
|
BYTE buffer[sizeof(UNICODE_STRING) + MAX_PATH*sizeof(WCHAR)]; /* this buffer should be enough */
|
|
|
|
UNICODE_STRING *dynamic_buffer = NULL;
|
|
|
|
UNICODE_STRING *result = NULL;
|
|
|
|
NTSTATUS status;
|
|
|
|
DWORD needed;
|
|
|
|
|
2011-10-03 23:56:12 +02:00
|
|
|
/* FIXME: On Windows, ProcessImageFileName return an NT path. In Wine it
|
|
|
|
* is a DOS path and we depend on this. */
|
2009-04-22 16:54:16 +02:00
|
|
|
status = NtQueryInformationProcess(hProcess, ProcessImageFileName, buffer,
|
|
|
|
sizeof(buffer) - sizeof(WCHAR), &needed);
|
2009-03-29 23:36:33 +02:00
|
|
|
if (status == STATUS_INFO_LENGTH_MISMATCH)
|
|
|
|
{
|
2009-04-22 16:54:16 +02:00
|
|
|
dynamic_buffer = HeapAlloc(GetProcessHeap(), 0, needed + sizeof(WCHAR));
|
2009-03-29 23:36:33 +02:00
|
|
|
status = NtQueryInformationProcess(hProcess, ProcessImageFileName, (LPBYTE)dynamic_buffer, needed, &needed);
|
|
|
|
result = dynamic_buffer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
result = (PUNICODE_STRING)buffer;
|
|
|
|
|
|
|
|
if (status) goto cleanup;
|
|
|
|
|
|
|
|
if (dwFlags & PROCESS_NAME_NATIVE)
|
|
|
|
{
|
2011-10-03 23:56:12 +02:00
|
|
|
WCHAR drive[3];
|
|
|
|
WCHAR device[1024];
|
|
|
|
DWORD ntlen, devlen;
|
|
|
|
|
|
|
|
if (result->Buffer[1] != ':' || result->Buffer[0] < 'A' || result->Buffer[0] > 'Z')
|
2009-03-29 23:36:33 +02:00
|
|
|
{
|
2011-10-03 23:56:12 +02:00
|
|
|
/* We cannot convert it to an NT device path so fail */
|
|
|
|
status = STATUS_NO_SUCH_DEVICE;
|
2009-03-29 23:36:33 +02:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-10-03 23:56:12 +02:00
|
|
|
/* Find this drive's NT device path */
|
|
|
|
drive[0] = result->Buffer[0];
|
|
|
|
drive[1] = ':';
|
|
|
|
drive[2] = 0;
|
2018-07-30 21:18:09 +02:00
|
|
|
if (!QueryDosDeviceW(drive, device, ARRAY_SIZE(device)))
|
2011-10-03 23:56:12 +02:00
|
|
|
{
|
|
|
|
status = STATUS_NO_SUCH_DEVICE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
devlen = lstrlenW(device);
|
|
|
|
ntlen = devlen + (result->Length/sizeof(WCHAR) - 2);
|
|
|
|
if (ntlen + 1 > *pdwSize)
|
|
|
|
{
|
2015-03-17 06:34:03 +01:00
|
|
|
status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
goto cleanup;
|
2011-10-03 23:56:12 +02:00
|
|
|
}
|
|
|
|
*pdwSize = ntlen;
|
|
|
|
|
|
|
|
memcpy(lpExeName, device, devlen * sizeof(*device));
|
|
|
|
memcpy(lpExeName + devlen, result->Buffer + 2, result->Length - 2 * sizeof(WCHAR));
|
|
|
|
lpExeName[*pdwSize] = 0;
|
|
|
|
TRACE("NT path: %s\n", debugstr_w(lpExeName));
|
2009-03-29 23:36:33 +02:00
|
|
|
}
|
2011-10-03 23:56:12 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (result->Length/sizeof(WCHAR) + 1 > *pdwSize)
|
|
|
|
{
|
|
|
|
status = STATUS_BUFFER_TOO_SMALL;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2009-03-29 23:36:33 +02:00
|
|
|
|
2011-10-03 23:56:12 +02:00
|
|
|
*pdwSize = result->Length/sizeof(WCHAR);
|
|
|
|
memcpy( lpExeName, result->Buffer, result->Length );
|
|
|
|
lpExeName[*pdwSize] = 0;
|
|
|
|
}
|
2009-03-29 23:36:33 +02:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
HeapFree(GetProcessHeap(), 0, dynamic_buffer);
|
2019-10-01 09:36:16 +02:00
|
|
|
return set_ntstatus( status );
|
2009-03-29 23:36:33 +02:00
|
|
|
}
|
|
|
|
|
2011-04-08 14:17:45 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* K32GetProcessImageFileNameA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI K32GetProcessImageFileNameA( HANDLE process, LPSTR file, DWORD size )
|
|
|
|
{
|
2011-08-05 09:56:26 +02:00
|
|
|
return QueryFullProcessImageNameA(process, PROCESS_NAME_NATIVE, file, &size) ? size : 0;
|
2011-04-08 14:17:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* K32GetProcessImageFileNameW (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI K32GetProcessImageFileNameW( HANDLE process, LPWSTR file, DWORD size )
|
|
|
|
{
|
|
|
|
return QueryFullProcessImageNameW(process, PROCESS_NAME_NATIVE, file, &size) ? size : 0;
|
|
|
|
}
|
|
|
|
|
2011-05-03 23:08:42 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* K32EnumProcesses (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI K32EnumProcesses(DWORD *lpdwProcessIDs, DWORD cb, DWORD *lpcbUsed)
|
|
|
|
{
|
|
|
|
SYSTEM_PROCESS_INFORMATION *spi;
|
|
|
|
ULONG size = 0x4000;
|
|
|
|
void *buf = NULL;
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
do {
|
|
|
|
size *= 2;
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
buf = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
if (!buf)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
status = NtQuerySystemInformation(SystemProcessInformation, buf, size, NULL);
|
|
|
|
} while(status == STATUS_INFO_LENGTH_MISMATCH);
|
|
|
|
|
2019-10-01 09:36:16 +02:00
|
|
|
if (!set_ntstatus( status ))
|
2011-05-03 23:08:42 +02:00
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
spi = buf;
|
|
|
|
|
|
|
|
for (*lpcbUsed = 0; cb >= sizeof(DWORD); cb -= sizeof(DWORD))
|
|
|
|
{
|
|
|
|
*lpdwProcessIDs++ = HandleToUlong(spi->UniqueProcessId);
|
|
|
|
*lpcbUsed += sizeof(DWORD);
|
|
|
|
|
|
|
|
if (spi->NextEntryOffset == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
spi = (SYSTEM_PROCESS_INFORMATION *)(((PCHAR)spi) + spi->NextEntryOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-05-11 15:06:45 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* K32QueryWorkingSet (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI K32QueryWorkingSet( HANDLE process, LPVOID buffer, DWORD size )
|
|
|
|
{
|
|
|
|
TRACE( "(%p, %p, %d)\n", process, buffer, size );
|
|
|
|
|
2019-10-01 09:36:16 +02:00
|
|
|
return set_ntstatus( NtQueryVirtualMemory( process, NULL, MemoryWorkingSetList, buffer, size, NULL ));
|
2011-05-11 15:06:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* K32QueryWorkingSetEx (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI K32QueryWorkingSetEx( HANDLE process, LPVOID buffer, DWORD size )
|
|
|
|
{
|
|
|
|
TRACE( "(%p, %p, %d)\n", process, buffer, size );
|
|
|
|
|
2020-01-24 21:19:39 +01:00
|
|
|
return set_ntstatus( NtQueryVirtualMemory( process, NULL, MemoryWorkingSetExInformation, buffer, size, NULL ));
|
2011-05-11 15:06:45 +02:00
|
|
|
}
|
|
|
|
|
2011-05-12 14:19:40 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* K32GetProcessMemoryInfo (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Retrieve memory usage information for a given process
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI K32GetProcessMemoryInfo(HANDLE process,
|
|
|
|
PPROCESS_MEMORY_COUNTERS pmc, DWORD cb)
|
|
|
|
{
|
|
|
|
VM_COUNTERS vmc;
|
|
|
|
|
|
|
|
if (cb < sizeof(PROCESS_MEMORY_COUNTERS))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-10-01 09:36:16 +02:00
|
|
|
if (!set_ntstatus( NtQueryInformationProcess( process, ProcessVmCounters, &vmc, sizeof(vmc), NULL )))
|
2011-05-12 14:19:40 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
pmc->cb = sizeof(PROCESS_MEMORY_COUNTERS);
|
|
|
|
pmc->PageFaultCount = vmc.PageFaultCount;
|
|
|
|
pmc->PeakWorkingSetSize = vmc.PeakWorkingSetSize;
|
|
|
|
pmc->WorkingSetSize = vmc.WorkingSetSize;
|
|
|
|
pmc->QuotaPeakPagedPoolUsage = vmc.QuotaPeakPagedPoolUsage;
|
|
|
|
pmc->QuotaPagedPoolUsage = vmc.QuotaPagedPoolUsage;
|
|
|
|
pmc->QuotaPeakNonPagedPoolUsage = vmc.QuotaPeakNonPagedPoolUsage;
|
|
|
|
pmc->QuotaNonPagedPoolUsage = vmc.QuotaNonPagedPoolUsage;
|
|
|
|
pmc->PagefileUsage = vmc.PagefileUsage;
|
|
|
|
pmc->PeakPagefileUsage = vmc.PeakPagefileUsage;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-09-17 07:31:32 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ProcessIdToSessionId (KERNEL32.@)
|
|
|
|
* This function is available on Terminal Server 4SP4 and Windows 2000
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ProcessIdToSessionId( DWORD procid, DWORD *sessionid_ptr )
|
|
|
|
{
|
2015-10-08 14:20:05 +02:00
|
|
|
if (procid != GetCurrentProcessId())
|
|
|
|
FIXME("Unsupported for other processes.\n");
|
|
|
|
|
|
|
|
*sessionid_ptr = NtCurrentTeb()->Peb->SessionId;
|
2003-09-17 07:31:32 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-27 06:08:04 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* RegisterServiceProcess (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* A service process calls this function to ensure that it continues to run
|
|
|
|
* even after a user logged off.
|
|
|
|
*/
|
|
|
|
DWORD WINAPI RegisterServiceProcess(DWORD dwProcessId, DWORD dwType)
|
|
|
|
{
|
2004-12-15 11:48:18 +01:00
|
|
|
/* I don't think that Wine needs to do anything in this function */
|
2003-06-27 06:08:04 +02:00
|
|
|
return 1; /* success */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetCurrentProcess (KERNEL32.@)
|
2004-12-15 11:48:18 +01:00
|
|
|
*
|
|
|
|
* Get a handle to the current process.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* A handle representing the current process.
|
2003-06-27 06:08:04 +02:00
|
|
|
*/
|
2019-06-26 12:41:22 +02:00
|
|
|
HANDLE WINAPI KERNEL32_GetCurrentProcess(void)
|
2003-06-27 06:08:04 +02:00
|
|
|
{
|
2008-12-08 15:51:22 +01:00
|
|
|
return (HANDLE)~(ULONG_PTR)0;
|
2003-06-27 06:08:04 +02:00
|
|
|
}
|
2006-02-22 12:54:16 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CmdBatNotification (KERNEL32.@)
|
|
|
|
*
|
2006-03-31 13:33:04 +02:00
|
|
|
* Notifies the system that a batch file has started or finished.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* bBatchRunning [I] TRUE if a batch file has started or
|
|
|
|
* FALSE if a batch file has finished executing.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Unknown.
|
2006-02-22 12:54:16 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI CmdBatNotification( BOOL bBatchRunning )
|
|
|
|
{
|
|
|
|
FIXME("%d\n", bBatchRunning);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-01-30 03:37:17 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RegisterApplicationRestart (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI RegisterApplicationRestart(PCWSTR pwzCommandLine, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("(%s,%d)\n", debugstr_w(pwzCommandLine), dwFlags);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2009-07-16 05:00:13 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* WTSGetActiveConsoleSessionId (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI WTSGetActiveConsoleSessionId(void)
|
|
|
|
{
|
2014-01-28 00:57:59 +01:00
|
|
|
static int once;
|
|
|
|
if (!once++) FIXME("stub\n");
|
2015-10-08 14:20:50 +02:00
|
|
|
/* Return current session id. */
|
|
|
|
return NtCurrentTeb()->Peb->SessionId;
|
2009-07-16 05:00:13 +02:00
|
|
|
}
|
2010-09-22 06:17:29 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetSystemDEPPolicy (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
DEP_SYSTEM_POLICY_TYPE WINAPI GetSystemDEPPolicy(void)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return OptIn;
|
|
|
|
}
|
2011-05-22 01:31:58 +02:00
|
|
|
|
2010-11-05 14:10:04 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* SetProcessDEPPolicy (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetProcessDEPPolicy(DWORD newDEP)
|
|
|
|
{
|
|
|
|
FIXME("(%d): stub\n", newDEP);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-05-22 01:31:58 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* ApplicationRecoveryFinished (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI ApplicationRecoveryFinished(BOOL success)
|
|
|
|
{
|
|
|
|
FIXME(": stub\n");
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
}
|
2011-05-22 01:35:01 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* ApplicationRecoveryInProgress (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI ApplicationRecoveryInProgress(PBOOL canceled)
|
|
|
|
{
|
|
|
|
FIXME(":%p stub\n", canceled);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2011-05-22 23:18:06 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* RegisterApplicationRecoveryCallback (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI RegisterApplicationRecoveryCallback(APPLICATION_RECOVERY_CALLBACK callback, PVOID param, DWORD pingint, DWORD flags)
|
|
|
|
{
|
2019-12-09 17:32:54 +01:00
|
|
|
FIXME("%p, %p, %d, %d: stub, faking success\n", callback, param, pingint, flags);
|
|
|
|
return S_OK;
|
2011-05-22 23:18:06 +02:00
|
|
|
}
|
2011-06-23 11:09:57 +02:00
|
|
|
|
2018-08-27 18:26:29 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetApplicationRestartSettings (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI GetApplicationRestartSettings(HANDLE process, WCHAR *cmdline, DWORD *size, DWORD *flags)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p, %p, %p)\n", process, cmdline, size, flags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-06-23 11:09:57 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* GetNumaNodeProcessorMask (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetNumaNodeProcessorMask(UCHAR node, PULONGLONG mask)
|
|
|
|
{
|
|
|
|
FIXME("(%c %p): stub\n", node, mask);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetNumaAvailableMemoryNode (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetNumaAvailableMemoryNode(UCHAR node, PULONGLONG available_bytes)
|
|
|
|
{
|
|
|
|
FIXME("(%c %p): stub\n", node, available_bytes);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-10-20 00:59:05 +02:00
|
|
|
|
2019-05-08 22:34:08 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* GetNumaAvailableMemoryNodeEx (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetNumaAvailableMemoryNodeEx(USHORT node, PULONGLONG available_bytes)
|
|
|
|
{
|
|
|
|
FIXME("(%hu %p): stub\n", node, available_bytes);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-06-29 06:27:34 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetNumaProcessorNode (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetNumaProcessorNode(UCHAR processor, PUCHAR node)
|
|
|
|
{
|
|
|
|
SYSTEM_INFO si;
|
|
|
|
|
|
|
|
TRACE("(%d, %p)\n", processor, node);
|
|
|
|
|
|
|
|
GetSystemInfo( &si );
|
|
|
|
if (processor < si.dwNumberOfProcessors)
|
|
|
|
{
|
|
|
|
*node = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*node = 0xFF;
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-05-08 22:34:08 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetNumaProcessorNodeEx (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetNumaProcessorNodeEx(PPROCESSOR_NUMBER processor, PUSHORT node_number)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetNumaProximityNode (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetNumaProximityNode(ULONG proximity_id, PUCHAR node_number)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-10-20 00:59:05 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* GetProcessDEPPolicy (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetProcessDEPPolicy(HANDLE process, LPDWORD flags, PBOOL permanent)
|
|
|
|
{
|
2014-10-21 07:46:10 +02:00
|
|
|
ULONG dep_flags;
|
|
|
|
|
|
|
|
TRACE("(%p %p %p)\n", process, flags, permanent);
|
|
|
|
|
2019-10-01 09:36:16 +02:00
|
|
|
if (!set_ntstatus( NtQueryInformationProcess( GetCurrentProcess(), ProcessExecuteFlags,
|
|
|
|
&dep_flags, sizeof(dep_flags), NULL )))
|
|
|
|
return FALSE;
|
2014-10-21 07:46:10 +02:00
|
|
|
|
2019-10-01 09:36:16 +02:00
|
|
|
if (flags)
|
|
|
|
{
|
|
|
|
*flags = 0;
|
|
|
|
if (dep_flags & MEM_EXECUTE_OPTION_DISABLE)
|
|
|
|
*flags |= PROCESS_DEP_ENABLE;
|
|
|
|
if (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION)
|
|
|
|
*flags |= PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION;
|
2014-10-21 07:46:10 +02:00
|
|
|
}
|
2019-10-01 09:36:16 +02:00
|
|
|
|
|
|
|
if (permanent) *permanent = (dep_flags & MEM_EXECUTE_OPTION_PERMANENT) != 0;
|
|
|
|
return TRUE;
|
2012-05-01 22:26:24 +02:00
|
|
|
}
|
2011-10-20 00:59:05 +02:00
|
|
|
|
2012-05-01 22:26:24 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* FlushProcessWriteBuffers (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
VOID WINAPI FlushProcessWriteBuffers(void)
|
|
|
|
{
|
2012-05-03 00:00:36 +02:00
|
|
|
static int once = 0;
|
|
|
|
|
|
|
|
if (!once++)
|
|
|
|
FIXME(": stub\n");
|
2011-10-20 00:59:05 +02:00
|
|
|
}
|
2014-06-18 01:24:48 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* UnregisterApplicationRestart (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI UnregisterApplicationRestart(void)
|
|
|
|
{
|
|
|
|
FIXME(": stub\n");
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2015-01-23 05:49:59 +01:00
|
|
|
|
2018-03-05 04:59:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CreateUmsCompletionList (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CreateUmsCompletionList(PUMS_COMPLETION_LIST *list)
|
|
|
|
{
|
|
|
|
FIXME( "%p: stub\n", list );
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-05 04:59:55 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CreateUmsThreadContext (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CreateUmsThreadContext(PUMS_CONTEXT *ctx)
|
|
|
|
{
|
|
|
|
FIXME( "%p: stub\n", ctx );
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-05 04:59:57 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* DeleteUmsCompletionList (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DeleteUmsCompletionList(PUMS_COMPLETION_LIST list)
|
|
|
|
{
|
|
|
|
FIXME( "%p: stub\n", list );
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-05 04:59:58 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* DeleteUmsThreadContext (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DeleteUmsThreadContext(PUMS_CONTEXT ctx)
|
|
|
|
{
|
|
|
|
FIXME( "%p: stub\n", ctx );
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-05 04:59:59 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* DequeueUmsCompletionListItems (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DequeueUmsCompletionListItems(void *list, DWORD timeout, PUMS_CONTEXT *ctx)
|
|
|
|
{
|
|
|
|
FIXME( "%p,%08x,%p: stub\n", list, timeout, ctx );
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-05 05:00:00 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* EnterUmsSchedulingMode (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnterUmsSchedulingMode(UMS_SCHEDULER_STARTUP_INFO *info)
|
|
|
|
{
|
|
|
|
FIXME( "%p: stub\n", info );
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-05 05:00:02 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ExecuteUmsThread (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ExecuteUmsThread(PUMS_CONTEXT ctx)
|
|
|
|
{
|
|
|
|
FIXME( "%p: stub\n", ctx );
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-05 05:00:03 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* GetCurrentUmsThread (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
PUMS_CONTEXT WINAPI GetCurrentUmsThread(void)
|
|
|
|
{
|
|
|
|
FIXME( "stub\n" );
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-05 05:00:04 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* GetNextUmsListItem (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
PUMS_CONTEXT WINAPI GetNextUmsListItem(PUMS_CONTEXT ctx)
|
|
|
|
{
|
|
|
|
FIXME( "%p: stub\n", ctx );
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-05 05:00:05 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* GetUmsCompletionListEvent (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetUmsCompletionListEvent(PUMS_COMPLETION_LIST list, HANDLE *event)
|
|
|
|
{
|
|
|
|
FIXME( "%p,%p: stub\n", list, event );
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-05 05:00:07 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* QueryUmsThreadInformation (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI QueryUmsThreadInformation(PUMS_CONTEXT ctx, UMS_THREAD_INFO_CLASS class,
|
|
|
|
void *buf, ULONG length, ULONG *ret_length)
|
|
|
|
{
|
|
|
|
FIXME( "%p,%08x,%p,%08x,%p: stub\n", ctx, class, buf, length, ret_length );
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-05 05:00:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SetUmsThreadInformation (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetUmsThreadInformation(PUMS_CONTEXT ctx, UMS_THREAD_INFO_CLASS class,
|
|
|
|
void *buf, ULONG length)
|
|
|
|
{
|
|
|
|
FIXME( "%p,%08x,%p,%08x: stub\n", ctx, class, buf, length );
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-05 05:00:09 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* UmsThreadYield (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI UmsThreadYield(void *param)
|
|
|
|
{
|
|
|
|
FIXME( "%p: stub\n", param );
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2017-01-18 23:38:26 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* BaseFlushAppcompatCache (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI BaseFlushAppcompatCache(void)
|
|
|
|
{
|
|
|
|
FIXME(": stub\n");
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|