保护模式(九):挂物理页

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

DWORD* buf;

void __declspec(naked) Test(){
    __asm{
        pushad
        pushfd
    }
    *(unsigned __int64*)(((0x0000>>9)&0x7FFFF8)+0xC0000000)=*(unsigned __int64*)((((DWORD)buf>>9)&0x7FFFF8)+0xC0000000);
    __asm{
        popfd
        popad
        iretd
    }
}

int main(int argc, char* argv[])
{
    buf=(DWORD*)VirtualAlloc(NULL,0x1000,MEM_COMMIT,PAGE_EXECUTE_READWRITE);
    for(int i=0;i<100;i++){
        *(buf+i)=(DWORD)(buf+i);
    }
    printf("%x\n",(DWORD)Test);
    getchar();
    __asm int 0x20
    for(i=0;i<100;i++)
        printf("%x\n",*((DWORD*)0x0000+i));
    getchar();
    return 0;
}

 

posted @ 2020-12-24 20:22  Harmonica11  阅读(165)  评论(0编辑  收藏  举报