cch123 / cch123/supermonkey

Is there any way to call original function by symbol name?

Open
#18 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
257
Forks
15
PR merge metrics
No merged PRs in 30d

Description

```
var guard_down *sm.PatchGuard
download_hook := "xxx.DownloadPiece"
guard_down = sm.PatchByFullSymbolName(download_hook, func(ctx context.Context, pt peer.Task, request *peer.DownloadPieceRequest) (success bool) {
// do something

// temporary unpatch
guard_down.Unpatch()
defer guard_down.Restore()

// use forceexport to fetch original function
var function func(context.Context, peer.Task, *peer.DownloadPieceRequest) (success bool)
err := forceexport.GetFunc(&function, download_hook)
if err != nil {
log.Panicf("connect target error: %s", err)
}

// call original function
success = function(ctx, pt, request)
return
})
```

If the original function is unexported, and should be called inside the hooked method as above, is **supermonkey** provide some way to call it by symbol name rather than use [**forceexport**](https://github.com/alangpierce/go-forceexport)?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.