Metadata-Version: 2.1
Name: cyminhook
Version: 0.1.0
Summary: Hook functions on Windows using MinHook
Home-page: https://github.com/segevfiner/cyminhook
Author: Segev Finer
Author-email: segev208@gmail.com
License: MIT
Project-URL: Documentation, https://segevfiner.github.io/cyminhook/
Project-URL: Issue Tracker, https://github.com/segevfiner/cyminhook/issues
Keywords: MinHook
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Win32 (MS Windows)
Classifier: Intended Audience :: Developers
Classifier: Topic :: Security
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Cython
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Python: >=3.6
Description-Content-Type: text/x-rst
Provides-Extra: dev
License-File: LICENSE
License-File: NOTICE

cyminhook
=========
.. image:: https://img.shields.io/pypi/v/cyminhook.svg
   :target: https://pypi.org/project/cyminhook/
   :alt: PyPI

.. image:: https://github.com/segevfiner/cyminhook/actions/workflows/docs.yml/badge.svg
   :target: https://segevfiner.github.io/cyminhook/
   :alt: Docs

Hook functions on Windows using MinHook.

Quick Start:

.. code-block:: python

    import ctypes
    import ctypes.wintypes
    import cyminhook
    import win32api
    import win32con


    class MessageBoxExWHook(cyminhook.MinHook):
        signature = ctypes.WINFUNCTYPE(
            ctypes.c_int,
            ctypes.wintypes.HWND,
            ctypes.wintypes.LPCWSTR,
            ctypes.wintypes.LPCWSTR,
            ctypes.wintypes.UINT,
            ctypes.wintypes.WORD,
            use_last_error=True,
        )

        target = ctypes.windll.user32.MessageBoxExW

        def detour(self, hWnd, lpText, lpCaption, uType, langId):
            return self.original(hWnd, "Hooked", "Hooked", uType, langId)


    with MessageBoxExWHook() as hook:
        hook.enable()

        win32api.MessageBox(None, "Hello, World!", "Python", win32con.MB_OK)


