在VC6中如何知道内联函数是否展开了?
解决方案 »
- 问一下 IP协议中 IHL的长度
- 招一C++程序员, 写一进销存软件
- 请问如何将两个对话框程序合并到一起
- 一个问题,大家帮我啊
- 已经用ICommandText::SetCommandText设置了查询语句,但是ICommand::Execute返回说DB_E_NOCOMMAND...
- csdn现在注册只用200分好像以前有2000分(不够用)
- C进制转换和组合的问题
- 求助,有一个加密解密类,怎样通过对象序列化制作密钥文件
- 怎么获得cpu的频率?inter的和amd的都要
- 不过我显示完这条,还想接着"printf",用上面的函数还好使吗?不用关心什么HDC坐标吧?纯字符
- 奇怪,关于钩子的一个问题
- 基础题目
__forceinline
DWORD test1( void )
{
CONTEXT c;
RtlCaptureContext( &c );
return c.Eip;
}DWORD test2( void )
{
CONTEXT c;
RtlCaptureContext( &c );
return c.Eip;
}int _tmain(int argc, _TCHAR* argv[])
{
CONTEXT c1, c2;
DWORD dwEip; RtlCaptureContext( &c1 );
dwEip = test1();
RtlCaptureContext( &c2 );
if ( dwEip >= c1.Eip && dwEip <= c2.Eip )
{
cout << "test1 is a inline function." << endl;
}
else
{
cout << "test1 is a non-inline function." << endl;
} RtlCaptureContext( &c1 );
dwEip = test2();
RtlCaptureContext( &c2 );
if ( dwEip >= c1.Eip && dwEip <= c2.Eip )
{
cout << "test2 is a inline function." << endl;
}
else
{
cout << "test2 is a non-inline function." << endl;
}
system( "pause" );
return 0;
}
函数内部的eip是通过返回值传出的。如果你不想改动函数的返回值,可以将函数内部的CONTEXT放到全局域里,结果是一样的。
CONTEXT g_c;
__forceinline
int test1( void )
{
cout << "test1 called" << endl;
RtlCaptureContext( &g_c );
return 0;
}
int test2( void )
{
cout << "test2 called" << endl;
RtlCaptureContext( &g_c );
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
CONTEXT c1, c2;
RtlCaptureContext( &c1 );
test1(); // 调用测试函数1
RtlCaptureContext( &c2 );
if ( g_c.Eip >= c1.Eip && g_c.Eip <= c2.Eip )
{
cout << "test1 is a inline function." << endl;
}
else
{
cout << "test1 is a non-inline function." << endl;
}
RtlCaptureContext( &c1 );
test2(); // 调用测试函数2
RtlCaptureContext( &c2 );
if ( g_c.Eip >= c1.Eip && g_c.Eip <= c2.Eip )
{
cout << "test2 is a inline function." << endl;
}
else
{
cout << "test2 is a non-inline function." << endl;
}
system( "pause" );
return 0;
}
输出结果:test1 called
test1 is a inline function.
test2 called
test2 is a non-inline function.
请按任意键继续. . .