读IDTR与GDTR的值

转自油条智辅论坛

#include "stdafx.h"
#include <Windows.h>


int _tmain(int argc, _TCHAR* argv[])
{
	char idtr[6]={0};
    char gdtr[6]={0};
	SetThreadAffinityMask(GetCurrentThread(),1);
    __asm
	{
		sidt idtr
		sgdt gdtr
	}
	printf("idt limit is %.4x,base is %.8x\n",*(unsigned short *)idtr,*(unsigned int *)(idtr+2));
	printf("gdt limit is %.4x,base is %.8x\n",*(unsigned short *)gdtr,*(unsigned int *)(gdtr+2));
	SetThreadAffinityMask(GetCurrentThread(),2);
	__asm
	{
		sidt idtr
		sgdt gdtr
	}
	printf("idt limit is %.4x,base is %.8x\n",*(unsigned short *)idtr,*(unsigned int *)(idtr+2));
	printf("gdt limit is %.4x,base is %.8x\n",*(unsigned short *)gdtr,*(unsigned int *)(gdtr+2));
	return 0;
}


SetThreadAffinityMask设置使用多核CPU的哪个核心

你可能感兴趣的:(读IDTR与GDTR的值)