Revert "refactor(Dalamud): switch to file-scoped namespaces"

This reverts commit b5f34c3199.
This commit is contained in:
goat 2021-11-18 15:23:40 +01:00
parent d473826247
commit 1561fbac00
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5
325 changed files with 45549 additions and 45209 deletions

View file

@ -1,46 +1,47 @@
using System;
using System.Runtime.Serialization;
namespace Dalamud.Memory.Exceptions;
/// <summary>
/// An exception thrown when VirtualAlloc fails.
/// </summary>
public class MemoryAllocationException : MemoryException
namespace Dalamud.Memory.Exceptions
{
/// <summary>
/// Initializes a new instance of the <see cref="MemoryAllocationException"/> class.
/// An exception thrown when VirtualAlloc fails.
/// </summary>
public MemoryAllocationException()
public class MemoryAllocationException : MemoryException
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryAllocationException"/> class.
/// </summary>
public MemoryAllocationException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryAllocationException"/> class.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public MemoryAllocationException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryAllocationException"/> class.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public MemoryAllocationException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryAllocationException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception.</param>
public MemoryAllocationException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryAllocationException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception.</param>
public MemoryAllocationException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryAllocationException"/> class.
/// </summary>
/// <param name="info">The object that holds the serialized data about the exception being thrown.</param>
/// <param name="context">The object that contains contextual information about the source or destination.</param>
protected MemoryAllocationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
/// <summary>
/// Initializes a new instance of the <see cref="MemoryAllocationException"/> class.
/// </summary>
/// <param name="info">The object that holds the serialized data about the exception being thrown.</param>
/// <param name="context">The object that contains contextual information about the source or destination.</param>
protected MemoryAllocationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

View file

@ -1,46 +1,47 @@
using System;
using System.Runtime.Serialization;
namespace Dalamud.Memory.Exceptions;
/// <summary>
/// The base exception when thrown from Dalamud.Memory.
/// </summary>
public abstract class MemoryException : Exception
namespace Dalamud.Memory.Exceptions
{
/// <summary>
/// Initializes a new instance of the <see cref="MemoryException"/> class.
/// The base exception when thrown from Dalamud.Memory.
/// </summary>
public MemoryException()
public abstract class MemoryException : Exception
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryException"/> class.
/// </summary>
public MemoryException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryException"/> class.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public MemoryException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryException"/> class.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public MemoryException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception.</param>
public MemoryException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception.</param>
public MemoryException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryException"/> class.
/// </summary>
/// <param name="info">The object that holds the serialized data about the exception being thrown.</param>
/// <param name="context">The object that contains contextual information about the source or destination.</param>
protected MemoryException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
/// <summary>
/// Initializes a new instance of the <see cref="MemoryException"/> class.
/// </summary>
/// <param name="info">The object that holds the serialized data about the exception being thrown.</param>
/// <param name="context">The object that contains contextual information about the source or destination.</param>
protected MemoryException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

View file

@ -1,46 +1,47 @@
using System;
using System.Runtime.Serialization;
namespace Dalamud.Memory.Exceptions;
/// <summary>
/// An exception thrown when VirtualProtect fails.
/// </summary>
public class MemoryPermissionException : MemoryException
namespace Dalamud.Memory.Exceptions
{
/// <summary>
/// Initializes a new instance of the <see cref="MemoryPermissionException"/> class.
/// An exception thrown when VirtualProtect fails.
/// </summary>
public MemoryPermissionException()
public class MemoryPermissionException : MemoryException
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryPermissionException"/> class.
/// </summary>
public MemoryPermissionException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryPermissionException"/> class.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public MemoryPermissionException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryPermissionException"/> class.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public MemoryPermissionException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryPermissionException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception.</param>
public MemoryPermissionException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryPermissionException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception.</param>
public MemoryPermissionException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryPermissionException"/> class.
/// </summary>
/// <param name="info">The object that holds the serialized data about the exception being thrown.</param>
/// <param name="context">The object that contains contextual information about the source or destination.</param>
protected MemoryPermissionException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
/// <summary>
/// Initializes a new instance of the <see cref="MemoryPermissionException"/> class.
/// </summary>
/// <param name="info">The object that holds the serialized data about the exception being thrown.</param>
/// <param name="context">The object that contains contextual information about the source or destination.</param>
protected MemoryPermissionException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

View file

@ -1,46 +1,47 @@
using System;
using System.Runtime.Serialization;
namespace Dalamud.Memory.Exceptions;
/// <summary>
/// An exception thrown when ReadProcessMemory fails.
/// </summary>
public class MemoryReadException : MemoryException
namespace Dalamud.Memory.Exceptions
{
/// <summary>
/// Initializes a new instance of the <see cref="MemoryReadException"/> class.
/// An exception thrown when ReadProcessMemory fails.
/// </summary>
public MemoryReadException()
public class MemoryReadException : MemoryException
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryReadException"/> class.
/// </summary>
public MemoryReadException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryReadException"/> class.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public MemoryReadException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryReadException"/> class.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public MemoryReadException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryReadException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception.</param>
public MemoryReadException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryReadException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception.</param>
public MemoryReadException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryReadException"/> class.
/// </summary>
/// <param name="info">The object that holds the serialized data about the exception being thrown.</param>
/// <param name="context">The object that contains contextual information about the source or destination.</param>
protected MemoryReadException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
/// <summary>
/// Initializes a new instance of the <see cref="MemoryReadException"/> class.
/// </summary>
/// <param name="info">The object that holds the serialized data about the exception being thrown.</param>
/// <param name="context">The object that contains contextual information about the source or destination.</param>
protected MemoryReadException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

View file

@ -1,46 +1,47 @@
using System;
using System.Runtime.Serialization;
namespace Dalamud.Memory.Exceptions;
/// <summary>
/// An exception thrown when WriteProcessMemory fails.
/// </summary>
public class MemoryWriteException : MemoryException
namespace Dalamud.Memory.Exceptions
{
/// <summary>
/// Initializes a new instance of the <see cref="MemoryWriteException"/> class.
/// An exception thrown when WriteProcessMemory fails.
/// </summary>
public MemoryWriteException()
public class MemoryWriteException : MemoryException
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryWriteException"/> class.
/// </summary>
public MemoryWriteException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryWriteException"/> class.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public MemoryWriteException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryWriteException"/> class.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public MemoryWriteException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryWriteException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception.</param>
public MemoryWriteException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryWriteException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception.</param>
public MemoryWriteException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MemoryWriteException"/> class.
/// </summary>
/// <param name="info">The object that holds the serialized data about the exception being thrown.</param>
/// <param name="context">The object that contains contextual information about the source or destination.</param>
protected MemoryWriteException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
/// <summary>
/// Initializes a new instance of the <see cref="MemoryWriteException"/> class.
/// </summary>
/// <param name="info">The object that holds the serialized data about the exception being thrown.</param>
/// <param name="context">The object that contains contextual information about the source or destination.</param>
protected MemoryWriteException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -2,115 +2,116 @@ using System;
// This is a copy from NativeFunctions.MemoryProtection
namespace Dalamud.Memory;
/// <summary>
/// PAGE_* from memoryapi.
/// </summary>
[Flags]
public enum MemoryProtection
namespace Dalamud.Memory
{
// Copied from NativeFunctions to expose to the user.
/// <summary>
/// Enables execute access to the committed region of pages. An attempt to write to the committed region results
/// in an access violation. This flag is not supported by the CreateFileMapping function.
/// PAGE_* from memoryapi.
/// </summary>
Execute = 0x10,
[Flags]
public enum MemoryProtection
{
// Copied from NativeFunctions to expose to the user.
/// <summary>
/// Enables execute or read-only access to the committed region of pages. An attempt to write to the committed region
/// results in an access violation.
/// </summary>
ExecuteRead = 0x20,
/// <summary>
/// Enables execute access to the committed region of pages. An attempt to write to the committed region results
/// in an access violation. This flag is not supported by the CreateFileMapping function.
/// </summary>
Execute = 0x10,
/// <summary>
/// Enables execute, read-only, or read/write access to the committed region of pages.
/// </summary>
ExecuteReadWrite = 0x40,
/// <summary>
/// Enables execute or read-only access to the committed region of pages. An attempt to write to the committed region
/// results in an access violation.
/// </summary>
ExecuteRead = 0x20,
/// <summary>
/// Enables execute, read-only, or copy-on-write access to a mapped view of a file mapping object. An attempt to
/// write to a committed copy-on-write page results in a private copy of the page being made for the process. The
/// private page is marked as PAGE_EXECUTE_READWRITE, and the change is written to the new page. This flag is not
/// supported by the VirtualAlloc or VirtualAllocEx functions.
/// </summary>
ExecuteWriteCopy = 0x80,
/// <summary>
/// Enables execute, read-only, or read/write access to the committed region of pages.
/// </summary>
ExecuteReadWrite = 0x40,
/// <summary>
/// Disables all access to the committed region of pages. An attempt to read from, write to, or execute the committed
/// region results in an access violation. This flag is not supported by the CreateFileMapping function.
/// </summary>
NoAccess = 0x01,
/// <summary>
/// Enables execute, read-only, or copy-on-write access to a mapped view of a file mapping object. An attempt to
/// write to a committed copy-on-write page results in a private copy of the page being made for the process. The
/// private page is marked as PAGE_EXECUTE_READWRITE, and the change is written to the new page. This flag is not
/// supported by the VirtualAlloc or VirtualAllocEx functions.
/// </summary>
ExecuteWriteCopy = 0x80,
/// <summary>
/// Enables read-only access to the committed region of pages. An attempt to write to the committed region results
/// in an access violation. If Data Execution Prevention is enabled, an attempt to execute code in the committed
/// region results in an access violation.
/// </summary>
ReadOnly = 0x02,
/// <summary>
/// Disables all access to the committed region of pages. An attempt to read from, write to, or execute the committed
/// region results in an access violation. This flag is not supported by the CreateFileMapping function.
/// </summary>
NoAccess = 0x01,
/// <summary>
/// Enables read-only or read/write access to the committed region of pages. If Data Execution Prevention is enabled,
/// attempting to execute code in the committed region results in an access violation.
/// </summary>
ReadWrite = 0x04,
/// <summary>
/// Enables read-only access to the committed region of pages. An attempt to write to the committed region results
/// in an access violation. If Data Execution Prevention is enabled, an attempt to execute code in the committed
/// region results in an access violation.
/// </summary>
ReadOnly = 0x02,
/// <summary>
/// Enables read-only or copy-on-write access to a mapped view of a file mapping object. An attempt to write to
/// a committed copy-on-write page results in a private copy of the page being made for the process. The private
/// page is marked as PAGE_READWRITE, and the change is written to the new page. If Data Execution Prevention is
/// enabled, attempting to execute code in the committed region results in an access violation. This flag is not
/// supported by the VirtualAlloc or VirtualAllocEx functions.
/// </summary>
WriteCopy = 0x08,
/// <summary>
/// Enables read-only or read/write access to the committed region of pages. If Data Execution Prevention is enabled,
/// attempting to execute code in the committed region results in an access violation.
/// </summary>
ReadWrite = 0x04,
/// <summary>
/// Sets all locations in the pages as invalid targets for CFG. Used along with any execute page protection like
/// PAGE_EXECUTE, PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE and PAGE_EXECUTE_WRITECOPY. Any indirect call to locations
/// in those pages will fail CFG checks and the process will be terminated. The default behavior for executable
/// pages allocated is to be marked valid call targets for CFG. This flag is not supported by the VirtualProtect
/// or CreateFileMapping functions.
/// </summary>
TargetsInvalid = 0x40000000,
/// <summary>
/// Enables read-only or copy-on-write access to a mapped view of a file mapping object. An attempt to write to
/// a committed copy-on-write page results in a private copy of the page being made for the process. The private
/// page is marked as PAGE_READWRITE, and the change is written to the new page. If Data Execution Prevention is
/// enabled, attempting to execute code in the committed region results in an access violation. This flag is not
/// supported by the VirtualAlloc or VirtualAllocEx functions.
/// </summary>
WriteCopy = 0x08,
/// <summary>
/// Pages in the region will not have their CFG information updated while the protection changes for VirtualProtect.
/// For example, if the pages in the region was allocated using PAGE_TARGETS_INVALID, then the invalid information
/// will be maintained while the page protection changes. This flag is only valid when the protection changes to
/// an executable type like PAGE_EXECUTE, PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE and PAGE_EXECUTE_WRITECOPY.
/// The default behavior for VirtualProtect protection change to executable is to mark all locations as valid call
/// targets for CFG.
/// </summary>
TargetsNoUpdate = TargetsInvalid,
/// <summary>
/// Sets all locations in the pages as invalid targets for CFG. Used along with any execute page protection like
/// PAGE_EXECUTE, PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE and PAGE_EXECUTE_WRITECOPY. Any indirect call to locations
/// in those pages will fail CFG checks and the process will be terminated. The default behavior for executable
/// pages allocated is to be marked valid call targets for CFG. This flag is not supported by the VirtualProtect
/// or CreateFileMapping functions.
/// </summary>
TargetsInvalid = 0x40000000,
/// <summary>
/// Pages in the region become guard pages. Any attempt to access a guard page causes the system to raise a
/// STATUS_GUARD_PAGE_VIOLATION exception and turn off the guard page status. Guard pages thus act as a one-time
/// access alarm. For more information, see Creating Guard Pages. When an access attempt leads the system to turn
/// off guard page status, the underlying page protection takes over. If a guard page exception occurs during a
/// system service, the service typically returns a failure status indicator. This value cannot be used with
/// PAGE_NOACCESS. This flag is not supported by the CreateFileMapping function.
/// </summary>
Guard = 0x100,
/// <summary>
/// Pages in the region will not have their CFG information updated while the protection changes for VirtualProtect.
/// For example, if the pages in the region was allocated using PAGE_TARGETS_INVALID, then the invalid information
/// will be maintained while the page protection changes. This flag is only valid when the protection changes to
/// an executable type like PAGE_EXECUTE, PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE and PAGE_EXECUTE_WRITECOPY.
/// The default behavior for VirtualProtect protection change to executable is to mark all locations as valid call
/// targets for CFG.
/// </summary>
TargetsNoUpdate = TargetsInvalid,
/// <summary>
/// Sets all pages to be non-cachable. Applications should not use this attribute except when explicitly required
/// for a device. Using the interlocked functions with memory that is mapped with SEC_NOCACHE can result in an
/// EXCEPTION_ILLEGAL_INSTRUCTION exception. The PAGE_NOCACHE flag cannot be used with the PAGE_GUARD, PAGE_NOACCESS,
/// or PAGE_WRITECOMBINE flags. The PAGE_NOCACHE flag can be used only when allocating private memory with the
/// VirtualAlloc, VirtualAllocEx, or VirtualAllocExNuma functions. To enable non-cached memory access for shared
/// memory, specify the SEC_NOCACHE flag when calling the CreateFileMapping function.
/// </summary>
NoCache = 0x200,
/// <summary>
/// Pages in the region become guard pages. Any attempt to access a guard page causes the system to raise a
/// STATUS_GUARD_PAGE_VIOLATION exception and turn off the guard page status. Guard pages thus act as a one-time
/// access alarm. For more information, see Creating Guard Pages. When an access attempt leads the system to turn
/// off guard page status, the underlying page protection takes over. If a guard page exception occurs during a
/// system service, the service typically returns a failure status indicator. This value cannot be used with
/// PAGE_NOACCESS. This flag is not supported by the CreateFileMapping function.
/// </summary>
Guard = 0x100,
/// <summary>
/// Sets all pages to be write-combined. Applications should not use this attribute except when explicitly required
/// for a device. Using the interlocked functions with memory that is mapped as write-combined can result in an
/// EXCEPTION_ILLEGAL_INSTRUCTION exception. The PAGE_WRITECOMBINE flag cannot be specified with the PAGE_NOACCESS,
/// PAGE_GUARD, and PAGE_NOCACHE flags. The PAGE_WRITECOMBINE flag can be used only when allocating private memory
/// with the VirtualAlloc, VirtualAllocEx, or VirtualAllocExNuma functions. To enable write-combined memory access
/// for shared memory, specify the SEC_WRITECOMBINE flag when calling the CreateFileMapping function.
/// </summary>
WriteCombine = 0x400,
/// <summary>
/// Sets all pages to be non-cachable. Applications should not use this attribute except when explicitly required
/// for a device. Using the interlocked functions with memory that is mapped with SEC_NOCACHE can result in an
/// EXCEPTION_ILLEGAL_INSTRUCTION exception. The PAGE_NOCACHE flag cannot be used with the PAGE_GUARD, PAGE_NOACCESS,
/// or PAGE_WRITECOMBINE flags. The PAGE_NOCACHE flag can be used only when allocating private memory with the
/// VirtualAlloc, VirtualAllocEx, or VirtualAllocExNuma functions. To enable non-cached memory access for shared
/// memory, specify the SEC_NOCACHE flag when calling the CreateFileMapping function.
/// </summary>
NoCache = 0x200,
/// <summary>
/// Sets all pages to be write-combined. Applications should not use this attribute except when explicitly required
/// for a device. Using the interlocked functions with memory that is mapped as write-combined can result in an
/// EXCEPTION_ILLEGAL_INSTRUCTION exception. The PAGE_WRITECOMBINE flag cannot be specified with the PAGE_NOACCESS,
/// PAGE_GUARD, and PAGE_NOCACHE flags. The PAGE_WRITECOMBINE flag can be used only when allocating private memory
/// with the VirtualAlloc, VirtualAllocEx, or VirtualAllocExNuma functions. To enable write-combined memory access
/// for shared memory, specify the SEC_WRITECOMBINE flag when calling the CreateFileMapping function.
/// </summary>
WriteCombine = 0x400,
}
}