FreeRDP
process.c File Reference
#include <winpr/config.h>
#include <winpr/handle.h>
#include "../handle/nonehandle.h"
#include <winpr/thread.h>
#include <winpr/assert.h>
#include <winpr/crt.h>
#include <winpr/path.h>
#include <winpr/environment.h>
#include <grp.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "thread.h"
#include "../security/security.h"

Macros

#define NSIG   64
 

Functions

static char * FindApplicationPath (char *application)
 
static HANDLE CreateProcessHandle (pid_t pid)
 
static BOOL ProcessHandleCloseHandle (HANDLE handle)
 
static BOOL _CreateProcessExA (HANDLE hToken, DWORD dwLogonFlags, LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
 
BOOL CreateProcessA (LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
 
BOOL CreateProcessW (LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
 
BOOL CreateProcessAsUserA (HANDLE hToken, LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
 
BOOL CreateProcessAsUserW (HANDLE hToken, LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
 
BOOL CreateProcessWithLogonA (LPCSTR lpUsername, LPCSTR lpDomain, LPCSTR lpPassword, DWORD dwLogonFlags, LPCSTR lpApplicationName, LPSTR lpCommandLine, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
 
BOOL CreateProcessWithLogonW (LPCWSTR lpUsername, LPCWSTR lpDomain, LPCWSTR lpPassword, DWORD dwLogonFlags, LPCWSTR lpApplicationName, LPWSTR lpCommandLine, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
 
BOOL CreateProcessWithTokenA (HANDLE hToken, DWORD dwLogonFlags, LPCSTR lpApplicationName, LPSTR lpCommandLine, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
 
BOOL CreateProcessWithTokenW (HANDLE hToken, DWORD dwLogonFlags, LPCWSTR lpApplicationName, LPWSTR lpCommandLine, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
 
VOID ExitProcess (UINT uExitCode)
 
BOOL GetExitCodeProcess (HANDLE hProcess, LPDWORD lpExitCode)
 
HANDLE _GetCurrentProcess (VOID)
 
DWORD GetCurrentProcessId (VOID)
 
BOOL TerminateProcess (HANDLE hProcess, UINT uExitCode)
 
static BOOL ProcessHandleIsHandle (HANDLE handle)
 
static int ProcessGetFd (HANDLE handle)
 
static DWORD ProcessCleanupHandle (HANDLE handle)
 
static int _pidfd_open (pid_t pid)
 

Variables

static HANDLE_OPS ops
 

Macro Definition Documentation

◆ NSIG

#define NSIG   64

WinPR: Windows Portable Runtime Process Thread Functions

Copyright 2012 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.com Copyright 2014 DI (FH) Martin Haimberger marti.nosp@m.n.ha.nosp@m.imber.nosp@m.ger@.nosp@m.thinc.nosp@m.ast..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. CreateProcessA CreateProcessW CreateProcessAsUserA CreateProcessAsUserW ExitProcess GetCurrentProcess GetCurrentProcessId GetExitCodeProcess GetProcessHandleCount GetProcessId GetProcessIdOfThread GetProcessMitigationPolicy GetProcessTimes GetProcessVersion OpenProcess OpenProcessToken ProcessIdToSessionId SetProcessAffinityUpdateMode SetProcessMitigationPolicy SetProcessShutdownParameters TerminateProcess

Function Documentation

◆ _CreateProcessExA()

static BOOL _CreateProcessExA ( HANDLE  hToken,
DWORD  dwLogonFlags,
LPCSTR  lpApplicationName,
LPSTR  lpCommandLine,
LPSECURITY_ATTRIBUTES  lpProcessAttributes,
LPSECURITY_ATTRIBUTES  lpThreadAttributes,
BOOL  bInheritHandles,
DWORD  dwCreationFlags,
LPVOID  lpEnvironment,
LPCSTR  lpCurrentDirectory,
LPSTARTUPINFOA  lpStartupInfo,
LPPROCESS_INFORMATION  lpProcessInformation 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _GetCurrentProcess()

HANDLE _GetCurrentProcess ( VOID  )

◆ _pidfd_open()

static int _pidfd_open ( pid_t  pid)
static
Here is the caller graph for this function:

◆ CreateProcessA()

BOOL CreateProcessA ( LPCSTR  lpApplicationName,
LPSTR  lpCommandLine,
LPSECURITY_ATTRIBUTES  lpProcessAttributes,
LPSECURITY_ATTRIBUTES  lpThreadAttributes,
BOOL  bInheritHandles,
DWORD  dwCreationFlags,
LPVOID  lpEnvironment,
LPCSTR  lpCurrentDirectory,
LPSTARTUPINFOA  lpStartupInfo,
LPPROCESS_INFORMATION  lpProcessInformation 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateProcessAsUserA()

BOOL CreateProcessAsUserA ( HANDLE  hToken,
LPCSTR  lpApplicationName,
LPSTR  lpCommandLine,
LPSECURITY_ATTRIBUTES  lpProcessAttributes,
LPSECURITY_ATTRIBUTES  lpThreadAttributes,
BOOL  bInheritHandles,
DWORD  dwCreationFlags,
LPVOID  lpEnvironment,
LPCSTR  lpCurrentDirectory,
LPSTARTUPINFOA  lpStartupInfo,
LPPROCESS_INFORMATION  lpProcessInformation 
)
Here is the call graph for this function:

◆ CreateProcessAsUserW()

BOOL CreateProcessAsUserW ( HANDLE  hToken,
LPCWSTR  lpApplicationName,
LPWSTR  lpCommandLine,
LPSECURITY_ATTRIBUTES  lpProcessAttributes,
LPSECURITY_ATTRIBUTES  lpThreadAttributes,
BOOL  bInheritHandles,
DWORD  dwCreationFlags,
LPVOID  lpEnvironment,
LPCWSTR  lpCurrentDirectory,
LPSTARTUPINFOW  lpStartupInfo,
LPPROCESS_INFORMATION  lpProcessInformation 
)

◆ CreateProcessHandle()

HANDLE CreateProcessHandle ( pid_t  pid)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateProcessW()

BOOL CreateProcessW ( LPCWSTR  lpApplicationName,
LPWSTR  lpCommandLine,
LPSECURITY_ATTRIBUTES  lpProcessAttributes,
LPSECURITY_ATTRIBUTES  lpThreadAttributes,
BOOL  bInheritHandles,
DWORD  dwCreationFlags,
LPVOID  lpEnvironment,
LPCWSTR  lpCurrentDirectory,
LPSTARTUPINFOW  lpStartupInfo,
LPPROCESS_INFORMATION  lpProcessInformation 
)

◆ CreateProcessWithLogonA()

BOOL CreateProcessWithLogonA ( LPCSTR  lpUsername,
LPCSTR  lpDomain,
LPCSTR  lpPassword,
DWORD  dwLogonFlags,
LPCSTR  lpApplicationName,
LPSTR  lpCommandLine,
DWORD  dwCreationFlags,
LPVOID  lpEnvironment,
LPCSTR  lpCurrentDirectory,
LPSTARTUPINFOA  lpStartupInfo,
LPPROCESS_INFORMATION  lpProcessInformation 
)

◆ CreateProcessWithLogonW()

BOOL CreateProcessWithLogonW ( LPCWSTR  lpUsername,
LPCWSTR  lpDomain,
LPCWSTR  lpPassword,
DWORD  dwLogonFlags,
LPCWSTR  lpApplicationName,
LPWSTR  lpCommandLine,
DWORD  dwCreationFlags,
LPVOID  lpEnvironment,
LPCWSTR  lpCurrentDirectory,
LPSTARTUPINFOW  lpStartupInfo,
LPPROCESS_INFORMATION  lpProcessInformation 
)

◆ CreateProcessWithTokenA()

BOOL CreateProcessWithTokenA ( HANDLE  hToken,
DWORD  dwLogonFlags,
LPCSTR  lpApplicationName,
LPSTR  lpCommandLine,
DWORD  dwCreationFlags,
LPVOID  lpEnvironment,
LPCSTR  lpCurrentDirectory,
LPSTARTUPINFOA  lpStartupInfo,
LPPROCESS_INFORMATION  lpProcessInformation 
)
Here is the call graph for this function:

◆ CreateProcessWithTokenW()

BOOL CreateProcessWithTokenW ( HANDLE  hToken,
DWORD  dwLogonFlags,
LPCWSTR  lpApplicationName,
LPWSTR  lpCommandLine,
DWORD  dwCreationFlags,
LPVOID  lpEnvironment,
LPCWSTR  lpCurrentDirectory,
LPSTARTUPINFOW  lpStartupInfo,
LPPROCESS_INFORMATION  lpProcessInformation 
)

◆ ExitProcess()

VOID ExitProcess ( UINT  uExitCode)

◆ FindApplicationPath()

static char* FindApplicationPath ( char *  application)
static

If the file name does not contain a directory path, the system searches for the executable file in the following sequence:

1) The directory from which the application loaded. 2) The current directory for the parent process. 3) The 32-bit Windows system directory. Use the GetSystemDirectory function to get the path of this directory. 4) The 16-bit Windows system directory. There is no function that obtains the path of this directory, but it is searched. The name of this directory is System. 5) The Windows directory. Use the GetWindowsDirectory function to get the path of this directory. 6) The directories that are listed in the PATH environment variable. Note that this function does not search the per-application path specified by the App Paths registry key. To include this per-application path in the search sequence, use the ShellExecute function.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCurrentProcessId()

DWORD GetCurrentProcessId ( VOID  )

◆ GetExitCodeProcess()

BOOL GetExitCodeProcess ( HANDLE  hProcess,
LPDWORD  lpExitCode 
)
Here is the caller graph for this function:

◆ ProcessCleanupHandle()

static DWORD ProcessCleanupHandle ( HANDLE  handle)
static

◆ ProcessGetFd()

static int ProcessGetFd ( HANDLE  handle)
static
Here is the call graph for this function:

◆ ProcessHandleCloseHandle()

static BOOL ProcessHandleCloseHandle ( HANDLE  handle)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessHandleIsHandle()

static BOOL ProcessHandleIsHandle ( HANDLE  handle)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TerminateProcess()

BOOL TerminateProcess ( HANDLE  hProcess,
UINT  uExitCode 
)
Here is the caller graph for this function:

Variable Documentation

◆ ops

HANDLE_OPS ops
static
Initial value:
NULL }
if availableBytes return NULL
Definition: TPCircularBuffer.h:109
static DWORD ProcessCleanupHandle(HANDLE handle)
Definition: process.c:512
static BOOL ProcessHandleIsHandle(HANDLE handle)
Definition: process.c:497
static int ProcessGetFd(HANDLE handle)
Definition: process.c:502
static BOOL ProcessHandleCloseHandle(HANDLE handle)
Definition: process.c:484