ReactOS 0.4.16-dev-1453-g06343fa
process.c File Reference
#include <stdarg.h>
#include <string.h>
#include "ntstatus.h"
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "wincontypes.h"
#include "winternl.h"
#include "kernelbase.h"
#include "wine/debug.h"
#include "wine/condrv.h"
Include dependency graph for process.c:

Go to the source code of this file.

Classes

struct  proc_thread_attr
 
struct  _PROC_THREAD_ATTRIBUTE_LIST
 

Macros

#define WIN32_NO_STATUS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (process)
 
static BOOL find_exe_file (const WCHAR *name, WCHAR *buffer, DWORD buflen)
 
static WCHARget_file_name (WCHAR *cmdline, WCHAR *buffer, DWORD buflen)
 
static RTL_USER_PROCESS_PARAMETERScreate_process_params (const WCHAR *filename, const WCHAR *cmdline, const WCHAR *cur_dir, void *env, DWORD flags, const STARTUPINFOW *startup)
 
static NTSTATUS create_nt_process (HANDLE token, HANDLE debug, SECURITY_ATTRIBUTES *psa, SECURITY_ATTRIBUTES *tsa, DWORD process_flags, RTL_USER_PROCESS_PARAMETERS *params, RTL_USER_PROCESS_INFORMATION *info, HANDLE parent, USHORT machine, const struct proc_thread_attr *handle_list, const struct proc_thread_attr *job_list)
 
static NTSTATUS create_vdm_process (HANDLE token, HANDLE debug, SECURITY_ATTRIBUTES *psa, SECURITY_ATTRIBUTES *tsa, DWORD flags, RTL_USER_PROCESS_PARAMETERS *params, RTL_USER_PROCESS_INFORMATION *info)
 
static NTSTATUS create_cmd_process (HANDLE token, HANDLE debug, SECURITY_ATTRIBUTES *psa, SECURITY_ATTRIBUTES *tsa, DWORD flags, RTL_USER_PROCESS_PARAMETERS *params, RTL_USER_PROCESS_INFORMATION *info)
 
BOOL WINAPI DECLSPEC_HOTPATCH CloseHandle (HANDLE handle)
 
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessAsUserA (HANDLE token, const char *app_name, char *cmd_line, SECURITY_ATTRIBUTES *process_attr, SECURITY_ATTRIBUTES *thread_attr, BOOL inherit, DWORD flags, void *env, const char *cur_dir, STARTUPINFOA *startup_info, PROCESS_INFORMATION *info)
 
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessAsUserW (HANDLE token, const WCHAR *app_name, WCHAR *cmd_line, SECURITY_ATTRIBUTES *process_attr, SECURITY_ATTRIBUTES *thread_attr, BOOL inherit, DWORD flags, void *env, const WCHAR *cur_dir, STARTUPINFOW *startup_info, PROCESS_INFORMATION *info)
 
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessInternalA (HANDLE token, const char *app_name, char *cmd_line, SECURITY_ATTRIBUTES *process_attr, SECURITY_ATTRIBUTES *thread_attr, BOOL inherit, DWORD flags, void *env, const char *cur_dir, STARTUPINFOA *startup_info, PROCESS_INFORMATION *info, HANDLE *new_token)
 
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessInternalW (HANDLE token, const WCHAR *app_name, WCHAR *cmd_line, SECURITY_ATTRIBUTES *process_attr, SECURITY_ATTRIBUTES *thread_attr, BOOL inherit, DWORD flags, void *env, const WCHAR *cur_dir, STARTUPINFOW *startup_info, PROCESS_INFORMATION *info, HANDLE *new_token)
 
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA (const char *app_name, char *cmd_line, SECURITY_ATTRIBUTES *process_attr, SECURITY_ATTRIBUTES *thread_attr, BOOL inherit, DWORD flags, void *env, const char *cur_dir, STARTUPINFOA *startup_info, PROCESS_INFORMATION *info)
 
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW (const WCHAR *app_name, WCHAR *cmd_line, SECURITY_ATTRIBUTES *process_attr, SECURITY_ATTRIBUTES *thread_attr, BOOL inherit, DWORD flags, void *env, const WCHAR *cur_dir, STARTUPINFOW *startup_info, PROCESS_INFORMATION *info)
 
BOOL WINAPI SetProcessInformation (HANDLE process, PROCESS_INFORMATION_CLASS info_class, void *info, DWORD size)
 
BOOL WINAPI DECLSPEC_HOTPATCH DuplicateHandle (HANDLE source_process, HANDLE source, HANDLE dest_process, HANDLE *dest, DWORD access, BOOL inherit, DWORD options)
 
HRESULT WINAPI GetApplicationRestartSettings (HANDLE process, WCHAR *cmdline, DWORD *size, DWORD *flags)
 
HANDLE WINAPI kernelbase_GetCurrentProcess (void)
 
DWORD WINAPI kernelbase_GetCurrentProcessId (void)
 
UINT WINAPI DECLSPEC_HOTPATCH GetErrorMode (void)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetExitCodeProcess (HANDLE process, LPDWORD exit_code)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetHandleInformation (HANDLE handle, DWORD *flags)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetPriorityClass (HANDLE process)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetProcessGroupAffinity (HANDLE process, USHORT *count, USHORT *array)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetProcessHandleCount (HANDLE process, DWORD *count)
 
HANDLE WINAPI kernelbase_GetProcessHeap (void)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetProcessId (HANDLE process)
 
BOOL WINAPI GetProcessMitigationPolicy (HANDLE process, PROCESS_MITIGATION_POLICY policy, void *buffer, SIZE_T length)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetProcessPriorityBoost (HANDLE process, PBOOL disable)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetProcessShutdownParameters (LPDWORD level, LPDWORD flags)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetProcessTimes (HANDLE process, FILETIME *create, FILETIME *exit, FILETIME *kernel, FILETIME *user)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetProcessVersion (DWORD pid)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetProcessWorkingSetSizeEx (HANDLE process, SIZE_T *minset, SIZE_T *maxset, DWORD *flags)
 
BOOL WINAPI DECLSPEC_HOTPATCH IsProcessInJob (HANDLE process, HANDLE job, BOOL *result)
 
BOOL WINAPI DECLSPEC_HOTPATCH IsProcessorFeaturePresent (DWORD feature)
 
BOOL WINAPI DECLSPEC_HOTPATCH IsWow64Process2 (HANDLE process, USHORT *machine, USHORT *native_machine)
 
BOOL WINAPI DECLSPEC_HOTPATCH IsWow64Process (HANDLE process, PBOOL wow64)
 
BOOL WINAPI GetProcessInformation (HANDLE process, PROCESS_INFORMATION_CLASS info_class, void *data, DWORD size)
 
HANDLE WINAPI DECLSPEC_HOTPATCH OpenProcess (DWORD access, BOOL inherit, DWORD id)
 
BOOL WINAPI DECLSPEC_HOTPATCH ProcessIdToSessionId (DWORD pid, DWORD *id)
 
BOOL WINAPI DECLSPEC_HOTPATCH QueryProcessCycleTime (HANDLE process, ULONG64 *cycle)
 
UINT WINAPI DECLSPEC_HOTPATCH SetErrorMode (UINT mode)
 
UINT WINAPI DECLSPEC_HOTPATCH SetHandleCount (UINT count)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetHandleInformation (HANDLE handle, DWORD mask, DWORD flags)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetPriorityClass (HANDLE process, DWORD class)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetProcessAffinityUpdateMode (HANDLE process, DWORD flags)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetProcessGroupAffinity (HANDLE process, const GROUP_AFFINITY *new, GROUP_AFFINITY *old)
 
BOOL WINAPI SetProcessMitigationPolicy (PROCESS_MITIGATION_POLICY policy, void *buffer, SIZE_T length)
 
BOOL WINAPI SetProcessPriorityBoost (HANDLE process, BOOL disable)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetProcessShutdownParameters (DWORD level, DWORD flags)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetProcessWorkingSetSizeEx (HANDLE process, SIZE_T minset, SIZE_T maxset, DWORD flags)
 
BOOL WINAPI DECLSPEC_HOTPATCH TerminateProcess (HANDLE handle, DWORD exit_code)
 
void init_startup_info (RTL_USER_PROCESS_PARAMETERS *params)
 
BOOL WINAPI BaseFlushAppcompatCache (void)
 
LPSTR WINAPI GetCommandLineA (void)
 
LPWSTR WINAPI GetCommandLineW (void)
 
void WINAPI DECLSPEC_HOTPATCH GetStartupInfoW (STARTUPINFOW *info)
 
HANDLE WINAPI DECLSPEC_HOTPATCH GetStdHandle (DWORD std_handle)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetStdHandle (DWORD std_handle, HANDLE handle)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetStdHandleEx (DWORD std_handle, HANDLE handle, HANDLE *prev)
 
static SIZE_T get_env_length (const WCHAR *env)
 
DWORD WINAPI DECLSPEC_HOTPATCH ExpandEnvironmentStringsA (LPCSTR src, LPSTR dst, DWORD count)
 
DWORD WINAPI DECLSPEC_HOTPATCH ExpandEnvironmentStringsW (LPCWSTR src, LPWSTR dst, DWORD len)
 
LPSTR WINAPI DECLSPEC_HOTPATCH GetEnvironmentStringsA (void)
 
LPWSTR WINAPI DECLSPEC_HOTPATCH GetEnvironmentStringsW (void)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentStringsA (char *env)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentStringsW (WCHAR *env)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetEnvironmentVariableA (LPCSTR name, LPSTR value, DWORD size)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetEnvironmentVariableW (LPCWSTR name, LPWSTR val, DWORD size)
 
BOOL WINAPI DECLSPEC_HOTPATCH FreeEnvironmentStringsW (LPWSTR ptr)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableA (LPCSTR name, LPCSTR value)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableW (LPCWSTR name, LPCWSTR value)
 
BOOL WINAPI DECLSPEC_HOTPATCH InitializeProcThreadAttributeList (struct _PROC_THREAD_ATTRIBUTE_LIST *list, DWORD count, DWORD flags, SIZE_T *size)
 
static DWORD validate_proc_thread_attribute (DWORD_PTR attr, SIZE_T size)
 
BOOL WINAPI DECLSPEC_HOTPATCH UpdateProcThreadAttribute (struct _PROC_THREAD_ATTRIBUTE_LIST *list, DWORD flags, DWORD_PTR attr, void *value, SIZE_T size, void *prev_ret, SIZE_T *size_ret)
 
void WINAPI DECLSPEC_HOTPATCH DeleteProcThreadAttributeList (struct _PROC_THREAD_ATTRIBUTE_LIST *list)
 
BOOL WINAPI DECLSPEC_HOTPATCH CompareObjectHandles (HANDLE first, HANDLE second)
 

Variables

static DWORD shutdown_flags = 0
 
static DWORD shutdown_priority = 0x280
 
static charcommand_lineA
 
static WCHARcommand_lineW
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 25 of file process.c.

Function Documentation

◆ BaseFlushAppcompatCache()

BOOL WINAPI BaseFlushAppcompatCache ( void  )

Definition at line 1318 of file process.c.

1319{
1320 FIXME( "stub\n" );
1322 return FALSE;
1323}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define FALSE
Definition: types.h:117
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define SetLastError(x)
Definition: compat.h:752

Referenced by ShimFlushCache().

◆ CloseHandle()

BOOL WINAPI DECLSPEC_HOTPATCH CloseHandle ( HANDLE  handle)

Definition at line 421 of file process.c.

422{
425 else if (handle == (HANDLE)STD_OUTPUT_HANDLE)
427 else if (handle == (HANDLE)STD_ERROR_HANDLE)
429
430 return set_ntstatus( NtClose( handle ));
431}
static __inline BOOL set_ntstatus(NTSTATUS status)
Definition: security.c:227
PPEB Peb
Definition: dllmain.c:27
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define NtCurrentTeb
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1913
#define STD_OUTPUT_HANDLE
Definition: winbase.h:301
#define STD_INPUT_HANDLE
Definition: winbase.h:300
#define STD_ERROR_HANDLE
Definition: winbase.h:302

