Agent skill

Smali Bytecode Hooks

by kveld9 in kveld9/kveld-morphe-patches

Smali and Dalvik bytecode hooking guidelines, register architecture conventions, multi-return reverse traversal, TwoRegisterInstruction extraction, reflection bridges, and obfuscation guidelines.

GPL-3.0Auto-check passedMobile

Install Smali Bytecode Hooks

skills CLI
$ npx skills add kveld9/kveld-morphe-patches --skill smali-bytecode-hooks -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install kveld9/kveld-morphe-patches smali-bytecode-hooks --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/kveld9/kveld-morphe-patches.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/smali-bytecode-hooks .claude/skills/smali-bytecode-hooks && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
smali-bytecode-hooks
GitHub stars
112
Token cost
~1.6k tokens
SKILL.md length
336 words
Files
1
Skills in repo
4
Repo updated
First seen
Licence
GPL-3.0

At a glance

Smali and Dalvik bytecode hooking guidelines, register architecture conventions, multi-return reverse traversal, TwoRegisterInstruction extraction, reflection bridges, and obfuscation guidelines.

  • Works in 6 steps: Register Architecture & Essential… → Multi-Return Hooking & Reverse Traversal → Register Extraction & Instruction Sniffing → …
  • Mobile work in your project
  • SKILL.md covers 1. Register Architecture &…, 2. Multi-Return Hooking &…, 3. Register Extraction &… and 4. Multi-Branch & Label…, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Smali Bytecode Hooks is an agent skill from kveld9/kveld-morphe-patches. Smali and Dalvik bytecode hooking guidelines, register architecture conventions, multi-return reverse traversal, TwoRegisterInstruction extraction, reflection bridges, and obfuscation guidelines.

Its SKILL.md is about 1.6k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Mobile. It works with Android. The repository describes itself as: Custom Morphe patches on Android. The licence is GPL-3.0.

When your agent uses it

  • Mobile work in your project

Example prompts

  • “/smali-bytecode-hooks”

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. Register Architecture & Essential Extension Imports
  2. Multi-Return Hooking & Reverse Traversal
  3. Register Extraction & Instruction Sniffing
  4. Multi-Branch & Label Management
  5. Dynamic Reflection Bridges & Obfuscation Caveats
  6. Mandatory In-Situ Patcher Verification Gate

What it can do on your machine

Read from SKILL.md and the folder at commit bfc153e. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are kotlin and smali).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Smali Bytecode Hooks loads about 1.6k tokens when it runs. Until then it costs about 54 tokens; SKILL.md has 336 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~54
When it runs · the whole SKILL.md, loaded when a task matches
~1.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from kveld9/kveld-morphe-patches at commit bfc153e, republished under its GPL-3.0 licence (© kveld9). 336 words, ~1,584 tokens.

