09.02.2014 Views

Windows sysinternals

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

22 Part I Getting Started<br />

■ The contents of a set of CPU registers representing the state of the processor. These<br />

include an instruction pointer that identifies the next machine instruction the thread<br />

will execute.<br />

■ Two stacks, one for the thread to use while executing in kernel mode and one for<br />

executing in user mode.<br />

■ A private storage area called thread-local storage (TLS) for use by subsystems, run-time<br />

libraries, and dynamic-link libraries (DLLs).<br />

■ A unique identifier called a thread ID (TID). Process IDs and thread IDs are generated<br />

from the same namespace, so they never overlap.<br />

■ Threads sometimes have their own security context that is often used by multithreaded<br />

server applications that impersonate the security context of the clients they serve.<br />

Although threads have their own execution context, every thread within a process shares<br />

the process’ virtual address space (in addition to the rest of the resources belonging to the<br />

process), meaning that all the threads in a process can write to and read from one another’s<br />

memory. Threads cannot reference the address space of another process, however, unless the<br />

other process makes available part of its private address space as a shared memory section<br />

(called a file mapping object in the <strong>Windows</strong> API) or unless one process has the right to open<br />

another process to use cross-process memory functions.<br />

By default, threads don’t have their own access token, but they can obtain one, thus allowing<br />

individual threads to impersonate a different security context—including that of a process<br />

running on a remote <strong>Windows</strong> system—without affecting other threads in the process.<br />

User Mode and Kernel Mode<br />

To prevent user applications from accessing or modifying critical operating system data,<br />

<strong>Windows</strong> uses two processor access modes: user mode and kernel mode. All processes other<br />

than the System process run in user mode (Ring 3 on Intel x86 and x64 architectures), whereas<br />

device drivers and operating system components such as the executive and kernel run<br />

only in kernel mode. Kernel mode refers to a mode of execution (Ring 0 on x86 and x64) in a<br />

processor that grants access to all system memory and to all CPU instructions. By providing<br />

the low-level operating system software with a higher privilege level than user-mode processes<br />

have, the processor provides a necessary foundation for operating system designers to<br />

ensure that a misbehaving application can’t disrupt the stability of the system as a whole.<br />

Note Do not confuse the user-mode vs. kernel-mode distinction with that of user rights<br />

vs. administrator rights. “User mode” in this context does not mean “has only standard user<br />

privileges.”<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!