pub fn sys_object_set_property(
        &mut self,
        handle_value: HandleValue,
        property: u32,
        buffer: usize,
        buffer_size: usize,
    ) -> ZxResult {
        let property = Property::try_from(property).map_err(|_| ZxError::INVALID_ARGS)?;
        info!(
            "object.set_property: handle={:#x?}, property={:?}, buffer=({:#x}; {:#x?})",
            handle_value, property, buffer, buffer_size
        );
        let proc = self.thread.proc();
        let object = proc.get_dyn_object_with_rights(handle_value, Rights::SET_PROPERTY)?;
        match property {
            Property::Name => {
                let length = buffer_size.min(MAX_NAME_LEN) as usize;
                let s = UserInPtr::<u8>::from(buffer).read_string(length)?;
                object.set_name(&s);
                Ok(())
            }
            Property::ProcessDebugAddr => {
                let addr = UserInPtr::<usize>::from_addr_size(buffer, buffer_size)?.read()?;
                proc.get_object_with_rights::<Process>(handle_value, Rights::SET_PROPERTY)?
                    .set_debug_addr(addr);
                Ok(())
            }
            #[cfg(target_arch = "x86_64")]
            Property::RegisterFs => {
                let thread = proc.get_object::<Thread>(handle_value)?;
                let fsbase = UserInPtr::<usize>::from_addr_size(buffer, buffer_size)?.read()?;
                thread.set_fsbase(fsbase)?;
                Ok(())
            }
            #[cfg(target_arch = "x86_64")]
            Property::RegisterGs => {
                let thread = proc.get_object::<Thread>(handle_value)?;
                let gsbase = UserInPtr::<usize>::from_addr_size(buffer, buffer_size)?.read()?;
                thread.set_gsbase(gsbase)?;
                Ok(())
            }
            Property::ProcessBreakOnLoad => {
                let addr = UserInPtr::<usize>::from_addr_size(buffer, buffer_size)?.read()?;
                proc.get_object_with_rights::<Process>(handle_value, Rights::SET_PROPERTY)?
                    .set_dyn_break_on_load(addr);
                Ok(())
            }
            Property::SocketRxThreshold => {
                let threshold = UserInPtr::<usize>::from_addr_size(buffer, buffer_size)?.read()?;
                proc.get_object::<Socket>(handle_value)?
                    .set_read_threshold(threshold)
            }
            Property::SocketTxThreshold => {
                let threshold = UserInPtr::<usize>::from_addr_size(buffer, buffer_size)?.read()?;
                proc.get_object::<Socket>(handle_value)?
                    .set_write_threshold(threshold)
            }
            Property::VmoContentSize => {
                let content_size =
                    UserInPtr::<usize>::from_addr_size(buffer, buffer_size)?.read()?;
                proc.get_object::<VmObject>(handle_value)?
                    .set_content_size(content_size)
            }
            Property::ExceptionState => {
                let state = UserInPtr::<u32>::from_addr_size(buffer, buffer_size)?.read()?;
                proc.get_object_with_rights::<ExceptionObject>(handle_value, Rights::SET_PROPERTY)?
                    .set_state(state)?;
                Ok(())
            }
            Property::ExceptionStrategy => {
                let strategy = UserInPtr::<u32>::from_addr_size(buffer, buffer_size)?.read()?;
                proc.get_object_with_rights::<ExceptionObject>(handle_value, Rights::SET_PROPERTY)?
                    .set_strategy(strategy)?;
                Ok(())
            }
            _ => {
                warn!("unknown property");
                Err(ZxError::INVALID_ARGS)
            }
        }
    }
/// Set various properties of various kernel objects.
Set various properties of various kernel objects.
Set various properties of various kernel objects .
pub fn sys_object_set_property(
        &mut self,
        handle_value: HandleValue,
        property: u32,
        buffer: usize,
        buffer_size: usize,
    ) -> ZxResult {
        let property = Property::try_from(property).map_err(|_| ZxError::INVALID_ARGS)?;
        info!(
            "object.set_property: handle={:#x?}, property={:?}, buffer=({:#x}; {:#x?})",
            handle_value, property, buffer, buffer_size
        );
        let proc = self.thread.proc();
        let object = proc.get_dyn_object_with_rights(handle_value, Rights::SET_PROPERTY)?;
        match property {
            Property::Name => {
                let length = buffer_size.min(MAX_NAME_LEN) as usize;
                let s = UserInPtr::<u8>::from(buffer).read_string(length)?;
                object.set_name(&s);
                Ok(())
            }
            Property::ProcessDebugAddr => {
                let addr = UserInPtr::<usize>::from_addr_size(buffer, buffer_size)?.read()?;
                proc.get_object_with_rights::<Process>(handle_value, Rights::SET_PROPERTY)?
                    .set_debug_addr(addr);
                Ok(())
            }
            #[cfg(target_arch = "x86_64")]
            Property::RegisterFs => {
                let thread = proc.get_object::<Thread>(handle_value)?;
                let fsbase = UserInPtr::<usize>::from_addr_size(buffer, buffer_size)?.read()?;
                thread.set_fsbase(fsbase)?;
                Ok(())
            }
            #[cfg(target_arch = "x86_64")]
            Property::RegisterGs => {
                let thread = proc.get_object::<Thread>(handle_value)?;
                let gsbase = UserInPtr::<usize>::from_addr_size(buffer, buffer_size)?.read()?;
                thread.set_gsbase(gsbase)?;
                Ok(())
            }
            Property::ProcessBreakOnLoad => {
                let addr = UserInPtr::<usize>::from_addr_size(buffer, buffer_size)?.read()?;
                proc.get_object_with_rights::<Process>(handle_value, Rights::SET_PROPERTY)?
                    .set_dyn_break_on_load(addr);
                Ok(())
            }
            Property::SocketRxThreshold => {
                let threshold = UserInPtr::<usize>::from_addr_size(buffer, buffer_size)?.read()?;
                proc.get_object::<Socket>(handle_value)?
                    .set_read_threshold(threshold)
            }
            Property::SocketTxThreshold => {
                let threshold = UserInPtr::<usize>::from_addr_size(buffer, buffer_size)?.read()?;
                proc.get_object::<Socket>(handle_value)?
                    .set_write_threshold(threshold)
            }
            Property::VmoContentSize => {
                let content_size =
                    UserInPtr::<usize>::from_addr_size(buffer, buffer_size)?.read()?;
                proc.get_object::<VmObject>(handle_value)?
                    .set_content_size(content_size)
            }
            Property::ExceptionState => {
                let state = UserInPtr::<u32>::from_addr_size(buffer, buffer_size)?.read()?;
                proc.get_object_with_rights::<ExceptionObject>(handle_value, Rights::SET_PROPERTY)?
                    .set_state(state)?;
                Ok(())
            }
            Property::ExceptionStrategy => {
                let strategy = UserInPtr::<u32>::from_addr_size(buffer, buffer_size)?.read()?;
                proc.get_object_with_rights::<ExceptionObject>(handle_value, Rights::SET_PROPERTY)?
                    .set_strategy(strategy)?;
                Ok(())
            }
            _ => {
                warn!("unknown property");
                Err(ZxError::INVALID_ARGS)
            }
        }
    }