◆ CompareObjectHandles()

BOOL WINAPI DECLSPEC_HOTPATCH CompareObjectHandles ( HANDLE  first,
HANDLE  second 
)

Definition at line 1869 of file process.c.

1870{
1871 return set_ntstatus( NtCompareObjects( first, second ));
1872}
const GLint * first
Definition: glext.h:5794

◆ create_cmd_process()

static NTSTATUS create_cmd_process ( HANDLE  token,
HANDLE  debug,
SECURITY_ATTRIBUTES psa,
SECURITY_ATTRIBUTES tsa,
DWORD  flags,
RTL_USER_PROCESS_PARAMETERS params,
RTL_USER_PROCESS_INFORMATION info 
)
static

Definition at line 392 of file process.c.

396{
397 WCHAR comspec[MAX_PATH];
398 WCHAR *newcmdline;
400 UINT len;
401
402 if (!GetEnvironmentVariableW( L"COMSPEC", comspec, ARRAY_SIZE( comspec )))
403 lstrcpyW( comspec, L"C:\\windows\\system32\\cmd.exe" );
404
405 len = lstrlenW(comspec) + 7 + lstrlenW(params->CommandLine.Buffer) + 2;
406 if (!(newcmdline = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
407 return STATUS_NO_MEMORY;
408
409 swprintf( newcmdline, len, L"%s /s/c \"%s\"", comspec, params->CommandLine.Buffer );
410 RtlInitUnicodeString( &params->ImagePathName, comspec );
411 RtlInitUnicodeString( &params->CommandLine, newcmdline );
413 RtlFreeHeap( GetProcessHeap(), 0, newcmdline );
414 return status;
415}
LONG NTSTATUS
Definition: precomp.h:26
#define ARRAY_SIZE(A)
Definition: main.h:20
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:634
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
static NTSTATUS create_nt_process(HANDLE token, HANDLE debug, SECURITY_ATTRIBUTES *psa, SECURITY_ATTRIBUTES *tsa, DWORD process_flags, RTL_USER_PROCESS_PARAMETERS *params, RTL_USER_PROCESS_INFORMATION *info, HANDLE parent, USHORT machine, const struct proc_thread_attr *handle_list, const struct proc_thread_attr *job_list)
Definition: process.c:257
#define swprintf
Definition: precomp.h:40
#define L(x)
Definition: resources.c:13
GLenum const GLfloat * params
Definition: glext.h:5645
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
#define debug(msg)
Definition: key_call.c:71
static SCRIPT_CACHE SCRIPT_ANALYSIS * psa
Definition: usp10.c:64
unsigned int UINT
Definition: ndis.h:50
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
Definition: ps.c:97
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CreateProcessInternalW().

◆ create_nt_process()

static NTSTATUS create_nt_process ( HANDLE  token,
HANDLE  debug,
SECURITY_ATTRIBUTES psa,
SECURITY_ATTRIBUTES tsa,
DWORD  process_flags,
RTL_USER_PROCESS_PARAMETERS params,
RTL_USER_PROCESS_INFORMATION info,
HANDLE  parent,
USHORT  machine,
const struct proc_thread_attr handle_list,
const struct proc_thread_attr job_list 
)
static

Definition at line 257 of file process.c.

264{
265 OBJECT_ATTRIBUTES process_attr, thread_attr;
266 PS_CREATE_INFO create_info;
267 ULONG_PTR buffer[offsetof( PS_ATTRIBUTE_LIST, Attributes[9] ) / sizeof(ULONG_PTR)];
268 PS_ATTRIBUTE_LIST *attr = (PS_ATTRIBUTE_LIST *)buffer;
271 UINT pos = 0;
272
273 if (!params->ImagePathName.Buffer[0]) return STATUS_OBJECT_PATH_NOT_FOUND;
275 if (!status)
276 {
278
279 attr->Attributes[pos].Attribute = PS_ATTRIBUTE_IMAGE_NAME;
280 attr->Attributes[pos].Size = nameW.Length;
281 attr->Attributes[pos].ValuePtr = nameW.Buffer;
282 attr->Attributes[pos].ReturnLength = NULL;
283 pos++;
284 attr->Attributes[pos].Attribute = PS_ATTRIBUTE_CLIENT_ID;
285 attr->Attributes[pos].Size = sizeof(info->ClientId);
286 attr->Attributes[pos].ValuePtr = &info->ClientId;
287 attr->Attributes[pos].ReturnLength = NULL;
288 pos++;
289 attr->Attributes[pos].Attribute = PS_ATTRIBUTE_IMAGE_INFO;
290 attr->Attributes[pos].Size = sizeof(info->ImageInformation);
291 attr->Attributes[pos].ValuePtr = &info->ImageInformation;
292 attr->Attributes[pos].ReturnLength = NULL;
293 pos++;
294 if (parent)
295 {
296 attr->Attributes[pos].Attribute = PS_ATTRIBUTE_PARENT_PROCESS;
297 attr->Attributes[pos].Size = sizeof(parent);
298 attr->Attributes[pos].ValuePtr = parent;
299 attr->Attributes[pos].ReturnLength = NULL;
300 pos++;
301 }
302 if ((process_flags & PROCESS_CREATE_FLAGS_INHERIT_HANDLES) && handle_list)
303 {
304 attr->Attributes[pos].Attribute = PS_ATTRIBUTE_HANDLE_LIST;
305 attr->Attributes[pos].Size = handle_list->size;
306 attr->Attributes[pos].ValuePtr = handle_list->value;
307 attr->Attributes[pos].ReturnLength = NULL;
308 pos++;
309 }
310 if (token)
311 {
312 attr->Attributes[pos].Attribute = PS_ATTRIBUTE_TOKEN;
313 attr->Attributes[pos].Size = sizeof(token);
314 attr->Attributes[pos].ValuePtr = token;
315 attr->Attributes[pos].ReturnLength = NULL;
316 pos++;
317 }
318 if (debug)
319 {
320 attr->Attributes[pos].Attribute = PS_ATTRIBUTE_DEBUG_PORT;
321 attr->Attributes[pos].Size = sizeof(debug);
322 attr->Attributes[pos].ValuePtr = debug;
323 attr->Attributes[pos].ReturnLength = NULL;
324 pos++;
325 }
326 if (job_list)
327 {
328 attr->Attributes[pos].Attribute = PS_ATTRIBUTE_JOB_LIST;
329 attr->Attributes[pos].Size = job_list->size;
330 attr->Attributes[pos].ValuePtr = job_list->value;
331 attr->Attributes[pos].ReturnLength = NULL;
332 pos++;
333 }
334 if (machine)
335 {
336 attr->Attributes[pos].Attribute = PS_ATTRIBUTE_MACHINE_TYPE;
337 attr->Attributes[pos].Size = sizeof(machine);
338 attr->Attributes[pos].Value = machine;
339 attr->Attributes[pos].ReturnLength = NULL;
340 pos++;
341 }
342 attr->TotalLength = offsetof( PS_ATTRIBUTE_LIST, Attributes[pos] );
343
344 InitializeObjectAttributes( &process_attr, NULL, 0, NULL, psa ? psa->lpSecurityDescriptor : NULL );
345 InitializeObjectAttributes( &thread_attr, NULL, 0, NULL, tsa ? tsa->lpSecurityDescriptor : NULL );
346
347 status = NtCreateUserProcess( &info->Process, &info->Thread, PROCESS_ALL_ACCESS, THREAD_ALL_ACCESS,
348 &process_attr, &thread_attr, process_flags,
350 &create_info, attr );
351
353 }
354 return status;
355}
static const WCHAR nameW[]
Definition: main.c:49
r parent
Definition: btrfs.c:3010
#define ULONG_PTR
Definition: config.h:101
GLuint buffer
Definition: glext.h:5915
#define PROCESS_CREATE_FLAGS_INHERIT_HANDLES
Definition: pstypes.h:94
NTSYSAPI NTSTATUS WINAPI RtlDosPathNameToNtPathName_U_WithStatus(PCWSTR, PUNICODE_STRING, PWSTR *, CURDIR *)
#define THREAD_CREATE_FLAGS_CREATE_SUSPENDED
Definition: winternl.h:2349
static const char machine[]
Definition: profile.c:104
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI PRTL_USER_PROCESS_PARAMETERS NTAPI RtlNormalizeProcessParams(_In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters)
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
#define PROCESS_ALL_ACCESS
Definition: nt_native.h:1324
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define offsetof(TYPE, MEMBER)
LPVOID lpSecurityDescriptor
Definition: compat.h:193
Definition: cookie.c:202
void * value
Definition: process.c:241
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STATUS_OBJECT_PATH_NOT_FOUND
Definition: udferr_usr.h:151
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes

Referenced by create_cmd_process(), create_vdm_process(), and CreateProcessInternalW().

◆ create_process_params()

static RTL_USER_PROCESS_PARAMETERS * create_process_params ( const WCHAR filename,
const WCHAR cmdline,
const WCHAR cur_dir,
void env,
DWORD  flags,
const STARTUPINFOW startup 
)
static

Definition at line 141 of file process.c.

144{
146 UNICODE_STRING imageW, curdirW, cmdlineW, titleW, desktopW, runtimeW, newdirW;
147 WCHAR imagepath[MAX_PATH];
148 WCHAR *envW = env;
149
150 if (!GetLongPathNameW( filename, imagepath, MAX_PATH )) lstrcpynW( imagepath, filename, MAX_PATH );
151 if (!GetFullPathNameW( imagepath, MAX_PATH, imagepath, NULL )) lstrcpynW( imagepath, filename, MAX_PATH );
152
153 if (env && !(flags & CREATE_UNICODE_ENVIRONMENT)) /* convert environment to unicode */
154 {
155 char *e = env;
156 DWORD lenW;
157
158 while (*e) e += strlen(e) + 1;
159 e++; /* final null */
160 lenW = MultiByteToWideChar( CP_ACP, 0, env, e - (char *)env, NULL, 0 );
161 if ((envW = RtlAllocateHeap( GetProcessHeap(), 0, lenW * sizeof(WCHAR) )))
162 MultiByteToWideChar( CP_ACP, 0, env, e - (char *)env, envW, lenW );
163 }
164
165 newdirW.Buffer = NULL;
166 if (cur_dir)
167 {
168 if (RtlDosPathNameToNtPathName_U( cur_dir, &newdirW, NULL, NULL ))
169 cur_dir = newdirW.Buffer + 4; /* skip \??\ prefix */
170 else
171 cur_dir = NULL;
172 }
173 RtlInitUnicodeString( &imageW, imagepath );
174 RtlInitUnicodeString( &curdirW, cur_dir );
175 RtlInitUnicodeString( &cmdlineW, cmdline );
176 RtlInitUnicodeString( &titleW, startup->lpTitle ? startup->lpTitle : imagepath );
177 RtlInitUnicodeString( &desktopW, startup->lpDesktop );
178 runtimeW.Buffer = (WCHAR *)startup->lpReserved2;
179 runtimeW.Length = runtimeW.MaximumLength = startup->cbReserved2;
180 if (RtlCreateProcessParametersEx( &params, &imageW, NULL, cur_dir ? &curdirW : NULL,
181 &cmdlineW, envW, &titleW, &desktopW,
183 {
184 RtlFreeUnicodeString( &newdirW );
185 if (envW != env) RtlFreeHeap( GetProcessHeap(), 0, envW );
186 return NULL;
187 }
188 RtlFreeUnicodeString( &newdirW );
189
191 params->ProcessGroupId = NtCurrentTeb()->Peb->ProcessParameters->ProcessGroupId;
192 else if (!(flags & CREATE_NEW_CONSOLE))
193 params->ConsoleFlags = 1;
194
195 if (flags & CREATE_NEW_CONSOLE) params->ConsoleHandle = CONSOLE_HANDLE_ALLOC;
196 else if (!(flags & DETACHED_PROCESS))
197 {
198 if (flags & CREATE_NO_WINDOW) params->ConsoleHandle = CONSOLE_HANDLE_ALLOC_NO_WINDOW;
199 else
200 {
201 params->ConsoleHandle = NtCurrentTeb()->Peb->ProcessParameters->ConsoleHandle;
202 if (!params->ConsoleHandle) params->ConsoleHandle = CONSOLE_HANDLE_ALLOC;
203 }
204 }
205
206 if (startup->dwFlags & STARTF_USESTDHANDLES)
207 {
208 params->hStdInput = startup->hStdInput;
209 params->hStdOutput = startup->hStdOutput;
210 params->hStdError = startup->hStdError;
211 }
212 else if (!(flags & (DETACHED_PROCESS | CREATE_NEW_CONSOLE)))
213 {
214 params->hStdInput = NtCurrentTeb()->Peb->ProcessParameters->hStdInput;
215 params->hStdOutput = NtCurrentTeb()->Peb->ProcessParameters->hStdOutput;
216 params->hStdError = NtCurrentTeb()->Peb->ProcessParameters->hStdError;
217 }
218
219 if (params->hStdInput == INVALID_HANDLE_VALUE) params->hStdInput = NULL;
220 if (params->hStdOutput == INVALID_HANDLE_VALUE) params->hStdOutput = NULL;
221 if (params->hStdError == INVALID_HANDLE_VALUE) params->hStdError = NULL;
222
223 params->dwX = startup->dwX;
224 params->dwY = startup->dwY;
225 params->dwXSize = startup->dwXSize;
226 params->dwYSize = startup->dwYSize;
227 params->dwXCountChars = startup->dwXCountChars;
228 params->dwYCountChars = startup->dwYCountChars;
229 params->dwFillAttribute = startup->dwFillAttribute;
230 params->dwFlags = startup->dwFlags;
231 params->wShowWindow = startup->wShowWindow;
232
233 if (envW != env) RtlFreeHeap( GetProcessHeap(), 0, envW );
234 return params;
235}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void startup(void)
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:170
#define CP_ACP
Definition: compat.h:109
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MultiByteToWideChar
Definition: compat.h:110
#define lstrcpynW
Definition: compat.h:738
DWORD WINAPI GetLongPathNameW(IN LPCWSTR lpszShortPath, OUT LPWSTR lpszLongPath, IN DWORD cchBuffer)
Definition: path.c:1456
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
static const WCHAR desktopW[]
Definition: main.c:46
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR titleW[]
Definition: htmlelem.c:1067
#define PROCESS_PARAMS_FLAG_NORMALIZED
Definition: winternl.h:227
const char * filename
Definition: ioapi.h:137
#define e
Definition: ke_i.h:82
if(dx< 0)
Definition: linetemp.h:194
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
TCHAR * cmdline
Definition: stretchblt.cpp:32
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define CREATE_UNICODE_ENVIRONMENT
Definition: winbase.h:196
#define CREATE_NO_WINDOW
Definition: winbase.h:222
#define CREATE_NEW_PROCESS_GROUP
Definition: winbase.h:195
#define STARTF_USESTDHANDLES
Definition: winbase.h:532
#define DETACHED_PROCESS
Definition: winbase.h:189
#define CREATE_NEW_CONSOLE
Definition: winbase.h:190

Referenced by CreateProcessInternalW().

◆ create_vdm_process()

static NTSTATUS create_vdm_process ( HANDLE  token,
HANDLE  debug,
SECURITY_ATTRIBUTES psa,
SECURITY_ATTRIBUTES tsa,
DWORD  flags,
RTL_USER_PROCESS_PARAMETERS params,
RTL_USER_PROCESS_INFORMATION info 
)
static

Definition at line 361 of file process.c.

365{
366 const WCHAR *winevdm = (is_win64 || is_wow64 ?
367 L"C:\\windows\\syswow64\\winevdm.exe" :
368 L"C:\\windows\\system32\\winevdm.exe");
369 WCHAR *newcmdline;
371 UINT len;
372
373 len = (lstrlenW(params->ImagePathName.Buffer) + lstrlenW(params->CommandLine.Buffer) +
374 lstrlenW(winevdm) + 16);
375
376 if (!(newcmdline = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
377 return STATUS_NO_MEMORY;
378
379 swprintf( newcmdline, len, L"%s --app-name \"%s\" %s",
380 winevdm, params->ImagePathName.Buffer, params->CommandLine.Buffer );
381 RtlInitUnicodeString( &params->ImagePathName, winevdm );
382 RtlInitUnicodeString( &params->CommandLine, newcmdline );
384 HeapFree( GetProcessHeap(), 0, newcmdline );
385 return status;
386}
#define HeapFree(x, y, z)
Definition: compat.h:735
BOOL is_wow64
Definition: main.c:38
static const BOOL is_win64
Definition: kernelbase.h:49

Referenced by CreateProcessInternalW().

◆ CreateProcessA()

BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA ( const char app_name,
char cmd_line,
SECURITY_ATTRIBUTES process_attr,
SECURITY_ATTRIBUTES thread_attr,
BOOL  inherit,
DWORD  flags,
void env,
const char cur_dir,
STARTUPINFOA startup_info,
PROCESS_INFORMATION info 
)

Definition at line 686 of file process.c.

691{
692 return CreateProcessInternalA( NULL, app_name, cmd_line, process_attr, thread_attr,
693 inherit, flags, env, cur_dir, startup_info, info, NULL );
694}
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessInternalA(HANDLE token, const char *app_name, char *cmd_line, SECURITY_ATTRIBUTES *process_attr, SECURITY_ATTRIBUTES *thread_attr, BOOL inherit, DWORD flags, void *env, const char *cur_dir, STARTUPINFOA *startup_info, PROCESS_INFORMATION *info, HANDLE *new_token)
Definition: process.c:466
LPCWSTR app_name
Definition: notevil.c:34

Referenced by _create_process(), DosCreateProcess(), START_TEST(), test_BreakawayOk(), test_CommandLine(), test_Console(), test_DebuggingFlag(), test_DetachConsoleHandles(), test_DetachStdHandles(), test_Directory(), test_Environment(), test_ExitCode(), test_GetProcessVersion(), test_IsWow64Process(), test_jobInheritance(), test_NtSuspendProcess(), test_Startup(), test_StartupNoConsole(), test_SuspendFlag(), test_TerminateProcess(), and test_Toolhelp().

◆ CreateProcessAsUserA()

BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessAsUserA ( HANDLE  token,
const char app_name,
char cmd_line,
SECURITY_ATTRIBUTES process_attr,
SECURITY_ATTRIBUTES thread_attr,
BOOL  inherit,
DWORD  flags,
void env,
const char cur_dir,
STARTUPINFOA startup_info,
PROCESS_INFORMATION info 
)

Definition at line 437 of file process.c.

443{
444 return CreateProcessInternalA( token, app_name, cmd_line, process_attr, thread_attr,
445 inherit, flags, env, cur_dir, startup_info, info, NULL );
446}

◆ CreateProcessAsUserW()

BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessAsUserW ( HANDLE  token,
const WCHAR app_name,
WCHAR cmd_line,
SECURITY_ATTRIBUTES process_attr,
SECURITY_ATTRIBUTES thread_attr,
BOOL  inherit,
DWORD  flags,
void env,
const WCHAR cur_dir,
STARTUPINFOW startup_info,
PROCESS_INFORMATION info 
)

Definition at line 452 of file process.c.

458{
459 return CreateProcessInternalW( token, app_name, cmd_line, process_attr, thread_attr,
460 inherit, flags, env, cur_dir, startup_info, info, NULL );
461}
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessInternalW(HANDLE token, const WCHAR *app_name, WCHAR *cmd_line, SECURITY_ATTRIBUTES *process_attr, SECURITY_ATTRIBUTES *thread_attr, BOOL inherit, DWORD flags, void *env, const WCHAR *cur_dir, STARTUPINFOW *startup_info, PROCESS_INFORMATION *info, HANDLE *new_token)
Definition: process.c:508

◆ CreateProcessInternalA()

BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessInternalA ( HANDLE  token,
const char app_name,
char cmd_line,
SECURITY_ATTRIBUTES process_attr,
SECURITY_ATTRIBUTES thread_attr,
BOOL  inherit,
DWORD  flags,
void env,
const char cur_dir,
STARTUPINFOA startup_info,
PROCESS_INFORMATION info,
HANDLE new_token 
)

Definition at line 466 of file process.c.

472{
473 BOOL ret = FALSE;
474 WCHAR *app_nameW = NULL, *cmd_lineW = NULL, *cur_dirW = NULL;
476 STARTUPINFOEXW infoW;
477
478 desktopW.Buffer = NULL;
479 titleW.Buffer = NULL;
480 if (app_name && !(app_nameW = file_name_AtoW( app_name, TRUE ))) goto done;
481 if (cmd_line && !(cmd_lineW = file_name_AtoW( cmd_line, TRUE ))) goto done;
482 if (cur_dir && !(cur_dirW = file_name_AtoW( cur_dir, TRUE ))) goto done;
483
484 if (startup_info->lpDesktop) RtlCreateUnicodeStringFromAsciiz( &desktopW, startup_info->lpDesktop );
485 if (startup_info->lpTitle) RtlCreateUnicodeStringFromAsciiz( &titleW, startup_info->lpTitle );
486
487 memcpy( &infoW.StartupInfo, startup_info, sizeof(infoW.StartupInfo) );
488 infoW.StartupInfo.lpDesktop = desktopW.Buffer;
489 infoW.StartupInfo.lpTitle = titleW.Buffer;
490
492 infoW.lpAttributeList = ((STARTUPINFOEXW *)startup_info)->lpAttributeList;
493
494 ret = CreateProcessInternalW( token, app_nameW, cmd_lineW, process_attr, thread_attr,
495 inherit, flags, env, cur_dirW, (STARTUPINFOW *)&infoW, info, new_token );
496done:
497 RtlFreeHeap( GetProcessHeap(), 0, app_nameW );
498 RtlFreeHeap( GetProcessHeap(), 0, cmd_lineW );
499 RtlFreeHeap( GetProcessHeap(), 0, cur_dirW );
502 return ret;
503}
#define TRUE
Definition: types.h:120
WCHAR * file_name_AtoW(LPCSTR name, BOOL alloc)
Definition: file.c:411
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
static const SecPkgInfoW infoW
Definition: kerberos.c:293
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
LPSTR lpTitle
Definition: winbase.h:869
LPSTR lpDesktop
Definition: winbase.h:868
#define EXTENDED_STARTUPINFO_PRESENT
Definition: winbase.h:210

Referenced by CreateProcessA(), and CreateProcessAsUserA().

◆ CreateProcessInternalW()

BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessInternalW ( HANDLE  token,
const WCHAR app_name,
WCHAR cmd_line,
SECURITY_ATTRIBUTES process_attr,
SECURITY_ATTRIBUTES thread_attr,
BOOL  inherit,
DWORD  flags,
void env,
const WCHAR cur_dir,
STARTUPINFOW startup_info,
PROCESS_INFORMATION info,
HANDLE new_token 
)

Definition at line 508 of file process.c.

514{
515 const struct proc_thread_attr *handle_list = NULL, *job_list = NULL;
517 WCHAR *p, *tidy_cmdline = cmd_line;
520 HANDLE parent = 0, debug = 0;
521 ULONG nt_flags = 0;
522 USHORT machine = 0;
524
525 /* Process the AppName and/or CmdLine to get module name and path */
526
527 TRACE( "app %s cmdline %s\n", debugstr_w(app_name), debugstr_w(cmd_line) );
528
529 if (new_token) FIXME( "No support for returning created process token\n" );
530
531 if (app_name)
532 {
533 if (!cmd_line || !cmd_line[0]) /* no command-line, create one */
534 {
535 if (!(tidy_cmdline = RtlAllocateHeap( GetProcessHeap(), 0, (lstrlenW(app_name)+3) * sizeof(WCHAR) )))
536 return FALSE;
537 swprintf( tidy_cmdline, lstrlenW(app_name) + 3, L"\"%s\"", app_name );
538 }
539 }
540 else
541 {
542 if (!(tidy_cmdline = get_file_name( cmd_line, name, ARRAY_SIZE(name) ))) return FALSE;
543 app_name = name;
544 }
545
546 /* Warn if unsupported features are used */
547
550 WARN( "(%s,...): ignoring some flags in %lx\n", debugstr_w(app_name), flags );
551
552 if (cur_dir)
553 {
554 DWORD attr = GetFileAttributesW( cur_dir );
556 {
558 goto done;
559 }
560 }
561
562 info->hThread = info->hProcess = 0;
563 info->dwProcessId = info->dwThreadId = 0;
564
565 if (!(params = create_process_params( app_name, tidy_cmdline, cur_dir, env, flags, startup_info )))
566 {
568 goto done;
569 }
570
572 {
573 if ((status = DbgUiConnectToDbg())) goto done;
575 }
576
578 {
580 (struct _PROC_THREAD_ATTRIBUTE_LIST *)((STARTUPINFOEXW *)startup_info)->lpAttributeList;
581 unsigned int i;
582
583 if (attrs)
584 {
585 for (i = 0; i < attrs->count; ++i)
586 {
587 switch(attrs->attrs[i].attr)
588 {
590 parent = *(HANDLE *)attrs->attrs[i].value;
591 TRACE("PROC_THREAD_ATTRIBUTE_PARENT_PROCESS parent %p.\n", parent);
592 if (!parent)
593 {
595 goto done;
596 }
597 break;
598 case PROC_THREAD_ATTRIBUTE_EXTENDED_FLAGS:
599 FIXME("PROC_THREAD_ATTRIBUTE_EXTENDED_FLAGS %lx.\n", *(ULONG *)attrs->attrs[i].value);
600 break;
602 handle_list = &attrs->attrs[i];
603 TRACE("PROC_THREAD_ATTRIBUTE_HANDLE_LIST handle count %Iu.\n", attrs->attrs[i].size / sizeof(HANDLE));
604 break;
605 case PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE:
606 {
607 struct pseudo_console *console = attrs->attrs[i].value;
608 TRACE( "PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE %p reference %p\n",
609 console, console->reference );
610 params->ConsoleHandle = console->reference;
611 break;
612 }
613 case PROC_THREAD_ATTRIBUTE_JOB_LIST:
614 job_list = &attrs->attrs[i];
615 TRACE( "PROC_THREAD_ATTRIBUTE_JOB_LIST handle count %Iu.\n",
616 attrs->attrs[i].size / sizeof(HANDLE) );
617 break;
618 case PROC_THREAD_ATTRIBUTE_MACHINE_TYPE:
619 machine = *(USHORT *)attrs->attrs[i].value;
620 TRACE( "PROC_THREAD_ATTRIBUTE_MACHINE %x.\n", machine );
621 break;
622 default:
623 FIXME("Unsupported attribute %#Ix.\n", attrs->attrs[i].attr);
624 break;
625 }
626 }
627 }
628 }
629
630 if (inherit) nt_flags |= PROCESS_CREATE_FLAGS_INHERIT_HANDLES;
633 if (flags & CREATE_SUSPENDED) nt_flags |= PROCESS_CREATE_FLAGS_SUSPENDED;
634
635 status = create_nt_process( token, debug, process_attr, thread_attr,
636 nt_flags, params, &rtl_info, parent, machine, handle_list, job_list );
637 switch (status)
638 {
639 case STATUS_SUCCESS:
640 break;
644 TRACE( "starting %s as Win16/DOS binary\n", debugstr_w(app_name) );
645 status = create_vdm_process( token, debug, process_attr, thread_attr,
646 nt_flags, params, &rtl_info );
647 break;
649 /* check for .com or .bat extension */
650 if (!(p = wcsrchr( app_name, '.' ))) break;
651 if (!wcsicmp( p, L".com" ) || !wcsicmp( p, L".pif" ))
652 {
653 TRACE( "starting %s as DOS binary\n", debugstr_w(app_name) );
654 status = create_vdm_process( token, debug, process_attr, thread_attr,
655 nt_flags, params, &rtl_info );
656 }
657 else if (!wcsicmp( p, L".bat" ) || !wcsicmp( p, L".cmd" ))
658 {
659 TRACE( "starting %s as batch binary\n", debugstr_w(app_name) );
660 status = create_cmd_process( token, debug, process_attr, thread_attr,
661 nt_flags, params, &rtl_info );
662 }
663 break;
664 }
665
666 if (!status)
667 {
668 info->hProcess = rtl_info.Process;
669 info->hThread = rtl_info.Thread;
670 info->dwProcessId = HandleToUlong( rtl_info.ClientId.UniqueProcess );
671 info->dwThreadId = HandleToUlong( rtl_info.ClientId.UniqueThread );
672 if (!(flags & CREATE_SUSPENDED)) NtResumeThread( rtl_info.Thread, NULL );
673 TRACE( "started process pid %04lx tid %04lx\n", info->dwProcessId, info->dwThreadId );
674 }
675
676 done:
678 if (tidy_cmdline != cmd_line) HeapFree( GetProcessHeap(), 0, tidy_cmdline );
679 return set_ntstatus( status );
680}
#define WARN(fmt,...)
Definition: precomp.h:61
#define HandleToUlong(h)
Definition: basetsd.h:79
#define STATUS_INVALID_HANDLE
Definition: d3dkmdt.h:40
NTSTATUS NTAPI DbgUiConnectToDbg(VOID)
Definition: dbgui.c:25
HANDLE NTAPI DbgUiGetThreadDebugObject(VOID)
Definition: dbgui.c:333
#define wcsrchr
Definition: compat.h:16
#define wcsicmp
Definition: compat.h:15
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
static NTSTATUS create_cmd_process(HANDLE token, HANDLE debug, SECURITY_ATTRIBUTES *psa, SECURITY_ATTRIBUTES *tsa, DWORD flags, RTL_USER_PROCESS_PARAMETERS *params, RTL_USER_PROCESS_INFORMATION *info)
Definition: process.c:392
static NTSTATUS create_vdm_process(HANDLE token, HANDLE debug, SECURITY_ATTRIBUTES *psa, SECURITY_ATTRIBUTES *tsa, DWORD flags, RTL_USER_PROCESS_PARAMETERS *params, RTL_USER_PROCESS_INFORMATION *info)
Definition: process.c:361
static RTL_USER_PROCESS_PARAMETERS * create_process_params(const WCHAR *filename, const WCHAR *cmdline, const WCHAR *cur_dir, void *env, DWORD flags, const STARTUPINFOW *startup)
Definition: process.c:141
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define PROCESS_CREATE_FLAGS_BREAKAWAY
Definition: pstypes.h:92
#define PROCESS_CREATE_FLAGS_NO_DEBUG_INHERIT
Definition: pstypes.h:93
#define debugstr_w
Definition: kernel32.h:32
static LPCWSTR name
Definition: process.c:75
NTSYSAPI NTSTATUS NTAPI RtlDestroyProcessParameters(_In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters)
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
NTSTATUS NTAPI NtResumeThread(IN HANDLE ThreadHandle, OUT PULONG SuspendCount OPTIONAL)
Definition: state.c:290
#define STATUS_INVALID_IMAGE_WIN_16
Definition: ntstatus.h:541
#define STATUS_INVALID_IMAGE_NE_FORMAT
Definition: ntstatus.h:519
#define STATUS_INVALID_IMAGE_NOT_MZ
Definition: ntstatus.h:539
#define STATUS_INVALID_IMAGE_PROTECT
Definition: ntstatus.h:540
unsigned short USHORT
Definition: pedump.c:61
#define get_file_name
Definition: regproc.h:51
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE UniqueThread
Definition: compat.h:826
HANDLE UniqueProcess
Definition: compat.h:825
struct proc_thread_attr attrs[1]
Definition: process.c:251
Definition: name.c:39
HANDLE reference
Definition: kernelbase.h:35
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_NOT_A_DIRECTORY
Definition: udferr_usr.h:169
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define CREATE_BREAKAWAY_FROM_JOB
Definition: winbase.h:219
#define PROFILE_SERVER
Definition: winbase.h:225
#define REALTIME_PRIORITY_CLASS
Definition: winbase.h:194
#define HIGH_PRIORITY_CLASS
Definition: winbase.h:193
#define CREATE_DEFAULT_ERROR_MODE
Definition: winbase.h:221
#define PROFILE_KERNEL
Definition: winbase.h:224
#define CREATE_SUSPENDED
Definition: winbase.h:188
#define PROC_THREAD_ATTRIBUTE_PARENT_PROCESS
Definition: winbase.h:1472
#define DEBUG_ONLY_THIS_PROCESS
Definition: winbase.h:187
#define PROC_THREAD_ATTRIBUTE_HANDLE_LIST
Definition: winbase.h:1471
#define PROFILE_USER
Definition: winbase.h:223
#define IDLE_PRIORITY_CLASS
Definition: winbase.h:192
#define DEBUG_PROCESS
Definition: winbase.h:186

Referenced by CreateProcessAsUserW(), CreateProcessInternalA(), and CreateProcessW().

◆ CreateProcessW()

BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW ( const WCHAR app_name,
WCHAR cmd_line,
SECURITY_ATTRIBUTES process_attr,
SECURITY_ATTRIBUTES thread_attr,
BOOL  inherit,
DWORD  flags,
void env,
const WCHAR cur_dir,
STARTUPINFOW startup_info,
PROCESS_INFORMATION info 
)

Definition at line 700 of file process.c.

705{
706 return CreateProcessInternalW( NULL, app_name, cmd_line, process_attr, thread_attr,
707 inherit, flags, env, cur_dir, startup_info, info, NULL );
708}

◆ DeleteProcThreadAttributeList()

void WINAPI DECLSPEC_HOTPATCH DeleteProcThreadAttributeList ( struct _PROC_THREAD_ATTRIBUTE_LIST list)

Definition at line 1860 of file process.c.

1861{
1862 return;
1863}

◆ DuplicateHandle()

BOOL WINAPI DECLSPEC_HOTPATCH DuplicateHandle ( HANDLE  source_process,
HANDLE  source,
HANDLE  dest_process,
HANDLE dest,
DWORD  access,
BOOL  inherit,
DWORD  options 
)

Definition at line 734 of file process.c.

737{
738 return set_ntstatus( NtDuplicateObject( source_process, source, dest_process, dest,
739 access, inherit ? OBJ_INHERIT : 0, options ));
740}
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
#define OBJ_INHERIT
Definition: winternl.h:225
static char * dest
Definition: rtl.c:135
NTSTATUS NTAPI NtDuplicateObject(IN HANDLE SourceProcessHandle, IN HANDLE SourceHandle, IN HANDLE TargetProcessHandle OPTIONAL, OUT PHANDLE TargetHandle OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG HandleAttributes, IN ULONG Options)
Definition: obhandle.c:3410

Referenced by test_Console(), test_DuplicateHandle(), test_Handles(), and test_TerminateProcess().

◆ ExpandEnvironmentStringsA()

DWORD WINAPI DECLSPEC_HOTPATCH ExpandEnvironmentStringsA ( LPCSTR  src,
LPSTR  dst,
DWORD  count 
)

Definition at line 1449 of file process.c.

1450{
1451 UNICODE_STRING us_src;
1452 PWSTR dstW = NULL;
1453 DWORD count_neededW;
1454 DWORD count_neededA = 0;
1455
1457
1458 /* We always need to call ExpandEnvironmentStringsW, since we need the result to calculate the needed buffer size */
1459 count_neededW = ExpandEnvironmentStringsW( us_src.Buffer, NULL, 0 );
1460 if (!(dstW = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, count_neededW * sizeof(WCHAR) ))) goto cleanup;
1461 count_neededW = ExpandEnvironmentStringsW( us_src.Buffer, dstW, count_neededW );
1462
1463 /* Calculate needed buffer */
1464 count_neededA = WideCharToMultiByte( CP_ACP, 0, dstW, count_neededW, NULL, 0, NULL, NULL );
1465
1466 /* If provided buffer is enough, do actual conversion */
1467 if (count > count_neededA)
1468 count_neededA = WideCharToMultiByte( CP_ACP, 0, dstW, count_neededW, dst, count, NULL, NULL );
1469 else if(dst)
1470 *dst = 0;
1471
1472cleanup:
1473 RtlFreeUnicodeString( &us_src );
1474 HeapFree( GetProcessHeap(), 0, dstW );
1475
1476 if (count_neededA >= count) /* When the buffer is too small, native over-reports by one byte */
1477 return count_neededA + 1;
1478 return count_neededA;
1479}
#define HeapAlloc
Definition: compat.h:733
#define WideCharToMultiByte
Definition: compat.h:111
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static void cleanup(void)
Definition: main.c:1335
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
uint16_t * PWSTR
Definition: typedefs.h:56

Referenced by DosCreateProcess().

◆ ExpandEnvironmentStringsW()

DWORD WINAPI DECLSPEC_HOTPATCH ExpandEnvironmentStringsW ( LPCWSTR  src,
LPWSTR  dst,
DWORD  len 
)

Definition at line 1485 of file process.c.

1486{
1487 UNICODE_STRING us_src, us_dst;
1489 DWORD res;
1490
1491 TRACE( "(%s %p %lu)\n", debugstr_w(src), dst, len );
1492
1493 RtlInitUnicodeString( &us_src, src );
1494
1495 /* make sure we don't overflow the maximum UNICODE_STRING size */
1497
1498 us_dst.Length = 0;
1499 us_dst.MaximumLength = len * sizeof(WCHAR);
1500 us_dst.Buffer = dst;
1501
1502 res = 0;
1503 status = RtlExpandEnvironmentStrings_U( NULL, &us_src, &us_dst, &res );
1504 res /= sizeof(WCHAR);
1506 {
1507 if(!set_ntstatus( status ))
1508 return 0;
1509 }
1510 return res;
1511}
GLuint res
Definition: glext.h:9613
NTSYSAPI NTSTATUS WINAPI RtlExpandEnvironmentStrings_U(PCWSTR, const UNICODE_STRING *, UNICODE_STRING *, ULONG *)
#define min(a, b)
Definition: monoChain.cc:55
#define UNICODE_STRING_MAX_CHARS
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69

◆ find_exe_file()

static BOOL find_exe_file ( const WCHAR name,
WCHAR buffer,
DWORD  buflen 
)
static

Definition at line 49 of file process.c.

50{
51 WCHAR *load_path;
52 BOOL ret;
53
54 if (!set_ntstatus( RtlGetExePath( name, &load_path ))) return FALSE;
55
56 TRACE( "looking for %s in %s\n", debugstr_w(name), debugstr_w(load_path) );
57
58 ret = (SearchPathW( load_path, name, L".exe", buflen, buffer, NULL ) ||
59 /* not found, try without extension in case it is a Unix app */
60 SearchPathW( load_path, name, NULL, buflen, buffer, NULL ));
61
62 if (ret) /* make sure it can be opened, SearchPathW also returns directories */
63 {
65 NULL, OPEN_EXISTING, 0, 0 );
67 }
68 RtlReleasePath( load_path );
69 return ret;
70}
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI SearchPathW(IN LPCWSTR lpPath OPTIONAL, IN LPCWSTR lpFileName, IN LPCWSTR lpExtension OPTIONAL, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart OPTIONAL)
Definition: path.c:1298
#define FILE_SHARE_DELETE
Definition: nt_native.h:682

Referenced by get_file_name().

◆ FreeEnvironmentStringsW()

BOOL WINAPI DECLSPEC_HOTPATCH FreeEnvironmentStringsW ( LPWSTR  ptr)

Definition at line 1685 of file process.c.

1686{
1687 return HeapFree( GetProcessHeap(), 0, ptr );
1688}
static PVOID ptr
Definition: dispmode.c:27

Referenced by doChild().

◆ get_env_length()

static SIZE_T get_env_length ( const WCHAR env)
inlinestatic

Definition at line 1439 of file process.c.

1440{
1441 const WCHAR *end = env;
1442 while (*end) end += lstrlenW(end) + 1;
1443 return end + 1 - env;
1444}
GLuint GLuint end
Definition: gl.h:1545

Referenced by GetEnvironmentStringsA(), and GetEnvironmentStringsW().

◆ get_file_name()

static WCHAR * get_file_name ( WCHAR cmdline,
WCHAR buffer,
DWORD  buflen 
)
static

Definition at line 80 of file process.c.

81{
82 WCHAR *name, *pos, *first_space, *ret = NULL;
83 const WCHAR *p;
84
85 /* first check for a quoted file name */
86
87 if (cmdline[0] == '"' && (p = wcschr( cmdline + 1, '"' )))
88 {
89 int len = p - cmdline - 1;
90 /* extract the quoted portion as file name */
91 if (!(name = RtlAllocateHeap( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return NULL;
92 memcpy( name, cmdline + 1, len * sizeof(WCHAR) );
93 name[len] = 0;
94
95 if (!find_exe_file( name, buffer, buflen )) goto done;
96 ret = cmdline; /* no change necessary */
97 goto done;
98 }
99
100 /* now try the command-line word by word */
101
102 if (!(name = RtlAllocateHeap( GetProcessHeap(), 0, (lstrlenW(cmdline) + 1) * sizeof(WCHAR) )))
103 return NULL;
104 pos = name;
105 p = cmdline;
106 first_space = NULL;
107
108 for (;;)
109 {
110 while (*p && *p != ' ' && *p != '\t') *pos++ = *p++;
111 *pos = 0;
112 if (find_exe_file( name, buffer, buflen ))
113 {
114 ret = cmdline;
115 break;
116 }
117 if (!first_space) first_space = pos;
118 if (!(*pos++ = *p++)) break;
119 }
120
121 if (!ret)
122 {
124 }
125 else if (first_space) /* build a new command-line with quotes */
126 {
127 if (!(ret = HeapAlloc( GetProcessHeap(), 0, (lstrlenW(cmdline) + 3) * sizeof(WCHAR) )))
128 goto done;
129 swprintf( ret, lstrlenW(cmdline) + 3, L"\"%s\"%s", name, p );
130 }
131
132 done:
134 return ret;
135}
#define wcschr
Definition: compat.h:17
static BOOL find_exe_file(const WCHAR *name, WCHAR *buffer, DWORD buflen)
Definition: process.c:49
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79

◆ GetApplicationRestartSettings()

HRESULT WINAPI GetApplicationRestartSettings ( HANDLE  process,
WCHAR cmdline,
DWORD size,
DWORD flags 
)

Definition at line 746 of file process.c.

748{
749 FIXME( "%p, %p, %p, %p)\n", process, cmdline, size, flags );
750 return E_NOTIMPL;
751}
#define E_NOTIMPL
Definition: ddrawi.h:99
GLsizeiptr size
Definition: glext.h:5919

◆ GetCommandLineA()

LPSTR WINAPI GetCommandLineA ( void  )

Definition at line 1329 of file process.c.

1330{
1331 return command_lineA;
1332}
static char * command_lineA
Definition: process.c:1300

Referenced by __acrt_initialize_command_line(), crt_process_init(), DllMain(), doChild(), main(), START_TEST(), test__get_narrow_winmain_command_line(), and wmain().

◆ GetCommandLineW()

◆ GetEnvironmentStringsA()

LPSTR WINAPI DECLSPEC_HOTPATCH GetEnvironmentStringsA ( void  )

Definition at line 1518 of file process.c.

1519{
1520 LPWSTR env;
1521 LPSTR ret;
1522 SIZE_T lenA, lenW;
1523
1525 env = NtCurrentTeb()->Peb->ProcessParameters->Environment;
1526 lenW = get_env_length( env );
1527 lenA = WideCharToMultiByte( CP_ACP, 0, env, lenW, NULL, 0, NULL, NULL );
1528 if ((ret = HeapAlloc( GetProcessHeap(), 0, lenA )))
1529 WideCharToMultiByte( CP_ACP, 0, env, lenW, ret, lenA, NULL, NULL );
1531 return ret;
1532}
static SIZE_T get_env_length(const WCHAR *env)
Definition: process.c:1439
NTSYSAPI void WINAPI RtlReleasePebLock(void)
Definition: libsupp.c:84
NTSYSAPI void WINAPI RtlAcquirePebLock(void)
Definition: libsupp.c:74
ULONG_PTR SIZE_T
Definition: typedefs.h:80
char * LPSTR
Definition: xmlstorage.h:182
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by doChild(), and test_Environment().

◆ GetEnvironmentStringsW()

◆ GetEnvironmentVariableA()

DWORD WINAPI DECLSPEC_HOTPATCH GetEnvironmentVariableA ( LPCSTR  name,
LPSTR  value,
DWORD  size 
)

Definition at line 1621 of file process.c.

1622{
1623 UNICODE_STRING us_name, us_value;
1624 PWSTR valueW;
1626 DWORD len, ret;
1627
1628 /* limit the size to sane values */
1629 size = min( size, 32767 );
1630 if (!(valueW = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) return 0;
1631
1633 us_value.Length = 0;
1634 us_value.MaximumLength = (size ? size - 1 : 0) * sizeof(WCHAR);
1635 us_value.Buffer = valueW;
1636
1637 status = RtlQueryEnvironmentVariable_U( NULL, &us_name, &us_value );
1638 len = us_value.Length / sizeof(WCHAR);
1639 if (status == STATUS_BUFFER_TOO_SMALL) ret = len + 1;
1640 else if (!set_ntstatus( status )) ret = 0;
1641 else if (!size) ret = len + 1;
1642 else
1643 {
1644 if (len) WideCharToMultiByte( CP_ACP, 0, valueW, len + 1, value, size, NULL, NULL );
1645 value[len] = 0;
1646 ret = len;
1647 }
1648
1649 RtlFreeUnicodeString( &us_name );
1651 return ret;
1652}
static const WCHAR valueW[]
Definition: object.c:48
NTSYSAPI NTSTATUS NTAPI RtlQueryEnvironmentVariable_U(_In_opt_ PWSTR Environment, _In_ PCUNICODE_STRING Name, _Out_ PUNICODE_STRING Value)
Definition: pdh_main.c:96

◆ GetEnvironmentVariableW()

DWORD WINAPI DECLSPEC_HOTPATCH GetEnvironmentVariableW ( LPCWSTR  name,
LPWSTR  val,
DWORD  size 
)

Definition at line 1658 of file process.c.

1659{
1660 UNICODE_STRING us_name, us_value;
1662 DWORD len;
1663
1664 TRACE( "(%s %p %lu)\n", debugstr_w(name), val, size );
1665
1666 RtlInitUnicodeString( &us_name, name );
1667 us_value.Length = 0;
1668 us_value.MaximumLength = (size ? size - 1 : 0) * sizeof(WCHAR);
1669 us_value.Buffer = val;
1670
1671 status = RtlQueryEnvironmentVariable_U( NULL, &us_name, &us_value );
1672 len = us_value.Length / sizeof(WCHAR);
1673 if (status == STATUS_BUFFER_TOO_SMALL) return len + 1;
1674 if (!set_ntstatus( status )) return 0;
1675 if (!size) return len + 1;
1676 val[len] = 0;
1677 return len;
1678}
GLuint GLfloat * val
Definition: glext.h:7180

◆ GetErrorMode()

UINT WINAPI DECLSPEC_HOTPATCH GetErrorMode ( void  )

Definition at line 775 of file process.c.

776{
777 UINT mode;
778
780 &mode, sizeof(mode), NULL );
781 return mode;
782}
#define GetCurrentProcess()
Definition: compat.h:759
GLenum mode
Definition: glext.h:6217
@ ProcessDefaultHardErrorMode
Definition: winternl.h:868
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59

Referenced by my_LoadLibraryA(), my_LoadLibraryExA(), my_LoadLibraryExW(), my_LoadLibraryW(), SetErrorMode(), START_TEST(), test_LoadLibraryA(), test_LoadLibraryExA(), test_LoadLibraryExW(), test_LoadLibraryW(), and UnhandledExceptionFilter().

◆ GetExitCodeProcess()

BOOL WINAPI DECLSPEC_HOTPATCH GetExitCodeProcess ( HANDLE  process,
LPDWORD  exit_code 
)

Definition at line 788 of file process.c.

789{
792
794 if (!status && exit_code) *exit_code = pbi.ExitStatus;
795 return set_ntstatus( status );
796}
@ ProcessBasicInformation
Definition: cicbase.cpp:44
static UINT exit_code
Definition: process.c:78
_Inout_ PERBANDINFO * pbi
Definition: winddi.h:3917

Referenced by do_spawnT(), test_ExitCode(), test_Handles(), and test_TerminateJobObject().

◆ GetHandleInformation()

BOOL WINAPI DECLSPEC_HOTPATCH GetHandleInformation ( HANDLE  handle,
DWORD flags 
)

Definition at line 802 of file process.c.

803{
804 OBJECT_HANDLE_FLAG_INFORMATION info;
805
806 if (!set_ntstatus( NtQueryObject( handle, ObjectHandleFlagInformation, &info, sizeof(info), NULL )))
807 return FALSE;
808
809 if (flags)
810 {
811 *flags = 0;
812 if (info.Inherit) *flags |= HANDLE_FLAG_INHERIT;
813 if (info.ProtectFromClose) *flags |= HANDLE_FLAG_PROTECT_FROM_CLOSE;
814 }
815 return TRUE;
816}
NTSTATUS NtQueryObject(IN HANDLE Handle, IN OBJECT_INFO_CLASS ObjectInformationClass, OUT PVOID ObjectInformation, IN ULONG ObjectInformationLength, OUT PULONG ReturnLength)
#define HANDLE_FLAG_PROTECT_FROM_CLOSE
Definition: winbase.h:298
#define HANDLE_FLAG_INHERIT
Definition: winbase.h:297

Referenced by do_spawnT(), and test_DuplicateHandle().

◆ GetPriorityClass()

DWORD WINAPI DECLSPEC_HOTPATCH GetPriorityClass ( HANDLE  process)

Definition at line 822 of file process.c.

823{
825
827 &pbi, sizeof(pbi), NULL )))
828 return 0;
829
830 switch (pbi.BasePriority)
831 {
838 default: return 0;
839 }
840}
#define PROCESS_PRIOCLASS_REALTIME
Definition: winternl.h:1318
#define PROCESS_PRIOCLASS_ABOVE_NORMAL
Definition: winternl.h:1320
#define PROCESS_PRIOCLASS_NORMAL
Definition: winternl.h:1316
#define PROCESS_PRIOCLASS_HIGH
Definition: winternl.h:1317
#define PROCESS_PRIOCLASS_IDLE
Definition: winternl.h:1315
#define PROCESS_PRIOCLASS_BELOW_NORMAL
Definition: winternl.h:1319
#define NORMAL_PRIORITY_CLASS
Definition: winbase.h:191
#define BELOW_NORMAL_PRIORITY_CLASS
Definition: winbase.h:200
#define ABOVE_NORMAL_PRIORITY_CLASS
Definition: winbase.h:201

◆ GetProcessGroupAffinity()

BOOL WINAPI DECLSPEC_HOTPATCH GetProcessGroupAffinity ( HANDLE  process,
USHORT count,
USHORT array 
)

Definition at line 846 of file process.c.

847{
848 FIXME( "(%p,%p,%p): stub\n", process, count, array );
850 return FALSE;
851}

◆ GetProcessHandleCount()

BOOL WINAPI DECLSPEC_HOTPATCH GetProcessHandleCount ( HANDLE  process,
DWORD count 
)

Definition at line 857 of file process.c.

858{
860 count, sizeof(*count), NULL ));
861}
@ ProcessHandleCount
Definition: winternl.h:876

◆ GetProcessId()

DWORD WINAPI DECLSPEC_HOTPATCH GetProcessId ( HANDLE  process)

Definition at line 876 of file process.c.

877{
879
881 &pbi, sizeof(pbi), NULL )))
882 return 0;
883 return pbi.UniqueProcessId;
884}

