|
#include <windows.h>
#include <stdio.h>
//申请一个页面边界的内存(添加一个新的段)
#pragma section("data_seg",read,write)
__declspec(allocate("data_seg"))DWORD var = 1;
DWORD out = 0;
void __declspec(naked) IdtEntry()
{
//__asm
//{
// push 0x30;
// pop fs;
//}
__asm
{
mov eax, var;
mov DWORD ptr ds : [out], eax;
iretd;
}
//__asm
//{
// push 0x3b;
// pop fs;
// iretd;
//}
}
//eq 8003f600 0040ee00`00081014
void go()
{
__asm
{
int 0x40;
}
}
int main(int argc, char* argv[])
{
printf("IdtEntry:%x\r\n", (DWORD)IdtEntry);
if ((DWORD)IdtEntry != 0x00401000)
{
printf("funaddr faild\r\n");
return -1;
}
printf("var:%x\r\n", &var);
getchar();
go();
printf("out:%x\r\n", out);
return 0;
}
代码就是在一个页边界申请了一个变量,然后去访问这个变量,其实这个变量是没有挂 PTE的,也就是说执行 mov eax, var; 的时候会触发0E中断,按道理是会修复,不会修复的话,按道理会报错,但是也没有? 就比较好奇 |
|