c++ - C++ DLL(本地挂钩)和 C# 应用程序之间的合适 IPC
问题描述
对于注入第三方进程和 C# 应用程序的 C++ DLL,最好的进程间通信是什么?这是目前的情况:
// This gets executed within the target process memory region
LRESULT CALLBACK HookProc(int code, WPARAM wParam, LPARAM lParam)
{
if (code > 0)
{
auto csharpApplicationFunctionPointerAddress = 0xdeadbeef;
auto csharpApplicationFunctionResult = call csharp function with N parameters here
// Do something with the result
if (csharpApplicationFunctionResult == "foo")
{
}
}
return CallNextHookEx(hookInstance, code, wParam, lParam);
}
我遇到了这个问题并发现我需要一个 RPC,但是我似乎找不到最适合这个问题的 RPC,因为这种通信需要传递 N 个参数并尽快返回结果。
笔记:
- 套接字不在意,因为我不想处理超时
- 命名管道会在这里工作还是只适用于字符串消息?(不考虑序列化/反序列化)
- 我不想对远程线程使用消息轮询,因为这会占用太多 CPU
甚至还有什么选择吗?请随时纠正我上面的注释。
解决方案
我最终创建了一个不可见的虚拟窗口,作为通过SendMessage
DLL 调用接收消息的中心点。
推荐阅读
- html - 如何创建交错的 2 col 网格视图,其中 2nd col 略低于第一列
- reactjs - 点击路由并通过路由传递数据:react js
- r - R计算两列所有值之间的差异
- c - 为什么打开的文件描述符没有被重用,而是在数值上增加
- shell - 如何在automator快速操作中编写“去除水印和ocr”的shell脚本?
- react-native - 在通过 QR 码安装应用程序之前存储一个 ID
- reactjs - Nginx 负载均衡器不加载 React 站点
- c# - KVP 字典中的 ComboBox DisplayMember 对象属性
- r - R中的任何方式都可以只保留其行被过滤的列?
- python - 我对抓取很陌生,请多多包涵,这是我的第一个项目。我正在尝试使用 selenium 抓取网站