◆ GetProcessInformation()

BOOL WINAPI GetProcessInformation ( HANDLE  process,
PROCESS_INFORMATION_CLASS  info_class,
void data,
DWORD  size 
)

Definition at line 1036 of file process.c.

1037{
1038 switch (info_class)
1039 {
1040 case ProcessMachineTypeInfo:
1041 {
1042 PROCESS_MACHINE_INFORMATION *mi = data;
1043 SYSTEM_SUPPORTED_PROCESSOR_ARCHITECTURES_INFORMATION machines[8];
1045 ULONG i;
1046
1047 if (size != sizeof(*mi))
1048 {
1050 return FALSE;
1051 }
1052
1053 status = NtQuerySystemInformationEx( SystemSupportedProcessorArchitectures, &process, sizeof(process),
1054 machines, sizeof(machines), NULL );
1055 if (status) return set_ntstatus( status );
1056
1057 for (i = 0; machines[i].Machine; i++)
1058 {
1059 if (machines[i].Process)
1060 {
1061 mi->ProcessMachine = machines[i].Machine;
1062 mi->Res0 = 0;
1063 mi->MachineAttributes = 0;
1064 if (machines[i].KernelMode)
1065 mi->MachineAttributes |= KernelEnabled;
1066 if (machines[i].UserMode)
1067 mi->MachineAttributes |= UserEnabled;
1068 if (machines[i].WoW64Container)
1069 mi->MachineAttributes |= Wow64Container;
1070
1071 return TRUE;
1072 }
1073 }
1074
1075 break;
1076 }
1077 default:
1078 FIXME("Unsupported information class %d.\n", info_class);
1079 }
1080
1081 return FALSE;
1082}
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
NTSYSAPI NTSTATUS WINAPI NtQuerySystemInformationEx(SYSTEM_INFORMATION_CLASS, void *, ULONG, void *, ULONG, ULONG *)
static PIO_STATUS_BLOCK void ULONG FS_INFORMATION_CLASS info_class
Definition: pipe.c:76
static MONITORINFO mi
Definition: win.c:7338
#define KernelMode
Definition: asm.h:38
#define UserMode
Definition: asm.h:39
#define ERROR_BAD_LENGTH
Definition: winerror.h:127

