Windows process
1 Windows process
A process is a container that contains a variety of resources for an application instance. Windows multitasking operating system, so you can execute multiple processes at the same time.
2 Some features of the Windows process
2.1 The process contains resources such as execution code.
The 2.2 process has a private address space.
2.3 Each process has an ID that identifies the process.
2.4 Each process has its own security attributes
2.5 include at least one thread that can be executed.
Environment of the two processes
1 Access to environmental information
Get:
LPVOID getenvironmentstrings (VOID)
The return value is all the environment information obtained
Release:
BOOL freeenvironmentstrings ( LPTSTR lpszenvironmentblock)
2 Getting and setting of environment variables
Get:
DWORD GetEnvironmentVariable (LPCTSTR lpName, // variable name LPTSTR lpbuffer, / / data buff DWORD NSize // buff );
The return value is the length of the obtained string
Set up:
BOOL setenvironmentvariable ( / / variable name lpctstr lpvalue // Value of the variable );
Three process information
1 Process ID and handle
GetCurrentProcess Gets the handle to the process,
The return value is-1, which is the pseudo-handle of the current process and is always-1. If you want to get the actual handle of the current process, you need to use the OpenProcess function.
2 open process
HANDLE OpenProcess (DWORD dwdesiredaccess, Span style= "margin:0px; padding:0px; line-height:1.5; Color:rgb (0, 128, 0); " >// access mode BOOL bInheritHandle, // Span style= "margin:0px; padding:0px; line-height:1.5; Color:rgb (0, 128, 0); " > Inherit the identity DWORD dwprocessid process id );
Returns a handle to a process
3 gets all the modules used by the process (EXE or DLL)
Use the PSAPI function.
BOOL EnumProcessModules (HANDLE hprocess,//Process HandleHmodule * Lphmodule,//Array of modulesDWORD CB,//the length of the arrayLpdword lpcbneeded//Gets the number of bytes to the data);