哪个进程创建了我的 DLL 进程?
我正在将第三方应用程序与我的 DLL 集成。每次运行第三方软件时,都会多次创建和销毁 DLL。
从我的 DLL 中,我需要识别它是否是同一个第三方运行的,或者是不同的第三方运行的。有没有办法识别第三方软件的哪个进程正在创建我?
I am integrating a third party's application with my DLL. The DLL is created and destroyed several times per each run of the third party's software.
From my DLL, I need to recognize if it is the same third party's run or a different one that is creating me. Is there a way to recognize which process of the third party software is creating me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果每次都卸载 DLL,那么每次加载之间可能需要某种持久存储。如果调用应用程序不提供此信息,则 DLL 本身将需要执行此操作。
一种可能是使用 命名共享内存。如果它不存在,请创建它,然后使用它作为“标志”来知道它在同一个执行中被再次调用。当进程退出时,它将被销毁。当然,这需要考虑安全隐患。另一个进程可能会创建该共享内存,使您的 DLL“认为”它在同一次运行中被再次调用,而实际上它是第一次调用。
If the DLL is being unloaded each time, then it will likely need some kind of persistent storage between each time it is loaded. If the calling application does not provide this information, then the DLL itself will need to perform that.
One possibility might be to use named shared memory. If it does not exist, create it and then use that as the "flag" to know that it is being called again in the same execution. When the process exits, it will be destroyed. There are, of course, security implications with this that would need to be considered. Another process could potentially create that shared memory to make your DLL "think" that it was being called again in the same run when it was actually the first invocation.