◆ GetProcessMitigationPolicy()

BOOL WINAPI GetProcessMitigationPolicy ( HANDLE  process,
PROCESS_MITIGATION_POLICY  policy,
void buffer,
SIZE_T  length 
)

Definition at line 890 of file process.c.

892{
893 FIXME( "(%p, %u, %p, %Iu): stub\n", process, policy, buffer, length );
894 return TRUE;
895}
WINBASEAPI _Check_return_ _Out_ AppPolicyProcessTerminationMethod * policy
Definition: appmodel.h:47
GLuint GLsizei GLsizei * length
Definition: glext.h:6040

◆ GetProcessPriorityBoost()

BOOL WINAPI DECLSPEC_HOTPATCH GetProcessPriorityBoost ( HANDLE  process,
PBOOL  disable 
)

Definition at line 901 of file process.c.

902{
903 FIXME( "(%p,%p): semi-stub\n", process, disable );
904 *disable = FALSE; /* report that no boost is present */
905 return TRUE;
906}
int disable
Definition: msacm.c:1365

◆ GetProcessShutdownParameters()

BOOL WINAPI DECLSPEC_HOTPATCH GetProcessShutdownParameters ( LPDWORD  level,
LPDWORD  flags 
)

Definition at line 912 of file process.c.

913{
916 return TRUE;
917}
static DWORD shutdown_flags
Definition: process.c:38
static DWORD shutdown_priority
Definition: process.c:39
GLint level
Definition: gl.h:1546

