将PInvoke与IAsyncOperation混合会导致崩溃/异常/ BufferOverflow

时间:2019-05-30 12:53:33

标签: c# windows-runtime pinvoke

我仍在研究UWP VpnPlugin。不使用。它确实成功连接到了Hyper-v Debian机器上的我的测试VPN服务器。在第二步中,我需要使用第三方C / C ++ dll / lib。当我将简单的C ++ WinRT组件与C#BackgroundTask WinRT组件一起使用时,应用程序在调用(第一个)C#异步方法时崩溃。使用PInvoke后,问题开始出现。 因此,PInvoke与WinRT组件中的异步C#东西相处得不好。

在此问题上的任何帮助都将不胜感激。

我当时正在考虑在c ++组件中使用托管类,但没有确信它可以解决问题。 在此处找到完整的项目源代码: https://github.com/marcusrunge/ToyVpn/tree/extern

错误消息:

ntdll.dll!_NtWaitForAlertByThreadId@8()
ntdll.dll!@RtlpWaitOnAddressWithTimeout@16()
ntdll.dll!RtlpWaitOnCriticalSection()
ntdll.dll!_RtlpEnterCriticalSectionContended@4()
ntdll.dll!_RtlEnterCriticalSection@4()
ntdll.dll!ExecuteHandler2@20()
ntdll.dll!ExecuteHandler@20()
ntdll.dll!_KiUserExceptionDispatcher@8()
Windows.Networking.dll!
Windows::Internal::AsyncBaseFTM<Windows::Foundation::IAsyncActionCompletedHandler,1,Microsoft::WRL::AsyncCausalityOptions<&DatagramSocketConnectAsyncOperationName,&GUID_CAUSALITY_WINDOWS_PLATFORM_ID,2> >::FireCompletion() Zeile 162 C++
Windows.Networking.dll!
SocketOperationBase<Windows::Foundation::IAsyncActionCompletedHandler,Microsoft::WRL::AsyncCausalityOptions<&DatagramSocketConnectAsyncOperationName,&GUID_CAUSALITY_WINDOWS_PLATFORM_ID,2> >::FireCompletionAndReleaseOperation() Zeile 46 C++
Windows.Networking.dll!    
SocketOperationBase<Windows::Foundation::IAsyncActionCompletedHandler,Microsoft::WRL::AsyncCausalityOptions<&DatagramSocketConnectAsyncOperationName,&GUID_CAUSALITY_WINDOWS_PLATFORM_ID,2> >::CompleteAsyncOperation(HRESULT hr) Zeile 35  C++
Windows.Networking.dll
SocketNameResolver::GetAddrInfoCompleteHandler<DatagramSocketConnectOperationServer>(void * context, HRESULT hr, addrinfoexW * addrInfoList) Zeile 165  C++
Windows.Networking.dll!SocketNameResolver::CompleteGetAddrInfoEx(HRESULT hrStatus) Zeile 489    C++
Windows.Networking.dll!
SocketNameResolver::GetAddrInfoExWaitCallback(_TP_CALLBACK_INSTANCE * instance, void * context, _TP_WAIT * wait, long waitResult) Zeile 292 C++
ntdll.dll!TppExecuteWaitCallback()
ntdll.dll!TppWaitCompletion()
ntdll.dll!_TppWorkerThread@4()
kernel32.dll!@BaseThreadInitThunk@12()
ntdll.dll!__RtlUserThreadStart()
ntdll.dll!__RtlUserThreadStart@8()

0 个答案:

没有答案