// Close will release all of the objects and memory needed to process debug // messages from other processes. func (r *OutputDebugStringReceiver) Close() error { if nil == r.err { r.done <- struct{}{} <-r.completed } var result, err error result = r.dataReadyEvent.Close() err = r.bufferReadyEvent.Close() if nil != result { result = err } if 0 != r.view { err = windows.UnmapViewOfFile(r.view) if nil != result { result = err } } if windows.InvalidHandle != r.buffer { err = windows.CloseHandle(r.buffer) if nil != result { result = err } } return result }
func munmap(b []byte) (err error) { m := memoryMap(b) dh := m.header() addr := dh.Data length := uintptr(dh.Len) flush(addr, length) err = windows.UnmapViewOfFile(addr) if err != nil { return err } handleLock.Lock() defer handleLock.Unlock() handle, ok := handleMap[addr] if !ok { // should be impossible; we would've errored above return errors.New("unknown base address") } delete(handleMap, addr) e := windows.CloseHandle(windows.Handle(handle)) return os.NewSyscallError("CloseHandle", e) }