◆ GetProcessTimes()

BOOL WINAPI DECLSPEC_HOTPATCH GetProcessTimes ( HANDLE  process,
FILETIME create,
FILETIME exit,
FILETIME kernel,
FILETIME user 
)

Definition at line 923 of file process.c.

925{
927
929 return FALSE;
930
931 create->dwLowDateTime = time.CreateTime.u.LowPart;
932 create->dwHighDateTime = time.CreateTime.u.HighPart;
933 exit->dwLowDateTime = time.ExitTime.u.LowPart;
934 exit->dwHighDateTime = time.ExitTime.u.HighPart;
935 kernel->dwLowDateTime = time.KernelTime.u.LowPart;
936 kernel->dwHighDateTime = time.KernelTime.u.HighPart;
937 user->dwLowDateTime = time.UserTime.u.LowPart;
938 user->dwHighDateTime = time.UserTime.u.HighPart;
939 return TRUE;
940}
void user(int argc, const char *argv[])
Definition: cmds.c:1350
@ ProcessTimes
Definition: winternl.h:860
__u16 time
Definition: mkdosfs.c:8
static const struct access_res create[16]
Definition: package.c:7505
#define exit(n)
Definition: config.h:202
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65

◆ GetProcessVersion()

DWORD WINAPI DECLSPEC_HOTPATCH GetProcessVersion ( DWORD  pid)

