Skip to content

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

@cutecutecat

Description

@cutecutecat
        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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions