pyMHF 0.1.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. pymhf-0.1.7/.github/workflows/pipeline.yml +88 -0
  2. pymhf-0.1.7/.gitignore +10 -0
  3. pymhf-0.1.7/LICENCE.md +21 -0
  4. pymhf-0.1.7/PKG-INFO +77 -0
  5. pymhf-0.1.7/README.md +47 -0
  6. pymhf-0.1.7/docs/api/mod_loader.md +12 -0
  7. pymhf-0.1.7/docs/change_log.md +45 -0
  8. pymhf-0.1.7/docs/settings.md +32 -0
  9. pymhf-0.1.7/docs/setup.md +16 -0
  10. pymhf-0.1.7/docs/writing_libraries.md +21 -0
  11. pymhf-0.1.7/pyMHF.egg-info/PKG-INFO +77 -0
  12. pymhf-0.1.7/pyMHF.egg-info/SOURCES.txt +45 -0
  13. pymhf-0.1.7/pyMHF.egg-info/dependency_links.txt +1 -0
  14. pymhf-0.1.7/pyMHF.egg-info/entry_points.txt +2 -0
  15. pymhf-0.1.7/pyMHF.egg-info/requires.txt +9 -0
  16. pymhf-0.1.7/pyMHF.egg-info/top_level.txt +1 -0
  17. pymhf-0.1.7/pymhf/__init__.py +200 -0
  18. pymhf-0.1.7/pymhf/_preinject.py +5 -0
  19. pymhf-0.1.7/pymhf/core/__init__.py +0 -0
  20. pymhf-0.1.7/pymhf/core/_internal.py +32 -0
  21. pymhf-0.1.7/pymhf/core/_types.py +35 -0
  22. pymhf-0.1.7/pymhf/core/caching.py +83 -0
  23. pymhf-0.1.7/pymhf/core/calling.py +82 -0
  24. pymhf-0.1.7/pymhf/core/common.py +12 -0
  25. pymhf-0.1.7/pymhf/core/errors.py +12 -0
  26. pymhf-0.1.7/pymhf/core/hashing.py +11 -0
  27. pymhf-0.1.7/pymhf/core/hooking.py +673 -0
  28. pymhf-0.1.7/pymhf/core/importing.py +47 -0
  29. pymhf-0.1.7/pymhf/core/logging.py +25 -0
  30. pymhf-0.1.7/pymhf/core/math.py +41 -0
  31. pymhf-0.1.7/pymhf/core/memutils.py +268 -0
  32. pymhf-0.1.7/pymhf/core/mod_loader.py +381 -0
  33. pymhf-0.1.7/pymhf/core/module_data.py +23 -0
  34. pymhf-0.1.7/pymhf/core/process.py +67 -0
  35. pymhf-0.1.7/pymhf/core/protocols.py +58 -0
  36. pymhf-0.1.7/pymhf/core/utils.py +152 -0
  37. pymhf-0.1.7/pymhf/extensions/cpptypes.py +212 -0
  38. pymhf-0.1.7/pymhf/gui/__init__.py +1 -0
  39. pymhf-0.1.7/pymhf/gui/decorators.py +105 -0
  40. pymhf-0.1.7/pymhf/gui/gui.py +345 -0
  41. pymhf-0.1.7/pymhf/gui/protocols.py +26 -0
  42. pymhf-0.1.7/pymhf/injected.py +267 -0
  43. pymhf-0.1.7/pymhf/log_terminal.py +134 -0
  44. pymhf-0.1.7/pymhf/main.py +340 -0
  45. pymhf-0.1.7/pyproject.toml +70 -0
  46. pymhf-0.1.7/setup.cfg +4 -0
  47. pymhf-0.1.7/uv.lock +3417 -0
