Skip to main content
Version: 15.x (API 15) [Legacy]

Class Util

Class providing various helper methods for use in Dalamud and plugins.

Assembly: Dalamud.dll​
Declaration
public static class Util

Methods​

DescribeAddress(void*)​

Describes a memory address relative to module, or allocation base.

Declaration
public static string DescribeAddress(void* p)
Returns​

System.String: Address description.

Parameters​
TypeNameDescription
System.Void*pAddress.

DescribeAddress(nint)​

Describes a memory address relative to module, or allocation base.

Declaration
public static string DescribeAddress(nint p)
Returns​

System.String: Address description.

Parameters​
TypeNameDescription
System.IntPtrpAddress.

DumpMemory(nint, int)​

Read memory from an offset and hexdump them via Serilog.

Declaration
public static void DumpMemory(nint offset, int len = 512)
Parameters​
TypeNameDescription
System.IntPtroffsetThe offset to read from.
System.Int32lenThe length to read.

ByteArrayToHex(byte[], int, int)​

Create a hexdump of the provided bytes.

Declaration
public static string ByteArrayToHex(byte[] bytes, int offset = 0, int bytesPerLine = 16)
Returns​

System.String: The generated hexdump in string form.

Parameters​
TypeNameDescription
System.Byte[]bytesThe bytes to hexdump.
System.Int32offsetThe offset in the byte array to start at.
System.Int32bytesPerLineThe amount of bytes to display per line.

ShowStruct(object, ulong, bool, IEnumerable<string>?)​

Show a structure in an ImGui context.

Declaration
public static void ShowStruct(object obj, ulong addr, bool autoExpand = false, IEnumerable<string>? path = null)
Parameters​
TypeNameDescription
System.ObjectobjThe structure to show.
System.UInt64addrThe address to the structure.
System.BooleanautoExpandWhether this structure should start out expanded.
System.Collections.Generic.IEnumerable<System.String>pathThe already followed path.

ShowStruct<T>(T*, bool)​

Show a structure in an ImGui context.

Declaration
public static void ShowStruct<T>(T* obj, bool autoExpand = false) where T : unmanaged
Parameters​
TypeNameDescription
<T>*objThe pointer to the structure.
System.BooleanautoExpandWhether this structure should start out expanded.
Type Parameters​
NameDescription
TThe type of the structure.

ShowGameObjectStruct(IGameObject, bool)​

Show a GameObject's internal data in an ImGui-context.

Declaration
public static void ShowGameObjectStruct(IGameObject go, bool autoExpand = true)
Parameters​
TypeNameDescription
Dalamud.Game.ClientState.Objects.Types.IGameObjectgoThe GameObject to show.
System.BooleanautoExpandWhether the struct should start as expanded.

ShowObject(object)​

Show all properties and fields of the provided object via ImGui.

Declaration
public static void ShowObject(object obj)
Parameters​
TypeNameDescription
System.ObjectobjThe object to show.

Fatal(string, string, bool)​

Display an error MessageBox and exit the current process.

Declaration
public static void Fatal(string message, string caption, bool exit = true)
Parameters​
TypeNameDescription
System.StringmessageMessageBox body.
System.StringcaptionMessageBox caption (title).
System.BooleanexitSpecify whether to exit immediately.

FormatBytes(long)​

Transform byte count to human readable format.

Declaration
public static string FormatBytes(long bytes)
Returns​

System.String: Human readable version.

Parameters​
TypeNameDescription
System.Int64bytesNumber of bytes.

FormatBytes(ulong)​

Transform byte count to human readable format.

Declaration
public static string FormatBytes(ulong bytes)
Returns​

System.String: Human readable version.

Parameters​
TypeNameDescription
System.UInt64bytesNumber of bytes.

GetUTF8String(byte[])​

Retrieve a UTF8 string from a null terminated byte array.

Declaration
public static string GetUTF8String(byte[] array)
Returns​

System.String: A UTF8 encoded string.

Parameters​
TypeNameDescription
System.Byte[]arrayA null terminated UTF8 byte array.

CompressString(string)​

Compress a string using GZip.

Declaration
public static byte[] CompressString(string str)
Returns​

System.Byte[]: The compressed output bytes.

Parameters​
TypeNameDescription
System.StringstrThe input string.

DecompressString(byte[])​

Decompress a string using GZip.

Declaration
public static string DecompressString(byte[] bytes)
Returns​

System.String: The compressed output string.

Parameters​
TypeNameDescription
System.Byte[]bytesThe input bytes.

IsWine()​

Determine if Dalamud is currently running within a Wine context (e.g. either on macOS or Linux). This method will not return information about the host operating system.

Declaration
public static bool IsWine()
Returns​

System.Boolean: Returns true if running on Wine, false otherwise.

GetHostPlatform()​

Gets the current host's platform based on the injector launch arguments or heuristics.

Declaration
public static OSPlatform GetHostPlatform()
Returns​

System.Runtime.InteropServices.OSPlatform: Returns the System.Runtime.InteropServices.OSPlatform that Dalamud is currently running on.

IsWindows11()​

Heuristically determine if the Windows version is higher than Windows 11's first build.

Declaration
public static bool IsWindows11()
Returns​

System.Boolean: If Windows 11 has been detected.

OpenLink(string)​

Open a link in the default browser, and attempts to focus the newly launched application.

Declaration
public static void OpenLink(string url)
Parameters​
TypeNameDescription
System.StringurlThe link to open.

ZipperMerge<TSource>(params IEnumerable<TSource>[])​

Perform a "zipper merge" (A, 1, B, 2, C, 3) of multiple enumerables, allowing for lists to end early.

Declaration
public static IEnumerable<TSource> ZipperMerge<TSource>(params IEnumerable<TSource>[] sources)
Returns​

System.Collections.Generic.IEnumerable<<TSource>>: A new enumerable, consisting of the final merge of all lists.

Parameters​
TypeNameDescription
System.Collections.Generic.IEnumerable<<TSource>>[]sourcesA set of enumerable sources to combine.
Type Parameters​
NameDescription
TSourceThe resulting type of the merged list to return.

ApplicationIsActivated()​

Returns true if the current application has focus, false otherwise.

Declaration
public static bool ApplicationIsActivated()
Returns​

System.Boolean: If the current application is focused.

FlashWindow(bool)​

Request that Windows flash the game window to grab the user's attention.

Declaration
public static void FlashWindow(bool flashIfOpen = false)
Parameters​
TypeNameDescription
System.BooleanflashIfOpenAttempt to flash even if the game is currently focused.

GetReplaceableFileName(string)​

Gets a temporary file name, for use as the sourceFileName in System.IO.File.Replace(System.String,System.String,System.String).

Declaration
public static string GetReplaceableFileName(string targetFile)
Returns​

System.String: A temporary file name that should be usable with System.IO.File.Replace(System.String,System.String,System.String).

Parameters​
TypeNameDescription
System.StringtargetFileThe target file.
Remarks​

No write operation is done on the filesystem.