/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
impl ProcessReader { pubfn copy_null_terminated_string(&self, address: usize) -> Result<CString, ReadError> { // Try copying the string word-by-word first, this is considerably // faster than one byte at a time. iflet Ok(string) = self.copy_null_terminated_string_word_by_word(address) { return Ok(string);
}
// Reading the string one word at a time failed, let's try again one // byte at a time. It's slow but it might work in situations where the // string alignment causes word-by-word access to straddle page // boundaries. letmut length = 0; letmut string = Vec::<u8>::new();
// SAFETY: If we reach this point we've read at least one byte and we // know that the last one we read is nul.
Ok(unsafe { CString::from_vec_with_nul_unchecked(string) })
}
loop { let array = self.copy_array::<u8>(address + length, WORD_SIZE)?; let null_terminator = array.iter().position(|&e| e == 0);
length += null_terminator.unwrap_or(WORD_SIZE);
string.extend(array.into_iter());
if null_terminator.is_some() {
string.truncate(length + 1); break;
}
}
// SAFETY: If we reach this point we've read at least one byte and we // know that the last one we read is nul.
Ok(unsafe { CString::from_vec_with_nul_unchecked(string) })
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-18)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.