pub fn sys_object_set_property ( & mut self , handle_value : HandleValue , property : u32 , buffer : usize , buffer_size : usize , ) -> ZxResult { let property = Property :: try_from ( property ) . map_err ( | _ | ZxError :: INVALID_ARGS ) ? ; info ! ( " " handle_value property buffer buffer_size ) ; let proc = self . thread . proc ( ) ; let object = proc . get_dyn_object_with_rights ( handle_value , Rights :: SET_PROPERTY ) ? ; match property { Property :: Name => { let length = buffer_size . min ( MAX_NAME_LEN ) as usize ; let s = UserInPtr :: < u8 > :: from ( buffer ) . read_string ( length ) ? ; object . set_name ( & s ) ; Ok ( ( ) ) } Property :: ProcessDebugAddr => { let addr = UserInPtr :: < usize > :: from_addr_size ( buffer , buffer_size ) ? . read ( ) ? ; proc . get_object_with_rights :: < Process > ( handle_value , Rights :: SET_PROPERTY ) ? . set_debug_addr ( addr ) ; Ok ( ( ) ) } # [ cfg ( target_arch " " ) ] Property :: RegisterFs => { let thread = proc . get_object :: < Thread > ( handle_value ) ? ; let fsbase = UserInPtr :: < usize > :: from_addr_size ( buffer , buffer_size ) ? . read ( ) ? ; thread . set_fsbase ( fsbase ) ? ; Ok ( ( ) ) } # [ cfg ( target_arch " " ) ] Property :: RegisterGs => { let thread = proc . get_object :: < Thread > ( handle_value ) ? ; let gsbase = UserInPtr :: < usize > :: from_addr_size ( buffer , buffer_size ) ? . read ( ) ? ; thread . set_gsbase ( gsbase ) ? ; Ok ( ( ) ) } Property :: ProcessBreakOnLoad => { let addr = UserInPtr :: < usize > :: from_addr_size ( buffer , buffer_size ) ? . read ( ) ? ; proc . get_object_with_rights :: < Process > ( handle_value , Rights :: SET_PROPERTY ) ? . set_dyn_break_on_load ( addr ) ; Ok ( ( ) ) } Property :: SocketRxThreshold => { let threshold = UserInPtr :: < usize > :: from_addr_size ( buffer , buffer_size ) ? . read ( ) ? ; proc . get_object :: < Socket > ( handle_value ) ? . set_read_threshold ( threshold ) } Property :: SocketTxThreshold => { let threshold = UserInPtr :: < usize > :: from_addr_size ( buffer , buffer_size ) ? . read ( ) ? ; proc . get_object :: < Socket > ( handle_value ) ? . set_write_threshold ( threshold ) } Property :: VmoContentSize => { let content_size = UserInPtr :: < usize > :: from_addr_size ( buffer , buffer_size ) ? . read ( ) ? ; proc . get_object :: < VmObject > ( handle_value ) ? . set_content_size ( content_size ) } Property :: ExceptionState => { let state = UserInPtr :: < u32 > :: from_addr_size ( buffer , buffer_size ) ? . read ( ) ? ; proc . get_object_with_rights :: < ExceptionObject > ( handle_value , Rights :: SET_PROPERTY ) ? . set_state ( state ) ? ; Ok ( ( ) ) } Property :: ExceptionStrategy => { let strategy = UserInPtr :: < u32 > :: from_addr_size ( buffer , buffer_size ) ? . read ( ) ? ; proc . get_object_with_rights :: < ExceptionObject > ( handle_value , Rights :: SET_PROPERTY ) ? . set_strategy ( strategy ) ? ; Ok ( ( ) ) } _ => { warn ! ( " " ) ; Err ( ZxError :: INVALID_ARGS ) } } }
Set various properties of various kernel objects.
Set various properties of various kernel objects .
&mut self
handle_value
HandleValue
property
u32
buffer
usize
buffer_size
usize
&mut self
handle_value
HandleValue
property
u32
buffer
usize
buffer_size
usize