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

Method ReadULEB128

view/sharedcache/core/VirtualMemory.cpp:183–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183uint64_t VirtualMemoryReader::ReadULEB128(size_t cursorLimit)
184{
185 uint64_t result = 0;
186 int bit = 0;
187 uint64_t offset;
188 auto mapping = m_memory->GetRegionAtAddress(m_cursor, offset);
189 auto fileLimit = offset + (cursorLimit - m_cursor);
190 auto fa = mapping->fileAccessor.lock();
191 auto* fileBuff = (uint8_t*)fa->Data();
192 do
193 {
194 if (offset >= fileLimit)
195 return -1;
196 uint64_t slice = ((uint64_t*)&((fileBuff)[offset]))[0] & 0x7f;
197 if (bit > 63)
198 return -1;
199 else
200 {
201 result |= (slice << bit);
202 bit += 7;
203 }
204 } while (((uint64_t*)&(fileBuff[offset++]))[0] & 0x80);
205 // TODO: There has got to be a better way to prevent this...
206 fa->Data(); // prevent deallocation of the fileAccessor as we're operating on the raw data buffer
207 return result;
208}
209
210int64_t VirtualMemoryReader::ReadSLEB128(size_t cursorLimit)
211{

Callers

nothing calls this directly

Calls 3

GetRegionAtAddressMethod · 0.80
DataMethod · 0.80
lockMethod · 0.45

Tested by

no test coverage detected