github.com/HXSecurity/DongTai-agent-go@v0.4.2/core/base/stringsBuilderWriteString/install.go (about)

     1  package stringsBuilderWriteString
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  	"github.com/HXSecurity/DongTai-agent-go/model"
     7  	"github.com/brahma-adshonor/gohook"
     8  	"strings"
     9  )
    10  
    11  func init() {
    12  	model.HookMap["stringsBuilderWriteString"] = new(BufferWriteString)
    13  }
    14  
    15  type BufferWriteString struct {
    16  }
    17  
    18  func (h *BufferWriteString) Hook() {
    19  	var bt *strings.Builder
    20  	err := gohook.HookMethod(bt, "WriteString", WriteString, WriteStringT)
    21  	if err != nil {
    22  		fmt.Println(err, "stringsBuilderWriteString")
    23  	} else {
    24  		fmt.Println("stringsBuilderWriteString")
    25  	}
    26  }
    27  
    28  func (h *BufferWriteString) UnHook() {
    29  	var bt bytes.Buffer
    30  	gohook.UnHookMethod(bt, "stringsBuilderWriteString")
    31  }