是否可以在进程之间跟踪 PostMessage?

编程入门 行业动态 更新时间:2024-10-27 22:19:58
本文介绍了是否可以在进程之间跟踪 PostMessage?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我们有一个系统,其中通常有两个进程在同一系统上运行.一个进程处理 GUI,另一个进程像服务一样运行(尽管由于历史原因,它不是服务,只是一个没有可见窗口的 exe).

We have a system where there are typically two processes running on the same system. One process handles the GUI and the other runs like a service (although for historical reasons, it's not a service, just an exe with no visible window).

这两个进程主要通过异步注册消息进行 IPC - 即我们在两个进程中使用 RegisterWindowMessage() 来定义大量消息,这些消息有效地形成了服务器进程的 API.

The two processes undertake IPC mainly via registered messages asynchronously - i.e. we use RegisterWindowMessage() in both processes to define a large'ish set of messages that effectively form the API to the server process.

我编写了一个免提"监控应用程序,它使用 SetWindowsHookEx() 来监控和显示两个进程的消息队列,并提供 API 使用方式的某种程度的解码以及如何将通知传播到 GUI 进程(每个单独的窗口都可以直接从服务器订阅通知).

I have written a "hands-free" monitoring application that uses SetWindowsHookEx() to monitor and display the message queues of both processes and provide some level of decoding of the way the API is being utilised and how notifications are being propagated to the GUI process (each individual window can subscribe to notifications from the server directly).

所以,双向都有大量消息,所以我有过滤和汇总计数等.这样我就可以专注于特定活动.所有这些都可以在不影响实时代码的情况下完成,这很好.

So, there are a large number of messages in both directions so I have filtering and summary counts etc. so I can focus on particular activity. All this can be done without affecting the live code, which is good.

这一切都运行良好,但现在能够标记"源自 GUI 的消息将非常有用,因此我可以在服务器处理该消息时跟踪相同的消息.这对于调试和诊断系统问题非常有用,但我找不到一个干净的方法(实际上我找不到任何方法!)工作,涉及的风险比我目前感到舒服.由于服务器预处理了一些消息,然后将 PostMessage() 返回给自身以执行操作,因此它变得更加复杂,因此原始消息可能会丢失".

This all works well, but it now would be very useful to be able to "tag" a message originating in the GUI so I can trace the same message when it's processed by the server. This would be enormously useful for debugging and diagnosing system issues, but I can't find a clean way (actually I can't find any way!) of doing this without adding such support to our registered message API, which would be a lot of work and involves more risk than I'm comfortable with at the moment. It gets further complicated by the fact that the server pre-processes some messages and then does a PostMessage() back to itself to perform the action, so the originating message can get "lost".

这里有人解决过这种问题吗?如果是这样,你能给我一些指点吗?如果没有,那么是否有任何记录或未记录的方法可以将一小块数据添加到 Windows 消息中并在以后检索它?我看过 SetMessageExtraInfo() 但这似乎是按队列而不是按消息.

Has anyone here tackled this type of problem? If so, can you give me some pointers? If not, then are there any documented or undocumented ways of adding a small block of data to a Windows message and retrieving it later? I've looked at SetMessageExtraInfo() but that seems to be per-queue rather than per-message.

推荐答案

FindWindow 或 FindWindowEx 将为您提供 GUI 窗口的详细信息.与截获的消息进行对比

FindWindow or FindWindowEx will give you the details of the GUI Window. Compare the details with message intercepted

这篇关于是否可以在进程之间跟踪 PostMessage?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 02:10:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1198666.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:进程   PostMessage

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!