Process Hacker
runas.c File Reference
#include <phapp.h>
#include <phsvc.h>
#include <phsvccl.h>
#include <settings.h>
#include <emenu.h>
#include <shlwapi.h>
#include <winsta.h>
#include <windowsx.h>

Go to the source code of this file.

Macros

#define SIP(String, Integer)   { (String), (PVOID)(Integer) }
 

Typedefs

typedef struct
_RUNAS_DIALOG_CONTEXT 
RUNAS_DIALOG_CONTEXT
 
typedef struct
_RUNAS_DIALOG_CONTEXT * 
PRUNAS_DIALOG_CONTEXT
 

Functions

INT_PTR CALLBACK PhpRunAsDlgProc (_In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
VOID PhSetDesktopWinStaAccess (VOID)
 Sets the access control lists of the current window station and desktop to allow all access.
 
VOID PhpSplitUserName (_In_ PWSTR UserName, _Out_ PPH_STRING *DomainPart, _Out_ PPH_STRING *UserPart)
 
VOID PhShowRunAsDialog (_In_ HWND ParentWindowHandle, _In_opt_ HANDLE ProcessId)
 
NTSTATUS PhExecuteRunAsCommand (_In_ PPH_RUNAS_SERVICE_PARAMETERS Parameters)
 Executes the run-as service.
 
NTSTATUS PhExecuteRunAsCommand2 (_In_ HWND hWnd, _In_ PWSTR Program, _In_opt_ PWSTR UserName, _In_opt_ PWSTR Password, _In_opt_ ULONG LogonType, _In_opt_ HANDLE ProcessIdWithToken, _In_ ULONG SessionId, _In_ PWSTR DesktopName, _In_ BOOLEAN UseLinkedToken)
 Starts a program as another user.
 
NTSTATUS PhRunAsServiceStart (_In_ PPH_STRING ServiceName)
 
NTSTATUS PhInvokeRunAsService (_In_ PPH_RUNAS_SERVICE_PARAMETERS Parameters)
 

Macro Definition Documentation

#define SIP (   String,
  Integer 
)    { (String), (PVOID)(Integer) }

Definition at line 94 of file runas.c.

Typedef Documentation

typedef struct _RUNAS_DIALOG_CONTEXT * PRUNAS_DIALOG_CONTEXT
typedef struct _RUNAS_DIALOG_CONTEXT RUNAS_DIALOG_CONTEXT

Function Documentation

NTSTATUS PhExecuteRunAsCommand ( _In_ PPH_RUNAS_SERVICE_PARAMETERS  Parameters)

Executes the run-as service.

Parameters
ParametersThe run-as parameters.
Remarks
This function requires administrator-level access.

Definition at line 812 of file runas.c.

NTSTATUS PhExecuteRunAsCommand2 ( _In_ HWND  hWnd,
_In_ PWSTR  Program,
_In_opt_ PWSTR  UserName,
_In_opt_ PWSTR  Password,
_In_opt_ ULONG  LogonType,
_In_opt_ HANDLE  ProcessIdWithToken,
_In_ ULONG  SessionId,
_In_ PWSTR  DesktopName,
_In_ BOOLEAN  UseLinkedToken 
)

Starts a program as another user.

Parameters
hWndA handle to the parent window.
ProgramThe command line of the program to start.
UserNameThe user to start the program as. The user name should be specified as: domain\name. This parameter can be NULL if ProcessIdWithToken is specified.
PasswordThe password for the specified user. If there is no password, specify an empty string. This parameter can be NULL if ProcessIdWithToken is specified.
LogonTypeThe logon type for the specified user. This parameter can be 0 if ProcessIdWithToken is specified.
ProcessIdWithTokenThe ID of a process from which to duplicate the token.
SessionIdThe ID of the session to run the program under.
DesktopNameThe window station and desktop to run the program under.
UseLinkedTokenUses the linked token if possible.
Return values
STATUS_CANCELLEDThe user cancelled the operation.
Remarks
This function will cause another instance of Process Hacker to be executed if the current security context does not have sufficient system access. This is done through a UAC elevation prompt.

Definition at line 921 of file runas.c.

NTSTATUS PhInvokeRunAsService ( _In_ PPH_RUNAS_SERVICE_PARAMETERS  Parameters)

Definition at line 1116 of file runas.c.

INT_PTR CALLBACK PhpRunAsDlgProc ( _In_ HWND  hwndDlg,
_In_ UINT  uMsg,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)

Definition at line 234 of file runas.c.

static VOID PhpSplitUserName ( _In_ PWSTR  UserName,
_Out_ PPH_STRING DomainPart,
_Out_ PPH_STRING UserPart 
)

Definition at line 1003 of file runas.c.

NTSTATUS PhRunAsServiceStart ( _In_ PPH_STRING  ServiceName)

Definition at line 1083 of file runas.c.

VOID PhSetDesktopWinStaAccess ( VOID  )

Sets the access control lists of the current window station and desktop to allow all access.

Definition at line 737 of file runas.c.

VOID PhShowRunAsDialog ( _In_ HWND  ParentWindowHandle,
_In_opt_ HANDLE  ProcessId 
)

Definition at line 112 of file runas.c.