mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Merge branch 'master' of https://github.com/goatcorp/Dalamud
This commit is contained in:
commit
b80072ea44
43 changed files with 1592 additions and 621 deletions
|
|
@ -11,6 +11,9 @@
|
||||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>Portable</DebugType>
|
<DebugType>Portable</DebugType>
|
||||||
|
<NoWarn>IDE1006;CS1701;CS1702</NoWarn>
|
||||||
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
<DocumentationFile>$(SolutionDir)\bin\Dalamud.Injector.xml</DocumentationFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Label="Feature">
|
<PropertyGroup Label="Feature">
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
|
@ -19,9 +22,6 @@
|
||||||
<Description>XIVLauncher addon injection</Description>
|
<Description>XIVLauncher addon injection</Description>
|
||||||
<Version>5.2.4.6</Version>
|
<Version>5.2.4.6</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
|
||||||
<DocumentationFile></DocumentationFile>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
<AppOutputBase>$(MSBuildProjectDirectory)\</AppOutputBase>
|
<AppOutputBase>$(MSBuildProjectDirectory)\</AppOutputBase>
|
||||||
<PathMap>$(AppOutputBase)=C:\goatsoft\companysecrets\injector\</PathMap>
|
<PathMap>$(AppOutputBase)=C:\goatsoft\companysecrets\injector\</PathMap>
|
||||||
|
|
@ -33,9 +33,19 @@
|
||||||
<PackageIconUrl />
|
<PackageIconUrl />
|
||||||
<ApplicationIcon>dalamud.ico</ApplicationIcon>
|
<ApplicationIcon>dalamud.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="stylecop.json" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AdditionalFiles Include="stylecop.json" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="EasyHook" Version="2.7.6270" />
|
<PackageReference Include="EasyHook" Version="2.7.6270" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.333">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DalamudDebugStub\DalamudDebugStub.vcxproj" />
|
<ProjectReference Include="..\DalamudDebugStub\DalamudDebugStub.vcxproj" />
|
||||||
|
|
@ -45,6 +55,6 @@
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)'=='Release'">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)'=='Release'">
|
||||||
<Exec Command="powershell -ExecutionPolicy Unrestricted $(SolutionDir)CreateHashList.ps1 $(OutputPath)" />
|
<Exec Command="powershell -ExecutionPolicy Unrestricted $(SolutionDir)CreateHashList.ps1 $(OutputPath)" />
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
19
Dalamud.Injector/GlobalSuppressions.cs
Normal file
19
Dalamud.Injector/GlobalSuppressions.cs
Normal file
|
|
@ -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)")]
|
||||||
|
|
@ -1,79 +1,491 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.ConstrainedExecution;
|
using System.Runtime.ConstrainedExecution;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security;
|
using System.Security;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Injector
|
namespace Dalamud.Injector
|
||||||
{
|
{
|
||||||
static class NativeFunctions
|
/// <summary>
|
||||||
|
/// Native functions.
|
||||||
|
/// </summary>
|
||||||
|
internal static class NativeFunctions
|
||||||
{
|
{
|
||||||
[Flags]
|
/// <summary>
|
||||||
public enum ProcessAccessFlags : uint
|
/// MEM_* from memoryapi.
|
||||||
{
|
/// </summary>
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum AllocationType
|
public enum AllocationType
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
CoalescePlaceholders = 0x00000001,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
PreservePlaceholder = 0x00000002,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
Commit = 0x1000,
|
Commit = 0x1000,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
Reserve = 0x2000,
|
Reserve = 0x2000,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
Decommit = 0x4000,
|
Decommit = 0x4000,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
Release = 0x8000,
|
Release = 0x8000,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
Reset = 0x80000,
|
Reset = 0x80000,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
ResetUndo = 0x1000000,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
Physical = 0x400000,
|
Physical = 0x400000,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allocates memory at the highest possible address. This can be slower than regular allocations, especially when
|
||||||
|
/// there are many allocations.
|
||||||
|
/// </summary>
|
||||||
TopDown = 0x100000,
|
TopDown = 0x100000,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
WriteWatch = 0x200000,
|
WriteWatch = 0x200000,
|
||||||
LargePages = 0x20000000
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
LargePages = 0x20000000,
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
|
/// <summary>
|
||||||
public static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress,
|
/// PAGE_* from memoryapi.
|
||||||
int dwSize, AllocationType dwFreeType);
|
/// </summary>
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum MemoryProtection
|
public enum MemoryProtection
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Enables execute access to the committed region of pages. An attempt to write to the committed region results
|
||||||
|
/// in an access violation. This flag is not supported by the CreateFileMapping function.
|
||||||
|
/// </summary>
|
||||||
Execute = 0x10,
|
Execute = 0x10,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enables execute or read-only access to the committed region of pages. An attempt to write to the committed region
|
||||||
|
/// results in an access violation.
|
||||||
|
/// </summary>
|
||||||
ExecuteRead = 0x20,
|
ExecuteRead = 0x20,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enables execute, read-only, or read/write access to the committed region of pages.
|
||||||
|
/// </summary>
|
||||||
ExecuteReadWrite = 0x40,
|
ExecuteReadWrite = 0x40,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enables execute, read-only, or copy-on-write access to a mapped view of a file mapping object. An attempt to
|
||||||
|
/// write to a committed copy-on-write page results in a private copy of the page being made for the process. The
|
||||||
|
/// private page is marked as PAGE_EXECUTE_READWRITE, and the change is written to the new page. This flag is not
|
||||||
|
/// supported by the VirtualAlloc or VirtualAllocEx functions.
|
||||||
|
/// </summary>
|
||||||
ExecuteWriteCopy = 0x80,
|
ExecuteWriteCopy = 0x80,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disables all access to the committed region of pages. An attempt to read from, write to, or execute the committed
|
||||||
|
/// region results in an access violation. This flag is not supported by the CreateFileMapping function.
|
||||||
|
/// </summary>
|
||||||
NoAccess = 0x01,
|
NoAccess = 0x01,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enables read-only access to the committed region of pages. An attempt to write to the committed region results
|
||||||
|
/// in an access violation. If Data Execution Prevention is enabled, an attempt to execute code in the committed
|
||||||
|
/// region results in an access violation.
|
||||||
|
/// </summary>
|
||||||
ReadOnly = 0x02,
|
ReadOnly = 0x02,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enables read-only or read/write access to the committed region of pages. If Data Execution Prevention is enabled,
|
||||||
|
/// attempting to execute code in the committed region results in an access violation.
|
||||||
|
/// </summary>
|
||||||
ReadWrite = 0x04,
|
ReadWrite = 0x04,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enables read-only or copy-on-write access to a mapped view of a file mapping object. An attempt to write to
|
||||||
|
/// a committed copy-on-write page results in a private copy of the page being made for the process. The private
|
||||||
|
/// page is marked as PAGE_READWRITE, and the change is written to the new page. If Data Execution Prevention is
|
||||||
|
/// enabled, attempting to execute code in the committed region results in an access violation. This flag is not
|
||||||
|
/// supported by the VirtualAlloc or VirtualAllocEx functions.
|
||||||
|
/// </summary>
|
||||||
WriteCopy = 0x08,
|
WriteCopy = 0x08,
|
||||||
GuardModifierflag = 0x100,
|
|
||||||
NoCacheModifierflag = 0x200,
|
/// <summary>
|
||||||
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.
|
||||||
|
/// </summary>
|
||||||
|
TargetsInvalid = 0x40000000,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pages in the region will not have their CFG information updated while the protection changes for VirtualProtect.
|
||||||
|
/// For example, if the pages in the region was allocated using PAGE_TARGETS_INVALID, then the invalid information
|
||||||
|
/// will be maintained while the page protection changes. This flag is only valid when the protection changes to
|
||||||
|
/// an executable type like PAGE_EXECUTE, PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE and PAGE_EXECUTE_WRITECOPY.
|
||||||
|
/// The default behavior for VirtualProtect protection change to executable is to mark all locations as valid call
|
||||||
|
/// targets for CFG.
|
||||||
|
/// </summary>
|
||||||
|
TargetsNoUpdate = 0x40000000,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pages in the region become guard pages. Any attempt to access a guard page causes the system to raise a
|
||||||
|
/// STATUS_GUARD_PAGE_VIOLATION exception and turn off the guard page status. Guard pages thus act as a one-time
|
||||||
|
/// access alarm. For more information, see Creating Guard Pages. When an access attempt leads the system to turn
|
||||||
|
/// off guard page status, the underlying page protection takes over. If a guard page exception occurs during a
|
||||||
|
/// system service, the service typically returns a failure status indicator. This value cannot be used with
|
||||||
|
/// PAGE_NOACCESS. This flag is not supported by the CreateFileMapping function.
|
||||||
|
/// </summary>
|
||||||
|
Guard = 0x100,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets all pages to be non-cachable. Applications should not use this attribute except when explicitly required
|
||||||
|
/// for a device. Using the interlocked functions with memory that is mapped with SEC_NOCACHE can result in an
|
||||||
|
/// EXCEPTION_ILLEGAL_INSTRUCTION exception. The PAGE_NOCACHE flag cannot be used with the PAGE_GUARD, PAGE_NOACCESS,
|
||||||
|
/// or PAGE_WRITECOMBINE flags. The PAGE_NOCACHE flag can be used only when allocating private memory with the
|
||||||
|
/// VirtualAlloc, VirtualAllocEx, or VirtualAllocExNuma functions. To enable non-cached memory access for shared
|
||||||
|
/// memory, specify the SEC_NOCACHE flag when calling the CreateFileMapping function.
|
||||||
|
/// </summary>
|
||||||
|
NoCache = 0x200,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets all pages to be write-combined. Applications should not use this attribute except when explicitly required
|
||||||
|
/// for a device. Using the interlocked functions with memory that is mapped as write-combined can result in an
|
||||||
|
/// EXCEPTION_ILLEGAL_INSTRUCTION exception. The PAGE_WRITECOMBINE flag cannot be specified with the PAGE_NOACCESS,
|
||||||
|
/// PAGE_GUARD, and PAGE_NOCACHE flags. The PAGE_WRITECOMBINE flag can be used only when allocating private memory
|
||||||
|
/// with the VirtualAlloc, VirtualAllocEx, or VirtualAllocExNuma functions. To enable write-combined memory access
|
||||||
|
/// for shared memory, specify the SEC_WRITECOMBINE flag when calling the CreateFileMapping function.
|
||||||
|
/// </summary>
|
||||||
|
WriteCombine = 0x400,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PROCESS_* from processthreadsapi.
|
||||||
|
/// </summary>
|
||||||
|
[Flags]
|
||||||
|
public enum ProcessAccessFlags : uint
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// All possible access rights for a process object.
|
||||||
|
/// </summary>
|
||||||
|
AllAccess = 0x001F0FFF,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required to create a process.
|
||||||
|
/// </summary>
|
||||||
|
CreateProcess = 0x0080,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required to create a thread.
|
||||||
|
/// </summary>
|
||||||
|
CreateThread = 0x0002,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required to duplicate a handle using DuplicateHandle.
|
||||||
|
/// </summary>
|
||||||
|
DupHandle = 0x0040,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required to retrieve certain information about a process, such as its token, exit code,
|
||||||
|
/// and priority class (see OpenProcessToken).
|
||||||
|
/// </summary>
|
||||||
|
QueryInformation = 0x0400,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
QueryLimitedInformation = 0x1000,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required to set certain information about a process, such as its priority class (see SetPriorityClass).
|
||||||
|
/// </summary>
|
||||||
|
SetInformation = 0x0200,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required to set memory limits using SetProcessWorkingSetSize.
|
||||||
|
/// </summary>
|
||||||
|
SetQuote = 0x0100,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required to suspend or resume a process.
|
||||||
|
/// </summary>
|
||||||
|
SuspendResume = 0x0800,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required to terminate a process using TerminateProcess.
|
||||||
|
/// </summary>
|
||||||
|
Terminate = 0x0001,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required to perform an operation on the address space of a process(see VirtualProtectEx and WriteProcessMemory).
|
||||||
|
/// </summary>
|
||||||
|
VmOperation = 0x0008,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required to read memory in a process using ReadProcessMemory.
|
||||||
|
/// </summary>
|
||||||
|
VmRead = 0x0010,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required to write to memory in a process using WriteProcessMemory.
|
||||||
|
/// </summary>
|
||||||
|
VmWrite = 0x0020,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required to wait for the process to terminate using the wait functions.
|
||||||
|
/// </summary>
|
||||||
|
Synchronize = 0x00100000,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes an open object handle.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hObject">
|
||||||
|
/// A valid handle to an open object.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// 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.
|
||||||
|
/// </returns>
|
||||||
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
|
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
|
||||||
|
[SuppressUnmanagedCodeSecurity]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool CloseHandle(IntPtr hObject);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hProcess">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="lpThreadAttributes">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="dwStackSize">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="lpStartAddress">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="lpParameter">
|
||||||
|
/// A pointer to a variable to be passed to the thread function.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="dwCreationFlags">
|
||||||
|
/// The flags that control the creation of the thread.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="lpThreadId">
|
||||||
|
/// A pointer to a variable that receives the thread identifier. If this parameter is NULL, the thread identifier is
|
||||||
|
/// not returned.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// 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).
|
||||||
|
/// </returns>
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
public static extern IntPtr CreateRemoteThread(
|
||||||
|
IntPtr hProcess,
|
||||||
|
IntPtr lpThreadAttributes,
|
||||||
|
uint dwStackSize,
|
||||||
|
IntPtr lpStartAddress,
|
||||||
|
IntPtr lpParameter,
|
||||||
|
uint dwCreationFlags,
|
||||||
|
IntPtr lpThreadId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="lpModuleName">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// 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.
|
||||||
|
/// </returns>
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
||||||
|
public static extern IntPtr GetModuleHandle(string lpModuleName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the address of an exported function or variable from the specified dynamic-link library (DLL).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hModule">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="procName">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// 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.
|
||||||
|
/// </returns>
|
||||||
|
[DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
|
||||||
|
public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// See https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-openprocess.
|
||||||
|
/// Opens an existing local process object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="processAccess">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="bInheritHandle">
|
||||||
|
/// If this value is TRUE, processes created by this process will inherit the handle. Otherwise, the processes do
|
||||||
|
/// not inherit this handle.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="processId">
|
||||||
|
/// The identifier of the local process to be opened.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// 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.
|
||||||
|
/// </returns>
|
||||||
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
|
public static extern IntPtr OpenProcess(
|
||||||
|
ProcessAccessFlags processAccess,
|
||||||
|
bool bInheritHandle,
|
||||||
|
int processId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hProcess">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="lpAddress">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="dwSize">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="flAllocationType">
|
||||||
|
/// The type of memory allocation. This parameter must contain one of the MEM_* enum values.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="flProtect">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// 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.
|
||||||
|
/// </returns>
|
||||||
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
|
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
|
||||||
public static extern IntPtr VirtualAllocEx(
|
public static extern IntPtr VirtualAllocEx(
|
||||||
IntPtr hProcess,
|
IntPtr hProcess,
|
||||||
|
|
@ -82,34 +494,76 @@ namespace Dalamud.Injector
|
||||||
AllocationType flAllocationType,
|
AllocationType flAllocationType,
|
||||||
MemoryProtection flProtect);
|
MemoryProtection flProtect);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hProcess">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="lpAddress">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="dwSize">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="dwFreeType">
|
||||||
|
/// The type of free operation. This parameter must be one of the MEM_* enum values.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// 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.
|
||||||
|
/// </returns>
|
||||||
|
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
|
||||||
|
public static extern bool VirtualFreeEx(
|
||||||
|
IntPtr hProcess,
|
||||||
|
IntPtr lpAddress,
|
||||||
|
int dwSize,
|
||||||
|
AllocationType dwFreeType);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hProcess">
|
||||||
|
/// A handle to the process memory to be modified. The handle must have PROCESS_VM_WRITE and PROCESS_VM_OPERATION access
|
||||||
|
/// to the process.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="lpBaseAddress">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="lpBuffer">
|
||||||
|
/// A pointer to the buffer that contains data to be written in the address space of the specified process.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="dwSize">
|
||||||
|
/// The number of bytes to be written to the specified process.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="lpNumberOfBytesWritten">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// 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.
|
||||||
|
/// </returns>
|
||||||
[DllImport("kernel32.dll", SetLastError = true)]
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
public static extern bool WriteProcessMemory(
|
public static extern bool WriteProcessMemory(
|
||||||
IntPtr hProcess,
|
IntPtr hProcess,
|
||||||
IntPtr lpBaseAddress,
|
IntPtr lpBaseAddress,
|
||||||
byte[] lpBuffer,
|
byte[] lpBuffer,
|
||||||
int dwSize,
|
int dwSize,
|
||||||
out IntPtr lpNumberOfBytesWritten);
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,27 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
using EasyHook;
|
using EasyHook;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Dalamud.Injector {
|
namespace Dalamud.Injector
|
||||||
internal static class Program {
|
{
|
||||||
static private Process process = null;
|
/// <summary>
|
||||||
|
/// Application entrypoint.
|
||||||
|
/// </summary>
|
||||||
|
internal static class Program
|
||||||
|
{
|
||||||
|
private static Process process = null;
|
||||||
|
|
||||||
private static void Main(string[] args) {
|
private static void Main(string[] args)
|
||||||
|
{
|
||||||
AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs eventArgs)
|
AppDomain.CurrentDomain.UnhandledException += (sender, eventArgs) =>
|
||||||
{
|
{
|
||||||
File.WriteAllText("InjectorException.txt", eventArgs.ExceptionObject.ToString());
|
File.WriteAllText("InjectorException.txt", eventArgs.ExceptionObject.ToString());
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
|
|
@ -29,13 +32,14 @@ namespace Dalamud.Injector {
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var pid = -1;
|
var pid = -1;
|
||||||
if (args.Length >= 1) {
|
if (args.Length >= 1)
|
||||||
|
{
|
||||||
pid = int.Parse(args[0]);
|
pid = int.Parse(args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (pid) {
|
switch (pid)
|
||||||
|
{
|
||||||
case -1:
|
case -1:
|
||||||
process = Process.GetProcessesByName("ffxiv_dx11")[0];
|
process = Process.GetProcessesByName("ffxiv_dx11")[0];
|
||||||
break;
|
break;
|
||||||
|
|
@ -51,13 +55,16 @@ namespace Dalamud.Injector {
|
||||||
}
|
}
|
||||||
|
|
||||||
DalamudStartInfo startInfo;
|
DalamudStartInfo startInfo;
|
||||||
if (args.Length <= 1) {
|
if (args.Length <= 1)
|
||||||
|
{
|
||||||
startInfo = GetDefaultStartInfo();
|
startInfo = GetDefaultStartInfo();
|
||||||
Console.WriteLine("\nA Dalamud start info was not found in the program arguments. One has been generated for you.");
|
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("\nCopy the following contents into the program arguments:");
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.WriteLine(Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(startInfo))));
|
Console.WriteLine(Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(startInfo))));
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
startInfo = JsonConvert.DeserializeObject<DalamudStartInfo>(Encoding.UTF8.GetString(Convert.FromBase64String(args[1])));
|
startInfo = JsonConvert.DeserializeObject<DalamudStartInfo>(Encoding.UTF8.GetString(Convert.FromBase64String(args[1])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,7 +73,7 @@ namespace Dalamud.Injector {
|
||||||
// Seems to help with the STATUS_INTERNAL_ERROR condition
|
// Seems to help with the STATUS_INTERNAL_ERROR condition
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
//Thread.Sleep(10000);
|
// Thread.Sleep(10000);
|
||||||
|
|
||||||
// Inject to process
|
// Inject to process
|
||||||
Inject(process, startInfo);
|
Inject(process, startInfo);
|
||||||
|
|
@ -75,16 +82,18 @@ namespace Dalamud.Injector {
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
// Inject exception handler
|
// Inject exception handler
|
||||||
//NativeInject(process);
|
// NativeInject(process);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Inject(Process process, DalamudStartInfo info) {
|
private static void Inject(Process process, DalamudStartInfo info)
|
||||||
|
{
|
||||||
Console.WriteLine($"Injecting to {process.Id}");
|
Console.WriteLine($"Injecting to {process.Id}");
|
||||||
|
|
||||||
// File check
|
// File check
|
||||||
var libPath = Path.GetFullPath("Dalamud.dll");
|
var libPath = Path.GetFullPath("Dalamud.dll");
|
||||||
if (!File.Exists(libPath)) {
|
if (!File.Exists(libPath))
|
||||||
|
{
|
||||||
Console.WriteLine($"Can't find a dll on {libPath}");
|
Console.WriteLine($"Can't find a dll on {libPath}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -104,12 +113,14 @@ namespace Dalamud.Injector {
|
||||||
Console.WriteLine($"Injecting {libPath}...");
|
Console.WriteLine($"Injecting {libPath}...");
|
||||||
|
|
||||||
var handle = NativeFunctions.OpenProcess(
|
var handle = NativeFunctions.OpenProcess(
|
||||||
NativeFunctions.ProcessAccessFlags.All,
|
NativeFunctions.ProcessAccessFlags.AllAccess,
|
||||||
false,
|
false,
|
||||||
process.Id);
|
process.Id);
|
||||||
|
|
||||||
if (handle == IntPtr.Zero)
|
if (handle == IntPtr.Zero)
|
||||||
|
{
|
||||||
throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not OpenProcess");
|
throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not OpenProcess");
|
||||||
|
}
|
||||||
|
|
||||||
var dllMem = NativeFunctions.VirtualAllocEx(
|
var dllMem = NativeFunctions.VirtualAllocEx(
|
||||||
handle,
|
handle,
|
||||||
|
|
@ -119,7 +130,9 @@ namespace Dalamud.Injector {
|
||||||
NativeFunctions.MemoryProtection.ReadWrite);
|
NativeFunctions.MemoryProtection.ReadWrite);
|
||||||
|
|
||||||
if (dllMem == IntPtr.Zero)
|
if (dllMem == IntPtr.Zero)
|
||||||
|
{
|
||||||
throw new Win32Exception(Marshal.GetLastWin32Error(), $"Could not alloc memory {Marshal.GetLastWin32Error():X}");
|
throw new Win32Exception(Marshal.GetLastWin32Error(), $"Could not alloc memory {Marshal.GetLastWin32Error():X}");
|
||||||
|
}
|
||||||
|
|
||||||
Console.WriteLine($"dll path at {dllMem.ToInt64():X}");
|
Console.WriteLine($"dll path at {dllMem.ToInt64():X}");
|
||||||
|
|
||||||
|
|
@ -128,9 +141,10 @@ namespace Dalamud.Injector {
|
||||||
dllMem,
|
dllMem,
|
||||||
pathBytes,
|
pathBytes,
|
||||||
len,
|
len,
|
||||||
out var bytesWritten
|
out var bytesWritten))
|
||||||
))
|
{
|
||||||
throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not write DLL");
|
throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not write DLL");
|
||||||
|
}
|
||||||
|
|
||||||
Console.WriteLine($"Wrote {bytesWritten}");
|
Console.WriteLine($"Wrote {bytesWritten}");
|
||||||
|
|
||||||
|
|
@ -144,11 +158,12 @@ namespace Dalamud.Injector {
|
||||||
loadLibA,
|
loadLibA,
|
||||||
dllMem,
|
dllMem,
|
||||||
0,
|
0,
|
||||||
IntPtr.Zero
|
IntPtr.Zero);
|
||||||
);
|
|
||||||
|
|
||||||
if (remoteThread == IntPtr.Zero)
|
if (remoteThread == IntPtr.Zero)
|
||||||
|
{
|
||||||
throw new Win32Exception(Marshal.GetLastWin32Error(), $"Could not CreateRemoteThread");
|
throw new Win32Exception(Marshal.GetLastWin32Error(), $"Could not CreateRemoteThread");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO kill myself
|
TODO kill myself
|
||||||
|
|
@ -163,9 +178,11 @@ namespace Dalamud.Injector {
|
||||||
NativeFunctions.CloseHandle(handle);
|
NativeFunctions.CloseHandle(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DalamudStartInfo GetDefaultStartInfo() {
|
private static DalamudStartInfo GetDefaultStartInfo()
|
||||||
|
{
|
||||||
var ffxivDir = Path.GetDirectoryName(process.MainModule.FileName);
|
var ffxivDir = Path.GetDirectoryName(process.MainModule.FileName);
|
||||||
var startInfo = new DalamudStartInfo {
|
var startInfo = new DalamudStartInfo
|
||||||
|
{
|
||||||
WorkingDirectory = null,
|
WorkingDirectory = null,
|
||||||
ConfigurationPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "dalamudConfig.json"),
|
ConfigurationPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "dalamudConfig.json"),
|
||||||
PluginDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "installedPlugins"),
|
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"),
|
AssetDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "dalamudAssets"),
|
||||||
|
|
||||||
GameVersion = File.ReadAllText(Path.Combine(ffxivDir, "ffxivgame.ver")),
|
GameVersion = File.ReadAllText(Path.Combine(ffxivDir, "ffxivgame.ver")),
|
||||||
Language = ClientLanguage.English
|
Language = ClientLanguage.English,
|
||||||
};
|
};
|
||||||
|
|
||||||
Console.WriteLine("Creating a StartInfo with:\n" +
|
Console.WriteLine("Creating a StartInfo with:\n" +
|
||||||
|
|
|
||||||
13
Dalamud.Injector/stylecop.json
Normal file
13
Dalamud.Injector/stylecop.json
Normal file
|
|
@ -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" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup Label="Target">
|
<PropertyGroup Label="Target">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>net472</TargetFramework>
|
||||||
<LangVersion>8.0</LangVersion>
|
<LangVersion>9.0</LangVersion>
|
||||||
<Platforms>AnyCPU;x64</Platforms>
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Label="Build">
|
<PropertyGroup Label="Build">
|
||||||
|
|
|
||||||
|
|
@ -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<T>() {
|
|
||||||
return Marshal.PtrToStructure<T>(Address.JobGaugeData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
35
Dalamud/Game/ClientState/JobGauges.cs
Normal file
35
Dalamud/Game/ClientState/JobGauges.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
|
namespace Dalamud.Game.ClientState
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class converts in-memory Job gauge data to structs.
|
||||||
|
/// </summary>
|
||||||
|
public class JobGauges
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="JobGauges"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="addressResolver">Address resolver with the JobGauge memory location(s).</param>
|
||||||
|
public JobGauges(ClientStateAddressResolver addressResolver)
|
||||||
|
{
|
||||||
|
this.Address = addressResolver;
|
||||||
|
|
||||||
|
Log.Verbose("JobGaugeData address {JobGaugeData}", this.Address.JobGaugeData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClientStateAddressResolver Address { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the JobGauge for a given job.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">A JobGauge struct from ClientState.Structs.JobGauge.</typeparam>
|
||||||
|
/// <returns>A JobGauge.</returns>
|
||||||
|
public T Get<T>()
|
||||||
|
{
|
||||||
|
return Marshal.PtrToStructure<T>(this.Address.JobGaugeData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,25 +1,35 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge {
|
|
||||||
|
|
||||||
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory AST job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct ASTGauge {
|
public struct ASTGauge
|
||||||
[FieldOffset(4)] private CardType Card;
|
{
|
||||||
[FieldOffset(5)] private unsafe fixed byte Seals[3];
|
[FieldOffset(4)]
|
||||||
|
private CardType card;
|
||||||
|
|
||||||
public CardType DrawnCard() {
|
[FieldOffset(5)]
|
||||||
return Card;
|
private unsafe fixed byte seals[3];
|
||||||
}
|
|
||||||
|
|
||||||
public unsafe bool ContainsSeal(SealType seal) {
|
/// <summary>
|
||||||
if (Seals[0] == (byte)seal) return true;
|
/// Gets the currently drawn <see cref="CardType"/>.
|
||||||
if (Seals[1] == (byte)seal) return true;
|
/// </summary>
|
||||||
if (Seals[2] == (byte)seal) return true;
|
/// <returns>Currently drawn <see cref="CardType"/>.</returns>
|
||||||
|
public CardType DrawnCard() => this.card;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if a <see cref="SealType"/> is currently active on the divination gauge.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="seal">The <see cref="SealType"/> to check for.</param>
|
||||||
|
/// <returns>If the given Seal is currently divined.</returns>
|
||||||
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,59 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge {
|
|
||||||
|
|
||||||
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory BLM job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct BLMGauge {
|
public struct BLMGauge
|
||||||
[FieldOffset(0)] public short TimeUntilNextPolyglot; //eno timer (ms)
|
{
|
||||||
[FieldOffset(2)] public short ElementTimeRemaining; //ui/af timer
|
/// <summary>
|
||||||
[FieldOffset(4)] private byte ElementStance; //ui/af
|
/// Gets the time until the next Polyglot stack in milliseconds.
|
||||||
[FieldOffset(5)] public byte NumUmbralHearts; //number of umbral hearts
|
/// </summary>
|
||||||
[FieldOffset(6)] public byte NumPolyglotStacks; //number of polyglot stacks
|
[FieldOffset(0)]
|
||||||
[FieldOffset(7)] private byte EnoState; //eno active?
|
public short TimeUntilNextPolyglot; // enochian timer
|
||||||
|
|
||||||
public bool InUmbralIce() {
|
/// <summary>
|
||||||
return ElementStance > 4;
|
/// Gets the time remaining for Astral Fire or Umbral Ice in milliseconds.
|
||||||
}
|
/// </summary>
|
||||||
|
[FieldOffset(2)]
|
||||||
|
public short ElementTimeRemaining; // umbral ice and astral fire timer
|
||||||
|
|
||||||
public bool InAstralFire() {
|
[FieldOffset(4)]
|
||||||
return ElementStance > 0 && ElementStance < 4;
|
private byte elementStance; // umbral ice or astral fire
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsEnoActive() {
|
/// <summary>
|
||||||
return EnoState > 0;
|
/// Gets the number of Umbral Hearts remaining.
|
||||||
}
|
/// </summary>
|
||||||
|
[FieldOffset(5)]
|
||||||
|
public byte NumUmbralHearts;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the number of Polyglot stacks remaining.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(6)]
|
||||||
|
public byte NumPolyglotStacks;
|
||||||
|
|
||||||
|
[FieldOffset(7)]
|
||||||
|
private byte enochianState;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if the player is in Umbral Ice.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
|
public bool InUmbralIce() => this.elementStance > 4;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if the player is in Astral fire.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
|
public bool InAstralFire() => this.elementStance > 0 && this.elementStance < 4;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if Enochian is active.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
|
public bool IsEnoActive() => this.enochianState > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,35 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge {
|
|
||||||
|
|
||||||
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory BRD job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct BRDGauge {
|
public struct BRDGauge
|
||||||
[FieldOffset(0)] public short SongTimer;
|
{
|
||||||
[FieldOffset(2)] public byte NumSongStacks;
|
/// <summary>
|
||||||
[FieldOffset(3)] public byte SoulVoiceValue;
|
/// Gets the current song timer in milliseconds.
|
||||||
[FieldOffset(4)] public CurrentSong ActiveSong;
|
/// </summary>
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public short SongTimer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the number of stacks for the current song.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(2)]
|
||||||
|
public byte NumSongStacks;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the amount of Soul Voice accumulated.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(3)]
|
||||||
|
public byte SoulVoiceValue;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the type of song that is active.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public CurrentSong ActiveSong;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,43 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge {
|
|
||||||
|
|
||||||
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory DNC job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public unsafe struct DNCGauge {
|
public unsafe struct DNCGauge
|
||||||
[FieldOffset(0)] public byte NumFeathers;
|
{
|
||||||
[FieldOffset(1)] public byte Esprit;
|
/// <summary>
|
||||||
[FieldOffset(2)] private fixed byte StepOrder[4];
|
/// Gets the number of feathers available.
|
||||||
[FieldOffset(6)] public byte NumCompleteSteps;
|
/// </summary>
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public byte NumFeathers;
|
||||||
|
|
||||||
public bool IsDancing() {
|
/// <summary>
|
||||||
return StepOrder[0] != 0;
|
/// Gets the amount of Espirit available.
|
||||||
}
|
/// </summary>
|
||||||
|
[FieldOffset(1)]
|
||||||
|
public byte Esprit;
|
||||||
|
|
||||||
public ulong NextStep() {
|
[FieldOffset(2)]
|
||||||
return (ulong)(15999 + StepOrder[NumCompleteSteps] - 1);
|
private fixed byte stepOrder[4];
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the number of steps completed for the current dance.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(6)]
|
||||||
|
public byte NumCompleteSteps;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the next step in the current dance.
|
||||||
|
/// </summary>
|
||||||
|
public ulong NextStep => (ulong)(15999 + this.stepOrder[this.NumCompleteSteps] - 1);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if the player is dancing or not.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
|
public bool IsDancing() => this.stepOrder[0] != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,29 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge {
|
|
||||||
|
|
||||||
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory DRG job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct DRGGauge {
|
public struct DRGGauge
|
||||||
[FieldOffset(0)] public short BOTDTimer;
|
{
|
||||||
[FieldOffset(2)] public BOTDState BOTDState;
|
/// <summary>
|
||||||
[FieldOffset(3)] public byte EyeCount;
|
/// Gets the time remaining for Blood of the Dragon in milliseconds.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public short BOTDTimer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current state of Blood of the Dragon.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(2)]
|
||||||
|
public BOTDState BOTDState;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the count of eyes opened during Blood of the Dragon.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(3)]
|
||||||
|
public byte EyeCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,38 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge {
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory DRK job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct DRKGauge {
|
public struct DRKGauge
|
||||||
[FieldOffset(0)] public byte Blood;
|
{
|
||||||
[FieldOffset(2)] public ushort DarksideTimeRemaining;
|
/// <summary>
|
||||||
[FieldOffset(4)] private byte DarkArtsState;
|
/// Gets the amount of blood accumulated.
|
||||||
[FieldOffset(6)] public ushort ShadowTimeRemaining;
|
/// </summary>
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public byte Blood;
|
||||||
|
|
||||||
public bool HasDarkArts() {
|
/// <summary>
|
||||||
return DarkArtsState > 0;
|
/// Gets the Darkside time remaining in milliseconds.
|
||||||
}
|
/// </summary>
|
||||||
|
[FieldOffset(2)]
|
||||||
|
public ushort DarksideTimeRemaining;
|
||||||
|
|
||||||
|
[FieldOffset(4)]
|
||||||
|
private byte darkArtsState;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the Shadow time remaining in milliseconds.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(6)]
|
||||||
|
public ushort ShadowTimeRemaining;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if the player has Dark Arts or not.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
|
public bool HasDarkArts() => this.darkArtsState > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,29 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge {
|
|
||||||
|
|
||||||
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory GNB job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct GNBGauge {
|
public struct GNBGauge
|
||||||
[FieldOffset(0)] public byte NumAmmo;
|
{
|
||||||
[FieldOffset(2)] public short MaxTimerDuration;
|
/// <summary>
|
||||||
[FieldOffset(4)] public byte AmmoComboStepNumber;
|
/// Gets the amount of ammo available.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public byte NumAmmo;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the max combo time of the Gnashing Fang combo.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(2)]
|
||||||
|
public short MaxTimerDuration;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current step of the Gnashing Fang combo.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public byte AmmoComboStepNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,67 +1,272 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge {
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
public enum SealType : byte {
|
{
|
||||||
|
#region AST
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// AST Divination seal types.
|
||||||
|
/// </summary>
|
||||||
|
public enum SealType : byte
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// No seal.
|
||||||
|
/// </summary>
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
SUN,
|
|
||||||
MOON,
|
/// <summary>
|
||||||
CELESTIAL
|
/// Sun seal.
|
||||||
|
/// </summary>
|
||||||
|
SUN = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Moon seal.
|
||||||
|
/// </summary>
|
||||||
|
MOON = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Celestial seal.
|
||||||
|
/// </summary>
|
||||||
|
CELESTIAL = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum CardType : byte {
|
/// <summary>
|
||||||
|
/// AST Arcanum (card) types.
|
||||||
|
/// </summary>
|
||||||
|
public enum CardType : byte
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// No card.
|
||||||
|
/// </summary>
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
BALANCE,
|
|
||||||
BOLE,
|
/// <summary>
|
||||||
ARROW,
|
/// The Balance card.
|
||||||
SPEAR,
|
/// </summary>
|
||||||
EWER,
|
BALANCE = 1,
|
||||||
SPIRE,
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Bole card.
|
||||||
|
/// </summary>
|
||||||
|
BOLE = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Arrow card.
|
||||||
|
/// </summary>
|
||||||
|
ARROW = 3,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Spear card.
|
||||||
|
/// </summary>
|
||||||
|
SPEAR = 4,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Ewer card.
|
||||||
|
/// </summary>
|
||||||
|
EWER = 5,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Spire card.
|
||||||
|
/// </summary>
|
||||||
|
SPIRE = 6,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Lord of Crowns card.
|
||||||
|
/// </summary>
|
||||||
LORD = 0x70,
|
LORD = 0x70,
|
||||||
LADY = 0x80
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Lady of Crowns card.
|
||||||
|
/// </summary>
|
||||||
|
LADY = 0x80,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SummonPet : byte {
|
#endregion
|
||||||
|
|
||||||
|
#region BRD
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// BRD Current Song types.
|
||||||
|
/// </summary>
|
||||||
|
public enum CurrentSong : byte
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// No song is active type.
|
||||||
|
/// </summary>
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
IFRIT = 3,
|
|
||||||
TITAN,
|
|
||||||
GARUDA
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum PetGlam : byte {
|
/// <summary>
|
||||||
NONE = 0,
|
/// Mage's Ballad type.
|
||||||
EMERALD,
|
/// </summary>
|
||||||
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 = 5,
|
MAGE = 5,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Army's Paeon type.
|
||||||
|
/// </summary>
|
||||||
ARMY = 0xA,
|
ARMY = 0xA,
|
||||||
WANDERER = 0xF
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Wanderer's Minuet type.
|
||||||
|
/// </summary>
|
||||||
|
WANDERER = 0xF,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DismissedFairy : byte {
|
#endregion
|
||||||
EOS = 6,
|
|
||||||
SELENE
|
#region DRG
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DRG Blood of the Dragon state types.
|
||||||
|
/// </summary>
|
||||||
|
public enum BOTDState : byte
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Inactive type.
|
||||||
|
/// </summary>
|
||||||
|
NONE = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Blood of the Dragon is active.
|
||||||
|
/// </summary>
|
||||||
|
BOTD = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Life of the Dragon is active.
|
||||||
|
/// </summary>
|
||||||
|
LOTD = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Mudras : byte {
|
#endregion
|
||||||
|
|
||||||
|
#region NIN
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// NIN Mudra types.
|
||||||
|
/// </summary>
|
||||||
|
public enum Mudras : byte
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Ten mudra.
|
||||||
|
/// </summary>
|
||||||
TEN = 1,
|
TEN = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Chi mudra.
|
||||||
|
/// </summary>
|
||||||
CHI = 2,
|
CHI = 2,
|
||||||
JIN = 3
|
|
||||||
|
/// <summary>
|
||||||
|
/// Jin mudra.
|
||||||
|
/// </summary>
|
||||||
|
JIN = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SAM
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Samurai Sen types.
|
||||||
|
/// </summary>
|
||||||
|
[Flags]
|
||||||
|
public enum Sen : byte
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// No Sen.
|
||||||
|
/// </summary>
|
||||||
|
NONE = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Setsu Sen type.
|
||||||
|
/// </summary>
|
||||||
|
SETSU = 1 << 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Getsu Sen type.
|
||||||
|
/// </summary>
|
||||||
|
GETSU = 1 << 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ka Sen type.
|
||||||
|
/// </summary>
|
||||||
|
KA = 1 << 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SCH
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SCH Dismissed fairy types.
|
||||||
|
/// </summary>
|
||||||
|
public enum DismissedFairy : byte
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Dismissed fairy is Eos.
|
||||||
|
/// </summary>
|
||||||
|
EOS = 6,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Dismissed fairy is Selene.
|
||||||
|
/// </summary>
|
||||||
|
SELENE = 7,
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SMN
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SMN summoned pet types.
|
||||||
|
/// </summary>
|
||||||
|
public enum SummonPet : byte
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// No pet.
|
||||||
|
/// </summary>
|
||||||
|
NONE = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The summoned pet Ifrit.
|
||||||
|
/// </summary>
|
||||||
|
IFRIT = 3,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The summoned pet Titan.
|
||||||
|
/// </summary>
|
||||||
|
TITAN = 4,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The summoned pet Garuda.
|
||||||
|
/// </summary>
|
||||||
|
GARUDA = 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SMN summoned pet glam types.
|
||||||
|
/// </summary>
|
||||||
|
public enum PetGlam : byte
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// No pet glam.
|
||||||
|
/// </summary>
|
||||||
|
NONE = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Emerald carbuncle pet glam.
|
||||||
|
/// </summary>
|
||||||
|
EMERALD = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Topaz carbuncle pet glam.
|
||||||
|
/// </summary>
|
||||||
|
TOPAZ = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ruby carbuncle pet glam.
|
||||||
|
/// </summary>
|
||||||
|
RUBY = 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,56 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge {
|
|
||||||
|
|
||||||
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory MCH job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct MCHGauge{
|
public struct MCHGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the time time remaining for Overheat in milliseconds.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public short OverheatTimeRemaining;
|
||||||
|
|
||||||
[FieldOffset(0)] public short OverheatTimeRemaining;
|
/// <summary>
|
||||||
[FieldOffset(2)] public short RobotTimeRemaining;
|
/// Gets the time remaining for the Rook or Queen in milliseconds.
|
||||||
[FieldOffset(4)] public byte Heat;
|
/// </summary>
|
||||||
[FieldOffset(5)] public byte Battery;
|
[FieldOffset(2)]
|
||||||
[FieldOffset(6)] public byte LastRobotBatteryPower;
|
public short RobotTimeRemaining;
|
||||||
[FieldOffset(7)] private byte TimerActive;
|
|
||||||
|
|
||||||
public bool IsOverheated() {
|
/// <summary>
|
||||||
return (TimerActive & 1) != 0;
|
/// Gets the current Heat level.
|
||||||
}
|
/// </summary>
|
||||||
public bool IsRobotActive() {
|
[FieldOffset(4)]
|
||||||
return (TimerActive & 2) != 0;
|
public byte Heat;
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current Battery level.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(5)]
|
||||||
|
public byte Battery;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the battery level of the last Robot.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(6)]
|
||||||
|
public byte LastRobotBatteryPower;
|
||||||
|
|
||||||
|
[FieldOffset(7)]
|
||||||
|
private byte timerActive;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if the player is currently Overheated.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
|
public bool IsOverheated() => (this.timerActive & 1) != 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if the player has an active Robot.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
|
public bool IsRobotActive() => (this.timerActive & 2) != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,20 +3,40 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory MNK job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct MNKGauge
|
public struct MNKGauge
|
||||||
{
|
{
|
||||||
[FieldOffset(0)] public byte NumChakra;
|
/// <summary>
|
||||||
|
/// Gets the number of Chakra available.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public byte NumChakra;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the Greased Lightning timer in milliseconds.
|
||||||
|
/// </summary>
|
||||||
|
[Obsolete("GL has been removed from the game")]
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public byte GLTimer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the amount of Greased Lightning stacks.
|
||||||
|
/// </summary>
|
||||||
|
[Obsolete("GL has been removed from the game")]
|
||||||
|
[FieldOffset(2)]
|
||||||
|
public byte NumGLStacks;
|
||||||
|
|
||||||
[Obsolete("GL has been removed from the game")]
|
[Obsolete("GL has been removed from the game")]
|
||||||
[FieldOffset(0)] public byte GLTimer;
|
[FieldOffset(4)]
|
||||||
|
private byte glTimerFreezeState;
|
||||||
[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;
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if the Greased Lightning timer has been frozen.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>><c>true</c> or <c>false</c>.</returns>
|
||||||
[Obsolete("GL has been removed from the game")]
|
[Obsolete("GL has been removed from the game")]
|
||||||
public bool IsGLTimerFroze() => false;
|
public bool IsGLTimerFroze() => false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,36 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory NIN job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct NINGauge
|
public struct NINGauge
|
||||||
{
|
{
|
||||||
[FieldOffset(0)] public int HutonTimeLeft;
|
/// <summary>
|
||||||
[FieldOffset(4)] public byte Ninki;
|
/// Gets the time left on Huton in milliseconds.
|
||||||
|
/// </summary>
|
||||||
|
// TODO: Probably a short, confirm.
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public int HutonTimeLeft;
|
||||||
|
|
||||||
[Obsolete("Does not appear to be used")]
|
/// <summary>
|
||||||
[FieldOffset(4)] public byte TCJMudrasUsed;
|
/// Gets the amount of Ninki available.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public byte Ninki;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Obsolete.
|
||||||
|
/// </summary>
|
||||||
[Obsolete("Does not appear to be used")]
|
[Obsolete("Does not appear to be used")]
|
||||||
[FieldOffset(6)] public byte NumHutonManualCasts;
|
[FieldOffset(4)]
|
||||||
|
public byte TCJMudrasUsed;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the number of times Huton has been cast manually.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(5)]
|
||||||
|
public byte NumHutonManualCasts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,17 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge {
|
|
||||||
|
|
||||||
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory PLD job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct PLDGauge {
|
public struct PLDGauge
|
||||||
[FieldOffset(0)] public byte GaugeAmount;
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current level of the Oath gauge.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public byte GaugeAmount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,23 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge {
|
|
||||||
|
|
||||||
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory RDM job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct RDMGauge {
|
public struct RDMGauge
|
||||||
[FieldOffset(0)] public byte WhiteGauge;
|
{
|
||||||
[FieldOffset(1)] public byte BlackGauge;
|
/// <summary>
|
||||||
|
/// Gets the level of the White gauge.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public byte WhiteGauge;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the level of the Black gauge.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(1)]
|
||||||
|
public byte BlackGauge;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,47 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge {
|
|
||||||
|
|
||||||
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory SAM job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct SAMGauge {
|
public struct SAMGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current amount of Kenki available.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(3)]
|
||||||
|
public byte Kenki;
|
||||||
|
|
||||||
[FieldOffset(3)] public byte Kenki;
|
/// <summary>
|
||||||
[FieldOffset(4)] public byte MeditationStacks;
|
/// Gets the amount of Meditation stacks.
|
||||||
[FieldOffset(5)] public Sen Sen;
|
/// </summary>
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public byte MeditationStacks;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the active Sen.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(5)]
|
||||||
|
public Sen Sen;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if the Setsu Sen is active.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
|
public bool HasSetsu() => (this.Sen & Sen.SETSU) != 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if the Getsu Sen is active.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
|
public bool HasGetsu() => (this.Sen & Sen.GETSU) != 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if the Ka Sen is active.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
|
public bool HasKa() => (this.Sen & Sen.KA) != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,35 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge {
|
|
||||||
|
|
||||||
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory SCH job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct SCHGauge {
|
public struct SCHGauge
|
||||||
[FieldOffset(2)] public byte NumAetherflowStacks;
|
{
|
||||||
[FieldOffset(3)] public byte FairyGaugeAmount;
|
/// <summary>
|
||||||
[FieldOffset(4)] public short SeraphTimer;
|
/// Gets the amount of Aetherflow stacks available.
|
||||||
[FieldOffset(6)] public DismissedFairy DismissedFairy;
|
/// </summary>
|
||||||
|
[FieldOffset(2)]
|
||||||
|
public byte NumAetherflowStacks;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current level of the Fairy Gauge.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(3)]
|
||||||
|
public byte FairyGaugeAmount;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the Seraph time remaining in milliseconds.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public short SeraphTimer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the last dismissed fairy.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(6)]
|
||||||
|
public DismissedFairy DismissedFairy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,54 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge {
|
|
||||||
|
|
||||||
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory SMN job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct SMNGauge {
|
public struct SMNGauge
|
||||||
|
{
|
||||||
//Unfinished
|
/// <summary>
|
||||||
[FieldOffset(0)] public short TimerRemaining;
|
/// Gets the time remaining for the current summon.
|
||||||
[FieldOffset(2)] public SummonPet ReturnSummon;
|
/// </summary>
|
||||||
[FieldOffset(3)] public PetGlam ReturnSummonGlam;
|
[FieldOffset(0)]
|
||||||
[FieldOffset(4)] public byte NumStacks;
|
public short TimerRemaining;
|
||||||
|
|
||||||
public bool IsPhoenixReady() {
|
/// <summary>
|
||||||
return (NumStacks & 0x10) > 0;
|
/// Gets the summon that will return after the current summon expires.
|
||||||
}
|
/// </summary>
|
||||||
|
[FieldOffset(2)]
|
||||||
|
public SummonPet ReturnSummon;
|
||||||
|
|
||||||
public bool IsBahamutReady() {
|
/// <summary>
|
||||||
return (NumStacks & 8) > 0;
|
/// Gets the summon glam for the <see cref="ReturnSummon"/>.
|
||||||
}
|
/// </summary>
|
||||||
|
[FieldOffset(3)]
|
||||||
|
public PetGlam ReturnSummonGlam;
|
||||||
|
|
||||||
public bool HasAetherflowStacks() {
|
/// <summary>
|
||||||
return (NumStacks & 3) > 0;
|
/// Gets the current stacks.
|
||||||
}
|
/// Use the summon accessors instead.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public byte NumStacks;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if Phoenix is ready to be summoned.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
|
public bool IsPhoenixReady() => (this.NumStacks & 0x10) > 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if Bahamut is ready to be summoned.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
|
public bool IsBahamutReady() => (this.NumStacks & 8) > 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if there are any Aetherflow stacks available.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
|
public bool HasAetherflowStacks() => (this.NumStacks & 3) > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,17 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge {
|
|
||||||
|
|
||||||
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory WAR job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct WARGauge {
|
public struct WARGauge
|
||||||
[FieldOffset(0)] public byte BeastGaugeAmount;
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the amount of wrath in the Beast gauge.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public byte BeastGaugeAmount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,29 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs.JobGauge {
|
|
||||||
|
|
||||||
|
namespace Dalamud.Game.ClientState.Structs.JobGauge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// In-memory WHM job gauge.
|
||||||
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
public struct WHMGauge {
|
public struct WHMGauge
|
||||||
[FieldOffset(2)] public short LilyTimer; //Counts to 30k = 30s
|
{
|
||||||
[FieldOffset(4)] public byte NumLilies;
|
/// <summary>
|
||||||
[FieldOffset(5)] public byte NumBloodLily;
|
/// Gets the time to next lily in milliseconds.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(2)]
|
||||||
|
public short LilyTimer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the number of Lilies.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public byte NumLilies;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the number of times the blood lily has been nourished.
|
||||||
|
/// </summary>
|
||||||
|
[FieldOffset(5)]
|
||||||
|
public byte NumBloodLily;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,41 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Dalamud.Configuration;
|
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
using Microsoft.CodeAnalysis;
|
|
||||||
using Microsoft.CodeAnalysis.CSharp;
|
|
||||||
using Microsoft.CodeAnalysis.CSharp.Scripting;
|
using Microsoft.CodeAnalysis.CSharp.Scripting;
|
||||||
using Microsoft.CodeAnalysis.Scripting;
|
using Microsoft.CodeAnalysis.Scripting;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Interface.Scratchpad
|
namespace Dalamud.Interface.Scratchpad
|
||||||
{
|
{
|
||||||
class ScratchExecutionManager
|
/// <summary>
|
||||||
|
/// This class manages the execution of <see cref="ScratchpadDocument"/> classes.
|
||||||
|
/// </summary>
|
||||||
|
internal class ScratchExecutionManager
|
||||||
{
|
{
|
||||||
private readonly Dalamud dalamud;
|
private readonly Dalamud dalamud;
|
||||||
private Dictionary<Guid, IDalamudPlugin> loadedScratches = new Dictionary<Guid, IDalamudPlugin>();
|
private Dictionary<Guid, IDalamudPlugin> loadedScratches = new();
|
||||||
|
|
||||||
public ScratchMacroProcessor MacroProcessor { get; private set; } = new ScratchMacroProcessor();
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ScratchExecutionManager"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dalamud">The Dalamud instance.</param>
|
||||||
public ScratchExecutionManager(Dalamud dalamud)
|
public ScratchExecutionManager(Dalamud dalamud)
|
||||||
{
|
{
|
||||||
this.dalamud = dalamud;
|
this.dalamud = dalamud;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the ScratchPad macro processor.
|
||||||
|
/// </summary>
|
||||||
|
public ScratchMacroProcessor MacroProcessor { get; private set; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Dispose of all currently loaded ScratchPads.
|
||||||
|
/// </summary>
|
||||||
public void DisposeAllScratches()
|
public void DisposeAllScratches()
|
||||||
{
|
{
|
||||||
foreach (var dalamudPlugin in this.loadedScratches)
|
foreach (var dalamudPlugin in this.loadedScratches)
|
||||||
|
|
@ -37,6 +46,11 @@ namespace Dalamud.Interface.Scratchpad
|
||||||
this.loadedScratches.Clear();
|
this.loadedScratches.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Renew a given ScratchPadDocument.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="doc">The document to renew.</param>
|
||||||
|
/// <returns>The new load status.</returns>
|
||||||
public ScratchLoadStatus RenewScratch(ScratchpadDocument doc)
|
public ScratchLoadStatus RenewScratch(ScratchpadDocument doc)
|
||||||
{
|
{
|
||||||
var existingScratch = this.loadedScratches.FirstOrDefault(x => x.Key == doc.Id);
|
var existingScratch = this.loadedScratches.FirstOrDefault(x => x.Key == doc.Id);
|
||||||
|
|
@ -51,11 +65,10 @@ namespace Dalamud.Interface.Scratchpad
|
||||||
var options = ScriptOptions.Default
|
var options = ScriptOptions.Default
|
||||||
.AddReferences(typeof(ImGui).Assembly)
|
.AddReferences(typeof(ImGui).Assembly)
|
||||||
.AddReferences(typeof(Dalamud).Assembly)
|
.AddReferences(typeof(Dalamud).Assembly)
|
||||||
.AddReferences(typeof(FFXIVClientStructs.Attributes.Addon)
|
.AddReferences(typeof(FFXIVClientStructs.Attributes.Addon).Assembly) // FFXIVClientStructs
|
||||||
.Assembly) // FFXIVClientStructs
|
|
||||||
.AddReferences(typeof(Lumina.GameData).Assembly) // Lumina
|
.AddReferences(typeof(Lumina.GameData).Assembly) // Lumina
|
||||||
.AddReferences(typeof(TerritoryType).Assembly) // Lumina.Excel
|
.AddReferences(typeof(TerritoryType).Assembly) // Lumina.Excel
|
||||||
//.WithReferences(MetadataReference.CreateFromFile(typeof(ScratchExecutionManager).Assembly.Location))
|
// .WithReferences(MetadataReference.CreateFromFile(typeof(ScratchExecutionManager).Assembly.Location))
|
||||||
.AddImports("System")
|
.AddImports("System")
|
||||||
.AddImports("System.IO")
|
.AddImports("System.IO")
|
||||||
.AddImports("System.Reflection")
|
.AddImports("System.Reflection")
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,27 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Interface.Scratchpad
|
namespace Dalamud.Interface.Scratchpad
|
||||||
{
|
{
|
||||||
class ScratchFileWatcher
|
/// <summary>
|
||||||
|
/// A file watcher for <see cref="ScratchpadDocument"/> classes.
|
||||||
|
/// </summary>
|
||||||
|
internal class ScratchFileWatcher
|
||||||
{
|
{
|
||||||
|
private FileSystemWatcher watcher = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the list of tracked ScratchPad documents.
|
||||||
|
/// </summary>
|
||||||
public List<ScratchpadDocument> TrackedScratches { get; set; } = new List<ScratchpadDocument>();
|
public List<ScratchpadDocument> TrackedScratches { get; set; } = new List<ScratchpadDocument>();
|
||||||
|
|
||||||
private FileSystemWatcher watcher = new FileSystemWatcher();
|
/// <summary>
|
||||||
|
/// Load a new ScratchPadDocument from disk.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The filepath to load.</param>
|
||||||
public void Load(string path)
|
public void Load(string path)
|
||||||
{
|
{
|
||||||
TrackedScratches.Add(new ScratchpadDocument
|
this.TrackedScratches.Add(new ScratchpadDocument
|
||||||
{
|
{
|
||||||
Title = Path.GetFileName(path),
|
Title = Path.GetFileName(path),
|
||||||
Content = File.ReadAllText(path),
|
Content = File.ReadAllText(path),
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,28 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Interface.Scratchpad
|
namespace Dalamud.Interface.Scratchpad
|
||||||
{
|
{
|
||||||
enum ScratchLoadStatus
|
/// <summary>
|
||||||
|
/// The load status of a <see cref="ScratchpadDocument"/> class.
|
||||||
|
/// </summary>
|
||||||
|
internal enum ScratchLoadStatus
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Unknown.
|
||||||
|
/// </summary>
|
||||||
Unknown,
|
Unknown,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Failure to compile.
|
||||||
|
/// </summary>
|
||||||
FailureCompile,
|
FailureCompile,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Failure to initialize.
|
||||||
|
/// </summary>
|
||||||
FailureInit,
|
FailureInit,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Success.
|
||||||
|
/// </summary>
|
||||||
Success,
|
Success,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,18 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
|
|
||||||
namespace Dalamud.Interface.Scratchpad
|
namespace Dalamud.Interface.Scratchpad
|
||||||
{
|
{
|
||||||
class ScratchMacroProcessor
|
/// <summary>
|
||||||
|
/// This class converts ScratchPad macros into runnable scripts.
|
||||||
|
/// </summary>
|
||||||
|
internal class ScratchMacroProcessor
|
||||||
{
|
{
|
||||||
private const string template = @"
|
private const string Template = @"
|
||||||
|
|
||||||
public class ScratchPlugin : IDalamudPlugin {
|
public class ScratchPlugin : IDalamudPlugin {
|
||||||
|
|
||||||
|
|
@ -53,22 +54,14 @@ public class ScratchPlugin : IDalamudPlugin {
|
||||||
Dispose,
|
Dispose,
|
||||||
}
|
}
|
||||||
|
|
||||||
private class HookInfo
|
/// <summary>
|
||||||
{
|
/// Process the given macro input and return a script.
|
||||||
public string Body { get; set; }
|
/// </summary>
|
||||||
|
/// <param name="input">Input to process.</param>
|
||||||
public string Arguments { get; set; }
|
/// <returns>A runnable script.</returns>
|
||||||
|
|
||||||
public string Invocation { get; set; }
|
|
||||||
|
|
||||||
public string RetType { get; set; }
|
|
||||||
|
|
||||||
public string Sig { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Process(string input)
|
public string Process(string input)
|
||||||
{
|
{
|
||||||
var lines = input.Split(new[] {'\r', '\n'});
|
var lines = input.Split(new[] { '\r', '\n' });
|
||||||
|
|
||||||
var ctx = ParseContext.None;
|
var ctx = ParseContext.None;
|
||||||
|
|
||||||
|
|
@ -181,10 +174,8 @@ public class ScratchPlugin : IDalamudPlugin {
|
||||||
$"private Hook<Hook{i}Delegate> hook{i}Inst;\n";
|
$"private Hook<Hook{i}Delegate> hook{i}Inst;\n";
|
||||||
|
|
||||||
hookInit += $"var addrH{i} = pi.TargetModuleScanner.ScanText(\"{hook.Sig}\");\n";
|
hookInit += $"var addrH{i} = pi.TargetModuleScanner.ScanText(\"{hook.Sig}\");\n";
|
||||||
hookInit +=
|
hookInit += $"this.hook{i}Inst = new Hook<Hook{i}Delegate>(addrH{i}, new Hook{i}Delegate(Hook{i}Detour), this);\n";
|
||||||
$"this.hook{i}Inst = new Hook<Hook{i}Delegate>(addrH{i}, new Hook{i}Delegate(Hook{i}Detour), this);\n";
|
hookInit += $"this.hook{i}Inst.Enable();\n";
|
||||||
hookInit +=
|
|
||||||
$"this.hook{i}Inst.Enable();\n";
|
|
||||||
|
|
||||||
var originalCall = $"this.hook{i}Inst.Original({hook.Invocation});\n";
|
var originalCall = $"this.hook{i}Inst.Original({hook.Invocation});\n";
|
||||||
if (hook.RetType != "void")
|
if (hook.RetType != "void")
|
||||||
|
|
@ -225,7 +216,7 @@ public class ScratchPlugin : IDalamudPlugin {
|
||||||
noneBody += "\n" + hookDetour;
|
noneBody += "\n" + hookDetour;
|
||||||
disposeBody += "\n" + hookDispose;
|
disposeBody += "\n" + hookDispose;
|
||||||
|
|
||||||
var output = template;
|
var output = Template;
|
||||||
output = output.Replace("{SETUPBODY}", setupBody);
|
output = output.Replace("{SETUPBODY}", setupBody);
|
||||||
output = output.Replace("{INITBODY}", initBody);
|
output = output.Replace("{INITBODY}", initBody);
|
||||||
output = output.Replace("{DRAWBODY}", drawBody);
|
output = output.Replace("{DRAWBODY}", drawBody);
|
||||||
|
|
@ -234,5 +225,18 @@ public class ScratchPlugin : IDalamudPlugin {
|
||||||
|
|
||||||
return output;
|
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; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,45 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Interface.Scratchpad
|
namespace Dalamud.Interface.Scratchpad
|
||||||
{
|
{
|
||||||
class ScratchpadDocument
|
/// <summary>
|
||||||
|
/// This class represents a single document in the ScratchPad.
|
||||||
|
/// </summary>
|
||||||
|
internal class ScratchpadDocument
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the guid ID of the document.
|
||||||
|
/// </summary>
|
||||||
public Guid Id { get; set; } = Guid.NewGuid();
|
public Guid Id { get; set; } = Guid.NewGuid();
|
||||||
|
|
||||||
public string Content = "INITIALIZE:\n\tPluginLog.Information(\"Loaded!\");\nEND;\n\nDISPOSE:\n\tPluginLog.Information(\"Disposed!\");\nEND;\n";
|
/// <summary>
|
||||||
|
/// Gets or sets the document content.
|
||||||
|
/// </summary>
|
||||||
|
public string Content { get; set; } = "INITIALIZE:\n\tPluginLog.Information(\"Loaded!\");\nEND;\n\nDISPOSE:\n\tPluginLog.Information(\"Disposed!\");\nEND;\n";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the document title.
|
||||||
|
/// </summary>
|
||||||
public string Title { get; set; } = "New Document";
|
public string Title { get; set; } = "New Document";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the document has unsaved content.
|
||||||
|
/// </summary>
|
||||||
public bool HasUnsaved { get; set; }
|
public bool HasUnsaved { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the document is open.
|
||||||
|
/// </summary>
|
||||||
public bool IsOpen { get; set; }
|
public bool IsOpen { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the load status of the document.
|
||||||
|
/// </summary>
|
||||||
public ScratchLoadStatus Status { get; set; }
|
public ScratchLoadStatus Status { get; set; }
|
||||||
|
|
||||||
public bool IsMacro = true;
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether this document is a macro.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsMacro { get; set; } = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,31 +2,30 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using Dalamud.Interface.Colors;
|
using Dalamud.Interface.Colors;
|
||||||
using Dalamud.Interface.Windowing;
|
using Dalamud.Interface.Windowing;
|
||||||
using Dalamud.Plugin;
|
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Interface.Scratchpad
|
namespace Dalamud.Interface.Scratchpad
|
||||||
{
|
{
|
||||||
class ScratchpadWindow : Window, IDisposable
|
/// <summary>
|
||||||
|
/// This class facilitates interacting with the ScratchPad window.
|
||||||
|
/// </summary>
|
||||||
|
internal class ScratchpadWindow : Window, IDisposable
|
||||||
{
|
{
|
||||||
private readonly Dalamud dalamud;
|
private readonly Dalamud dalamud;
|
||||||
|
private List<ScratchpadDocument> documents = new();
|
||||||
public ScratchExecutionManager Execution { get; private set; }
|
private ScratchFileWatcher watcher = new();
|
||||||
|
|
||||||
private List<ScratchpadDocument> documents = new List<ScratchpadDocument>();
|
|
||||||
|
|
||||||
private ScratchFileWatcher watcher = new ScratchFileWatcher();
|
|
||||||
|
|
||||||
private string pathInput = string.Empty;
|
private string pathInput = string.Empty;
|
||||||
|
|
||||||
public ScratchpadWindow(Dalamud dalamud) :
|
/// <summary>
|
||||||
base("Plugin Scratchpad", ImGuiWindowFlags.MenuBar)
|
/// Initializes a new instance of the <see cref="ScratchpadWindow"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dalamud">The Dalamud instance.</param>
|
||||||
|
public ScratchpadWindow(Dalamud dalamud)
|
||||||
|
: base("Plugin Scratchpad", ImGuiWindowFlags.MenuBar)
|
||||||
{
|
{
|
||||||
this.dalamud = dalamud;
|
this.dalamud = dalamud;
|
||||||
this.documents.Add(new ScratchpadDocument());
|
this.documents.Add(new ScratchpadDocument());
|
||||||
|
|
@ -36,6 +35,12 @@ namespace Dalamud.Interface.Scratchpad
|
||||||
this.Execution = new ScratchExecutionManager(dalamud);
|
this.Execution = new ScratchExecutionManager(dalamud);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the ScratchPad execution manager.
|
||||||
|
/// </summary>
|
||||||
|
public ScratchExecutionManager Execution { get; private set; }
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
if (ImGui.BeginPopupModal("Choose Path"))
|
if (ImGui.BeginPopupModal("Choose Path"))
|
||||||
|
|
@ -53,7 +58,11 @@ namespace Dalamud.Interface.Scratchpad
|
||||||
|
|
||||||
ImGui.SetItemDefaultFocus();
|
ImGui.SetItemDefaultFocus();
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
if (ImGui.Button("Cancel", new Vector2(120, 0))) { ImGui.CloseCurrentPopup(); }
|
if (ImGui.Button("Cancel", new Vector2(120, 0)))
|
||||||
|
{
|
||||||
|
ImGui.CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.EndPopup();
|
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.BeginTabItem(docs[i].Title + (docs[i].HasUnsaved ? "*" : string.Empty) + "###ScratchItem" + i, ref isOpen))
|
||||||
{
|
{
|
||||||
if (ImGui.InputTextMultiline("###ScratchInput" + i, ref docs[i].Content, 20000,
|
var content = docs[i].Content;
|
||||||
new Vector2(-1, -34), ImGuiInputTextFlags.AllowTabInput))
|
if (ImGui.InputTextMultiline("###ScratchInput" + i, ref content, 20000, new Vector2(-1, -34), ImGuiInputTextFlags.AllowTabInput))
|
||||||
{
|
{
|
||||||
|
docs[i].Content = content;
|
||||||
docs[i].HasUnsaved = true;
|
docs[i].HasUnsaved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,7 +143,11 @@ namespace Dalamud.Interface.Scratchpad
|
||||||
|
|
||||||
ImGui.SameLine();
|
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();
|
ImGui.SameLine();
|
||||||
|
|
||||||
|
|
@ -167,6 +181,9 @@ namespace Dalamud.Interface.Scratchpad
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Dispose of managed and unmanaged resources.
|
||||||
|
/// </summary>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
this.Execution.DisposeAllScratches();
|
this.Execution.DisposeAllScratches();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Serilog;
|
|
||||||
|
|
||||||
namespace Dalamud.Interface.Windowing
|
namespace Dalamud.Interface.Windowing
|
||||||
{
|
{
|
||||||
|
|
@ -12,7 +11,6 @@ namespace Dalamud.Interface.Windowing
|
||||||
{
|
{
|
||||||
private bool internalLastIsOpen = false;
|
private bool internalLastIsOpen = false;
|
||||||
private bool internalIsOpen = false;
|
private bool internalIsOpen = false;
|
||||||
private bool mainIsOpen = false;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Window"/> class.
|
/// Initializes a new instance of the <see cref="Window"/> class.
|
||||||
|
|
@ -30,6 +28,9 @@ namespace Dalamud.Interface.Windowing
|
||||||
this.ForceMainWindow = forceMainWindow;
|
this.ForceMainWindow = forceMainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the namespace of the window.
|
||||||
|
/// </summary>
|
||||||
public string Namespace { get; set; }
|
public string Namespace { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -115,28 +116,35 @@ namespace Dalamud.Interface.Windowing
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Code to be executed every time the window renders.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
/// In this method, implement your drawing code.
|
/// In this method, implement your drawing code.
|
||||||
/// You do NOT need to ImGui.Begin your window.
|
/// You do NOT need to ImGui.Begin your window.
|
||||||
/// </summary>
|
/// </remarks>
|
||||||
public abstract void Draw();
|
public abstract void Draw();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Code to be executed when the window is opened.
|
/// Code to be executed when the window is opened.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void OnOpen() { }
|
public virtual void OnOpen()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Code to be executed when the window is closed.
|
/// Code to be executed when the window is closed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void OnClose() { }
|
public virtual void OnClose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Draw the window via ImGui.
|
/// Draw the window via ImGui.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal void DrawInternal()
|
internal void DrawInternal()
|
||||||
{
|
{
|
||||||
//if (WindowName.Contains("Credits"))
|
// if (WindowName.Contains("Credits"))
|
||||||
// Log.Information($"Draw: {IsOpen} {this.internalIsOpen} {this.internalLastIsOpen}");
|
// Log.Information($"Draw: {IsOpen} {this.internalIsOpen} {this.internalLastIsOpen}");
|
||||||
|
|
||||||
if (!this.IsOpen)
|
if (!this.IsOpen)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace Dalamud.Interface.Windowing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WindowSystem
|
public class WindowSystem
|
||||||
{
|
{
|
||||||
private readonly List<Window> windows = new List<Window>();
|
private readonly List<Window> windows = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="WindowSystem"/> class.
|
/// Initializes a new instance of the <see cref="WindowSystem"/> class.
|
||||||
|
|
@ -70,7 +70,7 @@ namespace Dalamud.Interface.Windowing
|
||||||
foreach (var window in this.windows)
|
foreach (var window in this.windows)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#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
|
#endif
|
||||||
|
|
||||||
window.DrawInternal();
|
window.DrawInternal();
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ namespace Dalamud
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delegate for the <see cref="Localization.OnLocalizationChanged"/> event that occurs when the language is changed.
|
/// Delegate for the <see cref="OnLocalizationChanged"/> event that occurs when the language is changed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="langCode">The language code of the new language.</param>
|
/// <param name="langCode">The language code of the new language.</param>
|
||||||
public delegate void LocalizationChangedDelegate(string langCode);
|
public delegate void LocalizationChangedDelegate(string langCode);
|
||||||
|
|
@ -51,6 +51,19 @@ namespace Dalamud
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event LocalizationChangedDelegate OnLocalizationChanged;
|
public event LocalizationChangedDelegate OnLocalizationChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">The string key to be returned.</param>
|
||||||
|
/// <param name="fallBack">The fallback string, usually your source language.</param>
|
||||||
|
/// <returns>The localized string, fallback or string key if not found.</returns>
|
||||||
|
public static string Localize(string key, string fallBack)
|
||||||
|
{
|
||||||
|
return Loc.Localize(key, fallBack, Assembly.GetCallingAssembly());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set up the UI language with the users' local UI culture.
|
/// Set up the UI language with the users' local UI culture.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -118,19 +131,6 @@ namespace Dalamud
|
||||||
Loc.ExportLocalizableForAssembly(this.assembly);
|
Loc.ExportLocalizableForAssembly(this.assembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 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.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key">The string key to be returned.</param>
|
|
||||||
/// <param name="fallBack">The fallback string, usually your source language.</param>
|
|
||||||
/// <returns>The localized string, fallback or string key if not found.</returns>
|
|
||||||
public static string Localize(string key, string fallBack)
|
|
||||||
{
|
|
||||||
return Loc.Localize(key, fallBack, Assembly.GetCallingAssembly());
|
|
||||||
}
|
|
||||||
|
|
||||||
private string ReadLocData(string langCode)
|
private string ReadLocData(string langCode)
|
||||||
{
|
{
|
||||||
if (this.useEmbedded)
|
if (this.useEmbedded)
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ namespace Dalamud.Plugin
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the directory your plugin configurations are stored in.
|
/// Gets the directory your plugin configurations are stored in.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DirectoryInfo ConfigDirectory => new DirectoryInfo(this.GetPluginConfigDirectory());
|
public DirectoryInfo ConfigDirectory => new(this.GetPluginConfigDirectory());
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the config file of your plugin.
|
/// Gets the config file of your plugin.
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Plugin
|
namespace Dalamud.Plugin
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,3 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Dalamud.Plugin
|
namespace Dalamud.Plugin
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
using Serilog;
|
|
||||||
using Serilog.Events;
|
|
||||||
|
|
||||||
namespace Dalamud.Plugin
|
namespace Dalamud.Plugin
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace Dalamud
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Attention! The performance of these methods is severely worse than regular <see cref="Marshal"/> calls.
|
/// Attention! The performance of these methods is severely worse than regular <see cref="Marshal"/> calls.
|
||||||
/// Please consider using these instead in performance-critical code.
|
/// Please consider using those instead in performance-critical code.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static class SafeMemory
|
public static class SafeMemory
|
||||||
{
|
{
|
||||||
|
|
@ -50,7 +50,7 @@ namespace Dalamud
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read an object of the specified struct from the current process.
|
/// Read an object of the specified struct from the current process.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The type of the struct.</typeparam>
|
/// <typeparam name="T">The type of the struct.</typeparam>
|
||||||
/// <param name="address">The address to read from.</param>
|
/// <param name="address">The address to read from.</param>
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,8 @@ namespace Dalamud
|
||||||
ThirdRepo = dalamud.Configuration.ThirdRepoList,
|
ThirdRepo = dalamud.Configuration.ThirdRepoList,
|
||||||
};
|
};
|
||||||
|
|
||||||
Log.Information("TROUBLESHOOTING:" +
|
var encodedPayload = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(payload)));
|
||||||
System.Convert.ToBase64String(
|
Log.Information($"TROUBLESHOOTING:{encodedPayload}");
|
||||||
Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(payload))));
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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<string, JObject> cachedResponses = new ConcurrentDictionary<string, JObject>();
|
|
||||||
|
|
||||||
[Obsolete("This class will not be supported anymore in the future. Please migrate to your own version.", true)]
|
|
||||||
public static async Task<JObject> 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<JObject> 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<JObject> 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<JObject> 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<JObject> 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<JObject> 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<JObject> 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<JObject> 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<JObject> 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<dynamic> 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +1,13 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
|
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
|
||||||
"settings": {
|
"settings": {
|
||||||
"documentationRules": {
|
|
||||||
|
|
||||||
},
|
|
||||||
"orderingRules": {
|
"orderingRules": {
|
||||||
"systemUsingDirectivesFirst": true,
|
"systemUsingDirectivesFirst": true,
|
||||||
"usingDirectivesPlacement": "outsideNamespace",
|
"usingDirectivesPlacement": "outsideNamespace",
|
||||||
"blankLinesBetweenUsingGroups": "require"
|
"blankLinesBetweenUsingGroups": "require"
|
||||||
},
|
},
|
||||||
"maintainabilityRules": {
|
"maintainabilityRules": {
|
||||||
"topLevelTypes": ["class", "interface", "struct", "enum"]
|
"topLevelTypes": [ "class", "interface", "struct", "enum" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue