// Construct Call Gate pointing to Ring0 proc and write it there
DWORD addr=(DWORD)Ring0; CALL_GATE g={addr&0xffff,8,1,0,12,3,1,addr>>16}; Virtual(gdtr.base+gate*8, &g,8,9);
// Quite ugly way to do far call
WORD farcall[3]={0,0,(gate<<3)}; char* param=0,**p=¶m; long result=0;
// Switch from Ring 3 to Ring 0 is just normal call ;)
__asm push p
__asm call fword ptr [farcall] //0x004ebd55 处未处理的异常: 0xC0000005: 读取位置 0xffffffff 时发生访问冲突
__asm mov result, eax
// Cleanup Call Gate from GDT
__int64 c=0; Virtual(gdtr.base+gate*8, &c,8,9);