mirror of
https://github.com/yv1ing/ShotRDP.git
synced 2025-09-16 15:10:57 +08:00
新增动态链接库调用
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package main
|
||||
package client
|
||||
|
||||
import (
|
||||
"ShotRDP/common"
|
||||
@@ -181,7 +181,7 @@ func (client *RdpClient) setEventHandler() {
|
||||
去除requestedProtocol中的PROTOCOL_HYBRID,避免使用NLA
|
||||
*/
|
||||
|
||||
func getScreen(host string) ([]byte, error) {
|
||||
func RealGetScreen(host string) ([]byte, error) {
|
||||
client := Newclient(host, glog.INFO)
|
||||
return client.Login("", "", "")
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package main
|
||||
package client
|
||||
|
||||
import (
|
||||
"testing"
|
||||
29
mainDLL.go
Normal file
29
mainDLL.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"ShotRDP/client"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
//export GetScreen
|
||||
func GetScreen(host *C.char, data **C.char, length *C.int) *C.char {
|
||||
imgBytes, err := client.RealGetScreen(C.GoString(host))
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
|
||||
*data = (*C.char)(C.CBytes(imgBytes))
|
||||
*length = C.int(len(imgBytes))
|
||||
return nil
|
||||
}
|
||||
|
||||
//export Free
|
||||
func Free(p *C.char) {
|
||||
C.free(unsafe.Pointer(p))
|
||||
}
|
||||
|
||||
func main() {}
|
||||
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"ShotRDP/client"
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
@@ -13,7 +14,7 @@ type Server struct {
|
||||
}
|
||||
|
||||
func (server *Server) GetScreen(ctx context.Context, in *pb.Request) (*pb.Response, error) {
|
||||
imgBytes, err := getScreen(in.GetHost())
|
||||
imgBytes, err := client.RealGetScreen(in.GetHost())
|
||||
return &pb.Response{ImageBytes: imgBytes}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user