1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#pragma once
#include "ModuleHeaders.h"
struct StaticGcDesc;
class DispatchMap;
typedef unsigned char UInt8;
class TypeManager
{
HANDLE m_osModule;
ReadyToRunHeader * m_pHeader;
DispatchMap** m_pDispatchMapTable;
StaticGcDesc* m_pStaticsGCInfo;
StaticGcDesc* m_pThreadStaticsGCInfo;
UInt8* m_pStaticsGCDataSection;
UInt8* m_pThreadStaticsDataSection;
UInt32* m_pTlsIndex; // Pointer to TLS index if this module uses thread statics
void** m_pClasslibFunctions;
UInt32 m_nClasslibFunctions;
UInt32* m_pLoopHijackFlag;
TypeManager(HANDLE osModule, ReadyToRunHeader * pHeader, void** pClasslibFunctions, UInt32 nClasslibFunctions);
public:
static TypeManager * Create(HANDLE osModule, void * pModuleHeader, void** pClasslibFunctions, UInt32 nClasslibFunctions);
void * GetModuleSection(ReadyToRunSectionType sectionId, int * length);
DispatchMap ** GetDispatchMapLookupTable();
void EnumStaticGCRefs(void * pfnCallback, void * pvCallbackData);
HANDLE GetOsModuleHandle();
void* GetClasslibFunction(ClasslibFunctionId functionId);
UInt32* GetPointerToTlsIndex() { return m_pTlsIndex; }
void SetLoopHijackFlag(UInt32 flag) { if (m_pLoopHijackFlag != nullptr) *m_pLoopHijackFlag = flag; }
private:
struct ModuleInfoRow
{
int32_t SectionId;
int32_t Flags;
void * Start;
void * End;
bool HasEndPointer();
int GetLength();
};
void EnumStaticGCRefsBlock(void * pfnCallback, void * pvCallbackData, StaticGcDesc* pStaticGcInfo);
void EnumThreadStaticGCRefsBlock(void * pfnCallback, void * pvCallbackData, StaticGcDesc* pStaticGcInfo, UInt8* pbThreadStaticData);
};
// TypeManagerHandle represents an AOT module in MRT based runtimes.
// These handles are either a pointer to an OS module, or a pointer to a TypeManager
// When this is a pointer to a TypeManager, then the pointer will have its lowest bit
// set to indicate that it is a TypeManager pointer instead of OS module.
struct TypeManagerHandle
{
static TypeManagerHandle Null()
{
TypeManagerHandle handle;
handle._value = nullptr;
return handle;
}
static TypeManagerHandle Create(TypeManager * value)
{
TypeManagerHandle handle;
handle._value = ((uint8_t *)value) + 1;
return handle;
}
static TypeManagerHandle Create(HANDLE value)
{
TypeManagerHandle handle;
handle._value = value;
return handle;
}
void *_value;
bool IsTypeManager();
TypeManager* AsTypeManager();
HANDLE AsOsModule();
};
|