kmeisthax / retrogram Goto Github PK
View Code? Open in Web Editor NEWBinary program analysis toolkit
Binary program analysis toolkit
e.g. writes to 0x4000 on an MBC GB cart should set the bank number so we can trace bank calls.
Let's say we encounter a jump table, like so:
ld a, [JMP_PARAM]
ld hl, JMP_TABLE
add a, l
ld l, a
ld a, h
adc a, 0
ld h, a
ld a, [hli]
ld h, [hl]
ld l, a
jp [hl]
Right now tracing will hit the last line of the stream and then bail as the entropy of jp [hl]
is maximal. It can literally go anywhere if you don't know the value of the jump table's parameter, which goes from 8 to 9 to 16 to up to 25 bits of entropy as to where the jump lands. If we instead forked at the start on the value of a
, then we'd only have 8 bits total (although with still plenty of invalid values, which we'd have to discover by some other means).
In order to do entropy minimization, we need to actually track data values through the trace, as well as have a way to analyze data dependencies (so we can discard irrelevant forks).
When a new parent label is created in between a parent and it's child, the child's parent is not updated to the new parent.
Example: In Telefang, disassemble $A2A
- this creates a child block at $A3D
. Then disassemble $A34
- the label .LOC_A3D
will still be parented to ENTER_A2A
despite not being actually local anymore.
More generally we should enforce a restriction that all local labels must be parented to the last parent block; and furthermore prevent creation of local labels on symbols that have nonlocal crossreferences. Some assemblers do not allow you to use non-local symbols as global symbols (e.g. ENTER_A34.LOC_A3D
)
In Telefang, disassemble 4:4000. The resulting code will have excessively contextualized pointers, like so:
ENTER_4_4000:
ld a, [$PR_4!c3e1]
ld hl, 16394
call $PR_4!e97
jp [hl]
The PR_4
is the internal string form of a ROM context on this platform; those are WRAM and HOME pointers though, so their contexts should be stripped when analyzing.
ProjectDatabase
, which is our in-memory representation of retrogram.db
, should not be specific to one architecture type. It should be architecture-agnostic, so that programs from multiple architectures can be analyzed in the same database.
Database<AR>
should be separated into an architecture-erased trait that includes Any
and a concrete database type. ProjectDatabase
will store boxed, type-erased databases and use Any
to type-check AR
for methods that need to interact with an architecture.
Platform constructors should have a trait Platform
which allows handing the constructor a filesystem and getting a memory bus out of it. This should be roughly equivalent to the existing construct_platform
methods, but with the ability to hand more than one file to the constructor.
with_architecture!
can then lose the file
parameter, as not all architecture-specific code needs to have a working memory bus.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.