| 181 | } |
| 182 | |
| 183 | uint64_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 | |
| 210 | int64_t VirtualMemoryReader::ReadSLEB128(size_t cursorLimit) |
| 211 | { |
nothing calls this directly
no test coverage detected