Show / Hide Table of Contents

# Class Util

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

##### Inheritance

System.Object
Util

##### Inherited Members

System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()

###### Namespace: Dalamud.Utility

###### Assembly: Dalamud.dll

##### Syntax

    public static class Util

### Properties

| Improve this Doc View Source

#### AssemblyVersion

Gets the assembly version of Dalamud.

##### Declaration

    public static string AssemblyVersion { get; }

##### Property Value

Type | Description
--- | ---
System.String |

| Improve this Doc View Source

#### HttpClient

Gets an httpclient for usage. Do NOT await this.

##### Declaration

    public static HttpClient HttpClient { get; }

##### Property Value

Type | Description
--- | ---
System.Net.Http.HttpClient |

### Methods

| Improve this Doc View Source

#### ByteArrayToHex(Byte[], Int32, Int32)

Create a hexdump of the provided bytes.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
System.Byte[] | bytes | The bytes to hexdump.
System.Int32 | offset | The offset in the byte array to start at.
System.Int32 | bytesPerLine | The amount of bytes to display per line.

##### Returns

Type | Description
--- | ---
System.String | The generated hexdump in string form.

| Improve this Doc View Source

#### CompressString(String)

Compress a string using GZip.

##### Declaration

    public static byte[] CompressString(string str)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | str | The input string.

##### Returns

Type | Description
--- | ---
System.Byte[] | The compressed output bytes.

| Improve this Doc View Source

#### CopyTo(Stream, Stream, Int32)

Copy one stream to another.

##### Declaration

    [Obsolete("Use Stream.CopyTo() instead", true)]
    public static void CopyTo(Stream src, Stream dest, int len = 4069)

##### Parameters

Type | Name | Description
--- | --- | ---
System.IO.Stream | src | The source stream.
System.IO.Stream | dest | The destination stream.
System.Int32 | len | The maximum length to copy.

| Improve this Doc View Source

#### DecompressString(Byte[])

Decompress a string using GZip.

##### Declaration

    public static string DecompressString(byte[] bytes)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Byte[] | bytes | The input bytes.

##### Returns

Type | Description
--- | ---
System.String | The compressed output string.

| Improve this Doc View Source

#### DumpMemory(IntPtr, Int32)

Read memory from an offset and hexdump them via Serilog.

##### Declaration

    public static void DumpMemory(IntPtr offset, int len = 512)

##### Parameters

Type | Name | Description
--- | --- | ---
System.IntPtr | offset | The offset to read from.
System.Int32 | len | The length to read.

| Improve this Doc View Source

#### FastByteArrayCompare(Byte[], Byte[])

Check two byte arrays for equality.

##### Declaration

    public static bool FastByteArrayCompare(byte[] a1, byte[] a2)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Byte[] | a1 | The first byte array.
System.Byte[] | a2 | The second byte array.

##### Returns

Type | Description
--- | ---
System.Boolean | Whether or not the byte arrays are equal.

| Improve this Doc View Source

#### Fatal(String, String, Boolean)

Display an error MessageBox and exit the current process.

##### Declaration

    public static void Fatal(string message, string caption, bool exit = true)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | message | MessageBox body.
System.String | caption | MessageBox caption (title).
System.Boolean | exit | Specify whether to exit immediately.

| Improve this Doc View Source

#### FormatBytes(Int64)

Transform byte count to human readable format.

##### Declaration

    public static string FormatBytes(long bytes)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int64 | bytes | Number of bytes.

##### Returns

Type | Description
--- | ---
System.String | Human readable version.

| Improve this Doc View Source

#### GetGitHash()

Gets the git hash value from the assembly or null if it cannot be found.

##### Declaration

    public static string GetGitHash()

##### Returns

Type | Description
--- | ---
System.String | The git hash of the assembly.

| Improve this Doc View Source

#### GetGitHashClientStructs()

Gets the git hash value from the assembly or null if it cannot be found.

##### Declaration

    public static string GetGitHashClientStructs()

##### Returns

Type | Description
--- | ---
System.String | The git hash of the assembly.

| Improve this Doc View Source

#### GetUTF8String(Byte[])

Retrieve a UTF8 string from a null terminated byte array.

##### Declaration

    public static string GetUTF8String(byte[] array)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Byte[] | array | A null terminated UTF8 byte array.

##### Returns

Type | Description
--- | ---
System.String | A UTF8 encoded string.

| Improve this Doc View Source

#### IsLinux()

Heuristically determine if Dalamud is running on Linux/WINE.

##### Declaration

    public static bool IsLinux()

##### Returns

Type | Description
--- | ---
System.Boolean | Whether or not Dalamud is running on Linux/WINE.

| Improve this Doc View Source

#### OpenLink(String)

Open a link in the default browser.

##### Declaration

    public static void OpenLink(string url)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | url | The link to open.

| Improve this Doc View Source

#### ShowGameObjectStruct(GameObject, Boolean)

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

##### Declaration

    public static void ShowGameObjectStruct(GameObject go, bool autoExpand = true)

##### Parameters

Type | Name | Description
--- | --- | ---
GameObject | go | The GameObject to show.
System.Boolean | autoExpand | Whether or not the struct should start as expanded.

| Improve this Doc View Source

#### ShowObject(Object)

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

##### Declaration

    public static void ShowObject(object obj)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Object | obj | The object to show.

| Improve this Doc View Source

#### ShowStruct(Object, UInt64, Boolean, 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

Type | Name | Description
--- | --- | ---
System.Object | obj | The structure to show.
System.UInt64 | addr | The address to the structure.
System.Boolean | autoExpand | Whether or not this structure should start out expanded.
System.Collections.Generic.IEnumerable<System.String> | path | The already followed path.

| Improve this Doc View Source

#### ShowStruct<T>(T*, Boolean)

Show a structure in an ImGui context.

##### Declaration

    public static void ShowStruct<T>(T*obj, bool autoExpand = false)
        where T : struct

##### Parameters

Type | Name | Description
--- | --- | ---
T* | obj | The pointer to the structure.
System.Boolean | autoExpand | Whether or not this structure should start out expanded.

##### Type Parameters

Name | Description
--- | ---
T | The type of the structure.