1
1
// Exports symbols to PCSX-Redux's symbols map including Overlays filtering
2
+ //@author Nicolas "Pixel" Noble
2
3
//@author acemon33
3
- //@category PSX
4
4
5
5
import ghidra .app .script .GhidraScript ;
6
6
import ghidra .program .model .symbol .*;
12
12
import java .net .http .HttpResponse ;
13
13
import java .util .*;
14
14
15
- public class OverlayReduxSymbols extends GhidraScript {
15
+ public class PsxOverlayReduxSymbols extends GhidraScript {
16
16
17
17
public void run () throws Exception {
18
- MemoryBlock [] MemoryBlockList = state .getCurrentProgram ().getMemory ().getBlocks ();
19
- List <String > choices = new ArrayList ();
20
- for (int i = 0 ; i < MemoryBlockList .length ; i ++) { if (MemoryBlockList [i ].isOverlay ()) choices .add (MemoryBlockList [i ].getName ()); }
21
- List <String > filterList = askChoices ("Title" , "Message" , choices );
22
- List <String > choiceList = new ArrayList ();
23
- for (String e : choices ) { choiceList .add (e + "::" ); choiceList .add (e + "__" ); }
18
+ List <String > options = this .getMemoryBlockOptions ();
19
+ List <String > filterList = askChoices ("Title" , "Message" , options );
20
+ List <String > choiceList = this .getOptionList (options );
24
21
25
22
List <String > symbols = new ArrayList <String >();
26
23
SymbolTable st = state .getCurrentProgram ().getSymbolTable ();
@@ -31,15 +28,28 @@ public void run() throws Exception {
31
28
String name = sym .getName (true );
32
29
33
30
boolean hasFilter = true ;
34
- for (String s : filterList ) { if (add .toString ().contains (s )) { hasFilter = false ; break ; } }
31
+ for (String s : filterList ) {
32
+ if (add .toString ().contains (s )) {
33
+ hasFilter = false ;
34
+ break ;
35
+ }
36
+ }
35
37
if (hasFilter )
36
38
{
37
39
boolean isNext = false ;
38
- for (String s : choiceList ) { if (add .toString ().contains (s )) { isNext = true ; break ; } }
39
- if (isNext ) continue ;
40
+ for (String s : choiceList ) {
41
+ if (add .toString ().contains (s )) {
42
+ isNext = true ;
43
+ break ;
44
+ }
45
+ }
46
+ if (isNext )
47
+ continue ;
40
48
}
41
49
42
50
symbols .add (String .format ("%08x %s" , add .getOffset (), name ));
51
+ // symbols.add(String.format("%s %s", add, name));
52
+ // println(String.format("%s %s", add, name));
43
53
}
44
54
45
55
HttpClient client = HttpClient .newHttpClient ();
@@ -50,6 +60,26 @@ public void run() throws Exception {
50
60
51
61
client .send (request , HttpResponse .BodyHandlers .ofString ());
52
62
63
+ // for (String address : symbols) println(address);
53
64
println ("size: " + symbols .size ());
54
65
}
66
+
67
+ private List <String > getMemoryBlockOptions () {
68
+ MemoryBlock [] MemoryBlockList = state .getCurrentProgram ().getMemory ().getBlocks ();
69
+ List <String > options = new ArrayList ();
70
+ for (int i = 0 ; i < MemoryBlockList .length ; i ++) {
71
+ if (MemoryBlockList [i ].isOverlay ())
72
+ options .add (MemoryBlockList [i ].getName ());
73
+ }
74
+ return options ;
75
+ }
76
+
77
+ private List <String > getOptionList (List <String > options ) {
78
+ List <String > resultList = new ArrayList ();
79
+ for (String e : options ) {
80
+ resultList .add (e + "::" );
81
+ resultList .add (e + "__" );
82
+ }
83
+ return resultList ;
84
+ }
55
85
}
0 commit comments