@@ -0,0 +1,88 @@
1
+ name: pyMHF
2
+
3
+ on:
4
+ # Run on all branches except for the gh-pages branch
5
+ push:
6
+ paths-ignore:
7
+ - '*.md'
8
+ branches-ignore:
9
+ - 'gh-pages'
10
+ tags:
11
+ - '*'
12
+
13
+ jobs:
14
+ build_test:
15
+ name: Build artefacts
16
+ runs-on: Windows-latest
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ py_ver: [{version: '3.9'}] # , {version: '3.10'}, {version: '3.11'}]
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+ with:
24
+ fetch-depth: 0
25
+ - name: Set up Python ${{ matrix.py_ver.version}}
26
+ uses: actions/setup-python@v5
27
+ with:
28
+ python-version: "${{ matrix.py_ver.version}}"
29
+ - name: Install dependencies
30
+ run: |
31
+ python -m pip install --upgrade pip uv
32
+ uv sync --frozen --dev
33
+ - name: Build Python ${{ matrix.py_ver.version}} wheel
34
+ run: uv build
35
+ - name: Lint and format code
36
+ run: |
37
+ uv run ruff check ./pymhf
38
+ uv run ruff format --check ./pymhf
39
+ uv run python -m twine check ./dist/*
40
+ - name: Upload Wheels
41
+ uses: actions/upload-artifact@v4
42
+ with:
43
+ name: python-package-distributions
44
+ path: dist/
45
+ release:
46
+ name: Release pyMHF wheels and source build to PyPI
47
+ # Only run this job if the commit was tagged.
48
+ if: startsWith(github.ref, 'refs/tags')
49
+ needs:
50
+ - build_test
51
+ runs-on: ubuntu-latest
52
+ environment:
53
+ name: pypi
54
+ url: https://pypi.org/p/pyMHF
55
+ permissions:
56
+ id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
57
+ steps:
58
+ - name: Download files for release
59
+ uses: actions/download-artifact@v4
60
+ with:
61
+ name: python-package-distributions
62
+ path: dist/
63
+ - name: Publish package distributions to PyPI
64
+ uses: pypa/gh-action-pypi-publish@release/v1
65
+ with:
66
+ attestations: true
67
+
68
+ test-release:
69
+ name: Release pyMHF wheels and source build to test-PyPI
70
+ needs:
71
+ - build_test
72
+ runs-on: ubuntu-latest
73
+ environment:
74
+ name: testpypi
75
+ url: https://test.pypi.org/p/pyMHF
76
+ permissions:
77
+ id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
78
+ steps:
79
+ - name: Download files for release
80
+ uses: actions/download-artifact@v4
81
+ with:
82
+ name: python-package-distributions
83
+ path: dist/
84
+ - name: Publish package distributions to PyPI
85
+ uses: pypa/gh-action-pypi-publish@release/v1
86
+ with:
87
+ repository-url: https://test.pypi.org/legacy/
88
+ attestations: true
pymhf-0.1.7/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ build/*
2
+ *.egg-info/
3
+ **/__pycache__/**
4
+ **/logs/**
5
+ **/CRITICAL_ERROR.txt
6
+ dist/*
7
+ logs
8
+ mods
9
+ .venv/
10
+ /run_*.py
pymhf-0.1.7/LICENCE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 monkeyman192
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
pymhf-0.1.7/PKG-INFO ADDED
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyMHF
3
+ Version: 0.1.7
4
+ Summary: python Modding and Hooking Framework
5
+ Author: monkeyman192
6
+ Maintainer: monkeyman192
7
+ Project-URL: Homepage, https://github.com/monkeyman192/pyMHF
8
+ Project-URL: Repository, https://github.com/monkeyman192/pyMHF.git
9
+ Keywords: hooking,games,hacking,modding
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Environment :: Win32 (MS Windows)
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: Microsoft
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENCE.md
21
+ Requires-Dist: cyminhook>=0.1.4
22
+ Requires-Dist: psutil~=5.9.5
23
+ Requires-Dist: pymem[speed]~=1.12.0
24
+ Requires-Dist: keyboard
25
+ Requires-Dist: pywin32
26
+ Requires-Dist: dearpygui~=1.11.0
27
+ Requires-Dist: questionary
28
+ Requires-Dist: pywinctl
29
+ Requires-Dist: packaging
30
+
31
+ # pyMHF
32
+
33
+ *pyMHF* is a python Modding and Hooking Framework.
34
+ It is designed to make it very easy to create libraries for any game or application which can then be used to make mods.
35
+
36
+ ## Features
37
+
38
+ *pyMHF* contains a number of important features to make creatting a modding library as easy as possible:
39
+
40
+ ### Simple hooking
41
+
42
+ To create a hook, the following pieces of information are required:
43
+ - The relative offset of the function from the start of the binary or the byte signature [WIP] of the function.
44
+ - The function call signature. This is the return and argument types, specified as would be expected by using Pythons' `ctypes` library.
45
+ - A class definition which can be used to indicate the hierarchy of functions to allow for simpler calling of functions from the code.
46
+
47
+ Once this is provided, hooks can be defined as methods within a `Mod` class, allowing for complex behaviour to be implemented with little effort.
48
+
49
+ ### Ability to hook functions across multiple binaries
50
+
51
+ Whilst not fully feature complete yet, it will be possible to specify what loaded libraries or binaries the functions reside within, to allow for hook function in both the main executable as well as loaded ones.
52
+
53
+ ### Automatically generated GUI
54
+
55
+ A GUI (using [DearPyGUI](https://github.com/hoffstadt/DearPyGui)) is automatically generated for the program. All mods will appear automatically as separate tabs, and widgets can be added by way of function decorators within the mod to easily create simple interfaces.
56
+
57
+ ### "Compound hooks"
58
+
59
+ All hooks are defined as either being run **before** or **after** the original function. This allows *pyMHF* to construct what we call "compound hooks" which may consist of any number of detour methods across any number of mods. This means that two mods which affect the same function may coexist (generally) peacefully.
60
+
61
+ **Note**: The order of execution of detours is arbitrary, so one must not expect their detour to be run before or after any other detour of the same hook.
62
+
63
+ ### Custom callbacks
64
+
65
+ Modding libraries can define custom callbacks which can be used to allow methods to be called whenever they are triggered. Examples include *every game tick* or *level change* for example.
66
+
67
+ ### Keyboard callbacks
68
+
69
+ It is possible to declare methods to be run when a certain key is pressed or released.
70
+
71
+ ### Reloadability
72
+
73
+ One major annoyance when testing and debugging mods at this level is the requirement to often have to reload the game to reload any mods and hooks which have been created. *pyMHF* has the ability to reload mods (either via the GUI, or via the injected python REPL). This will re-read the python file and reload any hooks or keyboard callbacks which are defined in it.
74
+
75
+ ### Mod states
76
+
77
+ While reloading mods is great, sometimes objects are instantiated once when the game starts and that is it. To avoid losing these instances across reloads, there is the concept of a `ModState` object which will persist across reloads. These object are bound to the mod itself so it is generally recommended to use these to store any kind of state (and in fact, can be serialized and deserialized to json as a form of saving).
pymhf-0.1.7/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # pyMHF
2
+
3
+ *pyMHF* is a python Modding and Hooking Framework.
4
+ It is designed to make it very easy to create libraries for any game or application which can then be used to make mods.
5
+
6
+ ## Features
7
+
8
+ *pyMHF* contains a number of important features to make creatting a modding library as easy as possible:
9
+
10
+ ### Simple hooking
11
+
12
+ To create a hook, the following pieces of information are required:
13
+ - The relative offset of the function from the start of the binary or the byte signature [WIP] of the function.
14
+ - The function call signature. This is the return and argument types, specified as would be expected by using Pythons' `ctypes` library.
15
+ - A class definition which can be used to indicate the hierarchy of functions to allow for simpler calling of functions from the code.
16
+
17
+ Once this is provided, hooks can be defined as methods within a `Mod` class, allowing for complex behaviour to be implemented with little effort.
18
+
19
+ ### Ability to hook functions across multiple binaries
20
+
21
+ Whilst not fully feature complete yet, it will be possible to specify what loaded libraries or binaries the functions reside within, to allow for hook function in both the main executable as well as loaded ones.
22
+
23
+ ### Automatically generated GUI
24
+
25
+ A GUI (using [DearPyGUI](https://github.com/hoffstadt/DearPyGui)) is automatically generated for the program. All mods will appear automatically as separate tabs, and widgets can be added by way of function decorators within the mod to easily create simple interfaces.
26
+
27
+ ### "Compound hooks"
28
+
29
+ All hooks are defined as either being run **before** or **after** the original function. This allows *pyMHF* to construct what we call "compound hooks" which may consist of any number of detour methods across any number of mods. This means that two mods which affect the same function may coexist (generally) peacefully.
30
+
31
+ **Note**: The order of execution of detours is arbitrary, so one must not expect their detour to be run before or after any other detour of the same hook.
32
+
33
+ ### Custom callbacks
34
+
35
+ Modding libraries can define custom callbacks which can be used to allow methods to be called whenever they are triggered. Examples include *every game tick* or *level change* for example.
36
+
37
+ ### Keyboard callbacks
38
+
39
+ It is possible to declare methods to be run when a certain key is pressed or released.
40
+
41
+ ### Reloadability
42
+
43
+ One major annoyance when testing and debugging mods at this level is the requirement to often have to reload the game to reload any mods and hooks which have been created. *pyMHF* has the ability to reload mods (either via the GUI, or via the injected python REPL). This will re-read the python file and reload any hooks or keyboard callbacks which are defined in it.
44
+
45
+ ### Mod states
46
+
47
+ While reloading mods is great, sometimes objects are instantiated once when the game starts and that is it. To avoid losing these instances across reloads, there is the concept of a `ModState` object which will persist across reloads. These object are bound to the mod itself so it is generally recommended to use these to store any kind of state (and in fact, can be serialized and deserialized to json as a form of saving).
@@ -0,0 +1,12 @@
1
+ # Mod Loader
2
+
3
+ The `pymhf/core/mod_loader.py` file contains a number of functions and classes related to loading of mods.
4
+
5
+ ## Classes
6
+
7
+ ### `class ModState(ABC)`:
8
+ This class is the Base class which is used to indicate that the inheriting class is a "Mod State" (see docs...) # TODO: add link.
9
+
10
+ ### `class Mod(ABC)`:
11
+ The base class for any mod.
12
+ No methods are currently defined on this class, however, if your mod class has its own `__init__` method, then you MUST call `super().__init__()` in it otherwise the mod will not be properly initialised and an error will be raised to indicate this.
@@ -0,0 +1,45 @@
1
+ # Change Log
2
+
3
+ ## Current
4
+
5
+ ### 0.1.6 (08/09/2024)
6
+
7
+ - Add ability for GUI widgets to reload when their associated mod gets reloaded ([gh-4](https://github.com/monkeyman192/pyMHF/issues/4))
8
+ - Add `extra_args` option to GUI field type decorators (eg, `FLOAT`) which are passed through to DearPyGui ([gh-8](https://github.com/monkeyman192/pyMHF/issues/8))
9
+ - Fix issues with hooking multiple functions which are overloads of the same base function.
10
+ - Add the ability for patterns to be hooked up using the `FUNC_PATTERNS` data in implementing libraries ([gh-14](https://github.com/monkeyman192/pyMHF/issues/14))
11
+
12
+ ### 0.1.5 (26/08/2024)
13
+
14
+ - Allow overriding of function return values.
15
+ - Fixed issue with `after` manual hooks with a `_result_` argument.
16
+ - Implement pattern scanning functionality ([gh-1](https://github.com/monkeyman192/pyMHF/issues/1))
17
+
18
+ ### 0.1.4 (14/08/2024)
19
+
20
+ - Overhauled config system to provide a more user-friendly experience.
21
+ - Fixed a critical bug in hooking which meant that no result was returned.
22
+ - Fixed an issue injecting variables into pymhf.
23
+
24
+ ### 0.1.3 (31/07/2024)
25
+
26
+ - Implemented manual hooks. These are a decorator which have the can take an offset, name, and function definition, and allow for hooking a function without having to rely on the underlying library which utilises pymhf.
27
+ - Made changes so that libraries can be installed as plugins to pymhf so that they can be run like `pymhf <libname>`
28
+
29
+ ### 0.1.2 (15/07/2024)
30
+
31
+ - Made improvements to config reading
32
+
33
+ ### 0.1.1 (05/07/2024)
34
+
35
+ - Fixed issues loading applications which aren't loaded with steam.
36
+ - Fixed logging number of mods loaded.
37
+ - Implemented custom triggers. They can be implemented by libraries which use this framework to enable custom triggers which are specific to the game/application.
38
+ - Fixed some issues with reloading of mods when there are multiple mods all contributing to compound hooks, including hooks with completely disabled detours.
39
+ - Added `@no_gui` decorator which can be applied to a `Mod` class to indicate that it doesn't need to be shown in the GUI.
40
+
41
+ ## Previous
42
+
43
+ ### 0.1.0 (30/06/2024)
44
+
45
+ - Initial release. Much of the functionality has been copied over from NMS.py which was how this project started.
@@ -0,0 +1,32 @@
1
+ # pyMHF settings file
2
+
3
+ *pyMHF* contains a file called `pymhf.cfg` which (currently) must be situated within the root directory of the modding library (cf. [here](../writing_libraries.md))
4
+ This file has a number of properties in different sections. Some are required and others are not:
5
+
6
+ ## `binary` section:
7
+
8
+ This section handles properties which relate to the game or program that the library will be for.
9
+
10
+ - **path**: The full path of the binary to be run.
11
+
12
+ - **mod_dir**: The full path to the directory containing the mods to be run.
13
+
14
+ - **hash**: The `SHA1` hash of the exe. This is used to ensure that the binary matches what is expected by the library exactly.
15
+
16
+ - **steam_guid** [optional]: If the game is run through steam, this should set to the Steam App ID. This can be found by right clicking on the game in your library and selecting "Properties...". The value can be found under the "Updates" option on the left.
17
+
18
+ - **required_assemblies**: [optional]: A list of assemblies that are required to be loaded by the binary at `path` for the game to be considered "loaded". For now, if this is provided, it will also be the binary within which offsets are found relative to, however this will be relaxed in the future as better functionality regarding this is developed.
19
+
20
+ ## `pymhf` section:
21
+
22
+ - **log_level**: Whether to log at the standard level (`INFO`), or more in-depth (`DEBUG`).
23
+
24
+ ## `gui` section:
25
+
26
+ This section related to properties specifically for the GUI which is auto-generated.
27
+
28
+ - **shown**: Whether or not to show the GUI (`True` or `False`).
29
+
30
+ - **scale**: The scale of the GUI. For some high-resolution monitors the GUI may end up scaled down when running from within a process, so sometimes this may need to be set to 1.5 for the GUI to look correct.
31
+
32
+ - **log_window_name_override** The text to display at the top of the log window.
@@ -0,0 +1,16 @@
1
+ # Setup
2
+
3
+ 1. Ensure that python 3.9+ is installed
4
+ 1. Install the required dependencies. Run the following in the current directory: `python -m pip install .`
5
+ 1. Modify `pymhf.cfg` to have the correct binary path. Note that currently the only supported binary is the one which has the hash listed in the file. You can check the hash of your NMS binary by running `certutil -hashfile "NMS.exe" SHA1` in the directory with the NMS.exe binary.
6
+ 1. in a terminal run `python main.py`
7
+
8
+ You should have another popup appear with the pyMHF logo at the top, and then a series of log messages.
9
+ If this doesn't occur then your firewall may be blocking the port 6770, so make sure that a TCP connection is allowed on this port on your local network (ie. 127.0.0.0, or possibly 0.0.0.)
10
+
11
+ If all goes well you should see `"Serving on executor ('127.0.0.1', 6770)"`
12
+ Once you see this message you are fine to press anything in the other window where you entered `python main.py`.
13
+
14
+ Any exceptions will be logged to a file named `CRITICAL_ERROR.txt`, and logs will be placed in a `logs` directory.
15
+
16
+ - If you want to stop the application, you can press `ctrl + C` in the window you started the process in to kill it.
@@ -0,0 +1,21 @@
1
+ # Writing Libraries
2
+
3
+ The primary usage of *pyMHF* is to facilitate writing python libraries which can then be used to write mods.
4
+ *pyMHF* provides all the tools required to make setting up a library easy, so that one only has to provide the definitions and all the hooking and mod complexity will be handled automatically.
5
+
6
+ Follow the next steps to get your library project set up.
7
+
8
+ ## Creating the folder structure
9
+
10
+ ```
11
+ LibraryName
12
+ ├── functions
13
+ │ ├── __init__.py
14
+ │ ├── call_sigs.py
15
+ │ ├── hooks.py
16
+ │ ├── offsets.py
17
+ ├── types
18
+ │ ├── structs.py
19
+ ├── __init__.py
20
+ └── pymhf.cfg
21
+ ```
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyMHF
3
+ Version: 0.1.7
4
+ Summary: python Modding and Hooking Framework
5
+ Author: monkeyman192
6
+ Maintainer: monkeyman192
7
+ Project-URL: Homepage, https://github.com/monkeyman192/pyMHF
8
+ Project-URL: Repository, https://github.com/monkeyman192/pyMHF.git
9
+ Keywords: hooking,games,hacking,modding
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Environment :: Win32 (MS Windows)
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: Microsoft
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENCE.md
21
+ Requires-Dist: cyminhook>=0.1.4
22
+ Requires-Dist: psutil~=5.9.5
23
+ Requires-Dist: pymem[speed]~=1.12.0
24
+ Requires-Dist: keyboard
25
+ Requires-Dist: pywin32
26
+ Requires-Dist: dearpygui~=1.11.0
27
+ Requires-Dist: questionary
28
+ Requires-Dist: pywinctl
29
+ Requires-Dist: packaging
30
+
31
+ # pyMHF
32
+
33
+ *pyMHF* is a python Modding and Hooking Framework.
34
+ It is designed to make it very easy to create libraries for any game or application which can then be used to make mods.
35
+
36
+ ## Features
37
+
38
+ *pyMHF* contains a number of important features to make creatting a modding library as easy as possible:
39
+
40
+ ### Simple hooking
41
+
42
+ To create a hook, the following pieces of information are required:
43
+ - The relative offset of the function from the start of the binary or the byte signature [WIP] of the function.
44
+ - The function call signature. This is the return and argument types, specified as would be expected by using Pythons' `ctypes` library.
45
+ - A class definition which can be used to indicate the hierarchy of functions to allow for simpler calling of functions from the code.
46
+
47
+ Once this is provided, hooks can be defined as methods within a `Mod` class, allowing for complex behaviour to be implemented with little effort.
48
+
49
+ ### Ability to hook functions across multiple binaries
50
+
51
+ Whilst not fully feature complete yet, it will be possible to specify what loaded libraries or binaries the functions reside within, to allow for hook function in both the main executable as well as loaded ones.
52
+
53
+ ### Automatically generated GUI
54
+
55
+ A GUI (using [DearPyGUI](https://github.com/hoffstadt/DearPyGui)) is automatically generated for the program. All mods will appear automatically as separate tabs, and widgets can be added by way of function decorators within the mod to easily create simple interfaces.
56
+
57
+ ### "Compound hooks"
58
+
59
+ All hooks are defined as either being run **before** or **after** the original function. This allows *pyMHF* to construct what we call "compound hooks" which may consist of any number of detour methods across any number of mods. This means that two mods which affect the same function may coexist (generally) peacefully.
60
+
61
+ **Note**: The order of execution of detours is arbitrary, so one must not expect their detour to be run before or after any other detour of the same hook.
62
+
63
+ ### Custom callbacks
64
+
65
+ Modding libraries can define custom callbacks which can be used to allow methods to be called whenever they are triggered. Examples include *every game tick* or *level change* for example.
66
+
67
+ ### Keyboard callbacks
68
+
69
+ It is possible to declare methods to be run when a certain key is pressed or released.
70
+
71
+ ### Reloadability
72
+
73
+ One major annoyance when testing and debugging mods at this level is the requirement to often have to reload the game to reload any mods and hooks which have been created. *pyMHF* has the ability to reload mods (either via the GUI, or via the injected python REPL). This will re-read the python file and reload any hooks or keyboard callbacks which are defined in it.
74
+
75
+ ### Mod states
76
+
77
+ While reloading mods is great, sometimes objects are instantiated once when the game starts and that is it. To avoid losing these instances across reloads, there is the concept of a `ModState` object which will persist across reloads. These object are bound to the mod itself so it is generally recommended to use these to store any kind of state (and in fact, can be serialized and deserialized to json as a form of saving).
@@ -0,0 +1,45 @@
1
+ .gitignore
2
+ LICENCE.md
3
+ README.md
4
+ pyproject.toml
5
+ uv.lock
6
+ .github/workflows/pipeline.yml
7
+ docs/change_log.md
8
+ docs/settings.md
9
+ docs/setup.md
10
+ docs/writing_libraries.md
11
+ docs/api/mod_loader.md
12
+ pyMHF.egg-info/PKG-INFO
13
+ pyMHF.egg-info/SOURCES.txt
14
+ pyMHF.egg-info/dependency_links.txt
15
+ pyMHF.egg-info/entry_points.txt
16
+ pyMHF.egg-info/requires.txt
17
+ pyMHF.egg-info/top_level.txt
18
+ pymhf/__init__.py
19
+ pymhf/_preinject.py
20
+ pymhf/injected.py
21
+ pymhf/log_terminal.py
22
+ pymhf/main.py
23
+ pymhf/core/__init__.py
24
+ pymhf/core/_internal.py
25
+ pymhf/core/_types.py
26
+ pymhf/core/caching.py
27
+ pymhf/core/calling.py
28
+ pymhf/core/common.py
29
+ pymhf/core/errors.py
30
+ pymhf/core/hashing.py
31
+ pymhf/core/hooking.py
32
+ pymhf/core/importing.py
33
+ pymhf/core/logging.py
34
+ pymhf/core/math.py
35
+ pymhf/core/memutils.py
36
+ pymhf/core/mod_loader.py
37
+ pymhf/core/module_data.py
38
+ pymhf/core/process.py
39
+ pymhf/core/protocols.py
40
+ pymhf/core/utils.py
41
+ pymhf/extensions/cpptypes.py
42
+ pymhf/gui/__init__.py
43
+ pymhf/gui/decorators.py
44
+ pymhf/gui/gui.py
45
+ pymhf/gui/protocols.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ pymhf = pymhf:run
@@ -0,0 +1,9 @@
1
+ cyminhook>=0.1.4
2
+ psutil~=5.9.5
3
+ pymem[speed]~=1.12.0
4
+ keyboard
5
+ pywin32
6
+ dearpygui~=1.11.0
7
+ questionary
8
+ pywinctl
9
+ packaging
@@ -0,0 +1 @@
1
+ pymhf