Dalamud/docs/api/Dalamud.SafeMemory.html
2021-12-08 21:55:20 +01:00

1000 lines
39 KiB
HTML

<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Class SafeMemory
</title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Class SafeMemory
">
<meta name="generator" content="docfx 2.58.9.0">
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" href="../styles/docfx.vendor.css">
<link rel="stylesheet" href="../styles/docfx.css">
<link rel="stylesheet" href="../styles/main.css">
<meta property="docfx:navrel" content="">
<meta property="docfx:tocrel" content="toc.html">
</head>
<body data-spy="scroll" data-target="#affix" data-offset="120">
<div id="wrapper">
<header>
<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../index.html">
<img id="logo" class="svg" src="../logo.svg" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav>
<div class="subnav navbar navbar-default">
<div class="container hide-when-search" id="breadcrumb">
<ul class="breadcrumb">
<li></li>
</ul>
</div>
</div>
</header>
<div role="main" class="container body-content hide-when-search">
<div class="sidenav hide-when-search">
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
<div class="sidetoggle collapse" id="sidetoggle">
<div id="sidetoc"></div>
</div>
</div>
<div class="article row grid-right">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="Dalamud.SafeMemory">
<h1 id="Dalamud_SafeMemory" data-uid="Dalamud.SafeMemory" class="text-break">Class SafeMemory
</h1>
<div class="markdown level0 summary"><p>Class facilitating safe memory access.</p>
</div>
<div class="markdown level0 conceptual"></div>
<div class="inheritance">
<h5>Inheritance</h5>
<div class="level0"><span class="xref">System.Object</span></div>
<div class="level1"><span class="xref">SafeMemory</span></div>
</div>
<div class="inheritedMembers">
<h5>Inherited Members</h5>
<div>
<span class="xref">System.Object.Equals(System.Object)</span>
</div>
<div>
<span class="xref">System.Object.Equals(System.Object, System.Object)</span>
</div>
<div>
<span class="xref">System.Object.GetHashCode()</span>
</div>
<div>
<span class="xref">System.Object.GetType()</span>
</div>
<div>
<span class="xref">System.Object.MemberwiseClone()</span>
</div>
<div>
<span class="xref">System.Object.ReferenceEquals(System.Object, System.Object)</span>
</div>
<div>
<span class="xref">System.Object.ToString()</span>
</div>
</div>
<h6><strong>Namespace</strong>: <a class="xref" href="Dalamud.html">Dalamud</a></h6>
<h6><strong>Assembly</strong>: Dalamud.dll</h6>
<h5 id="Dalamud_SafeMemory_syntax">Syntax</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static class SafeMemory</code></pre>
</div>
<h5 id="Dalamud_SafeMemory_remarks"><strong>Remarks</strong></h5>
<div class="markdown level0 remarks"><p>Attention! The performance of these methods is severely worse than regular <span class="xref">System.Runtime.InteropServices.Marshal</span> calls.
Please consider using those instead in performance-critical code.</p>
</div>
<h3 id="methods">Methods
</h3>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/goatcorp/Dalamud/new/master/apiSpec/new?filename=Dalamud_SafeMemory_PtrToStructure_System_IntPtr_System_Type_.md&amp;value=---%0Auid%3A%20Dalamud.SafeMemory.PtrToStructure(System.IntPtr%2CSystem.Type)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/goatcorp/Dalamud/blob/master/Dalamud/SafeMemory.cs/#L207">View Source</a>
</span>
<a id="Dalamud_SafeMemory_PtrToStructure_" data-uid="Dalamud.SafeMemory.PtrToStructure*"></a>
<h4 id="Dalamud_SafeMemory_PtrToStructure_System_IntPtr_System_Type_" data-uid="Dalamud.SafeMemory.PtrToStructure(System.IntPtr,System.Type)">PtrToStructure(IntPtr, Type)</h4>
<div class="markdown level1 summary"><p>Marshals data from an unmanaged block of memory to a managed object.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static object PtrToStructure(IntPtr addr, Type type)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IntPtr</span></td>
<td><span class="parametername">addr</span></td>
<td><p>The address to read from.</p>
</td>
</tr>
<tr>
<td><span class="xref">System.Type</span></td>
<td><span class="parametername">type</span></td>
<td><p>The type to create.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Object</span></td>
<td><p>The read object, or null, if it could not be read.</p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/goatcorp/Dalamud/new/master/apiSpec/new?filename=Dalamud_SafeMemory_PtrToStructure__1_System_IntPtr_.md&amp;value=---%0Auid%3A%20Dalamud.SafeMemory.PtrToStructure%60%601(System.IntPtr)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/goatcorp/Dalamud/blob/master/Dalamud/SafeMemory.cs/#L199">View Source</a>
</span>
<a id="Dalamud_SafeMemory_PtrToStructure_" data-uid="Dalamud.SafeMemory.PtrToStructure*"></a>
<h4 id="Dalamud_SafeMemory_PtrToStructure__1_System_IntPtr_" data-uid="Dalamud.SafeMemory.PtrToStructure``1(System.IntPtr)">PtrToStructure&lt;T&gt;(IntPtr)</h4>
<div class="markdown level1 summary"><p>Marshals data from an unmanaged block of memory to a managed object.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static T? PtrToStructure&lt;T&gt;(IntPtr addr)
where T : struct</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IntPtr</span></td>
<td><span class="parametername">addr</span></td>
<td><p>The address to read from.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Nullable</span>&lt;T&gt;</td>
<td><p>The read object, or null, if it could not be read.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="parametername">T</span></td>
<td><p>The type to create.</p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/goatcorp/Dalamud/new/master/apiSpec/new?filename=Dalamud_SafeMemory_Read__1_System_IntPtr___0__.md&amp;value=---%0Auid%3A%20Dalamud.SafeMemory.Read%60%601(System.IntPtr%2C%60%600%40)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/goatcorp/Dalamud/blob/master/Dalamud/SafeMemory.cs/#L54">View Source</a>
</span>
<a id="Dalamud_SafeMemory_Read_" data-uid="Dalamud.SafeMemory.Read*"></a>
<h4 id="Dalamud_SafeMemory_Read__1_System_IntPtr___0__" data-uid="Dalamud.SafeMemory.Read``1(System.IntPtr,``0@)">Read&lt;T&gt;(IntPtr, out T)</h4>
<div class="markdown level1 summary"><p>Read an object of the specified struct from the current process.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static bool Read&lt;T&gt;(IntPtr address, out T result)
where T : struct</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IntPtr</span></td>
<td><span class="parametername">address</span></td>
<td><p>The address to read from.</p>
</td>
</tr>
<tr>
<td><span class="xref">T</span></td>
<td><span class="parametername">result</span></td>
<td><p>The resulting object.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Boolean</span></td>
<td><p>Whether or not the read succeeded.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="parametername">T</span></td>
<td><p>The type of the struct.</p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/goatcorp/Dalamud/new/master/apiSpec/new?filename=Dalamud_SafeMemory_Read__1_System_IntPtr_System_Int32_.md&amp;value=---%0Auid%3A%20Dalamud.SafeMemory.Read%60%601(System.IntPtr%2CSystem.Int32)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/goatcorp/Dalamud/blob/master/Dalamud/SafeMemory.cs/#L76">View Source</a>
</span>
<a id="Dalamud_SafeMemory_Read_" data-uid="Dalamud.SafeMemory.Read*"></a>
<h4 id="Dalamud_SafeMemory_Read__1_System_IntPtr_System_Int32_" data-uid="Dalamud.SafeMemory.Read``1(System.IntPtr,System.Int32)">Read&lt;T&gt;(IntPtr, Int32)</h4>
<div class="markdown level1 summary"><p>Read an array of objects of the specified struct from the current process.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static T[] Read&lt;T&gt;(IntPtr address, int count)
where T : struct</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IntPtr</span></td>
<td><span class="parametername">address</span></td>
<td><p>The address to read from.</p>
</td>
</tr>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><span class="parametername">count</span></td>
<td><p>The length of the array.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>T[]</td>
<td><p>An array of the read objects, or null if any entry of the array failed to read.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="parametername">T</span></td>
<td><p>The type of the struct.</p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/goatcorp/Dalamud/new/master/apiSpec/new?filename=Dalamud_SafeMemory_ReadBytes_System_IntPtr_System_Int32_System_Byte____.md&amp;value=---%0Auid%3A%20Dalamud.SafeMemory.ReadBytes(System.IntPtr%2CSystem.Int32%2CSystem.Byte%5B%5D%40)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/goatcorp/Dalamud/blob/master/Dalamud/SafeMemory.cs/#L30">View Source</a>
</span>
<a id="Dalamud_SafeMemory_ReadBytes_" data-uid="Dalamud.SafeMemory.ReadBytes*"></a>
<h4 id="Dalamud_SafeMemory_ReadBytes_System_IntPtr_System_Int32_System_Byte____" data-uid="Dalamud.SafeMemory.ReadBytes(System.IntPtr,System.Int32,System.Byte[]@)">ReadBytes(IntPtr, Int32, out Byte[])</h4>
<div class="markdown level1 summary"><p>Read a byte array from the current process.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static bool ReadBytes(IntPtr address, int count, out byte[] buffer)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IntPtr</span></td>
<td><span class="parametername">address</span></td>
<td><p>The address to read from.</p>
</td>
</tr>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><span class="parametername">count</span></td>
<td><p>The amount of bytes to read.</p>
</td>
</tr>
<tr>
<td><span class="xref">System.Byte</span>[]</td>
<td><span class="parametername">buffer</span></td>
<td><p>The result buffer.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Boolean</span></td>
<td><p>Whether or not the read succeeded.</p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/goatcorp/Dalamud/new/master/apiSpec/new?filename=Dalamud_SafeMemory_ReadString_System_IntPtr_System_Int32_.md&amp;value=---%0Auid%3A%20Dalamud.SafeMemory.ReadString(System.IntPtr%2CSystem.Int32)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/goatcorp/Dalamud/blob/master/Dalamud/SafeMemory.cs/#L132">View Source</a>
</span>
<a id="Dalamud_SafeMemory_ReadString_" data-uid="Dalamud.SafeMemory.ReadString*"></a>
<h4 id="Dalamud_SafeMemory_ReadString_System_IntPtr_System_Int32_" data-uid="Dalamud.SafeMemory.ReadString(System.IntPtr,System.Int32)">ReadString(IntPtr, Int32)</h4>
<div class="markdown level1 summary"><p>Read a string from the current process(UTF-8).</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static string ReadString(IntPtr address, int maxLength = 256)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IntPtr</span></td>
<td><span class="parametername">address</span></td>
<td><p>The address to read from.</p>
</td>
</tr>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><span class="parametername">maxLength</span></td>
<td><p>The maximum length of the string.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.String</span></td>
<td><p>The read string, or null in case the read was not successful.</p>
</td>
</tr>
</tbody>
</table>
<h5 id="Dalamud_SafeMemory_ReadString_System_IntPtr_System_Int32__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Attention! This will use the .NET Encoding.UTF8 class to decode the text.
If you read a FFXIV string, please use ReadBytes and parse the string with the applicable class,
since Encoding.UTF8 destroys the FFXIV payload structure.</p>
</div>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/goatcorp/Dalamud/new/master/apiSpec/new?filename=Dalamud_SafeMemory_ReadString_System_IntPtr_System_Text_Encoding_System_Int32_.md&amp;value=---%0Auid%3A%20Dalamud.SafeMemory.ReadString(System.IntPtr%2CSystem.Text.Encoding%2CSystem.Int32)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/goatcorp/Dalamud/blob/master/Dalamud/SafeMemory.cs/#L149">View Source</a>
</span>
<a id="Dalamud_SafeMemory_ReadString_" data-uid="Dalamud.SafeMemory.ReadString*"></a>
<h4 id="Dalamud_SafeMemory_ReadString_System_IntPtr_System_Text_Encoding_System_Int32_" data-uid="Dalamud.SafeMemory.ReadString(System.IntPtr,System.Text.Encoding,System.Int32)">ReadString(IntPtr, Encoding, Int32)</h4>
<div class="markdown level1 summary"><p>Read a string from the current process(UTF-8).</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static string ReadString(IntPtr address, Encoding encoding, int maxLength = 256)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IntPtr</span></td>
<td><span class="parametername">address</span></td>
<td><p>The address to read from.</p>
</td>
</tr>
<tr>
<td><span class="xref">System.Text.Encoding</span></td>
<td><span class="parametername">encoding</span></td>
<td><p>The encoding to use to decode the string.</p>
</td>
</tr>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><span class="parametername">maxLength</span></td>
<td><p>The maximum length of the string.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.String</span></td>
<td><p>The read string, or null in case the read was not successful.</p>
</td>
</tr>
</tbody>
</table>
<h5 id="Dalamud_SafeMemory_ReadString_System_IntPtr_System_Text_Encoding_System_Int32__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Attention! This will use the .NET Encoding class to decode the text.
If you read a FFXIV string, please use ReadBytes and parse the string with the applicable class,
since Encoding may destroy the FFXIV payload structure.</p>
</div>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/goatcorp/Dalamud/new/master/apiSpec/new?filename=Dalamud_SafeMemory_SizeOf__1.md&amp;value=---%0Auid%3A%20Dalamud.SafeMemory.SizeOf%60%601%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/goatcorp/Dalamud/blob/master/Dalamud/SafeMemory.cs/#L225">View Source</a>
</span>
<a id="Dalamud_SafeMemory_SizeOf_" data-uid="Dalamud.SafeMemory.SizeOf*"></a>
<h4 id="Dalamud_SafeMemory_SizeOf__1" data-uid="Dalamud.SafeMemory.SizeOf``1">SizeOf&lt;T&gt;()</h4>
<div class="markdown level1 summary"><p>Get the size of the passed type.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static int SizeOf&lt;T&gt;()
where T : struct</code></pre>
</div>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><p>The size of the passed type.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="parametername">T</span></td>
<td><p>The type to inspect.</p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/goatcorp/Dalamud/new/master/apiSpec/new?filename=Dalamud_SafeMemory_Write__1_System_IntPtr___0_.md&amp;value=---%0Auid%3A%20Dalamud.SafeMemory.Write%60%601(System.IntPtr%2C%60%600)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/goatcorp/Dalamud/blob/master/Dalamud/SafeMemory.cs/#L96">View Source</a>
</span>
<a id="Dalamud_SafeMemory_Write_" data-uid="Dalamud.SafeMemory.Write*"></a>
<h4 id="Dalamud_SafeMemory_Write__1_System_IntPtr___0_" data-uid="Dalamud.SafeMemory.Write``1(System.IntPtr,``0)">Write&lt;T&gt;(IntPtr, T)</h4>
<div class="markdown level1 summary"><p>Write a struct to the current process.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static bool Write&lt;T&gt;(IntPtr address, T obj)
where T : struct</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IntPtr</span></td>
<td><span class="parametername">address</span></td>
<td><p>The address to write to.</p>
</td>
</tr>
<tr>
<td><span class="xref">T</span></td>
<td><span class="parametername">obj</span></td>
<td><p>The object to write.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Boolean</span></td>
<td><p>Whether or not the write succeeded.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="parametername">T</span></td>
<td><p>The type of the struct.</p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/goatcorp/Dalamud/new/master/apiSpec/new?filename=Dalamud_SafeMemory_Write__1_System_IntPtr___0___.md&amp;value=---%0Auid%3A%20Dalamud.SafeMemory.Write%60%601(System.IntPtr%2C%60%600%5B%5D)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/goatcorp/Dalamud/blob/master/Dalamud/SafeMemory.cs/#L110">View Source</a>
</span>
<a id="Dalamud_SafeMemory_Write_" data-uid="Dalamud.SafeMemory.Write*"></a>
<h4 id="Dalamud_SafeMemory_Write__1_System_IntPtr___0___" data-uid="Dalamud.SafeMemory.Write``1(System.IntPtr,``0[])">Write&lt;T&gt;(IntPtr, T[])</h4>
<div class="markdown level1 summary"><p>Write an array of structs to the current process.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static bool Write&lt;T&gt;(IntPtr address, T[] objArray)
where T : struct</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IntPtr</span></td>
<td><span class="parametername">address</span></td>
<td><p>The address to write to.</p>
</td>
</tr>
<tr>
<td>T[]</td>
<td><span class="parametername">objArray</span></td>
<td><p>The array to write.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Boolean</span></td>
<td><p>Whether or not the write succeeded.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="parametername">T</span></td>
<td><p>The type of the structs.</p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/goatcorp/Dalamud/new/master/apiSpec/new?filename=Dalamud_SafeMemory_WriteBytes_System_IntPtr_System_Byte___.md&amp;value=---%0Auid%3A%20Dalamud.SafeMemory.WriteBytes(System.IntPtr%2CSystem.Byte%5B%5D)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/goatcorp/Dalamud/blob/master/Dalamud/SafeMemory.cs/#L42">View Source</a>
</span>
<a id="Dalamud_SafeMemory_WriteBytes_" data-uid="Dalamud.SafeMemory.WriteBytes*"></a>
<h4 id="Dalamud_SafeMemory_WriteBytes_System_IntPtr_System_Byte___" data-uid="Dalamud.SafeMemory.WriteBytes(System.IntPtr,System.Byte[])">WriteBytes(IntPtr, Byte[])</h4>
<div class="markdown level1 summary"><p>Write a byte array to the current process.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static bool WriteBytes(IntPtr address, byte[] buffer)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IntPtr</span></td>
<td><span class="parametername">address</span></td>
<td><p>The address to write to.</p>
</td>
</tr>
<tr>
<td><span class="xref">System.Byte</span>[]</td>
<td><span class="parametername">buffer</span></td>
<td><p>The buffer to write.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Boolean</span></td>
<td><p>Whether or not the write succeeded.</p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/goatcorp/Dalamud/new/master/apiSpec/new?filename=Dalamud_SafeMemory_WriteString_System_IntPtr_System_String_.md&amp;value=---%0Auid%3A%20Dalamud.SafeMemory.WriteString(System.IntPtr%2CSystem.String)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/goatcorp/Dalamud/blob/master/Dalamud/SafeMemory.cs/#L169">View Source</a>
</span>
<a id="Dalamud_SafeMemory_WriteString_" data-uid="Dalamud.SafeMemory.WriteString*"></a>
<h4 id="Dalamud_SafeMemory_WriteString_System_IntPtr_System_String_" data-uid="Dalamud.SafeMemory.WriteString(System.IntPtr,System.String)">WriteString(IntPtr, String)</h4>
<div class="markdown level1 summary"><p>Write a string to the current process.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static bool WriteString(IntPtr address, string str)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IntPtr</span></td>
<td><span class="parametername">address</span></td>
<td><p>The address to write to.</p>
</td>
</tr>
<tr>
<td><span class="xref">System.String</span></td>
<td><span class="parametername">str</span></td>
<td><p>The string to write.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Boolean</span></td>
<td><p>Whether or not the write succeeded.</p>
</td>
</tr>
</tbody>
</table>
<h5 id="Dalamud_SafeMemory_WriteString_System_IntPtr_System_String__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Attention! This will use the .NET Encoding class to encode the text.
If you read a FFXIV string, please use WriteBytes with the applicable encoded SeString,
since Encoding may destroy the FFXIV payload structure.</p>
</div>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/goatcorp/Dalamud/new/master/apiSpec/new?filename=Dalamud_SafeMemory_WriteString_System_IntPtr_System_String_System_Text_Encoding_.md&amp;value=---%0Auid%3A%20Dalamud.SafeMemory.WriteString(System.IntPtr%2CSystem.String%2CSystem.Text.Encoding)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/goatcorp/Dalamud/blob/master/Dalamud/SafeMemory.cs/#L186">View Source</a>
</span>
<a id="Dalamud_SafeMemory_WriteString_" data-uid="Dalamud.SafeMemory.WriteString*"></a>
<h4 id="Dalamud_SafeMemory_WriteString_System_IntPtr_System_String_System_Text_Encoding_" data-uid="Dalamud.SafeMemory.WriteString(System.IntPtr,System.String,System.Text.Encoding)">WriteString(IntPtr, String, Encoding)</h4>
<div class="markdown level1 summary"><p>Write a string to the current process.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static bool WriteString(IntPtr address, string str, Encoding encoding)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IntPtr</span></td>
<td><span class="parametername">address</span></td>
<td><p>The address to write to.</p>
</td>
</tr>
<tr>
<td><span class="xref">System.String</span></td>
<td><span class="parametername">str</span></td>
<td><p>The string to write.</p>
</td>
</tr>
<tr>
<td><span class="xref">System.Text.Encoding</span></td>
<td><span class="parametername">encoding</span></td>
<td><p>The encoding to use.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Boolean</span></td>
<td><p>Whether or not the write succeeded.</p>
</td>
</tr>
</tbody>
</table>
<h5 id="Dalamud_SafeMemory_WriteString_System_IntPtr_System_String_System_Text_Encoding__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Attention! This will use the .NET Encoding class to encode the text.
If you read a FFXIV string, please use WriteBytes with the applicable encoded SeString,
since Encoding may destroy the FFXIV payload structure.</p>
</div>
</article>
</div>
<div class="hidden-sm col-md-2" role="complementary">
<div class="sideaffix">
<div class="contribution">
<ul class="nav">
<li>
<a href="https://github.com/goatcorp/Dalamud/new/master/apiSpec/new?filename=Dalamud_SafeMemory.md&amp;value=---%0Auid%3A%20Dalamud.SafeMemory%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A" class="contribution-link">Improve this Doc</a>
</li>
<li>
<a href="https://github.com/goatcorp/Dalamud/blob/master/Dalamud/SafeMemory.cs/#L14" class="contribution-link">View Source</a>
</li>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<h5>In This Article</h5>
<div></div>
</nav>
</div>
</div>
</div>
</div>
<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>
<span>Generated by <strong>DocFX</strong></span>
</div>
</div>
</footer>
</div>
<script type="text/javascript" src="../styles/docfx.vendor.js"></script>
<script type="text/javascript" src="../styles/docfx.js"></script>
<script type="text/javascript" src="../styles/main.js"></script>
</body>
</html>