Skip to content

Commit

Permalink
Merge pull request #7 from lockbox/5-fix-api-changes
Browse files Browse the repository at this point in the history
fix binary [new] ninja warnings and errors
  • Loading branch information
lockbox authored Jun 18, 2023
2 parents 0c17a32 + 6b31dc1 commit 9aa250f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
10 changes: 8 additions & 2 deletions pd_ninja/pd_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ def import_sdk_header(bv: BinaryView):
types = parsed[0].types
functions = parsed[0].functions

if parsed is None:
log_error("Failed parsing header file")
return

# add the functions and types so we can actually use them
for t in types:
bv.define_user_type(t.name, t.type)
Expand Down Expand Up @@ -155,7 +159,7 @@ def add_platform_symbols(bv: BinaryView):
bv.define_user_data_var(PLAYDATE_KERNEL_START, ivt_type)
bv.define_user_symbol(
Symbol(SymbolType.DataSymbol,
PLAYDATE_KERNEL_START, "ivt_table")
PLAYDATE_KERNEL_START, "ivt_table")
)

# the first value in the IVT is the stack pointer, not a pointer
Expand All @@ -169,7 +173,8 @@ def add_platform_symbols(bv: BinaryView):
bv.define_auto_symbol(
Symbol(SymbolType.FunctionSymbol, value, name))

log_info("not adding platform types")
log_info("Added IVT_TABLE and created appropriate function pointers")


def apply_stabilized_types(bv: BinaryView):
"""Applies known types to known symbols. TODO
Expand All @@ -180,6 +185,7 @@ def apply_stabilized_types(bv: BinaryView):
bv to modify
"""


def register_plugin():
PluginCommand.register("pd-ninja\Load Symbols.db",
"Load symbols.db from the SDK",
Expand Down
12 changes: 11 additions & 1 deletion pd_ninja/pd_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def __init__(self, data: BinaryView):
self.pd_mem_size: int = 0

def create_sections(self):
# add the proper semantic sections on top of the data segments
# add the proper semantic sections on top of the data segments\

# slam all these sections into a single undo operation
self.begin_undo_actions()

if self.pd_view_type in [PDViewType.FULL, PDViewType.KERNEL]:
# add IVT section
Expand All @@ -85,6 +88,9 @@ def create_sections(self):
self.add_user_section("Usermode Data", user_data_start, PLAYDATE_USER_END -
user_data_start, SectionSemantics.ReadOnlyDataSectionSemantics)

# end undo actions - all these segments will be removed as 1 unit
self.commit_undo_actions()

def create_segments(self):
# add SRAM regions
for region in STM32F7_SRAM_REGIONS:
Expand Down Expand Up @@ -241,3 +247,7 @@ def is_valid_for_data(cls, data: BinaryView):

# we've now determined that this is a valid playdate view
return True

def perform_get_address_size(self) -> int:
"""This should be the sane default"""
return self.arch.address_size

0 comments on commit 9aa250f

Please sign in to comment.