Definition at line 946 of file process.c.

947{
951
952 if (pid && pid != GetCurrentProcessId())
953 {
954 if (!(process = OpenProcess( PROCESS_QUERY_INFORMATION, FALSE, pid ))) return 0;
957 }
959 &info, sizeof(info), NULL );
960
961 if (!set_ntstatus( status )) return 0;
962 return MAKELONG( info.MinorSubsystemVersion, info.MajorSubsystemVersion );
963}
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:167
@ ProcessImageInformation
Definition: winternl.h:892
#define MAKELONG(a, b)
Definition: typedefs.h:249
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3837

Referenced by test_GetProcessVersion().

◆ GetProcessWorkingSetSizeEx()

BOOL WINAPI DECLSPEC_HOTPATCH GetProcessWorkingSetSizeEx ( HANDLE  process,
SIZE_T minset,
SIZE_T maxset,
DWORD flags 
)

Definition at line 969 of file process.c.

971{
972 FIXME( "(%p,%p,%p,%p): stub\n", process, minset, maxset, flags );
973 /* 32 MB working set size */
974 if (minset) *minset = 32*1024*1024;
975 if (maxset) *maxset = 32*1024*1024;
977 return TRUE;
978}
#define QUOTA_LIMITS_HARDWS_MIN_DISABLE
#define QUOTA_LIMITS_HARDWS_MAX_DISABLE

◆ GetStartupInfoW()

void WINAPI DECLSPEC_HOTPATCH GetStartupInfoW ( STARTUPINFOW info)

Definition at line 1347 of file process.c.

1348{
1350
1352
1354
1355 info->cb = sizeof(*info);
1356 info->lpReserved = NULL;
1357 info->lpDesktop = params->Desktop.Buffer;
1358 info->lpTitle = params->WindowTitle.Buffer;
1359 info->dwX = params->dwX;
1360 info->dwY = params->dwY;
1361 info->dwXSize = params->dwXSize;
1362 info->dwYSize = params->dwYSize;
1363 info->dwXCountChars = params->dwXCountChars;
1364 info->dwYCountChars = params->dwYCountChars;
1365 info->dwFillAttribute = params->dwFillAttribute;
1366 info->dwFlags = params->dwFlags;
1367 info->wShowWindow = params->wShowWindow;
1368 info->cbReserved2 = params->RuntimeInfo.MaximumLength;
1369 info->lpReserved2 = params->RuntimeInfo.MaximumLength ? (void *)params->RuntimeInfo.Buffer : NULL;
1370 if (params->dwFlags & STARTF_USESTDHANDLES)
1371 {
1372 info->hStdInput = params->hStdInput;
1373 info->hStdOutput = params->hStdOutput;
1374 info->hStdError = params->hStdError;
1375 }
1377}
NTSYSAPI PEB *WINAPI RtlGetCurrentPeb(void)
Definition: libsupp.c:65

Referenced by doChild().

◆ GetStdHandle()

