| 21 | extern "C" { |
| 22 | typedef void(__cdecl* netstack_cb)(uint8_t*, size_t, void*); |
| 23 | void cb(uint8_t* data, size_t size, void* outputStreamAbi) { |
| 24 | bool needSendDummyBuffer = false; |
| 25 | { |
| 26 | std::lock_guard _guard{ VpnPluginInstance->m_decapQueueLock }; |
| 27 | auto& q = VpnPluginInstance->m_decapQueue; |
| 28 | { |
| 29 | std::vector<uint8_t> buf(size); |
| 30 | if (memcpy_s(buf.data(), buf.capacity(), data, size)) { |
| 31 | return; |
| 32 | } |
| 33 | needSendDummyBuffer = q.empty(); |
| 34 | q.emplace(buf); |
| 35 | } |
| 36 | } |
| 37 | if (!needSendDummyBuffer) { |
| 38 | return; |
| 39 | } |
| 40 | IOutputStream outputStream{ nullptr }; |
| 41 | winrt::attach_abi(outputStream, outputStreamAbi); |
| 42 | try { |
| 43 | const auto _ = outputStream.WriteAsync(dummyBuffer); |
| 44 | } |
| 45 | catch (...) {} |
| 46 | winrt::detach_abi(outputStream); |
| 47 | } |
| 48 | } |
| 49 | void VpnPlugin::Connect(VpnChannel const& channel) |
| 50 | { |