import{_ as o,r as p,o as c,c as i,b as s,d as e,a as l,e as n}from"./app.f643a53b.js";const r={},t=l(`<h1 id="\u7528\u6CD5\u793A\u4F8B" tabindex="-1"><a class="header-anchor" href="#\u7528\u6CD5\u793A\u4F8B" aria-hidden="true">#</a> \u7528\u6CD5\u793A\u4F8B</h1><blockquote><p>\u8FD9\u91CC\u4ECB\u7ECD\u4E86 <code>YukiHookAPI</code> \u7684\u57FA\u672C\u5DE5\u4F5C\u65B9\u5F0F\u4EE5\u53CA\u5217\u4E3E\u4E86\u7B80\u5355\u7684 Hook \u4F8B\u5B50\u548C\u5E38\u7528\u529F\u80FD\u3002</p></blockquote><h2 id="\u7ED3\u6784\u56FE\u89E3" tabindex="-1"><a class="header-anchor" href="#\u7ED3\u6784\u56FE\u89E3" aria-hidden="true">#</a> \u7ED3\u6784\u56FE\u89E3</h2><blockquote><p>\u4E0B\u65B9\u7684\u7ED3\u6784\u63CF\u8FF0\u4E86 <code>YukiHookAPI</code> \u7684\u57FA\u672C\u5DE5\u4F5C\u65B9\u5F0F\u548C\u539F\u7406\u3002</p></blockquote><div class="language-text ext-text"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#adbac7;">Host Environment</span></span>
<span class="line"><span style="color:#adbac7;">\u2514\u2500\u2500 YukiMemberHookCreator</span></span>
<span class="line"><span style="color:#adbac7;">    \u2514\u2500\u2500 Class</span></span>
<span class="line"><span style="color:#adbac7;">        \u2514\u2500\u2500 MemberHookCreator</span></span>
<span class="line"><span style="color:#adbac7;">            \u2514\u2500\u2500 Member</span></span>
<span class="line"><span style="color:#adbac7;">                \u251C\u2500\u2500 Before</span></span>
<span class="line"><span style="color:#adbac7;">                \u2514\u2500\u2500 After</span></span>
<span class="line"><span style="color:#adbac7;">            MemberHookCreator</span></span>
<span class="line"><span style="color:#adbac7;">            \u2514\u2500\u2500 Member</span></span>
<span class="line"><span style="color:#adbac7;">                \u251C\u2500\u2500 Before</span></span>
<span class="line"><span style="color:#adbac7;">                \u2514\u2500\u2500 After</span></span>
<span class="line"><span style="color:#adbac7;">            ...</span></span>
<span class="line"><span style="color:#adbac7;">    YukiResourcesHookCreator</span></span>
<span class="line"><span style="color:#adbac7;">    \u2514\u2500\u2500 Resources</span></span>
<span class="line"><span style="color:#adbac7;">        \u2514\u2500\u2500 ResourcesHookCreator</span></span>
<span class="line"><span style="color:#adbac7;">            \u2514\u2500\u2500 Drawable</span></span>
<span class="line"><span style="color:#adbac7;">                \u2514\u2500\u2500 Replace</span></span>
<span class="line"><span style="color:#adbac7;">            ResourcesHookCreator</span></span>
<span class="line"><span style="color:#adbac7;">            \u2514\u2500\u2500 Layout</span></span>
<span class="line"><span style="color:#adbac7;">                \u2514\u2500\u2500 Inject</span></span>
<span class="line"><span style="color:#adbac7;">            ...</span></span>
<span class="line"><span style="color:#adbac7;"></span></span></code></pre></div><blockquote><p>\u4E0A\u65B9\u7684\u7ED3\u6784\u6362\u505A\u4EE3\u7801\u5C06\u53EF\u5199\u4E3A\u5982\u4E0B\u5F62\u5F0F\u3002</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;">TargetClass</span><span style="color:#ADBAC7;">.hook { </span></span>
<span class="line"><span style="color:#ADBAC7;">    injectMember { </span></span>
<span class="line"><span style="color:#ADBAC7;">        method { </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;">        beforeHook {</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;">        afterHook {</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;">resources().hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">    injectResource {</span></span>
<span class="line"><span style="color:#ADBAC7;">        conditions {</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;">        replaceTo(...)</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><h2 id="demo" tabindex="-1"><a class="header-anchor" href="#demo" aria-hidden="true">#</a> Demo</h2><blockquote><p>\u4F60\u53EF\u4EE5\u5728\u4E0B\u65B9\u627E\u5230 API \u63D0\u4F9B\u7684 Demo \u6765\u5B66\u4E60 <code>YukiHookAPI</code> \u7684\u4F7F\u7528\u65B9\u6CD5\u3002</p></blockquote>`,9),d=n("\u5BBF\u4E3B APP Demo "),u={href:"https://github.com/fankes/YukiHookAPI/tree/master/demo-app",target:"_blank",rel:"noopener noreferrer"},A=n("\u70B9\u51FB\u8FD9\u91CC\u67E5\u770B"),v=n("\u6A21\u5757 APP Demo "),y={href:"https://github.com/fankes/YukiHookAPI/tree/master/demo-module",target:"_blank",rel:"noopener noreferrer"},m=n("\u70B9\u51FB\u8FD9\u91CC\u67E5\u770B"),b=l(`<p>\u540C\u65F6\u5B89\u88C5\u5BBF\u4E3B\u548C\u6A21\u5757 Demo\uFF0C\u901A\u8FC7\u6FC0\u6D3B\u6A21\u5757\u6765\u6D4B\u8BD5\u5BBF\u4E3B\u4E2D\u88AB Hook \u7684\u529F\u80FD\u3002</p><h2 id="\u4E00\u4E2A\u7B80\u5355\u7684-hook-\u4F8B\u5B50" tabindex="-1"><a class="header-anchor" href="#\u4E00\u4E2A\u7B80\u5355\u7684-hook-\u4F8B\u5B50" aria-hidden="true">#</a> \u4E00\u4E2A\u7B80\u5355\u7684 Hook \u4F8B\u5B50</h2><blockquote><p>\u8FD9\u91CC\u7ED9\u51FA\u4E86 Hook APP\u3001Hook \u7CFB\u7EDF\u6846\u67B6\u4E0E Hook Resources \u7B49\u4F8B\u5B50\uFF0C\u53EF\u4F9B\u53C2\u8003\u3002</p></blockquote><h3 id="hook-app" tabindex="-1"><a class="header-anchor" href="#hook-app" aria-hidden="true">#</a> Hook APP</h3><p>\u5047\u8BBE\uFF0C\u6211\u4EEC\u8981 Hook <code>com.android.browser</code> \u4E2D\u7684 <code>onCreate</code> \u65B9\u6CD5\u5E76\u5F39\u51FA\u4E00\u4E2A\u5BF9\u8BDD\u6846\u3002</p><p>\u5728 <code>encase</code> \u65B9\u6CD5\u4F53\u4E2D\u6DFB\u52A0\u4EE3\u7801\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;">loadApp(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.android.browser&quot;</span><span style="color:#ADBAC7;">) {</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;">        injectMember { </span></span>
<span class="line"><span style="color:#ADBAC7;">            method { </span></span>
<span class="line"><span style="color:#ADBAC7;">                name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;onCreate&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">                param(</span><span style="color:#F69D50;">BundleClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">                returnType </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">UnitType</span></span>
<span class="line"><span style="color:#ADBAC7;">            }</span></span>
<span class="line"><span style="color:#ADBAC7;">            afterHook {</span></span>
<span class="line"><span style="color:#ADBAC7;">                </span><span style="color:#F69D50;">AlertDialog</span><span style="color:#ADBAC7;">.</span><span style="color:#F69D50;">Builder</span><span style="color:#ADBAC7;">(instance())</span></span>
<span class="line"><span style="color:#ADBAC7;">                    .setTitle(</span><span style="color:#96D0FF;">&quot;Hooked&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">                    .setMessage(</span><span style="color:#96D0FF;">&quot;I am hook!&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">                    .setPositiveButton(</span><span style="color:#96D0FF;">&quot;OK&quot;</span><span style="color:#ADBAC7;">, </span><span style="color:#6CB6FF;">null</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">                    .show()</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><p>\u81F3\u6B64\uFF0C<code>onCreate</code> \u65B9\u6CD5\u5C06\u88AB\u6210\u529F Hook \u5E76\u5728 <code>com.android.browser</code> \u4E2D\u7684\u6BCF\u4E2A <code>Activity</code> \u542F\u52A8\u65F6\u5F39\u51FA\u6B64\u5BF9\u8BDD\u6846\u3002</p><p>\u90A3\u4E48\uFF0C\u6211\u60F3\u7EE7\u7EED Hook <code>onStart</code> \u65B9\u6CD5\u8981\u600E\u4E48\u505A\u5462\uFF1F</p><p>\u5728\u521A\u521A\u7684\u4EE3\u7801\u4E2D\uFF0C\u7EE7\u7EED\u63D2\u5165\u4E00\u4E2A <code>injectMember</code> \u65B9\u6CD5\u4F53\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:#ADBAC7;">loadApp(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.android.browser&quot;</span><span style="color:#ADBAC7;">) {</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;">        injectMember { </span></span>
<span class="line"><span style="color:#ADBAC7;">            method { </span></span>
<span class="line"><span style="color:#ADBAC7;">                name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;onCreate&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">                param(</span><span style="color:#F69D50;">BundleClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">                returnType </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">UnitType</span></span>
<span class="line"><span style="color:#ADBAC7;">            }</span></span>
<span class="line"><span style="color:#ADBAC7;">            afterHook {</span></span>
<span class="line"><span style="color:#ADBAC7;">                </span><span style="color:#F69D50;">AlertDialog</span><span style="color:#ADBAC7;">.</span><span style="color:#F69D50;">Builder</span><span style="color:#ADBAC7;">(instance())</span></span>
<span class="line"><span style="color:#ADBAC7;">                    .setTitle(</span><span style="color:#96D0FF;">&quot;Hooked&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">                    .setMessage(</span><span style="color:#96D0FF;">&quot;I am hook!&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">                    .setPositiveButton(</span><span style="color:#96D0FF;">&quot;OK&quot;</span><span style="color:#ADBAC7;">, </span><span style="color:#6CB6FF;">null</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">                    .show()</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;">        injectMember { </span></span>
<span class="line"><span style="color:#ADBAC7;">            method { </span></span>
<span class="line"><span style="color:#ADBAC7;">                name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;onStart&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">                emptyParam()</span></span>
<span class="line"><span style="color:#ADBAC7;">                returnType </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">UnitType</span></span>
<span class="line"><span style="color:#ADBAC7;">            }</span></span>
<span class="line"><span style="color:#ADBAC7;">            afterHook {</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 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>\u5BF9\u4E8E\u5F53\u524D\u9879\u76EE\u4E0B\u6CA1\u6709\u7684 <code>Class</code>\uFF0C\u4F60\u53EF\u4EE5\u4F7F\u7528 <code>stub</code> \u65B9\u5F0F\u6216 <code>findClass</code> \u65B9\u6CD5\u6765\u5F97\u5230\u9700\u8981 Hook \u7684\u7C7B\u3002</p><p>\u6BD4\u5982\uFF0C\u6211\u8981\u5F97\u5230 <code>com.example.demo.TestClass</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;">findClass(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.example.demo.TestClass&quot;</span><span style="color:#ADBAC7;">).hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">    injectMember {</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></div><p>\u82E5 <code>com.example.demo</code> \u662F\u4F60\u8981 Hook \u7684 APP\uFF0C\u90A3\u4E48\u5199\u6CD5\u53EF\u4EE5\u66F4\u7B80\u5355\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;">findClass(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;$packageName.TestClass&quot;</span><span style="color:#ADBAC7;">).hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">    injectMember {</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></div><p>\u5230\u8FD9\u91CC\u6709\u4E9B\u540C\u5B66\u53EF\u80FD\u5C31\u5F00\u59CB\u8BF4\u4E86\uFF0C\u5728\u67D0\u4E9B\u573A\u666F\u4E0B <code>findClass</code> \u663E\u5F97\u6709\u4E9B\u7E41\u7410\u3002</p><p>\u56E0\u4E3A\u53EF\u80FD\u6709\u4E9B\u540C\u5B66\u6709\u5982\u4E0B\u9700\u6C42\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;">const</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">TestClass</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.example.demo.TestClass&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F69D50;">TestClass</span><span style="color:#ADBAC7;">.hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">    injectMember {</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 class="line-number"></div></div></div><p>\u6CA1\u5173\u7CFB\uFF0C\u4F60\u8FD8\u53EF\u4EE5\u4F7F\u7528\u5B57\u7B26\u4E32\u7C7B\u540D\u76F4\u63A5\u521B\u5EFA\u4E00\u4E2A 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:#96D0FF;">&quot;$packageName.TestClass&quot;</span><span style="color:#ADBAC7;">.hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">    injectMember {</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></div><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/core/YukiMemberHookCreator#memberhookcreator-class">MemberHookCreator</a>\u3002</p></div><h3 id="hook-zygote" tabindex="-1"><a class="header-anchor" href="#hook-zygote" aria-hidden="true">#</a> Hook Zygote</h3><p>\u5728 APP \u542F\u52A8\u65F6\uFF0C\u65B0\u7684\u8FDB\u7A0B\u88AB fork \u540E\u7684\u7B2C\u4E00\u4E2A\u4E8B\u4EF6 <code>initZygote</code>\u3002</p><p>\u5047\u8BBE\u6211\u4EEC\u8981\u5168\u5C40 Hook \u4E00\u4E2A APP <code>Activity</code> \u7684 <code>onCreate</code> \u4E8B\u4EF6</p><p>\u5728 <code>encase</code> \u65B9\u6CD5\u4F53\u4E2D\u6DFB\u52A0\u4EE3\u7801\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;">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;">        injectMember { </span></span>
<span class="line"><span style="color:#ADBAC7;">            method { </span></span>
<span class="line"><span style="color:#ADBAC7;">                name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;onCreate&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">                param(</span><span style="color:#F69D50;">BundleClass</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">                returnType </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">UnitType</span></span>
<span class="line"><span style="color:#ADBAC7;">            }</span></span>
<span class="line"><span style="color:#ADBAC7;">            afterHook {</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></div><div class="custom-container warning"><p class="custom-container-title">\u6CE8\u610F</p><p>\u5728 <strong>loadZygote</strong> \u4E2D\u8FDB\u884C\u7684\u529F\u80FD\u5341\u5206\u6709\u9650\uFF0C\u51E0\u4E4E\u5F88\u5C11\u7684\u60C5\u51B5\u4E0B\u9700\u8981\u7528\u5230 <strong>loadZygote</strong> \u65B9\u6CD5\u3002</p></div><h3 id="hook-\u7CFB\u7EDF\u6846\u67B6" tabindex="-1"><a class="header-anchor" href="#hook-\u7CFB\u7EDF\u6846\u67B6" aria-hidden="true">#</a> Hook \u7CFB\u7EDF\u6846\u67B6</h3><p>\u5728 <code>YukiHookAPI</code> \u4E2D\uFF0CHook \u7CFB\u7EDF\u6846\u67B6\u7684\u5B9E\u73B0\u975E\u5E38\u7B80\u5355\u3002</p><p>\u5047\u8BBE\uFF0C\u4F60\u8981\u5F97\u5230 <code>ApplicationInfo</code> \u4E0E <code>PackageInfo</code> \u5E76\u5BF9\u5B83\u4EEC\u8FDB\u884C\u4E00\u4E9B\u64CD\u4F5C\u3002</p><p>\u5728 <code>encase</code> \u65B9\u6CD5\u4F53\u4E2D\u6DFB\u52A0\u4EE3\u7801\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;">loadSystem {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F69D50;">ApplicationInfoClass</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:#F69D50;">PackageInfoClass</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></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></div><div class="custom-container danger"><p class="custom-container-title">\u7279\u522B\u6CE8\u610F</p><p><strong>loadZygote</strong> \u4E0E <strong>loadSystem</strong> \u6709\u76F4\u63A5\u6027\u533A\u522B\uFF0C<strong>loadZygote</strong> \u4F1A\u5728 <strong>initZygote</strong> \u4E2D\u88C5\u8F7D\uFF0C\u7CFB\u7EDF\u6846\u67B6\u88AB\u89C6\u4E3A <strong>loadApp(name = &quot;android&quot;)</strong> \u800C\u5B58\u5728\uFF0C\u82E5\u8981 Hook \u7CFB\u7EDF\u6846\u67B6\uFF0C\u53EF\u76F4\u63A5\u4F7F\u7528 <strong>loadSystem</strong>\u3002</p></div><h3 id="hook-resources" tabindex="-1"><a class="header-anchor" href="#hook-resources" aria-hidden="true">#</a> Hook Resources</h3><p>\u5047\u8BBE\uFF0C\u6211\u4EEC\u8981 Hook <code>com.android.browser</code> \u4E2D <code>string</code> \u7C7B\u578B\u7684 <code>app_name</code> \u5185\u5BB9\u66FF\u6362\u4E3A <code>123</code>\u3002</p><p>\u5728 <code>encase</code> \u65B9\u6CD5\u4F53\u4E2D\u6DFB\u52A0\u4EE3\u7801\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;">loadApp(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.android.browser&quot;</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">    resources().hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">        injectResource {</span></span>
<span class="line"><span style="color:#ADBAC7;">            conditions {</span></span>
<span class="line"><span style="color:#ADBAC7;">                name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;app_name&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">                string()</span></span>
<span class="line"><span style="color:#ADBAC7;">            }</span></span>
<span class="line"><span style="color:#ADBAC7;">            replaceTo(</span><span style="color:#96D0FF;">&quot;123&quot;</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 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>\u82E5\u5F53\u524D APP \u4F7F\u7528 <code>app_name</code> \u8BBE\u7F6E\u4E86\u6807\u9898\u680F\u6587\u672C\uFF0C\u5219\u5B83\u5C31\u4F1A\u53D8\u6210\u6211\u4EEC\u7684 <code>123</code>\u3002</p><p>\u4F60\u8FD8\u53EF\u4EE5\u4F7F\u7528\u5F53\u524D Xposed \u6A21\u5757\u7684 Resources \u66FF\u6362 Hook APP \u7684 Resources\u3002</p><p>\u5047\u8BBE\uFF0C\u6211\u4EEC\u8981\u7EE7\u7EED Hook <code>com.android.browser</code> \u4E2D <code>mipmap</code> \u7C7B\u578B\u7684 <code>ic_launcher</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;">loadApp(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.android.browser&quot;</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">    resources().hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">        injectResource {</span></span>
<span class="line"><span style="color:#ADBAC7;">            conditions {</span></span>
<span class="line"><span style="color:#ADBAC7;">                name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;ic_launcher&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">                mipmap()</span></span>
<span class="line"><span style="color:#ADBAC7;">            }</span></span>
<span class="line"><span style="color:#ADBAC7;">            replaceToModuleResource(</span><span style="color:#F69D50;">R</span><span style="color:#ADBAC7;">.mipmap.ic_launcher)</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>\u81F3\u6B64\u76EE\u6807 APP \u7684\u56FE\u6807\u5C06\u4F1A\u88AB\u66FF\u6362\u4E3A\u6211\u4EEC\u8BBE\u7F6E\u7684\u56FE\u6807\u3002</p><p>\u82E5\u4F60\u60F3\u66FF\u6362\u7CFB\u7EDF\u6846\u67B6\u7684\u8D44\u6E90\uFF0C\u540C\u6837\u4E5F\u53EF\u4EE5\u8FD9\u6837\u5B9E\u73B0\uFF0C\u53EA\u9700\u8981\u628A <code>loadApp</code> \u6362\u6210 <code>loadZygote</code> \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:#ADBAC7;">loadZygote {</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></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><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/core/YukiResourcesHookCreator#resourceshookcreator-class">ResourcesHookCreator</a>\u3002</p></div><h3 id="\u89E3\u9664-hook" tabindex="-1"><a class="header-anchor" href="#\u89E3\u9664-hook" aria-hidden="true">#</a> \u89E3\u9664 Hook</h3><p>\u539F\u751F\u7684 Xposed \u4E3A\u6211\u4EEC\u63D0\u4F9B\u4E86\u4E00\u4E2A <code>XC_MethodHook.Unhook</code> \u529F\u80FD\uFF0C\u53EF\u4EE5\u4ECE Hook \u961F\u5217\u4E2D\u5C06\u5F53\u524D Hook \u79FB\u9664\uFF0C<code>YukiHookAPI</code> \u540C\u6837\u53EF\u4EE5\u5B9E\u73B0\u6B64\u529F\u80FD\u3002</p><p>\u7B2C\u4E00\u79CD\u65B9\u6CD5\uFF0C\u4FDD\u5B58\u5F53\u524D\u6CE8\u5165\u5BF9\u8C61\u7684 <code>Result</code> \u5B9E\u4F8B\uFF0C\u5728\u9002\u5F53\u7684\u65F6\u5019\u548C\u5730\u65B9\u8C03\u7528 <code>remove</code> \u5373\u53EF\u89E3\u9664\u8BE5\u6CE8\u5165\u5BF9\u8C61\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:#768390;">// \u8BBE\u7F6E\u4E00\u4E2A\u53D8\u91CF\u4FDD\u5B58\u5F53\u524D\u5B9E\u4F8B</span></span>
<span class="line"><span style="color:#F47067;">val</span><span style="color:#ADBAC7;"> hookResult </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> injectMember { </span></span>
<span class="line"><span style="color:#ADBAC7;">    method { </span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;test&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">        returnType </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">UnitType</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">    afterHook {</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:#768390;">// \u5728\u9002\u5F53\u7684\u65F6\u5019\u8C03\u7528\u5982\u4E0B\u65B9\u6CD5\u5373\u53EF</span></span>
<span class="line"><span style="color:#ADBAC7;">hookResult.remove()</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></div><p>\u7B2C\u4E8C\u79CD\u65B9\u6CD5\uFF0C\u5728 Hook \u56DE\u8C03\u65B9\u6CD5\u4E2D\u8C03\u7528 <code>removeSelf</code> \u79FB\u9664\u81EA\u8EAB\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;">injectMember { </span></span>
<span class="line"><span style="color:#ADBAC7;">    method { </span></span>
<span class="line"><span style="color:#ADBAC7;">        name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;test&quot;</span></span>
<span class="line"><span style="color:#ADBAC7;">        returnType </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">UnitType</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">    afterHook {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u76F4\u63A5\u8C03\u7528\u5982\u4E0B\u65B9\u6CD5\u5373\u53EF</span></span>
<span class="line"><span style="color:#ADBAC7;">        removeSelf()</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><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/core/YukiMemberHookCreator#memberhookcreator-class">MemberHookCreator</a>\u3002</p></div><h2 id="\u5F02\u5E38\u5904\u7406" tabindex="-1"><a class="header-anchor" href="#\u5F02\u5E38\u5904\u7406" aria-hidden="true">#</a> \u5F02\u5E38\u5904\u7406</h2><blockquote><p><code>YukiHookAPI</code> \u91CD\u65B0\u8BBE\u8BA1\u4E86\u5BF9\u5F02\u5E38\u7684\u76D1\u542C\uFF0C\u4EFB\u4F55\u5F02\u5E38\u90FD\u4E0D\u4F1A\u5728 Hook \u8FC7\u7A0B\u4E2D\u629B\u51FA\uFF0C\u907F\u514D\u6253\u65AD\u4E0B\u4E00\u4E2A Hook \u6D41\u7A0B\u5BFC\u81F4 Hook \u8FDB\u7A0B\u201C\u6B7B\u6389\u201D\u3002</p></blockquote><h3 id="\u76D1\u542C\u5F02\u5E38" tabindex="-1"><a class="header-anchor" href="#\u76D1\u542C\u5F02\u5E38" aria-hidden="true">#</a> \u76D1\u542C\u5F02\u5E38</h3><p>\u4F60\u53EF\u4EE5\u5904\u7406 Hook \u65B9\u6CD5\u8FC7\u7A0B\u53D1\u751F\u7684\u5F02\u5E38\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;">injectMember {</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;">}.result {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5904\u7406 Hook \u5F00\u59CB\u65F6\u7684\u5F02\u5E38</span></span>
<span class="line"><span style="color:#ADBAC7;">    onHookingFailure {}</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5904\u7406 Hook \u8FC7\u7A0B\u4E2D\u7684\u5F02\u5E38</span></span>
<span class="line"><span style="color:#ADBAC7;">    onConductFailure { param, throwable </span><span style="color:#F47067;">-&gt;</span><span style="color:#ADBAC7;"> }</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5904\u7406\u5168\u90E8\u5F02\u5E38</span></span>
<span class="line"><span style="color:#ADBAC7;">    onAllFailure {}</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></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>\u5728 Resources Hook \u65F6\u6B64\u65B9\u6CD5\u540C\u6837\u9002\u7528\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;">injectResource {</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;">}.result {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u5904\u7406 Hook \u65F6\u7684\u4EFB\u610F\u5F02\u5E38</span></span>
<span class="line"><span style="color:#ADBAC7;">    onHookingFailure {}</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></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>\u4F60\u8FD8\u53EF\u4EE5\u5904\u7406 Hook \u7684 <code>Class</code> \u4E0D\u5B58\u5728\u65F6\u53D1\u751F\u7684\u5F02\u5E38\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:#F69D50;">TargetClass</span><span style="color:#ADBAC7;">.hook {</span></span>
<span class="line"><span style="color:#ADBAC7;">    injectMember {</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;">}.onHookClassNotFoundFailure {</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></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>\u4F60\u8FD8\u53EF\u4EE5\u5904\u7406\u67E5\u627E\u65B9\u6CD5\u65F6\u7684\u5F02\u5E38\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;">method {</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;">}.onNoSuchMethod {</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></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><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/core/YukiMemberHookCreator#result-class">MemberHookCreator.Result</a>\u3001<a href="../api/public/com/highcapable/yukihookapi/hook/core/YukiResourcesHookCreator#result-class">ResourcesHookCreator.Result</a>\u3002</p></div><p>\u8FD9\u91CC\u4ECB\u7ECD\u4E86\u53EF\u80FD\u53D1\u751F\u7684\u5E38\u89C1\u5F02\u5E38\uFF0C\u82E5\u8981\u4E86\u89E3\u66F4\u591A\u8BF7\u53C2\u8003 <a href="../config/api-exception">API \u5F02\u5E38\u5904\u7406</a>\u3002</p><h3 id="\u629B\u51FA\u5F02\u5E38" tabindex="-1"><a class="header-anchor" href="#\u629B\u51FA\u5F02\u5E38" aria-hidden="true">#</a> \u629B\u51FA\u5F02\u5E38</h3><p>\u5728\u67D0\u4E9B\u60C5\u51B5\u4E0B\uFF0C\u4F60\u53EF\u4EE5<strong>\u624B\u52A8\u629B\u51FA\u5F02\u5E38</strong>\u6765\u8FBE\u5230\u63D0\u9192\u67D0\u4E9B\u529F\u80FD\u5B58\u5728\u95EE\u9898\u7684\u76EE\u7684\u3002</p><p>\u4E0A\u9762\u5DF2\u7ECF\u4ECB\u7ECD\u8FC7\uFF0C\u5728 <code>hook</code> \u65B9\u6CD5\u4F53\u5185\u629B\u51FA\u7684\u5F02\u5E38\u4F1A\u88AB <code>YukiHookAPI</code> \u63A5\u7BA1\uFF0C\u907F\u514D\u6253\u65AD\u4E0B\u4E00\u4E2A Hook \u6D41\u7A0B\u5BFC\u81F4 Hook \u8FDB\u7A0B\u201C\u6B7B\u6389\u201D\u3002</p><p>\u4EE5\u4E0B\u662F <code>YukiHookAPI</code> \u63A5\u7BA1\u65F6\u8FD9\u4E9B\u5F02\u5E38\u7684\u8FD0\u4F5C\u65B9\u5F0F\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:#768390;">// &lt;\u60C5\u666F1&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">injectMember {</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#F47067;">throw</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">RuntimeException</span><span style="color:#ADBAC7;">(</span><span style="color:#96D0FF;">&quot;Exception Test&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">    afterHook {</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;">}.result {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u80FD\u591F\u6355\u83B7\u5230 RuntimeException</span></span>
<span class="line"><span style="color:#ADBAC7;">    onHookingFailure {}</span></span>
<span class="line"><span style="color:#ADBAC7;">}</span></span>
<span class="line"><span style="color:#768390;">// &lt;\u60C5\u666F2&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">injectMember {</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</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;">    afterHook {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#F47067;">throw</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">RuntimeException</span><span style="color:#ADBAC7;">(</span><span style="color:#96D0FF;">&quot;Exception Test&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }</span></span>
<span class="line"><span style="color:#ADBAC7;">}.result {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u80FD\u591F\u6355\u83B7\u5230 RuntimeException</span></span>
<span class="line"><span style="color:#ADBAC7;">    onConductFailure { param, throwable </span><span style="color:#F47067;">-&gt;</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 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>\u4EE5\u4E0A\u60C5\u666F\u53EA\u4F1A\u5728 (Xposed) \u5BBF\u4E3B\u73AF\u5883\u88AB\u5904\u7406\uFF0C\u4E0D\u4F1A\u5BF9\u5BBF\u4E3B\u81EA\u8EAB\u9020\u6210\u4EFB\u4F55\u5F71\u54CD\u3002</p><p>\u82E5\u6211\u4EEC\u60F3\u5C06\u8FD9\u4E9B\u5F02\u5E38\u76F4\u63A5\u629B\u7ED9\u5BBF\u4E3B\uFF0C\u539F\u751F\u7684 Xposed \u4E3A\u6211\u4EEC\u63D0\u4F9B\u4E86 <code>param.throwable</code> \u65B9\u6CD5\uFF0C<code>YukiHookAPI</code> \u540C\u6837\u53EF\u4EE5\u5B9E\u73B0\u6B64\u529F\u80FD\u3002</p><p>\u82E5\u60F3\u5728 Hook \u56DE\u8C03\u65B9\u6CD5\u4F53\u4E2D\u5C06\u4E00\u4E2A\u5F02\u5E38\u76F4\u63A5\u629B\u7ED9\u5BBF\u4E3B\uFF0C\u53EF\u4EE5\u6709\u5982\u4E0B\u5B9E\u73B0\u65B9\u6CD5\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;">injectMember {</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</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;">    afterHook {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#F69D50;">RuntimeException</span><span style="color:#ADBAC7;">(</span><span style="color:#96D0FF;">&quot;Exception Test&quot;</span><span style="color:#ADBAC7;">).throwToApp()</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></div><p>\u4F60\u4E5F\u53EF\u4EE5\u76F4\u63A5\u5728 Hook \u56DE\u8C03\u65B9\u6CD5\u4F53\u4E2D\u629B\u51FA\u5F02\u5E38\uFF0C\u7136\u540E\u6807\u8BC6\u5C06\u5F02\u5E38\u629B\u7ED9\u5BBF\u4E3B\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;">injectMember {</span></span>
<span class="line"><span style="color:#ADBAC7;">    method {</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;">    afterHook {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#F47067;">throw</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">RuntimeException</span><span style="color:#ADBAC7;">(</span><span style="color:#96D0FF;">&quot;Exception Test&quot;</span><span style="color:#ADBAC7;">)</span></span>
<span class="line"><span style="color:#ADBAC7;">    }.onFailureThrowToApp()</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></div><p>\u4EE5\u4E0A\u4E24\u79CD\u65B9\u6CD5\u5747\u53EF\u5728\u5BBF\u4E3B\u63A5\u6536\u5230\u5F02\u5E38\u4ECE\u800C\u4F7F\u5BBF\u4E3B\u8FDB\u7A0B\u5D29\u6E83\u3002</p><div class="custom-container warning"><p class="custom-container-title">\u6CE8\u610F</p><p>\u4E3A\u4E86\u4FDD\u8BC1 Hook \u8C03\u7528\u57DF\u4E0E\u5BBF\u4E3B\u5185\u8C03\u7528\u57DF\u76F8\u4E92\u9694\u79BB\uFF0C\u5F02\u5E38\u53EA\u6709\u5728 <strong>beforeHook</strong> \u4E0E <strong>afterHook</strong> \u56DE\u8C03\u65B9\u6CD5\u4F53\u4E2D\u624D\u80FD\u629B\u7ED9\u5BBF\u4E3B\u3002</p></div><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/HookParam#throwable-throwtoapp-i-ext-method">Throwable.throwToApp</a>\u3001<a href="../api/public/com/highcapable/yukihookapi/hook/core/YukiMemberHookCreator#hookcallback-class">YukiMemberHookCreator.MemberMookCreator.HookCallback</a>\u3002</p></div><h2 id="\u72B6\u6001\u76D1\u542C" tabindex="-1"><a class="header-anchor" href="#\u72B6\u6001\u76D1\u542C" aria-hidden="true">#</a> \u72B6\u6001\u76D1\u542C</h2><p>\u5728\u4F7F\u7528 <code>XposedHelpers</code> \u7684\u540C\u5B66\u5F80\u5F80\u4F1A\u5728 Hook \u540E\u6253\u5370 <code>Unhook</code> \u7684\u65B9\u6CD5\u786E\u5B9A\u662F\u5426 Hook \u6210\u529F\u3002</p><p>\u5728 <code>YukiHookAPI</code> \u4E2D\uFF0C\u4F60\u53EF\u4EE5\u7528\u4EE5\u4E0B\u65B9\u6CD5\u65B9\u4FBF\u5730\u91CD\u65B0\u5B9E\u73B0\u8FD9\u4E2A\u529F\u80FD\u3002</p><p>\u9996\u5148\u6211\u4EEC\u53EF\u4EE5\u76D1\u542C Hook \u5DF2\u7ECF\u51C6\u5907\u5F00\u59CB\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:#F69D50;">YourClass</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;">}.onPrepareHook {</span></span>
<span class="line"><span style="color:#ADBAC7;">    loggerD(msg </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;$instanceClass hook start&quot;</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><div class="custom-container danger"><p class="custom-container-title">\u7279\u522B\u6CE8\u610F</p><p><strong>instanceClass</strong> \u5EFA\u8BAE\u53EA\u5728 <strong>onPrepareHook</strong> \u4E2D\u4F7F\u7528\uFF0C\u5426\u5219\u88AB Hook \u7684 <strong>Class</strong> \u4E0D\u5B58\u5728\u4F1A\u629B\u51FA\u65E0\u6CD5\u62E6\u622A\u7684\u5F02\u5E38\u5BFC\u81F4 Hook \u8FDB\u7A0B\u201C\u6B7B\u6389\u201D\u3002</p></div><p>\u7136\u540E\uFF0C\u6211\u4EEC\u8FD8\u53EF\u4EE5\u5BF9 Hook \u7684\u65B9\u6CD5\u7ED3\u679C\u8FDB\u884C\u76D1\u542C\u662F\u5426\u6210\u529F\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;">injectMember {</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;">}.onHooked { member </span><span style="color:#F47067;">-&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">    loggerD(msg </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;$member has hooked&quot;</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><h2 id="\u6269\u5C55\u7528\u6CD5" tabindex="-1"><a class="header-anchor" href="#\u6269\u5C55\u7528\u6CD5" aria-hidden="true">#</a> \u6269\u5C55\u7528\u6CD5</h2><blockquote><p>\u4F60\u53EF\u4EE5\u5728 Hook \u8FC7\u7A0B\u4E2D\u4F7F\u7528\u4E0B\u9762\u7684\u65B9\u6CD5\u65B9\u4FBF\u5730\u5B9E\u73B0\u5404\u79CD\u5224\u65AD\u548C\u529F\u80FD\u3002</p></blockquote><h3 id="\u591A\u4E2A\u5BBF\u4E3B" tabindex="-1"><a class="header-anchor" href="#\u591A\u4E2A\u5BBF\u4E3B" aria-hidden="true">#</a> \u591A\u4E2A\u5BBF\u4E3B</h3><p>\u5982\u679C\u4F60\u7684\u6A21\u5757\u9700\u8981\u540C\u65F6\u5904\u7406\u591A\u4E2A APP \u7684 Hook \u4E8B\u4EF6\uFF0C\u4F60\u53EF\u4EE5\u4F7F\u7528 <code>loadApp</code> \u65B9\u6CD5\u4F53\u6765\u533A\u5206\u4F60\u8981 Hook \u7684 APP\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;">loadApp(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.android.browser&quot;</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;">loadApp(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;com.android.phone&quot;</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></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><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#loadapp-method">PackageParam.loadApp</a>\u3002</p></div><h3 id="\u591A\u4E2A\u8FDB\u7A0B" tabindex="-1"><a class="header-anchor" href="#\u591A\u4E2A\u8FDB\u7A0B" aria-hidden="true">#</a> \u591A\u4E2A\u8FDB\u7A0B</h3><p>\u5982\u679C\u4F60 Hook \u7684\u5BBF\u4E3B APP \u6709\u591A\u4E2A\u8FDB\u7A0B\uFF0C\u4F60\u53EF\u4EE5\u4F7F\u7528 <code>withProcess</code> \u65B9\u6CD5\u4F53\u6765\u5BF9\u5B83\u4EEC\u5206\u522B\u8FDB\u884C 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:#ADBAC7;">withProcess(mainProcessName) {</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;">withProcess(name </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#96D0FF;">&quot;$packageName:tool&quot;</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></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><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#withprocess-method">PackageParam.withProcess</a>\u3002</p></div><h2 id="\u5199\u6CD5\u4F18\u5316" tabindex="-1"><a class="header-anchor" href="#\u5199\u6CD5\u4F18\u5316" aria-hidden="true">#</a> \u5199\u6CD5\u4F18\u5316</h2><p>\u4E3A\u4E86\u4F7F\u4EE3\u7801\u66F4\u52A0\u7B80\u6D01\uFF0C\u4F60\u53EF\u4EE5\u5220\u53BB <code>YukiHookAPI</code> \u7684\u540D\u79F0\uFF0C\u5C06\u4F60\u7684 <code>onHook</code> \u5165\u53E3\u5199\u4F5C <code>lambda</code> \u5F62\u5F0F\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;">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;">    </span><span style="color:#768390;">// Your code here.</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></div><h2 id="xposed-\u6A21\u5757\u72B6\u6001" tabindex="-1"><a class="header-anchor" href="#xposed-\u6A21\u5757\u72B6\u6001" aria-hidden="true">#</a> Xposed \u6A21\u5757\u72B6\u6001</h2><p>\u901A\u5E38\u60C5\u51B5\u4E0B\uFF0CXposed \u6A21\u5757\u7684\u5F00\u53D1\u8005\u90FD\u4F1A\u53BB\u9009\u62E9\u8BFB\u53D6\u5F53\u524D Xposed \u6A21\u5757\u7684\u6FC0\u6D3B\u4FE1\u606F\u4EE5\u66F4\u597D\u5730\u5411\u7528\u6237\u5C55\u793A\u5F53\u524D\u529F\u80FD\u7684\u751F\u6548\u72B6\u6001\u3002</p><p>\u9664\u4E86\u57FA\u672C\u7684 Hook \u529F\u80FD\uFF0C<code>YukiHookAPI</code> \u8FD8\u4E3A\u5F00\u53D1\u8005\u8BBE\u8BA1\u4E86\u4E00\u5957 Xposed \u6A21\u5757\u72B6\u6001\u5224\u65AD\u7684\u529F\u80FD\uFF0C\u5982\u6FC0\u6D3B\u72B6\u6001\u3001Hook Framework \u4FE1\u606F\u3002</p><h3 id="\u5224\u65AD\u81EA\u8EAB\u6FC0\u6D3B\u72B6\u6001" tabindex="-1"><a class="header-anchor" href="#\u5224\u65AD\u81EA\u8EAB\u6FC0\u6D3B\u72B6\u6001" aria-hidden="true">#</a> \u5224\u65AD\u81EA\u8EAB\u6FC0\u6D3B\u72B6\u6001</h3><p>\u901A\u5E38\u60C5\u51B5\u4E0B\uFF0C\u6211\u4EEC\u4F1A\u9009\u62E9\u5199\u4E00\u4E2A\u65B9\u6CD5\uFF0C\u4F7F\u5176\u8FD4\u56DE <code>false</code>\uFF0C\u7136\u540E Hook \u6389\u8FD9\u4E2A\u65B9\u6CD5\u4F7F\u5176\u8FD4\u56DE <code>true</code> \u6765\u8BC1\u660E Hook \u5DF2\u7ECF\u751F\u6548\u3002</p><p>\u5728 <code>YukiHookAPI</code> \u4E2D\u4F60\u5B8C\u5168\u4E0D\u9700\u8981\u518D\u8FD9\u4E48\u505A\u4E86\uFF0C<code>YukiHookAPI</code> \u5DF2\u7ECF\u5E2E\u4F60\u5C01\u88C5\u597D\u4E86\u8FD9\u4E2A\u64CD\u4F5C\uFF0C\u4F60\u53EF\u4EE5\u76F4\u63A5\u8FDB\u884C\u4F7F\u7528\u3002</p><p>\u73B0\u5728\uFF0C\u4F60\u53EF\u4EE5\u76F4\u63A5\u4F7F\u7528 <code>YukiHookAPI.Status.isXposedModuleActive</code> \u5728\u6A21\u5757\u4E2D\u5224\u65AD\u81EA\u8EAB\u662F\u5426\u88AB\u6FC0\u6D3B\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;">if</span><span style="color:#ADBAC7;">(</span><span style="color:#F69D50;">YukiHookAPI</span><span style="color:#ADBAC7;">.</span><span style="color:#F69D50;">Status</span><span style="color:#ADBAC7;">.isXposedModuleActive) {</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></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></div><p>\u7531\u4E8E\u4E00\u4E9B\u7279\u6B8A\u539F\u56E0\uFF0C\u5728\u592A\u6781\u3001\u65E0\u6781\u4E2D\u7684\u6A21\u5757\u65E0\u6CD5\u4F7F\u7528\u6807\u51C6\u65B9\u6CD5\u68C0\u6D4B\u6FC0\u6D3B\u72B6\u6001\u3002</p><p>\u6B64\u65F6\u4F60\u53EF\u4EE5\u4F7F\u7528 <code>YukiHookAPI.Status.isTaiChiModuleActive</code> \u5224\u65AD\u81EA\u8EAB\u662F\u5426\u88AB\u6FC0\u6D3B\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;">if</span><span style="color:#ADBAC7;">(</span><span style="color:#F69D50;">YukiHookAPI</span><span style="color:#ADBAC7;">.</span><span style="color:#F69D50;">Status</span><span style="color:#ADBAC7;">.isTaiChiModuleActive) {</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></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></div><p>\u82E5\u4F60\u60F3\u4F7F\u7528\u4E24\u8005\u5F97\u517C\u7684\u5224\u65AD\u65B9\u6848\uFF0C<code>YukiHookAPI</code> \u540C\u6837\u4E3A\u4F60\u5C01\u88C5\u4E86\u4FBF\u6377\u7684\u65B9\u5F0F\u3002</p><p>\u6B64\u65F6\u4F60\u53EF\u4EE5\u4F7F\u7528 <code>YukiHookAPI.Status.isModuleActive</code> \u5224\u65AD\u81EA\u8EAB\u662F\u5426\u5728 Xposed \u6216\u592A\u6781\u3001\u65E0\u6781\u4E2D\u88AB\u6FC0\u6D3B\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;">if</span><span style="color:#ADBAC7;">(</span><span style="color:#F69D50;">YukiHookAPI</span><span style="color:#ADBAC7;">.</span><span style="color:#F69D50;">Status</span><span style="color:#ADBAC7;">.isModuleActive) {</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></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></div><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#status-object">YukiHookAPI.Status</a>\u3002</p></div><div class="custom-container warning"><p class="custom-container-title">\u6CE8\u610F</p><p>\u5982\u679C\u4F60\u7684\u6A21\u5757 API \u7248\u672C\u9AD8\u4E8E 29 \u4E14\u6B63\u5728\u76EE\u6807 API \u4E3A 29 \u4EE5\u4E0A\u7684\u7CFB\u7EDF\u4E2D\u8FD0\u884C\uFF0C\u4F60\u9700\u8981\u5728 <strong>AndroidManifest.xml</strong> \u4E2D\u6DFB\u52A0\u5982\u4E0B\u6743\u9650\u58F0\u660E\u624D\u80FD\u6B63\u5E38\u5224\u65AD\u6A21\u5757\u5728\u592A\u6781\u3001\u65E0\u6781\u4E2D\u7684\u6FC0\u6D3B\u72B6\u6001\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-xml ext-xml line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#ADBAC7;">&lt;</span><span style="color:#8DDB8C;">queries</span><span style="color:#ADBAC7;">&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">    &lt;</span><span style="color:#8DDB8C;">intent</span><span style="color:#ADBAC7;">&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">        &lt;</span><span style="color:#8DDB8C;">action</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">android:name</span><span style="color:#ADBAC7;">=</span><span style="color:#96D0FF;">&quot;android.intent.action.MAIN&quot;</span><span style="color:#ADBAC7;"> /&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">    &lt;/</span><span style="color:#8DDB8C;">intent</span><span style="color:#ADBAC7;">&gt;</span></span>
<span class="line"><span style="color:#ADBAC7;">&lt;/</span><span style="color:#8DDB8C;">queries</span><span style="color:#ADBAC7;">&gt;</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>\u8FD8\u6709\u4E00\u79CD\u65B9\u6848\uFF0C\u4F60\u53EF\u4EE5\u76F4\u63A5\u58F0\u660E <strong>android.permission.QUERY_ALL_PACKAGES</strong> \u6743\u9650\uFF0C\u4F46\u662F\u4E0D\u63A8\u8350\u4E14\u4F1A\u88AB\u4EE3\u7801\u68C0\u67E5\u8B66\u544A\u3002</p><blockquote><p>\u793A\u4F8B\u5982\u4E0B</p></blockquote><div class="language-xml ext-xml line-numbers-mode"><pre class="shiki" style="background-color:#22272e;"><code><span class="line"><span style="color:#ADBAC7;">&lt;</span><span style="color:#8DDB8C;">uses-permission</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">android:name</span><span style="color:#ADBAC7;">=</span><span style="color:#96D0FF;">&quot;android.permission.QUERY_ALL_PACKAGES&quot;</span><span style="color:#ADBAC7;"> /&gt;</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>\u82E5\u6A21\u5757\u6FC0\u6D3B\u5224\u65AD\u4E2D\u5305\u542B\u592A\u6781\u3001\u65E0\u6781\u4E2D\u7684\u6FC0\u6D3B\u72B6\u6001\uFF0C\u5C31\u5FC5\u987B\u5C06\u6A21\u5757\u7684 <strong>Application</strong> \u7EE7\u627F\u4E8E <strong>ModuleApplication</strong> \u6216\u76F4\u63A5\u4F7F\u7528 <strong>ModuleApplication</strong>\u3002</p></div><h3 id="\u83B7\u53D6-hook-framework-\u4FE1\u606F" tabindex="-1"><a class="header-anchor" href="#\u83B7\u53D6-hook-framework-\u4FE1\u606F" aria-hidden="true">#</a> \u83B7\u53D6 Hook Framework \u4FE1\u606F</h3><p>\u9664\u4E86\u5224\u65AD\u81EA\u8EAB\u6FC0\u6D3B\u72B6\u6001\u4E4B\u5916\uFF0C\u4F60\u8FD8\u53EF\u4EE5\u901A\u8FC7 <code>YukiHookAPI.Status</code> \u4E2D\u7684 <code>Executor</code> \u6765\u83B7\u53D6\u5F53\u524D Hook Framework \u7684\u76F8\u5173\u4FE1\u606F\u3002</p><p>\u4F8B\u5982\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528 <code>YukiHookAPI.Status.Executor.name</code> \u6765\u83B7\u53D6\u5F53\u524D Hook Framework \u7684\u540D\u79F0\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;">val</span><span style="color:#ADBAC7;"> frameworkName </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">YukiHookAPI</span><span style="color:#ADBAC7;">.</span><span style="color:#F69D50;">Status</span><span style="color:#ADBAC7;">.</span><span style="color:#F69D50;">Executor</span><span style="color:#ADBAC7;">.name</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>\u6211\u4EEC\u8FD8\u53EF\u4EE5\u4F7F\u7528 <code>YukiHookAPI.Status.Executor.apiLevel</code> \u6765\u83B7\u53D6\u5F53\u524D Hook Framework \u7684 API Level\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;">val</span><span style="color:#ADBAC7;"> frameworkApiLevel </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">YukiHookAPI</span><span style="color:#ADBAC7;">.</span><span style="color:#F69D50;">Status</span><span style="color:#ADBAC7;">.</span><span style="color:#F69D50;">Executor</span><span style="color:#ADBAC7;">.apiLevel</span></span>
<span class="line"></span></code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><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#executor-object">YukiHookAPI.Status.Executor</a>\u3002</p></div><div class="custom-container warning"><p class="custom-container-title">\u6CE8\u610F</p><p><strong>1.0.91</strong> \u7248\u672C\u540E\u7684 <strong>YukiHookAPI</strong> \u4FEE\u6539\u4E86\u83B7\u53D6 Xposed \u6A21\u5757\u72B6\u6001\u7684\u903B\u8F91\u5224\u65AD\u65B9\u5F0F\uFF0C\u73B0\u5728\u4F60\u53EF\u4EE5\u5728\u6A21\u5757\u4E0E Hook APP (\u5BBF\u4E3B) \u4E2D\u540C\u65F6\u4F7F\u7528\u6B64 API\uFF1B</p><p>\u9700\u8981\u786E\u4FDD <strong>YukiHookAPI.Configs.isEnableHookModuleStatus</strong> \u662F\u542F\u7528\u72B6\u6001\uFF1B</p><p><strong>YukiHookAPI</strong> \u4EC5\u5BF9\u5DF2\u77E5\u7684\u83B7\u53D6\u65B9\u5F0F\u8FDB\u884C\u4E86\u5BF9\u63A5\uFF0C\u9664\u4E86\u63D0\u4F9B\u6807\u51C6 API \u7684 Hook Framework \u4E4B\u5916\uFF0C\u5176\u5B83\u60C5\u51B5\u4E0B\u6A21\u5757\u53EF\u80FD\u90FD\u5C06\u65E0\u6CD5\u5224\u65AD\u81EA\u5DF1\u662F\u5426\u88AB\u6FC0\u6D3B\u6216\u662F\u83B7\u53D6 Hook Framework \u7684\u76F8\u5173\u4FE1\u606F\u3002</p></div>`,155);function k(D,C){const a=p("ExternalLinkIcon");return c(),i("div",null,[t,s("ul",null,[s("li",null,[s("p",null,[d,s("a",u,[A,e(a)])])]),s("li",null,[s("p",null,[v,s("a",y,[m,e(a)])])])]),b])}const h=o(r,[["render",k],["__file","example.html.vue"]]);export{h as default};
