Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 0713f9e

Browse files
committed
added logic for viewing the inner classes.dex entry
1 parent 2d492dc commit 0713f9e

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed

ClassySharkWS/src/com/google/classyshark/gui/panel/tree/FilesTree.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ public void valueChanged(TreeSelectionEvent e) {
200200

201201
DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode) selection;
202202

203-
if (selection.toString().startsWith("classes") &&
204-
selection.toString().endsWith(".dex")) {
203+
if (selection.toString().endsWith(".dex")) {
205204
FilesTree.this.viewerController.onSelectedClassName(
206205
(String) defaultMutableTreeNode.getUserObject());
207206
return;

ClassySharkWS/src/com/google/classyshark/silverghost/translator/dex/DexInfoTranslator.java

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,54 @@ private static File extractClassesDex(String dexName, File apkFile, DexInfoTrans
140140
}
141141
}
142142

143-
// TODO add here login for custom dex loading
143+
if (zipEntry.getName().endsWith("jar") || zipEntry.getName().endsWith("zip")) {
144+
145+
File innerZip = File.createTempFile("inner_zip", "zip");
146+
innerZip.deleteOnExit();
147+
148+
FileOutputStream fos =
149+
new FileOutputStream(innerZip);
150+
byte[] bytes = new byte[1024];
151+
int length;
152+
while ((length = zipFile.read(bytes)) >= 0) {
153+
fos.write(bytes, 0, length);
154+
}
155+
156+
fos.close();
157+
158+
// so far we have a zip file
159+
ZipInputStream fromInnerZip = new ZipInputStream(new FileInputStream(
160+
innerZip));
161+
162+
ZipEntry innerZipEntry;
163+
164+
while (true) {
165+
innerZipEntry = fromInnerZip.getNextEntry();
166+
167+
if (innerZipEntry == null) {
168+
fromInnerZip.close();
169+
break;
170+
}
171+
172+
if (innerZipEntry.getName().endsWith(".dex")) {
173+
file = File.createTempFile("classes_innerzip", "dex");
174+
FileOutputStream fos1 = new FileOutputStream(file);
175+
byte[] bytes1 = new byte[1024];
176+
177+
while ((length = fromInnerZip.read(bytes1)) >= 0) {
178+
fos1.write(bytes1, 0, length);
179+
}
180+
181+
fos1.close();
182+
183+
if (dexName.startsWith(zipEntry.getName())) {
184+
diTranslator.index = 99;
185+
zipFile.close();
186+
return file;
187+
}
188+
}
189+
}
190+
}
144191
}
145192
zipFile.close();
146193
} catch (Exception e) {

0 commit comments

Comments
 (0)