I have a DLL compiled with CGO. It exports 3 functions:

```
//export Run1
func Run(text string) (stdout []byte, stderr []byte, err error) {
fmt.Println(text)
return nil, nil, nil
}

//export Run2
func Run2() (stdout []byte, stderr []byte, err error) {
       fmt.Println("Heyyyyy")
        fmt.Println(111111)
return nil, nil, nil
}

//export Run3
func Run3(a int) (stdout []byte, stderr []byte, err error) {
        fmt.Println(a)
return nil, nil, nil
}
```


In a seperate Go file I import the DLL and try to call the exported 
function.
For Run2 everything works

```
s = uinptr(ADDRESS_RUN2)
syscall.SyscallN(s)
```

It prints Heyyyyy and 1111111 in my output


For Run3, I am not sure how to pass the argument to SyscallN.
```
   
    s = uinptr(ADDRESS_RUN3)
    a := 999999999
    syscall.SyscallN(s, uintptr(unsafe.Pointer(&a)))  ----> Fail (random 
Number printed)

    a := 999999999
    syscall.SyscallN(s, uintptr(unsafe.Pointer(a)))  -----> Fail (random 
Number printed)

```

For Run1, it get worse as sometimes I get C0000005 error as I use the 
string elsewhere:
```
        s = uinptr(ADDRESS_RUN1)

cmdBytes := []byte(torun)
cmdBytes = append(cmdBytes, 0)
ptr := unsafe.Pointer(&cmdBytes[0])
        syscall.SyscallN(d, uintptr(ptr))
```

Any help please ??

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/a26ceb2c-d2fd-4b30-b715-51acc6737933n%40googlegroups.com.

Reply via email to