HANDLE WINAPI DECLSPEC_HOTPATCH GetStdHandle ( DWORD  std_handle)

Definition at line 1383 of file process.c.

1384{
1385 switch (std_handle)
1386 {
1387 case STD_INPUT_HANDLE: return NtCurrentTeb()->Peb->ProcessParameters->hStdInput;
1388 case STD_OUTPUT_HANDLE: return NtCurrentTeb()->Peb->ProcessParameters->hStdOutput;
1389 case STD_ERROR_HANDLE: return NtCurrentTeb()->Peb->ProcessParameters->hStdError;
1390 }
1392 return INVALID_HANDLE_VALUE;
1393}
#define ERROR_INVALID_HANDLE
Definition: compat.h:98

Referenced by doChild(), test_DetachConsoleHandles(), test_DetachStdHandles(), and test_Handles().

◆ init_startup_info()

void init_startup_info ( RTL_USER_PROCESS_PARAMETERS params)

Definition at line 1306 of file process.c.

1307{
1309
1310 command_lineW = params->CommandLine.Buffer;
1311 if (!RtlUnicodeStringToAnsiString( &ansi, &params->CommandLine, TRUE )) command_lineA = ansi.Buffer;
1312}
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
static UINT WPARAM LPARAM BOOL ansi
Definition: misc.c:135

Referenced by DllMain().

◆ InitializeProcThreadAttributeList()

BOOL WINAPI DECLSPEC_HOTPATCH InitializeProcThreadAttributeList ( struct _PROC_THREAD_ATTRIBUTE_LIST list,
DWORD  count,
DWORD  flags,
SIZE_T size 
)

Definition at line 1753 of file process.c.

1755{
1756 SIZE_T needed;
1757 BOOL ret = FALSE;
1758
1759 TRACE( "(%p %ld %lx %p)\n", list, count, flags, size );
1760
1761 needed = FIELD_OFFSET( struct _PROC_THREAD_ATTRIBUTE_LIST, attrs[count] );
1762 if (list && *size >= needed)
1763 {
1764 list->mask = 0;
1765 list->size = count;
1766 list->count = 0;
1767 list->unk = 0;
1768 ret = TRUE;
1769 }
1771
1772 *size = needed;
1773 return ret;
1774}
Definition: list.h:37
size_type size() const
Definition: _list.h:379
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Referenced by alloc_console(), and create_pseudo_console().

◆ IsProcessInJob()

BOOL WINAPI DECLSPEC_HOTPATCH IsProcessInJob ( HANDLE  process,
HANDLE  job,
BOOL result 
)

Definition at line 984 of file process.c.

985{
987
988 switch (status)
989 {
991 *result = TRUE;
992 return TRUE;
994 *result = FALSE;
995 return TRUE;
996 default:
997 return set_ntstatus( status );
998 }
999}
GLuint64EXT * result
Definition: glext.h:11304
static HANDLE job
Definition: process.c:77
NTSTATUS NTAPI NtIsProcessInJob(IN HANDLE ProcessHandle, IN HANDLE JobHandle OPTIONAL)
Definition: job.c:361
#define STATUS_PROCESS_IN_JOB
Definition: ntstatus.h:108
#define STATUS_PROCESS_NOT_IN_JOB
Definition: ntstatus.h:107

◆ IsProcessorFeaturePresent()

BOOL WINAPI DECLSPEC_HOTPATCH IsProcessorFeaturePresent ( DWORD  feature)

Definition at line 1005 of file process.c.

1006{
1007 return RtlIsProcessorFeaturePresent( feature );
1008}
INTERNETFEATURELIST feature
Definition: misc.c:1719

◆ IsWow64Process()

BOOL WINAPI DECLSPEC_HOTPATCH IsWow64Process ( HANDLE  process,
PBOOL  wow64 
)

Definition at line 1023 of file process.c.

1024{
1025 ULONG_PTR pbi;
1027
1029 if (!status) *wow64 = !!pbi;
1030 return set_ntstatus( status );
1031}
@ ProcessWow64Information
Definition: cicbase.cpp:46
static BOOL wow64
Definition: psapi_main.c:44

◆ IsWow64Process2()

BOOL WINAPI DECLSPEC_HOTPATCH IsWow64Process2 ( HANDLE  process,
USHORT machine,
USHORT native_machine 
)

Definition at line 1014 of file process.c.

1015{
1016 return set_ntstatus( RtlWow64GetProcessMachines( process, machine, native_machine ));
1017}

◆ kernelbase_GetCurrentProcess()

HANDLE WINAPI kernelbase_GetCurrentProcess ( void  )

Definition at line 757 of file process.c.

758{
759 return (HANDLE)~(ULONG_PTR)0;
760}

◆ kernelbase_GetCurrentProcessId()

DWORD WINAPI kernelbase_GetCurrentProcessId ( void  )

Definition at line 766 of file process.c.

767{
769}
#define HandleToULong(h)
Definition: basetsd.h:95
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1151

◆ kernelbase_GetProcessHeap()

HANDLE WINAPI kernelbase_GetProcessHeap ( void  )

Definition at line 867 of file process.c.

868{
869 return NtCurrentTeb()->Peb->ProcessHeap;
870}

◆ OpenProcess()

HANDLE WINAPI DECLSPEC_HOTPATCH OpenProcess ( DWORD  access,
BOOL  inherit,
DWORD  id 
)

Definition at line 1088 of file process.c.

1089{
1090 HANDLE handle;
1092 CLIENT_ID cid;
1093
1094 if (GetVersion() & 0x80000000) access = PROCESS_ALL_ACCESS;
1095
1096 attr.Length = sizeof(OBJECT_ATTRIBUTES);
1097 attr.RootDirectory = 0;
1098 attr.Attributes = inherit ? OBJ_INHERIT : 0;
1099 attr.ObjectName = NULL;
1100 attr.SecurityDescriptor = NULL;
1101 attr.SecurityQualityOfService = NULL;
1102
1103 cid.UniqueProcess = ULongToHandle(id);
1104 cid.UniqueThread = 0;
1105
1106 if (!set_ntstatus( NtOpenProcess( &handle, access, &attr, &cid ))) return NULL;
1107 return handle;
1108}
#define ULongToHandle(h)
Definition: basetsd.h:81
DWORD WINAPI GetVersion(void)
Definition: version.c:1458
static TfClientId cid
NTSTATUS NTAPI NtOpenProcess(OUT PHANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN PCLIENT_ID ClientId)
Definition: process.c:1440
struct _OBJECT_ATTRIBUTES OBJECT_ATTRIBUTES

◆ ProcessIdToSessionId()

BOOL WINAPI DECLSPEC_HOTPATCH ProcessIdToSessionId ( DWORD  pid,
DWORD id 
)

Definition at line 1114 of file process.c.

1115{
1118
1119 if (pid == GetCurrentProcessId())
1120 {
1121 *id = NtCurrentTeb()->Peb->SessionId;
1122 return TRUE;
1123 }
1127 return set_ntstatus( status );
1128}
@ ProcessSessionInformation
Definition: winternl.h:880
#define PROCESS_QUERY_LIMITED_INFORMATION
Definition: security.c:45

◆ QueryProcessCycleTime()

BOOL WINAPI DECLSPEC_HOTPATCH QueryProcessCycleTime ( HANDLE  process,
ULONG64 cycle 
)

Definition at line 1134 of file process.c.

1135{
1136 PROCESS_CYCLE_TIME_INFORMATION time;
1137
1139 return FALSE;
1140
1141 *cycle = time.AccumulatedCycles;
1142 return TRUE;
1143}
@ ProcessCycleTime
Definition: winternl.h:893

◆ SetEnvironmentStringsA()

BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentStringsA ( char env)

Definition at line 1555 of file process.c.

1556{
1557 WCHAR *envW;
1558 const char *p = env;
1559 DWORD len;
1560 BOOL ret;
1561
1562 for (p = env; *p; p += strlen( p ) + 1);
1563
1564 len = MultiByteToWideChar( CP_ACP, 0, env, p - env, NULL, 0 );
1565 if (!(envW = HeapAlloc( GetProcessHeap(), 0, len )))
1566 {
1568 return FALSE;
1569 }
1570 MultiByteToWideChar( CP_ACP, 0, env, p - env, envW, len );
1571 ret = SetEnvironmentStringsW( envW );
1572 HeapFree( GetProcessHeap(), 0, envW );
1573 return ret;
1574}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentStringsW(WCHAR *env)
Definition: process.c:1580

◆ SetEnvironmentStringsW()

BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentStringsW ( WCHAR env)

Definition at line 1580 of file process.c.

1581{
1582 WCHAR *p;
1583 WCHAR *new_env;
1585
1586 for (p = env; *p; p += wcslen( p ) + 1)
1587 {
1588 const WCHAR *eq = wcschr( p, '=' );
1589 if (!eq || eq == p)
1590 {
1592 return FALSE;
1593 }
1594 }
1595
1596 if ((status = RtlCreateEnvironment( FALSE, &new_env )))
1597 return set_ntstatus( status );
1598
1599 for (p = env; *p; p += wcslen( p ) + 1)
1600 {
1601 const WCHAR *eq = wcschr( p, '=' );
1603 var.Buffer = p;
1604 var.Length = (eq - p) * sizeof(WCHAR);
1605 RtlInitUnicodeString( &value, eq + 1 );
1606 if ((status = RtlSetEnvironmentVariable( &new_env, &var, &value )))
1607 {
1608 RtlDestroyEnvironment( new_env );
1609 return set_ntstatus( status );
1610 }
1611 }
1612
1613 RtlSetCurrentEnvironment( new_env, NULL );
1614 return TRUE;
1615}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSYSAPI void WINAPI RtlSetCurrentEnvironment(PWSTR, PWSTR *)
Definition: env.c:263
const char * var
Definition: shader.c:5666
#define eq(received, expected, label, type)
Definition: locale.c:144
NTSYSAPI NTSTATUS NTAPI RtlSetEnvironmentVariable(_In_z_ PWSTR *Environment, _In_ PUNICODE_STRING Name, _In_ PUNICODE_STRING Value)
NTSYSAPI NTSTATUS NTAPI RtlCreateEnvironment(_In_ BOOLEAN Inherit, _Out_ PWSTR *Environment)
NTSYSAPI VOID NTAPI RtlDestroyEnvironment(_In_ PWSTR Environment)

Referenced by SetEnvironmentStringsA().

◆ SetEnvironmentVariableA()

BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableA ( LPCSTR  name,
LPCSTR  value 
)

Definition at line 1694 of file process.c.

1695{
1696 UNICODE_STRING us_name, us_value;
1697 BOOL ret;
1698
1699 if (!name)
1700 {
1702 return FALSE;
1703 }
1704
1706 if (value)
1707 {
1709 ret = SetEnvironmentVariableW( us_name.Buffer, us_value.Buffer );
1710 RtlFreeUnicodeString( &us_value );
1711 }
1712 else ret = SetEnvironmentVariableW( us_name.Buffer, NULL );
1713 RtlFreeUnicodeString( &us_name );
1714 return ret;
1715}
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableW(LPCWSTR name, LPCWSTR value)
Definition: process.c:1721
#define ERROR_ENVVAR_NOT_FOUND
Definition: winerror.h:261

◆ SetEnvironmentVariableW()

BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableW ( LPCWSTR  name,
LPCWSTR  value 
)

Definition at line 1721 of file process.c.

1722{
1723 UNICODE_STRING us_name, us_value;
1725
1726 TRACE( "(%s %s)\n", debugstr_w(name), debugstr_w(value) );
1727
1728 if (!name)
1729 {
1731 return FALSE;
1732 }
1733
1734 RtlInitUnicodeString( &us_name, name );
1735 if (value)
1736 {
1737 RtlInitUnicodeString( &us_value, value );
1738 status = RtlSetEnvironmentVariable( NULL, &us_name, &us_value );
1739 }
1740 else status = RtlSetEnvironmentVariable( NULL, &us_name, NULL );
1741
1742 return set_ntstatus( status );
1743}

