出口类成员
具体何时使用 DLL 或代码注入
这是一个示例类,仅用于解释
class test
{
int newint1;
char newchararray[512];
void (*newfunction1)( int newarg1 );
int newfunction2( bool newarg1, char newarg2 )
{
return newint1;
}
} mynewclass1;
,涵盖类中包含的最常见元素
现在将此函数导出到另一个 DLL 或应用程序时
并错过了其中的一个元素,无论是数据成员还是函数成员,私有还是公共
发生了什么或改变了他们的顺序?
如果每个函数在代码注入时都被分配了它的值,就像
mynewclass1.newfunction1 = (void *)(newexportedfunction);
在这种情况下发生的情况一样,如果类的成员是在类构造之后分配的指针,然后错过了一个成员或更改了它们的顺序?
When Using DLLs or Code-injecting to be Specific
this is an example class only intended for explaining
class test
{
int newint1;
char newchararray[512];
void (*newfunction1)( int newarg1 );
int newfunction2( bool newarg1, char newarg2 )
{
return newint1;
}
} mynewclass1;
that covers most common elements that's included in classes
now when exporting this function to another DLL or application
and missed an element of those, either data member or function member, private or public
what happens or changed their order ?
and if each function is assigned it's value when Code-Injecting like
mynewclass1.newfunction1 = (void *)(newexportedfunction);
what's the happens in this case, if members of the class are pointers that are assigned after class construction and then missed one member or changed their order ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想您忘记添加 public: (:)
mynewclass1 在加载时静态初始化为零(除非您正在使用非常旧版本的 Windows)。
如果您向类添加构造函数,行为将变得不可预测,因为很难知道静态何时有效初始化(至少是链接时依赖项)。
I suppose that you forget to add a public: (:)
mynewclass1 is a statically initialized to zero at load time (unless you are working on very old version of windows).
if you add a constructor to your class behavior will become unpredictable because it is quite difficult to know when the static is effectively initialized (link-time dependencies at least).