[The memory addresses specified by this example code may change in future releases of Windows. To ensure that your application will continue to run correctly in the future, your application must call GetCurrentProcessId and then ProcessIdToSessionId instead of the following sample code.]
The following example x86 assembly code gets the Terminal Services session ID associated with the current process.
mov eax,fs:[00000018]
mov eax,[eax+0x30]
mov eax,[eax+0x1d4]
Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.
