【问题标题】:Write access to symbols, exported from DLL or SO对符号的写访问权,从 DLL 或 SO 导出
【发布时间】:2012-04-12 09:00:28
【问题描述】:

在附加的 DLL/SO 中覆盖导出的数据是否合法?

示例(win32):

t_Controller controller = (t_Controller*) GetProcAddress(SomeDLL, "Controller");
controller->Args = args; //  <--- here
controller->Run();

【问题讨论】:

    标签: windows linux dll shared-libraries


    【解决方案1】:

    好的 - 所以你正在导出某种结构。

    一旦获得了指向结构体的指针,从exe写入结构体是否合法,完全取决于它在dll中是否合法地写入结构体。

    即它是一个常量结构吗? 如果它没有定义为 const,那么你可以写入它。 如果它被定义为 const,那么您的 GetProcAddress 只是将 const 转换为关闭的一种复杂方式,这将导致 - 一如既往 - 导致未定义的行为。即它可能起作用,也可能不起作用,具体取决于您的编译器实现 - 通常是否将在全局范围内声明的静态对象放置在只读数据部分中。

    【讨论】:

      猜你喜欢
      • 2014-01-02
      • 2019-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-15
      相关资源
      最近更新 更多