VM-Exit Interruption-Information的结构struct构建和读取

#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);
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值