Skip to main content

pyminhook

此库是对minhook的python包装,仅支持windows。

用法如下

import ctypes
from ctypes import wintypes
from minhook import *
if __name__ == "__main__":

    class TestHook(Hook):
        prototype = ctypes.WINFUNCTYPE(wintypes.HANDLE, wintypes.LPCWSTR)
        modname = 'kernel32'
        apiname = 'GetModuleHandleW'

        def detour(self, lpModuleName):
            print('before hook param', lpModuleName)
            ret = self.fp_orginal(lpModuleName)
            print('after hook ret = %08X' % ret)
            return ret

    h = TestHook()
    print('-' * 32)
    print('call 1 ret = %08X' % h.fp_target('kernel32'))
    print('-' * 32)
    h.disable()
    print('call 2 ret = %08X' % h.fp_target('ntdll'))
    print('-' * 32)
    h.enable()
    print('call 3 ret = %08X' % h.fp_target('user32'))

输出如下:

--------------------------------
before hook param kernel32
after hook ret = 7FF970430000
call 1 ret = 7FF970430000
--------------------------------
call 2 ret = 7FF9718E0000
--------------------------------
before hook param user32
after hook ret = 7FF970120000
call 3 ret = 7FF970120000

Release files for pyminhook 0.1

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

Source distribution (sdist)

Source distribution for pyminhook 0.1
File Size Uploaded
pyminhook-0.1.tar.gz 19.4 kB Details

Built distribution (wheel)

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

Total release size: 38.1 kB

Release files / pyminhook-0.1.tar.gz

Download URL pyminhook-0.1.tar.gz
Size 19.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a9ae9cb63d403f9649e27fa85d9163648ed3dfb7bb35e73c8fbdde295a5a43fb
BLAKE2b-256 checksum
How to use checksums
2bdbcf2fa04d3ad1cf228ab8bcb5e9a6ed15c75acb4aab71d4db540f2339e8d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.5

Release files / pyminhook-0.1-py3-none-any.whl

Download URL pyminhook-0.1-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cc1738298e59abe60a76e46ea26210e0b5cf82bf6a16e7284925570d6befa348
BLAKE2b-256 checksum
How to use checksums
edba38cfdb0e1738ff14a75a2aecc1cb33c7d9da37f2ea5f325019848431024e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.5

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

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