Skip to content

Commit 7c92e5e

Browse files
committed
Fix SyncBromaScript member importing and allow importing without syncing bindings
1 parent 3fffa5b commit 7c92e5e

File tree

3 files changed

+360
-256
lines changed

3 files changed

+360
-256
lines changed

scripts/ghidra/Broma.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,15 +399,17 @@ private Matcher forkMatcher(Pattern regex, Matcher of, String group, boolean fin
399399
}
400400
return matcher;
401401
}
402-
private void applyRegexes(Platform platform) {
402+
private void applyRegexes(Platform platform, boolean importGlobals) {
403403
var matcher = Regexes.GRAB_CLASS.matcher(this.data);
404404
while (matcher.find()) {
405405
this.classes.add(new Class(this, platform, matcher));
406406
}
407407

408-
var funMatcher = Regexes.GRAB_GLOBAL_FUNCTION.matcher(this.data);
409-
while (funMatcher.find()) {
410-
this.functions.add(new Function(this, null, platform, funMatcher));
408+
if (importGlobals) {
409+
var funMatcher = Regexes.GRAB_GLOBAL_FUNCTION.matcher(this.data);
410+
while (funMatcher.find()) {
411+
this.functions.add(new Function(this, null, platform, funMatcher));
412+
}
411413
}
412414
}
413415

@@ -444,13 +446,13 @@ public static Type fakeType(String name) {
444446
* @param path Path to the Broma file
445447
* @throws IOException
446448
*/
447-
public Broma(Path path, Platform platform) throws IOException {
449+
public Broma(Path path, Platform platform, boolean importGlobals) throws IOException {
448450
this.path = path;
449451
data = Files.readString(path);
450452
patches = new ArrayList<Patch>();
451453
classes = new ArrayList<Class>();
452454
functions = new ArrayList<Function>();
453-
this.applyRegexes(platform);
455+
this.applyRegexes(platform, importGlobals);
454456
}
455457

456458
/**

scripts/ghidra/ScriptWrapper.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ void updateTypeDatabase(Platform platform) throws Exception {
661661
var stringDataUnion = new UnionDataType(cat, cat.getName());
662662
stringDataUnion.add(new PointerDataType(CharDataType.dataType), pointerSize, "ptr", "");
663663
stringDataUnion.add(new ArrayDataType(CharDataType.dataType, 0x10, 0x1), 0x10, "data", "SSO");
664+
stringDataUnion.setPackingEnabled(true);
664665

665666
cat = this.createCategoryAll(category.extend("gd", "string"));
666667
var string = new StructureDataType(cat, cat.getName(), 0x0);
@@ -696,11 +697,13 @@ else if (platform == Platform.MAC_ARM || platform == Platform.MAC_INTEL || platf
696697
if (platform != Platform.MAC_INTEL) {
697698
stringShort.add(ByteDataType.dataType, 0x1, "size", "The size of the string data");
698699
}
700+
stringShort.setPackingEnabled(true);
699701

700702
cat = this.createCategoryAll(category.extend("gd", "string_data_union"));
701703
var stringDataUnion = new UnionDataType(cat, cat.getName());
702704
stringDataUnion.add(stringLong, pointerSize * 3, "long", "Long string data");
703705
stringDataUnion.add(stringShort, pointerSize * 3, "short", "Short string data");
706+
stringDataUnion.setPackingEnabled(true);
704707

705708
cat = this.createCategoryAll(category.extend("gd", "string"));
706709
var string = new StructureDataType(cat, cat.getName(), 0x0);
@@ -721,6 +724,7 @@ else if (platform == Platform.ANDROID32 || platform == Platform.ANDROID64) { //
721724
var stringDataUnion = new UnionDataType(cat, cat.getName());
722725
stringDataUnion.add(new PointerDataType(stringData), pointerSize, "data", "Pointer to the string information");
723726
stringDataUnion.add(new PointerDataType(CharDataType.dataType), pointerSize, "ptr", "Pointer to the string data");
727+
stringDataUnion.setPackingEnabled(true);
724728

725729
cat = this.createCategoryAll(category.extend("gd", "string"));
726730
var string = new StructureDataType(cat, cat.getName(), 0x0);
@@ -1070,6 +1074,14 @@ else if (platform == Platform.ANDROID32 || platform == Platform.ANDROID64) { //
10701074
ccDictElement.setPackingEnabled(true);
10711075
manager.addDataType(ccDictElement, DataTypeConflictHandler.REPLACE_HANDLER);
10721076

1077+
// cocos2d::cc_timeval
1078+
cat = this.createCategoryAll(category.extend("cocos2d", "cc_timeval"));
1079+
var ccTimeval = new StructureDataType(cat, cat.getName(), 0x0);
1080+
ccTimeval.add(LongDataType.dataType, LongDataType.dataType.getLength(), "tv_sec", "Seconds");
1081+
ccTimeval.add(IntegerDataType.dataType, 4, "tv_usec", "Microseconds");
1082+
ccTimeval.setPackingEnabled(true);
1083+
manager.addDataType(ccTimeval, DataTypeConflictHandler.REPLACE_HANDLER);
1084+
10731085
// geode::SeedValueSRV etc.
10741086

10751087
for (var x : new String[] { "SR", "RS", "VRS", "VSR", "RVS", "RSV", "SVR", "SRV" }) {

0 commit comments

Comments
 (0)