MCPcopy Index your code
hub / github.com/inbug-team/InScan / AppendExec

Function AppendExec

generate_exec/generate_exec.go:111–131  ·  view source on GitHub ↗
(data interface{}, tplPath, execPath string)

Source from the content-addressed store, hash-verified

109}
110
111func AppendExec(data interface{}, tplPath, execPath string) {
112 // 1.读取模板内容
113 dataByte, err := json.Marshal(data)
114 CheckError(err)
115 tplFile, err := os.OpenFile(tplPath, os.O_RDONLY, 0666)
116 CheckError(err)
117 defer tplFile.Close()
118 fileInfo, err := tplFile.Stat()
119 CheckError(err)
120 size := fileInfo.Size()
121 tplBuf := make([]byte, size)
122 tplFile.Read(tplBuf)
123
124 // 2.写入新的可执行程序
125 execFile, err := os.Create(execPath)
126 CheckError(err)
127 defer execFile.Close()
128 execFile.Write(tplBuf)
129 execFile.WriteString(AesEncrypt(string(dataByte), "1234567890123456"))
130 execFile.Write(IntToBytes(int(size)))
131}

Callers 1

mainFunction · 0.92

Calls 3

CheckErrorFunction · 0.85
AesEncryptFunction · 0.85
IntToBytesFunction · 0.85

Tested by

no test coverage detected