### Smali 'Hello World' Method Example Source: https://pysmali.readthedocs.io/en/latest/api/smali/language An example of a Smali method that prints 'Hello World' to the console. It demonstrates register allocation, string constant loading, and invoking a virtual method for output. ```smali 1.method public static main([Ljava/lang/String;)V 2 .registers 2 3 4 sget-object v0, Ljava/lang/System;->out:Ljava/lang/PrintStream; 5 6 const-string v1, "Hello World" 7 8 invoke-virtual {v0, v1}, Ljava/lang/PrintStream;->println(Ljava/lang/String;)V 9 10 return-void 11 12.end method ``` -------------------------------- ### Execute Smali Code from CLI with ismali Source: https://pysmali.readthedocs.io/en/latest/index This example shows how to interact with Smali code directly from the command line using the `ismali` tool. It demonstrates defining variables and executing Smali instructions. ```shell $ ismali >>> vars {'p0': } >>> const-string v1, "Hello World" >>> vars {'p0': , 'v1': 'Hello World'} ``` -------------------------------- ### Load and Initialize Smali Class and Create Object Source: https://pysmali.readthedocs.io/en/latest/api/smali/bridge This example illustrates loading Smali source code, defining a class, manually initializing it, and then creating an instance of that class. It also shows how to retrieve and call methods on the class and its instances. Dependencies include SmaliClass, SmaliObject, and SmaliVM from smali.bridge. ```python from smali.bridge import SmaliClass, SmaliObject, SmaliVM # Assume class source code is stored here source = ... vm = SmaliVM() # Load and define the class (without calling ) my_class = vm.classloader.load_class(source, init=False) # Manually initialize the class by calling my_class.clinit() # Create an instance of the class instance = SmaliObject(my_class) # Initialize the instance separately instance.init(...) # Retrieve a method from the class object toString = my_class.method("toString") # Call the method on the instance (first argument is the instance itself) value = toString(instance) # The returned value behaves like a string print("Returned value:", value) ``` -------------------------------- ### Smali Annotation Directive Example Source: https://pysmali.readthedocs.io/en/latest/api/smali/language An illustrative example of a Smali annotation directive. This example demonstrates defining a runtime annotation with string and sub-annotation properties. ```smali 1.annotation runtime Lcom/example/MyAnnotation; 2 name = "John Doe" 3 age = .subannotation runtime Lcom/example/Age; 4 value = 30 5 .end subannotation 6.end annotation ``` -------------------------------- ### Smali Class Definition Example Source: https://pysmali.readthedocs.io/en/latest/api/smali/index An example of a Smali class definition, showcasing the syntax for class declaration, superclass, interface implementation, fields, and methods. This is the target output generated by the SmaliWriter. ```smali 1.class public abstract Lcom/example/Car; 2.super Ljava/lang/Object; 3 4.implements Ljava/lang/Runnable; 5 6.field private id:I 7 8.method public abstract run()I 9.end method ``` -------------------------------- ### SmaliVM Initialization Source: https://pysmali.readthedocs.io/en/latest/api/smali/bridge Demonstrates how to create a new SmaliVM instance to emulate Smali code. ```APIDOC ## SmaliVM Initialization ### Description Creates a new instance of the SmaliVM for executing Smali code. ### Method Instantiation ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from smali.bridge import SmaliVM vm = SmaliVM() ``` ### Response #### Success Response (200) N/A (This is a constructor call) #### Response Example N/A ``` -------------------------------- ### Smali Field Definition: Example Source: https://pysmali.readthedocs.io/en/latest/api/smali/language Provides a concrete example of a Smali field definition, specifying a private integer field named 'myField'. ```smali .field private myField:I ``` -------------------------------- ### Instruction Visitor API Source: https://pysmali.readthedocs.io/en/latest/api/smali/visitor Methods for visiting common instructions with one or two parameters. ```APIDOC ## visit_instruction / Instruction Visitor API ### Description Visits common instructions with one or two parameters. ### Method `visit_instruction` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **ins_name** (str) - Required - the instruction name - **args** (list) - Required - the argument list ### Request Example ```json { "ins_name": "move-result", "args": ["v0"] } ``` ### Response #### Success Response (200) None. #### Response Example ```json null ``` ``` -------------------------------- ### Execute Smali Method Source: https://pysmali.readthedocs.io/en/latest/api/smali/shell Illustrates how to invoke a method within the Smali interpreter. This example calls the Object.toString() method and stores the result in a register. ```smali invoke-virtual {p0}, Ljava/lang/Object;->toString()Ljava/lang/String; move-result-object v1 vars ``` -------------------------------- ### MethodVisitor Methods Source: https://pysmali.readthedocs.io/en/latest/api/smali/visitor Details on the methods available in the `MethodVisitor` class. Currently, this base class is empty and serves as a placeholder. ```APIDOC ## MethodVisitor Methods The `MethodVisitor` class serves as a base for visitors handling method-specific parsing events. Currently, it does not define specific visitor methods beyond those inherited from `VisitorBase` and acts as a structural base. ``` -------------------------------- ### Getting All Inner Classes from SmaliClass Source: https://pysmali.readthedocs.io/en/latest/api/smali/bridge_api Accesses a property that returns a dictionary containing all inner classes defined within a SmaliClass. This allows for iteration or inspection of all nested classes associated with the SmaliClass object. ```python _property _inner_classes_: dict[str, SmaliClass] ``` -------------------------------- ### Smali Components Source: https://pysmali.readthedocs.io/en/latest/installation Documentation for various Smali components, including tokens, access modifiers, type descriptors, and utility components like `Line`. ```APIDOC ## Smali Components ### Description This section details various fundamental components used within the Pysmali library for representing and manipulating Smali code elements. ### Smali Token - **`Token`**: Represents a single token in the Smali language, such as keywords, identifiers, or literals. ### Smali Access Modifiers - **`AccessType`**: An enum or class representing Smali access modifiers (e.g., public, private, static, final). - **Methods**: - `find()`: Finds an `AccessType` by its flag value. - `get_flags()`: Returns the integer flag value for a given access modifier name. - `get_names()`: Returns a list of names for a given flag value. ### Smali Type Descriptors - **`SVMType`**: Represents Smali type descriptors, such as 'Ljava/lang/String;' or '[I'. - **Attributes**: - `TYPES`: A mapping of type names to their descriptors. - `array_type`: Returns the type descriptor for an array element. - `dim`: Returns the dimension of an array type. - `dvm_name`: Returns the Dalvik VM name for the type. - `full_name`: Returns the fully qualified name of the type. - `is_signature()`: Checks if the type descriptor represents a signature. - `pretty_name`: Returns a human-readable name for the type. - `signature`: Returns the type descriptor as a signature. - `simple_name`: Returns the simple name of the type (e.g., 'String'). - `svm_type`: Returns the internal SVM representation of the type. - **`Signature`**: Represents a method signature. - **Attributes**: - `CLINIT`: Special signature for the class initializer. - `INIT`: Special signature for instance initializers. - `declaring_class`: The class that declares the method. - `descriptor`: The type descriptor of the method. - `name`: The name of the method. - `parameter_types`: A list of type descriptors for the method parameters. - `return_type`: The type descriptor of the method's return value. - `sig`: The raw signature string. ### Smali Value - `smali_value()`: A utility function to parse or represent Smali values. ### Utility Components - **`Line`**: Represents a single line of Smali code, providing methods for parsing and manipulation. - **Attributes**: - `RE_EOL_COMMENT`: Regular expression for end-of-line comments. - `cleaned`: The line content after removing whitespace and comments. - `eol_comment`: The end-of-line comment, if present. - `has_eol()`: Checks if the line contains an end-of-line comment. - `has_next()`: Checks if there is a next line available. - `last()`: Gets the last token on the line. - `peek()`: Peeks at the next line without consuming it. - `raw`: The original, unparsed line content. - `reset()`: Resets the line's parsing state. - `split_line()`: Splits the line into tokens. ``` -------------------------------- ### Smali API Overview Source: https://pysmali.readthedocs.io/en/latest/api/smali/shell Provides an overview of the Smali API, including type and method descriptors. ```APIDOC ## Smali API Overview ### Description This section provides an overview of the Smali API, including details on type descriptors and method descriptors used within the Smali language. ### Method N/A (Documentation Overview) ### Endpoint N/A (Documentation Overview) ### Parameters N/A ### Request Example N/A ### Response N/A ## Smali API - Type Descriptors ### Description Details on how type descriptors are represented and used within the Smali API. ### Method N/A ### Endpoint N/A ## Smali API - Method Descriptors ### Description Details on how method descriptors are represented and used within the Smali API. ### Method N/A ### Endpoint N/A ``` -------------------------------- ### Getting Declared Smali Methods with Access Type Filter Source: https://pysmali.readthedocs.io/en/latest/api/smali/bridge_api Retrieves a list of all methods declared within a SmaliClass, optionally filtered by access type. This method is essential for inspecting the method signatures and implementations available in a Smali class. ```python get_declared_methods(_access_type : AccessType = None_) -> list[SmaliMethod] ``` -------------------------------- ### Accessing and Modifying Frame Registers (Python) Source: https://pysmali.readthedocs.io/en/latest/api/smali/bridge_api Demonstrates how to interact with frame registers using dictionary-like access. This allows for getting, checking existence, and setting register values within an execution frame. It also shows iterating through all registers in the frame. ```python >>> value = frame["v0"] 0 >>> "v0" in frame True >>> frame["v0"] = 1 >>> for register_name in frame: ... value = frame[register_name] ``` -------------------------------- ### VisitorBase Methods Source: https://pysmali.readthedocs.io/en/latest/api/smali/visitor Details on the methods available in the `VisitorBase` class. ```APIDOC ## VisitorBase Methods ### `visit_comment(text: str) -> None` Visits a comment string. Use `visit_eol_comment()` for inline comments. **Parameters**: - **text** (str) - The comment's text without the leading '#'. ### `visit_end() -> None` Called at the end of an annotation. ### `visit_eol_comment(text: str) -> None` Visits an inlined comment (EOL comment). **Parameters**: - **text** (str) - The text without the leading '#'. ``` -------------------------------- ### Get Smali Access Modifier Flags (Python) Source: https://pysmali.readthedocs.io/en/latest/api/smali/index Shows how to obtain Smali access modifier flags using the AccessType class. This can be done by referencing enum members directly or by providing a list of string keywords that are translated into the corresponding flags. ```python modifiers = AccessType.get_flags(["public", "final"]) ``` -------------------------------- ### SmaliVM Class Loading and Initialization Source: https://pysmali.readthedocs.io/en/latest/api/smali/bridge Illustrates how to load Smali source code, define classes, and manually initialize them. ```APIDOC ## SmaliVM Class Loading and Initialization ### Description Loads Smali source code, defines a class within the VM, and optionally initializes its static constructors. ### Method N/A (Code execution example) ### Endpoint N/A ### Parameters None (This is a code snippet demonstrating API usage) ### Request Example ```python from smali.bridge import SmaliClass, SmaliObject, SmaliVM # Assume 'source' contains the Smali code as a string or bytes source = "..." vm = SmaliVM() # Load and define the class without calling my_class = vm.classloader.load_class(source, init=False) # Manually initialize the class (call ) my_class.clinit() # Create an instance of the class instance = SmaliObject(my_class) # Initialize the instance separately instance.init(...) # Get a method from the class object toString = my_class.method("toString") # Call the method on the instance value = toString(instance) print("Returned value:", value) ``` ### Response #### Success Response (200) N/A (This is a code snippet demonstrating API usage) #### Response Example N/A ``` -------------------------------- ### Using SmaliReader with SmaliWriter Source: https://pysmali.readthedocs.io/en/latest/api/smali/reader This snippet demonstrates how to initialize a SmaliReader and SmaliWriter, and then use the reader to visit source code, passing the writer to ensure all structures are copied. ```python reader = SmaliReader(...) writer = SmaliWriter(reader) reader.visit(source_code, writer) ``` -------------------------------- ### Annotation Visitor API Source: https://pysmali.readthedocs.io/en/latest/api/smali/visitor Methods for preparing to visit annotations, including access flags and signatures. ```APIDOC ## visit_annotation / Annotation Visitor API ### Description Prepares to visit an annotation. ### Method `visit_annotation` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **access_flags** (int) - Required - the annotations access flags (zero on most cases) - **signature** (str) - Required - the class signature ### Request Example ```json { "access_flags": 0, "signature": "Ljava/lang/Override;" } ``` ### Response #### Success Response (200) None (This is a visitor method, typically returns None or a visitor object). #### Response Example ```json null ``` ``` -------------------------------- ### Callable SmaliMethod for Method Execution (Python) Source: https://pysmali.readthedocs.io/en/latest/api/smali/bridge_api The SmaliMethod class implements Smali methods, making instances callable. It processes arguments based on the method's signature and executes the method within the SmaliVM context. For example, a method with signature 'add(II)I' can be called with two integer arguments. ```python # Example demonstrating a callable SmaliMethod # Assuming 'method' is an instance of SmaliMethod with signature "add(II)I" # result = method(5, 10) # This would call the method with arguments 5 and 10 ``` -------------------------------- ### Regular Expression for End-of-Line Comments in Python Source: https://pysmali.readthedocs.io/en/latest/api/smali/base Defines a regular expression pattern to identify and capture end-of-line comments, which typically start with a '#' symbol and are preceded by optional whitespace. This pattern is used within the `Line` class to process lines of text. Dependency: `re` module. ```python import re RE_EOL_COMMENT = re.compile('\s*#.*') ``` -------------------------------- ### Smali Visitor API - Method Visitor Source: https://pysmali.readthedocs.io/en/latest/api/smali/writer Explains the `MethodVisitor` class for traversing Smali method structures, including instructions, catches, and locals. ```APIDOC ## Smali Visitor API - MethodVisitor ### Description Details the `MethodVisitor` class, used for visiting various components within a Smali method, such as annotations, instructions, exception handlers, local variables, and control flow structures. ### Endpoint N/A (Conceptual API Section) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Smali VM Source: https://pysmali.readthedocs.io/en/latest/api/smali/shell Documentation for the SmaliVM class, used for executing or simulating Smali bytecode. ```APIDOC ## Smali VM - SmaliVM ### Description Documentation for the `SmaliVM` class, which provides functionality to simulate or execute Smali code. ### Method N/A (Class and Method Documentation) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Class: `SmaliVM` ### Description Simulates the Dalvik/ART Virtual Machine for executing Smali instructions. ### Attributes #### `__classes` ##### Description Internal storage for loaded classes. #### `__frames` ##### Description Internal storage for call stack frames. ### Methods #### `call(method_descriptor, ...)` ##### Description Executes a specified method within the VM. #### `classloader` ##### Description Attribute providing access to the classloader mechanism. #### `debug_handler` ##### Description Attribute for setting up a debug handler for VM execution. ``` -------------------------------- ### SVMType: Array and Class Type Operations Source: https://pysmali.readthedocs.io/en/latest/api/smali/base Demonstrates the usage of the SVMType class for handling array and class type descriptors. It shows how to get the underlying array type, dimensions, DVM name, full name, and a prettified name. Dependencies include the SVMType class itself. ```python >>> array = SVMType("[[B") >>> array.array_type # Expected output: an SVMType instance representing '[B' >>> cls = SVMType("Lcom/example/Class;") >>> cls.dvm_name 'com/example/Class' >>> cls = SVMType("com.example.Class") >>> cls.full_name 'Lcom/example/Class;' >>> array = SVMType("[[Lcom/example/Class;") >>> array.pretty_name '[[com.example.Class' ``` -------------------------------- ### Smali Bridge - Smali VM Source: https://pysmali.readthedocs.io/en/latest/api/smali/writer Documentation for the `SmaliVM` class, representing a virtual machine for executing Smali code. ```APIDOC ## Smali Bridge - Smali VM ### Description Details the `SmaliVM` class, which acts as a virtual machine for executing Smali code. It manages classes, frames, and provides methods for calling functions and handling debugging. ### Endpoint N/A (Conceptual Component) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Signature: Method Signature Parsing Source: https://pysmali.readthedocs.io/en/latest/api/smali/base Explains the functionality of the Signature class for parsing and extracting information from method signatures. It shows how to get the declaring class, method name, descriptor, parameter types, return type, and the full signature string. Input can be a string or an SVMType object. ```python >>> s1 = Signature("Lcom/example/Class;->(II)V") >>> str(s1.declaring_class) 'Lcom/example/Class;' >>> s = Signature("Lcom/example/Class;->getLength(Ljava/lang/String;)I") >>> s.name 'getLength' >>> s.descriptor '(Ljava/lang/String;)I' >>> s = Signature("(II)V") >>> params: list[SVMType] = s.parameter_types >>> [str(x) for x in params] ['I', 'I'] >>> s = Signature("(II)V") >>> str(s.return_type) 'V' >>> s = Signature("(II)V") >>> s.sig '(II)V' ``` -------------------------------- ### Smali Visitor Methods Source: https://pysmali.readthedocs.io/en/latest/genindex Documents the various 'visit_*' methods available in Smali's visitor pattern implementations (ClassVisitor, FieldVisitor, MethodVisitor, AnnotationVisitor, VisitorBase). ```APIDOC ## GET /smali/visitor/methods ### Description Retrieves a list of available 'visit_*' methods within Smali's visitor classes, detailing their purpose and associated visitor type. ### Method GET ### Endpoint /smali/visitor/methods ### Parameters #### Query Parameters - **visitor_type** (string) - Optional - Filter methods by specific visitor type (e.g., 'ClassVisitor', 'MethodVisitor'). ### Response #### Success Response (200) - **method_name** (string) - The name of the visit method (e.g., 'visit_annotation'). - **visitor_class** (string) - The Smali visitor class that implements this method. - **description** (string) - A brief description of what the method does. #### Response Example ```json [ { "method_name": "visit_annotation()", "visitor_class": "smali.visitor.ClassVisitor", "description": "Visits an annotation." }, { "method_name": "visit_array_data()", "visitor_class": "smali.visitor.MethodVisitor", "description": "Visits array data within a method." } ] ``` ``` -------------------------------- ### Smali API - Overview Source: https://pysmali.readthedocs.io/en/latest/api/smali/writer Provides an overview of the Smali API, including type and method descriptors. ```APIDOC ## Smali API Overview ### Description Provides an overview of the Smali API, detailing type descriptors and method descriptors. ### Endpoint N/A (Conceptual API Section) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Smali Bridge - Smali VM Source: https://pysmali.readthedocs.io/en/latest/api/smali/reader Documents the `SmaliVM` class from the Smali Bridge, which simulates a Smali Virtual Machine. ```APIDOC ## Smali Bridge - Smali VM ### Description Documents the `SmaliVM` class from the Smali Bridge, which simulates a Smali Virtual Machine, managing classes, frames, and execution. ### Endpoint N/A (Class Documentation) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Smali Bridge - Smali VM Source: https://pysmali.readthedocs.io/en/latest/api/smali/bridge Documentation for the SmaliVM class, which provides a virtual machine environment for executing Smali code. ```APIDOC ## Smali Bridge - Smali VM ### Description Implements a virtual machine (`SmaliVM`) for running and debugging Smali bytecode. ### Class: `SmaliVM` * **Attributes**: * `__classes`: Internal storage for loaded classes. * `__frames`: Internal storage for call stack frames. * `classloader`: The classloader used by the VM. * `debug_handler`: Handler for debugging events. * **Methods**: * `call()`: Executes a Smali method call. ``` -------------------------------- ### Smali Bridge - Smali VM Source: https://pysmali.readthedocs.io/en/latest/installation Information about the Smali Bridge, specifically the `SmaliVM` class used for virtual machine operations. ```APIDOC ## Smali Bridge - Smali VM ### Description This section covers the Smali VM, which is part of the Smali Bridge, providing capabilities for executing Smali code in a virtual environment. ### `SmaliVM` Class - **`SmaliVM`**: The main class for the Smali Virtual Machine. - **Attributes**: - `__classes`: Internal storage for loaded classes. - `__frames`: Internal storage for call stack frames. - `classloader`: The class loader used by the VM. - `debug_handler`: A handler for debugging events. - **Methods**: - `call()`: Executes a method call within the VM. ``` -------------------------------- ### Smali Bridge - Smali VM Source: https://pysmali.readthedocs.io/en/latest/api/smali/bridge_api Documentation for the Smali Bridge, specifically the Smali VM component. ```APIDOC ## Smali Bridge - Smali VM ### Description This section covers the Smali Bridge, focusing on the `SmaliVM` component, which likely emulates or interacts with the Dalvik Virtual Machine for executing or analyzing Smali code. ### Method N/A (Documentation Overview) ### Endpoint N/A (Documentation Overview) ### Parameters N/A ### Request Example N/A ### Response N/A ## `SmaliVM` ### Description Represents the Smali Virtual Machine, responsible for core VM operations. ### Method `__classes` ### Description Internal attribute storing loaded classes. `__frames` ### Description Internal attribute storing execution frames. `call()` ### Description Executes a method call within the VM. `classloader` ### Description Provides access to the classloader used by the VM. `debug_handler` ### Description Handler for debugging events within the VM. ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### ISmali Interactive Shell Prompt Source: https://pysmali.readthedocs.io/en/latest/api/smali/shell This code snippet shows the initial prompt of the ISmali interactive shell, indicating the version and platform information. It also provides a placeholder comment for users to insert Smali instructions. ```text $ ismali ISmali $VERSION on $PLATFORM >>> # put Smali instructions here ``` -------------------------------- ### Smali Bridge VM Module Source: https://pysmali.readthedocs.io/en/latest/genindex Documentation for classes and attributes within the smali.bridge.vm module. ```APIDOC ## Module: smali.bridge.vm ### Description This module contains the Smali Virtual Machine implementation. ### Classes - **SmaliVM**: Represents the Smali Virtual Machine. ### Attributes - **use_strict** (smali.bridge.vm.SmaliVM attribute): Flag to enable strict mode. ### Other References - **smali.bridge.vm** (module): The module itself. ``` -------------------------------- ### Smali VM - SmaliVM.call() Source: https://pysmali.readthedocs.io/en/latest/index This endpoint describes the `SmaliVM.call()` method within the Smali VM API. ```APIDOC ## SmaliVM.call() ### Description Calls a method within the Smali VM. ### Method N/A - Method within a class ### Endpoint N/A - Method within a class ### Parameters N/A ### Request Example N/A ### Response N/A ### Response Example N/A ``` -------------------------------- ### Create and Initialize SmaliVM Instance Source: https://pysmali.readthedocs.io/en/latest/api/smali/bridge This snippet demonstrates how to create a basic SmaliVM instance in Python. The SmaliVM is the core component for emulating Smali code. Dependencies include the SmaliVM class from the smali.bridge module. ```python from smali.bridge import SmaliVM vm = SmaliVM() ``` -------------------------------- ### Smali Components Source: https://pysmali.readthedocs.io/en/latest/api/smali/shell Documentation for various Smali components, including tokens, access modifiers, type descriptors, and utility classes. ```APIDOC ## Smali Components - Smali Token ### Description Details on the `Token` class used to represent individual tokens in Smali code. ### Class: `Token` ### Description Represents a single token identified during Smali parsing. ### Method N/A ### Endpoint N/A ## Smali Components - Smali Access Modifiers ### Description Information on the `AccessType` class for handling Smali access modifiers. ### Class: `AccessType` ### Description Manages and provides information about Smali access modifiers (e.g., public, private, static). ### Methods #### `find(name)` ##### Description Finds an `AccessType` by its name. #### `get_flags()` ##### Description Returns the numerical flags associated with the access type. #### `get_names()` ##### Description Returns the string names of the access modifiers. ## Smali Components - Smali Type Descriptors ### Description Documentation for `SVMType` and `Signature` classes, handling Smali type representations. ### Class: `SVMType` ### Description Represents and manipulates Smali type descriptors. ### Attributes/Methods #### `TYPES` ##### Description Predefined type constants. #### `array_type(type, dim)` ##### Description Creates an array type descriptor. #### `dim` ##### Description Dimension of the array type. #### `dvm_name` ##### Description Dalvik VM-specific name of the type. #### `full_name` ##### Description The complete, unambiguous name of the type. #### `is_signature()` ##### Description Checks if the type is a signature. #### `pretty_name` ##### Description A human-readable representation of the type. #### `signature` ##### Description The signature string of the type. #### `simple_name` ##### Description The basic name of the type (e.g., 'int' instead of 'Ljava/lang/Integer;'). #### `svm_type` ##### Description Internal representation of the Smali type. ### Class: `Signature` ### Description Represents a method signature in Smali. ### Attributes #### `CLINIT` ##### Description Constant for the class initializer signature. #### `INIT` ##### Description Constant for the instance initializer signature. #### `declaring_class` ##### Description The class that declares this method signature. #### `descriptor` ##### Description The descriptor string of the signature. #### `name` ##### Description The name of the method. #### `parameter_types` ##### Description A list of parameter types. #### `return_type` ##### Description The return type of the method. #### `sig` ##### Description The raw signature string. ## Smali Components - Smali Value ### Description Utility function for handling Smali values. ### Function: `smali_value()` ##### Description Parses or creates a Smali value representation. ## Smali Components - Utility Components ### Description Utility classes and constants for processing lines of Smali code. ### Class: `Line` ### Description Represents a single line of Smali code, providing utilities for parsing and manipulation. ### Attributes/Methods #### `RE_EOL_COMMENT` ##### Description Regular expression for end-of-line comments. #### `cleaned` ##### Description The line content with leading/trailing whitespace removed. #### `eol_comment` ##### Description The end-of-line comment, if present. #### `has_eol()` ##### Description Checks if the line contains an end-of-line comment. #### `has_next()` ##### Description Checks if there is a next line available (in a multi-line context). #### `last()` ##### Description Gets the last part of a split line. #### `peek()` ##### Description Looks at the next token or part of the line without consuming it. #### `raw` ##### Description The original, raw content of the line. #### `reset()` ##### Description Resets the line's internal state. #### `split_line()` ##### Description Splits the line into components (e.g., instruction, arguments, comment). ``` -------------------------------- ### Smali API Overview Source: https://pysmali.readthedocs.io/en/latest/api/smali/bridge_api Provides an overview of the Smali API, including type descriptors and method descriptors. ```APIDOC ## Smali API Overview ### Description This section details the fundamental elements of the Smali API, focusing on how types and methods are represented and described within the Smali language. ### Method N/A (Documentation Overview) ### Endpoint N/A (Documentation Overview) ### Parameters N/A ### Request Example N/A ### Response N/A ## 1.1.1. Type descriptors ### Description Explains the format and usage of type descriptors in the Smali API. ### Method N/A ### Endpoint N/A ## 1.1.2. Method descriptors ### Description Details the structure and meaning of method descriptors within the Smali API. ### Method N/A ### Endpoint N/A ``` -------------------------------- ### Smali VM and ClassLoader Source: https://pysmali.readthedocs.io/en/latest/api/smali/index Details on SmaliVM functionalities for class manipulation and execution, and ClassLoader methods for defining and loading classes. ```APIDOC ## Smali VM and ClassLoader ### SmaliVM Methods * `SmaliVM.executors` * `SmaliVM.get_class()` * `SmaliVM.new_class()` * `SmaliVM.new_frame()` * `SmaliVM.use_strict` ### ClassLoader Methods * `ClassLoader.define_class()` * `ClassLoader.load_class()` ``` -------------------------------- ### Sparse Switch Visitor API Source: https://pysmali.readthedocs.io/en/latest/api/smali/visitor Methods for visiting '.sparse-switch' statements, including switch branches. ```APIDOC ## visit_sparse_switch / Sparse Switch Visitor API ### Description Visits a .sparse-switch statement. The branches take the original case value as their key and the block_id as their value. ### Method `visit_sparse_switch` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **branches** (dict) - Required - the switch branches ### Request Example ```json { "branches": { "10": "block_10", "20": "block_20" } } ``` ### Response #### Success Response (200) None. #### Response Example ```json null ``` ``` -------------------------------- ### Smali API Source: https://pysmali.readthedocs.io/en/latest/installation Overview of the Smali API, including type descriptors and method descriptors, as well as interfaces for parsing and generating Smali classes. ```APIDOC ## Smali API Overview ### Description Provides fundamental elements for working with Smali code, including type descriptors and method descriptors. It also defines interfaces for parsing and generating Smali classes. ### Type Descriptors - `SVMType`: Represents Smali type descriptors, including array types, dimensions, and names. - `Signature`: Represents method signatures, including declaring class, name, parameter types, return type, and the full signature. ### Interfaces and Components - **Parsing Classes**: Mechanisms for reading and parsing Smali code into an internal representation. - **Generating Classes**: Functionality to generate Smali code from an internal representation. ``` -------------------------------- ### Smali API Overview Source: https://pysmali.readthedocs.io/en/latest/api/smali/reader Provides an overview of the Smali API, including type descriptors and method descriptors. ```APIDOC ## Smali API Overview ### Description Provides an overview of the Smali API, including type descriptors and method descriptors. ### Endpoint N/A (Conceptual API Overview) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### SmaliReader API - SmaliReader.visit() Source: https://pysmali.readthedocs.io/en/latest/index This endpoint describes the `SmaliReader.visit()` method within the SmaliReader API. ```APIDOC ## SmaliReader.visit() ### Description Visits the Smali code using a visitor pattern. ### Method N/A - Method within a class ### Endpoint N/A - Method within a class ### Parameters N/A ### Request Example N/A ### Response N/A ### Response Example N/A ``` -------------------------------- ### SmaliVisitor API - ClassVisitor.visit_annotation() Source: https://pysmali.readthedocs.io/en/latest/index This endpoint describes the `ClassVisitor.visit_annotation()` method within the SmaliVisitor API. ```APIDOC ## ClassVisitor.visit_annotation() ### Description Visits an annotation within a class. ### Method N/A - Method within a class ### Endpoint N/A - Method within a class ### Parameters N/A ### Request Example N/A ### Response N/A ### Response Example N/A ``` -------------------------------- ### Smali Visitor API - Class Visitor Source: https://pysmali.readthedocs.io/en/latest/api/smali/writer Documentation for the `ClassVisitor` class, used for visiting various components of a Smali class. ```APIDOC ## Smali Visitor API - ClassVisitor ### Description Details the `ClassVisitor` class, designed for traversing and processing different parts of a Smali class definition, such as annotations, fields, methods, and source information. ### Endpoint N/A (Conceptual API Section) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### ClassVisitor Methods Source: https://pysmali.readthedocs.io/en/latest/api/smali/visitor Details on the methods available in the `ClassVisitor` class for parsing class-related information. ```APIDOC ## ClassVisitor Methods ### `visit_annotation(access_flags: int, signature: str) -> AnnotationVisitor` Prepares to visit an annotation associated with the class. **Parameters**: - **access_flags** (int) - The annotation's access flags (often zero). - **signature** (str) - The class signature. **Returns**: - An `AnnotationVisitor` instance to handle the annotation details. ### `visit_class(name: str, access_flags: int) -> None` Called when the class definition has been parsed. **Parameters**: - **name** (str) - The class name (e.g., 'Lcom/example/A;'). - **access_flags** (int) - The class's access flags (e.g., PUBLIC, FINAL). ### `visit_debug(enabled: int) -> None` Visits a `.debug` directive. **Parameters**: - **enabled** (int) - Indicates whether debugging symbols are enabled. ### `visit_field(name: str, access_flags: str, field_type: str, value=None) -> FieldVisitor` Called when a global field definition is parsed. **Parameters**: - **name** (str) - The field's name. - **access_flags** (str) - The field's access flags (e.g., PUBLIC, FINAL). - **field_type** (str) - The field's type (can be primitive). - **value** (any, optional) - The field's value. **Returns**: - A `FieldVisitor` instance to handle field details. ### `visit_implements(interface: str) -> None` Called upon an `implements` directive. **Parameters**: - **interface** (str) - The implemented interface name. ### `visit_inner_class(name: str, access_flags: int) -> ClassVisitor` Called when an inner class definition is parsed. **Parameters**: - **name** (str) - The inner class name (e.g., 'Lcom/example/Inner;'). - **access_flags** (int) - The inner class's access flags. **Returns**: - A `ClassVisitor` instance for the inner class. ### `visit_method(name: str, access_flags: int, parameters: list, return_type: str) -> MethodVisitor` Called when a method definition is parsed. **Parameters**: - **name** (str) - The method's name. - **access_flags** (int) - The method's access flags (e.g., PUBLIC, PRIVATE). - **parameters** (list) - The list of parameter types. - **return_type** (str) - The method's return type. **Returns**: - A `MethodVisitor` instance to handle method parsing events. ### `visit_source(source: str) -> None` Visits the source file information. **Parameters**: - **source** (str) - The source file name or type. ### `visit_super(super_class: str) -> None` Called when a `.super` statement is parsed. **Parameters**: - **super_class** (str) - The name of the super class. ``` -------------------------------- ### Goto Statement Visitor API Source: https://pysmali.readthedocs.io/en/latest/api/smali/visitor Methods for visiting 'goto' statements and their destination blocks. ```APIDOC ## visit_goto / Goto Statement Visitor API ### Description Visits ‘goto’ statements. ### Method `visit_goto` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **block_name** (str) - Required - the destination block name ### Request Example ```json { "block_name": "loop_start" } ``` ### Response #### Success Response (200) None. #### Response Example ```json null ``` ``` -------------------------------- ### Smali VM API Source: https://pysmali.readthedocs.io/en/latest/api/smali/bridge Provides core functionalities for the Smali Virtual Machine, including class loading, creation, and execution management. ```APIDOC ## Smali VM ### Description Core functionalities for the Smali Virtual Machine. ### Methods - `SmaliVM.executors` - `SmaliVM.get_class() - `SmaliVM.new_class() - `SmaliVM.new_frame() - `SmaliVM.use_strict ### ClassLoader #### Description Handles the loading and definition of Smali classes. #### Methods - `ClassLoader.define_class() - `ClassLoader.load_class() ``` -------------------------------- ### Instantiate and Call Smali Method Source: https://pysmali.readthedocs.io/en/latest/api/smali/bridge_api Demonstrates how to instantiate a Smali method and call it with an instance and arguments. The instance parameter is required unless the method is static. It can be set to `None` for static methods. ```python method = SmaliMethod(...) instance = SmaliObject(...) result = method(instance, 1, 2) ``` -------------------------------- ### Smali Visitor API Source: https://pysmali.readthedocs.io/en/latest/installation Details the Smali Visitor API, outlining base classes and concrete visitors for different Smali constructs like classes, fields, methods, and annotations. ```APIDOC ## Smali Visitor API ### Description This API provides a visitor pattern for traversing and processing Smali code structures. It includes a base visitor and specialized visitors for annotations, classes, fields, and methods. ### Base Visitor - **`VisitorBase`**: The abstract base class for all Smali visitors. It defines common visiting methods. - **Methods**: - `visit_comment()`: Called when a comment is encountered. - `visit_end()`: Called at the end of the visiting process. - `visit_eol_comment()`: Called for end-of-line comments. ### Specialized Visitors - **`ClassVisitor`**: Visits components of a Smali class. - **Methods**: - `visit_annotation()`: Visits class annotations. - `visit_class()`: Visits the class definition itself. - `visit_debug()`: Visits debug information. - `visit_field()`: Visits field definitions. - `visit_implements()`: Visits implemented interfaces. - `visit_inner_class()`: Visits inner class definitions. - `visit_method()`: Visits method definitions. - `visit_source()`: Visits the source file attribute. - `visit_super()`: Visits the superclass. - **`AnnotationVisitor`**: Visits elements within an annotation. - **Methods**: - `visit_array()`: Visits an array value in an annotation. - `visit_enum()`: Visits an enum value in an annotation. - `visit_subannotation()`: Visits a nested annotation. - `visit_value()`: Visits a primitive or string value. - **`FieldVisitor`**: Visits field-specific elements. - **Methods**: - `visit_annotation()`: Visits annotations on a field. - **`MethodVisitor`**: Visits elements within a Smali method. - **Methods**: - `visit_annotation()`: Visits annotations on a method. - `visit_array_data()`: Visits array data instructions. - `visit_block()`: Visits code blocks. - `visit_catch()`: Visits exception catch handlers. - `visit_catchall()`: Visits catch-all handlers. - `visit_goto()`: Visits goto instructions. - `visit_instruction()`: Visits individual bytecode instructions. - `visit_invoke()`: Visits method invocation instructions. - `visit_line()`: Visits line number directives. - `visit_local()`: Visits local variable declarations. - `visit_locals()`: Visits the entire local variable table. - `visit_packed_switch()`: Visits packed-switch instructions. - `visit_param()`: Visits method parameters. - `visit_prologue()`: Visits method prologue information. - `visit_registers()`: Visits register information. - `visit_restart()`: Visits restart directives. - `visit_return()`: Visits return instructions. - `visit_sparse_switch()`: Visits sparse-switch instructions. ``` -------------------------------- ### Smali API Documentation Source: https://pysmali.readthedocs.io/en/latest/api/smali/bridge Overview of the Smali API, including type and method descriptors, and interfaces for parsing and generating Smali classes. ```APIDOC ## Smali API Overview ### Description Provides core functionalities for working with Smali code, including parsing and generation of Smali classes. ### Endpoints * **1.1. Overview** * **1.1.1. Type descriptors**: Describes how types are represented in Smali. * **1.1.2. Method descriptors**: Describes how methods are represented in Smali. * **1.2. Interfaces and components** * **1.2.1. Parsing classes**: Functionality for parsing Smali classes. * **1.2.2. Generating classes**: Functionality for generating Smali classes. ``` -------------------------------- ### Block Visitor API Source: https://pysmali.readthedocs.io/en/latest/api/smali/visitor Methods for handling goto-block definitions. ```APIDOC ## visit_block / Block Visitor API ### Description Called when a goto-block definition is parsed. ### Method `visit_block` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **name** (str) - Required - the block’s name ### Request Example ```json { "name": "try_start" } ``` ### Response #### Success Response (200) None. #### Response Example ```json null ``` ``` -------------------------------- ### Restart Statement Visitor API Source: https://pysmali.readthedocs.io/en/latest/api/smali/visitor Methods for visiting '.restart' statements. ```APIDOC ## visit_restart / Restart Statement Visitor API ### Description Visits a .restart statement. ### Method `visit_restart` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **register** (str) - Required - the register ### Request Example ```json { "register": "v1" } ``` ### Response #### Success Response (200) None. #### Response Example ```json null ``` ``` -------------------------------- ### ClassLoader API Source: https://pysmali.readthedocs.io/en/latest/api/smali/language Handles the definition and loading of Smali classes within the virtual machine. ```APIDOC ## ClassLoader API ### Description Handles the definition and loading of Smali classes within the virtual machine. ### Methods * `ClassLoader.define_class(name: str, bytecode: bytes)` - Defines a class from bytecode. * `ClassLoader.load_class(name: str)` - Loads a class by its name. ``` -------------------------------- ### Smali Writer API - Writer Implementation Source: https://pysmali.readthedocs.io/en/latest/api/smali/writer Documentation for the writer implementation in the Smali Writer API, covering SmaliWriter and SmaliClassWriter. ```APIDOC ## Smali Writer API - Writer Implementation ### Description Details the implementation of the Smali writer, including the `SmaliWriter` and `_SmaliClassWriter` classes responsible for generating Smali code. ### Endpoint N/A (Conceptual API Section) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Parameter Visitor API Source: https://pysmali.readthedocs.io/en/latest/api/smali/visitor Methods for handling '.param' statements, including register and parameter name. ```APIDOC ## visit_param / Parameter Visitor API ### Description Called on a `.param` statement ### Method `visit_param` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **register** (str) - Required - the register - **name** (str) - Required - the parameter’s name ### Request Example ```json { "register": "v0", "name": "arg1" } ``` ### Response #### Success Response (200) None. #### Response Example ```json null ``` ``` -------------------------------- ### SmaliVM Class Methods Source: https://pysmali.readthedocs.io/en/latest/search This section details the methods and properties available within the SmaliVM class, which is central to executing Smali code. ```APIDOC ## SmaliVM Methods and Properties ### Description Provides an overview of the core methods and properties of the `SmaliVM` class for executing and managing Smali bytecode. ### Methods - `SmaliVM.executors`: Access to the executors within the VM. - `SmaliVM.get_class(name)`: Retrieves a class by its name. - `SmaliVM.new_class(name)`: Creates a new class. - `SmaliVM.new_frame()`: Instantiates a new execution frame. ### Properties - `SmaliVM.use_strict`: A boolean indicating whether strict mode is enabled. ```