-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: bring back smali files support (#961)
- Loading branch information
Showing
28 changed files
with
334 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ node_modules/ | |
jadx-output/ | ||
*-tmp/ | ||
**/tmp/ | ||
*.jobf | ||
|
||
*.class | ||
*.dump | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package jadx.cli; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
import java.nio.file.Files; | ||
import java.nio.file.LinkOption; | ||
import java.nio.file.Path; | ||
import java.nio.file.PathMatcher; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import jadx.core.utils.files.FileUtils; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class TestInput { | ||
private static final Logger LOG = LoggerFactory.getLogger(TestInput.class); | ||
|
||
@Test | ||
public void testDexInput() throws Exception { | ||
decompile("dex", "samples/hello.dex"); | ||
} | ||
|
||
@Test | ||
public void testSmaliInput() throws Exception { | ||
decompile("smali", "samples/HelloWorld.smali"); | ||
} | ||
|
||
private void decompile(String tmpDirName, String inputSample) throws URISyntaxException, IOException { | ||
StringBuilder args = new StringBuilder(); | ||
Path tempDir = FileUtils.createTempDir(tmpDirName); | ||
args.append("-v "); | ||
args.append("-d ").append(tempDir.toAbsolutePath()).append(' '); | ||
|
||
URL resource = getClass().getClassLoader().getResource(inputSample); | ||
assertThat(resource).isNotNull(); | ||
String sampleFile = resource.toURI().getRawPath(); | ||
args.append(sampleFile); | ||
|
||
int result = JadxCLI.execute(args.toString().split(" ")); | ||
assertThat(result).isEqualTo(0); | ||
List<Path> resultJavaFiles = collectJavaFilesInDir(tempDir); | ||
assertThat(resultJavaFiles).isNotEmpty(); | ||
} | ||
|
||
private static List<Path> collectJavaFilesInDir(Path dir) throws IOException { | ||
PathMatcher matcher = dir.getFileSystem().getPathMatcher("glob:**.java"); | ||
try (Stream<Path> pathStream = Files.walk(dir)) { | ||
return pathStream | ||
.filter(p -> Files.isRegularFile(p, LinkOption.NOFOLLOW_LINKS)) | ||
.peek(f -> LOG.debug("File in result dir: {}", f)) | ||
.filter(matcher::matches) | ||
.collect(Collectors.toList()); | ||
} | ||
} | ||
|
||
@AfterAll | ||
public static void cleanup() { | ||
FileUtils.clearTempRootDir(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.class LHelloWorld; | ||
.super Ljava/lang/Object; | ||
.source "HelloWorld.java" | ||
|
||
.method constructor <init>()V | ||
.registers 1 | ||
|
||
.line 1 | ||
invoke-direct {p0}, Ljava/lang/Object;-><init>()V | ||
|
||
return-void | ||
.end method | ||
|
||
.method public static main([Ljava/lang/String;)V | ||
.registers 2 | ||
|
||
.line 3 | ||
sget-object p0, Ljava/lang/System;->out:Ljava/io/PrintStream; | ||
|
||
const-string v0, "Hello, World" | ||
|
||
invoke-virtual {p0, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V | ||
|
||
.line 4 | ||
return-void | ||
.end method |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.