Skip to content

Commit

Permalink
#11 DEX format - parse items - encoded_value in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
amosshi committed Aug 25, 2021
1 parent e94712f commit 5c19ccc
Show file tree
Hide file tree
Showing 34 changed files with 829 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ public static Icon icon4Annotations() {
return icon("/image/icons8-bookmark-16.png");
}

/**
* Icon for array.
*
* @return Icon for array
* @see <a href="https://icons8.com/icon/78816/view-array">View Array</a> icon by <a href="https://icons8.com">Icons8</a>
*/
public static Icon icon4Array() {
return icon("/image/icons8-view-array-16.png");
}

/**
* Icon for binary file.
*
Expand Down Expand Up @@ -253,7 +263,7 @@ public static Icon icon4Size() {
}

/**
* Icon for tag.
* Icon for Tag or Type.
*
* @return tag icon
* @see <a href="https://icons8.com/icon/pmzH4rF8Lrv9/tag">Tag</a> icon by
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* DEXFile.java June 14, 2015, 22:20
* DexFile.java June 14, 2015, 22:20
*
* Copyright 2015, FreeInternals.org. All rights reserved.
* Use is subject to license terms.
Expand Down Expand Up @@ -223,7 +223,7 @@ public DexFile(File file) throws IOException, FileFormatException {
stream.flyTo(this.header.class_defs_off.intValue());
this.class_defs = new class_def_item[this.header.class_defs_size.intValue()];
for (int i = 0; i < this.class_defs.length; i++) {
this.class_defs[i] = new class_def_item(stream);
this.class_defs[i] = new class_def_item(stream, this);

if (this.class_defs[i].interfaces_off.value != 0) {
todoData.put(this.class_defs[i].interfaces_off.value, type_list.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@
* Interface for generating tree node for {@link DexFile}.
*
* @author Amos Shi
*
* <pre>
* java:S115 - Constant name does not follow naming conventions --- We respect the DEX spec name instead
* </pre>
*/
@SuppressWarnings({"java:S115"})
public interface GenerateTreeNodeDexFile {
static final ResourceBundle MESSAGES = ResourceBundle.getBundle(JTreeDexFile.class.getPackageName() + ".MessagesBundle", Locale.ROOT);
static final String FORMAT_STRING_STRING = "%s - %s";

static final String msg_annotation_set_item = "msg_annotation_set_item";

void generateTreeNode(final DefaultMutableTreeNode parentNode, final DexFile dexFile);

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* dexbyte.java June 17, 2015, 21:32
* Type_byte.java June 17, 2015, 21:32
*
* Copyright 2015, FreeInternals.org. All rights reserved.
* Use is subject to license terms.
Expand Down Expand Up @@ -38,4 +38,9 @@ public class Type_byte {
protected Type_byte(byte b) {
this.value = b;
}

@Override
public String toString() {
return String.format("0x%s | %d | %c", Integer.toHexString(this.value).toUpperCase(), this.value, this.value);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* dexint.java June 17, 2015, 21:38
* Type_int.java June 17, 2015, 21:38
*
* Copyright 2015, FreeInternals.org. All rights reserved.
* Use is subject to license terms.
Expand All @@ -8,7 +8,7 @@

/**
* 32-bit signed int, little-endian.
*
*
* @author Amos Shi
* @see
* <a href="https://source.android.com/devices/tech/dalvik/dex-format.html">
Expand All @@ -24,7 +24,7 @@ public class Type_int {
* Length of the type in bytes.
*/
public static final int LENGTH = 4;

/**
* Value of the DEX <code>int</code>.
*/
Expand All @@ -33,4 +33,9 @@ public class Type_int {
protected Type_int(int i) {
this.value = i;
}

@Override
public String toString() {
return String.format("0x%s | %,d", Integer.toHexString(this.value).toUpperCase(), this.value);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* dexlong.java June 17, 2015, 21:39
* Type_long.java June 17, 2015, 21:39
*
* Copyright 2015, FreeInternals.org. All rights reserved.
* Use is subject to license terms.
Expand Down Expand Up @@ -33,4 +33,9 @@ public class Type_long {
protected Type_long(long l) {
this.value = l;
}

@Override
public String toString() {
return String.format("0x%s | %,d", Long.toHexString(this.value).toUpperCase(), this.value);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* dexshort.java June 17, 2015, 21:36
* Type_short.java June 17, 2015, 21:36
*
* Copyright 2015, FreeInternals.org. All rights reserved.
* Use is subject to license terms.
Expand Down Expand Up @@ -37,6 +37,6 @@ protected Type_short(short s) {

@Override
public String toString() {
return "0x" + Long.toHexString(this.value).toUpperCase() + " | " + String.format("%,d", this.value);
return String.format("0x%s | %,d", Integer.toHexString(this.value).toUpperCase(), this.value);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* dexsleb128.java June 17, 2015, 21:41
* Type_sleb128.java June 17, 2015, 21:41
*
* Copyright 2015, FreeInternals.org. All rights reserved.
* Use is subject to license terms.
Expand Down Expand Up @@ -34,4 +34,9 @@ protected Type_sleb128(int v, int l) {
this.value = v;
this.length = l;
}

@Override
public String toString() {
return String.format("length=%d value=0x%s | %,d", this.length, Integer.toHexString(this.value).toUpperCase(), this.value);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* dexubyte.java June 17, 2015, 21:32
* Type_ubyte.java June 17, 2015, 21:32
*
* Copyright 2015, FreeInternals.org. All rights reserved.
* Use is subject to license terms.
Expand Down Expand Up @@ -35,9 +35,14 @@ protected Type_ubyte(int i) {
this.value = i;
}

@Override
public String toString() {
return String.format("0x%s | %d", Integer.toHexString(this.value).toUpperCase(), this.value);
}

/**
* Get string for <code>ubyte</code> array.
*
*
* @param bytes <code>ubyte</code> array
* @return String value
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* dexuint.java June 17, 2015, 21:39
* Type_uint.java June 17, 2015, 21:39
*
* Copyright 2015, FreeInternals.org. All rights reserved.
* Use is subject to license terms.
Expand Down Expand Up @@ -61,6 +61,6 @@ public String toString() {
* @return The String for <code>l</code>
*/
public static String toString(long l) {
return "0x" + Long.toHexString(l).toUpperCase() + " | " + String.format("%,d", l);
return String.format("0x%s | %,d", Long.toHexString(l).toUpperCase(), l);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* dexuleb128.java June 17, 2015, 21:42
* Type_uleb128.java June 17, 2015, 21:42
*
* Copyright 2015, FreeInternals.org. All rights reserved.
* Use is subject to license terms.
Expand Down Expand Up @@ -34,4 +34,9 @@ protected Type_uleb128(int v, int l) {
this.value = v;
this.length = l;
}

@Override
public String toString() {
return String.format("length=%d value=0x%s | %,d", this.length, Integer.toHexString(this.value).toUpperCase(), this.value);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* dexuleb128p1.java June 17, 2015, 21:42
* Type_uleb128p1.java June 17, 2015, 21:42
*
* Copyright 2015, FreeInternals.org. All rights reserved.
* Use is subject to license terms.
Expand All @@ -8,7 +8,7 @@

/**
* Unsigned LEB128 plus 1, variable-length.
*
*
* @author Amos Shi
* @see
* <a href="https://source.android.com/devices/tech/dalvik/dex-format.html">
Expand All @@ -34,4 +34,9 @@ protected Type_uleb128p1(int v, int l) {
this.value = v;
this.length = l;
}

@Override
public String toString() {
return String.format("length=%d value=0x%s | %,d", this.length, Integer.toHexString(this.value).toUpperCase(), this.value);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* dexulong.java June 17, 2015, 21:40
* Type_ulong.java June 17, 2015, 21:40
*
* Copyright 2015, FreeInternals.org. All rights reserved.
* Use is subject to license terms.
Expand Down Expand Up @@ -36,4 +36,12 @@ public class Type_ulong {
protected Type_ulong(BigInteger bi) {
this.value = bi;
}

@Override
public String toString() {
return String.format("0x%s | %s | %,d",
this.value.toString(16).toUpperCase(),
this.value.toString(),
this.value.longValue());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* dexushort.java June 17, 2015, 21:37
* Type_ushort.java June 17, 2015, 21:37
*
* Copyright 2015, FreeInternals.org. All rights reserved.
* Use is subject to license terms.
Expand Down Expand Up @@ -34,9 +34,9 @@ public class Type_ushort {
protected Type_ushort(int i) {
this.value = i;
}

@Override
public String toString() {
return "0x" + Long.toHexString(this.value).toUpperCase() + " | " + String.format("%,d", this.value);
}
return String.format("0x%s | %,d", Long.toHexString(this.value).toUpperCase(), this.value);
}
}
Loading

0 comments on commit 5c19ccc

Please sign in to comment.