Content of C++ vtbl
来源:互联网 发布:棋牌室收费软件 编辑:程序博客网 时间:2024/05/22 17:00
{/u/hui}:g++ t.C
{/u/hui}:./a.out
this[0x0]=0x11358 :
this[0x4]=0x41 :
this[0x8]=0x42 :
vtbl[0x0]=0x111f4 : B::foo1()
vtbl[0x4]=0x111d0 : B::foo2()
vtbl[0x8]=0x111ac : B::foo3()
vtbl[0xc]=0x10eec : B::~B()
vtbl[0x10]=0x11158 : B::~B()
vtbl[0x14]=0x11134 : B::foo4()
---------------------------------------------------------------
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
class A
{
public:
virtual void foo1() { printf("in A::foo1()/n"); };
virtual void foo2() { printf("in A::foo2()/n"); }
virtual void foo3() { printf("in A::foo2()/n"); }
public:
virtual ~A() {}
public:
A():a1('A') {};
A(int p):a1(p) {};
int a1;
};
class B: public A
{
public:
virtual void foo1() { printf("in B::foo1()/n"); };
virtual void foo2() { printf("in B::foo2()/n"); }
virtual void foo3() { printf("in B::foo2()/n"); }
virtual void foo4() { printf("in B::foo2()/n"); }
public:
virtual ~B() {}
public:
B():b1('B') {};
B(int p):b1(p) {};
int b1;
};
/**
* This function is not thread-safe.
*/
char * getSymbol(char * file, int address)
{
char *cmd = (char *)malloc(100);
static char buf[100];
FILE *ptr;
memset(buf,'/0',sizeof (buf));buf[0]='/n';
sprintf(cmd,"nm -C -x %s | grep /"%x|0x/" | awk -F//| '{print $8}'",file, address);
if ((ptr = popen(cmd, "r")) != NULL)
fgets(buf, BUFSIZ, ptr);
free(cmd);
(void) pclose(ptr);
return buf;
}
int main(int argc, char * argv[])
{
#define X B
X d;
int * p = (int *)&d;
int size = sizeof (X)/4;
//printf("this=0x%x,sizeof=%d*4 bytes/n",p,size);
for (int i=0;i<size;i++)
{
printf("this[0x%x]=0x%x/t: %s",i*4,*(p+i),getSymbol(argv[0],*(p+i)));
}
printf("/n");
int * vtbl = (int *)(*p);
for (int i=0;(((*(vtbl+i)) != 0));i++)
{
printf("vtbl[0x%x]=0x%x/t: %s", i*4,(*(vtbl+i)),getSymbol(argv[0],*(vtbl+i)));
}
//sleep(100);
}
- Content of C++ vtbl
- 虚表vtbl
- Table of Content
- Structure of Content Provider
- !!!Table of Content
- sed invalid content of \{\}
- The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,c
- The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,c
- The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,c
- Hibernate配置文件报错:The content of element type "session-factory" must match "(property*,mapping*,(c
- The content of element type "session-factory" must match "(property*,mapping*,(class-cache| c
- the table of content-type
- TOC(Table of Content)数据结构
- C++ content of std::string
- Flash of Unstyled Content (FOUC)
- Flash of Unstyled Content (FOUC)
- Flash of Unstyled Content (FOUC)
- Flash of Unstyled Content (FOUC)
- tips 一些小东西
- TX早晚会有报应
- C运算溢出怎么办?
- 大学宿舍出现频率最高的N句话
- 有点失落
- Content of C++ vtbl
- 用C++设计一个不能被继承的类
- JAVA数组
- 网页中Flash播放器里的视频获取的方法
- 一个女生,一个男生,一段爱情
- 互联网进化断代史第零纪--奇点纪
- Linux内核bridge中的数据包处理流程
- 17种正则表达式 asp
- VB解析英文压缩短信