diff --git a/Dalamud.Injector/Dalamud.Injector.csproj b/Dalamud.Injector/Dalamud.Injector.csproj
index c0234500c..5d76a11f6 100644
--- a/Dalamud.Injector/Dalamud.Injector.csproj
+++ b/Dalamud.Injector/Dalamud.Injector.csproj
@@ -11,6 +11,9 @@
false
true
Portable
+ IDE1006;CS1701;CS1702
+ true
+ $(SolutionDir)\bin\Dalamud.Injector.xml
true
@@ -19,9 +22,6 @@
XIVLauncher addon injection
5.2.4.6
-
-
-
$(MSBuildProjectDirectory)\
$(AppOutputBase)=C:\goatsoft\companysecrets\injector\
@@ -33,9 +33,19 @@
dalamud.ico
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
@@ -45,6 +55,6 @@
-
+
diff --git a/Dalamud.Injector/GlobalSuppressions.cs b/Dalamud.Injector/GlobalSuppressions.cs
new file mode 100644
index 000000000..3fca475cc
--- /dev/null
+++ b/Dalamud.Injector/GlobalSuppressions.cs
@@ -0,0 +1,19 @@
+// This file is used by Code Analysis to maintain SuppressMessage
+// attributes that are applied to this project.
+// Project-level suppressions either have no target or are given
+// a specific target and scoped to a namespace, type, member, etc.
+
+using System.Diagnostics.CodeAnalysis;
+
+// General
+[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1118:Parameter should not span multiple lines", Justification = "Preventing long lines", Scope = "namespaceanddescendants", Target = "~N:Dalamud")]
+[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1124:Do not use regions", Justification = "I like regions", Scope = "namespaceanddescendants", Target = "~N:Dalamud")]
+[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1123:Do not place regions within elements", Justification = "I like regions in elements too", Scope = "namespaceanddescendants", Target = "~N:Dalamud")]
+[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1503:Braces should not be omitted", Justification = "This is annoying", Scope = "namespaceanddescendants", Target = "~N:Dalamud")]
+[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1512:Single-line comments should not be followed by blank line", Justification = "I like this better", Scope = "namespaceanddescendants", Target = "~N:Dalamud")]
+[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1515:Single-line comment should be preceded by blank line", Justification = "I like this better", Scope = "namespaceanddescendants", Target = "~N:Dalamud")]
+[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1127:Generic type constraints should be on their own line", Justification = "I like this better", Scope = "namespaceanddescendants", Target = "~N:Dalamud")]
+[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:File should have header", Justification = "We don't do those yet")]
+
+// Program.cs
+[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Used during #if DEBUG", Scope = "member", Target = "~M:Dalamud.Injector.Program.NativeInject(System.Diagnostics.Process)")]
diff --git a/Dalamud.Injector/NativeFunctions.cs b/Dalamud.Injector/NativeFunctions.cs
index fb030b0e1..90e61a5fc 100644
--- a/Dalamud.Injector/NativeFunctions.cs
+++ b/Dalamud.Injector/NativeFunctions.cs
@@ -1,79 +1,491 @@
using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Security;
-using System.Text;
-using System.Threading.Tasks;
namespace Dalamud.Injector
{
- static class NativeFunctions
+ ///
+ /// Native functions.
+ ///
+ internal static class NativeFunctions
{
- [Flags]
- public enum ProcessAccessFlags : uint
- {
- All = 0x001F0FFF,
- Terminate = 0x00000001,
- CreateThread = 0x00000002,
- VirtualMemoryOperation = 0x00000008,
- VirtualMemoryRead = 0x00000010,
- VirtualMemoryWrite = 0x00000020,
- DuplicateHandle = 0x00000040,
- CreateProcess = 0x000000080,
- SetQuota = 0x00000100,
- SetInformation = 0x00000200,
- QueryInformation = 0x00000400,
- QueryLimitedInformation = 0x00001000,
- Synchronize = 0x00100000
- }
-
- [DllImport("kernel32.dll", SetLastError = true)]
- public static extern IntPtr OpenProcess(
- ProcessAccessFlags processAccess,
- bool bInheritHandle,
- int processId);
- public static IntPtr OpenProcess(Process proc, ProcessAccessFlags flags)
- {
- return OpenProcess(flags, false, proc.Id);
- }
-
+ ///
+ /// MEM_* from memoryapi.
+ ///
[Flags]
public enum AllocationType
{
+ ///
+ /// To coalesce two adjacent placeholders, specify MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS. When you coalesce
+ /// placeholders, lpAddress and dwSize must exactly match those of the placeholder.
+ ///
+ CoalescePlaceholders = 0x00000001,
+
+ ///
+ /// Frees an allocation back to a placeholder (after you've replaced a placeholder with a private allocation using
+ /// VirtualAlloc2 or Virtual2AllocFromApp). To split a placeholder into two placeholders, specify
+ /// MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER.
+ ///
+ PreservePlaceholder = 0x00000002,
+
+ ///
+ /// Allocates memory charges (from the overall size of memory and the paging files on disk) for the specified reserved
+ /// memory pages. The function also guarantees that when the caller later initially accesses the memory, the contents
+ /// will be zero. Actual physical pages are not allocated unless/until the virtual addresses are actually accessed.
+ /// To reserve and commit pages in one step, call VirtualAllocEx with MEM_COMMIT | MEM_RESERVE. Attempting to commit
+ /// a specific address range by specifying MEM_COMMIT without MEM_RESERVE and a non-NULL lpAddress fails unless the
+ /// entire range has already been reserved. The resulting error code is ERROR_INVALID_ADDRESS. An attempt to commit
+ /// a page that is already committed does not cause the function to fail. This means that you can commit pages without
+ /// first determining the current commitment state of each page. If lpAddress specifies an address within an enclave,
+ /// flAllocationType must be MEM_COMMIT.
+ ///
Commit = 0x1000,
+
+ ///
+ /// Reserves a range of the process's virtual address space without allocating any actual physical storage in memory
+ /// or in the paging file on disk. You commit reserved pages by calling VirtualAllocEx again with MEM_COMMIT. To
+ /// reserve and commit pages in one step, call VirtualAllocEx with MEM_COMMIT | MEM_RESERVE. Other memory allocation
+ /// functions, such as malloc and LocalAlloc, cannot use reserved memory until it has been released.
+ ///
Reserve = 0x2000,
+
+ ///
+ /// Decommits the specified region of committed pages. After the operation, the pages are in the reserved state.
+ /// The function does not fail if you attempt to decommit an uncommitted page. This means that you can decommit
+ /// a range of pages without first determining the current commitment state. The MEM_DECOMMIT value is not supported
+ /// when the lpAddress parameter provides the base address for an enclave.
+ ///
Decommit = 0x4000,
+
+ ///
+ /// Releases the specified region of pages, or placeholder (for a placeholder, the address space is released and
+ /// available for other allocations). After this operation, the pages are in the free state. If you specify this
+ /// value, dwSize must be 0 (zero), and lpAddress must point to the base address returned by the VirtualAlloc function
+ /// when the region is reserved. The function fails if either of these conditions is not met. If any pages in the
+ /// region are committed currently, the function first decommits, and then releases them. The function does not
+ /// fail if you attempt to release pages that are in different states, some reserved and some committed. This means
+ /// that you can release a range of pages without first determining the current commitment state.
+ ///
Release = 0x8000,
+
+ ///
+ /// Indicates that data in the memory range specified by lpAddress and dwSize is no longer of interest. The pages
+ /// should not be read from or written to the paging file. However, the memory block will be used again later, so
+ /// it should not be decommitted. This value cannot be used with any other value. Using this value does not guarantee
+ /// that the range operated on with MEM_RESET will contain zeros. If you want the range to contain zeros, decommit
+ /// the memory and then recommit it. When you use MEM_RESET, the VirtualAllocEx function ignores the value of fProtect.
+ /// However, you must still set fProtect to a valid protection value, such as PAGE_NOACCESS. VirtualAllocEx returns
+ /// an error if you use MEM_RESET and the range of memory is mapped to a file. A shared view is only acceptable
+ /// if it is mapped to a paging file.
+ ///
Reset = 0x80000,
+
+ ///
+ /// MEM_RESET_UNDO should only be called on an address range to which MEM_RESET was successfully applied earlier.
+ /// It indicates that the data in the specified memory range specified by lpAddress and dwSize is of interest to
+ /// the caller and attempts to reverse the effects of MEM_RESET. If the function succeeds, that means all data in
+ /// the specified address range is intact. If the function fails, at least some of the data in the address range
+ /// has been replaced with zeroes. This value cannot be used with any other value. If MEM_RESET_UNDO is called on
+ /// an address range which was not MEM_RESET earlier, the behavior is undefined. When you specify MEM_RESET, the
+ /// VirtualAllocEx function ignores the value of flProtect. However, you must still set flProtect to a valid
+ /// protection value, such as PAGE_NOACCESS.
+ ///
+ ResetUndo = 0x1000000,
+
+ ///
+ /// Reserves an address range that can be used to map Address Windowing Extensions (AWE) pages. This value must
+ /// be used with MEM_RESERVE and no other values.
+ ///
Physical = 0x400000,
+
+ ///
+ /// Allocates memory at the highest possible address. This can be slower than regular allocations, especially when
+ /// there are many allocations.
+ ///
TopDown = 0x100000,
+
+ ///
+ /// Causes the system to track pages that are written to in the allocated region. If you specify this value, you
+ /// must also specify MEM_RESERVE. To retrieve the addresses of the pages that have been written to since the region
+ /// was allocated or the write-tracking state was reset, call the GetWriteWatch function. To reset the write-tracking
+ /// state, call GetWriteWatch or ResetWriteWatch. The write-tracking feature remains enabled for the memory region
+ /// until the region is freed.
+ ///
WriteWatch = 0x200000,
- LargePages = 0x20000000
+
+ ///
+ /// Allocates memory using large page support. The size and alignment must be a multiple of the large-page minimum.
+ /// To obtain this value, use the GetLargePageMinimum function. If you specify this value, you must also specify
+ /// MEM_RESERVE and MEM_COMMIT.
+ ///
+ LargePages = 0x20000000,
}
- [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
- public static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress,
- int dwSize, AllocationType dwFreeType);
-
+ ///
+ /// PAGE_* from memoryapi.
+ ///
[Flags]
public enum MemoryProtection
{
+ ///
+ /// 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.
+ ///
Execute = 0x10,
+
+ ///
+ /// 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.
+ ///
ExecuteRead = 0x20,
+
+ ///
+ /// Enables execute, read-only, or read/write access to the committed region of pages.
+ ///
ExecuteReadWrite = 0x40,
+
+ ///
+ /// 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.
+ ///
ExecuteWriteCopy = 0x80,
+
+ ///
+ /// 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.
+ ///
NoAccess = 0x01,
+
+ ///
+ /// 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.
+ ///
ReadOnly = 0x02,
+
+ ///
+ /// 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.
+ ///
ReadWrite = 0x04,
+
+ ///
+ /// 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.
+ ///
WriteCopy = 0x08,
- GuardModifierflag = 0x100,
- NoCacheModifierflag = 0x200,
- WriteCombineModifierflag = 0x400
+
+ ///
+ /// 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.
+ ///
+ TargetsInvalid = 0x40000000,
+
+ ///
+ /// 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.
+ ///
+ TargetsNoUpdate = 0x40000000,
+
+ ///
+ /// 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.
+ ///
+ Guard = 0x100,
+
+ ///
+ /// 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.
+ ///
+ NoCache = 0x200,
+
+ ///
+ /// 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.
+ ///
+ WriteCombine = 0x400,
}
+ ///
+ /// PROCESS_* from processthreadsapi.
+ ///
+ [Flags]
+ public enum ProcessAccessFlags : uint
+ {
+ ///
+ /// All possible access rights for a process object.
+ ///
+ AllAccess = 0x001F0FFF,
+
+ ///
+ /// Required to create a process.
+ ///
+ CreateProcess = 0x0080,
+
+ ///
+ /// Required to create a thread.
+ ///
+ CreateThread = 0x0002,
+
+ ///
+ /// Required to duplicate a handle using DuplicateHandle.
+ ///
+ DupHandle = 0x0040,
+
+ ///
+ /// Required to retrieve certain information about a process, such as its token, exit code,
+ /// and priority class (see OpenProcessToken).
+ ///
+ QueryInformation = 0x0400,
+
+ ///
+ /// Required to retrieve certain information about a process(see GetExitCodeProcess, GetPriorityClass, IsProcessInJob,
+ /// QueryFullProcessImageName). A handle that has the PROCESS_QUERY_INFORMATION access right is automatically granted
+ /// PROCESS_QUERY_LIMITED_INFORMATION.
+ ///
+ QueryLimitedInformation = 0x1000,
+
+ ///
+ /// Required to set certain information about a process, such as its priority class (see SetPriorityClass).
+ ///
+ SetInformation = 0x0200,
+
+ ///
+ /// Required to set memory limits using SetProcessWorkingSetSize.
+ ///
+ SetQuote = 0x0100,
+
+ ///
+ /// Required to suspend or resume a process.
+ ///
+ SuspendResume = 0x0800,
+
+ ///
+ /// Required to terminate a process using TerminateProcess.
+ ///
+ Terminate = 0x0001,
+
+ ///
+ /// Required to perform an operation on the address space of a process(see VirtualProtectEx and WriteProcessMemory).
+ ///
+ VmOperation = 0x0008,
+
+ ///
+ /// Required to read memory in a process using ReadProcessMemory.
+ ///
+ VmRead = 0x0010,
+
+ ///
+ /// Required to write to memory in a process using WriteProcessMemory.
+ ///
+ VmWrite = 0x0020,
+
+ ///
+ /// Required to wait for the process to terminate using the wait functions.
+ ///
+ Synchronize = 0x00100000,
+ }
+
+ ///
+ /// Closes an open object handle.
+ ///
+ ///
+ /// A valid handle to an open object.
+ ///
+ ///
+ /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.To get extended
+ /// error information, call GetLastError. If the application is running under a debugger, the function will throw an
+ /// exception if it receives either a handle value that is not valid or a pseudo-handle value. This can happen if you
+ /// close a handle twice, or if you call CloseHandle on a handle returned by the FindFirstFile function instead of calling
+ /// the FindClose function.
+ ///
+ [DllImport("kernel32.dll", SetLastError = true)]
+ [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
+ [SuppressUnmanagedCodeSecurity]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool CloseHandle(IntPtr hObject);
+
+ ///
+ /// Creates a thread that runs in the virtual address space of another process. Use the CreateRemoteThreadEx function
+ /// to create a thread that runs in the virtual address space of another process and optionally specify extended attributes.
+ ///
+ ///
+ /// A handle to the process in which the thread is to be created. The handle must have the PROCESS_CREATE_THREAD,
+ /// PROCESS_QUERY_INFORMATION, PROCESS_VM_OPERATION, PROCESS_VM_WRITE, and PROCESS_VM_READ access rights, and may fail
+ /// without these rights on certain platforms. For more information, see Process Security and Access Rights.
+ ///
+ ///
+ /// A pointer to a SECURITY_ATTRIBUTES structure that specifies a security descriptor for the new thread and determines
+ /// whether child processes can inherit the returned handle. If lpThreadAttributes is NULL, the thread gets a default
+ /// security descriptor and the handle cannot be inherited. The access control lists (ACL) in the default security descriptor
+ /// for a thread come from the primary token of the creator.
+ ///
+ ///
+ /// The initial size of the stack, in bytes. The system rounds this value to the nearest page. If this parameter is
+ /// 0 (zero), the new thread uses the default size for the executable. For more information, see Thread Stack Size.
+ ///
+ ///
+ /// A pointer to the application-defined function of type LPTHREAD_START_ROUTINE to be executed by the thread and
+ /// represents the starting address of the thread in the remote process. The function must exist in the remote process.
+ /// For more information, see ThreadProc.
+ ///
+ ///
+ /// A pointer to a variable to be passed to the thread function.
+ ///
+ ///
+ /// The flags that control the creation of the thread.
+ ///
+ ///
+ /// A pointer to a variable that receives the thread identifier. If this parameter is NULL, the thread identifier is
+ /// not returned.
+ ///
+ ///
+ /// If the function succeeds, the return value is a handle to the new thread. If the function fails, the return value
+ /// is NULL.To get extended error information, call GetLastError. Note that CreateRemoteThread may succeed even if
+ /// lpStartAddress points to data, code, or is not accessible. If the start address is invalid when the thread runs,
+ /// an exception occurs, and the thread terminates. Thread termination due to a invalid start address is handled as
+ /// an error exit for the thread's process. This behavior is similar to the asynchronous nature of CreateProcess, where
+ /// the process is created even if it refers to invalid or missing dynamic-link libraries (DLL).
+ ///
+ [DllImport("kernel32.dll")]
+ public static extern IntPtr CreateRemoteThread(
+ IntPtr hProcess,
+ IntPtr lpThreadAttributes,
+ uint dwStackSize,
+ IntPtr lpStartAddress,
+ IntPtr lpParameter,
+ uint dwCreationFlags,
+ IntPtr lpThreadId);
+
+ ///
+ /// See https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulehandlew.
+ /// Retrieves a module handle for the specified module. The module must have been loaded by the calling process. To
+ /// avoid the race conditions described in the Remarks section, use the GetModuleHandleEx function.
+ ///
+ ///
+ /// The name of the loaded module (either a .dll or .exe file). If the file name extension is omitted, the default library
+ /// extension .dll is appended. The file name string can include a trailing point character (.) to indicate that the
+ /// module name has no extension. The string does not have to specify a path. When specifying a path, be sure to use
+ /// backslashes (\), not forward slashes (/). The name is compared (case independently) to the names of modules currently
+ /// mapped into the address space of the calling process. If this parameter is NULL, GetModuleHandle returns a handle
+ /// to the file used to create the calling process (.exe file). The GetModuleHandle function does not retrieve handles
+ /// for modules that were loaded using the LOAD_LIBRARY_AS_DATAFILE flag.For more information, see LoadLibraryEx.
+ ///
+ ///
+ /// If the function succeeds, the return value is a handle to the specified module. If the function fails, the return
+ /// value is NULL.To get extended error information, call GetLastError.
+ ///
+ [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
+ public static extern IntPtr GetModuleHandle(string lpModuleName);
+
+ ///
+ /// Retrieves the address of an exported function or variable from the specified dynamic-link library (DLL).
+ ///
+ ///
+ /// A handle to the DLL module that contains the function or variable. The LoadLibrary, LoadLibraryEx, LoadPackagedLibrary,
+ /// or GetModuleHandle function returns this handle. The GetProcAddress function does not retrieve addresses from modules
+ /// that were loaded using the LOAD_LIBRARY_AS_DATAFILE flag.For more information, see LoadLibraryEx.
+ ///
+ ///
+ /// The function or variable name, or the function's ordinal value. If this parameter is an ordinal value, it must be
+ /// in the low-order word; the high-order word must be zero.
+ ///
+ ///
+ /// If the function succeeds, the return value is the address of the exported function or variable. If the function
+ /// fails, the return value is NULL.To get extended error information, call GetLastError.
+ ///
+ [DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
+ public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
+
+ ///
+ /// See https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-openprocess.
+ /// Opens an existing local process object.
+ ///
+ ///
+ /// The access to the process object. This access right is checked against the security descriptor for the process.
+ /// This parameter can be one or more of the process access rights. If the caller has enabled the SeDebugPrivilege
+ /// privilege, the requested access is granted regardless of the contents of the security descriptor.
+ ///
+ ///
+ /// If this value is TRUE, processes created by this process will inherit the handle. Otherwise, the processes do
+ /// not inherit this handle.
+ ///
+ ///
+ /// The identifier of the local process to be opened.
+ ///
+ ///
+ /// If the function succeeds, the return value is an open handle to the specified process. If the function fails, the
+ /// return value is NULL.To get extended error information, call GetLastError.
+ ///
+ [DllImport("kernel32.dll", SetLastError = true)]
+ public static extern IntPtr OpenProcess(
+ ProcessAccessFlags processAccess,
+ bool bInheritHandle,
+ int processId);
+
+ ///
+ /// See https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualallocex.
+ /// Reserves, commits, or changes the state of a region of memory within the virtual address space of a specified process.
+ /// The function initializes the memory it allocates to zero. To specify the NUMA node for the physical memory, see
+ /// VirtualAllocExNuma.
+ ///
+ ///
+ /// The handle to a process. The function allocates memory within the virtual address space of this process. The handle
+ /// must have the PROCESS_VM_OPERATION access right. For more information, see Process Security and Access Rights.
+ ///
+ ///
+ /// The pointer that specifies a desired starting address for the region of pages that you want to allocate. If you
+ /// are reserving memory, the function rounds this address down to the nearest multiple of the allocation granularity.
+ /// If you are committing memory that is already reserved, the function rounds this address down to the nearest page
+ /// boundary. To determine the size of a page and the allocation granularity on the host computer, use the GetSystemInfo
+ /// function. If lpAddress is NULL, the function determines where to allocate the region. If this address is within
+ /// an enclave that you have not initialized by calling InitializeEnclave, VirtualAllocEx allocates a page of zeros
+ /// for the enclave at that address. The page must be previously uncommitted, and will not be measured with the EEXTEND
+ /// instruction of the Intel Software Guard Extensions programming model. If the address in within an enclave that you
+ /// initialized, then the allocation operation fails with the ERROR_INVALID_ADDRESS error.
+ ///
+ ///
+ /// The size of the region of memory to allocate, in bytes. If lpAddress is NULL, the function rounds dwSize up to the
+ /// next page boundary. If lpAddress is not NULL, the function allocates all pages that contain one or more bytes in
+ /// the range from lpAddress to lpAddress+dwSize. This means, for example, that a 2-byte range that straddles a page
+ /// boundary causes the function to allocate both pages.
+ ///
+ ///
+ /// The type of memory allocation. This parameter must contain one of the MEM_* enum values.
+ ///
+ ///
+ /// The memory protection for the region of pages to be allocated. If the pages are being committed, you can specify
+ /// any one of the memory protection constants.
+ ///
+ ///
+ /// If the function succeeds, the return value is the base address of the allocated region of pages. If the function
+ /// fails, the return value is NULL.To get extended error information, call GetLastError.
+ ///
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
public static extern IntPtr VirtualAllocEx(
IntPtr hProcess,
@@ -82,34 +494,76 @@ namespace Dalamud.Injector
AllocationType flAllocationType,
MemoryProtection flProtect);
+ ///
+ /// See https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualfreeex.
+ /// Releases, decommits, or releases and decommits a region of memory within the virtual address space of a specified
+ /// process.
+ ///
+ ///
+ /// A handle to a process. The function frees memory within the virtual address space of the process. The handle must
+ /// have the PROCESS_VM_OPERATION access right.For more information, see Process Security and Access Rights.
+ ///
+ ///
+ /// A pointer to the starting address of the region of memory to be freed. If the dwFreeType parameter is MEM_RELEASE,
+ /// lpAddress must be the base address returned by the VirtualAllocEx function when the region is reserved.
+ ///
+ ///
+ /// The size of the region of memory to free, in bytes. If the dwFreeType parameter is MEM_RELEASE, dwSize must be 0
+ /// (zero). The function frees the entire region that is reserved in the initial allocation call to VirtualAllocEx.
+ /// If dwFreeType is MEM_DECOMMIT, the function decommits all memory pages that contain one or more bytes in the range
+ /// from the lpAddress parameter to (lpAddress+dwSize). This means, for example, that a 2-byte region of memory that
+ /// straddles a page boundary causes both pages to be decommitted. If lpAddress is the base address returned by
+ /// VirtualAllocEx and dwSize is 0 (zero), the function decommits the entire region that is allocated by VirtualAllocEx.
+ /// After that, the entire region is in the reserved state.
+ ///
+ ///
+ /// The type of free operation. This parameter must be one of the MEM_* enum values.
+ ///
+ ///
+ /// If the function succeeds, the return value is a nonzero value. If the function fails, the return value is 0 (zero).
+ /// To get extended error information, call GetLastError.
+ ///
+ [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
+ public static extern bool VirtualFreeEx(
+ IntPtr hProcess,
+ IntPtr lpAddress,
+ int dwSize,
+ AllocationType dwFreeType);
+
+ ///
+ /// Writes data to an area of memory in a specified process. The entire area to be written to must be accessible or
+ /// the operation fails.
+ ///
+ ///
+ /// A handle to the process memory to be modified. The handle must have PROCESS_VM_WRITE and PROCESS_VM_OPERATION access
+ /// to the process.
+ ///
+ ///
+ /// A pointer to the base address in the specified process to which data is written. Before data transfer occurs, the
+ /// system verifies that all data in the base address and memory of the specified size is accessible for write access,
+ /// and if it is not accessible, the function fails.
+ ///
+ ///
+ /// A pointer to the buffer that contains data to be written in the address space of the specified process.
+ ///
+ ///
+ /// The number of bytes to be written to the specified process.
+ ///
+ ///
+ /// A pointer to a variable that receives the number of bytes transferred into the specified process. This parameter
+ /// is optional. If lpNumberOfBytesWritten is NULL, the parameter is ignored.
+ ///
+ ///
+ /// If the function succeeds, the return value is nonzero. If the function fails, the return value is 0 (zero). To get
+ /// extended error information, call GetLastError.The function fails if the requested write operation crosses into an
+ /// area of the process that is inaccessible.
+ ///
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool WriteProcessMemory(
- IntPtr hProcess,
- IntPtr lpBaseAddress,
- byte[] lpBuffer,
- int dwSize,
- out IntPtr lpNumberOfBytesWritten);
-
- [DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
- public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
-
- [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
- public static extern IntPtr GetModuleHandle(string lpModuleName);
-
- [DllImport("kernel32.dll")]
- public static extern IntPtr CreateRemoteThread(
- IntPtr hProcess,
- IntPtr lpThreadAttributes,
- uint dwStackSize,
- IntPtr lpStartAddress,
- IntPtr lpParameter,
- uint dwCreationFlags,
- IntPtr lpThreadId);
-
- [DllImport("kernel32.dll", SetLastError = true)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- [SuppressUnmanagedCodeSecurity]
- [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool CloseHandle(IntPtr hObject);
+ IntPtr hProcess,
+ IntPtr lpBaseAddress,
+ byte[] lpBuffer,
+ int dwSize,
+ out IntPtr lpNumberOfBytesWritten);
}
}
diff --git a/Dalamud.Injector/Program.cs b/Dalamud.Injector/Program.cs
index 040988955..74f3a1585 100644
--- a/Dalamud.Injector/Program.cs
+++ b/Dalamud.Injector/Program.cs
@@ -1,24 +1,27 @@
using System;
-using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
-using System.Drawing;
using System.IO;
-using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows.Forms;
+
using EasyHook;
using Newtonsoft.Json;
-namespace Dalamud.Injector {
- internal static class Program {
- static private Process process = null;
+namespace Dalamud.Injector
+{
+ ///
+ /// Application entrypoint.
+ ///
+ internal static class Program
+ {
+ private static Process process = null;
- private static void Main(string[] args) {
-
- AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs eventArgs)
+ private static void Main(string[] args)
+ {
+ AppDomain.CurrentDomain.UnhandledException += (sender, eventArgs) =>
{
File.WriteAllText("InjectorException.txt", eventArgs.ExceptionObject.ToString());
#if !DEBUG
@@ -29,13 +32,14 @@ namespace Dalamud.Injector {
Environment.Exit(0);
};
-
var pid = -1;
- if (args.Length >= 1) {
+ if (args.Length >= 1)
+ {
pid = int.Parse(args[0]);
}
- switch (pid) {
+ switch (pid)
+ {
case -1:
process = Process.GetProcessesByName("ffxiv_dx11")[0];
break;
@@ -51,13 +55,16 @@ namespace Dalamud.Injector {
}
DalamudStartInfo startInfo;
- if (args.Length <= 1) {
+ if (args.Length <= 1)
+ {
startInfo = GetDefaultStartInfo();
Console.WriteLine("\nA Dalamud start info was not found in the program arguments. One has been generated for you.");
Console.WriteLine("\nCopy the following contents into the program arguments:");
Console.WriteLine();
Console.WriteLine(Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(startInfo))));
- } else {
+ }
+ else
+ {
startInfo = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(Convert.FromBase64String(args[1])));
}
@@ -66,7 +73,7 @@ namespace Dalamud.Injector {
// Seems to help with the STATUS_INTERNAL_ERROR condition
Thread.Sleep(1000);
- //Thread.Sleep(10000);
+ // Thread.Sleep(10000);
// Inject to process
Inject(process, startInfo);
@@ -75,16 +82,18 @@ namespace Dalamud.Injector {
#if DEBUG
// Inject exception handler
- //NativeInject(process);
+ // NativeInject(process);
#endif
}
- private static void Inject(Process process, DalamudStartInfo info) {
+ private static void Inject(Process process, DalamudStartInfo info)
+ {
Console.WriteLine($"Injecting to {process.Id}");
// File check
var libPath = Path.GetFullPath("Dalamud.dll");
- if (!File.Exists(libPath)) {
+ if (!File.Exists(libPath))
+ {
Console.WriteLine($"Can't find a dll on {libPath}");
return;
}
@@ -104,12 +113,14 @@ namespace Dalamud.Injector {
Console.WriteLine($"Injecting {libPath}...");
var handle = NativeFunctions.OpenProcess(
- NativeFunctions.ProcessAccessFlags.All,
+ NativeFunctions.ProcessAccessFlags.AllAccess,
false,
process.Id);
if (handle == IntPtr.Zero)
+ {
throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not OpenProcess");
+ }
var dllMem = NativeFunctions.VirtualAllocEx(
handle,
@@ -119,7 +130,9 @@ namespace Dalamud.Injector {
NativeFunctions.MemoryProtection.ReadWrite);
if (dllMem == IntPtr.Zero)
+ {
throw new Win32Exception(Marshal.GetLastWin32Error(), $"Could not alloc memory {Marshal.GetLastWin32Error():X}");
+ }
Console.WriteLine($"dll path at {dllMem.ToInt64():X}");
@@ -128,9 +141,10 @@ namespace Dalamud.Injector {
dllMem,
pathBytes,
len,
- out var bytesWritten
- ))
+ out var bytesWritten))
+ {
throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not write DLL");
+ }
Console.WriteLine($"Wrote {bytesWritten}");
@@ -144,11 +158,12 @@ namespace Dalamud.Injector {
loadLibA,
dllMem,
0,
- IntPtr.Zero
- );
+ IntPtr.Zero);
if (remoteThread == IntPtr.Zero)
+ {
throw new Win32Exception(Marshal.GetLastWin32Error(), $"Could not CreateRemoteThread");
+ }
/*
TODO kill myself
@@ -163,9 +178,11 @@ namespace Dalamud.Injector {
NativeFunctions.CloseHandle(handle);
}
- private static DalamudStartInfo GetDefaultStartInfo() {
+ private static DalamudStartInfo GetDefaultStartInfo()
+ {
var ffxivDir = Path.GetDirectoryName(process.MainModule.FileName);
- var startInfo = new DalamudStartInfo {
+ var startInfo = new DalamudStartInfo
+ {
WorkingDirectory = null,
ConfigurationPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "dalamudConfig.json"),
PluginDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "installedPlugins"),
@@ -173,7 +190,7 @@ namespace Dalamud.Injector {
AssetDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "dalamudAssets"),
GameVersion = File.ReadAllText(Path.Combine(ffxivDir, "ffxivgame.ver")),
- Language = ClientLanguage.English
+ Language = ClientLanguage.English,
};
Console.WriteLine("Creating a StartInfo with:\n" +
diff --git a/Dalamud.Injector/stylecop.json b/Dalamud.Injector/stylecop.json
new file mode 100644
index 000000000..6881efc6d
--- /dev/null
+++ b/Dalamud.Injector/stylecop.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
+ "settings": {
+ "orderingRules": {
+ "systemUsingDirectivesFirst": true,
+ "usingDirectivesPlacement": "outsideNamespace",
+ "blankLinesBetweenUsingGroups": "require"
+ },
+ "maintainabilityRules": {
+ "topLevelTypes": [ "class", "interface", "struct", "enum" ]
+ }
+ }
+}
diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj
index 63c642db9..13abbe738 100644
--- a/Dalamud/Dalamud.csproj
+++ b/Dalamud/Dalamud.csproj
@@ -1,8 +1,8 @@
-
+
AnyCPU
net472
- 8.0
+ 9.0
AnyCPU;x64
diff --git a/Dalamud/Game/ClientState/JobGauge.cs b/Dalamud/Game/ClientState/JobGauge.cs
deleted file mode 100644
index 70a142e98..000000000
--- a/Dalamud/Game/ClientState/JobGauge.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System.Runtime.InteropServices;
-using Serilog;
-
-namespace Dalamud.Game.ClientState {
- public class JobGauges {
- private ClientStateAddressResolver Address { get; }
-
- public JobGauges(ClientStateAddressResolver addressResolver) {
- Address = addressResolver;
-
- Log.Verbose("JobGaugeData address {JobGaugeData}", Address.JobGaugeData);
- }
-
- // Should only be called with the gauge types in
- // ClientState.Structs.JobGauge
- public T Get() {
- return Marshal.PtrToStructure(Address.JobGaugeData);
- }
- }
-}
diff --git a/Dalamud/Game/ClientState/JobGauges.cs b/Dalamud/Game/ClientState/JobGauges.cs
new file mode 100644
index 000000000..f25f5d8ab
--- /dev/null
+++ b/Dalamud/Game/ClientState/JobGauges.cs
@@ -0,0 +1,35 @@
+using System.Runtime.InteropServices;
+
+using Serilog;
+
+namespace Dalamud.Game.ClientState
+{
+ ///
+ /// This class converts in-memory Job gauge data to structs.
+ ///
+ public class JobGauges
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Address resolver with the JobGauge memory location(s).
+ public JobGauges(ClientStateAddressResolver addressResolver)
+ {
+ this.Address = addressResolver;
+
+ Log.Verbose("JobGaugeData address {JobGaugeData}", this.Address.JobGaugeData);
+ }
+
+ private ClientStateAddressResolver Address { get; }
+
+ ///
+ /// Get the JobGauge for a given job.
+ ///
+ /// A JobGauge struct from ClientState.Structs.JobGauge.
+ /// A JobGauge.
+ public T Get()
+ {
+ return Marshal.PtrToStructure(this.Address.JobGaugeData);
+ }
+ }
+}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/ASTGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/ASTGauge.cs
index e6eca6548..c37e1c0a7 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/ASTGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/ASTGauge.cs
@@ -1,25 +1,35 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Dalamud.Game.ClientState.Structs.JobGauge {
+namespace Dalamud.Game.ClientState.Structs.JobGauge
+{
+ ///
+ /// In-memory AST job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
- public struct ASTGauge {
- [FieldOffset(4)] private CardType Card;
- [FieldOffset(5)] private unsafe fixed byte Seals[3];
+ public struct ASTGauge
+ {
+ [FieldOffset(4)]
+ private CardType card;
- public CardType DrawnCard() {
- return Card;
- }
+ [FieldOffset(5)]
+ private unsafe fixed byte seals[3];
- public unsafe bool ContainsSeal(SealType seal) {
- if (Seals[0] == (byte)seal) return true;
- if (Seals[1] == (byte)seal) return true;
- if (Seals[2] == (byte)seal) return true;
+ ///
+ /// Gets the currently drawn .
+ ///
+ /// Currently drawn .
+ public CardType DrawnCard() => this.card;
+
+ ///
+ /// Check if a is currently active on the divination gauge.
+ ///
+ /// The to check for.
+ /// If the given Seal is currently divined.
+ public unsafe bool ContainsSeal(SealType seal)
+ {
+ if (this.seals[0] == (byte)seal) return true;
+ if (this.seals[1] == (byte)seal) return true;
+ if (this.seals[2] == (byte)seal) return true;
return false;
}
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/BLMGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/BLMGauge.cs
index 8bbb74610..694a0d981 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/BLMGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/BLMGauge.cs
@@ -1,34 +1,59 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Dalamud.Game.ClientState.Structs.JobGauge {
+namespace Dalamud.Game.ClientState.Structs.JobGauge
+{
+ ///
+ /// In-memory BLM job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
- public struct BLMGauge {
- [FieldOffset(0)] public short TimeUntilNextPolyglot; //eno timer (ms)
- [FieldOffset(2)] public short ElementTimeRemaining; //ui/af timer
- [FieldOffset(4)] private byte ElementStance; //ui/af
- [FieldOffset(5)] public byte NumUmbralHearts; //number of umbral hearts
- [FieldOffset(6)] public byte NumPolyglotStacks; //number of polyglot stacks
- [FieldOffset(7)] private byte EnoState; //eno active?
+ public struct BLMGauge
+ {
+ ///
+ /// Gets the time until the next Polyglot stack in milliseconds.
+ ///
+ [FieldOffset(0)]
+ public short TimeUntilNextPolyglot; // enochian timer
- public bool InUmbralIce() {
- return ElementStance > 4;
- }
+ ///
+ /// Gets the time remaining for Astral Fire or Umbral Ice in milliseconds.
+ ///
+ [FieldOffset(2)]
+ public short ElementTimeRemaining; // umbral ice and astral fire timer
- public bool InAstralFire() {
- return ElementStance > 0 && ElementStance < 4;
- }
+ [FieldOffset(4)]
+ private byte elementStance; // umbral ice or astral fire
- public bool IsEnoActive() {
- return EnoState > 0;
- }
+ ///
+ /// Gets the number of Umbral Hearts remaining.
+ ///
+ [FieldOffset(5)]
+ public byte NumUmbralHearts;
+ ///
+ /// Gets the number of Polyglot stacks remaining.
+ ///
+ [FieldOffset(6)]
+ public byte NumPolyglotStacks;
+
+ [FieldOffset(7)]
+ private byte enochianState;
+
+ ///
+ /// Gets if the player is in Umbral Ice.
+ ///
+ /// true or false.
+ public bool InUmbralIce() => this.elementStance > 4;
+
+ ///
+ /// Gets if the player is in Astral fire.
+ ///
+ /// true or false.
+ public bool InAstralFire() => this.elementStance > 0 && this.elementStance < 4;
+
+ ///
+ /// Gets if Enochian is active.
+ ///
+ /// true or false.
+ public bool IsEnoActive() => this.enochianState > 0;
}
-
-
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/BRDGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/BRDGauge.cs
index b181d57a0..3fe2b5dee 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/BRDGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/BRDGauge.cs
@@ -1,17 +1,35 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Dalamud.Game.ClientState.Structs.JobGauge {
+namespace Dalamud.Game.ClientState.Structs.JobGauge
+{
+ ///
+ /// In-memory BRD job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
- public struct BRDGauge {
- [FieldOffset(0)] public short SongTimer;
- [FieldOffset(2)] public byte NumSongStacks;
- [FieldOffset(3)] public byte SoulVoiceValue;
- [FieldOffset(4)] public CurrentSong ActiveSong;
+ public struct BRDGauge
+ {
+ ///
+ /// Gets the current song timer in milliseconds.
+ ///
+ [FieldOffset(0)]
+ public short SongTimer;
+
+ ///
+ /// Gets the number of stacks for the current song.
+ ///
+ [FieldOffset(2)]
+ public byte NumSongStacks;
+
+ ///
+ /// Gets the amount of Soul Voice accumulated.
+ ///
+ [FieldOffset(3)]
+ public byte SoulVoiceValue;
+
+ ///
+ /// Gets the type of song that is active.
+ ///
+ [FieldOffset(4)]
+ public CurrentSong ActiveSong;
}
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/DNCGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/DNCGauge.cs
index b77e6f0e4..8e4484871 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/DNCGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/DNCGauge.cs
@@ -1,25 +1,43 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Dalamud.Game.ClientState.Structs.JobGauge {
+namespace Dalamud.Game.ClientState.Structs.JobGauge
+{
+ ///
+ /// In-memory DNC job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
- public unsafe struct DNCGauge {
- [FieldOffset(0)] public byte NumFeathers;
- [FieldOffset(1)] public byte Esprit;
- [FieldOffset(2)] private fixed byte StepOrder[4];
- [FieldOffset(6)] public byte NumCompleteSteps;
+ public unsafe struct DNCGauge
+ {
+ ///
+ /// Gets the number of feathers available.
+ ///
+ [FieldOffset(0)]
+ public byte NumFeathers;
- public bool IsDancing() {
- return StepOrder[0] != 0;
- }
+ ///
+ /// Gets the amount of Espirit available.
+ ///
+ [FieldOffset(1)]
+ public byte Esprit;
- public ulong NextStep() {
- return (ulong)(15999 + StepOrder[NumCompleteSteps] - 1);
- }
+ [FieldOffset(2)]
+ private fixed byte stepOrder[4];
+
+ ///
+ /// Gets the number of steps completed for the current dance.
+ ///
+ [FieldOffset(6)]
+ public byte NumCompleteSteps;
+
+ ///
+ /// Gets the next step in the current dance.
+ ///
+ public ulong NextStep => (ulong)(15999 + this.stepOrder[this.NumCompleteSteps] - 1);
+
+ ///
+ /// Gets if the player is dancing or not.
+ ///
+ /// true or false.
+ public bool IsDancing() => this.stepOrder[0] != 0;
}
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/DRGGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/DRGGauge.cs
index fa71eb541..101c483b0 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/DRGGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/DRGGauge.cs
@@ -1,16 +1,29 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Dalamud.Game.ClientState.Structs.JobGauge {
+namespace Dalamud.Game.ClientState.Structs.JobGauge
+{
+ ///
+ /// In-memory DRG job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
- public struct DRGGauge {
- [FieldOffset(0)] public short BOTDTimer;
- [FieldOffset(2)] public BOTDState BOTDState;
- [FieldOffset(3)] public byte EyeCount;
+ public struct DRGGauge
+ {
+ ///
+ /// Gets the time remaining for Blood of the Dragon in milliseconds.
+ ///
+ [FieldOffset(0)]
+ public short BOTDTimer;
+
+ ///
+ /// Gets the current state of Blood of the Dragon.
+ ///
+ [FieldOffset(2)]
+ public BOTDState BOTDState;
+
+ ///
+ /// Gets the count of eyes opened during Blood of the Dragon.
+ ///
+ [FieldOffset(3)]
+ public byte EyeCount;
}
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/DRKGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/DRKGauge.cs
index 1cc8bed4d..9c5306764 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/DRKGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/DRKGauge.cs
@@ -1,20 +1,38 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-namespace Dalamud.Game.ClientState.Structs.JobGauge {
+namespace Dalamud.Game.ClientState.Structs.JobGauge
+{
+ ///
+ /// In-memory DRK job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
- public struct DRKGauge {
- [FieldOffset(0)] public byte Blood;
- [FieldOffset(2)] public ushort DarksideTimeRemaining;
- [FieldOffset(4)] private byte DarkArtsState;
- [FieldOffset(6)] public ushort ShadowTimeRemaining;
+ public struct DRKGauge
+ {
+ ///
+ /// Gets the amount of blood accumulated.
+ ///
+ [FieldOffset(0)]
+ public byte Blood;
- public bool HasDarkArts() {
- return DarkArtsState > 0;
- }
+ ///
+ /// Gets the Darkside time remaining in milliseconds.
+ ///
+ [FieldOffset(2)]
+ public ushort DarksideTimeRemaining;
+
+ [FieldOffset(4)]
+ private byte darkArtsState;
+
+ ///
+ /// Gets the Shadow time remaining in milliseconds.
+ ///
+ [FieldOffset(6)]
+ public ushort ShadowTimeRemaining;
+
+ ///
+ /// Gets if the player has Dark Arts or not.
+ ///
+ /// true or false.
+ public bool HasDarkArts() => this.darkArtsState > 0;
}
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/GNBGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/GNBGauge.cs
index 969adda1d..c1f7e496b 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/GNBGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/GNBGauge.cs
@@ -1,16 +1,29 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Dalamud.Game.ClientState.Structs.JobGauge {
+namespace Dalamud.Game.ClientState.Structs.JobGauge
+{
+ ///
+ /// In-memory GNB job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
- public struct GNBGauge {
- [FieldOffset(0)] public byte NumAmmo;
- [FieldOffset(2)] public short MaxTimerDuration;
- [FieldOffset(4)] public byte AmmoComboStepNumber;
+ public struct GNBGauge
+ {
+ ///
+ /// Gets the amount of ammo available.
+ ///
+ [FieldOffset(0)]
+ public byte NumAmmo;
+
+ ///
+ /// Gets the max combo time of the Gnashing Fang combo.
+ ///
+ [FieldOffset(2)]
+ public short MaxTimerDuration;
+
+ ///
+ /// Gets the current step of the Gnashing Fang combo.
+ ///
+ [FieldOffset(4)]
+ public byte AmmoComboStepNumber;
}
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/JobEnums.cs b/Dalamud/Game/ClientState/Structs/JobGauge/JobEnums.cs
index 69762e295..4c6ab351a 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/JobEnums.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/JobEnums.cs
@@ -1,67 +1,272 @@
using System;
-namespace Dalamud.Game.ClientState.Structs.JobGauge {
- public enum SealType : byte {
+namespace Dalamud.Game.ClientState.Structs.JobGauge
+{
+ #region AST
+
+ ///
+ /// AST Divination seal types.
+ ///
+ public enum SealType : byte
+ {
+ ///
+ /// No seal.
+ ///
NONE = 0,
- SUN,
- MOON,
- CELESTIAL
+
+ ///
+ /// Sun seal.
+ ///
+ SUN = 1,
+
+ ///
+ /// Moon seal.
+ ///
+ MOON = 2,
+
+ ///
+ /// Celestial seal.
+ ///
+ CELESTIAL = 3,
}
- public enum CardType : byte {
+ ///
+ /// AST Arcanum (card) types.
+ ///
+ public enum CardType : byte
+ {
+ ///
+ /// No card.
+ ///
NONE = 0,
- BALANCE,
- BOLE,
- ARROW,
- SPEAR,
- EWER,
- SPIRE,
+
+ ///
+ /// The Balance card.
+ ///
+ BALANCE = 1,
+
+ ///
+ /// The Bole card.
+ ///
+ BOLE = 2,
+
+ ///
+ /// The Arrow card.
+ ///
+ ARROW = 3,
+
+ ///
+ /// The Spear card.
+ ///
+ SPEAR = 4,
+
+ ///
+ /// The Ewer card.
+ ///
+ EWER = 5,
+
+ ///
+ /// The Spire card.
+ ///
+ SPIRE = 6,
+
+ ///
+ /// The Lord of Crowns card.
+ ///
LORD = 0x70,
- LADY = 0x80
+
+ ///
+ /// The Lady of Crowns card.
+ ///
+ LADY = 0x80,
}
- public enum SummonPet : byte {
+ #endregion
+
+ #region BRD
+
+ ///
+ /// BRD Current Song types.
+ ///
+ public enum CurrentSong : byte
+ {
+ ///
+ /// No song is active type.
+ ///
NONE = 0,
- IFRIT = 3,
- TITAN,
- GARUDA
- }
- public enum PetGlam : byte {
- NONE = 0,
- EMERALD,
- TOPAZ,
- RUBY
- }
-
- [Flags]
- public enum Sen : byte {
- NONE = 0,
- SETSU = 1 << 0,
- GETSU = 1 << 1,
- KA = 1 << 2
- }
-
- public enum BOTDState : byte {
- NONE = 0,
- BOTD,
- LOTD
- }
-
- public enum CurrentSong : byte {
+ ///
+ /// Mage's Ballad type.
+ ///
MAGE = 5,
+
+ ///
+ /// Army's Paeon type.
+ ///
ARMY = 0xA,
- WANDERER = 0xF
+
+ ///
+ /// The Wanderer's Minuet type.
+ ///
+ WANDERER = 0xF,
}
- public enum DismissedFairy : byte {
- EOS = 6,
- SELENE
+ #endregion
+
+ #region DRG
+
+ ///
+ /// DRG Blood of the Dragon state types.
+ ///
+ public enum BOTDState : byte
+ {
+ ///
+ /// Inactive type.
+ ///
+ NONE = 0,
+
+ ///
+ /// Blood of the Dragon is active.
+ ///
+ BOTD = 1,
+
+ ///
+ /// Life of the Dragon is active.
+ ///
+ LOTD = 2,
}
- public enum Mudras : byte {
+ #endregion
+
+ #region NIN
+
+ ///
+ /// NIN Mudra types.
+ ///
+ public enum Mudras : byte
+ {
+ ///
+ /// Ten mudra.
+ ///
TEN = 1,
+
+ ///
+ /// Chi mudra.
+ ///
CHI = 2,
- JIN = 3
+
+ ///
+ /// Jin mudra.
+ ///
+ JIN = 3,
}
+
+ #endregion
+
+ #region SAM
+
+ ///
+ /// Samurai Sen types.
+ ///
+ [Flags]
+ public enum Sen : byte
+ {
+ ///
+ /// No Sen.
+ ///
+ NONE = 0,
+
+ ///
+ /// Setsu Sen type.
+ ///
+ SETSU = 1 << 0,
+
+ ///
+ /// Getsu Sen type.
+ ///
+ GETSU = 1 << 1,
+
+ ///
+ /// Ka Sen type.
+ ///
+ KA = 1 << 2,
+ }
+
+ #endregion
+
+ #region SCH
+
+ ///
+ /// SCH Dismissed fairy types.
+ ///
+ public enum DismissedFairy : byte
+ {
+ ///
+ /// Dismissed fairy is Eos.
+ ///
+ EOS = 6,
+
+ ///
+ /// Dismissed fairy is Selene.
+ ///
+ SELENE = 7,
+ }
+
+ #endregion
+
+ #region SMN
+
+ ///
+ /// SMN summoned pet types.
+ ///
+ public enum SummonPet : byte
+ {
+ ///
+ /// No pet.
+ ///
+ NONE = 0,
+
+ ///
+ /// The summoned pet Ifrit.
+ ///
+ IFRIT = 3,
+
+ ///
+ /// The summoned pet Titan.
+ ///
+ TITAN = 4,
+
+ ///
+ /// The summoned pet Garuda.
+ ///
+ GARUDA = 5,
+ }
+
+ ///
+ /// SMN summoned pet glam types.
+ ///
+ public enum PetGlam : byte
+ {
+ ///
+ /// No pet glam.
+ ///
+ NONE = 0,
+
+ ///
+ /// Emerald carbuncle pet glam.
+ ///
+ EMERALD = 1,
+
+ ///
+ /// Topaz carbuncle pet glam.
+ ///
+ TOPAZ = 2,
+
+ ///
+ /// Ruby carbuncle pet glam.
+ ///
+ RUBY = 3,
+ }
+
+ #endregion
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/MCHGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/MCHGauge.cs
index e606cb751..18f684c21 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/MCHGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/MCHGauge.cs
@@ -1,27 +1,56 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Dalamud.Game.ClientState.Structs.JobGauge {
+namespace Dalamud.Game.ClientState.Structs.JobGauge
+{
+ ///
+ /// In-memory MCH job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
- public struct MCHGauge{
+ public struct MCHGauge
+ {
+ ///
+ /// Gets the time time remaining for Overheat in milliseconds.
+ ///
+ [FieldOffset(0)]
+ public short OverheatTimeRemaining;
- [FieldOffset(0)] public short OverheatTimeRemaining;
- [FieldOffset(2)] public short RobotTimeRemaining;
- [FieldOffset(4)] public byte Heat;
- [FieldOffset(5)] public byte Battery;
- [FieldOffset(6)] public byte LastRobotBatteryPower;
- [FieldOffset(7)] private byte TimerActive;
+ ///
+ /// Gets the time remaining for the Rook or Queen in milliseconds.
+ ///
+ [FieldOffset(2)]
+ public short RobotTimeRemaining;
- public bool IsOverheated() {
- return (TimerActive & 1) != 0;
- }
- public bool IsRobotActive() {
- return (TimerActive & 2) != 0;
- }
+ ///
+ /// Gets the current Heat level.
+ ///
+ [FieldOffset(4)]
+ public byte Heat;
+
+ ///
+ /// Gets the current Battery level.
+ ///
+ [FieldOffset(5)]
+ public byte Battery;
+
+ ///
+ /// Gets the battery level of the last Robot.
+ ///
+ [FieldOffset(6)]
+ public byte LastRobotBatteryPower;
+
+ [FieldOffset(7)]
+ private byte timerActive;
+
+ ///
+ /// Gets if the player is currently Overheated.
+ ///
+ /// true or false.
+ public bool IsOverheated() => (this.timerActive & 1) != 0;
+
+ ///
+ /// Gets if the player has an active Robot.
+ ///
+ /// true or false.
+ public bool IsRobotActive() => (this.timerActive & 2) != 0;
}
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/MNKGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/MNKGauge.cs
index 1d46346ec..177b077fc 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/MNKGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/MNKGauge.cs
@@ -3,20 +3,40 @@ using System.Runtime.InteropServices;
namespace Dalamud.Game.ClientState.Structs.JobGauge
{
+ ///
+ /// In-memory MNK job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
public struct MNKGauge
{
- [FieldOffset(0)] public byte NumChakra;
+ ///
+ /// Gets the number of Chakra available.
+ ///
+ [FieldOffset(0)]
+ public byte NumChakra;
+
+ ///
+ /// Gets the Greased Lightning timer in milliseconds.
+ ///
+ [Obsolete("GL has been removed from the game")]
+ [FieldOffset(0)]
+ public byte GLTimer;
+
+ ///
+ /// Gets the amount of Greased Lightning stacks.
+ ///
+ [Obsolete("GL has been removed from the game")]
+ [FieldOffset(2)]
+ public byte NumGLStacks;
[Obsolete("GL has been removed from the game")]
- [FieldOffset(0)] public byte GLTimer;
-
- [Obsolete("GL has been removed from the game")]
- [FieldOffset(2)] public byte NumGLStacks;
-
- [Obsolete("GL has been removed from the game")]
- [FieldOffset(4)] private byte GLTimerFreezeState;
+ [FieldOffset(4)]
+ private byte glTimerFreezeState;
+ ///
+ /// Gets if the Greased Lightning timer has been frozen.
+ ///
+ /// >true or false.
[Obsolete("GL has been removed from the game")]
public bool IsGLTimerFroze() => false;
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/NINGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/NINGauge.cs
index 36f9bb268..13eaec09d 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/NINGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/NINGauge.cs
@@ -3,16 +3,36 @@ using System.Runtime.InteropServices;
namespace Dalamud.Game.ClientState.Structs.JobGauge
{
+ ///
+ /// In-memory NIN job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
public struct NINGauge
{
- [FieldOffset(0)] public int HutonTimeLeft;
- [FieldOffset(4)] public byte Ninki;
+ ///
+ /// Gets the time left on Huton in milliseconds.
+ ///
+ // TODO: Probably a short, confirm.
+ [FieldOffset(0)]
+ public int HutonTimeLeft;
- [Obsolete("Does not appear to be used")]
- [FieldOffset(4)] public byte TCJMudrasUsed;
+ ///
+ /// Gets the amount of Ninki available.
+ ///
+ [FieldOffset(4)]
+ public byte Ninki;
+ ///
+ /// Obsolete.
+ ///
[Obsolete("Does not appear to be used")]
- [FieldOffset(6)] public byte NumHutonManualCasts;
+ [FieldOffset(4)]
+ public byte TCJMudrasUsed;
+
+ ///
+ /// Gets the number of times Huton has been cast manually.
+ ///
+ [FieldOffset(5)]
+ public byte NumHutonManualCasts;
}
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/PLDGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/PLDGauge.cs
index 30b7f65e3..d3eae81f3 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/PLDGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/PLDGauge.cs
@@ -1,14 +1,17 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Dalamud.Game.ClientState.Structs.JobGauge {
+namespace Dalamud.Game.ClientState.Structs.JobGauge
+{
+ ///
+ /// In-memory PLD job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
- public struct PLDGauge {
- [FieldOffset(0)] public byte GaugeAmount;
+ public struct PLDGauge
+ {
+ ///
+ /// Gets the current level of the Oath gauge.
+ ///
+ [FieldOffset(0)]
+ public byte GaugeAmount;
}
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/RDMGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/RDMGauge.cs
index b0a2fa0c6..f72d61d13 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/RDMGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/RDMGauge.cs
@@ -1,15 +1,23 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Dalamud.Game.ClientState.Structs.JobGauge {
+namespace Dalamud.Game.ClientState.Structs.JobGauge
+{
+ ///
+ /// In-memory RDM job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
- public struct RDMGauge {
- [FieldOffset(0)] public byte WhiteGauge;
- [FieldOffset(1)] public byte BlackGauge;
+ public struct RDMGauge
+ {
+ ///
+ /// Gets the level of the White gauge.
+ ///
+ [FieldOffset(0)]
+ public byte WhiteGauge;
+
+ ///
+ /// Gets the level of the Black gauge.
+ ///
+ [FieldOffset(1)]
+ public byte BlackGauge;
}
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/SAMGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/SAMGauge.cs
index 74d6e3817..d0796e5c9 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/SAMGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/SAMGauge.cs
@@ -1,17 +1,47 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Dalamud.Game.ClientState.Structs.JobGauge {
+namespace Dalamud.Game.ClientState.Structs.JobGauge
+{
+ ///
+ /// In-memory SAM job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
- public struct SAMGauge {
+ public struct SAMGauge
+ {
+ ///
+ /// Gets the current amount of Kenki available.
+ ///
+ [FieldOffset(3)]
+ public byte Kenki;
- [FieldOffset(3)] public byte Kenki;
- [FieldOffset(4)] public byte MeditationStacks;
- [FieldOffset(5)] public Sen Sen;
+ ///
+ /// Gets the amount of Meditation stacks.
+ ///
+ [FieldOffset(4)]
+ public byte MeditationStacks;
+
+ ///
+ /// Gets the active Sen.
+ ///
+ [FieldOffset(5)]
+ public Sen Sen;
+
+ ///
+ /// Gets if the Setsu Sen is active.
+ ///
+ /// true or false.
+ public bool HasSetsu() => (this.Sen & Sen.SETSU) != 0;
+
+ ///
+ /// Gets if the Getsu Sen is active.
+ ///
+ /// true or false.
+ public bool HasGetsu() => (this.Sen & Sen.GETSU) != 0;
+
+ ///
+ /// Gets if the Ka Sen is active.
+ ///
+ /// true or false.
+ public bool HasKa() => (this.Sen & Sen.KA) != 0;
}
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/SCHGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/SCHGauge.cs
index 5d742ee0e..5dc99cf15 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/SCHGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/SCHGauge.cs
@@ -1,17 +1,35 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Dalamud.Game.ClientState.Structs.JobGauge {
+namespace Dalamud.Game.ClientState.Structs.JobGauge
+{
+ ///
+ /// In-memory SCH job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
- public struct SCHGauge {
- [FieldOffset(2)] public byte NumAetherflowStacks;
- [FieldOffset(3)] public byte FairyGaugeAmount;
- [FieldOffset(4)] public short SeraphTimer;
- [FieldOffset(6)] public DismissedFairy DismissedFairy;
+ public struct SCHGauge
+ {
+ ///
+ /// Gets the amount of Aetherflow stacks available.
+ ///
+ [FieldOffset(2)]
+ public byte NumAetherflowStacks;
+
+ ///
+ /// Gets the current level of the Fairy Gauge.
+ ///
+ [FieldOffset(3)]
+ public byte FairyGaugeAmount;
+
+ ///
+ /// Gets the Seraph time remaining in milliseconds.
+ ///
+ [FieldOffset(4)]
+ public short SeraphTimer;
+
+ ///
+ /// Gets the last dismissed fairy.
+ ///
+ [FieldOffset(6)]
+ public DismissedFairy DismissedFairy;
}
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/SMNGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/SMNGauge.cs
index 1742f4d97..a5e9cc219 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/SMNGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/SMNGauge.cs
@@ -1,31 +1,54 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Dalamud.Game.ClientState.Structs.JobGauge {
+namespace Dalamud.Game.ClientState.Structs.JobGauge
+{
+ ///
+ /// In-memory SMN job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
- public struct SMNGauge {
-
- //Unfinished
- [FieldOffset(0)] public short TimerRemaining;
- [FieldOffset(2)] public SummonPet ReturnSummon;
- [FieldOffset(3)] public PetGlam ReturnSummonGlam;
- [FieldOffset(4)] public byte NumStacks;
+ public struct SMNGauge
+ {
+ ///
+ /// Gets the time remaining for the current summon.
+ ///
+ [FieldOffset(0)]
+ public short TimerRemaining;
- public bool IsPhoenixReady() {
- return (NumStacks & 0x10) > 0;
- }
+ ///
+ /// Gets the summon that will return after the current summon expires.
+ ///
+ [FieldOffset(2)]
+ public SummonPet ReturnSummon;
- public bool IsBahamutReady() {
- return (NumStacks & 8) > 0;
- }
+ ///
+ /// Gets the summon glam for the .
+ ///
+ [FieldOffset(3)]
+ public PetGlam ReturnSummonGlam;
- public bool HasAetherflowStacks() {
- return (NumStacks & 3) > 0;
- }
+ ///
+ /// Gets the current stacks.
+ /// Use the summon accessors instead.
+ ///
+ [FieldOffset(4)]
+ public byte NumStacks;
+
+ ///
+ /// Gets if Phoenix is ready to be summoned.
+ ///
+ /// true or false.
+ public bool IsPhoenixReady() => (this.NumStacks & 0x10) > 0;
+
+ ///
+ /// Gets if Bahamut is ready to be summoned.
+ ///
+ /// true or false.
+ public bool IsBahamutReady() => (this.NumStacks & 8) > 0;
+
+ ///
+ /// Gets if there are any Aetherflow stacks available.
+ ///
+ /// true or false.
+ public bool HasAetherflowStacks() => (this.NumStacks & 3) > 0;
}
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/WARGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/WARGauge.cs
index ed1ecf364..7747b9cea 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/WARGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/WARGauge.cs
@@ -1,14 +1,17 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Dalamud.Game.ClientState.Structs.JobGauge {
+namespace Dalamud.Game.ClientState.Structs.JobGauge
+{
+ ///
+ /// In-memory WAR job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
- public struct WARGauge {
- [FieldOffset(0)] public byte BeastGaugeAmount;
+ public struct WARGauge
+ {
+ ///
+ /// Gets the amount of wrath in the Beast gauge.
+ ///
+ [FieldOffset(0)]
+ public byte BeastGaugeAmount;
}
}
diff --git a/Dalamud/Game/ClientState/Structs/JobGauge/WHMGauge.cs b/Dalamud/Game/ClientState/Structs/JobGauge/WHMGauge.cs
index a5ad15906..0ea51470e 100644
--- a/Dalamud/Game/ClientState/Structs/JobGauge/WHMGauge.cs
+++ b/Dalamud/Game/ClientState/Structs/JobGauge/WHMGauge.cs
@@ -1,16 +1,29 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Dalamud.Game.ClientState.Structs.JobGauge {
+namespace Dalamud.Game.ClientState.Structs.JobGauge
+{
+ ///
+ /// In-memory WHM job gauge.
+ ///
[StructLayout(LayoutKind.Explicit)]
- public struct WHMGauge {
- [FieldOffset(2)] public short LilyTimer; //Counts to 30k = 30s
- [FieldOffset(4)] public byte NumLilies;
- [FieldOffset(5)] public byte NumBloodLily;
+ public struct WHMGauge
+ {
+ ///
+ /// Gets the time to next lily in milliseconds.
+ ///
+ [FieldOffset(2)]
+ public short LilyTimer;
+
+ ///
+ /// Gets the number of Lilies.
+ ///
+ [FieldOffset(4)]
+ public byte NumLilies;
+
+ ///
+ /// Gets the number of times the blood lily has been nourished.
+ ///
+ [FieldOffset(5)]
+ public byte NumBloodLily;
}
}
diff --git a/Dalamud/Interface/Scratchpad/ScratchExecutionManager.cs b/Dalamud/Interface/Scratchpad/ScratchExecutionManager.cs
index 3110fed5a..07010bc84 100644
--- a/Dalamud/Interface/Scratchpad/ScratchExecutionManager.cs
+++ b/Dalamud/Interface/Scratchpad/ScratchExecutionManager.cs
@@ -1,32 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Dalamud.Configuration;
+
using Dalamud.Plugin;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Scripting;
using Microsoft.CodeAnalysis.Scripting;
using Serilog;
namespace Dalamud.Interface.Scratchpad
{
- class ScratchExecutionManager
+ ///
+ /// This class manages the execution of classes.
+ ///
+ internal class ScratchExecutionManager
{
private readonly Dalamud dalamud;
- private Dictionary loadedScratches = new Dictionary();
-
- public ScratchMacroProcessor MacroProcessor { get; private set; } = new ScratchMacroProcessor();
+ private Dictionary loadedScratches = new();
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Dalamud instance.
public ScratchExecutionManager(Dalamud dalamud)
{
this.dalamud = dalamud;
}
+ ///
+ /// Gets the ScratchPad macro processor.
+ ///
+ public ScratchMacroProcessor MacroProcessor { get; private set; } = new();
+
+ ///
+ /// Dispose of all currently loaded ScratchPads.
+ ///
public void DisposeAllScratches()
{
foreach (var dalamudPlugin in this.loadedScratches)
@@ -37,6 +46,11 @@ namespace Dalamud.Interface.Scratchpad
this.loadedScratches.Clear();
}
+ ///
+ /// Renew a given ScratchPadDocument.
+ ///
+ /// The document to renew.
+ /// The new load status.
public ScratchLoadStatus RenewScratch(ScratchpadDocument doc)
{
var existingScratch = this.loadedScratches.FirstOrDefault(x => x.Key == doc.Id);
@@ -51,11 +65,10 @@ namespace Dalamud.Interface.Scratchpad
var options = ScriptOptions.Default
.AddReferences(typeof(ImGui).Assembly)
.AddReferences(typeof(Dalamud).Assembly)
- .AddReferences(typeof(FFXIVClientStructs.Attributes.Addon)
- .Assembly) // FFXIVClientStructs
+ .AddReferences(typeof(FFXIVClientStructs.Attributes.Addon).Assembly) // FFXIVClientStructs
.AddReferences(typeof(Lumina.GameData).Assembly) // Lumina
.AddReferences(typeof(TerritoryType).Assembly) // Lumina.Excel
- //.WithReferences(MetadataReference.CreateFromFile(typeof(ScratchExecutionManager).Assembly.Location))
+ // .WithReferences(MetadataReference.CreateFromFile(typeof(ScratchExecutionManager).Assembly.Location))
.AddImports("System")
.AddImports("System.IO")
.AddImports("System.Reflection")
diff --git a/Dalamud/Interface/Scratchpad/ScratchFileWatcher.cs b/Dalamud/Interface/Scratchpad/ScratchFileWatcher.cs
index 65ecf49e0..805ce11fe 100644
--- a/Dalamud/Interface/Scratchpad/ScratchFileWatcher.cs
+++ b/Dalamud/Interface/Scratchpad/ScratchFileWatcher.cs
@@ -1,21 +1,27 @@
-using System;
using System.Collections.Generic;
using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Dalamud.Interface.Scratchpad
{
- class ScratchFileWatcher
+ ///
+ /// A file watcher for classes.
+ ///
+ internal class ScratchFileWatcher
{
+ private FileSystemWatcher watcher = new();
+
+ ///
+ /// Gets or sets the list of tracked ScratchPad documents.
+ ///
public List TrackedScratches { get; set; } = new List();
- private FileSystemWatcher watcher = new FileSystemWatcher();
-
+ ///
+ /// Load a new ScratchPadDocument from disk.
+ ///
+ /// The filepath to load.
public void Load(string path)
{
- TrackedScratches.Add(new ScratchpadDocument
+ this.TrackedScratches.Add(new ScratchpadDocument
{
Title = Path.GetFileName(path),
Content = File.ReadAllText(path),
diff --git a/Dalamud/Interface/Scratchpad/ScratchLoadStatus.cs b/Dalamud/Interface/Scratchpad/ScratchLoadStatus.cs
index 1baf6d280..b9398c0f5 100644
--- a/Dalamud/Interface/Scratchpad/ScratchLoadStatus.cs
+++ b/Dalamud/Interface/Scratchpad/ScratchLoadStatus.cs
@@ -1,16 +1,28 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
namespace Dalamud.Interface.Scratchpad
{
- enum ScratchLoadStatus
+ ///
+ /// The load status of a class.
+ ///
+ internal enum ScratchLoadStatus
{
+ ///
+ /// Unknown.
+ ///
Unknown,
+
+ ///
+ /// Failure to compile.
+ ///
FailureCompile,
+
+ ///
+ /// Failure to initialize.
+ ///
FailureInit,
+
+ ///
+ /// Success.
+ ///
Success,
}
}
diff --git a/Dalamud/Interface/Scratchpad/ScratchMacroProcessor.cs b/Dalamud/Interface/Scratchpad/ScratchMacroProcessor.cs
index 6265f20b7..f47c2cab2 100644
--- a/Dalamud/Interface/Scratchpad/ScratchMacroProcessor.cs
+++ b/Dalamud/Interface/Scratchpad/ScratchMacroProcessor.cs
@@ -1,17 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Runtime.InteropServices;
-using System.Text;
using System.Text.RegularExpressions;
-using System.Threading.Tasks;
+
using Dalamud.Plugin;
namespace Dalamud.Interface.Scratchpad
{
- class ScratchMacroProcessor
+ ///
+ /// This class converts ScratchPad macros into runnable scripts.
+ ///
+ internal class ScratchMacroProcessor
{
- private const string template = @"
+ private const string Template = @"
public class ScratchPlugin : IDalamudPlugin {
@@ -53,22 +54,14 @@ public class ScratchPlugin : IDalamudPlugin {
Dispose,
}
- private class HookInfo
- {
- public string Body { get; set; }
-
- public string Arguments { get; set; }
-
- public string Invocation { get; set; }
-
- public string RetType { get; set; }
-
- public string Sig { get; set; }
- }
-
+ ///
+ /// Process the given macro input and return a script.
+ ///
+ /// Input to process.
+ /// A runnable script.
public string Process(string input)
{
- var lines = input.Split(new[] {'\r', '\n'});
+ var lines = input.Split(new[] { '\r', '\n' });
var ctx = ParseContext.None;
@@ -181,10 +174,8 @@ public class ScratchPlugin : IDalamudPlugin {
$"private Hook hook{i}Inst;\n";
hookInit += $"var addrH{i} = pi.TargetModuleScanner.ScanText(\"{hook.Sig}\");\n";
- hookInit +=
- $"this.hook{i}Inst = new Hook(addrH{i}, new Hook{i}Delegate(Hook{i}Detour), this);\n";
- hookInit +=
- $"this.hook{i}Inst.Enable();\n";
+ hookInit += $"this.hook{i}Inst = new Hook(addrH{i}, new Hook{i}Delegate(Hook{i}Detour), this);\n";
+ hookInit += $"this.hook{i}Inst.Enable();\n";
var originalCall = $"this.hook{i}Inst.Original({hook.Invocation});\n";
if (hook.RetType != "void")
@@ -225,7 +216,7 @@ public class ScratchPlugin : IDalamudPlugin {
noneBody += "\n" + hookDetour;
disposeBody += "\n" + hookDispose;
- var output = template;
+ var output = Template;
output = output.Replace("{SETUPBODY}", setupBody);
output = output.Replace("{INITBODY}", initBody);
output = output.Replace("{DRAWBODY}", drawBody);
@@ -234,5 +225,18 @@ public class ScratchPlugin : IDalamudPlugin {
return output;
}
+
+ private class HookInfo
+ {
+ public string Body { get; set; }
+
+ public string Arguments { get; set; }
+
+ public string Invocation { get; set; }
+
+ public string RetType { get; set; }
+
+ public string Sig { get; set; }
+ }
}
}
diff --git a/Dalamud/Interface/Scratchpad/ScratchpadDocument.cs b/Dalamud/Interface/Scratchpad/ScratchpadDocument.cs
index 07f66b63b..22c1e6b51 100644
--- a/Dalamud/Interface/Scratchpad/ScratchpadDocument.cs
+++ b/Dalamud/Interface/Scratchpad/ScratchpadDocument.cs
@@ -1,25 +1,45 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Dalamud.Interface.Scratchpad
{
- class ScratchpadDocument
+ ///
+ /// This class represents a single document in the ScratchPad.
+ ///
+ internal class ScratchpadDocument
{
+ ///
+ /// Gets or sets the guid ID of the document.
+ ///
public Guid Id { get; set; } = Guid.NewGuid();
- public string Content = "INITIALIZE:\n\tPluginLog.Information(\"Loaded!\");\nEND;\n\nDISPOSE:\n\tPluginLog.Information(\"Disposed!\");\nEND;\n";
+ ///
+ /// Gets or sets the document content.
+ ///
+ public string Content { get; set; } = "INITIALIZE:\n\tPluginLog.Information(\"Loaded!\");\nEND;\n\nDISPOSE:\n\tPluginLog.Information(\"Disposed!\");\nEND;\n";
+ ///
+ /// Gets or sets the document title.
+ ///
public string Title { get; set; } = "New Document";
+ ///
+ /// Gets or sets a value indicating whether the document has unsaved content.
+ ///
public bool HasUnsaved { get; set; }
+ ///
+ /// Gets or sets a value indicating whether the document is open.
+ ///
public bool IsOpen { get; set; }
+ ///
+ /// Gets or sets the load status of the document.
+ ///
public ScratchLoadStatus Status { get; set; }
- public bool IsMacro = true;
+ ///
+ /// Gets or sets a value indicating whether this document is a macro.
+ ///
+ public bool IsMacro { get; set; } = true;
}
}
diff --git a/Dalamud/Interface/Scratchpad/ScratchpadWindow.cs b/Dalamud/Interface/Scratchpad/ScratchpadWindow.cs
index 753eb9f87..91324117c 100644
--- a/Dalamud/Interface/Scratchpad/ScratchpadWindow.cs
+++ b/Dalamud/Interface/Scratchpad/ScratchpadWindow.cs
@@ -2,31 +2,30 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
-using System.Text;
-using System.Threading.Tasks;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Windowing;
-using Dalamud.Plugin;
using ImGuiNET;
using Serilog;
namespace Dalamud.Interface.Scratchpad
{
- class ScratchpadWindow : Window, IDisposable
+ ///
+ /// This class facilitates interacting with the ScratchPad window.
+ ///
+ internal class ScratchpadWindow : Window, IDisposable
{
private readonly Dalamud dalamud;
-
- public ScratchExecutionManager Execution { get; private set; }
-
- private List documents = new List();
-
- private ScratchFileWatcher watcher = new ScratchFileWatcher();
-
+ private List documents = new();
+ private ScratchFileWatcher watcher = new();
private string pathInput = string.Empty;
- public ScratchpadWindow(Dalamud dalamud) :
- base("Plugin Scratchpad", ImGuiWindowFlags.MenuBar)
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Dalamud instance.
+ public ScratchpadWindow(Dalamud dalamud)
+ : base("Plugin Scratchpad", ImGuiWindowFlags.MenuBar)
{
this.dalamud = dalamud;
this.documents.Add(new ScratchpadDocument());
@@ -36,6 +35,12 @@ namespace Dalamud.Interface.Scratchpad
this.Execution = new ScratchExecutionManager(dalamud);
}
+ ///
+ /// Gets the ScratchPad execution manager.
+ ///
+ public ScratchExecutionManager Execution { get; private set; }
+
+ ///
public override void Draw()
{
if (ImGui.BeginPopupModal("Choose Path"))
@@ -53,7 +58,11 @@ namespace Dalamud.Interface.Scratchpad
ImGui.SetItemDefaultFocus();
ImGui.SameLine();
- if (ImGui.Button("Cancel", new Vector2(120, 0))) { ImGui.CloseCurrentPopup(); }
+ if (ImGui.Button("Cancel", new Vector2(120, 0)))
+ {
+ ImGui.CloseCurrentPopup();
+ }
+
ImGui.EndPopup();
}
@@ -88,9 +97,10 @@ namespace Dalamud.Interface.Scratchpad
if (ImGui.BeginTabItem(docs[i].Title + (docs[i].HasUnsaved ? "*" : string.Empty) + "###ScratchItem" + i, ref isOpen))
{
- if (ImGui.InputTextMultiline("###ScratchInput" + i, ref docs[i].Content, 20000,
- new Vector2(-1, -34), ImGuiInputTextFlags.AllowTabInput))
+ var content = docs[i].Content;
+ if (ImGui.InputTextMultiline("###ScratchInput" + i, ref content, 20000, new Vector2(-1, -34), ImGuiInputTextFlags.AllowTabInput))
{
+ docs[i].Content = content;
docs[i].HasUnsaved = true;
}
@@ -133,7 +143,11 @@ namespace Dalamud.Interface.Scratchpad
ImGui.SameLine();
- ImGui.Checkbox("Use Macros", ref docs[i].IsMacro);
+ var isMacro = docs[i].IsMacro;
+ if (ImGui.Checkbox("Use Macros", ref isMacro))
+ {
+ docs[i].IsMacro = isMacro;
+ }
ImGui.SameLine();
@@ -167,6 +181,9 @@ namespace Dalamud.Interface.Scratchpad
}
}
+ ///
+ /// Dispose of managed and unmanaged resources.
+ ///
public void Dispose()
{
this.Execution.DisposeAllScratches();
diff --git a/Dalamud/Interface/Windowing/Window.cs b/Dalamud/Interface/Windowing/Window.cs
index 1271d09fb..bd3c55bd5 100644
--- a/Dalamud/Interface/Windowing/Window.cs
+++ b/Dalamud/Interface/Windowing/Window.cs
@@ -1,7 +1,6 @@
using System.Numerics;
using ImGuiNET;
-using Serilog;
namespace Dalamud.Interface.Windowing
{
@@ -12,7 +11,6 @@ namespace Dalamud.Interface.Windowing
{
private bool internalLastIsOpen = false;
private bool internalIsOpen = false;
- private bool mainIsOpen = false;
///
/// Initializes a new instance of the class.
@@ -30,6 +28,9 @@ namespace Dalamud.Interface.Windowing
this.ForceMainWindow = forceMainWindow;
}
+ ///
+ /// Gets or sets the namespace of the window.
+ ///
public string Namespace { get; set; }
///
@@ -115,28 +116,35 @@ namespace Dalamud.Interface.Windowing
}
///
+ /// Code to be executed every time the window renders.
+ ///
+ ///
/// In this method, implement your drawing code.
/// You do NOT need to ImGui.Begin your window.
- ///
+ ///
public abstract void Draw();
///
/// Code to be executed when the window is opened.
///
- public virtual void OnOpen() { }
+ public virtual void OnOpen()
+ {
+ }
///
/// Code to be executed when the window is closed.
///
- public virtual void OnClose() { }
+ public virtual void OnClose()
+ {
+ }
///
/// Draw the window via ImGui.
///
internal void DrawInternal()
{
- //if (WindowName.Contains("Credits"))
- // Log.Information($"Draw: {IsOpen} {this.internalIsOpen} {this.internalLastIsOpen}");
+ // if (WindowName.Contains("Credits"))
+ // Log.Information($"Draw: {IsOpen} {this.internalIsOpen} {this.internalLastIsOpen}");
if (!this.IsOpen)
{
diff --git a/Dalamud/Interface/Windowing/WindowSystem.cs b/Dalamud/Interface/Windowing/WindowSystem.cs
index a42b51a18..f13797a17 100644
--- a/Dalamud/Interface/Windowing/WindowSystem.cs
+++ b/Dalamud/Interface/Windowing/WindowSystem.cs
@@ -12,7 +12,7 @@ namespace Dalamud.Interface.Windowing
///
public class WindowSystem
{
- private readonly List windows = new List();
+ private readonly List windows = new();
///
/// Initializes a new instance of the class.
@@ -70,7 +70,7 @@ namespace Dalamud.Interface.Windowing
foreach (var window in this.windows)
{
#if DEBUG
- //Log.Verbose($"[WS{(hasNamespace ? "/" + this.Namespace : string.Empty)}] Drawing {window.WindowName}");
+ // Log.Verbose($"[WS{(hasNamespace ? "/" + this.Namespace : string.Empty)}] Drawing {window.WindowName}");
#endif
window.DrawInternal();
diff --git a/Dalamud/Localization.cs b/Dalamud/Localization.cs
index 4fefa1fe3..3469dcb64 100644
--- a/Dalamud/Localization.cs
+++ b/Dalamud/Localization.cs
@@ -41,7 +41,7 @@ namespace Dalamud
}
///
- /// Delegate for the event that occurs when the language is changed.
+ /// Delegate for the event that occurs when the language is changed.
///
/// The language code of the new language.
public delegate void LocalizationChangedDelegate(string langCode);
@@ -51,6 +51,19 @@ namespace Dalamud
///
public event LocalizationChangedDelegate OnLocalizationChanged;
+ ///
+ /// Search the set-up localization data for the provided assembly for the given string key and return it.
+ /// If the key is not present, the fallback is shown.
+ /// The fallback is also required to create the string files to be localized.
+ ///
+ /// The string key to be returned.
+ /// The fallback string, usually your source language.
+ /// The localized string, fallback or string key if not found.
+ public static string Localize(string key, string fallBack)
+ {
+ return Loc.Localize(key, fallBack, Assembly.GetCallingAssembly());
+ }
+
///
/// Set up the UI language with the users' local UI culture.
///
@@ -118,19 +131,6 @@ namespace Dalamud
Loc.ExportLocalizableForAssembly(this.assembly);
}
- ///
- /// Search the set-up localization data for the provided assembly for the given string key and return it.
- /// If the key is not present, the fallback is shown.
- /// The fallback is also required to create the string files to be localized.
- ///
- /// The string key to be returned.
- /// The fallback string, usually your source language.
- /// The localized string, fallback or string key if not found.
- public static string Localize(string key, string fallBack)
- {
- return Loc.Localize(key, fallBack, Assembly.GetCallingAssembly());
- }
-
private string ReadLocData(string langCode)
{
if (this.useEmbedded)
diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs
index 544ef9209..a9ed0dc4a 100644
--- a/Dalamud/Plugin/DalamudPluginInterface.cs
+++ b/Dalamud/Plugin/DalamudPluginInterface.cs
@@ -94,7 +94,7 @@ namespace Dalamud.Plugin
///
/// Gets the directory your plugin configurations are stored in.
///
- public DirectoryInfo ConfigDirectory => new DirectoryInfo(this.GetPluginConfigDirectory());
+ public DirectoryInfo ConfigDirectory => new(this.GetPluginConfigDirectory());
///
/// Gets the config file of your plugin.
diff --git a/Dalamud/Plugin/IDalamudPlugin.cs b/Dalamud/Plugin/IDalamudPlugin.cs
index c5585a0ae..aff863eac 100644
--- a/Dalamud/Plugin/IDalamudPlugin.cs
+++ b/Dalamud/Plugin/IDalamudPlugin.cs
@@ -1,8 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Dalamud.Plugin
{
diff --git a/Dalamud/Plugin/PluginLoadReason.cs b/Dalamud/Plugin/PluginLoadReason.cs
index fa60e33a6..789d4d094 100644
--- a/Dalamud/Plugin/PluginLoadReason.cs
+++ b/Dalamud/Plugin/PluginLoadReason.cs
@@ -1,9 +1,3 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
namespace Dalamud.Plugin
{
///
diff --git a/Dalamud/Plugin/PluginLog.cs b/Dalamud/Plugin/PluginLog.cs
index ef1d3c78e..3bfa0d904 100644
--- a/Dalamud/Plugin/PluginLog.cs
+++ b/Dalamud/Plugin/PluginLog.cs
@@ -1,10 +1,6 @@
using System;
-using System.Diagnostics;
using System.Reflection;
-using Serilog;
-using Serilog.Events;
-
namespace Dalamud.Plugin
{
///
diff --git a/Dalamud/SafeMemory.cs b/Dalamud/SafeMemory.cs
index 44aca3543..458cc6824 100644
--- a/Dalamud/SafeMemory.cs
+++ b/Dalamud/SafeMemory.cs
@@ -12,7 +12,7 @@ namespace Dalamud
///
///
/// Attention! The performance of these methods is severely worse than regular calls.
- /// Please consider using these instead in performance-critical code.
+ /// Please consider using those instead in performance-critical code.
///
public static class SafeMemory
{
@@ -50,7 +50,7 @@ namespace Dalamud
}
///
- /// Read an object of the specified struct from the current process.
+ /// Read an object of the specified struct from the current process.
///
/// The type of the struct.
/// The address to read from.
diff --git a/Dalamud/Troubleshooting.cs b/Dalamud/Troubleshooting.cs
index 8cabc4ede..d8137165a 100644
--- a/Dalamud/Troubleshooting.cs
+++ b/Dalamud/Troubleshooting.cs
@@ -37,9 +37,8 @@ namespace Dalamud
ThirdRepo = dalamud.Configuration.ThirdRepoList,
};
- Log.Information("TROUBLESHOOTING:" +
- System.Convert.ToBase64String(
- Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(payload))));
+ var encodedPayload = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(payload)));
+ Log.Information($"TROUBLESHOOTING:{encodedPayload}");
}
catch (Exception ex)
{
diff --git a/Dalamud/XivApi.cs b/Dalamud/XivApi.cs
deleted file mode 100644
index 31b6f334b..000000000
--- a/Dalamud/XivApi.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http;
-using System.Text;
-using System.Threading.Tasks;
-using Microsoft.CSharp.RuntimeBinder;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using Serilog;
-
-namespace Dalamud
-{
- class XivApi
- {
- private const string URL = "https://xivapi.com/";
-
- private static readonly ConcurrentDictionary cachedResponses = new ConcurrentDictionary();
-
- [Obsolete("This class will not be supported anymore in the future. Please migrate to your own version.", true)]
- public static async Task GetWorld(int world)
- {
- var res = await Get("World/" + world);
-
- return res;
- }
-
- [Obsolete("This class will not be supported anymore in the future. Please migrate to your own version.", true)]
- public static async Task GetClassJob(int id)
- {
- var res = await Get("ClassJob/" + id);
-
- return res;
- }
-
- [Obsolete("This class will not be supported anymore in the future. Please migrate to your own version.", true)]
- public static async Task GetFate(int id)
- {
- var res = await Get("Fate/" + id);
-
- return res;
- }
-
- [Obsolete("This class will not be supported anymore in the future. Please migrate to your own version.", true)]
- public static async Task GetCharacterSearch(string name, string world)
- {
- var res = await Get("character/search" + $"?name={name}&server={world}");
-
- return res;
- }
-
- [Obsolete("This class will not be supported anymore in the future. Please migrate to your own version.", true)]
- public static async Task GetContentFinderCondition(int contentFinderCondition) {
- return await Get("ContentFinderCondition/" + contentFinderCondition);
- }
-
- [Obsolete("This class will not be supported anymore in the future. Please migrate to your own version.", true)]
- public static async Task Search(string query, string indexes, int limit = 100, bool exact = false) {
- query = System.Net.WebUtility.UrlEncode(query);
-
- var queryString = $"?string={query}&indexes={indexes}&limit={limit}";
- if (exact)
- {
- queryString += "&string_algo=match";
- }
-
- return await Get("search" + queryString);
- }
-
- [Obsolete("This class will not be supported anymore in the future. Please migrate to your own version.", true)]
- public static async Task GetMarketInfoWorld(int itemId, string worldName) {
- return await Get($"market/{worldName}/item/{itemId}", true);
- }
-
- [Obsolete("This class will not be supported anymore in the future. Please migrate to your own version.", true)]
- public static async Task GetMarketInfoDc(int itemId, string dcName) {
- return await Get($"market/item/{itemId}?dc={dcName}", true);
- }
-
- [Obsolete("This class will not be supported anymore in the future. Please migrate to your own version.", true)]
- public static async Task GetItem(uint itemId) {
- return await Get($"Item/{itemId}", true);
- }
-
- [Obsolete("This class will not be supported anymore in the future. Please migrate to your own version.", true)]
- public static async Task Get(string endpoint, bool noCache = false)
- {
- Log.Verbose("XIVAPI FETCH: {0}", endpoint);
-
- if (cachedResponses.TryGetValue(endpoint, out var val) && !noCache)
- return val;
-
- var client = new HttpClient();
- var response = await client.GetAsync(URL + endpoint);
- var result = await response.Content.ReadAsStringAsync();
-
- var obj = JObject.Parse(result);
-
- if (!noCache)
- cachedResponses.TryAdd(endpoint, obj);
-
- return obj;
- }
- }
-}
diff --git a/Dalamud/stylecop.json b/Dalamud/stylecop.json
index aaefb4f82..6881efc6d 100644
--- a/Dalamud/stylecop.json
+++ b/Dalamud/stylecop.json
@@ -1,16 +1,13 @@
{
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
- "documentationRules": {
-
- },
"orderingRules": {
"systemUsingDirectivesFirst": true,
"usingDirectivesPlacement": "outsideNamespace",
"blankLinesBetweenUsingGroups": "require"
},
"maintainabilityRules": {
- "topLevelTypes": ["class", "interface", "struct", "enum"]
+ "topLevelTypes": [ "class", "interface", "struct", "enum" ]
}
}
}