| | | 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 | | |
| | | 4 | | namespace System.Reflection.PortableExecutable |
| | | 5 | | { |
| | | 6 | | [Flags] |
| | | 7 | | public enum PEStreamOptions |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// By default the stream is disposed when <see cref="PEReader"/> is disposed and sections of the PE image are r |
| | | 11 | | /// </summary> |
| | | 12 | | Default = 0, |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Keep the stream open when the <see cref="PEReader"/> is disposed. |
| | | 16 | | /// </summary> |
| | | 17 | | LeaveOpen = 1, |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// Reads metadata section into memory right away. |
| | | 21 | | /// </summary> |
| | | 22 | | /// <remarks> |
| | | 23 | | /// Reading from other sections of the file is not allowed (<see cref="InvalidOperationException"/> is thrown by |
| | | 24 | | /// The underlying file may be closed and even deleted after <see cref="PEReader"/> is constructed. |
| | | 25 | | /// |
| | | 26 | | /// <see cref="PEReader"/> closes the stream automatically by the time the constructor returns unless <see cref= |
| | | 27 | | /// </remarks> |
| | | 28 | | PrefetchMetadata = 1 << 1, |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Reads the entire image into memory right away. |
| | | 32 | | /// </summary> |
| | | 33 | | /// <remarks> |
| | | 34 | | /// <see cref="PEReader"/> closes the stream automatically by the time the constructor returns unless <see cref= |
| | | 35 | | /// </remarks> |
| | | 36 | | PrefetchEntireImage = 1 << 2, |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Indicates that the underlying PE image has been loaded into memory by the OS loader. |
| | | 40 | | /// </summary> |
| | | 41 | | IsLoadedImage = 1 << 3, |
| | | 42 | | } |
| | | 43 | | |
| | | 44 | | internal static class PEStreamOptionsExtensions |
| | | 45 | | { |
| | | 46 | | public static bool IsValid(this PEStreamOptions options) |
| | 0 | 47 | | { |
| | 0 | 48 | | return (options & ~(PEStreamOptions.LeaveOpen | PEStreamOptions.PrefetchEntireImage | PEStreamOptions.Prefet |
| | 0 | 49 | | } |
| | | 50 | | } |
| | | 51 | | } |
| | | 52 | | |