- Link : https://docs.microsoft.com/windows/win32/procthread/processes-and-threads
- Headers : Win32Ex/System/Process.h, Win32Ex/System/Process.hpp
- Processes and threads
- Contents
- Reference
- Functions
- Classes
- Process
- ProcessW
- ProcessT<class StringType = Win32Ex::StringT>
- RunnableProcess
- RunnableProcessW
- RunnableProcessT<class StringType = Win32Ex::StringT>
- UserAccountProcess
- UserAccountProcessW
- UserAccountProcessT
- SystemAccountProcess
- SystemAccountProcessW
- SystemAccountProcessT
- RunnableSessionProcessT<ProcessAccountType Type, class StringType = Win32Ex::StringT>
- ElevatedProcess
- ElevatedProcessW
- ElevatedProcessT<class StringType = Win32Ex::StringT>
- Namespaces
- It's better using Wini32Ex::System::Session::NewProcess method than this funtion.
- Example
-
Creating a user account process in the current session.
#include <Win32Ex/System/Process.h> CreateUserAccountProcess(WTSGetActiveConsoleSessionId(), NULL, TEXT("CMD.exe /C QUERY SESSION"), /* ... */);
-
- It's better using Wini32Ex::System::Session::NewProcess method than this funtion.
- Example
-
Creating a system account process in the current session.
#include <Win32Ex/System/Process.h> CreateSystemAccountProcess(WTSGetActiveConsoleSessionId(), NULL, TEXT("CMD.exe /C QUERY SESSION"), /* ... */);
-
- C++ only
- It's better using Wini32Ex::System::Session::NewProcess method than this funtion.
- Example
-
Creating a user account process at the current session.
#include <Win32Ex/System/Process.h> CreateUserAccountProcessT<CHAR>(WTSGetActiveConsoleSessionId(), NULL, "CMD.exe /C QUERY SESSION", /* ... */);
-
- C++ only
- It's better using Wini32Ex::System::Session::NewProcess method than this funtion.
- Example
-
Creating a system account process at the current session.
#include <Win32Ex/System/Process.h> CreateSystemAccountProcessT<CHAR>(WTSGetActiveConsoleSessionId(), NULL, "CMD.exe /C QUERY SESSION", /* ... */);
-
- ProcessT<Win32Ex::String>
- Example
-
Attach Process by process id, process handle.
#include <Win32Ex/System/Process.hpp> DWORD pid = ... Win32Ex::System::Process process(pid); if (process.IsAttached()) { process.ExecutablePath(); } HANDLE hProcess = .. Win32Ex::System::Process process(Win32Ex::System::ProcessHandle::FromHANDLE(hProcess)); if (process.IsAttached()) { process.ExecutablePath(); }
-
Enumerate all processes.
#include <Win32Ex/System/Process.hpp> for (auto process : Win32Ex::System::Process::All()) { if (process) { if (process->IsAttached()) std::cout << "[Attached] PID :" << process->Id() << "\t\tPATH : " << process->ExecutablePath() << '\n'; else std::cout << "PID :" << process->Id() << "\t\tPATH : " << process->ExecutablePath() << '\n'; } }
-
- ProcessT<Win32Ex::StringW>
- Implements WaitableObject.
- Abstract
- RunnableProcessT<Win32Ex::String>
- Example
-
Use the RunnableProcess class to run 'user account process'.
#include <Win32Ex/System/Process.hpp> // It's better using the Wini32Ex::System::Session::NewProcess method than this class. Win32Ex::System::UserAccountProcess process("CMD", "/C WHOAMI"); Win32Ex::System::RunnableProcess &runnable = process; runnable.Run();
-
- Abstract
- RunnableProcessT<Win32Ex::StringW>
- Abstract
- Implements ProcessT.
- RunnableSessionProcessT<UserAccount, Win32Ex::String>
- It's better using Wini32Ex::System::Session::NewProcess method than this class.
- Example
-
Creating a user account process at the current session.
#include <Win32Ex/System/Process.hpp> Win32Ex::System::UserAccountProcess process("CMD.exe"); process.Run("/C QUERY SESSION"); auto waiter = process.RunAsync("/C QUERY SESSION"); waiter.Wait();
-
Runs user account process at each sessions.
#include <Win32Ex/System/Process.hpp> PWTS_SESSION_INFO sessionInfo = NULL; DWORD count = 0; if (WTSEnumerateSessions(WTS_CURRENT_SERVER, 0, 1, &sessionInfo, &count)) { for (DWORD i = 0; i < count; ++i) { Win32Ex::System::UserAccountProcess process(sessionInfo[i].SessionId, "CMD", "/C QUERY SESSION"); process.Run(); } }
-
Tests standard output and standard input.
Win32Ex::System::UserAccountProcess process("cmd /c more"); process.RunAsync(); process.StdIn() << "test 1\n"; process.StdIn() << "test 2\ntest 3\n"; process.StdIn().Close(); std::cout << process.ExecutablePath(); std::cout << process.StdOut().ReadAll();
-
- RunnableSessionProcessT<UserAccount, Win32Ex::StringW>
- It's better using Wini32Ex::System::Session::NewProcess method than this class.
- Implements RunnableProcessT.
- It's better using Wini32Ex::System::Session::NewProcess method than this class.
- RunnableSessionProcessT<SystemAccount, Win32Ex::String>
- It's better using Wini32Ex::System::Session::NewProcess method than this class.
- RunnableSessionProcessT<SystemAccount, Win32Ex::StringW>
- It's better using Wini32Ex::System::Session::NewProcess method than this class.
- Implements RunnableProcessT.
- It's better using Wini32Ex::System::Session::NewProcess method than this class.
- ElevatedProcessT<Win32Ex::String>
- Example
-
Creating a with elevated permissions UAC.
#include <Win32Ex/System/Process.hpp> Win32Ex::System::ElevatedProcess process("notepad.exe"); process.Run();
-
- ElevatedProcessT<Win32Ex::StringW>
- Implements RunnableProcessT.
- Example
-
Enumerate parent processes.
#include <Win32Ex/System/Process.hpp> Win32Ex::System::Process parent = Win32Ex::ThisProcess::Parent(); while (parent.IsValid()) { std::cout << parent.ExecutablePath() << '\n'; parent = parent.Parent(); }
-