Reputation: 41
I want to implement dll forwarding(or dll proxy)
In mingw, I can use cpp source with .def file, like gcc -shared -o test.dll functions.def test.cpp
But I don't know how to implement it in golang
Upvotes: 0
Views: 612
Reputation: 41
I know what to do to solve this problem.
use the extldflags
dlltool --def functions.def --output-exp evildll.exp
main.go
package main
import "C"
func main() {
// Need a main function to make CGO compile package as C shared library
}
use command go build -buildmode=c-shared -o exportgo.dll -ldflags="-extldflags=-Wl,C:/Users/Akkuman/Desktop/go-dll-proxy/evildll.exp"
then you can get the dll
use command go build -buildmode=c-shared -o exportgo.dll -ldflags="-extldflags=-Wl,C:/Users/Akkuman/Desktop/go-dll-proxy/functions.def"
then you can get the dll, but with a additional export function
Upvotes: 1