@@ -31,7 +31,12 @@ record struct ModuleLookupTables(
31
31
32
32
``` csharp
33
33
ModuleHandle GetModuleHandle (TargetPointer module );
34
+ TargetPointer GetRootAssembly ();
34
35
TargetPointer GetAssembly (ModuleHandle handle );
36
+ TargetPointer GetPEAssembly (ModuleHandle handle );
37
+ bool TryGetLoadedImageContents (ModuleHandle handle , out TargetPointer baseAddress , out uint size , out uint imageFlags );
38
+ bool TryGetSymbolStream (ModuleHandle handle , out TargetPointer buffer , out uint size );
39
+ bool IsProbeExtensionResultValid (ModuleHandle handle );
35
40
ModuleFlags GetFlags (ModuleHandle handle );
36
41
string GetPath (ModuleHandle handle );
37
42
string GetFileName (ModuleHandle handle );
@@ -49,12 +54,14 @@ Data descriptors used:
49
54
| Data Descriptor Name | Field | Meaning |
50
55
| --- | --- | --- |
51
56
| ` Module ` | ` Assembly ` | Assembly of the Module |
57
+ | ` Module ` | ` PEAssembly ` | PEAssembly of the Module |
52
58
| ` Module ` | ` Base ` | Pointer to start of PE file in memory |
53
59
| ` Module ` | ` Flags ` | Assembly of the Module |
54
60
| ` Module ` | ` LoaderAllocator ` | LoaderAllocator of the Module |
55
61
| ` Module ` | ` ThunkHeap ` | Pointer to the thunk heap |
56
62
| ` Module ` | ` Path ` | Path of the Module (UTF-16, null-terminated) |
57
63
| ` Module ` | ` FileName ` | File name of the Module (UTF-16, null-terminated) |
64
+ | ` Module ` | ` GrowableSymbolStream ` | Pointer to the in memory symbol stream |
58
65
| ` Module ` | ` FieldDefToDescMap ` | Mapping table |
59
66
| ` Module ` | ` ManifestModuleReferencesMap ` | Mapping table |
60
67
| ` Module ` | ` MemberRefToDescMap ` | Mapping table |
@@ -64,18 +71,92 @@ Data descriptors used:
64
71
| ` ModuleLookupMap ` | ` TableData ` | Start of the mapping table's data |
65
72
| ` ModuleLookupMap ` | ` SupportedFlagsMask ` | Mask for flag bits on lookup map entries |
66
73
| ` ModuleLookupMap ` | ` Count ` | Number of TargetPointer sized entries in this section of the map |
67
- | ` ModuleLookupMap ` | ` Next ` | Pointer to next ModuleLookupMap segment for this map
68
- | ` Assembly ` | ` IsCollectible ` | Flag indicating if this is module may be collected
74
+ | ` ModuleLookupMap ` | ` Next ` | Pointer to next ModuleLookupMap segment for this map |
75
+ | ` Assembly ` | ` IsCollectible ` | Flag indicating if this is module may be collected |
76
+ | ` PEAssembly ` | ` PEImage ` | Pointer to the PEAssembly's PEImage |
77
+ | ` PEImage ` | ` LoadedImageLayout ` | Pointer to the PEImage's loaded PEImageLayout |
78
+ | ` PEImage ` | ` ProbeExtensionResult ` | PEImage's ProbeExtensionResult |
79
+ | ` ProbeExtensionResult ` | ` Type ` | Type of ProbeExtensionResult |
80
+ | ` PEImageLayout ` | ` Base ` | Base address of the image layout |
81
+ | ` PEImageLayout ` | ` Size ` | Size of the image layout |
82
+ | ` PEImageLayout ` | ` Flags ` | Flags associated with the PEImageLayout |
83
+ | ` CGrowableSymbolStream ` | ` Buffer ` | Pointer to the raw symbol stream buffer start |
84
+ | ` CGrowableSymbolStream ` | ` Size ` | Size of the raw symbol stream buffer |
85
+ | ` AppDomain ` | ` RootAssembly ` | Pointer to the root assembly |
86
+
87
+ Global variables used:
88
+ | Global Name | Type | Purpose |
89
+ | --- | --- | --- |
90
+ | ` AppDomain ` | TargetPointer | Pointer to the global AppDomain |
91
+
69
92
70
93
``` csharp
71
94
ModuleHandle GetModuleHandle (TargetPointer modulePointer )
72
95
{
73
96
return new ModuleHandle (modulePointer );
74
97
}
75
98
99
+ TargetPointer GetRootAssembly ()
100
+ {
101
+ TargetPointer appDomainPointer = _target .ReadGlobalPointer (Constants .Globals .AppDomain );
102
+ AppDomain appDomain = // read AppDomain object starting at appDomainPointer
103
+ return appDomain .RootAssembly ;
104
+ }
105
+
76
106
TargetPointer GetAssembly (ModuleHandle handle )
77
107
{
78
- return target .ReadPointer (handle .Address + /* Module::Assrembly offset */ );
108
+ return target .ReadPointer (handle .Address + /* Module::Assembly offset */ );
109
+ }
110
+
111
+ TargetPointer GetPEAssembly (ModuleHandle handle )
112
+ {
113
+ return target .ReadPointer (handle .Address + /* Module::PEAssembly offset */ );
114
+ }
115
+
116
+ bool TryGetLoadedImageContents (ModuleHandle handle , out TargetPointer baseAddress , out uint size , out uint imageFlags )
117
+ {
118
+ baseAddress = TargetPointer .Null ;
119
+ size = 0 ;
120
+ imageFlags = 0 ;
121
+
122
+ TargetPointer peAssembly = target .ReadPointer (handle .Address + /* Module::PEAssembly offset */ );
123
+ if (peAssembly == 0 ) return false ; // no loaded PEAssembly
124
+
125
+ TargetPointer peImage = target .ReadPointer (peAssembly + /* PEAssembly::PEImage offset */ );
126
+ if (peImage == 0 ) return false ; // no loaded PEImage
127
+
128
+ TargetPointer peImageLayout = target .ReadPointer (peImage + /* PEImage::LoadedImageLayout offset */ );
129
+
130
+ baseAddress = target .ReadPointer (peImageLayout + /* PEImageLayout::Base offset */ );
131
+ size = target .Read <uint >(peImageLayout + /* PEImageLayout::Size offset */ );
132
+ imageFlags = target .Read <uint >(peImageLayout + /* PEImageLayout::Flags offset */ );
133
+ return true ;
134
+ }
135
+
136
+ bool TryGetSymbolStream (ModuleHandle handle , out TargetPointer buffer , out uint size )
137
+ {
138
+ buffer = TargetPointer .Null ;
139
+ size = 0 ;
140
+
141
+ TargetPointer growableSymbolStream = target .ReadPointer (handle .Address + /* Module::GrowableSymbolStream offset */ );
142
+ if (growableSymbolStream == 0 ) return false ; // no GrowableSymbolStream found
143
+
144
+ buffer = target .ReadPointer (growableSymbolStream + /* CGrowableSymbolStream::Buffer offset */ );
145
+ size = target .Read <uint >(growableSymbolStream + /* CGrowableSymbolStream::Size offset */ );
146
+ return true ;
147
+ }
148
+
149
+ bool IsProbeExtensionResultValid (ModuleHandle handle )
150
+ {
151
+ TargetPointer peAssembly = target .ReadPointer (handle .Address + /* Module::PEAssembly offset */ );
152
+ if (peAssembly == 0 ) return false ; // no loaded PEAssembly
153
+
154
+ TargetPointer peImage = target .ReadPointer (peAssembly + /* PEAssembly::PEImage offset */ );
155
+ if (peImage == 0 ) return false ; // no loaded PEImage
156
+
157
+ TargetPointer probeExtensionResult = target .ReadPointer (peImage + /* PEImage::ProbeExtensionResult offset */ );
158
+ int type = target .Read <int >(probeExtensionResult + /* ProbeExtensionResult::Type offset */ );
159
+ return type != 0 ; // 0 is the invalid type. See assemblyprobeextension.h for details
79
160
}
80
161
81
162
ModuleFlags GetFlags (ModuleHandle handle )
0 commit comments