6
6
import dev .skidfuscator .jghost .tree .GhostClassNode ;
7
7
import dev .skidfuscator .jghost .tree .GhostContents ;
8
8
import dev .skidfuscator .jghost .tree .GhostLibrary ;
9
+ import dev .skidfuscator .logger .Logger ;
9
10
import dev .skidfuscator .obfuscator .SkidfuscatorSession ;
10
11
import lombok .experimental .UtilityClass ;
11
- import org .apache .log4j .Logger ;
12
12
import org .mapleir .app .service .ApplicationClassSource ;
13
13
import org .mapleir .asm .ClassHelper ;
14
14
import org .mapleir .asm .ClassNode ;
24
24
25
25
@ UtilityClass
26
26
public class GhostHelper {
27
- private final Logger LOGGER = Logger .getLogger (GhostHelper .class );
28
- public ApplicationClassSource getLibraryClassSource (final SkidfuscatorSession session , final File file ) {
29
- return getLibraryClassSource (session , file , false );
27
+ public ApplicationClassSource getLibraryClassSource (final SkidfuscatorSession session , final Logger logger , final File file ) {
28
+ return getLibraryClassSource (session , logger , file , false );
30
29
}
31
30
32
- public ApplicationClassSource getJvm (final SkidfuscatorSession session , final File file ) {
33
- return getLibraryClassSource (session , file , true );
31
+ public ApplicationClassSource getJvm (final SkidfuscatorSession session , final Logger logger , final File file ) {
32
+ return getLibraryClassSource (session , logger , file , true );
34
33
}
35
34
36
- public ApplicationClassSource getJvm (final boolean fuckit , final File file ) {
37
- return getLibraryClassSource (fuckit , file , true );
35
+ public ApplicationClassSource getJvm (final Logger logger , final boolean fuckit , final File file ) {
36
+ return getLibraryClassSource (logger , fuckit , file , true );
38
37
}
39
38
40
- public ApplicationClassSource getJvm (final boolean fuckit , final File file , final File mappings ) {
41
- return getLibraryClassSource (fuckit , file , mappings , true );
39
+ public ApplicationClassSource getJvm (final Logger logger , final boolean fuckit , final File file , final File mappings ) {
40
+ return getLibraryClassSource (logger , fuckit , file , mappings , true );
42
41
}
43
42
44
- public GhostLibrary getLibrary (final File lib , boolean jre ) {
45
- return getLibrary (lib , null , jre );
43
+ public GhostLibrary getLibrary (final Logger logger , final File lib , boolean jre ) {
44
+ return getLibrary (logger , lib , null , jre );
46
45
}
47
46
48
- public GhostLibrary getLibrary (final File lib , final File folder , boolean jre ) {
49
- LOGGER . info ("[+] " + lib .getAbsolutePath ());
47
+ public GhostLibrary getLibrary (final Logger logger , final File lib , final File folder , boolean jre ) {
48
+ logger . post ("[+] " + lib .getAbsolutePath ());
50
49
51
50
final StringBuilder outputPath = new StringBuilder ();
52
51
if (folder != null ) {
@@ -67,36 +66,36 @@ public GhostLibrary getLibrary(final File lib, final File folder, boolean jre) {
67
66
final GhostLibrary library ;
68
67
69
68
if (!output .exists ()) {
70
- LOGGER . info ("[?] Could not find mappings for " + lib .getAbsolutePath () + "... Creating..." );
69
+ logger . post ("[?] Could not find mappings for " + lib .getAbsolutePath () + "... Creating..." );
71
70
output .getParentFile ().mkdirs ();
72
71
output .getParentFile ().mkdir ();
73
- library = GhostHelper .createFromLibraryFile (lib );
74
- GhostHelper .saveLibraryFile (library , output );
75
- LOGGER . info ("[✓] Creating mappings for " + lib .getAbsolutePath () + "!" );
72
+ library = GhostHelper .createFromLibraryFile (logger , lib );
73
+ GhostHelper .saveLibraryFile (logger , library , output );
74
+ logger . post ("[✓] Creating mappings for " + lib .getAbsolutePath () + "!" );
76
75
} else {
77
- library = GhostHelper .readFromLibraryFile (output );
76
+ library = GhostHelper .readFromLibraryFile (logger , output );
78
77
}
79
78
80
79
return library ;
81
80
}
82
81
83
- public ApplicationClassSource getLibraryClassSource (final SkidfuscatorSession session , final File lib , boolean jvm ) {
84
- return importFile (session .isFuckIt (), getLibrary (lib , jvm ));
82
+ public ApplicationClassSource getLibraryClassSource (final SkidfuscatorSession session , final Logger logger , final File lib , boolean jvm ) {
83
+ return importFile (logger , session .isFuckIt (), getLibrary (logger , lib , jvm ));
85
84
}
86
85
87
- public ApplicationClassSource getLibraryClassSource (final boolean fuckIt , final File lib , boolean jvm ) {
88
- return importFile (fuckIt , getLibrary (lib , jvm ));
86
+ public ApplicationClassSource getLibraryClassSource (final Logger logger , final boolean fuckIt , final File lib , boolean jvm ) {
87
+ return importFile (logger , fuckIt , getLibrary (logger , lib , jvm ));
89
88
}
90
89
91
- public ApplicationClassSource getLibraryClassSource (final SkidfuscatorSession session , final File lib , final File mappings , final boolean jvm ) {
92
- return importFile (session .isFuckIt (), getLibrary (lib , mappings , jvm ));
90
+ public ApplicationClassSource getLibraryClassSource (final SkidfuscatorSession session , final Logger logger , final File lib , final File mappings , final boolean jvm ) {
91
+ return importFile (logger , session .isFuckIt (), getLibrary (logger , lib , mappings , jvm ));
93
92
}
94
93
95
- public ApplicationClassSource getLibraryClassSource (final boolean fuckit , final File lib , final File mappings , final boolean jvm ) {
96
- return importFile (fuckit , getLibrary (lib , mappings , jvm ));
94
+ public ApplicationClassSource getLibraryClassSource (final Logger logger , final boolean fuckit , final File lib , final File mappings , final boolean jvm ) {
95
+ return importFile (logger , fuckit , getLibrary (logger , lib , mappings , jvm ));
97
96
}
98
97
99
- public ApplicationClassSource importFile (final boolean fuckit , final GhostLibrary library ) {
98
+ public ApplicationClassSource importFile (final Logger logger , final boolean fuckit , final GhostLibrary library ) {
100
99
/* Create a new library class source with superior to default priority */
101
100
final ApplicationClassSource libraryClassSource = new ApplicationClassSource (
102
101
"libraries" ,
@@ -107,12 +106,12 @@ public ApplicationClassSource importFile(final boolean fuckit, final GhostLibrar
107
106
.stream ()
108
107
.map (e -> ClassHelper .create (e .read ())).collect (Collectors .toList ())
109
108
);
110
- LOGGER . info ("[✓] Imported " + library .getContents ().getClasses ().size () + " library classes..." );
109
+ logger . post ("[✓] Imported " + library .getContents ().getClasses ().size () + " library classes..." );
111
110
112
111
return libraryClassSource ;
113
112
}
114
113
115
- public GhostLibrary readFromLibraryFile (final File file ) {
114
+ public GhostLibrary readFromLibraryFile (final Logger logger , final File file ) {
116
115
try {
117
116
final FileReader fileReader = new FileReader (file );
118
117
final GhostLibrary library = Ghost
@@ -121,12 +120,12 @@ public GhostLibrary readFromLibraryFile(final File file) {
121
120
fileReader .close ();
122
121
return library ;
123
122
} catch (IOException e ) {
124
- LOGGER .error ("Failed to download library cache" , e );
123
+ logger .error ("Failed to download library cache" , e );
125
124
return null ;
126
125
}
127
126
}
128
127
129
- public GhostLibrary createFromLibraryFile (final File file ) {
128
+ public GhostLibrary createFromLibraryFile (final Logger logger , final File file ) {
130
129
final JarInfo jarInfo = new JarInfo (file );
131
130
final AbstractJarDownloader <ClassNode > downloader = file .getName ().endsWith (".jmod" )
132
131
? new SingleJmodDownloader <>(jarInfo )
@@ -135,7 +134,7 @@ public GhostLibrary createFromLibraryFile(final File file) {
135
134
try {
136
135
downloader .download ();
137
136
} catch (IOException e ) {
138
- LOGGER .error ("Failed to download library" , e );
137
+ logger .error ("Failed to download library" , e );
139
138
return null ;
140
139
}
141
140
@@ -149,7 +148,7 @@ public GhostLibrary createFromLibraryFile(final File file) {
149
148
ghostLibrary .setSha1 (byteSource .hash (Hashing .sha1 ()).toString ());
150
149
ghostLibrary .setSha256 (byteSource .hash (Hashing .sha256 ()).toString ());
151
150
} catch (Throwable e ) {
152
- LOGGER .error ("Failed to hash library" , e );
151
+ logger .error ("Failed to hash library" , e );
153
152
return null ;
154
153
}
155
154
@@ -161,14 +160,14 @@ public GhostLibrary createFromLibraryFile(final File file) {
161
160
return ghostLibrary ;
162
161
}
163
162
164
- public void saveLibraryFile (final GhostLibrary library , final File file ) {
163
+ public void saveLibraryFile (final Logger logger , final GhostLibrary library , final File file ) {
165
164
try {
166
165
final FileWriter fileWriter = new FileWriter (file );
167
166
final BufferedWriter writer = new BufferedWriter (fileWriter );
168
167
writer .write (Ghost .gson ().toJson (library , GhostLibrary .class ));
169
168
writer .close ();
170
169
} catch (IOException e ) {
171
- LOGGER .error ("Failed to download library cache" , e );
170
+ logger .error ("Failed to download library cache" , e );
172
171
return ;
173
172
}
174
173
}
0 commit comments