unsigned int ChangeProtection(const unsigned int ulAddr, const unsigned int ulLength, const unsigned int ulMode )
{
int iRtn;
unsigned int ulLastPageEnd;
unsigned int ulFirstPageStart;
/* Find the start address of the page to which the adress belongs to */
ulFirstPageStart = ulAddr - (ulAddr % 4096);
ulLastPageEnd = ulAddr + ulLength;
ulLastPageEnd += 4096 - (ulLastPageEnd % 4096);
iRtn = mprotect((void*)ulFirstPageStart, ulLastPageEnd - ulFirstPageStart, ulMode );
//iRtn = mprotect((void*)ulFirstPageStart, 4096, ulMode );
if (0 != iRtn)
{
printf("\r\nCall mprotect fail!\n");
return FALSE;
}
return TRUE;
}
使用上述代码修改内存空间 ulAddr开始,长度为 ulLength的一段空间的读写权限,有问题吗?
vfdff 于 2010-08-21 01:35:11发表:
1# vfdff
程序做微笑调整、
if (TRUE != mprotect((void*)ulFirstPageStart, ulLastPageEnd - ulFirstPageStart, ulMode ))
{
return FALSE;
}
yanlong938 于 2010-08-20 10:03:30发表:
看不太懂。。。
qtsmy 于 2010-08-20 08:27:52发表:
帮顶