虚函数数组
当逆向工程和使用外部类时,我经常尝试重新定义库中的这些类:
class GameEngine // Exported with "GetGameEngine"
{
public:
virtual void foo1() = 0;
virtual void foo2() = 0;
virtual void foo3() = 0;
virtual void foo4() = 0;
virtual void foo5() = 0;
virtual void foo6() = 0;
virtual void foo7() = 0;
virtual void foo8() = 0;
virtual void foo9() = 0;
virtual void foo10() = 0;
virtual void foo11() = 0;
virtual void foo12() = 0;
virtual int GetGameStatus() = 0; //0x30
virtual void foo14() = 0;
virtual void foo15() = 0;
virtual void foo16() = 0;
virtual int AnotherUsefulFunction() = 0; //0x40
};
基本上我在外部调用 GetGameStatus 函数。是否有某种结构或可能性允许我这样写:
class GameEngine // Exported with "GetGameEngine"
{
public:
FUNCTABLE(12);
virtual int GetGameStatus() = 0; //0x30
FUNCTABLE(14,16);
virtual int AnotherUsefulFunction() = 0; //0x40
};
它会清理我的代码很多。
When reverse engineering and using external classes I often try to redefine those classes in my library:
class GameEngine // Exported with "GetGameEngine"
{
public:
virtual void foo1() = 0;
virtual void foo2() = 0;
virtual void foo3() = 0;
virtual void foo4() = 0;
virtual void foo5() = 0;
virtual void foo6() = 0;
virtual void foo7() = 0;
virtual void foo8() = 0;
virtual void foo9() = 0;
virtual void foo10() = 0;
virtual void foo11() = 0;
virtual void foo12() = 0;
virtual int GetGameStatus() = 0; //0x30
virtual void foo14() = 0;
virtual void foo15() = 0;
virtual void foo16() = 0;
virtual int AnotherUsefulFunction() = 0; //0x40
};
Basically I call the GetGameStatus function externally. Is there some structure or a possibility that allows me to write it this like:
class GameEngine // Exported with "GetGameEngine"
{
public:
FUNCTABLE(12);
virtual int GetGameStatus() = 0; //0x30
FUNCTABLE(14,16);
virtual int AnotherUsefulFunction() = 0; //0x40
};
It would clean up my code a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 boost::preprocessor,具体位于它的 REPEAT 宏。像这样的东西应该有效:
Look at boost::preprocessor, specifically at its REPEAT macro. Something like this should work: