github.com/tencent/goom@v1.0.1/internal/patch/monkey_386.go (about) 1 package patch 2 3 // nopOpcode 空指令插入到原函数开头第一个字节, 用于判断原函数是否已经被 Patch 过 4 const nopOpcode = 0x90 5 6 // jmpToFunctionValue Assembles a jump to a function value 7 func jmpToFunctionValue(_, to uintptr) []byte { 8 return []byte{ 9 0xBA, 10 byte(to), 11 byte(to >> 8), 12 byte(to >> 16), 13 byte(to >> 24), // mov edx,to 14 0xFF, 0x22, // jmp DWORD PTR [edx] 15 } 16 } 17 18 // checkAlreadyPatch 检测是否已经 patch 19 func checkAlreadyPatch(origin []byte) bool { 20 if origin[0] == nopOpcode { 21 return true 22 } 23 return false 24 }