diff --git a/scripts/ghidra/Broma.java b/scripts/ghidra/Broma.java index 801aa437a..b694f94f9 100644 --- a/scripts/ghidra/Broma.java +++ b/scripts/ghidra/Broma.java @@ -257,7 +257,7 @@ private Member(Broma broma, Class parent, Platform platform, Matcher matcher) { var addrMatcher = broma.forkMatcher(Regexes.GRAB_PLATFORM_ADDRESS, matcher, "platforms", false); while (addrMatcher.find()) { mutPaddings.put( - Platform.fromShortName(addrMatcher.group("platform")), + Platform.fromShortName(addrMatcher.group("platform"), platform), Integer.parseInt(addrMatcher.group("addr"), 16) ); } diff --git a/scripts/ghidra/PaddingInfo.java b/scripts/ghidra/PaddingInfo.java index e09acccc3..a65e29f1c 100644 --- a/scripts/ghidra/PaddingInfo.java +++ b/scripts/ghidra/PaddingInfo.java @@ -12,7 +12,7 @@ public PaddingInfo(Map platforms, int offset) { this.offset = offset; } - public PaddingInfo(String comment) { + public PaddingInfo(String comment, Platform curPlatform) { if (comment == null || comment.isEmpty()) { this.platforms = Map.of(); this.offset = -1; @@ -35,7 +35,7 @@ public PaddingInfo(String comment) { offset = addr; } else { - this.platforms.put(Platform.fromShortName(matcher.group("platform")), addr); + this.platforms.put(Platform.fromShortName(matcher.group("platform"), curPlatform), addr); } } this.offset = offset; diff --git a/scripts/ghidra/Platform.java b/scripts/ghidra/Platform.java index bc904d5e5..e8c2a7b7f 100644 --- a/scripts/ghidra/Platform.java +++ b/scripts/ghidra/Platform.java @@ -27,9 +27,9 @@ private Platform(String longName, String shortName, boolean singleBinary, String this.groupName = groupName; } - public static Platform fromShortName(String shortName) { + public static Platform fromShortName(String shortName, Platform curPlatform) { for (var v : Platform.values()) { - if (v.respondsToName(shortName)) { + if (v.respondsToName(shortName, curPlatform)) { return v; } } @@ -55,8 +55,11 @@ public String getGroupName() { public boolean hasSingleBinary() { return this.singleBinary; } - public boolean respondsToName(String shortName) { + public boolean respondsToName(String shortName, Platform curPlatform) { if (this.shortName.equals(shortName)) { + if ((this == Platform.WINDOWS32 || this == Platform.WINDOWS64) && (curPlatform == Platform.WINDOWS32 || curPlatform == Platform.WINDOWS64)) { + return this == curPlatform; + } return true; } if (this.groupName != null && this.groupName.equals(shortName)) { diff --git a/scripts/ghidra/Regexes.java b/scripts/ghidra/Regexes.java index 197bec409..ba68a3646 100644 --- a/scripts/ghidra/Regexes.java +++ b/scripts/ghidra/Regexes.java @@ -104,7 +104,7 @@ public static final Pattern grabMemberOrPad(String memberName) { public static final Pattern GRAB_CLASS = grabClass("(?:\\w+::)*\\w+"); public static final Pattern GRAB_TYPE = generateRecursiveRegex( "(?\\bconst\\s+)?(?\\b(?:signed|unsigned)\\s+)?(?(?:\\w+::)*\\w+)(?