Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cutecutecat opened this issue Aug 6, 2021 · 2 comments
Open

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

cutecutecat opened this issue Aug 6, 2021 · 2 comments

Comments

@cutecutecat
Copy link

        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?

@cutecutecat cutecutecat changed the title Are there any way to call original function by symbol name? Is there any way to call original function by symbol name? Aug 6, 2021
@cch123
Copy link
Owner

cch123 commented Aug 7, 2021

I have read the code of forceexport, we can use most of its code, and only change the implementation of:

func FindFuncWithName(name string) (uintptr, error) {
}


我看了一下 forceexport 的代码,如果在 supermonkey 里实现的话,应该简单改改 forceexport 的 FindFuncWithName 这部分就行了,
有兴趣贡献一发么~

@cutecutecat
Copy link
Author

没问题,但是可能要等一两周,最近手头其他工作比较忙。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants