Windows callback function in Golang

I want to do click subscribe to the Windows event log in the Golang
How exactly to transfer the callback function?

EVT_SUBSCRIBE_CALLBACK is a function pointer, e.g.

typedef DWORD ( WINAPI *EVT_SUBSCRIBE_CALLBACK)(
   EVT_SUBSCRIBE_NOTIFY_ACTION Action,
   PVOID                       UserContext,
   EVT_HANDLE                  Event
);

So my version looks like this:

func logCallback() syscall.Handle {

    cb := func(_ uintptr, _ uintptr, _ uintptr) uint64 {
        fmt.Printf("callback called %v", data)
        return 0
    }
    ptr := syscall.NewCallback(cb)
    return syscall.Handle(ptr) // type syscall.Handle uintptr
}

I get a successfully signed handler without errors, but it still doesn't work. Any ideas why? Where should I look first?

+4
source share
1 answer

When using syscall, include import "C"at the top of the file. Glad it helped you.

+3
source

Source: https://habr.com/ru/post/1680955/


All Articles