#include<iostream>
using namespace std;
typedef struct _Int_info
{
unsigned vector :8;
unsigned int_type :3;
unsigned error_code :1;
unsigned NMI_unblock :1;
unsigned Reserved :18;
unsigned valid :1;
}IntInfo,*pIntInfo;
void ShowStruct(pIntInfo info)
{
cout<<"中断或异常向量为 : "<<info->vector<<endl;
cout<<"中断类型 : "<<info->int_type;
switch (info->int_type)
{
case 0:cout<<" 外部中断;"<<endl;break;
case 1:cout<<" 保留;"<<endl;break;
case 2:cout<<" 非屏蔽中断;"<<endl;break;
case 3:cout<<" 硬件异常;"<<endl;break;
case 4:cout<<" 软件中断;"<<endl;break;
case 5:cout<<" 特权软件异常;"<<endl;break;
case 6:cout<<" 软件异常;"<<endl;break;
case 7:cout<<" 保留;"<<endl;break;
default :cout<<" 错误;"<<endl;
}
cout<<"错误代码 : "<<info->error_code;
if(info->error_code)
{
cout<<" 有错误代码传递,可参考VMCS中的VM Entry exception error code;"<<endl;
}
else
{
cout<<" 无错误代码传递;"<<endl;
}
cout<<"NMI是否由IRET引起 : "<<info->NMI_unblock<<((info->NMI_unblock==1)?" 由IRET引发;":" 不是由IRET引发;")<<endl;
cout<<"检测合法性 : "<<info->valid;
if(info->valid)
{
cout<<" 合法;"<<endl;
}
else
{
cout<<" 不合法;"<<endl;
}
}
int main()
{
unsigned long info=0x80000E06;
cout<<"-----------------------------------------------------"<<endl;
cout<<"---------VM-Exit Interruption-Information------------"<<endl;
cout<<"- 0000 0000 0000 0000 0000 0 000 0000 0000 -"<<endl;
cout<<"- _ - - ___ _________ -"<<endl;
cout<<"- 31 12 11 10-8 7-0 -"<<endl;
cout<<"- 位31 : 合法位 -"<<endl;
cout<<"- 位12 : NMI Unblocking 是否有IRET引发 -"<<endl;
cout<<"- 位11 : 错误代码传递(0=不传递,1=传递) -"<<endl;
cout<<"- 位10:8 : 中断类型 -"<<endl;
cout<<"- 位7:0 : 中断或异常向量 -"<<endl;
cout<<"-----------------------------------------------------"<<endl;
ShowStruct((pIntInfo)&info);
}
VM-Exit Interruption-Information的结构struct构建和读取
最新推荐文章于 2019-12-13 10:03:46 发布