-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
2,457 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
QuickLook.Plugin/QuickLook.Plugin.PEViewer/FluentBorder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Media; | ||
|
||
namespace QuickLook.Plugin.PEViewer; | ||
|
||
public class FluentBorder : Decorator | ||
{ | ||
public static readonly DependencyProperty CornerRadiusProperty = | ||
DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(FluentBorder), new FrameworkPropertyMetadata(new CornerRadius())); | ||
|
||
public CornerRadius CornerRadius | ||
{ | ||
get => (CornerRadius)GetValue(CornerRadiusProperty); | ||
set => SetValue(CornerRadiusProperty, value); | ||
} | ||
|
||
public static readonly DependencyProperty BackgroundProperty = | ||
DependencyProperty.Register("Background", typeof(Brush), typeof(FluentBorder), new FrameworkPropertyMetadata(Brushes.Transparent)); | ||
|
||
public Brush Background | ||
{ | ||
get => (Brush)GetValue(BackgroundProperty); | ||
set => SetValue(BackgroundProperty, value); | ||
} | ||
|
||
protected override void OnRender(DrawingContext drawingContext) | ||
{ | ||
if (Child != null) | ||
{ | ||
Rect rect = new(new Point(0, 0), RenderSize); | ||
drawingContext.DrawRoundedRectangle(Background, new Pen(Brushes.Transparent, 1), rect, CornerRadius.TopLeft, CornerRadius.TopRight); | ||
} | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
QuickLook.Plugin/QuickLook.Plugin.PEViewer/PEImageParser/ImageCharacteristics.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System; | ||
|
||
namespace QuickLook.Plugin.PEViewer.PEImageParser; | ||
|
||
/// <summary> | ||
/// Specifies the values for the <see cref="ImageCoffHeader.Characteristics" /> property of the COFF header of a PE image file. | ||
/// </summary> | ||
[Flags] | ||
public enum ImageCharacteristics : ushort | ||
{ | ||
/// <summary> | ||
/// Specifies that the file does not contain base relocations and must therefore be loaded at its preferred base address. If the base address is not available, the loader reports an error. The default behavior of the linker is to strip base relocations from executable (EXE) files. | ||
/// </summary> | ||
RelocationStripped = 0x1, | ||
|
||
/// <summary> | ||
/// Specifies that the image file is valid and can be run. If this flag is not set, it indicates a linker error. | ||
/// </summary> | ||
Executable = 0x2, | ||
|
||
/// <summary> | ||
/// Specifies that COFF line numbers have been removed. This flag is deprecated and should be zero. | ||
/// </summary> | ||
LineNumbersStripped = 0x4, | ||
|
||
/// <summary> | ||
/// Specifies that COFF symbol table entries for local symbols have been removed. This flag is deprecated and should be zero. | ||
/// </summary> | ||
SymbolsStripped = 0x8, | ||
|
||
/// <summary> | ||
/// Specifies to aggressively trim working set. This flag is deprecated for Windows 2000 and later and must be zero. | ||
/// </summary> | ||
AggressivelyTrimWorkingSet = 0x10, | ||
|
||
/// <summary> | ||
/// Specifies that the application can handle > 2 GB addresses. | ||
/// </summary> | ||
LargeAddressAware = 0x20, | ||
|
||
/// <summary> | ||
/// Specifies little endian: The least significant bit (LSB) precedes the most significant bit (MSB) in memory. This flag is deprecated and should be zero. | ||
/// </summary> | ||
BytesReversedLo = 0x80, | ||
|
||
/// <summary> | ||
/// Specifies that the machine is based on a 32-bit-word architecture. | ||
/// </summary> | ||
Machine32 = 0x100, | ||
|
||
/// <summary> | ||
/// Specifies that debugging information is removed from the image file. | ||
/// </summary> | ||
DebugStripped = 0x200, | ||
|
||
/// <summary> | ||
/// Specifies that if the image is on removable media, to fully load it and copy it to the swap file. | ||
/// </summary> | ||
RemovableRunFromSwap = 0x400, | ||
|
||
/// <summary> | ||
/// Specifies that if the image is on network media, to fully load it and copy it to the swap file. | ||
/// </summary> | ||
NetRunFromSwap = 0x800, | ||
|
||
/// <summary> | ||
/// Specifies that the image file is a system file, not a user program. | ||
/// </summary> | ||
System = 0x1000, | ||
|
||
/// <summary> | ||
/// Specifies that the image file is a dynamic-link library (DLL). Such files are considered executable files for almost all purposes, although they cannot be directly run. | ||
/// </summary> | ||
Dll = 0x2000, | ||
|
||
/// <summary> | ||
/// Specifies that the file should be run only on a uniprocessor machine. | ||
/// </summary> | ||
UpSystem = 0x4000, | ||
|
||
/// <summary> | ||
/// Specifies big endian: the MSB precedes the LSB in memory. This flag is deprecated and should be zero. | ||
/// </summary> | ||
BytesReversedHi = 0x8000 | ||
} |
46 changes: 46 additions & 0 deletions
46
QuickLook.Plugin/QuickLook.Plugin.PEViewer/PEImageParser/ImageCoffHeader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
namespace QuickLook.Plugin.PEViewer.PEImageParser; | ||
|
||
/// <summary> | ||
/// Represents the COFF header of a PE image file. | ||
/// </summary> | ||
public sealed class ImageCoffHeader | ||
{ | ||
/// <summary> | ||
/// Gets the number that identifies the type of target machine. | ||
/// </summary> | ||
public ImageMachineType Machine { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets the number of sections. This indicates the size of the section table, which immediately follows the headers. | ||
/// </summary> | ||
public ushort NumberOfSections { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets the low 32 bits of the number of seconds since 01.01.1970 00:00:00, that indicates when the file was created. | ||
/// </summary> | ||
public uint TimeDateStamp { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets the file offset of the COFF symbol table, or zero if no COFF symbol table is present. This value should be zero for an image because COFF debugging information is deprecated. | ||
/// </summary> | ||
public uint PointerToSymbolTable { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets the number of entries in the symbol table. This data can be used to locate the string table, which immediately follows the symbol table. This value should be zero for an image because COFF debugging information is deprecated. | ||
/// </summary> | ||
public uint NumberOfSymbols { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets the size of the optional header, which is required for executable files but not for object files. This value should be zero for an object file. | ||
/// </summary> | ||
public ushort SizeOfOptionalHeader { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets the flags that indicate the attributes of the file. | ||
/// </summary> | ||
public ImageCharacteristics Characteristics { get; internal set; } | ||
|
||
internal ImageCoffHeader() | ||
{ | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
QuickLook.Plugin/QuickLook.Plugin.PEViewer/PEImageParser/ImageDataDirectory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Diagnostics; | ||
|
||
namespace QuickLook.Plugin.PEViewer.PEImageParser; | ||
|
||
/// <summary> | ||
/// Represents a data directory of a PE image file. | ||
/// </summary> | ||
[DebuggerDisplay($"{nameof(ImageDataDirectory)}: Name = {{Name}}, VirtualAddress = {{VirtualAddress}}, Size = {{Size}}")] | ||
public sealed class ImageDataDirectory | ||
{ | ||
/// <summary> | ||
/// Gets the name of the data directory. This may not be a valid enum value of <see cref="ImageDataDirectoryName" />, if the image has more than 14 data directories. | ||
/// </summary> | ||
public ImageDataDirectoryName Name { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets the address of the first byte of a table or string that Windows uses. | ||
/// </summary> | ||
public uint VirtualAddress { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets size of a table or string that Windows uses. | ||
/// </summary> | ||
public uint Size { get; private set; } | ||
|
||
internal ImageDataDirectory(ImageDataDirectoryName name, uint virtualAddress, uint size) | ||
{ | ||
Name = name; | ||
VirtualAddress = virtualAddress; | ||
Size = size; | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
QuickLook.Plugin/QuickLook.Plugin.PEViewer/PEImageParser/ImageDataDirectoryName.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
namespace QuickLook.Plugin.PEViewer.PEImageParser; | ||
|
||
/// <summary> | ||
/// Specifies the name of a data directory entry of a PE image file. | ||
/// </summary> | ||
public enum ImageDataDirectoryName | ||
{ | ||
/// <summary> | ||
/// Specifies the export table address and size. | ||
/// </summary> | ||
ExportTable = 0, | ||
|
||
/// <summary> | ||
/// Specifies the import table address and size. | ||
/// </summary> | ||
ImportTable = 1, | ||
|
||
/// <summary> | ||
/// Specifies the resource table address and size. | ||
/// </summary> | ||
ResourceTable = 2, | ||
|
||
/// <summary> | ||
/// Specifies the exception table address and size. | ||
/// </summary> | ||
ExceptionTable = 3, | ||
|
||
/// <summary> | ||
/// Specifies the attribute certificate table address and size. | ||
/// </summary> | ||
CertificateTable = 4, | ||
|
||
/// <summary> | ||
/// Specifies the base relocation table address and size. | ||
/// </summary> | ||
BaseRelocationTable = 5, | ||
|
||
/// <summary> | ||
/// Specifies the debug data starting address and size. | ||
/// </summary> | ||
DebugDirectory = 6, | ||
|
||
/// <summary> | ||
/// Reserved, must be zero. | ||
/// </summary> | ||
Architecture = 7, | ||
|
||
/// <summary> | ||
/// Specifies the RVA of the value to be stored in the global pointer register. The size member of this structure must be set to zero. | ||
/// </summary> | ||
GlobalPointer = 8, | ||
|
||
/// <summary> | ||
/// Specifies the thread local storage (TLS) table address and size. | ||
/// </summary> | ||
TlsTable = 9, | ||
|
||
/// <summary> | ||
/// Specifies the load configuration table address and size. | ||
/// </summary> | ||
LoadConfigurationTable = 10, | ||
|
||
/// <summary> | ||
/// Specifies the bound import table address and size. | ||
/// </summary> | ||
BoundImportTable = 11, | ||
|
||
/// <summary> | ||
/// Specifies the import address table address and size. | ||
/// </summary> | ||
ImportAddressTable = 12, | ||
|
||
/// <summary> | ||
/// Specifies the delay import descriptor address and size. | ||
/// </summary> | ||
DelayImportDescriptors = 13, | ||
|
||
/// <summary> | ||
/// Specifies the CLR runtime header address and size. | ||
/// </summary> | ||
ClrRuntimeHeader = 14, | ||
} |
65 changes: 65 additions & 0 deletions
65
QuickLook.Plugin/QuickLook.Plugin.PEViewer/PEImageParser/ImageDllCharacteristics.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
|
||
namespace QuickLook.Plugin.PEViewer.PEImageParser; | ||
|
||
/// <summary> | ||
/// Specifies the values for the <see cref="ImageOptionalHeader.DllCharacteristics" /> property of the optional header of a PE image file. | ||
/// </summary> | ||
[Flags] | ||
public enum ImageDllCharacteristics : ushort | ||
{ | ||
/// <summary> | ||
/// Specifies that the image can handle a high entropy 64-bit virtual address space. | ||
/// </summary> | ||
HighEntropyVA = 0x20, | ||
|
||
/// <summary> | ||
/// Specifies that the DLL can be relocated at load time. | ||
/// </summary> | ||
DynamicBase = 0x40, | ||
|
||
/// <summary> | ||
/// Specifies that Code Integrity checks are enforced. | ||
/// </summary> | ||
ForceIntegrity = 0x80, | ||
|
||
/// <summary> | ||
/// Specifies that the image is NX compatible. | ||
/// </summary> | ||
NxCompatible = 0x100, | ||
|
||
/// <summary> | ||
/// Specifies that the image is isolation aware, but the image is not isolated. | ||
/// </summary> | ||
IsolationAware = 0x200, | ||
|
||
/// <summary> | ||
/// Specifies that the image does not use structured exception (SE) handling. No SE handler may be called in the image. | ||
/// </summary> | ||
NoSEH = 0x400, | ||
|
||
/// <summary> | ||
/// Specifies that the image is not bound. | ||
/// </summary> | ||
DoNotBind = 0x800, | ||
|
||
/// <summary> | ||
/// Specifies that the image must execute in an AppContainer. | ||
/// </summary> | ||
AppContainer = 0x1000, | ||
|
||
/// <summary> | ||
/// Specifies that the image is a WDM driver. | ||
/// </summary> | ||
WdmDriver = 0x2000, | ||
|
||
/// <summary> | ||
/// Specifies that the image supports Control Flow Guard. | ||
/// </summary> | ||
ControlFlowGuard = 0x4000, | ||
|
||
/// <summary> | ||
/// Specifies that the image is terminal Server aware. | ||
/// </summary> | ||
TerminalServerAware = 0x8000, | ||
} |
Oops, something went wrong.