2020-06-15 07:18:57 -07:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_NT_TEB_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_NT_TEB_H_
|
|
|
|
#include "libc/nt/struct/peb.h"
|
2021-02-03 17:14:17 -08:00
|
|
|
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
2020-06-15 07:18:57 -07:00
|
|
|
|
2021-02-03 06:22:51 -08:00
|
|
|
/*
|
|
|
|
* These macros address directly into NT's TEB a.k.a. TIB
|
2023-07-26 13:54:49 -07:00
|
|
|
* Any function that does this needs the `dontasan` keyword
|
2021-02-03 06:22:51 -08:00
|
|
|
*/
|
2024-02-01 03:39:46 -08:00
|
|
|
#define NtGetPeb() ((__seg_gs struct NtPeb *)0x60)
|
|
|
|
#define NtGetTeb() ((void *)*(__seg_gs uintptr_t *)0x30)
|
|
|
|
#define NtGetPid() (*(__seg_gs uint32_t *)0x40)
|
|
|
|
#define NtGetTid() (*(__seg_gs uint32_t *)0x48)
|
|
|
|
#define NtGetErr() (*(__seg_gs int *)0x68)
|
|
|
|
#define _NtGetSeh() ((void *)*(__seg_gs uintptr_t *)0x00)
|
|
|
|
#define _NtGetStackHigh() ((void *)*(__seg_gs uintptr_t *)0x08)
|
|
|
|
#define _NtGetStackLow() ((void *)*(__seg_gs uintptr_t *)0x10)
|
|
|
|
#define _NtGetSubsystemTib() ((void *)*(__seg_gs uintptr_t *)0x18)
|
|
|
|
#define _NtGetFib() ((void *)*(__seg_gs uintptr_t *)0x20)
|
|
|
|
#define _NtGetEnv() ((char16_t *)*(__seg_gs intptr_t *)0x38)
|
|
|
|
#define _NtGetRpc() ((void *)*(__seg_gs uintptr_t *)0x50)
|
|
|
|
#define _NtGetTls() ((void *)*(__seg_gs uintptr_t *)0x58)
|
2020-06-15 07:18:57 -07:00
|
|
|
|
2021-02-03 17:14:17 -08:00
|
|
|
#endif /* __GNUC__ && !__STRICT_ANSI__ */
|
2020-06-15 07:18:57 -07:00
|
|
|
#endif /* COSMOPOLITAN_LIBC_NT_TEB_H_ */
|