Gaining a Sense of One’s Own Identity

As threads execute, they frequently want to call Windows functions that change their execution environment. For example, a thread might want to alter its priority or its process’ priority. (Priorities are discussed in Chapter 7.) Because it is common for a thread to alter its (or its process’) environment, Windows offers functions that make it easy for a thread to refer to its process kernel object or to its own thread kernel object:

HANDLE GetCurrentProcess();
HANDLE GetCurrentThread();

Both of these functions return a pseudohandle to the calling thread’s process or thread kernel object. These functions do not create new handles in the calling process’ handle table. Also, calling these functions has no effect ...

Get Windows® via C/C++, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.