3
3
import java .awt .Desktop ;
4
4
import java .awt .event .ActionEvent ;
5
5
import java .awt .event .ActionListener ;
6
+ import java .awt .event .KeyEvent ;
6
7
import java .io .ByteArrayOutputStream ;
7
8
import java .io .File ;
8
9
import java .io .FileInputStream ;
14
15
import java .net .URL ;
15
16
import java .util .ArrayList ;
16
17
import java .util .HashMap ;
17
- import java .util .List ;
18
18
import java .util .Map .Entry ;
19
19
20
20
import javax .swing .JDialog ;
76
76
* bytecode editor that works by editing per method instead of entire class, methods are in a pane like the file navigator
77
77
* Make the tabs menu and middle mouse button click work on the tab itself not just the close button.
78
78
*
79
- * 2.9.2 :
79
+ * before 3.0.0 :
80
80
* make it use that global last used inside of export as jar
81
81
* Spiffy up the plugin console with hilighted lines
82
82
* Take https://github.com/ptnkjke/Java-Bytecode-Editor visualize
83
83
* fix the randomly sometimes fucked up names on file navigation bug
84
84
* make zipfile not include the decode shit
85
+ * When you drag a folder, it must add the folder name not just the child into the root jtree path
85
86
*
86
- * -----2.9.2-----:
87
- * 02/24/2015 - Actually fixed the compiler, LOL.
87
+ * -----2.9.3-----:
88
+ * 02/28/2015 - Added drag and drop for any file.
89
+ * 02/28/2015 - Added ctrl + w to close the current opened tab.
90
+ * 02/28/2015 - Updated to CFR 0_97.jar
91
+ * 02/28/2015 - Fixed a concurrency issue with the decompilers.
92
+ * 02/28/2015 - Added image resize via scroll on mouse.
93
+ * 02/28/2015 - Added resource refreshing.
94
+ * 02/28/2015 - Im Frizzy started working on Obfuscation.
88
95
*
89
96
* @author Konloch
90
97
*
93
100
public class BytecodeViewer {
94
101
95
102
/*per version*/
96
- public static String version = "2.9.2 " ;
103
+ public static String version = "2.9.3 " ;
97
104
public static String krakatauVersion = "2" ;
98
105
/*the rest*/
99
106
public static MainViewerGUI viewer = null ;
@@ -118,10 +125,7 @@ public class BytecodeViewer {
118
125
private static long start = System .currentTimeMillis ();
119
126
public static String lastDirectory = "" ;
120
127
public static ArrayList <Process > krakatau = new ArrayList <Process >();
121
-
122
- /* ASM Re-mapping Constants */
123
128
public static Refactorer refactorer = new Refactorer ();
124
- /* ASM Re-mapping Constants */
125
129
126
130
/**
127
131
* The version checker thread
@@ -354,7 +358,7 @@ public static void exit(int i) {
354
358
* @return the currently opened ClassNode
355
359
*/
356
360
public static ClassNode getCurrentlyOpenedClassNode () {
357
- return viewer .workPane .getCurrentClass ().cn ;
361
+ return viewer .workPane .getCurrentViewer ().cn ;
358
362
}
359
363
360
364
/**
@@ -388,18 +392,6 @@ public static void updateNode(ClassNode oldNode, ClassNode newNode) {
388
392
BytecodeViewer .loadedClasses .remove (oldNode .name );
389
393
BytecodeViewer .loadedClasses .put (oldNode .name , newNode );
390
394
}
391
-
392
- /**
393
- * Replaces an old node with a new instance
394
- * @param oldNode the old instance
395
- * @param newNode the new instance
396
- */
397
- public static void relocate (String name , ClassNode node ) {
398
- if (BytecodeViewer .loadedClasses .containsKey (name ))
399
- BytecodeViewer .loadedClasses .remove (name );
400
-
401
- BytecodeViewer .loadedClasses .put (node .name , node );
402
- }
403
395
404
396
/**
405
397
* Gets all of the loaded classes as an array list
@@ -422,9 +414,6 @@ public static ArrayList<ClassNode> getLoadedClasses() {
422
414
* @return true if no errors, false if it failed to compile.
423
415
*/
424
416
public static boolean compile (boolean message ) {
425
- if (getLoadedClasses ().isEmpty ())
426
- return false ;
427
-
428
417
boolean actuallyTried = false ;
429
418
430
419
for (java .awt .Component c : BytecodeViewer .viewer .workPane .getLoadedViewers ()) {
@@ -620,6 +609,9 @@ public void run() {
620
609
new the .bytecode .club .bytecodeviewer .api .ExceptionUI (e );
621
610
}
622
611
return ;
612
+ } else {
613
+ byte [] bytes = JarUtils .getBytes (new FileInputStream (f ));
614
+ BytecodeViewer .loadedResources .put (f .getName (), bytes );
623
615
}
624
616
}
625
617
}
@@ -672,12 +664,10 @@ public static void resetWorkSpace(boolean ask) {
672
664
if (!ask ) {
673
665
loadedResources .clear ();
674
666
loadedClasses .clear ();
675
- MainViewerGUI .getComponent (FileNavigationPane .class )
676
- .resetWorkspace ();
667
+ MainViewerGUI .getComponent (FileNavigationPane .class ).resetWorkspace ();
677
668
MainViewerGUI .getComponent (WorkPane .class ).resetWorkspace ();
678
669
MainViewerGUI .getComponent (SearchingPane .class ).resetWorkspace ();
679
- the .bytecode .club .bytecodeviewer .api .BytecodeViewer
680
- .getClassNodeLoader ().clear ();
670
+ the .bytecode .club .bytecodeviewer .api .BytecodeViewer .getClassNodeLoader ().clear ();
681
671
} else {
682
672
JOptionPane pane = new JOptionPane (
683
673
"Are you sure you want to reset the workspace?\n \r It will also reset your file navigator and search." );
@@ -695,12 +685,10 @@ public static void resetWorkSpace(boolean ask) {
695
685
if (result == 0 ) {
696
686
loadedResources .clear ();
697
687
loadedClasses .clear ();
698
- MainViewerGUI .getComponent (FileNavigationPane .class )
699
- .resetWorkspace ();
688
+ MainViewerGUI .getComponent (FileNavigationPane .class ).resetWorkspace ();
700
689
MainViewerGUI .getComponent (WorkPane .class ).resetWorkspace ();
701
690
MainViewerGUI .getComponent (SearchingPane .class ).resetWorkspace ();
702
- the .bytecode .club .bytecodeviewer .api .BytecodeViewer
703
- .getClassNodeLoader ().clear ();
691
+ the .bytecode .club .bytecodeviewer .api .BytecodeViewer .getClassNodeLoader ().clear ();
704
692
}
705
693
}
706
694
}
@@ -828,6 +816,19 @@ public static String getRandomizedName() {
828
816
return name ;
829
817
}
830
818
819
+
820
+ /**
821
+ * Replaces an old node with a new instance
822
+ * @param oldNode the old instance
823
+ * @param newNode the new instance
824
+ */
825
+ public static void relocate (String name , ClassNode node ) {
826
+ if (BytecodeViewer .loadedClasses .containsKey (name ))
827
+ BytecodeViewer .loadedClasses .remove (name );
828
+
829
+ BytecodeViewer .loadedClasses .put (node .name , node );
830
+ }
831
+
831
832
/**
832
833
* Returns the BCV directory
833
834
* @return the static BCV directory
@@ -876,4 +877,46 @@ private static String quickConvert(ArrayList<String> a) {
876
877
s += r + nl ;
877
878
return s ;
878
879
}
880
+
881
+ private static long last = System .currentTimeMillis ();
882
+ /**
883
+ * Checks the hotkeys
884
+ * @param e
885
+ */
886
+ public static void checkHotKey (KeyEvent e ) {
887
+ if (System .currentTimeMillis () - last <= (4000 ))
888
+ return ;
889
+
890
+ if ((e .getKeyCode () == KeyEvent .VK_O ) && ((e .getModifiers () & KeyEvent .CTRL_MASK ) != 0 )) {
891
+ last = System .currentTimeMillis ();
892
+ JFileChooser fc = new JFileChooser ();
893
+ try {
894
+ fc .setSelectedFile (new File (BytecodeViewer .lastDirectory ));
895
+ } catch (Exception e2 ) {
896
+
897
+ }
898
+ fc .setFileFilter (viewer .new APKDEXJarZipClassFileFilter ());
899
+ fc .setFileHidingEnabled (false );
900
+ fc .setAcceptAllFileFilterUsed (false );
901
+ int returnVal = fc .showOpenDialog (BytecodeViewer .viewer );
902
+
903
+ if (returnVal == JFileChooser .APPROVE_OPTION ) {
904
+ BytecodeViewer .lastDirectory = fc .getSelectedFile ().getAbsolutePath ();
905
+ try {
906
+ BytecodeViewer .viewer .setIcon (true );
907
+ BytecodeViewer .openFiles (new File [] { fc .getSelectedFile () }, true );
908
+ BytecodeViewer .viewer .setIcon (false );
909
+ } catch (Exception e1 ) {
910
+ new the .bytecode .club .bytecodeviewer .api .ExceptionUI (e1 );
911
+ }
912
+ }
913
+ } else if ((e .getKeyCode () == KeyEvent .VK_N ) && ((e .getModifiers () & KeyEvent .CTRL_MASK ) != 0 )) {
914
+ last = System .currentTimeMillis ();
915
+ BytecodeViewer .resetWorkSpace (true );
916
+ } else if ((e .getKeyCode () == KeyEvent .VK_W ) && ((e .getModifiers () & KeyEvent .CTRL_MASK ) != 0 )) {
917
+ last = System .currentTimeMillis ();
918
+ if (viewer .workPane .getCurrentViewer () != null )
919
+ viewer .workPane .tabs .remove (viewer .workPane .getCurrentViewer ());
920
+ }
921
+ }
879
922
}
0 commit comments