Referenced by SetEnvironmentVariableA().

◆ SetErrorMode()

UINT WINAPI DECLSPEC_HOTPATCH SetErrorMode ( UINT  mode)

Definition at line 1149 of file process.c.

1150{
1151 UINT old = GetErrorMode();
1152
1154 &mode, sizeof(mode) );
1155 return old;
1156}
UINT WINAPI DECLSPEC_HOTPATCH GetErrorMode(void)
Definition: process.c:775
NTSTATUS NTAPI NtSetInformationProcess(IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, IN PVOID ProcessInformation, IN ULONG ProcessInformationLength)
Definition: query.c:1161

◆ SetHandleCount()

UINT WINAPI DECLSPEC_HOTPATCH SetHandleCount ( UINT  count)

Definition at line 1162 of file process.c.

1163{
1164 return count;
1165}

◆ SetHandleInformation()

BOOL WINAPI DECLSPEC_HOTPATCH SetHandleInformation ( HANDLE  handle,
DWORD  mask,
DWORD  flags 
)

Definition at line 1171 of file process.c.

1172{
1173 OBJECT_HANDLE_FLAG_INFORMATION info;
1174
1175 /* if not setting both fields, retrieve current value first */
1178 {
1179 if (!set_ntstatus( NtQueryObject( handle, ObjectHandleFlagInformation, &info, sizeof(info), NULL )))
1180 return FALSE;
1181 }
1183 info.Inherit = (flags & HANDLE_FLAG_INHERIT) != 0;
1185 info.ProtectFromClose = (flags & HANDLE_FLAG_PROTECT_FROM_CLOSE) != 0;
1186
1187 return set_ntstatus( NtSetInformationObject( handle, ObjectHandleFlagInformation, &info, sizeof(info) ));
1188}
GLenum GLint GLuint mask
Definition: glext.h:6028
NTSTATUS NTAPI NtSetInformationObject(IN HANDLE ObjectHandle, IN OBJECT_INFORMATION_CLASS ObjectInformationClass, IN PVOID ObjectInformation, IN ULONG Length)
Definition: oblife.c:1824

Referenced by test_DuplicateHandle().

◆ SetPriorityClass()

BOOL WINAPI DECLSPEC_HOTPATCH SetPriorityClass ( HANDLE  process,
DWORD  class 
)

Definition at line 1194 of file process.c.

◆ SetProcessAffinityUpdateMode()

BOOL WINAPI DECLSPEC_HOTPATCH SetProcessAffinityUpdateMode ( HANDLE  process,
DWORD  flags 
)

Definition at line 1218 of file process.c.

1219{
1220 FIXME( "(%p,0x%08lx): stub\n", process, flags );
1222 return FALSE;
1223}

◆ SetProcessGroupAffinity()

BOOL WINAPI DECLSPEC_HOTPATCH SetProcessGroupAffinity ( HANDLE  process,
const GROUP_AFFINITY new,
GROUP_AFFINITY old 
)

Definition at line 1229 of file process.c.

1231{
1232 FIXME( "(%p,%p,%p): stub\n", process, new, old );
1234 return FALSE;
1235}

◆ SetProcessInformation()

BOOL WINAPI SetProcessInformation ( HANDLE  process,
PROCESS_INFORMATION_CLASS  info_class,
void info,
DWORD  size 
)

Definition at line 714 of file process.c.

715{
716 switch (info_class)
717 {
718 case ProcessMemoryPriority:
720 case ProcessPowerThrottling:
721 return set_ntstatus( NtSetInformationProcess( process, ProcessPowerThrottlingState, info, size ));
722 case ProcessLeapSecondInfo:
723 return set_ntstatus( NtSetInformationProcess( process, ProcessLeapSecondInformation, info, size ));
724 default:
725 FIXME("Unrecognized information class %d.\n", info_class);
726 return FALSE;
727 }
728}
@ ProcessPagePriority
Definition: winternl.h:894

◆ SetProcessMitigationPolicy()

BOOL WINAPI SetProcessMitigationPolicy ( PROCESS_MITIGATION_POLICY  policy,
void buffer,
SIZE_T  length 
)

Definition at line 1241 of file process.c.

1243{
1244 FIXME( "(%d, %p, %Iu): stub\n", policy, buffer, length );
1245 return TRUE;
1246}

◆ SetProcessPriorityBoost()

BOOL WINAPI SetProcessPriorityBoost ( HANDLE  process,
BOOL  disable 
)

Definition at line 1252 of file process.c.

1253{
1254 FIXME( "(%p,%d): stub\n", process, disable );
1255 return TRUE;
1256}

◆ SetProcessShutdownParameters()

BOOL WINAPI DECLSPEC_HOTPATCH SetProcessShutdownParameters ( DWORD  level,
DWORD  flags 
)

Definition at line 1262 of file process.c.

1263{
1264 FIXME( "(%08lx, %08lx): partial stub.\n", level, flags );
1267 return TRUE;
1268}

◆ SetProcessWorkingSetSizeEx()

BOOL WINAPI DECLSPEC_HOTPATCH SetProcessWorkingSetSizeEx ( HANDLE  process,
SIZE_T  minset,
SIZE_T  maxset,
DWORD  flags 
)

Definition at line 1274 of file process.c.

1276{
1277 return TRUE;
1278}

◆ SetStdHandle()

BOOL WINAPI DECLSPEC_HOTPATCH SetStdHandle ( DWORD  std_handle,
HANDLE  handle 
)

Definition at line 1399 of file process.c.

1400{
1401 switch (std_handle)
1402 {
1403 case STD_INPUT_HANDLE: NtCurrentTeb()->Peb->ProcessParameters->hStdInput = handle; return TRUE;
1404 case STD_OUTPUT_HANDLE: NtCurrentTeb()->Peb->ProcessParameters->hStdOutput = handle; return TRUE;
1405 case STD_ERROR_HANDLE: NtCurrentTeb()->Peb->ProcessParameters->hStdError = handle; return TRUE;
1406 }
1408 return FALSE;
1409}

Referenced by test_DetachStdHandles(), and test_Handles().

◆ SetStdHandleEx()

BOOL WINAPI DECLSPEC_HOTPATCH SetStdHandleEx ( DWORD  std_handle,
HANDLE  handle,
HANDLE prev 
)

Definition at line 1415 of file process.c.

1416{
1417 HANDLE *ptr;
1418
1419 switch (std_handle)
1420 {
1421 case STD_INPUT_HANDLE: ptr = &NtCurrentTeb()->Peb->ProcessParameters->hStdInput; break;
1422 case STD_OUTPUT_HANDLE: ptr = &NtCurrentTeb()->Peb->ProcessParameters->hStdOutput; break;
1423 case STD_ERROR_HANDLE: ptr = &NtCurrentTeb()->Peb->ProcessParameters->hStdError; break;
1424 default:
1426 return FALSE;
1427 }
1428 if (prev) *prev = *ptr;
1429 *ptr = handle;
1430 return TRUE;
1431}

◆ TerminateProcess()

BOOL WINAPI DECLSPEC_HOTPATCH TerminateProcess ( HANDLE  handle,
DWORD  exit_code 
)

Definition at line 1284 of file process.c.

1285{
1286 if (!handle)
1287 {
1289 return FALSE;
1290 }
1292}
NTSTATUS NTAPI NtTerminateProcess(HANDLE ProcessHandle, LONG ExitStatus)

◆ UpdateProcThreadAttribute()

BOOL WINAPI DECLSPEC_HOTPATCH UpdateProcThreadAttribute ( struct _PROC_THREAD_ATTRIBUTE_LIST list,
DWORD  flags,
DWORD_PTR  attr,
void value,
SIZE_T  size,
void prev_ret,
SIZE_T size_ret 
)

Definition at line 1820 of file process.c.

1823{
1824 DWORD mask, err;
1825 struct proc_thread_attr *entry;
1826
1827 TRACE( "(%p %lx %08Ix %p %Id %p %p)\n", list, flags, attr, value, size, prev_ret, size_ret );
1828
1829 if (list->count >= list->size)
1830 {
1832 return FALSE;
1833 }
1835 {
1836 SetLastError( err );
1837 return FALSE;
1838 }
1839
1841 if (list->mask & mask)
1842 {
1844 return FALSE;
1845 }
1846 list->mask |= mask;
1847
1848 entry = list->attrs + list->count;
1849 entry->attr = attr;
1850 entry->size = size;
1851 entry->value = value;
1852 list->count++;
1853 return TRUE;
1854}
static DWORD validate_proc_thread_attribute(DWORD_PTR attr, SIZE_T size)
Definition: process.c:1777
uint32_t entry
Definition: isohybrid.c:63
#define err(...)
DWORD_PTR attr
Definition: process.c:239
#define PROC_THREAD_ATTRIBUTE_NUMBER
Definition: winbase.h:1449
#define ERROR_OBJECT_NAME_EXISTS
Definition: winerror.h:479
#define ERROR_GEN_FAILURE
Definition: winerror.h:134

Referenced by alloc_console(), and create_pseudo_console().

◆ validate_proc_thread_attribute()

static DWORD validate_proc_thread_attribute ( DWORD_PTR  attr,
SIZE_T  size 
)
inlinestatic

Definition at line 1777 of file process.c.

1778{
1779 switch (attr)
1780 {
1782 if (size != sizeof(HANDLE)) return ERROR_BAD_LENGTH;
1783 break;
1784 case PROC_THREAD_ATTRIBUTE_EXTENDED_FLAGS:
1785 if (size != sizeof(ULONG)) return ERROR_BAD_LENGTH;
1786 break;
1788 if ((size / sizeof(HANDLE)) * sizeof(HANDLE) != size) return ERROR_BAD_LENGTH;
1789 break;
1791 if (size != sizeof(PROCESSOR_NUMBER)) return ERROR_BAD_LENGTH;
1792 break;
1793 case PROC_THREAD_ATTRIBUTE_CHILD_PROCESS_POLICY:
1794 if (size != sizeof(DWORD) && size != sizeof(DWORD64)) return ERROR_BAD_LENGTH;
1795 break;
1796 case PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY:
1797 if (size != sizeof(DWORD) && size != sizeof(DWORD64) && size != sizeof(DWORD64) * 2)
1798 return ERROR_BAD_LENGTH;
1799 break;
1800 case PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE:
1801 if (size != sizeof(HPCON)) return ERROR_BAD_LENGTH;
1802 break;
1803 case PROC_THREAD_ATTRIBUTE_JOB_LIST:
1804 if ((size / sizeof(HANDLE)) * sizeof(HANDLE) != size) return ERROR_BAD_LENGTH;
1805 break;
1806 case PROC_THREAD_ATTRIBUTE_MACHINE_TYPE:
1807 if (size != sizeof(USHORT)) return ERROR_BAD_LENGTH;
1808 break;
1809 default:
1810 FIXME( "Unhandled attribute %Iu\n", attr & PROC_THREAD_ATTRIBUTE_NUMBER );
1811 return ERROR_NOT_SUPPORTED;
1812 }
1813 return 0;
1814}
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
PROCESSOR_NUMBER
Definition: ntbasedef.h:654
uint64_t DWORD64
Definition: typedefs.h:67
#define PROC_THREAD_ATTRIBUTE_IDEAL_PROCESSOR
Definition: winbase.h:1470

Referenced by UpdateProcThreadAttribute().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( process  )

Variable Documentation

◆ command_lineA

char* command_lineA
static

Definition at line 1300 of file process.c.

Referenced by GetCommandLineA(), and init_startup_info().

◆ command_lineW

WCHAR* command_lineW
static

Definition at line 1301 of file process.c.

Referenced by GetCommandLineW(), and init_startup_info().

◆ shutdown_flags

DWORD shutdown_flags = 0
static

Definition at line 38 of file process.c.

Referenced by GetProcessShutdownParameters(), and SetProcessShutdownParameters().

◆ shutdown_priority

DWORD shutdown_priority = 0x280
static

Definition at line 39 of file process.c.

Referenced by GetProcessShutdownParameters(), and SetProcessShutdownParameters().