The official way to get environmental flow / block information (TIB / TEB)

In Windows, for a long time it was common, if not documented, to know that the stream information block (TIB) of the current stream can be found in FS: 0. But this only works on Intel processors where the FS register exists. Now I want to get into TIB on an ARM-based Windows system (Windows Phone and possibly Windows RT). Is there an API for this, please?

EDIT: I want to get a thread stack base for crash reporting purposes.

TIB / TEB Information: http://www.microsoft.com/msj/archive/S2CE.aspx

+3
source share
3 answers

NtCurrentTeb() winnt.h , ARM (Windows RT):

#if defined(_M_ARM) && !defined(__midl) && !defined(_M_CEE_PURE)

__forceinline
struct _TEB *
NtCurrentTeb (
    VOID
    )
{
    return (struct _TEB *)(ULONG_PTR)_MoveFromCoprocessor(CP15_TPIDRURW);
}
+7

, NtQueryInformationThread() THREAD_BASIC_INFORMATION, TIB TebBaseAddress.

+5

Igor nailed it. But FYI, in the ARM assembly, looks like this:

mrc p15, 0, r12, c13, c0, 2 ; r12 now points at TEB/TIB
ldr r12, [r12, #4] ; r12 now holds stack base
+1
source

Source: https://habr.com/ru/post/1683801/


All Articles