Is it possible to inject a Windows Form application into another application as an MDI Child in VB.NET?

北城余情 提交于 2019-12-11 21:00:04

问题


I am creating a program that interacts with another program and I would like to "inject" my program into this program as an MDI Child window. Is this even possible, and if so can it be done in VB.NET? What kind of pitfalls are associated with doing this?


回答1:


It could be done, in two ways, the first way, by obtaining a copy of Detours, and use pinvoke to inject your process into that parent process with MDI controller, the second way, although more dangerous, is to hook into the MDI controller's window messages and inject code that will execute - the dangerous part is that, since MDI controller is running in a separate process, you may incur a "Access violation" when trying to access another process's memory, namely the MDI controller.

You can most certainly hook into that process and trap the messages, have a look at this sample found here (written in C#, but you can easily add a reference to your VB.NET project) and here also.

It depends on how far you want to go, you may have to allow your process to access the protected memory space by your MDI controller which is in the other process by elevating it... try those example hooks in the links provided and see how it goes...



来源:https://stackoverflow.com/questions/3596341/is-it-possible-to-inject-a-windows-form-application-into-another-application-as

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!