IKVM11
11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IMAGE_NT_HEADERS.cs
Go to the documentation of this file.
1
/*
2
Copyright (C) 2009 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
*/
24
using
System.IO;
25
26
using
DWORD
=
System
.UInt32;
27
28
namespace
IKVM.Reflection.Reader
29
{
30
31
sealed
class
IMAGE_NT_HEADERS
32
{
33
34
public
const
DWORD
MAGIC_SIGNATURE
= 0x00004550;
// "PE\0\0"
35
36
public
DWORD
Signature
;
37
public
IMAGE_FILE_HEADER
FileHeader
=
new
IMAGE_FILE_HEADER
();
38
public
IMAGE_OPTIONAL_HEADER
OptionalHeader
=
new
IMAGE_OPTIONAL_HEADER
();
39
40
internal
void
Read(BinaryReader br)
41
{
42
Signature
= br.ReadUInt32();
43
if
(
Signature
!=
IMAGE_NT_HEADERS
.
MAGIC_SIGNATURE
)
44
throw
new
BadImageFormatException();
45
46
FileHeader
.Read(br);
47
var optionalHeaderPosition = br.BaseStream.Position;
48
OptionalHeader
.Read(br);
49
50
if
(br.BaseStream.Position > optionalHeaderPosition +
FileHeader
.
SizeOfOptionalHeader
)
51
throw
new
BadImageFormatException();
52
53
br.BaseStream.Seek(optionalHeaderPosition +
FileHeader
.
SizeOfOptionalHeader
, SeekOrigin.Begin);
54
}
55
56
}
57
58
}
DWORD
System.UInt32 DWORD
Definition
IMAGE_DATA_DIRECTORY.cs:26
IKVM.Reflection.Reader.IMAGE_FILE_HEADER
Definition
IMAGE_FILE_HEADER.cs:33
IKVM.Reflection.Reader.IMAGE_FILE_HEADER.SizeOfOptionalHeader
WORD SizeOfOptionalHeader
Definition
IMAGE_FILE_HEADER.cs:49
IKVM.Reflection.Reader.IMAGE_NT_HEADERS
Definition
IMAGE_NT_HEADERS.cs:32
IKVM.Reflection.Reader.IMAGE_NT_HEADERS.MAGIC_SIGNATURE
const DWORD MAGIC_SIGNATURE
Definition
IMAGE_NT_HEADERS.cs:34
IKVM.Reflection.Reader.IMAGE_NT_HEADERS.FileHeader
IMAGE_FILE_HEADER FileHeader
Definition
IMAGE_NT_HEADERS.cs:37
IKVM.Reflection.Reader.IMAGE_NT_HEADERS.Signature
DWORD Signature
Definition
IMAGE_NT_HEADERS.cs:36
IKVM.Reflection.Reader.IMAGE_NT_HEADERS.OptionalHeader
IMAGE_OPTIONAL_HEADER OptionalHeader
Definition
IMAGE_NT_HEADERS.cs:38
IKVM.Reflection.Reader.IMAGE_OPTIONAL_HEADER
Definition
IMAGE_OPTIONAL_HEADER.cs:35
IKVM.Reflection.Signature
Definition
Signature.cs:41
IKVM.Reflection.Reader
Definition
AssemblyReader.cs:31
System
Definition
HexConverter.cs:9
src
IKVM.CoreLib
Reflection
Reader
IMAGE_NT_HEADERS.cs
Generated by
1.12.0