Skip to main content

Hook functions on Windows using MinHook

Project description

PyPI Docs

Hook functions on Windows using MinHook.

Quick Start:

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)

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

cyminhook-0.1.4.tar.gz (46.7 kB view hashes)

Uploaded Source

Built Distributions

cyminhook-0.1.4-cp312-cp312-win_amd64.whl (67.7 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

cyminhook-0.1.4-cp312-cp312-win32.whl (57.2 kB view hashes)

Uploaded CPython 3.12 Windows x86

cyminhook-0.1.4-cp311-cp311-win_amd64.whl (68.9 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

cyminhook-0.1.4-cp311-cp311-win32.whl (58.1 kB view hashes)

Uploaded CPython 3.11 Windows x86

cyminhook-0.1.4-cp310-cp310-win_amd64.whl (68.7 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

cyminhook-0.1.4-cp310-cp310-win32.whl (58.2 kB view hashes)

Uploaded CPython 3.10 Windows x86

cyminhook-0.1.4-cp39-cp39-win_amd64.whl (69.4 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

cyminhook-0.1.4-cp39-cp39-win32.whl (58.7 kB view hashes)

Uploaded CPython 3.9 Windows x86

cyminhook-0.1.4-cp38-cp38-win_amd64.whl (69.6 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

cyminhook-0.1.4-cp38-cp38-win32.whl (58.6 kB view hashes)

Uploaded CPython 3.8 Windows x86

cyminhook-0.1.4-cp37-cp37m-win_amd64.whl (70.3 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

cyminhook-0.1.4-cp37-cp37m-win32.whl (58.9 kB view hashes)

Uploaded CPython 3.7m Windows x86

cyminhook-0.1.4-cp36-cp36m-win_amd64.whl (69.1 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

cyminhook-0.1.4-cp36-cp36m-win32.whl (57.7 kB view hashes)

Uploaded CPython 3.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