Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ba0f3/subhook.nim
subhook wrapper for Nim https://github.com/Zeex/subhook
https://github.com/ba0f3/subhook.nim
api hook hooking linux macos nim subhook unix windows
Last synced: about 1 month ago
JSON representation
subhook wrapper for Nim https://github.com/Zeex/subhook
- Host: GitHub
- URL: https://github.com/ba0f3/subhook.nim
- Owner: ba0f3
- License: bsd-2-clause
- Created: 2018-07-18T07:11:15.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-12-15T14:32:14.000Z (almost 3 years ago)
- Last Synced: 2024-05-02T18:50:32.176Z (5 months ago)
- Topics: api, hook, hooking, linux, macos, nim, subhook, unix, windows
- Language: Nim
- Homepage:
- Size: 17.6 KB
- Stars: 16
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-hacking-lists - ba0f3/subhook.nim - subhook wrapper for Nim https://github.com/Zeex/subhook (Nim)
README
# subhook.nim
subhook wrapper for Nim https://github.com/Zeex/subhook### Usage
```nim
import subhook, subhook/helpersproc recv(s: SOCKET, buf: cstring, len: int32, flags: int32): int32 {.fptr.} = 0x123456
proc MY_recv(s: SOCKET, buf: cstring, len: int32, flags: int32): int32 {.stdcall.} =
discardlet hook = initHook(recv, MY_recv)
if hook.install() != 0:
quit "Unable to install revc hook"
```Trampoline example:
```nim
import subhookproc add2(a, b: int): int =
result = a + b
echo "add2 result = ", resultvar addHook: Hook
proc double_add2(a, b: int): int =
echo "add called"
result = cast[typeof(add2)](addHook.getTrampoline())(a, b) * 2addHook = initHook(add2, double_add2, true)
assert add2(1, 3) == 8
```