import{_ as s,o as n,c as a,a as l}from"./app.f643a53b.js";const e={},o=l(`<h1 id="api-\u57FA\u672C\u914D\u7F6E" tabindex="-1"><a class="header-anchor" href="#api-\u57FA\u672C\u914D\u7F6E" aria-hidden="true">#</a> API \u57FA\u672C\u914D\u7F6E</h1><blockquote><p>\u8FD9\u91CC\u4ECB\u7ECD\u4E86 <code>YukiHookAPI</code> \u7684\u57FA\u672C\u914D\u7F6E\u65B9\u6CD5\u3002</p></blockquote><h2 id="\u529F\u80FD\u914D\u7F6E" tabindex="-1"><a class="header-anchor" href="#\u529F\u80FD\u914D\u7F6E" aria-hidden="true">#</a> \u529F\u80FD\u914D\u7F6E</h2><blockquote><p>\u65E0\u8BBA\u662F <a href="../config/xposed-using">\u4F5C\u4E3A Xposed \u6A21\u5757\u4F7F\u7528</a> \u8FD8\u662F <a href="../config/api-using">\u4F5C\u4E3A Hook API \u4F7F\u7528</a>\uFF0C\u4F60\u90FD\u53EF\u4EE5\u5728 API \u88C5\u8F7D\u4E4B\u524D\u6216\u88C5\u8F7D\u8FC7\u7A0B\u4E2D\u5BF9 <code>YukiHookAPI</code> \u8FDB\u884C\u914D\u7F6E\u3002</p></blockquote><h3 id="configs-\u65B9\u6CD5" tabindex="-1"><a class="header-anchor" href="#configs-\u65B9\u6CD5" aria-hidden="true">#</a> configs \u65B9\u6CD5</h3><div class="language-kotlin ext-kt"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">configs</span><span style="color:#ADBAC7;">(initiate</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Configs</span><span style="color:#ADBAC7;">.() </span><span style="color:#F47067;">-&gt;</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">Unit</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre></div><p><code>configs</code> \u65B9\u6CD5\u5BF9 <code>Configs</code> \u7C7B\u5B9E\u73B0\u4E86\u4E00\u4E2A <code>lambda</code> \u65B9\u6CD5\u4F53\uFF0C\u4F60\u53EF\u4EE5\u8F7B\u677E\u5730\u8C03\u7528\u5B83\u8FDB\u884C\u914D\u7F6E\u3002</p><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukihookapi/YukiHookAPI#configs-method">YukiHookAPI.configs</a> \u65B9\u6CD5\u3002</p></div><h2 id="hooker-\u914D\u7F6E" tabindex="-1"><a class="header-anchor" href="#hooker-\u914D\u7F6E" aria-hidden="true">#</a> Hooker \u914D\u7F6E</h2><blockquote><p>\u4E00\u4E2A Xposed \u6A21\u5757\u6216 Hook API \u6700\u91CD\u8981\u7684\u5730\u65B9\u5C31\u662F Hooker \u7684\u521B\u5EFA\u4E0E\u4F7F\u7528\uFF0C<code>YukiHookAPI</code> \u63D0\u4F9B\u4E86\u4E24\u79CD\u4F7F\u7528\u65B9\u6CD5\u3002</p></blockquote><h3 id="\u901A\u8FC7-lambda-\u521B\u5EFA" tabindex="-1"><a class="header-anchor" href="#\u901A\u8FC7-lambda-\u521B\u5EFA" aria-hidden="true">#</a> \u901A\u8FC7 lambda \u521B\u5EFA</h3><blockquote><p>\u8FD9\u79CD\u65B9\u6848\u662F\u6700\u7B80\u5355\u7684\uFF0C\u5982\u679C\u4F60\u7684\u6A21\u5757\u529F\u80FD\u4E0D\u591A\uFF0C\u4EE3\u7801\u6570\u91CF\u4E0D\u5927\uFF0C\u4E0D\u9700\u8981\u8FDB\u884C\u5206\u7C7B\u5904\u7406\uFF0C\u63A8\u8350\u4F7F\u7528\u8FD9\u79CD\u65B9\u5F0F\u8FDB\u884C\u521B\u5EFA\u3002</p></blockquote><h4 id="encase-\u65B9\u6CD5" tabindex="-1"><a class="header-anchor" href="#encase-\u65B9\u6CD5" aria-hidden="true">#</a> encase \u65B9\u6CD5</h4><div class="language-kotlin ext-kt"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">encase</span><span style="color:#ADBAC7;">(initiate</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">PackageParam</span><span style="color:#ADBAC7;">.() </span><span style="color:#F47067;">-&gt;</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">Unit</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre></div><p><code>encase</code> \u65B9\u6CD5\u662F Hook \u4E00\u5207\u751F\u547D\u7684\u5F00\u59CB\uFF0C\u5728\u4E00\u4E2A\u6A21\u5757\u6216\u4E00\u4E2A Hook \u8FC7\u7A0B\u4E2D\uFF0C<code>encase</code> \u65B9\u6CD5\u53EA\u80FD\u4F5C\u7528\u4E00\u6B21\uFF0C\u7528\u4E8E\u521B\u5EFA Hooker\u3002</p><p><code>PackageParam</code> \u4E3A\u5BBF\u4E3B(\u76EE\u6807 APP)\u7684\u91CD\u8981\u5B9E\u4F8B\u5BF9\u8C61\uFF0C\u901A\u8FC7 <code>PackageParam</code> \u6765\u5B9E\u73B0\u5BF9\u5F53\u524D Hook \u4F5C\u7528\u5BF9\u8C61\u7684\u5168\u90E8 Hook \u64CD\u4F5C\u3002</p><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukihookapi/hook/param/PackageParam">PackageParam</a>\u3002</p></div><p><code>encase</code> \u65B9\u6CD5\u53EF\u4EE5\u5728 <code>onHook</code> \u65B9\u6CD5\u4E2D\u4F7F\u7528\u4E24\u79CD\u65B9\u6848\u521B\u5EFA\u3002</p><blockquote><p>\u793A\u4F8B\u4EE3\u7801 1</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F69D50;">YukiHookAPI</span><span style="color:#ADBAC7;">.encase {</span></span>
<span class="line"><span style="color:#ADBAC7;">    loadApp(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.example.demo&quot;</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        findClass(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;$packageName.DemoClass&quot;</span><span style="color:#ADBAC7;">).hook { </span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#768390;">// Your code here.</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>\u793A\u4F8B\u4EE3\u7801 2</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#ADBAC7;">encase {</span></span>
<span class="line"><span style="color:#ADBAC7;">    loadApp(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.example.demo&quot;</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        findClass(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;$packageName.DemoClass&quot;</span><span style="color:#ADBAC7;">).hook { </span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#768390;">// Your code here.</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u5728 <code>encase</code> \u65B9\u6CD5\u4E2D\u8FDB\u884C\u4F60\u7684 Hook \u64CD\u4F5C\u3002</p><h3 id="\u901A\u8FC7\u81EA\u5B9A\u4E49-hooker-\u521B\u5EFA" tabindex="-1"><a class="header-anchor" href="#\u901A\u8FC7\u81EA\u5B9A\u4E49-hooker-\u521B\u5EFA" aria-hidden="true">#</a> \u901A\u8FC7\u81EA\u5B9A\u4E49 Hooker \u521B\u5EFA</h3><blockquote><p>\u8FD9\u79CD\u65B9\u6848\u66F4\u52A0\u9002\u7528\u4E8E\u5927\u578B\u9879\u76EE\uFF0C\u4F8B\u5982\u9700\u8981\u5BF9 Hooker \u8FDB\u884C\u5206\u7C7B\u6216\u5BF9 Hook \u7684\u4F5C\u7528\u5BF9\u8C61\u8FDB\u884C\u5206\u7C7B\u3002</p></blockquote><h4 id="encase-\u65B9\u6CD5-1" tabindex="-1"><a class="header-anchor" href="#encase-\u65B9\u6CD5-1" aria-hidden="true">#</a> encase \u65B9\u6CD5</h4><div class="language-kotlin ext-kt"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">encase</span><span style="color:#ADBAC7;">(</span><span style="color:#F47067;">vararg</span><span style="color:#ADBAC7;"> hooker</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">YukiBaseHooker</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre></div><p>\u540C\u6837\u4E3A <code>encase</code> \u65B9\u6CD5\uFF0C\u8FD9\u91CC\u7684\u65B9\u6CD5\u53EF\u53D8\u6570\u7EC4\u53C2\u6570 <code>hooker</code> \u4E3A\u521B\u5EFA\u5165\u53E3\u63D0\u4F9B\u4E86\u4E00\u4E2A\u5BF9\u8C61\uFF0C\u4F60\u53EF\u4EE5\u5C06\u6240\u6709\u7EE7\u627F\u4E8E <code>YukiBaseHooker</code> \u7684 Hooker \u4E00\u6B21\u6027\u8FDB\u884C\u88C5\u8F7D\u3002</p><h4 id="yukibasehooker-\u7528\u6CD5" tabindex="-1"><a class="header-anchor" href="#yukibasehooker-\u7528\u6CD5" aria-hidden="true">#</a> YukiBaseHooker \u7528\u6CD5</h4><p><code>YukiBaseHooker</code> \u7EE7\u627F\u4E8E <code>PackageParam</code>\uFF0C\u4F60\u9700\u8981\u5C06\u4F60\u7684\u5B50 Hooker \u7EE7\u627F\u4E8E <code>YukiBaseHooker</code>\u3002</p><div class="custom-container tip"><p class="custom-container-title">\u5C0F\u63D0\u793A</p><p>\u66F4\u591A\u529F\u80FD\u8BF7\u53C2\u8003 <a href="../api/public/com/highcapable/yukihookapi/hook/entity/YukiBaseHooker">YukiBaseHooker</a>\u3002</p></div><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">object</span><span style="color:#ADBAC7;"> CustomHooker </span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">YukiBaseHooker</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">override</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">onHook</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// Your code here.</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u5B50 Hooker <strong>\u5EFA\u8BAE\u4F7F\u7528</strong>\u5355\u4F8B <code>object</code> \u521B\u5EFA\uFF0C\u4F60\u4E5F\u53EF\u4EE5\u4F7F\u7528 <code>class</code> \u4F46\u4E00\u822C\u60C5\u51B5\u4E0B\u4E0D\u63A8\u8350\u3002</p><div class="custom-container warning"><p class="custom-container-title">\u6CE8\u610F</p><p>\u4F60\u65E0\u9700\u518D\u5728\u7EE7\u627F\u4E8E <strong>YukiBaseHooker</strong> \u7684 <strong>onHook</strong> \u65B9\u6CD5\u4E2D\u91CD\u65B0\u8C03\u7528 <strong>encase</strong>\uFF0C\u8FD9\u662F\u9519\u8BEF\u7684\uFF0C\u4E14<strong>\u4E0D\u4F1A\u751F\u6548</strong>\uFF0C\u4F60\u5E94\u8BE5\u76F4\u63A5\u5F00\u59CB\u7F16\u5199\u4F60\u7684 Hook \u4EE3\u7801\u3002</p></div><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">object</span><span style="color:#ADBAC7;"> CustomHooker </span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">YukiBaseHooker</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">override</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">onHook</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        loadApp(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.example.demo1&quot;</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">            findClass(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;$packageName.DemoClass&quot;</span><span style="color:#ADBAC7;">).hook { </span></span>
<span class="line"><span style="color:#ADBAC7;">                </span><span style="color:#768390;">// Your code here.</span></span>
<span class="line"><span style="color:#ADBAC7;">            }</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">        loadApp(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.example.demo2&quot;</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">            findClass(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;$packageName.CustomClass&quot;</span><span style="color:#ADBAC7;">).hook { </span></span>
<span class="line"><span style="color:#ADBAC7;">                </span><span style="color:#768390;">// Your code here.</span></span>
<span class="line"><span style="color:#ADBAC7;">            }</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u4F5C\u4E3A\u5B50 Hooker \u4F7F\u7528\uFF0C\u4F60\u8FD8\u53EF\u4EE5\u5728\u5916\u90E8\u8C03\u7528 <code>loadApp</code> \u65B9\u6CD5\uFF0C\u7136\u540E\u5728\u5185\u90E8\u76F4\u63A5\u5F00\u59CB Hook\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">object</span><span style="color:#ADBAC7;"> HookEntry </span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">IYukiHookXposedInit</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">override</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">onHook</span><span style="color:#ADBAC7;">() </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> encase {</span></span>
<span class="line"><span style="color:#ADBAC7;">        loadApp(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.example.demo&quot;</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">ChildCustomHooker</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F47067;">object</span><span style="color:#ADBAC7;"> ChildCustomHooker </span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">YukiBaseHooker</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">override</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">onHook</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        findClass(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;$packageName.DemoClass&quot;</span><span style="color:#ADBAC7;">).hook { </span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#768390;">// Your code here.</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u4F60\u53EF\u4EE5\u4F7F\u7528 <code>loadHooker</code> \u65B9\u6CD5\u5728\u5B50 Hooker \u4E2D\u591A\u5C42\u88C5\u8F7D\u53E6\u4E00\u4E2A Hooker\uFF0C\u8BF7\u6309\u7167\u4F60\u7684\u559C\u597D\u8FDB\u884C\u5373\u53EF\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">object</span><span style="color:#ADBAC7;"> FirstHooker </span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">YukiBaseHooker</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">override</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">onHook</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        findClass(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;$packageName.DemoClass&quot;</span><span style="color:#ADBAC7;">).hook { </span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#768390;">// Your code here.</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">        loadHooker(</span><span style="color:#F69D50;">SecondHooker</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">        loadHooker(</span><span style="color:#F69D50;">ThirdHooker</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u642D\u5EFA\u5B8C\u5168\u90E8 Hooker \u540E\uFF0C\u4F60\u5C31\u53EF\u4EE5\u5728\u4F60\u7684 Hook \u5165\u53E3\u7C7B\u4E2D\u7684 <code>onHook</code> \u65B9\u6CD5\u4E2D\u88C5\u8F7D\u4F60\u7684 Hooker \u4E86\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">object</span><span style="color:#ADBAC7;"> HookEntry </span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">IYukiHookXposedInit</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">override</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">onHook</span><span style="color:#ADBAC7;">() </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#F69D50;">YukiHookAPI</span><span style="color:#ADBAC7;">.encase(</span><span style="color:#F69D50;">FirstHooker</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">SecondHooker</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">ThirdHooker</span><span style="color:#ADBAC7;"> ...)</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u5F53\u7136\uFF0C\u6211\u4EEC\u540C\u6837\u53EF\u4EE5\u5BF9\u5176\u8FDB\u884C\u7B80\u5199\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">object</span><span style="color:#ADBAC7;"> HookEntry </span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">IYukiHookXposedInit</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">override</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">onHook</span><span style="color:#ADBAC7;">() </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> encase(</span><span style="color:#F69D50;">FirstHooker</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">SecondHooker</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">ThirdHooker</span><span style="color:#ADBAC7;"> ...)</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="\u7279\u6B8A\u60C5\u51B5" tabindex="-1"><a class="header-anchor" href="#\u7279\u6B8A\u60C5\u51B5" aria-hidden="true">#</a> \u7279\u6B8A\u60C5\u51B5</h4><p>\u4E0A\u9762\u6211\u4EEC\u8BF4\u5230\uFF0C\u5728\u4E00\u822C\u60C5\u51B5\u4E0B\u4E0D\u63A8\u8350\u4F7F\u7528 <code>class</code> \u521B\u5EFA\u5B50 Hooker\uFF0C\u4F46\u662F\u6709\u4E00\u79CD\u7279\u6B8A\u60C5\u51B5\uFF0C\u5B83\u53EF\u80FD\u4F9D\u7136\u9700\u8981\u4FDD\u6301\u4F60\u7684 Hooker \u652F\u6301\u591A\u4F8B\u3002</p><p>\u6709\u6781\u5C11\u7684\u53EF\u80FD\u6027\u4F1A\u51FA\u73B0\u5728\u4E00\u4E2A\u8FDB\u7A0B\u4E2D\u5B58\u5728\u591A\u4E2A\u5305\u540D\u7684\u60C5\u51B5\uFF0C\u8FD9\u79CD\u60C5\u51B5\u4E0B\uFF0C<code>YukiHookAPI</code> \u53D1\u73B0\u5B50 Hooker \u4E3A\u5355\u4F8B\u65F6\uFF0C\u5C06\u4F1A\u5FFD\u7565\u5E76\u6253\u5370\u4E00\u6761\u8B66\u544A\u4FE1\u606F\u3002</p><div class="language-text ext-text"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#adbac7;">This Hooker &quot;HOOKER&quot; is singleton or reused, but the current process has multiple package name &quot;NAME&quot;, the original is &quot;NAME&quot;</span></span>
<span class="line"><span style="color:#adbac7;">Make sure your Hooker supports multiple instances for this situation</span></span>
<span class="line"><span style="color:#adbac7;">The process with package name &quot;NAME&quot; will be ignored</span></span>
<span class="line"><span style="color:#adbac7;"></span></span></code></pre></div><p>\u9047\u5230\u8FD9\u79CD\u60C5\u51B5\u65F6\uFF0C\u6211\u4EEC\u53EA\u9700\u8981\u4FEE\u6539 <code>object</code> \u4E3A <code>class</code> \u6216\u8005\u5728\u88C5\u8F7D\u65F6\u5224\u65AD\u5305\u540D\u540E\u518D\u88C5\u8F7D\u5B50 Hooker\u3002</p><p>\u4F8B\u5982\u4EE5\u4E0A\u60C5\u51B5\u4E2D\u53EF\u4F7F\u7528\u4EE5\u4E0B\u5F62\u5F0F\u6765\u88C5\u8F7D\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#ADBAC7;">encase {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5047\u8BBE\u8FD9\u4E2A\u5C31\u662F\u4F60\u9700\u8981\u88C5\u8F7D\u7684 APP \u5305\u540D\u548C\u5B50 Hooker</span></span>
<span class="line"><span style="color:#ADBAC7;">    loadApp(</span><span style="color:#96D0FF;">&quot;com.example.demo&quot;</span><span style="color:#ADBAC7;">, </span><span style="color:#F69D50;">YourCustomHooker</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="\u6269\u5C55\u7279\u6027" tabindex="-1"><a class="header-anchor" href="#\u6269\u5C55\u7279\u6027" aria-hidden="true">#</a> \u6269\u5C55\u7279\u6027</h3><p>\u5982\u679C\u4F60\u5F53\u524D\u4F7F\u7528\u7684 Hook Framework \u652F\u6301\u5E76\u542F\u7528\u4E86\u8D44\u6E90\u94A9\u5B50(Resources Hook)\u529F\u80FD\uFF0C\u4F60\u73B0\u5728\u53EF\u4EE5\u76F4\u63A5\u5728 <code>encase</code> \u4E2D\u521B\u5EFA Resources Hook\u3002</p><p>\u4F60\u5B8C\u5168\u4E0D\u9700\u8981\u4E0E\u4E4B\u524D\u5728\u4F7F\u7528 Xposed API \u90A3\u6837\u533A\u5206 <code>initZygote</code>\u3001<code>handleLoadPackage</code>\u3001<code>handleInitPackageResources</code> \u65B9\u6CD5\u6765\u6267\u884C\u4E0D\u540C\u7684\u529F\u80FD\u3002</p><p>\u5728 <code>YukiHookAPI</code> \u4E2D\uFF0C\u8FD9\u4E9B\u529F\u80FD<strong>\u662F\u65E0\u7F1D\u7684</strong>\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#ADBAC7;">encase {</span></span>
<span class="line"><span style="color:#ADBAC7;">    loadApp(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.example.demo&quot;</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        findClass(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;$packageName.DemoClass&quot;</span><span style="color:#ADBAC7;">).hook { </span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#768390;">// Your code here.</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u521B\u5EFA\u4E00\u4E2A Resources Hook (\u56FA\u5B9A\u7528\u6CD5)</span></span>
<span class="line"><span style="color:#ADBAC7;">        resources().hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#768390;">// Your code here.</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u4F60\u8FD8\u53EF\u4EE5\u540C\u65F6\u4F7F\u7528 <code>loadZygote</code> \u65B9\u6CD5\u6765\u88C5\u8F7D\u65B0\u7684\u8FDB\u7A0B\u88AB fork \u540E\u7684\u7B2C\u4E00\u4E2A\u4E8B\u4EF6 <code>initZygote</code>\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#ADBAC7;">encase {</span></span>
<span class="line"><span style="color:#ADBAC7;">    loadZygote {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#F69D50;">ActivityClass</span><span style="color:#ADBAC7;">.hook { </span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#768390;">// Your code here.</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u5728 Zygote \u4E2D\u521B\u5EFA Resources Hook</span></span>
<span class="line"><span style="color:#ADBAC7;">        resources().hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#768390;">// Your code here.</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">    loadApp(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.example.demo&quot;</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        findClass(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;$packageName.DemoClass&quot;</span><span style="color:#ADBAC7;">).hook { </span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#768390;">// Your code here.</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u5728 APP \u4E2D\u521B\u5EFA Resources Hook</span></span>
<span class="line"><span style="color:#ADBAC7;">        resources().hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#768390;">// Your code here.</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="\u6CE8\u610F\u4E8B\u9879" tabindex="-1"><a class="header-anchor" href="#\u6CE8\u610F\u4E8B\u9879" aria-hidden="true">#</a> \u6CE8\u610F\u4E8B\u9879</h3><p>\u76F4\u63A5\u88C5\u8F7D Hooker \u6216\u76F4\u63A5\u5F00\u59CB Hook \u662F\u9519\u8BEF\u7684\uFF0C<code>encase</code> \u4E8B\u4EF6\u5728\u88AB Hook Framework \u88C5\u8F7D\u540E\uFF0C\u4F1A\u7ECF\u5386\u4E09\u6B21\u56DE\u8C03\u3002</p><ul><li><p>\u88C5\u8F7D <code>initZygote</code> \u2192 <code>encase</code></p></li><li><p>\u88C5\u8F7D <code>handleLoadPackage</code> \u2192 <code>encase</code></p></li><li><p>\u88C5\u8F7D <code>handleInitPackageResources</code> \u2192 <code>encase</code></p></li></ul><p>\u5728\u8FD9\u4E2A\u8FC7\u7A0B\u4E2D\uFF0C\u4F60\u9700\u8981\u4F7F\u7528 <code>loadApp</code>\u3001<code>loadSystem</code>\u3001<code>loadZygote</code> \u6765\u533A\u5206\u6BCF\u4E00\u6B21\u88C5\u8F7D\u4EE3\u7801\u7684\u8C03\u7528\u57DF\uFF0C\u5426\u5219\u4F60\u7684\u4EE3\u7801\u5C31\u4F1A\u88AB<u><strong>\u591A\u6B21\u6267\u884C\u9020\u6210\u9519\u8BEF</strong></u>\u3002</p><div class="custom-container warning"><p class="custom-container-title">\u6CE8\u610F</p><p>\u65E0\u8BBA\u4F7F\u7528 <strong>encase</strong> \u521B\u5EFA <strong>lambda</strong> \u65B9\u6CD5\u4F53\u8FD8\u662F\u76F4\u63A5\u4F7F\u7528 Hooker \u5F62\u5F0F\uFF0C\u4F60\u90FD\u4E0D\u5E94\u8BE5\u76F4\u63A5\u5728\u9996\u4E2A <strong>onHook</strong> \u4E8B\u4EF6\u4E2D\u76F4\u63A5\u88C5\u8F7D Hooker \u6216\u76F4\u63A5\u5F00\u59CB Hook\u3002</p></div><p>\u4E0B\u9762\u662F\u4E24\u4E2A<strong>\u9519\u8BEF</strong>\u793A\u4F8B\u3002</p><blockquote><p>\u793A\u4F8B\u4EE3\u7801 1</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#ADBAC7;">encase {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u2757\u9519\u8BEF\u7684\u4F7F\u7528\u65B9\u6CD5\uFF0C\u4E0D\u80FD\u76F4\u63A5\u5F00\u59CB Hook</span></span>
<span class="line"><span style="color:#ADBAC7;">    findClass(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.example.demo.DemoClass&quot;</span><span style="color:#ADBAC7;">).hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u2757\u9519\u8BEF\u7684\u4F7F\u7528\u65B9\u6CD5\uFF0C\u4E0D\u80FD\u76F4\u63A5\u5F00\u59CB Hook</span></span>
<span class="line"><span style="color:#ADBAC7;">    resources().hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>\u793A\u4F8B\u4EE3\u7801 2</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">object</span><span style="color:#ADBAC7;"> HookEntry </span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">IYukiHookXposedInit</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">override</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">onHook</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// &lt;\u60C5\u666F1&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">        encase {</span></span>
<span class="line"><span style="color:#ADBAC7;">            loadHooker(</span><span style="color:#F69D50;">CustomHooker</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// &lt;\u60C5\u666F2&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">        encase(</span><span style="color:#F69D50;">CustomHooker</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F47067;">object</span><span style="color:#ADBAC7;"> CustomHooker </span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">YukiBaseHooker</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">override</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">onHook</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u2757\u9519\u8BEF\u7684\u4F7F\u7528\u65B9\u6CD5\uFF0C\u7531\u4E8E\u5916\u5C42\u6CA1\u6709\u4EFB\u4F55\u5224\u65AD\u5BF9\u8C61\uFF0C\u4E0D\u80FD\u76F4\u63A5\u5F00\u59CB Hook</span></span>
<span class="line"><span style="color:#ADBAC7;">        findClass(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.example.demo.DemoClass&quot;</span><span style="color:#ADBAC7;">).hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>\u4E0B\u9762\u662F\u4E0A\u8FF0\u9519\u8BEF\u793A\u4F8B\u7684<strong>\u6B63\u786E</strong>\u793A\u4F8B\u3002</p><blockquote><p>\u793A\u4F8B\u4EE3\u7801 1</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#ADBAC7;">encase {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u2705 \u6B63\u786E\u7684\u4F7F\u7528\u65B9\u6CD5\uFF0C\u5728 Zygote \u4E2D\u88C5\u8F7D</span></span>
<span class="line"><span style="color:#ADBAC7;">    loadZygote(</span><span style="color:#F69D50;">CustomHooker</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">     </span><span style="color:#768390;">// \u2705 \u6B63\u786E\u7684\u4F7F\u7528\u65B9\u6CD5\uFF0C\u5728 Zygote \u4E2D\u88C5\u8F7D</span></span>
<span class="line"><span style="color:#ADBAC7;">    loadZygote {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u2705 \u6B63\u786E\u7684\u4F7F\u7528\u65B9\u6CD5\uFF0C\u5728 Zygote \u5185 Hook</span></span>
<span class="line"><span style="color:#ADBAC7;">        resources().hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u2705 \u6B63\u786E\u7684\u4F7F\u7528\u65B9\u6CD5\uFF0C\u4F7F\u7528 APP \u4F5C\u7528\u57DF\u88C5\u8F7D</span></span>
<span class="line"><span style="color:#ADBAC7;">    loadApp(</span><span style="color:#768390;">/** name \u53C2\u6570\u53EF\u9009 */</span><span style="color:#ADBAC7;">, hooker </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">CustomHooker</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u2705 \u6B63\u786E\u7684\u4F7F\u7528\u65B9\u6CD5\uFF0C\u5224\u65AD APP \u4F5C\u7528\u57DF\u540E\u518D\u88C5\u8F7D Hooker</span></span>
<span class="line"><span style="color:#ADBAC7;">    loadApp(</span><span style="color:#768390;">/** name \u53C2\u6570\u53EF\u9009 */</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        loadHooker(</span><span style="color:#F69D50;">CustomHooker</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">         </span><span style="color:#768390;">// \u2705 \u6B63\u786E\u7684\u4F7F\u7528\u65B9\u6CD5\uFF0C\u5728 APP \u4F5C\u7528\u57DF\u5185 Hook</span></span>
<span class="line"><span style="color:#ADBAC7;">        findClass(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.example.demo.DemoClass&quot;</span><span style="color:#ADBAC7;">).hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u2705 \u6B63\u786E\u7684\u4F7F\u7528\u65B9\u6CD5\uFF0C\u5728 APP \u4F5C\u7528\u57DF\u5185 Hook</span></span>
<span class="line"><span style="color:#ADBAC7;">        resources().hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">            </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>\u793A\u4F8B\u4EE3\u7801 2</p></blockquote><div class="language-kotlin ext-kt line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">object</span><span style="color:#ADBAC7;"> HookEntry </span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">IYukiHookXposedInit</span><span style="color:#ADBAC7;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">override</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">onHook</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        encase(</span><span style="color:#F69D50;">CustomHooker</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F47067;">object</span><span style="color:#ADBAC7;"> CustomHooker </span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">YukiBaseHooker</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F47067;">override</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">onHook</span><span style="color:#ADBAC7;">() {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u2705 \u6B63\u786E\u7684\u4F7F\u7528\u65B9\u6CD5\uFF0C\u7531\u4E8E\u5916\u5C42\u6CA1\u6709\u4EFB\u4F55\u5224\u65AD\u5BF9\u8C61\uFF0C\u9700\u8981\u5224\u65AD APP \u4F5C\u7528\u57DF\u540E\u518D\u8FDB\u884C Hook</span></span>
<span class="line"><span style="color:#ADBAC7;">        loadApp(</span><span style="color:#768390;">/** name \u53C2\u6570\u53EF\u9009 */</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">            findClass(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.example.demo.DemoClass&quot;</span><span style="color:#ADBAC7;">).hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">                </span><span style="color:#768390;">// ...</span></span>
<span class="line"><span style="color:#ADBAC7;">            }</span></span>
<span class="line"><span style="color:#ADBAC7;">        }</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="\u4F5C\u4E3A-hook-api-\u4F7F\u7528\u9700\u8981\u6CE8\u610F\u7684\u5730\u65B9" tabindex="-1"><a class="header-anchor" href="#\u4F5C\u4E3A-hook-api-\u4F7F\u7528\u9700\u8981\u6CE8\u610F\u7684\u5730\u65B9" aria-hidden="true">#</a> \u4F5C\u4E3A Hook API \u4F7F\u7528\u9700\u8981\u6CE8\u610F\u7684\u5730\u65B9</h2><p>\u82E5\u4F60\u4F5C\u4E3A Hook API \u4F7F\u7528\uFF0C\u90A3\u4E48\u4F60\u53EA\u9700\u8981\u5728\u5165\u53E3\u5904\u5BF9 <code>encase</code> \u65B9\u6CD5\u8FDB\u884C\u533A\u5206\u3002</p><div class="custom-container warning"><p class="custom-container-title">\u6CE8\u610F</p><p><strong>encase</strong> \u65B9\u6CD5\u5BF9\u4F5C\u4E3A Hook API \u4F7F\u7528\u63D0\u4F9B\u4E86\u4E24\u4E2A\u5B8C\u5168\u4E00\u6837\u7684\u65B9\u6CD5\uFF0C\u4F46\u662F\u6BD4\u524D\u4E24\u8005\u4EC5\u591A\u51FA\u4E00\u4E2A\u53C2\u6570 <strong>baseContext</strong>\u3002</p></div><blockquote><p>\u65B9\u6CD5 1</p></blockquote><div class="language-kotlin ext-kt"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">encase</span><span style="color:#ADBAC7;">(baseContext</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Context?</span><span style="color:#ADBAC7;">, initiate</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">PackageParam</span><span style="color:#ADBAC7;">.() </span><span style="color:#F47067;">-&gt;</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">Unit</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre></div><blockquote><p>\u65B9\u6CD5 2</p></blockquote><div class="language-kotlin ext-kt"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#F47067;">fun</span><span style="color:#ADBAC7;"> </span><span style="color:#DCBDFB;">encase</span><span style="color:#ADBAC7;">(baseContext</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Context?</span><span style="color:#ADBAC7;">, </span><span style="color:#F47067;">vararg</span><span style="color:#ADBAC7;"> hooker</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">YukiBaseHooker</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"></span></code></pre></div><p>\u6B64\u5904\u7684 <code>baseContext</code> \u53EA\u9700\u586B\u5165\u4F60\u5728 <code>attachBaseContext</code> \u5904\u5F97\u5230\u7684 <code>Context</code> \u5373\u53EF\uFF0C\u5176\u5B83\u7528\u6CD5\u4E0E\u4E0A\u8FF0\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4\u3002</p><div class="custom-container danger"><p class="custom-container-title">\u7279\u522B\u6CE8\u610F</p><p>\u5207\u52FF\u4EE5 Xposed \u65B9\u5F0F\u4F7F\u7528 <strong>encase</strong> \u65B9\u6CD5\u800C\u6F0F\u6389 <strong>baseContext</strong> \u53C2\u6570\uFF0C\u5426\u5219\u4F60\u7684 Hook \u5C06\u5B8C\u5168\u4E0D\u5DE5\u4F5C\u3002</p><p>Resources Hook \u529F\u80FD\u4E0D\u652F\u6301\u4F5C\u4E3A Hook API \u4F7F\u7528\u3002</p></div>`,90),p=[o];function c(i,r){return n(),a("div",null,p)}const d=s(e,[["render",c],["__file","api-example.html.vue"]]);export{d as default};
