第一题
#include <cstdio>
#include <windows.h>
DWORD gPDE = 0;
DWORD gPTE = 0;
char segment[] = {
0,0,0,0,0x48,0 };
一个获取线性地址PDE和PTE的裸函数,利用带一个参数的调用门
void _declspec(naked) _stdcall
MyReadMemory() {
_asm {
int 3
mov ecx,[esp+8]
push 0x30
pop fs
pushad
pushfd
xor eax,eax
mov eax,ecx
shr eax,0x14
and eax,0xffc
sub eax,0x3fd00000
mov eax,[eax]
mov gPDE,eax
xor eax,eax
mov eax,ecx
shr eax,0xa
and eax,0x3ffffc
sub eax,0x40000000
mov eax,[eax]
mov gPTE,eax
popfd
popad
retf 4
}
}
题目函数实现,其实没什么难度,就是在拷贝内存前判断一下地址是否,无效地址直接提示后返回即可,判断依据是PDE和PTE的低2位有效位,即P位和R/W位
BOOL ReadVirtualMemory(PVOID lineaddr, PVOID outbuf, UINT32 size) {
DWORD PageOffset = (DWORD)lineaddr &