The user-mode thread start address is stored in the ETHREAD. This is the system-supplied thread startup function in Ntdll.dll (
If this is a UMS thread,
Once that work is finished,
A check is made to ensure that the thread’s group affinity does not violate job limitations (which we already described earlier). In the process create path, this check is skipped because it was already done at the earlier stage.
Checks are made to ensure that the process hasn’t already been terminated, that the thread hasn’t already been terminated, or that the thread hasn’t even been able to start running. If any of these cases are true, thread creation will fail.
The KTHREAD part of the thread object is initialized by calling
The thread count in the process object is incremented, and the owner process’ I/O priority and page priority are inherited. If this is the highest number of threads the process has ever had, the thread count high watermark is updated as well. If this was the second thread in the process, the primary token is frozen (that is, it can no longer be changed, unless the process is a POSIX subsystem process).
If the thread is a UMS thread, the count of UMS threads is incremented.
The thread is inserted in the process’ thread list, and the thread is suspended if the creating process requested it.
If CPU rate limiting is enabled, the rate control APC is initialized and the
The object is inserted, and any registered thread callbacks are called. If this was the first thread in the process (and therefore, the operation happened as part of the
The handle is created with
The thread is readied for execution by calling
Stage 5: Performing Windows Subsystem–Specific Post-Initialization
Once
First of all, various checks are made for whether Windows should allow the executable to run. These checks include validating the image version in the header and checking whether Windows application certification has blocked the process (through a group policy). On specialized editions of Windows Server 2008 R2, such as Windows Web Server 2008 R2 and Windows HPC Server 2008 R2, additional checks are made to see whether the application imports any disallowed APIs.
If software restriction policies dictate, a restricted token is created for the new process. Afterward, the application-compatibility database is queried to see whether an entry exists in either the registry or system application database for the process. Compatibility shims will not be applied at this point—the information will be stored in the PEB once the initial thread starts executing (Stage 6).