[Autogenerated] all good things come to an end,
as they say, hopefully bad things as well.
And at some point the process might terminate and there are several
ways the process might terminate its execution.
One option is that all the threads in the process, exit.
And we know that when the process remains without threats and
essentially useless and the kind of will terminate such a process
destroyed that process object if possible.
Another option is that one of the threads in the process calls the
exit process API from the Windows API so it has to be done by a
thread which is part of the process.
And then the third option is a more violent option by calling
the terminal process API which can be done from outside the
process but it requires a handle powerful enough to the process
for these to actually work.
And let me ask you a question,
which option do you think is the most common for processes to to terminate?
You can pause the recording and think about it for a little bit.
So here's the answer.
The answer is actually option number two.
So that's calling the exit process API you might find that a bit weird.
I mean isn't the first option perhaps more viable,
but the thing is that most applications use the Windows subsystem.
So the link against the C runtime that we talked about already.
Now one of the things that happens with the C runtime
is it calls your main function.
And when the main function returns the c runtime calls exit process,
which terminates the process entirely,
killing all other threats that might exist in the process at that time.
And so sometimes people refer to the first threat in the process as the
main threat as though it has some special powers.
In fact, it doesn't.
From the colonel's perspective, all threads in the process are the same,
but from a practical perspective on that first thread terminates
when it when we return from the main function,
then the process terminates because the C runtime is calling the
exit process API So let's see what that process looks like and how
we can kill a process from the outside.