Skip to main content

PyMemoryModule is a Python binding for MemoryModule.

Project description

PyMemoryModule

PyMemoryModule is a Python binding for MemoryModule.

Build status

By this module, you can load DLL completely from memory - without storing on the disk first - all thanks to MemoryModule written by Joachim Bauch.

How to install

pip install pymemorymodule

Packages are available at PyPI and PyPI test.

How to use

import pymemorymodule as pymm
from ctypes import cast, c_int, CFUNCTYPE

with open("path/to/library.dll", "rb") as fp:
    # Load DLL from bytes object
    handle = pymm.MemoryLoadLibrary(fp.read())

    # __declspec(dllexport) int add(int a, int b)
    add = cast(
        pymm.MemoryGetProcAddress(handle, "add"),
        CFUNCTYPE(c_int, c_int, c_int)
    )

    # Use function exported from DLL
    assert add(1, 2) == 3

    # Free loaded DLL
    pymm.MemoryFreeLibrary(handle)

How to build and test

python setup.py build_ext -i test

How to run code check

python -m pip install flake8
python -m flake8 --show-source setup.py test.py

How to prepare README.rst

python setup.py md2rst

MemoryModule

https://github.com/fancycode/MemoryModule

License

Mozilla Public License Version 2.0 (MPL2.0)

See also license of MemoryModule.

Note: PyMemoryModule also distributes a few lines of MIT licensed codes taken from py3c project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymemorymodule-0.1.0.zip (18.8 kB view hashes)

Uploaded Source

Built Distributions

pymemorymodule-0.1.0-cp35-cp35m-win_amd64.whl (12.7 kB view hashes)

Uploaded CPython 3.5m Windows x86-64

pymemorymodule-0.1.0-cp35-cp35m-win32.whl (11.3 kB view hashes)

Uploaded CPython 3.5m Windows x86

pymemorymodule-0.1.0-cp34-cp34m-win_amd64.whl (11.7 kB view hashes)

Uploaded CPython 3.4m Windows x86-64

pymemorymodule-0.1.0-cp34-cp34m-win32.whl (10.9 kB view hashes)

Uploaded CPython 3.4m Windows x86

pymemorymodule-0.1.0-cp33-cp33m-win_amd64.whl (11.7 kB view hashes)

Uploaded CPython 3.3m Windows x86-64

pymemorymodule-0.1.0-cp33-cp33m-win32.whl (10.9 kB view hashes)

Uploaded CPython 3.3m Windows x86

pymemorymodule-0.1.0-cp27-cp27m-win_amd64.whl (11.7 kB view hashes)

Uploaded CPython 2.7m Windows x86-64

pymemorymodule-0.1.0-cp27-cp27m-win32.whl (11.0 kB view hashes)

Uploaded CPython 2.7m Windows x86

pymemorymodule-0.1.0-cp26-cp26m-win_amd64.whl (12.0 kB view hashes)

Uploaded CPython 2.6m Windows x86-64

pymemorymodule-0.1.0-cp26-cp26m-win32.whl (11.2 kB view hashes)

Uploaded CPython 2.6m Windows x86

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page