CommonLibVR
TLSData.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSExtraData.h"
4 #include "RE/E/ExtraDataList.h"
5 #include "RE/E/ExtraDataTypes.h"
6 
7 namespace RE
8 {
9  struct TLSData
10  {
11  inline static constexpr uint32_t CACHED_EXTRA_DATA_SIZE = (static_cast<uint32_t>(ExtraDataType::kResourcesPreload) + 1);
12  std::uint8_t unk000[0x10]; // 000
13  std::uint32_t stateCounter; // 010 - on GetExtraData(), this gets checked against the GlobalStateCounter, which is incremented every time extra data is changed or removed; if they're not equal, then the following cached extra data is zeroed-out and recached
14  std::uint32_t pad014; // 014
16  BSExtraData* cachedExtraData[CACHED_EXTRA_DATA_SIZE]; // 020 - ExtraData types up to kResourcesPreload (0xB5) are cached
17  std::uint8_t unk5D0[0x30]; // 5D0
18  bool consoleMode; // 600
19  std::uint8_t unk601[0x167]; // 601
20  std::uint32_t taskFlag; // 768 -- unknown enum
21  // ... many others ...
22  private:
23  KEEP_FOR_RE()
24  };
25  static_assert(offsetof(TLSData, consoleMode) == 0x600);
26  static_assert(offsetof(TLSData, taskFlag) == 0x768);
27 
28  inline static TLSData* GetStaticTLSData()
29  {
30  REL::Relocation<std::uint32_t*> tlsIndex{ RELOCATION_ID(528600, 415542) };
31  auto tlsDataArray = reinterpret_cast<TLSData**>(__readgsqword(0x58));
32  return tlsDataArray[*tlsIndex];
33  }
34 }
#define KEEP_FOR_RE()
Definition: PCH.h:713
#define RELOCATION_ID(SE, AE)
Definition: PCH.h:702
Definition: Relocation.h:210
Definition: BSExtraData.h:9
Definition: ExtraDataList.h:51
Definition: AbsorbEffect.h:6
static TLSData * GetStaticTLSData()
Definition: TLSData.h:28
Definition: TLSData.h:10
std::uint32_t pad014
Definition: TLSData.h:14
ExtraDataList * cachedExtraDataList
Definition: TLSData.h:15
std::uint32_t stateCounter
Definition: TLSData.h:13
std::uint8_t unk601[0x167]
Definition: TLSData.h:19
std::uint32_t taskFlag
Definition: TLSData.h:20
static constexpr uint32_t CACHED_EXTRA_DATA_SIZE
Definition: TLSData.h:11
std::uint8_t unk5D0[0x30]
Definition: TLSData.h:17
std::uint8_t unk000[0x10]
Definition: TLSData.h:12
bool consoleMode
Definition: TLSData.h:18
BSExtraData * cachedExtraData[CACHED_EXTRA_DATA_SIZE]
Definition: TLSData.h:16