Windows kernel32 SetConsoleCtrlHandler

What I currently have working is…

GenerateConsoleCtrlEvent(0, syscall.CTRL_C_EVENT);

This correctly sends CTRL+C to the target process, causing it to initiate a file save. What it also does is transmit CTRL+C to the current app itself, since it owns the process I’m trying to close. The suggested solution I found on Stack Overflow is to use SetConsoleCtrlHandler to temporarily disable CTRL+C within this app, allowing me to close the target process, then re-enable CTRL+C.

func disableCtrlHandler() {
	d, e := syscall.LoadDLL("kernel32.dll")
	if e != nil {
		log.Fatalf("LoadDLL: %v\n", e)
	}
	p, e := d.FindProc("SetConsoleCtrlHandler")
	if e != nil {
		log.Fatalf("FindProc: %v\n", e)
	}
    r, _, e := p.Call(nil, uintptr(1))
    if r == 0 {
    	log.Fatalf("SetConsoleCtrlHandler: %v\n", e)
    }
}

The specific error here is

cannot use nil as type uintptr in argument to p.Call

I’m just not sure what to make of a pointer that can’t be set to null. I also wasn’t sure if there was a better way to pass “true” and “false” to the call, other than “uintptr(1)” and “uintptr(0)”