Inject a DLL with a Python interpreter into a process, then use pure Python to access process functions and variables!
Python C
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
c
python
README

README

MOTIVATION:
    Injecting a DLL into a running process is a common way to automate or extend a closed-source executable, due to the ease of calling and intercepting internal functions.
    This is usually done in C or C++, but large projects can benefit from scripting. Scripting is done by using C/C++ as a middle layer, that imports internal functions and exports them to the script interpreter.

WHAT IS THIS:
    A proof of concept for eliminating the middle layer for Python scripts, by using the standard ctypes library to directly access internal functions and variables.

GOALS:
    1. Accelerate the development process by making use of a REPL and higher level language.
    2. Benchmark to see if there's a noticeable performance difference in typical applications.

STRUCTURE:
    python/d2funcs.py   process internals available to an injected interpreter
    python/d2vars.py    "
    python/d2struct.py  "
    python/lib/funcdefs.py  decorators and functions used to neatly define the above
    python/lib/asm.py   inline assembler required for more advanced techniques
    python/boot/        IDLE GUI and other startup code
    python/d2py.py      interpreter entry point
    c/Engine/*          DLL with Python interpreter and nothing else
    c/Injector/*        trivial DLL injector

CURRENTLY IMPLEMENTED:
    Variable pointers.
    Standard (stdcall, cdecl, MS __fastcall) function calls.
    Ability to inline simple assembly.

ROUGH ROADMAP:
    3. Do what I can with structs. They seem to really need a pretty-printer.
    4. Look into simple intercepts.
    5. Implement a classic, resourse-intensive program (Diablo 2 maphack) and compare to a C equivalent.
    6. Look into embedding simple assembly, in order to intercept and call non-stdcall, non-cdecl functions!

Originally based on some of my old code: http://code.google.com/p/d2py/

PROOF OF CONCEPT IN PROGRESS - CODE QUALITY NOT GUARANTEED!