MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / ReadNullTermString

Method ReadNullTermString

view/sharedcache/core/MappedFileAccessor.cpp:22–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22std::string MappedFileAccessor::ReadNullTermString(size_t address, const size_t maxLength) const
23{
24 if (address > Length())
25 return "";
26 // If we are not given a maxLength (i.e. -1) than we will set the max address to the length of the file.
27 const size_t maxAddr = (maxLength != -1) ? std::min(address + maxLength, Length()) : Length();
28 // Read a null-terminated string manually to avoid errors related to string length on Linux.
29 std::string str;
30 str.reserve(140);
31 for (size_t currAddr = address; currAddr < maxAddr; ++currAddr)
32 {
33 char c = m_file._mmap[currAddr];
34 if (c == '\0')
35 break;
36 str += c;
37 }
38 str.shrink_to_fit();
39 return str;
40}
41
42uint8_t MappedFileAccessor::ReadUInt8(size_t address) const
43{

Callers 2

ReadCStringMethod · 0.80
FromFileMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected