Skip to content

Commit b1a5664

Browse files
Add AI generated modding documentation
1 parent 2f1b8ed commit b1a5664

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

src/extra/advanced/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
- [Debugging NDK Libraries](./debugging_ndk_libraries/index.md)
44
- [JNI](./jni/index.md)
55
- [NDK Shims](./ndk_shims/index.md)
6+
- [Modding Api](./modding-api/)
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# MCPELauncher API Referenc
2+
## 🔧 Logging Functions
3+
4+
| Symbol | Description | Notes |
5+
|--------|-------------|-------|
6+
| `mcpelauncher_log` | Logs a message | Deprecated; use Android `liblog` |
7+
| `mcpelauncher_vlog` | Logs a verbose message | Deprecated; use Android `liblog` |
8+
9+
---
10+
11+
## 🪝 Hook Initialization
12+
13+
| Symbol | Signature | Description |
14+
|--------|-----------|-------------|
15+
| `mcpelauncher_preinithook2` | `void(const char* name, void* sym, void* user, void (*callback)(void*, void*))` | Registers a pre-init hook with a callback |
16+
| `mcpelauncher_preinithook` | `void(const char* name, void* sym, void** orig)` | Registers a pre-init hook and stores original symbol |
17+
18+
---
19+
20+
## 🧬 Hook Management
21+
22+
| Symbol | Signature | Description |
23+
|--------|-----------|-------------|
24+
| `mcpelauncher_hook` | `void*(void* sym, void* hook, void** orig)` | Creates and applies a hook for a symbol |
25+
| `mcpelauncher_hook2` | `void*(void* lib, const char* sym, void* hook, void** orig)` | Creates a hook for a symbol in a specific library |
26+
| `mcpelauncher_hook2_add_library` | `void(void* lib)` | Adds a library to the hook manager |
27+
| `mcpelauncher_hook2_remove_library` | `void(void* lib)` | Removes a library from the hook manager |
28+
| `mcpelauncher_hook2_delete` | `void(void* hook)` | Deletes a hook instance |
29+
| `mcpelauncher_hook2_apply` | `void()` | Applies all registered hooks |
30+
31+
---
32+
33+
## 🧵 Memory Patching
34+
35+
| Symbol | Signature | Description |
36+
|--------|-----------|-------------|
37+
| `mcpelauncher_patch` | `void*(void* address, void* data, size_t size)` | Patches memory at a given address |
38+
| *(Apple ARM64 only)* | Uses `pthread_jit_write_protect_np` and `sys_icache_invalidate` for JIT-safe patching |
39+
40+
---
41+
42+
## 📦 Dynamic Library Handling
43+
44+
| Symbol | Description |
45+
|--------|-------------|
46+
| `mcpelauncher_host_dlopen` | Wrapper for `dlopen` |
47+
| `mcpelauncher_host_dlsym` | Wrapper for `dlsym` |
48+
| `mcpelauncher_host_dlclose` | Wrapper for `dlclose` |
49+
| `mcpelauncher_dlclose_unlocked` | Custom unlocked `dlclose` |
50+
51+
---
52+
53+
## 🔁 Symbol Relocation
54+
55+
| Symbol | Signature | Description |
56+
|--------|-----------|-------------|
57+
| `mcpelauncher_relocate` | `void(void* handle, const char* name, void* hook)` | Relocates a single symbol |
58+
| `mcpelauncher_relocate2` | `void(void* handle, size_t count, hook_entry* entries)` | Relocates multiple symbols |
59+
| `mcpelauncher_load_library` | `void(const char* name, size_t count, hook_entry* entries)` | Loads a library and applies hooks |
60+
| `mcpelauncher_unload_library` | `void(void* handle)` | Unloads a previously loaded library |
61+
62+
---
63+
64+
## 📚 Data Structures
65+
66+
```cpp
67+
struct hook_entry {
68+
const char* name;
69+
void* hook;
70+
};
71+
```
72+
73+
Used for batch relocation and library loading.
74+
75+
---
76+
77+
Would you like this turned into documentation for developers, or maybe a visual diagram of how the hook system works?

0 commit comments

Comments
 (0)