Skip to content

Commit

Permalink
feat(android-stl): FIx std::vector<bool> implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaghettDev committed Dec 6, 2024
1 parent 95cadd9 commit ce70995
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion broma_ida/broma/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BromaCodegen:
FILE_HEADER = """// Generated by BromaIDA, do not modify
#include <array>
#define BROMAIDA_PLATFORM_MACRO_NAME
#define {BROMAIDA_PLATFORM_MACRO_NAME}
#define BROMAIDA_USE_CUSTOM_GNUSTL {BROMAIDA_USE_CUSTOM_GNUSTL_VALUE}
// platform shorthands
#define BROMAIDA_IS_PLATFORM_MACHO {BROMAIDA_IS_PLATFORM_MACHO_VALUE}
Expand Down
13 changes: 10 additions & 3 deletions broma_ida/broma/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,16 @@ def set_function_signature(ea: int, binding: Binding):
if "const" in binding.parameters[idx].type:
stl_type.set_const()

function_data[
idx + (0 if binding.is_static else 1)
].type = stl_type
try:
function_data[
idx + (0 if binding.is_static else 1)
].type = stl_type
except IndexError:
ida_warning(
"Couldn't fix STL parameters for "
f"""function {binding.qualified_name}!""",
)
return

if ret_has_stl_type:
stl_type = ida_tinfo_t()
Expand Down
28 changes: 23 additions & 5 deletions broma_ida/types/stl_includes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ struct custom_less : std::less<T>
bool pad;
};

#if BROMAIDA_IS_PLATFORM_ANDROID
namespace stl
{
struct _bit_iterator {
std::uintptr_t* m_bitptr;
unsigned int m_offset;
};
}
#endif

namespace std
{
// providing custom specializations for standard library templates is
Expand Down Expand Up @@ -216,12 +226,20 @@ namespace std

#if BROMAIDA_IS_PLATFORM_ANDROID
template <>
class vector<bool, allocator<bool>>
{
_Bit_iterator _M_start;
_Bit_iterator _M_finish;
_Bit_type* _M_end_of_storage;
class vector<bool> {
protected:
stl::_bit_iterator m_start;
stl::_bit_iterator m_end;
std::uintptr_t* m_capacity_end;
};

// template <>
// class vector<bool, allocator<bool>>
// {
// _Bit_iterator _M_start;
// _Bit_iterator _M_finish;
// _Bit_type* _M_end_of_storage;
// };
#elif BROMAIDA_IS_PLATFORM_MACHO
template <>
class vector<bool, allocator<bool>>
Expand Down

0 comments on commit ce70995

Please sign in to comment.