コード例 #1
0
ファイル: images.cpp プロジェクト: jessicah/haiku-private
/*!	This function will change the protection of all read-only segments to really
	be read-only (and executable).
	The areas have to be read/write first, so that they can be relocated.
	If at least one image is in compatibility mode then we allow execution of
	all areas.
*/
void
remap_images()
{
    for (image_t* image = sLoadedImages.head; image != NULL;
            image = image->next) {
        for (uint32 i = 0; i < image->num_regions; i++) {
            // we only need to do this once, so we remember those we've already
            // mapped
            if ((image->regions[i].flags & RFLAG_REMAPPED) != 0)
                continue;

            status_t result = B_OK;
            if ((image->regions[i].flags & RFLAG_RW) == 0) {
                result = _kern_set_area_protection(image->regions[i].id,
                                                   B_READ_AREA | B_EXECUTE_AREA);
            } else if (image->abi < B_HAIKU_ABI_GCC_2_HAIKU) {
                result = _kern_set_area_protection(image->regions[i].id,
                                                   B_READ_AREA | B_WRITE_AREA | B_EXECUTE_AREA);
            }

            if (result == B_OK)
                image->regions[i].flags |= RFLAG_REMAPPED;
        }
    }
}
コード例 #2
0
void
__set_stack_protection(void)
{
	if (__gABIVersion < B_HAIKU_ABI_GCC_2_HAIKU) {
		area_info info;
		ssize_t cookie = 0;

		while (get_next_area_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
			if ((info.protection & B_STACK_AREA) != 0) {
				_kern_set_area_protection(info.area,
					B_READ_AREA | B_WRITE_AREA | B_EXECUTE_AREA | B_STACK_AREA);
			}
		}
	}
}
コード例 #3
0
ファイル: images.cpp プロジェクト: mariuz/haiku
/*!	This function will change the protection of all read-only segments to really
	be read-only.
	The areas have to be read/write first, so that they can be relocated.
*/
void
remap_images()
{
	for (image_t* image = sLoadedImages.head; image != NULL;
			image = image->next) {
		for (uint32 i = 0; i < image->num_regions; i++) {
			if ((image->regions[i].flags & RFLAG_RW) == 0
				&& (image->regions[i].flags & RFLAG_REMAPPED) == 0) {
				// we only need to do this once, so we remember those we've already mapped
				if (_kern_set_area_protection(image->regions[i].id,
						B_READ_AREA | B_EXECUTE_AREA) == B_OK) {
					image->regions[i].flags |= RFLAG_REMAPPED;
				}
			}
		}
	}
}
コード例 #4
0
status_t
set_area_protection(area_id id, uint32 protection)
{
	return _kern_set_area_protection(id, protection);
}