Download SKILL.mdSave it as .claude/skills/smali-bytecode-hooks/SKILL.md (or your agent's skills folder).
name
smali-bytecode-hooks
description
Smali and Dalvik bytecode hooking guidelines, register architecture conventions, multi-return reverse traversal, TwoRegisterInstruction extraction, reflection bridges, and obfuscation guidelines.

Smali & Dalvik Bytecode Hooking Guidelines

1. Register Architecture & Essential Extension Imports

In Dalvik bytecode, register naming follows strict calling conventions:

  • p0: Represents this in instance methods, or the 1st parameter in static methods.
  • p1, p2, ...: Subsequent incoming method arguments.
  • v0, v1, ...: Local registers allocated for computation within the method frame.
Required Patcher Extension Imports

Always import the core instruction helper extensions from app.morphe.patcher:

kotlin
import app.morphe.patcher.extensions.InstructionExtensions.addInstructions
import app.morphe.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.morphe.patcher.extensions.InstructionExtensions.getInstruction
Safe Return Overrides

When replacing a complete method body, calculate register usage and wipe existing instructions:

kotlin
fingerprint.method.apply {
    removeInstructions(0, implementation!!.instructions.count())
    addInstructions(0, """
        const/4 v0, 0x1
        return v0
    """.trimIndent())
}

2. Multi-Return Hooking & Reverse Traversal

When modifying or injecting hooks before return instructions (return-void, return-object, return), inserting instructions shifts the indices of all subsequent instructions within the method.

To maintain valid AST offsets without invalidating subsequent indices, always collect return indices and iterate in reverse order using .asReversed():

kotlin
val method = fingerprint.method
val returnIndices = method.implementation?.instructions?.withIndex()
    ?.filter { it.value.opcode == Opcode.RETURN_OBJECT }
    ?.map { it.index to (it.value as OneRegisterInstruction).registerA }
    ?.toList() ?: emptyList()

// Reverse iteration prevents index shifting
returnIndices.asReversed().forEach { (returnIndex, reg) ->
    method.addInstructions(
        returnIndex,
        """
            invoke-static {v$reg}, Lcom/kveld9/morphe/extension/Payload;->filter(Ljava/lang/Object;)V
        """.trimIndent(),
    )
}

3. Register Extraction & Instruction Sniffing

Never hardcode register numbers when modifying intermediate instructions. Extract dynamically allocated registers directly from the dexlib2 AST instruction nodes:

OneRegisterInstruction

Applies to instructions with a single register reference (e.g. return-object, move-result, check-cast):

kotlin
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction

val matchIndex = fingerprint.instructionMatches[0].index
val resultReg = fingerprint.method
    .getInstruction<OneRegisterInstruction>(matchIndex + 1).registerA

fingerprint.method.addInstructions(matchIndex + 2, "const/4 v$resultReg, 0x0")
TwoRegisterInstruction

Applies to instructions with two register references (e.g. iput, iget, iput-boolean, instance-of):

  • registerA: Destination/source data register (vx).
  • registerB: Target instance/object reference register (vy). (Note: check-cast uses format 21c and is a OneRegisterInstruction with a type reference).
kotlin
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction

// Example: Neutralizing a boolean field write (iput-boolean vx, vy, Field)
val putIndex = fingerprint.instructionMatches[1].index
val instruction = fingerprint.method.getInstruction<TwoRegisterInstruction>(putIndex)
val putReg = instruction.registerA      // Data value register (vx)
val objReg = instruction.registerB      // Object instance register (vy)

fingerprint.method.addInstructions(putIndex, "const/4 v$putReg, 0x0")

4. Multi-Branch & Label Management

Use addInstructionsWithLabels when introducing branching logic (if-eqz, if-nez, goto) to guarantee proper branch label target resolution and relative offset recalculation:

kotlin
method.addInstructionsWithLabels(0, """
    invoke-static {}, Landroid/app/ActivityThread;->currentApplication()Landroid/app/Application;
    move-result-object v0
    invoke-static {v0}, Landroid/preference/PreferenceManager;->getDefaultSharedPreferences(Landroid/content/Context;)Landroid/content/SharedPreferences;
    move-result-object v0
    const-string v1, "morphe_feature_enabled"
    invoke-interface {v0, v1}, Landroid/content/SharedPreferences;->contains(Ljava/lang/String;)Z
    move-result v0
    if-nez v0, :disabled
    const/4 v0, 0x1
    return v0
    :disabled
    const/4 v0, 0x0
    return v0
""".trimIndent())

5. Dynamic Reflection Bridges & Obfuscation Caveats

When accessing private fields or methods across DEX boundaries where direct invocation causes IllegalAccessError, use reflection bridges:

smali
invoke-virtual {p0, p1}, Lorg/chromium/chrome/browser/settings/Preferences;->findPreference(Ljava/lang/CharSequence;)Landroidx/preference/Preference;
move-result-object v0
if-eqz v0, :done
move-object v3, p0
const-string v1, "mListener"
const-class v2, Landroidx/preference/Preference;
invoke-virtual {v2, v1}, Ljava/lang/Class;->getDeclaredField(Ljava/lang/String;)Ljava/lang/reflect/Field;
move-result-object v1
const/4 v2, 0x1
invoke-virtual {v1, v2}, Ljava/lang/reflect/Field;->setAccessible(Z)V
invoke-virtual {v1, v0, v3}, Ljava/lang/reflect/Field;->set(Ljava/lang/Object;Ljava/lang/Object;)V
:done
return-void
Obfuscation Warning & Guidelines
  • Obfuscated identifiers (such as P4, y, O0) are volatile and change between releases.
  • Always prefer anchoring on stable framework APIs (e.g. androidx.preference.Preference) or string literals.
  • When obfuscated symbols are strictly necessary, isolate them in centralized contracts or verify them via RE audit scripts (harness/update.py --audit) against newly updated APKs before building.

6. Mandatory In-Situ Patcher Verification Gate

Any modified Smali hook, register rewrite, or fingerprint must pass the runPatchTest gate in AGENTS.md (Section 3, Step 4), including its zero-smali-compile-error rule (non-range invokes only address v0-v15).

© kveld9, GPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/smali-bytecode-hooks of kveld9/kveld-morphe-patches.

Open the folder on GitHubat commit bfc153e

Compare with similar skills

Smali Bytecode Hooks next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Smali Bytecode Hooks compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Smali Bytecode Hooks this skillkveld9/kveld-morphe-patches112—~1.6kAutomated safety check: PassGPL-3.0
Compose Multiplatform Patternsmonta-app/ocpp-emulator1805 repos~2kAutomated safety check: PassApache-2.0
Phone HarnessShawnPana/phone-harness3.2k—~4.3kAutomated safety check: PassMIT
Stylesarindamxd/camerax-android1324 repos~2.3kAutomated safety check: PassApache-2.0
Verified Emailarindamxd/camerax-android1324 repos~4.7kAutomated safety check: PassApache-2.0
Argent Metro Debuggerbbplayer-app/BBPlayer1.1k—~3.4kAutomated safety check: PassMIT

Similar skills

  • Compose Multiplatform Patterns

    monta-app/ocpp-emulator

    Compose Multiplatform and Jetpack Compose patterns for KMP projects — state management, navigation, theming, performance, and platform-specific UI.

    180 GitHub starsUsed in 5 repos~2k tokens
    MobileAuto-check passed
  • Phone Harness

    ShawnPana/phone-harness

    Control the user's phone — an iPhone through the Mac's iPhone Mirroring window, an Android over adb, or a rented cloud Android: open apps, tap, type, swipe, read the screen.

    3.2k GitHub stars~4.3k tokensUpdated 10 days ago
    MobileAuto-check passed
  • Styles

    arindamxd/camerax-android

    A skill your agent uses to integrate the Jetpack Compose Styles API into an Android project.

    132 GitHub starsUsed in 4 repos~2.3k tokens
    MobileAuto-check passed
  • Verified Email

    arindamxd/camerax-android

    Provides a complete workflow for implementing verified email retrieval on Android Credential Manager API.

    132 GitHub starsUsed in 4 repos~4.7k tokens
    MobileAuto-check passed
  • Argent Metro Debugger

    bbplayer-app/BBPlayer

    Debug a JS runtime via CDP using argent debugger tools. An agent skill from bbplayer-app/BBPlayer.

    1.1k GitHub stars~3.4k tokensUpdated today
    MobileAuto-check passed
  • 统一 Android XML 资源命名:layout、drawable、mipmap、color、values、id 的前缀与 snakecase 规则;把颜色/圆角/描边/状态编码进文件名(bg、border、textcolor…selector)。

    1.6k GitHub stars~1.3k tokensUpdated 1 mo ago
    MobileAuto-check passed

More from kveld9/kveld-morphe-patches

  • Morphe Patcher

    kveld9/kveld-morphe-patches

    Architecture, patch typology (bytecodePatch, resourcePatch, rawResourcePatch), universal patches, stringOption DSL, fingerprint resolution, compatibility contracts (Constants.kt), and diagnostic…

    112 GitHub stars~2.2k tokensUpdated today
    Auto-check passed
  • Native Binary Patching

    kveld9/kveld-morphe-patches

    ARM64 ELF and binary asset patching guidelines covering libchrome.so host redirection, multi-candidate offset resolution, companion .so trimming, and Hermes bytecode patching.

    112 GitHub stars~1.5k tokensUpdated today
    Auto-check passed
  • Release Conventions

    kveld9/kveld-morphe-patches

    Semantic release and CI/CD lifecycle, conventional commit standards, release pipeline chain (release.yml and .releaserc), and git branching strategy.

    112 GitHub stars~893 tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Smali Bytecode Hooks

What does Smali Bytecode Hooks do?

Smali and Dalvik bytecode hooking guidelines, register architecture conventions, multi-return reverse traversal, TwoRegisterInstruction extraction, reflection bridges, and obfuscation guidelines. Smali Bytecode Hooks is an agent skill from kveld9/kveld-morphe-patches. Smali and Dalvik bytecode hooking guidelines, register architecture conventions, multi-return reverse traversal, TwoRegisterInstruction extraction, reflection bridges, and obfuscation guidelines.

When should I use Smali Bytecode Hooks?

Smali Bytecode Hooks fits situations like: mobile work in your project.

How do I install Smali Bytecode Hooks in Claude Code?

Run `npx skills add kveld9/kveld-morphe-patches --skill smali-bytecode-hooks -a claude-code`. Or copy the skill folder (.agents/skills/smali-bytecode-hooks in kveld9/kveld-morphe-patches) into .claude/skills/smali-bytecode-hooks in your project. Claude Code loads it when a task matches its description.

How do I install Smali Bytecode Hooks in Codex?

Run `npx skills add kveld9/kveld-morphe-patches --skill smali-bytecode-hooks -a codex`. Or copy the skill folder (.agents/skills/smali-bytecode-hooks in kveld9/kveld-morphe-patches) into .agents/skills/smali-bytecode-hooks in your project. Codex loads it when a task matches its description.

Can I use Smali Bytecode Hooks in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add kveld9/kveld-morphe-patches --skill smali-bytecode-hooks -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/smali-bytecode-hooks, .gemini/skills/smali-bytecode-hooks, .github/skills/smali-bytecode-hooks and .opencode/skills/smali-bytecode-hooks in your project.

What does Smali Bytecode Hooks need to run?

SKILL.md names no scripts, command-line tools or credentials: Smali Bytecode Hooks is instructions for the agent only.

Does Smali Bytecode Hooks access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Smali Bytecode Hooks safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Smali Bytecode Hooks use?

Smali Bytecode Hooks is published under the GPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Smali Bytecode Hooks use?

About 1.6k tokens (SKILL.md is roughly 6.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Smali Bytecode Hooks?

Skills that share tags, products or a category with Smali Bytecode Hooks: Compose Multiplatform Patterns (monta-app/ocpp-emulator, 180 stars), Phone Harness (ShawnPana/phone-harness, 3.2k stars), Styles (arindamxd/camerax-android, 132 stars) and Verified Email (arindamxd/camerax-android, 132 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Smali Bytecode Hooks?

kveld9 (a GitHub user) maintains it in kveld9/kveld-morphe-patches, which has 112 GitHub stars. The repository holds 4 skills in this directory. The repository was last updated on October 8, 2026.

Source: kveld9/kveld-morphe-patches on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.