Dalamud/docs/api/Dalamud.Hooking.Hook-1.html
2021-04-07 20:41:53 +02:00

507 lines
22 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 Hook&lt;T&gt;
</title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Class Hook&lt;T&gt;
">
<meta name="generator" content="docfx 2.56.6.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.Hooking.Hook`1">
<h1 id="Dalamud_Hooking_Hook_1" data-uid="Dalamud.Hooking.Hook`1" class="text-break">Class Hook&lt;T&gt;
</h1>
<div class="markdown level0 summary"><p>Manages a hook which can be used to intercept a call to native function.
This class is basically a thin wrapper around the LocalHook type to provide helper functions.</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">Hook&lt;T&gt;</span></div>
</div>
<div classs="implements">
<h5>Implements</h5>
<div><span class="xref">System.IDisposable</span></div>
</div>
<div class="inheritedMembers">
<h5>Inherited Members</h5>
<div>
<span class="xref">System.Object.ToString()</span>
</div>
<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.ReferenceEquals(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>
<h6><strong>Namespace</strong>: <a class="xref" href="Dalamud.Hooking.html">Dalamud.Hooking</a></h6>
<h6><strong>Assembly</strong>: Dalamud.dll</h6>
<h5 id="Dalamud_Hooking_Hook_1_syntax">Syntax</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public sealed class Hook&lt;T&gt; : IDisposable, IDalamudHook where T : Delegate</code></pre>
</div>
<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>Delegate type to represents a function prototype. This must be the same prototype as original function do.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="constructors">Constructors
</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_Hooking_Hook_1__ctor_System_IntPtr_System_Delegate_System_Object_.md&amp;value=---%0Auid%3A%20Dalamud.Hooking.Hook%601.%23ctor(System.IntPtr%2CSystem.Delegate%2CSystem.Object)%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/Hooking/Hook.cs/#L30">View Source</a>
</span>
<a id="Dalamud_Hooking_Hook_1__ctor_" data-uid="Dalamud.Hooking.Hook`1.#ctor*"></a>
<h4 id="Dalamud_Hooking_Hook_1__ctor_System_IntPtr_System_Delegate_System_Object_" data-uid="Dalamud.Hooking.Hook`1.#ctor(System.IntPtr,System.Delegate,System.Object)">Hook(IntPtr, Delegate, Object)</h4>
<div class="markdown level1 summary"><p>Initializes a new instance of the <a class="xref" href="Dalamud.Hooking.Hook-1.html">Hook&lt;T&gt;</a> class.
Hook is not activated until Enable() method is called.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public Hook(IntPtr address, Delegate detour, object callbackParam = null)</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>A memory address to install a hook.</p>
</td>
</tr>
<tr>
<td><span class="xref">System.Delegate</span></td>
<td><span class="parametername">detour</span></td>
<td><p>Callback function. Delegate must have a same original function prototype.</p>
</td>
</tr>
<tr>
<td><span class="xref">System.Object</span></td>
<td><span class="parametername">callbackParam</span></td>
<td><p>A callback object which can be accessed within the detour.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="properties">Properties
</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_Hooking_Hook_1_Address.md&amp;value=---%0Auid%3A%20Dalamud.Hooking.Hook%601.Address%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/Hooking/Hook.cs/#L42">View Source</a>
</span>
<a id="Dalamud_Hooking_Hook_1_Address_" data-uid="Dalamud.Hooking.Hook`1.Address*"></a>
<h4 id="Dalamud_Hooking_Hook_1_Address" data-uid="Dalamud.Hooking.Hook`1.Address">Address</h4>
<div class="markdown level1 summary"><p>Gets a memory address of the target function.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public IntPtr Address { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</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.IntPtr</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Condition</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.ObjectDisposedException</span></td>
<td><p>Hook is already disposed.</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_Hooking_Hook_1_IsDisposed.md&amp;value=---%0Auid%3A%20Dalamud.Hooking.Hook%601.IsDisposed%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/Hooking/Hook.cs/#L81">View Source</a>
</span>
<a id="Dalamud_Hooking_Hook_1_IsDisposed_" data-uid="Dalamud.Hooking.Hook`1.IsDisposed*"></a>
<h4 id="Dalamud_Hooking_Hook_1_IsDisposed" data-uid="Dalamud.Hooking.Hook`1.IsDisposed">IsDisposed</h4>
<div class="markdown level1 summary"><p>Gets a value indicating whether or not the hook has been disposed.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public bool IsDisposed { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</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></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_Hooking_Hook_1_IsEnabled.md&amp;value=---%0Auid%3A%20Dalamud.Hooking.Hook%601.IsEnabled%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/Hooking/Hook.cs/#L69">View Source</a>
</span>
<a id="Dalamud_Hooking_Hook_1_IsEnabled_" data-uid="Dalamud.Hooking.Hook`1.IsEnabled*"></a>
<h4 id="Dalamud_Hooking_Hook_1_IsEnabled" data-uid="Dalamud.Hooking.Hook`1.IsEnabled">IsEnabled</h4>
<div class="markdown level1 summary"><p>Gets a value indicating whether or not the hook is enabled.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public bool IsEnabled { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</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></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_Hooking_Hook_1_Original.md&amp;value=---%0Auid%3A%20Dalamud.Hooking.Hook%601.Original%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/Hooking/Hook.cs/#L56">View Source</a>
</span>
<a id="Dalamud_Hooking_Hook_1_Original_" data-uid="Dalamud.Hooking.Hook`1.Original*"></a>
<h4 id="Dalamud_Hooking_Hook_1_Original" data-uid="Dalamud.Hooking.Hook`1.Original">Original</h4>
<div class="markdown level1 summary"><p>Gets a delegate function that can be used to call the actual function as if function is not hooked yet.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public T Original { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</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">T</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Condition</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.ObjectDisposedException</span></td>
<td><p>Hook is already disposed.</p>
</td>
</tr>
</tbody>
</table>
<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_Hooking_Hook_1_Disable.md&amp;value=---%0Auid%3A%20Dalamud.Hooking.Hook%601.Disable%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/Hooking/Hook.cs/#L128">View Source</a>
</span>
<a id="Dalamud_Hooking_Hook_1_Disable_" data-uid="Dalamud.Hooking.Hook`1.Disable*"></a>
<h4 id="Dalamud_Hooking_Hook_1_Disable" data-uid="Dalamud.Hooking.Hook`1.Disable">Disable()</h4>
<div class="markdown level1 summary"><p>Stops intercepting a call to the function.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public void Disable()</code></pre>
</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_Hooking_Hook_1_Dispose.md&amp;value=---%0Auid%3A%20Dalamud.Hooking.Hook%601.Dispose%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/Hooking/Hook.cs/#L103">View Source</a>
</span>
<a id="Dalamud_Hooking_Hook_1_Dispose_" data-uid="Dalamud.Hooking.Hook`1.Dispose*"></a>
<h4 id="Dalamud_Hooking_Hook_1_Dispose" data-uid="Dalamud.Hooking.Hook`1.Dispose">Dispose()</h4>
<div class="markdown level1 summary"><p>Remove a hook 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 void Dispose()</code></pre>
</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_Hooking_Hook_1_Enable.md&amp;value=---%0Auid%3A%20Dalamud.Hooking.Hook%601.Enable%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/Hooking/Hook.cs/#L118">View Source</a>
</span>
<a id="Dalamud_Hooking_Hook_1_Enable_" data-uid="Dalamud.Hooking.Hook`1.Enable*"></a>
<h4 id="Dalamud_Hooking_Hook_1_Enable" data-uid="Dalamud.Hooking.Hook`1.Enable">Enable()</h4>
<div class="markdown level1 summary"><p>Starts intercepting a call to the function.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public void Enable()</code></pre>
</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_Hooking_Hook_1_FromSymbol_System_String_System_String_System_Delegate_System_Object_.md&amp;value=---%0Auid%3A%20Dalamud.Hooking.Hook%601.FromSymbol(System.String%2CSystem.String%2CSystem.Delegate%2CSystem.Object)%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/Hooking/Hook.cs/#L92">View Source</a>
</span>
<a id="Dalamud_Hooking_Hook_1_FromSymbol_" data-uid="Dalamud.Hooking.Hook`1.FromSymbol*"></a>
<h4 id="Dalamud_Hooking_Hook_1_FromSymbol_System_String_System_String_System_Delegate_System_Object_" data-uid="Dalamud.Hooking.Hook`1.FromSymbol(System.String,System.String,System.Delegate,System.Object)">FromSymbol(String, String, Delegate, Object)</h4>
<div class="markdown level1 summary"><p>Creates a hook. Hooking address is inferred by calling to GetProcAddress() function.
Hook is not activated until Enable() method is called.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static Hook&lt;T&gt; FromSymbol(string moduleName, string exportName, Delegate detour, object callbackParam = null)</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.String</span></td>
<td><span class="parametername">moduleName</span></td>
<td><p>A name of the module currently loaded in the memory. (e.g. ws2_32.dll).</p>
</td>
</tr>
<tr>
<td><span class="xref">System.String</span></td>
<td><span class="parametername">exportName</span></td>
<td><p>A name of the exported function name (e.g. send).</p>
</td>
</tr>
<tr>
<td><span class="xref">System.Delegate</span></td>
<td><span class="parametername">detour</span></td>
<td><p>Callback function. Delegate must have a same original function prototype.</p>
</td>
</tr>
<tr>
<td><span class="xref">System.Object</span></td>
<td><span class="parametername">callbackParam</span></td>
<td><p>A callback object which can be accessed within the detour.</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><a class="xref" href="Dalamud.Hooking.Hook-1.html">Hook</a>&lt;T&gt;</td>
<td><p>The hook with the supplied parameters.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="implements">Implements</h3>
<div>
<span class="xref">System.IDisposable</span>
</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_Hooking_Hook_1.md&amp;value=---%0Auid%3A%20Dalamud.Hooking.Hook%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" class="contribution-link">Improve this Doc</a>
</li>
<li>
<a href="https://github.com/goatcorp/Dalamud/blob/master/Dalamud/Hooking/Hook.cs/#L15" 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>