有时候我们希望将dll嵌入到程序内部,以提高程序的安全性,这里我写的一个开源memorydll模块。

首先 go get github.com/nkbai/go-memorydll

然后在需要的时候 import "go-memorydll"即可,

使用起来也非常简单,这里从test例子中摘取.

testdll,_:=base64.StdEncoding.DecodeString(testdllbase64)
dll,err:=
memorydll.NewDLL(testdll,"example.dll");
if err!=nil{
t.Error(err)
return
}
proc,err:=dll.FindProc("gcd")
if err!=nil{
t.Error(err)
return
}
result,_,_:=proc.Call(uintptr(4),uintptr(8))
//fmt.Println("rsult=",result)
if int(result)!=4{
t.Error("gcd calc error")
}

 

注意的是,结束的时候记得release相关模块

相关文章:

  • 2022-01-03
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
  • 2022-02-22
  • 2021-08-17
  • 2022-01-19
猜你喜欢
  • 2021-05-18
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案