2 Copyright (C) 2008 Jeroen Frijters
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
25 using IMAGE_DATA_DIRECTORY = IKVM.Reflection.Reader.IMAGE_DATA_DIRECTORY;
27 namespace IKVM.Reflection.Metadata
29 sealed class CliHeader
31 internal const uint COMIMAGE_FLAGS_ILONLY = 0x00000001;
32 internal const uint COMIMAGE_FLAGS_32BITREQUIRED = 0x00000002;
33 internal const uint COMIMAGE_FLAGS_STRONGNAMESIGNED = 0x00000008;
34 internal const uint COMIMAGE_FLAGS_NATIVE_ENTRYPOINT = 0x00000010;
35 internal const uint COMIMAGE_FLAGS_32BITPREFERRED = 0x00020000;
37 internal uint Cb = 0x48;
38 internal ushort MajorRuntimeVersion;
39 internal ushort MinorRuntimeVersion;
40 internal IMAGE_DATA_DIRECTORY MetaData;
42 internal uint EntryPointToken;
43 internal IMAGE_DATA_DIRECTORY Resources;
44 internal IMAGE_DATA_DIRECTORY StrongNameSignature;
45 internal IMAGE_DATA_DIRECTORY CodeManagerTable;
46 internal IMAGE_DATA_DIRECTORY VTableFixups;
47 internal IMAGE_DATA_DIRECTORY ExportAddressTableJumps;
48 internal IMAGE_DATA_DIRECTORY ManagedNativeHeader;
50 internal void Read(BinaryReader br)
53 MajorRuntimeVersion = br.ReadUInt16();
54 MinorRuntimeVersion = br.ReadUInt16();
56 Flags = br.ReadUInt32();
57 EntryPointToken = br.ReadUInt32();
59 StrongNameSignature.Read(br);
60 CodeManagerTable.Read(br);
61 VTableFixups.Read(br);
62 ExportAddressTableJumps.Read(br);
63 ManagedNativeHeader.Read(br);
66 internal void Write(IKVM.Reflection.Writer.MetadataWriter mw)
69 mw.Write(MajorRuntimeVersion);
70 mw.Write(MinorRuntimeVersion);
73 mw.Write(EntryPointToken);
75 StrongNameSignature.Write(mw);
76 CodeManagerTable.Write(mw);
77 VTableFixups.Write(mw);
78 ExportAddressTableJumps.Write(mw);
79 ManagedNativeHeader.Write(mw);