Skip to content

Commit

Permalink
fix output class file names on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
radioegor146 committed May 30, 2022
1 parent f85a4d3 commit 8cb3b62
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,23 @@ Also, this tool does not particulary obfuscates your code, it just transpiles it

### General usage:
```
Usage: native-obfuscator [-hV] [-b=<blackListFile>] [-l=<librariesDirectory>]
[--plain-lib-name=<libraryName>] [-w=<whiteListFile>]
<jarFile> <outputDirectory>
Usage: native-obfuscator [-ahV] [-b=<blackListFile>] [-l=<librariesDirectory>]
[-p=<platform>] [--plain-lib-name=<libraryName>]
[-w=<whiteListFile>] <jarFile> <outputDirectory>
Transpiles .jar file into .cpp files and generates output .jar file
<jarFile> Jar file to transpile
<outputDirectory> Output directory
-a, --annotations Use annotations to ignore/include native obfuscation
-b, --black-list=<blackListFile>
File with list of blacklist classes/methods for
transpilation
-h, --help Show this help message and exit.
-l, --libraries=<librariesDirectory>
Directory for dependent libraries
-p, --platform=<platform>
Target platform: hotspot - standard standalone
HotSpot JRE, std_java - java standard (as for
Android)
--plain-lib-name=<libraryName>
Plain library name for LoaderPlain
-V, --version Print version information and exit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public void process(Path inputJarPath, Path outputDir, List<Path> inputLibs,

staticClassProvider = new InterfaceStaticClassProvider(nativeDir);

Integer[] classIndexReference = new Integer[]{0};

jar.stream().forEach(entry -> {
if (entry.getName().equals(JarFile.MANIFEST_NAME)) return;

Expand Down Expand Up @@ -213,7 +215,8 @@ public void process(Path inputJarPath, Path outputDir, List<Path> inputLibs,
cachedMethods.clear();
cachedFields.clear();

try (ClassSourceBuilder cppBuilder = new ClassSourceBuilder(cppOutput, classNode.name, stringPool)) {
try (ClassSourceBuilder cppBuilder =
new ClassSourceBuilder(cppOutput, classNode.name, classIndexReference[0]++, stringPool)) {
StringBuilder instructions = new StringBuilder();

for (int i = 0; i < classNode.methods.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public class ClassSourceBuilder implements AutoCloseable {

private final StringPool stringPool;

public ClassSourceBuilder(Path cppOutputDir, String className, StringPool stringPool) throws IOException {
public ClassSourceBuilder(Path cppOutputDir, String className, int classIndex, StringPool stringPool) throws IOException {
this.className = className;
this.stringPool = stringPool;
filename = Util.escapeCppNameString(className.replace('/', '_'));
filename = String.format("%s_%d", Util.escapeCppNameString(className.replace('/', '_')), classIndex);

cppFile = cppOutputDir.resolve(filename.concat(".cpp"));
hppFile = cppOutputDir.resolve(filename.concat(".hpp"));
Expand Down

0 comments on commit 8cb3b62

Please sign in to comment.