(hostCtx uintptr, methodPtr uintptr, requestPtr uintptr, requestLen uintptr, responsePtr uintptr)
| 328 | } |
| 329 | |
| 330 | func windowsHostCall(hostCtx uintptr, methodPtr uintptr, requestPtr uintptr, requestLen uintptr, responsePtr uintptr) uintptr { |
| 331 | if responsePtr != 0 { |
| 332 | response := (*windowsBuffer)(unsafe.Pointer(responsePtr)) |
| 333 | response.ptr = 0 |
| 334 | response.len = 0 |
| 335 | } |
| 336 | if hostCtx == 0 || methodPtr == 0 { |
| 337 | return 1 |
| 338 | } |
| 339 | id := *(*uintptr)(unsafe.Pointer(hostCtx)) |
| 340 | rawHost, okHost := windowsHostCallbackEntries.Load(id) |
| 341 | if !okHost { |
| 342 | return 1 |
| 343 | } |
| 344 | entry, okHost := rawHost.(dynamicHostCallbackEntry) |
| 345 | if !okHost || entry.host == nil { |
| 346 | return 1 |
| 347 | } |
| 348 | var request []byte |
| 349 | if requestPtr != 0 && requestLen > 0 { |
| 350 | request = unsafe.Slice((*byte)(unsafe.Pointer(requestPtr)), requestLen) |
| 351 | request = append([]byte(nil), request...) |
| 352 | } |
| 353 | ctx := withHostCallbackPluginID(context.Background(), entry.pluginID) |
| 354 | resp, errCall := entry.host.callFromPlugin(ctx, windowsString(methodPtr), request) |
| 355 | if errCall != nil { |
| 356 | resp = marshalRPCError("host_call_failed", errCall.Error()) |
| 357 | } |
| 358 | if len(resp) == 0 || responsePtr == 0 { |
| 359 | return 0 |
| 360 | } |
| 361 | mem, errAlloc := windows.LocalAlloc(windows.LMEM_FIXED, uint32(len(resp))) |
| 362 | if errAlloc != nil || mem == 0 { |
| 363 | return 1 |
| 364 | } |
| 365 | copy(unsafe.Slice((*byte)(unsafe.Pointer(mem)), len(resp)), resp) |
| 366 | response := (*windowsBuffer)(unsafe.Pointer(responsePtr)) |
| 367 | response.ptr = mem |
| 368 | response.len = uintptr(len(resp)) |
| 369 | return 0 |
| 370 | } |
| 371 | |
| 372 | func windowsHostFree(ptr uintptr, len uintptr) uintptr { |
| 373 | if ptr != 0 { |
nothing calls this directly
no test coverage detected