Skip to main content

MinHook warp of Python

Project description

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

Project details


Release history Release notifications

This version

0.1

Download files

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

Files for pyminhook, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size pyminhook-0.1-py3-none-any.whl (18.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size pyminhook-0.1.tar.gz (19.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page