-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve docs, add MachOImageHeader.__iter__ for load commands
- Loading branch information
Showing
5 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ ktool | |
:maxdepth: 2 | ||
:caption: ktool Library: | ||
|
||
quickstart | ||
ktool | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,70 @@ | ||
Quick-Start Guide | ||
--------------------- | ||
|
||
TODO | ||
This is documentation for getting started with the library as a component of other python projects. | ||
|
||
Gonna try and speedrun this explanation so you can get up and running as soon as possible. | ||
|
||
Basic Concepts to understand: | ||
* There are a lot of subfiles and a few modules, but :python:`import ktool` will import all of the stuff you most likely need. | ||
* My struct system emulates C's. Or if you don't know C, it's like someone smashed together python structs and namedtuples. | ||
|
||
On the github, :sh:`src/ktool/ktool_script.py` is a fairly standard client for this library, and you can reference it to | ||
figure out how to do a lot of the basic stuff this library is capable of. | ||
|
||
Install The Library | ||
======================= | ||
|
||
:sh:`python3 -m pip install k2l` | ||
|
||
To install new updates: | ||
|
||
:sh:`python3 -m pip install --upgrade k2l` | ||
|
||
|
||
Code Examples | ||
======================= | ||
|
||
Ideally this library is fairly intuitive to use, and things just work how you expect. | ||
|
||
.. code-block:: python | ||
:caption: Load an image and dump the symbol list | ||
:emphasize-lines: 3 | ||
import ktool | ||
image = ktool.load_image('my/file.dylib') | ||
for addr, symbol in image.symbols.items(): | ||
print(f'{symbol.name} => {addr}') | ||
.. code-block:: python | ||
:caption: Dump the classlist for an image | ||
:emphasize-lines: 4 | ||
import ktool | ||
image = ktool.load_image('my/file.dylib') | ||
objc_image = ktool.load_objc_metadata(image) | ||
for objc_class in objc_image.classlist: | ||
print(f'{objc_class.name}') | ||
.. code-block:: python | ||
:caption: Loading and iterating the Mach-O Header. | ||
:emphasize-lines: 3,4 | ||
import ktool | ||
image = ktool.load_image('my/file.dylib') | ||
for load_command in image.macho_header: # Using the MachOImageHeader __iter__ functionality | ||
if isinstance(load_command, dylinker_command): | ||
print('Dylinker cmd!') | ||
print(f'{load_command.render_indented(4)}') | ||
# OR, using the basic list iterator | ||
for load_command in image.macho_header.load_commands: | ||
if isinstance(load_command, dylinker_command): | ||
print('Dylinker cmd!') | ||
print(f'{load_command.render_indented(4)}') | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters