Skip to content

Commit

Permalink
Use PascalCase with enum and struct names (#2081)
Browse files Browse the repository at this point in the history
Use PascalCase with enum and struct names
  • Loading branch information
nopara73 committed Aug 9, 2019
2 parents 10d75f6 + 17aa421 commit 75cd89a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions WalletWasabi.Packager/NSubsys/NSubsysUtil.cs
Expand Up @@ -22,19 +22,19 @@ public static bool ProcessFile(string exeFilePath)
var subsysOffset = peFile.MainHeaderOffset;

subsysVal = (SubSystemType)peFile.OptionalHeader.Subsystem;
subsysOffset += Marshal.OffsetOf<IMAGE_OPTIONAL_HEADER>(nameof(IMAGE_OPTIONAL_HEADER.Subsystem)).ToInt32();
subsysOffset += Marshal.OffsetOf<ImageOptionalHeader>(nameof(ImageOptionalHeader.Subsystem)).ToInt32();

switch (subsysVal)
{
case PeUtility.SubSystemType.IMAGE_SUBSYSTEM_WINDOWS_GUI:
case PeUtility.SubSystemType.ImageSubSystemWindowsGui:
Console.WriteLine("NSubsys: Executable file is already a Win32 App!");
return true;

case PeUtility.SubSystemType.IMAGE_SUBSYSTEM_WINDOWS_CUI:
case PeUtility.SubSystemType.ImageSubSystemWindowsCui:
Console.WriteLine("NSubsys: Console app detected...");
Console.WriteLine("NSubsys: Converting...");

var subsysSetting = BitConverter.GetBytes((ushort)SubSystemType.IMAGE_SUBSYSTEM_WINDOWS_GUI);
var subsysSetting = BitConverter.GetBytes((ushort)SubSystemType.ImageSubSystemWindowsGui);

if (!BitConverter.IsLittleEndian)
{
Expand Down
14 changes: 7 additions & 7 deletions WalletWasabi.Packager/NSubsys/PeUtility.cs
Expand Up @@ -9,19 +9,19 @@ internal class PeUtility : IDisposable
{
public enum SubSystemType : ushort
{
IMAGE_SUBSYSTEM_WINDOWS_GUI = 2,
IMAGE_SUBSYSTEM_WINDOWS_CUI = 3
ImageSubSystemWindowsGui = 2,
ImageSubSystemWindowsCui = 3
}

[StructLayout(LayoutKind.Explicit)]
public struct IMAGE_DOS_HEADER
public struct ImageDosHeader
{
[FieldOffset(60)]
public uint e_lfanew;
}

[StructLayout(LayoutKind.Explicit)]
public struct IMAGE_OPTIONAL_HEADER
public struct ImageOptionalHeader
{
[FieldOffset(68)]
public ushort Subsystem;
Expand All @@ -30,7 +30,7 @@ public struct IMAGE_OPTIONAL_HEADER
/// <summary>
/// Gets the optional header
/// </summary>
public IMAGE_OPTIONAL_HEADER OptionalHeader { get; }
public ImageOptionalHeader OptionalHeader { get; }

/// <summary>
/// Gets the PE file stream for R/W functions.
Expand All @@ -47,14 +47,14 @@ public PeUtility(string filePath)

var reader = new BinaryReader(Stream);

var dosHeader = FromBinaryReader<IMAGE_DOS_HEADER>(reader);
var dosHeader = FromBinaryReader<ImageDosHeader>(reader);

// Seek the new PE Header and skip NtHeadersSignature (4 bytes) & IMAGE_FILE_HEADER struct (20bytes).
Stream.Seek(dosHeader.e_lfanew + 4 + 20, SeekOrigin.Begin);

MainHeaderOffset = Stream.Position;

OptionalHeader = FromBinaryReader<IMAGE_OPTIONAL_HEADER>(reader);
OptionalHeader = FromBinaryReader<ImageOptionalHeader>(reader);

InternalBinReader = reader;
}
Expand Down

0 comments on commit 75cd89a

Please sign in to comment.