bool PCProcess::setMemoryAccessRights(Address start, size_t size, PCMemPerm rights) { mal_printf("setMemoryAccessRights to %s [%lx %lx]\n", rights.getPermName().c_str(), start, start+size); assert(!"Not implemented yet"); return false; }
void PCProcess::changeMemoryProtections(Address addr, size_t size, PCMemPerm rights, bool setShadow) { PCMemPerm oldRights; unsigned pageSize = getMemoryPageSize(); Address pageBase = addr - (addr % pageSize); size += (addr % pageSize); // Temporary: set on a page-by-page basis to work around problems // with memory deallocation for (Address idx = pageBase, idx_e = pageBase + size; idx < idx_e; idx += pageSize) { mal_printf("setting rights to %s for [%lx %lx)\n", rights.getPermName().c_str(), idx , idx + pageSize); if (!pcProc_->setMemoryAccessRights(idx, pageSize, rights, oldRights)) { mal_printf("ERROR: failed to set access rights " "for page %lx, %s[%d]\n", addr, FILE__, __LINE__); } else if (isMemoryEmulated() && setShadow) { Address shadowAddr = 0; PCMemPerm shadowRights; bool valid = false; boost::tie(valid, shadowAddr) = getMemEm()->translate(idx); if (!valid) { mal_printf("WARNING: set access rights on page %lx that has " "no shadow %s[%d]\n",addr,FILE__,__LINE__); } else { if(!pcProc_->setMemoryAccessRights(shadowAddr, pageSize, rights, shadowRights)) { mal_printf("ERROR: failed to set access rights " "for page %lx, %s[%d]\n", shadowAddr, FILE__, __LINE__); } if (shadowRights != oldRights) { mal_printf("WARNING: shadow page[%lx] rights %s did not " "match orig-page [%lx] rights %s\n", shadowAddr, shadowRights.getPermName().c_str(), addr, oldRights.getPermName().c_str()); } } } } }