GO Development Examples

If you need to pass in parameters for loading and executing the dynamic library, you need to force the entry point and then parse the parameters passed in.

Because CrossC2 beacon is developed by pure C, the variable type of the exported function is also C, and the type of the incoming variable needs to be converted before calling.

The following code shows the definition of the function type that needs to be exported and the analysis of the incoming parameters

import (

//export crossc2_entry
func crossc2_entry(argc C.int, argv  **C.char) int {
    tmpslice := (*[1 << 30]*C.char)(unsafe.Pointer(argv))[:argc:argc]
    goArgv := make([]string, argc)
    for i, s := range tmpslice {
        goArgv[i] = C.GoString(s)

    // use (argc, goArgv)

    return 10;

results matching ""

    No results matching ""