IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
RESOURCEHEADER.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2010-2012 Jeroen Frijters
3
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.
7
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:
11
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.
19
20 Jeroen Frijters
21 jeroen@frijters.net
22
23*/
24using System.Text;
25
27
29{
30
32 {
33
34 internal int DataSize;
35 internal int HeaderSize;
36 internal OrdinalOrName TYPE;
37 internal OrdinalOrName NAME;
38 internal int DataVersion;
39 internal ushort MemoryFlags;
40 internal ushort LanguageId;
41 internal int Version;
42 internal int Characteristics;
43
48 internal RESOURCEHEADER(ByteReader br)
49 {
50 DataSize = br.ReadInt32();
51 HeaderSize = br.ReadInt32();
52 TYPE = ReadOrdinalOrName(br);
53 NAME = ReadOrdinalOrName(br);
54 br.Align(4);
55 DataVersion = br.ReadInt32();
56 MemoryFlags = br.ReadUInt16();
57 LanguageId = br.ReadUInt16();
58 Version = br.ReadInt32();
59 Characteristics = br.ReadInt32();
60 }
61
63 {
64 var c = br.ReadChar();
65 if (c == 0xFFFF)
66 {
67 return new OrdinalOrName(br.ReadUInt16());
68 }
69 else
70 {
71 var sb = new StringBuilder();
72 while (c != 0)
73 {
74 sb.Append(c);
75 c = br.ReadChar();
76 }
77
78 return new OrdinalOrName(sb.ToString());
79 }
80 }
81
82 }
83
84}
readonly record struct OrdinalOrName(ushort Ordinal, string Name)
static OrdinalOrName ReadOrdinalOrName(ByteReader br)