Getting the Session ID of the Current Process

[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]

 

 

Show: