固定地址在.NET中被占用 [英] Fixed address is occupied in .NET

查看:108
本文介绍了固定地址在.NET中被占用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

支持FIPS的OpenSSL有一个限制 - 它必须在固定地址加载 libeay32.dll ,如果在任何其他地址加载,它将无法初始化检查,因此它不能



因此,我们根据微软的推荐选择地址,在某些机器上,有时会被其他各种库占用 - 例如 MSVCR120_CLR0400.dll mscorlib.ni.dll clr.dll



有任何方法来检查是否有固定的地址+长度,并要求操作系统为我释放那部分内存,例如rebase那些dll

更新



ve从20个设备收集信息与ListDLLs和有一些模式什么加载在哪里,但它远没有很好定义。所以我跑了一些数学,发现最大的差距,在那里没有什么东西加载在那20个日志中,我改变了libeay32基地址到某个地方的差距(差距是〜6倍大dll,所以我选择了〜中间的)和仍然后夫妇尝试应用程序管理加载的东西在那之间的libeay32(具体 - clrjit.dll,它的基地址为0x10000000,我认为是默认),虽然在应用程序我尝试加载libeay32

解决方案

为什么不合并给出的提示:





因此,它在加载可执行文件时加载,在任何托管代码运行之前,不会动态,因此所有可重定位的dll都不存在,并且不能妨碍。


FIPS capable OpenSSL has one limitation - it must load libeay32.dll at fixed address and if loads at any other address, it fails initialization check, so it can't be used in FIPS mode.

So we chose address according to Microsoft's recommendation and on some machines that address from time to time is occupied by various other libraries - like MSVCR120_CLR0400.dll or mscorlib.ni.dll or clr.dll, you get the point.

Is there any way to check if some fixed address + length is taken and ask OS to free that part of memory for me, like rebase those dll's to other memory parts or something like this?

Update:

I've collected information from 20 devices with ListDLLs and there is some pattern what is loaded where, but it is far from well defined. So I've ran some math, found largest gap, where nothing was loaded in it in those 20 logs I had, changed libeay32 base address to somewhere in that gap (gap was ~6 times larger than dll, so I've chosen ~middle of it) and still after couple tries application managed to load something in that gap before libeay32 (to be specific - clrjit.dll, it has base address of 0x10000000, which I think is default), although in application I try to load libeay32 as soon as possible.

解决方案

Why don't you combine the hints given:

  • Use /INCLUDE with a symbol from libeay.dll when linking your program to force a static dependency on that library.
  • Compile libeay32.dll with /FIXED so it cannot be relocated.

Thus, it's loaded on loading the executable, before any managed code runs, not sometime later dynamically, so all those relocatable dlls aren't there yet and cannot get in the way.

这篇关于固定地址在.NET中被占用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