import{_ as l,r as p,o as c,c as r,b as s,d as e,a as o,e as n}from"./app.f643a53b.js";const t={},i=o(`<h1 id="\u4F5C\u4E3A-hook-api-\u4F7F\u7528\u7684\u76F8\u5173\u914D\u7F6E" tabindex="-1"><a class="header-anchor" href="#\u4F5C\u4E3A-hook-api-\u4F7F\u7528\u7684\u76F8\u5173\u914D\u7F6E" aria-hidden="true">#</a> \u4F5C\u4E3A Hook API \u4F7F\u7528\u7684\u76F8\u5173\u914D\u7F6E</h1><blockquote><p>\u4F5C\u4E3A Hook API \u901A\u5E38\u4E3A\u505A\u81EA\u8EAB APP \u70ED\u66F4\u65B0\u6216\u529F\u80FD\u9700\u8981\u4EE5\u53CA\u4EA7\u54C1\u6D4B\u8BD5\u7684 Hook \u64CD\u4F5C\u3002</p></blockquote><h2 id="\u4F9D\u8D56\u914D\u7F6E" tabindex="-1"><a class="header-anchor" href="#\u4F9D\u8D56\u914D\u7F6E" aria-hidden="true">#</a> \u4F9D\u8D56\u914D\u7F6E</h2><p>\u4F60\u53EA\u9700\u8981\u96C6\u6210 <code>com.highcapable.yukihookapi:api</code> \u4F9D\u8D56\u5373\u53EF\u3002</p><p>\u7136\u540E\u8BF7\u96C6\u6210\u4F60\u76EE\u6807\u4F7F\u7528\u7684 <code>Hook Framework</code> \u4F9D\u8D56\u3002</p><h2 id="\u5165\u53E3\u914D\u7F6E" tabindex="-1"><a class="header-anchor" href="#\u5165\u53E3\u914D\u7F6E" aria-hidden="true">#</a> \u5165\u53E3\u914D\u7F6E</h2><p>\u521B\u5EFA\u4F60\u7684\u81EA\u5B9A\u4E49 <code>Application</code>\u3002</p><p>\u5728 <code>attachBaseContext</code> \u4E2D\u6DFB\u52A0 <code>YukiHookAPI.encase</code> \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:#F47067;">class</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">MyApplication</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">Application</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;">attachBaseContext</span><span style="color:#ADBAC7;">(base</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Context?</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#768390;">// \u88C5\u8F7D Hook Framework</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 style="color:#768390;">// Your code here.</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 style="color:#768390;">// \u914D\u7F6E YukiHookAPI</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#F69D50;">YukiHookApi</span><span style="color:#ADBAC7;">.configs {</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;">// \u88C5\u8F7D YukiHookAPI</span></span>
<span class="line"><span style="color:#ADBAC7;">        </span><span style="color:#F69D50;">YukiHookAPI</span><span style="color:#ADBAC7;">.encase(base) {</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:#6CB6FF;">super</span><span style="color:#ADBAC7;">.attachBaseContext(base)</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>\u8FD9\u6837\uFF0C\u4F60\u5C31\u5B8C\u6210\u4E86 API \u7684\u76F8\u5173\u914D\u7F6E\u3002</p><p>\u4F60\u53EF\u4EE5 <a href="../config/api-example#%E4%BD%9C%E4%B8%BA-hook-api-%E4%BD%BF%E7%94%A8%E9%9C%80%E8%A6%81%E6%B3%A8%E6%84%8F%E7%9A%84%E5%9C%B0%E6%96%B9">\u70B9\u51FB\u8FD9\u91CC</a> \u67E5\u770B\u5F02\u540C\u70B9\u548C\u6CE8\u610F\u4E8B\u9879\u3002</p><div class="custom-container warning"><p class="custom-container-title">\u6CE8\u610F</p><p>\u4F60\u4E0D\u80FD\u518D\u4F7F\u7528 <strong>loadApp</strong> \u8FDB\u884C\u5305\u88C5\uFF0C\u53EF\u76F4\u63A5\u5F00\u59CB\u7F16\u5199\u4F60\u7684 Hook \u4EE3\u7801\u3002</p></div><h2 id="hook-framework" tabindex="-1"><a class="header-anchor" href="#hook-framework" aria-hidden="true">#</a> Hook Framework</h2><blockquote><p>\u8FD9\u91CC\u7ED9\u51FA\u4E86\u4E00\u4E9B\u8F83\u9AD8\u4F7F\u7528\u7387\u7684 <code>Hook Framework</code> \u5982\u4F55\u5BF9\u63A5 <code>YukiHookAPI</code> \u7684\u76F8\u5173\u65B9\u5F0F\u3002</p></blockquote>`,15),d={id:"pine",tabindex:"-1"},A=s("a",{class:"header-anchor",href:"#pine","aria-hidden":"true"},"#",-1),y=n(),u={href:"https://github.com/canyie/pine",target:"_blank",rel:"noopener noreferrer"},B=n("Pine"),C=o(`<blockquote><p><strong>\u6240\u9700 Xposed API \u4F9D\u8D56</strong> <code>top.canyie.pine:xposed</code></p></blockquote><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;">attachBaseContext</span><span style="color:#ADBAC7;">(base</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Context?</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u88C5\u8F7D Pine</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F69D50;">PineConfig</span><span style="color:#ADBAC7;">.debug </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#6CB6FF;">true</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F69D50;">PineConfig</span><span style="color:#ADBAC7;">.debuggable </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">BuildConfig</span><span style="color:#ADBAC7;">.</span><span style="color:#F69D50;">DEBUG</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u88C5\u8F7D YukiHookAPI</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F69D50;">YukiHookAPI</span><span style="color:#ADBAC7;">.encase(base) {</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:#6CB6FF;">super</span><span style="color:#ADBAC7;">.attachBaseContext(base)</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>`,3),D={id:"sandhook",tabindex:"-1"},h=s("a",{class:"header-anchor",href:"#sandhook","aria-hidden":"true"},"#",-1),v=n(),b={href:"https://github.com/asLody/SandHook",target:"_blank",rel:"noopener noreferrer"},k=n("SandHook"),m=o(`<blockquote><p><strong>\u6240\u9700 Xposed API \u4F9D\u8D56</strong> <code>com.swift.sandhook:xposedcompat</code> \u6216 <code>com.swift.sandhook:xposedcompat_new</code></p></blockquote><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;">attachBaseContext</span><span style="color:#ADBAC7;">(base</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Context?</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u88C5\u8F7D SandHook</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F69D50;">SandHookConfig</span><span style="color:#ADBAC7;">.</span><span style="color:#F69D50;">DEBUG</span><span style="color:#ADBAC7;"> </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">BuildConfig</span><span style="color:#ADBAC7;">.</span><span style="color:#F69D50;">DEBUG</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F69D50;">XposedCompat</span><span style="color:#ADBAC7;">.cacheDir </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> base?.cacheDir</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F69D50;">XposedCompat</span><span style="color:#ADBAC7;">.context </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> base</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F69D50;">XposedCompat</span><span style="color:#ADBAC7;">.classLoader </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> javaClass.classLoader</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F69D50;">XposedCompat</span><span style="color:#ADBAC7;">.isFirstApplication </span><span style="color:#F47067;">=</span><span style="color:#ADBAC7;"> base?.processName </span><span style="color:#F47067;">==</span><span style="color:#ADBAC7;"> base?.packageName</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u88C5\u8F7D YukiHookAPI</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F69D50;">YukiHookAPI</span><span style="color:#ADBAC7;">.encase(base) {</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:#6CB6FF;">super</span><span style="color:#ADBAC7;">.attachBaseContext(base)</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></div>`,3),F={id:"whale",tabindex:"-1"},_=s("a",{class:"header-anchor",href:"#whale","aria-hidden":"true"},"#",-1),g=n(),x={href:"https://github.com/asLody/whale",target:"_blank",rel:"noopener noreferrer"},f=n("Whale"),H=s("blockquote",null,[s("p",null,[s("strong",null,"\u6240\u9700 Xposed API \u4F9D\u8D56"),n(),s("code",null,"com.wind.xposed:xposed-on-whale")])],-1),P=n("\u8BF7\u53C2\u8003 "),I={href:"https://github.com/WindySha/xposed-hook-based-on-whale",target:"_blank",rel:"noopener noreferrer"},Y=n("xposed-hook-based-on-whale"),q=n("\u3002"),w=o(`<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;">attachBaseContext</span><span style="color:#ADBAC7;">(base</span><span style="color:#F47067;">:</span><span style="color:#ADBAC7;"> </span><span style="color:#F69D50;">Context?</span><span style="color:#ADBAC7;">) {</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u88C5\u8F7D Whale \u4E0D\u9700\u8981\u4EFB\u4F55\u914D\u7F6E</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#768390;">// \u88C5\u8F7D YukiHookAPI</span></span>
<span class="line"><span style="color:#ADBAC7;">    </span><span style="color:#F69D50;">YukiHookAPI</span><span style="color:#ADBAC7;">.encase(base) {</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:#6CB6FF;">super</span><span style="color:#ADBAC7;">.attachBaseContext(base)</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>`,2);function E(X,L){const a=p("ExternalLinkIcon");return c(),r("div",null,[i,s("h3",d,[A,y,s("a",u,[B,e(a)])]),C,s("h3",D,[h,v,s("a",b,[k,e(a)])]),m,s("h3",F,[_,g,s("a",x,[f,e(a)])]),H,s("p",null,[P,s("a",I,[Y,e(a)]),q]),w])}const S=l(t,[["render",E],["__file","api-using.html.vue"]]);export{S as default};
