mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-19 16:08:02 +03:00
Update code style to follow project rules with one-liner namespace declarations
This commit is contained in:
@ -1,12 +1,10 @@
|
||||
using System;
|
||||
namespace X86Disassembler.PE;
|
||||
|
||||
namespace X86Disassembler.PE
|
||||
/// <summary>
|
||||
/// Represents the DOS header of a PE file
|
||||
/// </summary>
|
||||
public class DOSHeader
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the DOS header of a PE file
|
||||
/// </summary>
|
||||
public class DOSHeader
|
||||
{
|
||||
public ushort e_magic; // Magic number (MZ)
|
||||
public ushort e_cblp; // Bytes on last page of file
|
||||
public ushort e_cp; // Pages in file
|
||||
@ -36,5 +34,4 @@ namespace X86Disassembler.PE
|
||||
e_res = new ushort[4];
|
||||
e_res2 = new ushort[10];
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
namespace X86Disassembler.PE
|
||||
namespace X86Disassembler.PE;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the Export Directory of a PE file
|
||||
/// </summary>
|
||||
public class ExportDirectory
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Export Directory of a PE file
|
||||
/// </summary>
|
||||
public class ExportDirectory
|
||||
{
|
||||
public uint Characteristics; // Reserved, must be 0
|
||||
public uint TimeDateStamp; // Time and date stamp
|
||||
public ushort MajorVersion; // Major version
|
||||
@ -26,5 +26,4 @@ namespace X86Disassembler.PE
|
||||
// Initialize string field to avoid nullability warning
|
||||
DllName = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
namespace X86Disassembler.PE
|
||||
namespace X86Disassembler.PE;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the File header of a PE file
|
||||
/// </summary>
|
||||
public class FileHeader
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the File header of a PE file
|
||||
/// </summary>
|
||||
public class FileHeader
|
||||
{
|
||||
public ushort Machine; // Target machine type
|
||||
public ushort NumberOfSections; // Number of sections
|
||||
public uint TimeDateStamp; // Time and date stamp
|
||||
@ -12,5 +12,4 @@ namespace X86Disassembler.PE
|
||||
public uint NumberOfSymbols; // Number of symbols
|
||||
public ushort SizeOfOptionalHeader; // Size of optional header
|
||||
public ushort Characteristics; // Characteristics
|
||||
}
|
||||
}
|
@ -1,12 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
namespace X86Disassembler.PE;
|
||||
|
||||
namespace X86Disassembler.PE
|
||||
/// <summary>
|
||||
/// Represents an Import Descriptor in a PE file
|
||||
/// </summary>
|
||||
public class ImportDescriptor
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an Import Descriptor in a PE file
|
||||
/// </summary>
|
||||
public class ImportDescriptor
|
||||
{
|
||||
public uint OriginalFirstThunk; // RVA to original first thunk
|
||||
public uint TimeDateStamp; // Time and date stamp
|
||||
public uint ForwarderChain; // Forwarder chain
|
||||
@ -24,5 +22,4 @@ namespace X86Disassembler.PE
|
||||
// Initialize string field to avoid nullability warning
|
||||
DllName = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
namespace X86Disassembler.PE
|
||||
namespace X86Disassembler.PE;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the Optional header of a PE file
|
||||
/// </summary>
|
||||
public class OptionalHeader
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Optional header of a PE file
|
||||
/// </summary>
|
||||
public class OptionalHeader
|
||||
{
|
||||
// Optional Header Magic values
|
||||
private const ushort PE32_MAGIC = 0x10B; // 32-bit executable
|
||||
private const ushort PE32PLUS_MAGIC = 0x20B; // 64-bit executable
|
||||
@ -69,5 +69,4 @@ namespace X86Disassembler.PE
|
||||
{
|
||||
return Magic == PE32PLUS_MAGIC;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using X86Disassembler.PE.Parsers;
|
||||
|
||||
namespace X86Disassembler.PE
|
||||
namespace X86Disassembler.PE;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a Portable Executable (PE) file format parser
|
||||
/// </summary>
|
||||
public class PEFormat
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a Portable Executable (PE) file format parser
|
||||
/// </summary>
|
||||
public class PEFormat
|
||||
{
|
||||
// DOS Header constants
|
||||
private const ushort DOS_SIGNATURE = 0x5A4D; // 'MZ'
|
||||
private const uint PE_SIGNATURE = 0x00004550; // 'PE\0\0'
|
||||
@ -232,5 +228,4 @@ namespace X86Disassembler.PE
|
||||
{
|
||||
return section.ContainsCode();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
namespace X86Disassembler.PE;
|
||||
|
||||
namespace X86Disassembler.PE
|
||||
/// <summary>
|
||||
/// Utility class for PE format operations
|
||||
/// </summary>
|
||||
public class PEUtility
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility class for PE format operations
|
||||
/// </summary>
|
||||
public class PEUtility
|
||||
{
|
||||
private readonly List<SectionHeader> _sectionHeaders;
|
||||
private readonly uint _sizeOfHeaders;
|
||||
|
||||
@ -58,5 +55,4 @@ namespace X86Disassembler.PE
|
||||
|
||||
throw new ArgumentException($"RVA {rva:X8} is not within any section");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
namespace X86Disassembler.PE.Parsers;
|
||||
|
||||
namespace X86Disassembler.PE.Parsers
|
||||
/// <summary>
|
||||
/// Parser for the DOS header of a PE file
|
||||
/// </summary>
|
||||
public class DOSHeaderParser : IParser<DOSHeader>
|
||||
{
|
||||
/// <summary>
|
||||
/// Parser for the DOS header of a PE file
|
||||
/// </summary>
|
||||
public class DOSHeaderParser : IParser<DOSHeader>
|
||||
{
|
||||
// DOS Header constants
|
||||
private const ushort DOS_SIGNATURE = 0x5A4D; // 'MZ'
|
||||
|
||||
@ -59,5 +56,4 @@ namespace X86Disassembler.PE.Parsers
|
||||
|
||||
return header;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace X86Disassembler.PE.Parsers
|
||||
namespace X86Disassembler.PE.Parsers;
|
||||
|
||||
/// <summary>
|
||||
/// Parser for the Export Directory of a PE file
|
||||
/// </summary>
|
||||
public class ExportDirectoryParser
|
||||
{
|
||||
/// <summary>
|
||||
/// Parser for the Export Directory of a PE file
|
||||
/// </summary>
|
||||
public class ExportDirectoryParser
|
||||
{
|
||||
private readonly PEUtility _utility;
|
||||
|
||||
public ExportDirectoryParser(PEUtility utility)
|
||||
@ -172,5 +169,4 @@ namespace X86Disassembler.PE.Parsers
|
||||
|
||||
return exportedFunctions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
using System.IO;
|
||||
namespace X86Disassembler.PE.Parsers;
|
||||
|
||||
namespace X86Disassembler.PE.Parsers
|
||||
/// <summary>
|
||||
/// Parser for the File header of a PE file
|
||||
/// </summary>
|
||||
public class FileHeaderParser : IParser<FileHeader>
|
||||
{
|
||||
/// <summary>
|
||||
/// Parser for the File header of a PE file
|
||||
/// </summary>
|
||||
public class FileHeaderParser : IParser<FileHeader>
|
||||
{
|
||||
/// <summary>
|
||||
/// Parse the File header from the binary reader
|
||||
/// </summary>
|
||||
@ -26,5 +24,4 @@ namespace X86Disassembler.PE.Parsers
|
||||
|
||||
return header;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,15 @@
|
||||
using System.IO;
|
||||
namespace X86Disassembler.PE.Parsers;
|
||||
|
||||
namespace X86Disassembler.PE.Parsers
|
||||
/// <summary>
|
||||
/// Interface for PE format component parsers
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of component to parse</typeparam>
|
||||
public interface IParser<out T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for PE format component parsers
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of component to parse</typeparam>
|
||||
public interface IParser<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Parse a component from the binary reader
|
||||
/// </summary>
|
||||
/// <param name="reader">The binary reader positioned at the start of the component</param>
|
||||
/// <returns>The parsed component</returns>
|
||||
T Parse(BinaryReader reader);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace X86Disassembler.PE.Parsers
|
||||
namespace X86Disassembler.PE.Parsers;
|
||||
|
||||
/// <summary>
|
||||
/// Parser for Import Descriptors in a PE file
|
||||
/// </summary>
|
||||
public class ImportDescriptorParser
|
||||
{
|
||||
/// <summary>
|
||||
/// Parser for Import Descriptors in a PE file
|
||||
/// </summary>
|
||||
public class ImportDescriptorParser
|
||||
{
|
||||
private readonly PEUtility _utility;
|
||||
|
||||
public ImportDescriptorParser(PEUtility utility)
|
||||
@ -188,5 +185,4 @@ namespace X86Disassembler.PE.Parsers
|
||||
Console.WriteLine($"Error parsing imported functions for {descriptor.DllName}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
namespace X86Disassembler.PE.Parsers;
|
||||
|
||||
namespace X86Disassembler.PE.Parsers
|
||||
/// <summary>
|
||||
/// Parser for the Optional header of a PE file
|
||||
/// </summary>
|
||||
public class OptionalHeaderParser : IParser<OptionalHeader>
|
||||
{
|
||||
/// <summary>
|
||||
/// Parser for the Optional header of a PE file
|
||||
/// </summary>
|
||||
public class OptionalHeaderParser : IParser<OptionalHeader>
|
||||
{
|
||||
// Optional Header Magic values
|
||||
private const ushort PE32_MAGIC = 0x10B; // 32-bit executable
|
||||
private const ushort PE32PLUS_MAGIC = 0x20B; // 64-bit executable
|
||||
@ -110,5 +107,4 @@ namespace X86Disassembler.PE.Parsers
|
||||
{
|
||||
return header.Magic == PE32PLUS_MAGIC;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +1,12 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace X86Disassembler.PE.Parsers
|
||||
namespace X86Disassembler.PE.Parsers;
|
||||
|
||||
/// <summary>
|
||||
/// Parser for section headers in a PE file
|
||||
/// </summary>
|
||||
public class SectionHeaderParser : IParser<SectionHeader>
|
||||
{
|
||||
/// <summary>
|
||||
/// Parser for section headers in a PE file
|
||||
/// </summary>
|
||||
public class SectionHeaderParser : IParser<SectionHeader>
|
||||
{
|
||||
/// <summary>
|
||||
/// Parse a section header from the binary reader
|
||||
/// </summary>
|
||||
@ -34,5 +33,4 @@ namespace X86Disassembler.PE.Parsers
|
||||
|
||||
return header;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
namespace X86Disassembler.PE
|
||||
namespace X86Disassembler.PE;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a section header in a PE file
|
||||
/// </summary>
|
||||
public class SectionHeader
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a section header in a PE file
|
||||
/// </summary>
|
||||
public class SectionHeader
|
||||
{
|
||||
// Section characteristics flags
|
||||
private const uint IMAGE_SCN_CNT_CODE = 0x00000020; // Section contains code
|
||||
private const uint IMAGE_SCN_MEM_EXECUTE = 0x20000000; // Section is executable
|
||||
@ -67,5 +67,4 @@ namespace X86Disassembler.PE
|
||||
{
|
||||
return (Characteristics & IMAGE_SCN_MEM_EXECUTE) != 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using X86Disassembler.PE;
|
||||
|
||||
namespace X86Disassembler
|
||||
namespace X86Disassembler;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
// Path to the DLL file to disassemble
|
||||
private const string DllPath = @"C:\Program Files (x86)\Nikita\Iron Strategy\Terrain.dll"; // Example path, replace with your target DLL
|
||||
|
||||
@ -144,5 +142,4 @@ namespace X86Disassembler
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user