mirror of
https://github.com/revanced/smali.git
synced 2025-05-11 20:04:28 +02:00
Added support for Format30t
git-svn-id: https://smali.googlecode.com/svn/trunk@16 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
9e7550f062
commit
a0c2e9647e
@ -295,6 +295,11 @@ INSTRUCTION_FORMAT22c_FIELD_PHRASE
|
||||
WS
|
||||
FIELD_TYPE_DESCRIPTOR_EMITCHILD;
|
||||
|
||||
INSTRUCTION_FORMAT30t_PHRASE
|
||||
: INSTRUCTION_FORMAT30t_EMIT
|
||||
WS
|
||||
(LABEL_EMIT | OFFSET_EMIT);
|
||||
|
||||
INSTRUCTION_FORMAT35c_METHOD_PHRASE
|
||||
: INSTRUCTION_FORMAT35c_METHOD_EMIT
|
||||
WS
|
||||
@ -743,6 +748,11 @@ fragment INSTRUCTION_FORMAT22c_FIELD
|
||||
| 'iput-short'
|
||||
;
|
||||
|
||||
fragment INSTRUCTION_FORMAT30t_EMIT
|
||||
: INSTRUCTION_FORMAT30t {emit($INSTRUCTION_FORMAT30t, INSTRUCTION_FORMAT30t);};
|
||||
fragment INSTRUCTION_FORMAT30t
|
||||
: 'goto/32';
|
||||
|
||||
fragment INSTRUCTION_FORMAT35c_METHOD_EMIT
|
||||
: INSTRUCTION_FORMAT35c_METHOD {emit($INSTRUCTION_FORMAT35c_METHOD, INSTRUCTION_FORMAT35c_METHOD);};
|
||||
fragment INSTRUCTION_FORMAT35c_METHOD
|
||||
|
@ -61,6 +61,7 @@ tokens {
|
||||
I_STATEMENT_FORMAT21c_FIELD;
|
||||
I_STATEMENT_FORMAT22c_FIELD;
|
||||
I_STATEMENT_FORMAT21c_STRING;
|
||||
I_STATEMENT_FORMAT30t;
|
||||
I_STATEMENT_FORMAT35c_METHOD;
|
||||
I_STATEMENT_FORMAT3rc_METHOD;
|
||||
I_REGISTER_RANGE;
|
||||
@ -161,6 +162,9 @@ instruction returns [int size]
|
||||
| //e.g. iput-object v1 v0 org/JesusFreke/HelloWorld2/HelloWorld2.helloWorld Ljava/lang/String;
|
||||
INSTRUCTION_FORMAT22c_FIELD REGISTER REGISTER fully_qualified_field {$size = Format22c.Format.getByteCount();}
|
||||
-> ^(I_STATEMENT_FORMAT22c_FIELD[$start, "I_INSTANCE_FIELD_STATEMENT"] INSTRUCTION_FORMAT22c_FIELD REGISTER REGISTER fully_qualified_field)
|
||||
| //e.g. goto/32 endloop:
|
||||
INSTRUCTION_FORMAT30t (LABEL | OFFSET) {$size = Format30t.Format.getByteCount();}
|
||||
-> ^(I_STATEMENT_FORMAT30t[$start, "I_STATEMENT_FORMAT30t"] INSTRUCTION_FORMAT30t LABEL? OFFSET?)
|
||||
| //e.g. invoke-virtual {v0,v1} java/io/PrintStream/print(Ljava/lang/Stream;)V
|
||||
INSTRUCTION_FORMAT35c_METHOD OPEN_BRACKET register_list CLOSE_BRACKET fully_qualified_method {$size = Format35c.Format.getByteCount();}
|
||||
-> ^(I_STATEMENT_FORMAT35c_METHOD[$start, "I_STATEMENT_FORMAT35c_METHOD"] INSTRUCTION_FORMAT35c_METHOD register_list fully_qualified_method)
|
||||
|
@ -417,6 +417,15 @@ instruction returns[Instruction instruction]
|
||||
|
||||
$instruction = Format21c.Format.make(dexFile, opcode.value, regA, typeIdItem);
|
||||
}
|
||||
| //e.g. goto/32 endloop:
|
||||
^(I_STATEMENT_FORMAT30t INSTRUCTION_FORMAT30t offset_or_label)
|
||||
{
|
||||
Opcode opcode = Opcode.getOpcodeByName($INSTRUCTION_FORMAT30t.text);
|
||||
|
||||
int addressOffset = $offset_or_label.offsetValue;
|
||||
|
||||
$instruction = Format30t.Format.make(dexFile, opcode.value, addressOffset);
|
||||
}
|
||||
| //e.g. invoke-virtual {v0,v1} java/io/PrintStream/print(Ljava/lang/Stream;)V
|
||||
^(I_STATEMENT_FORMAT35c_METHOD INSTRUCTION_FORMAT35c_METHOD register_list fully_qualified_method)
|
||||
{
|
||||
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* [The "BSD licence"]
|
||||
* Copyright (c) 2009 Ben Gruver
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.JesusFreke.dexlib.code.Format;
|
||||
|
||||
import org.JesusFreke.dexlib.code.Instruction;
|
||||
import org.JesusFreke.dexlib.code.Opcode;
|
||||
import org.JesusFreke.dexlib.DexFile;
|
||||
|
||||
public class Format30t extends Format
|
||||
{
|
||||
public static final Format30t Format = new Format30t();
|
||||
|
||||
private Format30t() {
|
||||
}
|
||||
|
||||
public Instruction make(DexFile dexFile, byte opcode, int offA) {
|
||||
byte[] bytes = new byte[6];
|
||||
|
||||
Opcode op = Opcode.getOpcodeByValue(opcode);
|
||||
|
||||
checkOpcodeFormat(op);
|
||||
|
||||
bytes[0] = opcode;
|
||||
bytes[2] = (byte)offA;
|
||||
bytes[3] = (byte)(offA >> 8);
|
||||
bytes[4] = (byte)(offA >> 16);
|
||||
bytes[5] = (byte)(offA >> 24);
|
||||
|
||||
return new Instruction(dexFile, bytes, null);
|
||||
}
|
||||
|
||||
public int getByteCount()
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
|
||||
public String getFormatName()
|
||||
{
|
||||
return "30t";
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@
|
||||
;Format10t with a label
|
||||
;Format10t with an offset
|
||||
;Format20t with a label
|
||||
;Format30t with a label
|
||||
|
||||
|
||||
.method static constructor <clinit>()V ;test
|
||||
@ -177,7 +178,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
;test format20t with a label
|
||||
goto/16 SKIP2:
|
||||
|
||||
@ -193,6 +193,21 @@
|
||||
move-result-object v2
|
||||
|
||||
|
||||
;test format30t with a label
|
||||
goto/32 SKIP3:
|
||||
|
||||
const-string v1, "This shouldn't be displayed!"
|
||||
|
||||
SKIP3:
|
||||
const-string v1,"Format30t with a label"
|
||||
|
||||
invoke-virtual {v2, v1}, java/lang/String/concat(Ljava/lang/String;)Ljava/lang/String;
|
||||
move-result-object v2
|
||||
|
||||
invoke-virtual {v2, v3}, java/lang/String/concat(Ljava/lang/String;)Ljava/lang/String;
|
||||
move-result-object v2
|
||||
|
||||
|
||||
|
||||
check-cast v4, Landroid/app/Activity;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user