1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
9 // Zapping of headers (IMAGE_COR20_HEADER, CORCOMPILE_HEADER, etc.)
11 // ======================================================================================
13 #ifndef __ZAPHEADERS_H__
14 #define __ZAPHEADERS_H__
20 class ZapCorHeader : public ZapNode
23 ZapCorHeader(ZapImage * pImage)
27 virtual DWORD GetSize()
29 return sizeof(IMAGE_COR20_HEADER);
32 virtual UINT GetAlignment()
37 virtual ZapNodeType GetType()
39 return ZapNodeType_CorHeader;
42 virtual void Save(ZapWriter * pZapWriter)
44 ZapImage::GetImage(pZapWriter)->SaveCorHeader();
52 class ZapNativeHeader : public ZapNode
55 ZapNativeHeader(ZapImage * pImage)
59 virtual DWORD GetSize()
61 return sizeof(CORCOMPILE_HEADER);
64 virtual UINT GetAlignment()
69 virtual ZapNodeType GetType()
71 return ZapNodeType_NativeHeader;
74 virtual void Save(ZapWriter * pZapWriter)
76 ZapImage::GetImage(pZapWriter)->SaveNativeHeader();
81 // CORCOMPILE_VERSION_INFO
83 class ZapVersionInfo : public ZapNode
85 CORCOMPILE_VERSION_INFO m_versionInfo;
88 ZapVersionInfo(CORCOMPILE_VERSION_INFO * pVersionInfo)
90 memcpy(&m_versionInfo, pVersionInfo, sizeof(m_versionInfo));
93 CORCOMPILE_VERSION_INFO * GetData()
95 return &m_versionInfo;
98 virtual DWORD GetSize()
100 return sizeof(CORCOMPILE_VERSION_INFO);
103 virtual UINT GetAlignment()
105 return sizeof(DWORD);
108 virtual ZapNodeType GetType()
110 return ZapNodeType_VersionInfo;
113 virtual void Save(ZapWriter * pZapWriter)
115 pZapWriter->Write(&m_versionInfo, sizeof(m_versionInfo));
120 // CORCOMPILE_CORCOMPILE_DEPENDENCY
122 class ZapDependencies : public ZapNode
124 DWORD m_cDependencies;
125 CORCOMPILE_DEPENDENCY * m_pDependencies;
128 ZapDependencies(CORCOMPILE_DEPENDENCY * pDependencies, DWORD cDependencies)
129 : m_cDependencies(cDependencies), m_pDependencies(pDependencies)
133 virtual DWORD GetSize()
135 return sizeof(CORCOMPILE_DEPENDENCY) * m_cDependencies;
138 virtual UINT GetAlignment()
140 return sizeof(ULARGE_INTEGER);
143 virtual ZapNodeType GetType()
145 return ZapNodeType_Dependencies;
148 virtual void Save(ZapWriter * pZapWriter)
150 pZapWriter->Write(m_pDependencies, sizeof(CORCOMPILE_DEPENDENCY) * m_cDependencies);
155 // CORCOMPILE_CODE_MANAGER_ENTRY
158 class ZapCodeManagerEntry : public ZapNode
161 ZapCodeManagerEntry(ZapImage * pImage)
165 virtual DWORD GetSize()
167 return sizeof(CORCOMPILE_CODE_MANAGER_ENTRY);
170 virtual UINT GetAlignment()
172 return sizeof(DWORD);
175 virtual ZapNodeType GetType()
177 return ZapNodeType_CodeManagerEntry;
180 virtual void Save(ZapWriter * pZapWriter)
182 ZapImage::GetImage(pZapWriter)->SaveCodeManagerEntry();
190 class ZapVersionResource : public ZapNode
192 ZapNode * m_pVersionData;
195 ZapVersionResource(ZapNode * pVersionData)
196 : m_pVersionData(pVersionData)
200 struct VersionResourceHeader {
201 IMAGE_RESOURCE_DIRECTORY TypeDir;
202 IMAGE_RESOURCE_DIRECTORY_ENTRY TypeEntry;
203 IMAGE_RESOURCE_DIRECTORY NameDir;
204 IMAGE_RESOURCE_DIRECTORY_ENTRY NameEntry;
205 IMAGE_RESOURCE_DIRECTORY LangDir;
206 IMAGE_RESOURCE_DIRECTORY_ENTRY LangEntry;
207 IMAGE_RESOURCE_DATA_ENTRY DataEntry;
211 virtual DWORD GetSize()
213 return sizeof(VersionResourceHeader);
216 virtual UINT GetAlignment()
218 return sizeof(DWORD);
221 virtual ZapNodeType GetType()
223 return ZapNodeType_VersionResource;
226 virtual void Save(ZapWriter * pZapWriter);
234 class ZapDebugDirectory : public ZapNode
236 ZapNode * m_pNGenPdbDebugData;
237 DWORD m_nDebugDirectory;
238 IMAGE_DEBUG_DIRECTORY * m_pDebugDirectory;
239 ZapNode ** m_ppDebugData;
242 ZapDebugDirectory(ZapNode *pNGenPdbDebugData, DWORD nDebugDirectory, PIMAGE_DEBUG_DIRECTORY pDebugDirectory, ZapNode ** ppDebugData)
243 : m_pNGenPdbDebugData(pNGenPdbDebugData),
244 m_nDebugDirectory(nDebugDirectory),
245 m_pDebugDirectory(pDebugDirectory),
246 m_ppDebugData(ppDebugData)
250 virtual DWORD GetSize()
252 #if defined(NO_NGENPDB)
253 return sizeof(IMAGE_DEBUG_DIRECTORY) * m_nDebugDirectory;
255 // Add one for NGen PDB debug directory entry
256 return sizeof(IMAGE_DEBUG_DIRECTORY) * (m_nDebugDirectory + 1);
260 virtual UINT GetAlignment()
262 return sizeof(DWORD);
265 virtual ZapNodeType GetType()
267 return ZapNodeType_DebugDirectory;
270 void SaveOriginalDebugDirectoryEntry(ZapWriter *pZapWriter);
271 void SaveNGenDebugDirectoryEntry(ZapWriter *pZapWriter);
272 virtual void Save(ZapWriter * pZapWriter);
276 // PE Style exports. Currently can only save an empty list of exports
277 // but this is useful because it avoids the DLL being seen as Resource Only
278 // (which then causes SymServer to avoid copying its PDB to the cloud).
281 class ZapPEExports : public ZapNode
283 LPCWSTR m_dllFileName; // Just he DLL name without the path.
286 ZapPEExports(LPCWSTR dllPath);
287 virtual DWORD GetSize();
288 virtual UINT GetAlignment() { return sizeof(DWORD); }
289 virtual void Save(ZapWriter * pZapWriter);
293 // List of all sections for diagnostic purposes
295 class ZapVirtualSectionsTable : public ZapNode
301 ZapVirtualSectionsTable(ZapImage * pImage)
306 virtual DWORD GetSize();
308 virtual ZapNodeType GetType()
310 return ZapNodeType_VirtualSectionsTable;
313 virtual void Save(ZapWriter * pZapWriter);
316 #endif // __ZAPHEADERS_H__