Skip to main content

PyDLLManager

PyDLLManager is a Python library designed to simplify the process of loading and interacting with DLL (Dynamic Link Library) files. It allows you to effortlessly load DLLs, call functions, and manage data types using the ctypes module in Python.

Features

  • Load DLLs: Easily load DLL files into your Python program.
  • Retrieve Functions: Access functions within the DLL with automatic handling of argument and return types.
  • Thread Safety: Includes built-in thread safety using threading.Lock.
  • Decorator Support: Use the DllImprt decorator to automatically load and call functions from DLLs.

Installation

To install PyDLLManager, simply run the following pip command:

pip install pydllmanager

Usage

Basic Usage Example

  1. First, you need to initialize a DLLLoader object by providing the path to your DLL file.
from pydllmanager import DLLLoader, ctypes_type

dll_path = "path/to/your/dll/file.dll"
loader = DLLLoader(dll_path)
  1. Then, you can load functions from the DLL using the get_function method:
add_func = loader.get_function('add', [ctypes_type(int), ctypes_type(int)], ctypes_type(int))
result = add_func(5, 3)
print(result)  # Expected output: 8 (depends on the DLL function)

Using the include Decorator

The DllImprt decorator allows you to decorate functions to automatically load them from a DLL.

from pydllmanager import LoaderLibrary

loader = LoaderLibrary("path/to/your/dll/file.dll")
loader.load()

@loader.include()
def add(a: int, b: int) -> int: ... # The function is loaded from the DLL automatically

result = add(5, 3)
print(result)  # Expected output: 8

Example Code

from pydllmanager import DLLLoader, ctypes_type, LoaderLibrary

# Using DLLLoader to load and call a function
loader = DLLLoader("path/to/your/dll/file.dll")
subtract_func = loader.get_function('subtract', [ctypes_type(int), ctypes_type(int)], ctypes_type(int))
result = subtract_func(10, 4)
print(result)  # Expected output: 6 (depends on the DLL function)

loader = LoaderLibrary("path/to/your/dll/file.dll")
loader.load()

# Using DllImprt decorator
@loader.include()
def multiply(a: int, b: int) -> int: ...

result = multiply(2, 3)
print(result)  # Expected output: 6

Exception Handling

PyDLLManager defines a custom exception DLLManagerError to handle any errors during DLL loading or function retrieval. You can use it as follows:

try:
    loader = DLLLoader("invalid/path/to/dll.dll")
except DLLManagerError as e:
    print(f"Error loading DLL: {e}")

Compatibility

  • Supports both 32-bit and 64-bit architectures.
  • Compatible with most platforms that support the ctypes module in Python.

Contributing

Contributions to PyDLLManager are welcome! Feel free to fork the repository, submit issues, or open pull requests with improvements or bug fixes.

  1. Fork the repository.
  2. Clone it to your local machine.
  3. Make your changes and commit them.
  4. Push to your fork and create a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

  • Omar Mohamed
    GitHub
    Version: 1.1.0

Note: Be sure to replace "path/to/your/dll/file.dll" with the actual path to your DLL file in the examples.

thank you for using my project

Metadata

Release files for pydllmanager 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydllmanager 0.1.0
File Size Uploaded Provenance Actions
pydllmanager-0.1.0.tar.gz 4.3 kB Without provenance Details for pydllmanager-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pydllmanager 0.1.0
File Interpreter ABI Platform Actions
pydllmanager-0.1.0-py3-none-any.whl Python 3 none any Details for pydllmanager-0.1.0-py3-none-any.whl

Total release size: 8.8 kB

Release files / pydllmanager-0.1.0.tar.gz

Download URL pydllmanager-0.1.0.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
93201c078feba669a90a6f9526d834d4a9c2fb13b4aad4ed7830b100df4b681a
BLAKE2b-256 checksum
How to use checksums
9e4c76d267fb10480322c539a58db4545255c85d133e9655b82903ba48787280
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / pydllmanager-0.1.0-py3-none-any.whl

Download URL pydllmanager-0.1.0-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77cf3178a0dfcb1a7f226836c9dba3c824c776bc35efd3cb680ab17950417643
BLAKE2b-256 checksum
How to use checksums
94ba314c10413b64762e0b6e50b830ac24ee5d4d6a085d42e7fa51ce72f34c9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Security for pydllmanager 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page