如何在非托管 C++ dll 中查找调用程序程序集名称

问题描述:

我有一个非托管 C++ dll.我正在从 c# (.net 3.5)

I have an unmanaged c++ dll. I am calling external methods of this unmanaged dll from c# (.net 3.5)

我正在寻找一种方法来查找 witch c# 程序集正在调用我的非托管 c++ dll(进入我的 c++ dll)(至少,程序集的名称)

I am looking for a way to find witch c# assembly is calling my unmanaged c++ dll (into my c++ dll) (at least, name of assembly)

当然,我不想向方法传递任何额外的参数.

提前致谢

我终于找到了解决方案.

Finally I found the solution.

我正在寻找一种方法来限制对我的非托管 dll 的不允许访问.所以我爬取了我的调用者程序集位置的堆栈跟踪.

I was looking for a way to restrict not allowed access to my unmanaged dll. So I crawled the stack trace for my caller assembly location.

最后我决定检查调用者程序集的公钥令牌(通过这种方式找到)并验证它.

Finally I decided to check public key token of caller assembly (found this way) and validate it.

感谢您的时间和答案...

Thanks from you time and answers...