From 9770261d59b98394b5d7dc4915b80090ed050863 Mon Sep 17 00:00:00 2001 From: SpaghettDev <37266659+SpaghettDev@users.noreply.github.com> Date: Sat, 27 Jul 2024 12:47:51 -0400 Subject: [PATCH] TodoReturn is now an enum and add option to not use custom GNU STL for android --- BromaIDA.py | 2 +- broma_ida/broma/codegen.py | 10 +++++++++- broma_ida/broma/importer.py | 12 +++++++++++- broma_ida/types/cocos2d.hpp | 10 +++++----- broma_ida/types/gnustl.hpp | 2 +- broma_ida/types/stl_types.hpp | 10 +++++----- 6 files changed, 32 insertions(+), 14 deletions(-) diff --git a/BromaIDA.py b/BromaIDA.py index 01ab81a..564f765 100644 --- a/BromaIDA.py +++ b/BromaIDA.py @@ -1,4 +1,4 @@ -VERSION = "5.4.0" +VERSION = "5.5.0" __AUTHOR__ = "SpaghettDev" PLUGIN_NAME = "BromaIDA" diff --git a/broma_ida/broma/codegen.py b/broma_ida/broma/codegen.py index 62b7378..705fbe2 100644 --- a/broma_ida/broma/codegen.py +++ b/broma_ida/broma/codegen.py @@ -12,6 +12,7 @@ class BromaCodegen: #include #define BROMAIDA_PLATFORM_MACRO_NAME +#define BROMAIDA_USE_CUSTOM_GNUSTL_MACRO #define STR_CONCAT_WRAPPER(a, b) a ## b #define STR_CONCAT(a, b) STR_CONCAT_WRAPPER(a, b) @@ -20,6 +21,7 @@ class BromaCodegen: _classes: dict[str, Class] _path: Path _target_platform: BROMA_PLATFORMS + _use_custom_gnustl: bool = True _broma_path: Path _added_classes: set[str] = set() @@ -27,11 +29,13 @@ class BromaCodegen: def __init__( self, platform: BROMA_PLATFORMS, + use_custom_gnustl: bool, broma_classes: dict[str, Class], path: Path, broma_path: Path ): self._target_platform = platform + self._use_custom_gnustl = use_custom_gnustl self._classes = broma_classes self._path = path self._broma_path = broma_path @@ -54,6 +58,10 @@ def write(self): self.FILE_HEADER.replace( "BROMAIDA_PLATFORM_MACRO_NAME", self._get_bromaida_platform_macro() + ).replace( + "BROMAIDA_USE_CUSTOM_GNUSTL_MACRO", + "BROMAIDA_USE_CUSTOM_GNUSTL" if self._use_custom_gnustl \ + else "BROMAIDA_DONT_USE_CUSTOM_GNUSTL" ) ) @@ -102,7 +110,7 @@ def write(self): f.write("// Broma\n\n") f.write("// typdefs\n") - f.write("using TodoReturn = void; // :troll:\n") + f.write("enum class TodoReturn {}; // :troll:\n") f.write("\n") f.flush() diff --git a/broma_ida/broma/importer.py b/broma_ida/broma/importer.py index 9acf399..10df4bf 100644 --- a/broma_ida/broma/importer.py +++ b/broma_ida/broma/importer.py @@ -12,7 +12,7 @@ FUNC_LIB ) from ida_funcs import get_func, add_func -from ida_kernwin import ASKBTN_BTN1, ASKBTN_CANCEL +from ida_kernwin import ASKBTN_BTN1, ASKBTN_BTN2, ASKBTN_CANCEL from ida_typeinf import ( get_idati, get_ordinal_qty, func_type_data_t as ida_func_type_data_t, @@ -426,8 +426,18 @@ def _codegen_classes(self, classes: dict[str, Class]) -> bool: ) return False + use_custom_gnustl = True + if self._target_platform.startswith("android"): + if popup( + "Yes", "No", None, + "Use custom GNU STL? " + "(Recommended if you're not using genuine android GCC headers)" + ) == ASKBTN_BTN2: + use_custom_gnustl = False + BromaCodegen( self._target_platform, + use_custom_gnustl, classes, plugin_path / "broma_ida" / "types", Path("/".join(Path(self._file_path).parts[:-1])) diff --git a/broma_ida/types/cocos2d.hpp b/broma_ida/types/cocos2d.hpp index b82504b..75c9ee1 100644 --- a/broma_ida/types/cocos2d.hpp +++ b/broma_ida/types/cocos2d.hpp @@ -33,15 +33,15 @@ #include #include -#if !defined(BROMAIDA_PLATFORM_ANDROID32) && !defined(BROMAIDA_PLATFORM_ANDROID64) +#if !defined(BROMAIDA_DONT_USE_CUSTOM_GNUSTL) && (defined(BROMAIDA_PLATFORM_ANDROID32) || defined(BROMAIDA_PLATFORM_ANDROID64)) -#include -#include -#include +#include "gnustl.hpp" #else -#include "gnustl.hpp" +#include +#include +#include #endif diff --git a/broma_ida/types/gnustl.hpp b/broma_ida/types/gnustl.hpp index 1d11da5..e28c368 100644 --- a/broma_ida/types/gnustl.hpp +++ b/broma_ida/types/gnustl.hpp @@ -1,6 +1,6 @@ // taken from: https://github.com/geode-sdk/geode/blob/main/loader/include/Geode/c++stl/string.hpp -#if defined(BROMAIDA_PLATFORM_ANDROID32) || defined(BROMAIDA_PLATFORM_ANDROID64) +#if !defined(BROMAIDA_DONT_USE_CUSTOM_GNUSTL) && (defined(BROMAIDA_PLATFORM_ANDROID32) || defined(BROMAIDA_PLATFORM_ANDROID64)) #include #include diff --git a/broma_ida/types/stl_types.hpp b/broma_ida/types/stl_types.hpp index 654df9f..9352ccd 100644 --- a/broma_ida/types/stl_types.hpp +++ b/broma_ida/types/stl_types.hpp @@ -1,6 +1,10 @@ #include -#if !defined(BROMAIDA_PLATFORM_ANDROID32) && !defined(BROMAIDA_PLATFORM_ANDROID64) +#if !defined(BROMAIDA_DONT_USE_CUSTOM_GNUSTL) && (defined(BROMAIDA_PLATFORM_ANDROID32) || defined(BROMAIDA_PLATFORM_ANDROID64)) + +#include "gnustl.hpp" + +#else #include #include @@ -9,10 +13,6 @@ #include #include -#else - -#include "gnustl.hpp" - #endif #include "enums.hpp"